We initially encountered the following GeoServer issue:
- a layer in Lambert EPSG:31370
- a wms/GetFeatureInfo request with a bbox specified in Pseudo-Mercator EPSG:3857
when zoomed in on a feature, the feature is not returned. The reason appeared to be a faulty reprojection in the geotools renderer. So I discovered the following
- The MercatorHandlerFactory specifies a valid area with Double.Min and Double.Max as MinX and MaxX
- The ProjectionHandler.transformEnvelope attempts to transform this valid area to the target CRS
- This breaks because these are not valid X values for Mercator (should be between -180 and 180), throwing an IllegalArgumentException
- ProjectionHandler falls back to a transformation via WGS84 in the exception handler, but this fall-back transformation gives faulty result for very small areas.
For example, the envelope 381033.2707188717 : 381046.4083331082, 6583847.177786637 : 6583860.315400874
is transformed in 83378.41827628673,164601.17577413842,83386.84499185604,164609.5804206347
while it actually should be 83304.59570855058,164573.9584101988,83313.02253560493,164582.36316849105
an area that doesn't even intersect!
Interesting remark: older versions of geoserver (at least version 10) gave the correct result, because the transformation of the valid area did not appear to throw an exception on the faulty X coordinates