laravel-mysql-spatial
laravel-mysql-spatial copied to clipboard
Generate normalized GeoJSON
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?
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
@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.
@Glutamat42, also a good suggestion!
Any suggestion(s) on the implementation?