Hello developers,
I'm about to port our project *from GeoTools 2.7.1 to 8.0* (and if
successful, to 8.4 soon).
While switching the relevant jar's to 8.0, I'm encountering following
exception:
org.opengis.referencing.FactoryException: Geotools extension required for
"getIdentifiedObjectFinder" operation.
at
org.geotools.referencing.factory.AuthorityFactoryAdapter.getGeotoolsFactory(AuthorityFactoryAdapter.java:493)
at
org.geotools.referencing.factory.AuthorityFactoryAdapter.access$000(AuthorityFactoryAdapter.java:72)
at
org.geotools.referencing.factory.AuthorityFactoryAdapter$Finder.<init>(AuthorityFactoryAdapter.java:992)
at
org.geotools.referencing.factory.AuthorityFactoryAdapter.getIdentifiedObjectFinder(AuthorityFactoryAdapter.java:979)
at
org.geotools.referencing.factory.FallbackAuthorityFactory$Finder.ensureFallback(FallbackAuthorityFactory.java:937)
at
org.geotools.referencing.factory.FallbackAuthorityFactory$Finder.findIdentifier(FallbackAuthorityFactory.java:965)
at
org.geotools.referencing.factory.ManyAuthoritiesFactory$Finder.findIdentifier(ManyAuthoritiesFactory.java:869)
at
org.geotools.referencing.factory.ThreadedAuthorityFactory$Finder.findIdentifier(ThreadedAuthorityFactory.java:1098)
at org.geotools.referencing.CRS.lookupIdentifier(CRS.java:996)
at
org.geotools.geojson.feature.FeatureJSON.createCRS(FeatureJSON.java:425)
at
org.geotools.geojson.feature.FeatureJSON.writeCRS(FeatureJSON.java:404)
at
org.geotools.geojson.feature.FeatureJSON.toString(FeatureJSON.java:477)
at
org.geotools.geojson.feature.FeatureJSON$FeatureEncoder.toJSONString(FeatureJSON.java:510)
at
org.geotools.geojson.feature.FeatureJSON$FeatureEncoder.toJSONString(FeatureJSON.java:581)
at
org.geotools.geojson.feature.FeatureJSON.writeFeature(FeatureJSON.java:224)
at
org.geotools.geojson.feature.FeatureJSON.toString(FeatureJSON.java:248)
at de.joaobelem.GeoInterface.writeGeoJSON(GeoInterface.java:1011)
...
I've found a solution and I am willing to share it in order to get a deeper
insight into the backgrounds.
Please let me explain the environment subsequently:
In our project, we build a FeatureJSON to be stringified into GeoJSON
format. This is achieved by the SimpleFeatureTypeBuilder, given a CRS and a
geometry. By using the returned SimpleFeature, it's possible to pass it to
the toString(..) method of FeatureJSON like this:
/FeatureJSON fjson = new FeatureJSON();
SimpleFeature feature = ...
String geojson = fjson.toString(feature); // (this is the entry point into
GeoTools, given by the above stack trace)/
This workflow works perfektly in GeoTools 2.7.1!
For gt-referencing-8.0 in class ManyAuthoritiesFactory inside its inner
class Finder, the line
/final String id = finder.findIdentifier(object);/
does not return the String "CRS:84" for the given CRS code "EPSG:4326" (in
our kind of jar configuration).
Instead, *CartesianAuthorityFactory* is unsuccessfully used to identify the
projection code, resulting in a *NoSuchAuthorityCodeException* in:
/org.geotools.referencing.factory.AuthorityFactoryAdapter.getGeotoolsFactory(..)/
We have following jar's in our project:
gt-api-8.0.jar
gt-epsg-wkt-8.0.jar
gt-geojson-8.0.jar
gt-main-8.0.jar
gt-metadata-8.0.jar
gt-opengis-8.0.jar
gt-referencing-8.0.jar
commons-*.jar
jdom-1.0.jar
json_simple-1.1.jar
jsr-275-1.0-beta-2.jar
jts-1.12.jar
postgis-jdbc-jts-1.1.6.jar
postgresql-9.0-801.jdbc4.jar
vecmath-1.3.2.jar
First I thought some kind of plugin was not added as jar, so I tried
gt-epsg-postgresql-8.0.jar which turned out to be build for JDBC3,
therefore incompatible with our JDBC4 environment.
Then I debugged the use of authority factories in the relevant part and
realized that the *CartesianAuthorityFactory in GeoTools 8.x* is used where
in contrast *WebCRSFactory in GeoTools 2.7.x* was used before. Finally I
read about the
*META-INF/service/org.opengis.referencing.crs.CRSAuthorityFactory* file in
gt-referencing jar and also about the possibility to change the order of the
registered factories.
However, when modifying
META-INF/service/org.opengis.referencing.crs.CRSAuthorityFactory file in
gt-referencing jar by commenting out the line
*#org.geotools.referencing.factory.epsg.CartesianAuthorityFactory*
WebCRSFactory is successfully used again to identify the projection code.
I am also interessed in learing how to order the available authority
factories programmatically before trying to stringyfy our SimpleFeature's.
Could someone please explaint it for me? I'd really appreciate it.
Thanks,
João
--
View this message in context:
http://osgeo-org.1560.n6.nabble.com/order-of-authority-factories-causes-exception-in-CRS-lookupIdentifier-tp5019323.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Keep yourself connected to Go Parallel:
INSIGHTS What's next for parallel hardware, programming and related areas?
Interviews and blogs by thought leaders keep you ahead of the curve.
http://goparallel.sourceforge.net
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users