Skip to content

Generate normalized GeoJSON #113

Open
@sribna

Description

@sribna

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?

Activity

Glutamat42

Glutamat42 commented on Feb 27, 2020

@Glutamat42

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

grimzy commented on Mar 6, 2020

@grimzy
Owner

@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

grimzy commented on Mar 6, 2020

@grimzy
Owner

@Glutamat42, also a good suggestion!

Any suggestion(s) on the implementation?

added a commit that references this issue on Oct 1, 2020
086b012
linked a pull request that will close this issue on Oct 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @grimzy@Glutamat42@sribna

      Issue actions

        Generate normalized GeoJSON · Issue #113 · grimzy/laravel-mysql-spatial