Geoserver continuous map wrapping!

Recently one of our clients has provided us with the funding to address an issue with the Geoserver rendering core module that was preventing us 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.

Our specific use case is also quite challenging on its own since we need to use 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 GeoServer was performing point by point reprojections, therefore when a point was crossing the dateline the modular math used kicked in trasforming +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 do some work at the GeoTools level, modifying the renderer. 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 and GeoServer 1.7.7 and 2.0.1. On the development versions of the two seoftware the tweak is automatically applied while on the other side for the stable versions you need to specify two JVM options:

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