Timeline for Openlayers getExtent() returns wrong values when the dataset crosses the dateline
Current License: CC BY-SA 4.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 15, 2019 at 22:26 | vote | accept | Falcoa | ||
May 15, 2019 at 22:12 | comment | added | Mike | Yes, I set a a geojson with a polygon either side of the data line and got a similar result to you, but running the transform below in OpenLayers gives the result you were expecting without having to edit the geojson. | |
May 15, 2019 at 22:07 | comment | added | Falcoa | The longitudes in the geojson are all between -180 and 180. The thing is that the coordinates in Chatham are -176.5 and those in NZ south island are 169.5 (for example). So, when calculating the extent, I get awkward values. @Mike, do you think that converting all coordinates to fit the range 0-360 will fix the problem? | |
May 15, 2019 at 21:55 | comment | added | Falcoa | The longitudes in the geojson are all between -180 and 180. | |
May 15, 2019 at 15:11 | answer | added | Mike | timeline score: 3 | |
May 15, 2019 at 10:37 | comment | added | Mike | If I use a geojson with coordinates in the non-standard format 183.4 (i.e. wrapped across the date line) the extent reflects that. But if your geojson contains normalised coordinates e.g. -176.5 the extent being returned by OpenLayers is correct - but features will be repeated each time the map wraps the date line so see a copy of the Chatham Islands outside that extent. To calculate the smallest (wrapped) extent you would need to either update the geojson or run a transform on all the feature coordinates (to change the range to 0 to 360) in OpenLayers. | |
May 15, 2019 at 6:38 | history | asked | Falcoa | CC BY-SA 4.0 |