Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate normalized GeoJSON #113

Open
sribna opened this issue Jan 26, 2020 · 3 comments · May be fixed by #149
Open

Generate normalized GeoJSON #113

sribna opened this issue Jan 26, 2020 · 3 comments · May be fixed by #149

Comments

@sribna
Copy link

sribna commented Jan 26, 2020

Readme says I can use toJson() method to get a GeoJSON string

$point = new Point(40.7484404, -73.9878441);
$point->toJson();

// {
//   "type": "Feature",
//   "properties": {},
//   "geometry": {
//     "type": "Point",
//     "coordinates": [
//       -73.9878441,
//       40.7484404
//     ]
//   }
// }

In reality it returns {"type":"Point","coordinates":[-73.9878441,40.7484404]} whish is't a valid GeoJson format

Maybe add toGeoJson method?

@Glutamat42
Copy link

Additionaly it would be nice if we could use the properties field eg by defining a variable in our model to specify columns which will be added to the properties field

@grimzy
Copy link
Owner

grimzy commented Mar 6, 2020

@sribna thank you for reporting this.
You're absolutely right, the documentation is inaccurate: toJson() actually returns the geometry part of the Feature.

Adding toGeoJson() and updating the documentation sounds like a good idea.

@grimzy
Copy link
Owner

grimzy commented Mar 6, 2020

@Glutamat42, also a good suggestion!

Any suggestion(s) on the implementation?

limenet added a commit to limenet/laravel-mysql-spatial that referenced this issue Oct 1, 2020
@limenet limenet linked a pull request Oct 1, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants