GeoTools

OSGeo

Wednesday, February 24, 2010

GeoTools continuous map wrapping

Recently the GeoTools team under GeoSolutions' funding has addressed an issue with the rendering module that was preventing users from drawing polygons crossing the dateline change, or, to put it another way, to be able to have maps that were wrapping like continuous wrapped maps from Google.


As an example specific use case involved the use of a projection in which the dateline change has been moved away from the usual -180/+180 by using a non standard central meridian
The result, prior to the work described here, does not look so good across the discontinuity, as shown below


Bad results when crossing the dateline


The problem was that our renderer was performing point by point reprojections, therefore when a point was crossing the dateline the modular math we used kicked in, transforming +181 -> -179. This meant that the next point, when crossing the dateline, was moved to the other side of the world.


In order to perform proper processing of projection singularities and dateline wrapping on selected projections, in particular, Mercator, Transverse Mercator, and flat geographic, we have had to modify the renderer in its projection handling part. The outcome is that we finally have obtained seamless wrapping maps similar to the Google ones, as shown here:


Continents Oracle layer with EPSG:3329
Continents layer from Oracle datastore in EPSG:3329


Continents Oracle layer with EPSG:90013
Continents layer from Oracle datastore in EPSG:90013


You can try this work yourself starting from GeoTools 2.5.x and above. On the development versions of the two software the tweak is automatically applied while on the other side for the stable versions you need to specify two JVM options:
-DADVANCED_PROJECTION_ HANDLING=true
-DUSE_STREAMING_RENDERER=true

A big thanks goes to Andrea Aime who has been hired for the implementation of this feature.