-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
I came across this while using Leaflet.draw, but it is really an issue with compatibility between the L.Polygon class and the GeoJSON spec.
The GeoJSON polygon spec (http://geojson.org/geojson-spec.html#polygon) is supposed to consist of a LinearRing, described thus:
A LinearRing is closed LineString with 4 or more positions. The first and last positions are equivalent (they represent equivalent points). Though a LinearRing is not explicitly represented as a GeoJSON geometry type, it is referred to in the Polygon geometry type definition.
Since the L.Polygon does not create a last point the same as the first, exporting those coords to GeoJSON creates invalid objects which are rejected by applications which do implement the spec properly (ie: GeoDjango).
As a corollary, importing valid GeoJSON objects creates polygons with a hidden additional 4th marker for the last identical point. This isn't a problem until you start editing the shapes using tools like Leaflet.Draw and then you end up with weird appendages such as this one:
If I were better as javascript, I would have submitted this with a pull request. My suggestion is to modify the L.Polygon to require, create, and account for this last point and that only has markers for all but the last point.
Of course, if easy compatibility with GeoJSON is not a priority, then it's not a problem at all. Just wanted to bring it to your attention.
