International Date Line – Understanding the Wrap Around in GeoServer

antimeridiangeoserveropenlayers-2wfs

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.

enter image description here

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?

Best Answer

Reproject your map to use a projection which is split at the Greenwich meridian (or elsewhere) so that the polygons you are interested in don't cross the discontinuity in your map.