Open GML local file

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Open GML local file

alcesgabbo
Hi everybody.

I tried to open a GML local file (I tried with different GML local files ) using GeoTools (the same used in Udig) with this code:


public static void main(String[] args) {
    try{
    //create the parser with the gml 3.0 configuration
    org.geotools.xml.Configuration configuration = new org.geotools.gml3.GMLConfiguration();
    org.geotools.xml.Parser parser = new org.geotools.xml.Parser( configuration );

    //the xml instance document above
   InputStream xml = new FileInputStream("result2.gml");

     SimpleFeatureCollection fc = (SimpleFeatureCollection) parser.parse( xml );
      MapContext map = new DefaultMapContext();
      map.setTitle("Quickstart");
      map.addLayer(fc, null);

      // Now display the map
      JMapFrame.showMap(map);
    }catch(Exception e){
        e.printStackTrace();
    }
}}

but it returns these exceptions:


2-nov-2011 18.08.28 org.geotools.referencing.factory.epsg.ThreadedPostgreSQLEpsgFactory isAvailable
AVVERTENZA: Unavailable authority factory: European Petroleum Survey Group
org.opengis.referencing.FactoryException: Failed to connect to the EPSG database.
    at org.geotools.referencing.factory.epsg.ThreadedEpsgFactory.createBackingStore(ThreadedEpsgFactory.java:441)
    at org.geotools.referencing.factory.DeferredAuthorityFactory.getBackingStore(DeferredAuthorityFactory.java:133)
    at org.geotools.referencing.factory.BufferedAuthorityFactory.isAvailable(BufferedAuthorityFactory.java:235)
    at org.geotools.referencing.factory.DeferredAuthorityFactory.isAvailable(DeferredAuthorityFactory.java:119)
    at org.geotools.factory.FactoryRegistry.isAvailable(FactoryRegistry.java:667)
    at org.geotools.factory.FactoryRegistry.isAcceptable(FactoryRegistry.java:501)
    at org.geotools.factory.FactoryRegistry$1.filter(FactoryRegistry.java:192)
    at javax.imageio.spi.FilterIterator.advance(Unknown Source)
    at javax.imageio.spi.FilterIterator.<init>(Unknown Source)
    at javax.imageio.spi.ServiceRegistry.getServiceProviders(Unknown Source)
    at org.geotools.factory.FactoryRegistry.getServiceProviders(FactoryRegistry.java:197)
    at org.geotools.referencing.ReferencingFactoryFinder.getFactories(ReferencingFactoryFinder.java:178)
    at org.geotools.referencing.ReferencingFactoryFinder.getCRSAuthorityFactories(ReferencingFactoryFinder.java:453)
    at org.geotools.referencing.DefaultAuthorityFactory.getBackingFactory(DefaultAuthorityFactory.java:88)
    at org.geotools.referencing.DefaultAuthorityFactory.<init>(DefaultAuthorityFactory.java:69)
    at org.geotools.referencing.CRS.getAuthorityFactory(CRS.java:251)
    at org.geotools.referencing.CRS.decode(CRS.java:489)
    at org.geotools.referencing.CRS.decode(CRS.java:417)
    at org.geotools.gml2.bindings.GML2ParsingUtils.crs(GML2ParsingUtils.java:332)
    at org.geotools.gml3.bindings.GML3ParsingUtils.crs(GML3ParsingUtils.java:90)
    at org.geotools.gml3.bindings.AbstractGeometryTypeBinding.parse(AbstractGeometryTypeBinding.java:96)
    at org.geotools.xml.impl.ParseExecutor.visit(ParseExecutor.java:155)
    at org.geotools.xml.impl.BindingWalker$BindingExecutionChain.execute(BindingWalker.java:220)
    at org.geotools.xml.impl.BindingWalker.walk(BindingWalker.java:186)
    at org.geotools.xml.impl.ElementHandlerImpl.endElement(ElementHandlerImpl.java:233)
    at org.geotools.xml.impl.ParserHandler.endElement(ParserHandler.java:628)
    at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.geotools.xml.Parser.parse(Parser.java:238)
    at org.geotools.xml.Parser.parse(Parser.java:166)
    at testGML.mainAPP2.main(mainAPP2.java:28)
Caused by: org.postgresql.util.PSQLException: FATAL: password authentication failed for user "Geotools"
    at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:291)
    at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:108)
    at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66)
    at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:125)
    at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
    at org.postgresql.jdbc3.Jdbc3Connection.<init>(Jdbc3Connection.java:24)
    at org.postgresql.Driver.makeConnection(Driver.java:393)
    at org.postgresql.Driver.connect(Driver.java:267)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at org.postgresql.ds.common.BaseDataSource.getConnection(BaseDataSource.java:87)
    at org.postgresql.ds.common.BaseDataSource.getConnection(BaseDataSource.java:70)
    at org.geotools.referencing.factory.epsg.DirectEpsgFactory.getConnection(DirectEpsgFactory.java:3174)
    at org.geotools.referencing.factory.epsg.ThreadedEpsgFactory.createBackingStore(ThreadedEpsgFactory.java:436)
    ... 36 more

Why there are problems?

Alberto

_______________________________________________
udig-users mailing list
[hidden email]
http://lists.refractions.net/mailman/listinfo/udig-users