From: Martin D. <mar...@ge...> - 2006-09-29 00:43:18
|
Hyink, Jeffrey (LCDR) a écrit : > I've had a handful of classes that have implemented the Geodetic > Calculator to compute distances that have worked fine for a few months. > On recent runs, I started getting a stack of errors when instantiating > the calculator to the same CRS that I was using before. I need a few more informations: * Which Geotools version are you using? * How did you get the JARs (download from Sourceforge, built with Maven, etc.)? * Which Geotools JAR are in your classpath? > WARNING: Unavailable authority factory: European Petroleum Survey Group > org.opengis.referencing.FactoryException: Failed to connect to the EPSG database. > > [...snip...] > > at org.geotools.referencing.FactoryFinder.getCoordinateOperationFactory(FactoryFinder.java:280) > at org.geotools.referencing.GeodeticCalculator.<init>(GeodeticCalculator.java:292) This is a warning, it should not be a fatal error (does your program stopped to run?). However this is not yet clear to me why this warning occurs. In the above case, failure to connect to the EPSG database means that coordinate operations may be less accurate than they could be, but Geotools should still be able to fallback on some more approximative coordinate operations. > calculator = new GeodeticCalculator(); > > Is the previous constructor invoking a factory that is connecting to > something? No, it should not connect to any database. > I don't think I altered any other code that would have > involved this error. Did you changed your classpath? Or do you have an EPSG database installed on you system (for example de database in MS-Access format downloaded from www.epsg.org) with a new setting? > Also, for my own knowledge/testing purposes, is there a way to get an > instance of various CRS's? Right now, I'm pulling them from shapefile > .prj files, but is there a way to generate an instance with a static > reference of some kind? You have a choice: If you know the EPSG code (for example "EPSG:4326"), then you can use the following convenience method (CRS is a convenience class documented here): http://javadoc.geotools.fr/2.3/org/geotools/referencing/CRS.html CoordinateReferenceSystem myCRS = CRS.decode("EPSG:4326"); Or if you have the CRS definition as a Well Known Text (WKT), you can use the following convenience method: CoordinateReferenceSystem myCRS = CRS.parseWKT(...); You can also build the CRS programmatically, but this require more code and knowledge. Martin |