I'm trying to define a custom projection by parsing a Wkt string. I mistakenly developed my test app against gt2-referencing, gt2-main and gt2-geometry from Maven and it worked. I believe the latest versions for these dependencies are from 2008(!).
When I switched to using version 17.0 of gt-referencing, gt-main and gt-geometry from Maven instead, I get an exception when I run my test app. The full exception text is:
Apr 20, 2017 2:33:43 PM org.geotools.factory.FactoryRegistry scanForPlugins
WARNING: Can't load a service for category "MathTransformProvider". Cause is "ServiceConfigurationError: org.geotools.referencing.operation.MathTransformProvider: Provider org.geotools.referencing.operation.projection.AzimuthalEquidistant$Provider could not be instantiated".
java.util.ServiceConfigurationError: org.geotools.referencing.operation.MathTransformProvider: Provider org.geotools.referencing.operation.projection.AzimuthalEquidistant$Provider could not be instantiated
at java.util.ServiceLoader.fail(ServiceLoader.java:232)
at java.util.ServiceLoader.access$100(ServiceLoader.java:185)
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:384)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
at org.geotools.factory.FactoryRegistry.register(FactoryRegistry.java:826)
at org.geotools.factory.FactoryRegistry.scanForPlugins(FactoryRegistry.java:772)
at org.geotools.factory.FactoryRegistry.scanForPluginsIfNeeded(FactoryRegistry.java:805)
at org.geotools.factory.FactoryRegistry.getServiceProviders(FactoryRegistry.java:196)
at org.geotools.referencing.operation.DefaultMathTransformFactory.getProvider(DefaultMathTransformFactory.java:282)
at org.geotools.referencing.operation.DefaultMathTransformFactory.getDefaultParameters(DefaultMathTransformFactory.java:316)
at org.geotools.referencing.wkt.Parser.parseProjection(Parser.java:603)
at org.geotools.referencing.wkt.Parser.parseProjCS(Parser.java:917)
at org.geotools.referencing.wkt.Parser.parseCoordinateReferenceSystem(Parser.java:225)
at org.geotools.referencing.wkt.Parser.parseCoordinateReferenceSystem(Parser.java:204)
at org.geotools.referencing.factory.ReferencingObjectFactory.createFromWKT(ReferencingObjectFactory.java:1090)
at projection.TestCustomProjection.main(TestCustomProjection.java:64)
Caused by: java.lang.NoSuchFieldError: LONGITUDE_OF_CENTRE
at org.geotools.referencing.operation.projection.AzimuthalEquidistant$Provider.<clinit>(AzimuthalEquidistant.java:432)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:380)
... 14 more
I guess the key text here is:
Provider org.geotools.referencing.operation.projection.AzimuthalEquidistant$Provider could not be instantiated"
The code in question is pretty simple but I'll include it here for completeness:
CoordinateReferenceSystem targetCRS = targetCRS = factory.createFromWKT(s);
I'm not sure if I'm missing a dependency from Maven, but I don't think so as the AzimuthalEquidistant class is in the gt-referencing dependency.
The funny thing is, the code continues to run and successfully completes otherwise. The output is reported as a "WARNING" so I can probably ignore it. But I'm curious why the "warning" occurs, even though the code should be available in the compiled JAR.
I am adding my custom project string. This is an early test application so I'm ok with using hard coded values:
private static final String REFERENCE_SYSTEM = "PROJCS[\"WGS 84 / CYUL Local TM\"," + " GEOGCS[\"WGS 84\","
+ " DATUM[\"World Geodetic System 1984\","
+ " SPHEROID[\"WGS 84\", 6378137.0, 298.257223563, AUTHORITY[\"EPSG\",\"7030\"]],"
+ " AUTHORITY[\"EPSG\",\"6326\"]]," + " PRIMEM[\"Greenwich\", 0.0, AUTHORITY[\"EPSG\",\"8901\"]],"
+ " UNIT[\"degree\", 0.017453292519943295]," + " AXIS[\"Geodetic longitude\", EAST],"
+ " AXIS[\"Geodetic latitude\", NORTH]," + " AUTHORITY[\"EPSG\",\"4326\"]],"
+ " PROJECTION[\"Transverse Mercator\", AUTHORITY[\"EPSG\",\"9807\"]],"
+ " PARAMETER[\"central_meridian\", -73.736055]," + " PARAMETER[\"longitude_of_origin\", -73.736055],"
+ " PARAMETER[\"latitude_of_origin\", 45.470006667]," + " PARAMETER[\"scale_factor\", 1.0],"
+ " PARAMETER[\"false_easting\", 0.0]," + " PARAMETER[\"false_northing\", 0.0]," + " UNIT[\"m\", 1.0],"
+ " AXIS[\"Easting\", EAST]," + " AXIS[\"Northing\", NORTH]," + " AUTHORITY[\"EPSG\",\"3997\"]]";
What may I have missed?
LONGITUDE_OF_CENTRE
which GeoTools doesn't recognise