[geotk] Finding a CRS code/URN from a CoordinateReferenceSystem
object
Martin Desruisseaux
martin.desruisseaux at geomatys.fr
Thu Jun 18 14:35:40 EDT 2009
Hello
Calum.Byrom at tessella.com a écrit :
> I've been trying to get this to work but have hit some problems. If I
> try running without the backend DB, and do:
>
> crsCode = CRS.lookupIdentifier(null, crs, true);
>
> (i.e. with a null Citation - since I'm not sure what this needs to be
> set to) then I get back a code - although this is the same code that can
> be found via
>
> crs.getName().getCode()
>
> - so I guess it's just doing a default fall back on this?
The current implementation is to look at this crs.getName().getCode() first, and
only if there is nothing found there, look in the database.
If the value returned by crs.getName().getCode() is something else than
"EPSG:xxxx" and the value for the Citation argument is Citations.EPSG, then the
method should realize that the code is not appropriate and looks in the database.
> If I use the simpler interface, i.e.:
>
> crsCode = CRS.lookupIdentifier(crs, true);
>
> then this returns only nulls.
Could you post the output of crs.toString() please? It would help to see what is
going on. Also, do you noticed a slight delay during the execution of the above
method (something long enough to suggest that a search is actually running,
something like 1 or 2 seconds).
> I then tried adding the supporting DBs by including the jar files on the
> classpath - I tried the following two:
>
> *epsg-wkt-2.5-SNAPSHOT.jar*
> - produces identical results to before
>
> *epsg-hsql-2.5-SNAPSHOT.jar *- which requires the hsql.jar too (although
> this isn't actually specified anywhere).
> - this only runs occasionally - usually falling over with a StackOverflow:
>
> java.lang.StackOverflowError
> (...snip...)
> at org.geotoolkit.referencing.factory.DatumAliases.createPrimeMeridian(DatumAliases.java:605)
> at org.geotools.referencing.factory.DatumAliases.createPrimeMeridian(DatumAliases.java:572)
> at org.geotoolkit.referencing.factory.DatumAliases.createPrimeMeridian(DatumAliases.java:605)
> at org.geotoolkit.referencing.factory.DatumAliases.createPrimeMeridian(DatumAliases.java:605)
> at org.geotools.referencing.factory.DatumAliases.createPrimeMeridian(DatumAliases.java:572)
The stack trace shows a mix of Geotools and Geotoolkit. Because the factories
are registered as "plugins", each project has detected the factory of the other
project and try to use it, which is apparently causing confusion here.
I will investigate this bug (I would like those two projects to be able to live
together). In the main time it is safer to make sure that your classpath
contains the JAR of only one project (GeoTools or Geotoolkit) and avoid putting
both of them on the same classpath.
In order to use the EPSG database with Geotoolkit, try to put the following JAR
on your classpath:
- geotk-epsg.jar
- derby-10.4.2.0.jar
I have put a first draft of documentation there. I will try to complete it
progressively according the questions or comments:
http://www.geotoolkit.org/modules/referencing/geotk-epsg/index.html
Please let me known if it is any better.
Martin
More information about the Geotoolkit
mailing list