django-leaflet icon indicating copy to clipboard operation
django-leaflet copied to clipboard

weird New Zeland polygons

Open thrownblown opened this issue 8 years ago • 3 comments

So I have been using this for several years without any problems, and recently I have had issue with polygons drawn over NZ in that the multi_polygon.contains should come back as true but are not.

I looked at the map and I noticed there were two New Zealands if I zoomed out far enough, and more if I scrolled horizontally. So when I drew some squares over all the different NZ's and when inspected the resulting polygons gave some weird numbers back:

example good poly (Pdb) self.cleaned_data['zone_polygon'].geojson u'{ "type": "MultiPolygon", "coordinates": [ [ [ [ 161.3671875, -49.610709938074216 ], [ 161.3671875, -32.54681317351514 ], [ 182.109375, -32.54681317351514 ], [ 182.109375, -49.610709938074216 ], [ 161.3671875, -49.610709938074216 ] ] ] ] }'

below are bad polygon examples

(Pdb) self.cleaned_data['zone_polygon'].geojson u'{ "type": "MultiPolygon", "coordinates": [ [ [ [ -918.984375, -50.06419173665909 ], [ -918.984375, -35.746512259918497 ], [ -841.9921875, -35.746512259918497 ], [ -841.9921875, -50.06419173665909 ], [ -918.984375, -50.06419173665909 ] ] ] ] }'

(Pdb) self.cleaned_data['zone_polygon'].geojson u'{ "type": "MultiPolygon", "coordinates": [ [ [ [ -196.171875, -47.754097979680019 ], [ -196.171875, -34.307143856288029 ], [ -177.1875, -34.307143856288029 ], [ -177.1875, -47.754097979680019 ], [ -196.171875, -47.754097979680019 ] ] ] ] }'

i checked the version that i'm using: django-leaflet==0.18.1

was this been addressed in an update? is there some easy geo-math to fix this?

thrownblown avatar Sep 30 '17 04:09 thrownblown

You shouldn't have longitude below -180 or above 180. How did you create those polygons ?

Gagaro avatar Oct 04 '17 07:10 Gagaro

there's multiple new zealands on the map

thrownblown avatar Feb 14 '18 00:02 thrownblown

Take a look at https://github.com/Leaflet/Leaflet/issues/1885

Gagaro avatar Feb 14 '18 08:02 Gagaro