Using OpenLayers, I added a WFS layer (on GeoServer) with a filter that returns all features (black) that intersect my polygon (yellow) placed over some Latin American countries within certain dates.
However, the feature that crosses horizontally across the map does NOT actually intersect my polygon. This feature is somewhere in the pacific ocean between Hawaii and Fiji and NOT in Latin America. The problem is that instead of crossing the International Date Line it is being rendered on the map by wrapping around the whole world.
The problamatic feature is defined:
POLYGON((-179.700417 14.202717,-178.687422 13.992875,179.024138 8.24716,-179.98241 8.035567,-179.700417 14.202717))
I have many of problematic date line features like this but have narrowed it down to this one for this example. I can't just ignore it in my application because I have many of them.
I've tried using "wrapDateLine: true" in base layer and WFS layer with same results.
Not sure if this would be a GeoServer problem or an OpenLayers problem.
Does anyone know a solution to my international date line problem?
Answer
Unfortunately this is a known problem. The issue is that geometries that cross the date line like this are ambiguous. The OL and GeoServer renderers have no easy way of knowing that the intention is to go the "short" way around the world so they just interpret for instance 170 to -170 the "regular" way and go the long way around the world.
Unfortunately there is no good solution for this except to split up your geometries that lie across the dateline.
No comments:
Post a Comment