Closed dhauverNS closed 5 years ago
Thanks feel free to submit a patch
Unfortunately, I don't currently have capacity to work on developing a fix. Due to this bug, I ended up using the https://github.com/locationtech/proj4j library instead. However, I thought that the maintainers of this library and other potential users might at least want to be aware of this bug's existence. Sorry I can't provide further help at this time.
Thank you for the precise report, The recursion problem should be solved by this PR. Anyway, the situation with NAD83 is a bit complex. Usually, in CTS, the transformation from a datum to another is defined in the source datum. For large areas, when transformation parameters are not unique, CTS can use a grid based transformation, but currently, it only supports NTv2 format, not NADCON. For this reason, toWGS84 parameter of NAD83 has been left to null in the library (NAD83 is supposed to be the old original NAD83). That was leading to the infinite recursion problem. There was another problem : as the CRS was initialized with nad83 it had no toWGS84 parameter associated (parameters from the ESRI definition for this CRS was ignored. Now, if toWGS84 is part of the CRS definition (as it is in the ESRI file ), it can override the null parameter associated to nad83 in the core library.
Fixed thanks a lot to @mukoki
If a GeodeticDatum doesn't have a default transformation to WGS84 defined, a call to its getGeocentricTransformations method will infinitely recurse when GeodeticDatum.WGS84 is passed in as a parameter. For example:
GeodeticDatum.NAD83.getGeocentricTransformations(GeodeticDatum.WGS84);
The recursion happens on GeodeticDatum line 453:
if (!getGeocentricTransformations(GeodeticDatum.WGS84).isEmpty() &&
This manifests itself when CoordinateOperationFactory#createCoordinateOperations is called to try to obtain the coordinate operations for transforming coordinates from a projection using the NAD83 or NAD87 datums to one which is using the WGS84 datum.
I discovered this when trying to project from an Albers Equal Area projection to the EPSG:3857 web mercator projection. I used the following parameters, obtained from Esri's proj4 projections available at https://github.com/Esri/projection-engine-db-doc/blob/master/proj4/esri