From: Georg W. <wal...@un...> - 2011-08-23 10:57:25
|
Hi, I'm trying to parse a gml2 Input and write it into a postgis database. Actually, the geometries are written into the database. Despite, the coordinatereferencesystem which is set to "null" parsing the gml input. I'm using gt-8.0-M0 but tried gt.2.7.2 as well: Here's my code: GML gml = new GML(Version.GML2); SimpleFeatureIterator iter = null; ... iter = gml.decodeFeatureIterator(in); ... while( iter.hasNext() ){ feature = iter.next(); boundary =String.valueOf(feature.getDefaultGeometry()); try { st.execute("INSERT INTO "+ this.areaTable +"(SELECT ST_GeomFromeWKT('"+boundary+"'));"); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } here is an example gml input: ... <gml:featureMember> <esdl:areatable_4326 fid="areatable_4326.fid--13a66ae6_131d31af140_1e03"> <esdl:population>0</esdl:population> <esdl:boundary><gml:Polygon srsName="http://www.opengis.net/gml/srs/epsg.xml#4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates decimal="." cs="," ts=" ">9.77231662,53.54352298 9.77253859,53.54464077 9.77310543,53.54778347 9.77359133,53.55005718 ... .9.79152979,53.53654956 9.78886511,53.53764245 9.77834135,53.54153606 9.77327413,53.54288067 9.77231662,53.54352298</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon> </esdl:boundary> </esdl:areatable_4326> </gml:featureMember> ... Actually, I'm able to parse all attributes and properties but the coordinatereferencesytem. It also works on different inputs the same way. I tried: feature.getDefaultGeometryProperty().getDescriptor().getCoordinateReferenceSystem() feature.getType().getCoordinateReferenceSystem() com.vividsolutions.jts.geom.Polygon polygon = (com.vividsolutions.jts.geom.Polygon)feature.getDefaultGeometry(); polygon.getSRID(); but they all return "null" as coordinate reference system although the geometries itself are inherited Further the console prints some output which might lead to the solution of my problem but didn't really help me so far: 23.08.2011 10:55:59 org.geotools.referencing.factory.epsg.ThreadedEpsgFactory <init> INFO: Setting the EPSG factory org.geotools.referencing.factory.epsg.DefaultFactory to a 1800000ms timeout 23.08.2011 10:55:59 org.geotools.referencing.factory.epsg.ThreadedEpsgFactory <init> INFO: Setting the EPSG factory org.geotools.referencing.factory.epsg.ThreadedHsqlEpsgFactory to a 1800000ms timeout 23.08.2011 10:55:59 org.geotools.referencing.factory.epsg.ThreadedHsqlEpsgFactory createDataSource INFO: Building new data source for org.geotools.referencing.factory.epsg.ThreadedHsqlEpsgFactory 23.08.2011 10:55:59 org.geotools.referencing.factory.epsg.ThreadedHsqlEpsgFactory createBackingStore INFO: Building backing store for org.geotools.referencing.factory.epsg.ThreadedHsqlEpsgFactory 23.08.2011 10:55:59 org.geotools.referencing.factory.epsg.ThreadedHsqlEpsgFactory createBackingStore INFO: Creating cached EPSG database version 7.5.0. This operation may take a few minutes... 23.08.2011 10:56:00 org.geotools.referencing.factory.epsg.ThreadedEpsgFactory <init> INFO: Setting the EPSG factory org.geotools.referencing.factory.epsg.DefaultFactory to a 1800000ms timeout 23.08.2011 10:56:00 org.geotools.referencing.factory.epsg.ThreadedEpsgFactory <init> INFO: Setting the EPSG factory org.geotools.referencing.factory.epsg.ThreadedHsqlEpsgFactory to a 1800000ms timeout 23.08.2011 10:56:00 org.geotools.referencing.factory.epsg.ThreadedEpsgFactory <init> INFO: Setting the EPSG factory org.geotools.referencing.factory.epsg.DefaultFactory to a 1800000ms timeout 23.08.2011 10:56:00 org.geotools.referencing.factory.epsg.ThreadedEpsgFactory <init> INFO: Setting the EPSG factory org.geotools.referencing.factory.epsg.ThreadedHsqlEpsgFactory to a 1800000ms timeout 23.08.2011 10:56:00 org.geotools.referencing.factory.epsg.ThreadedEpsgFactory <init> INFO: Setting the EPSG factory org.geotools.referencing.factory.epsg.DefaultFactory to a 1800000ms timeout 23.08.2011 10:56:00 org.geotools.referencing.factory.epsg.ThreadedEpsgFactory <init> INFO: Setting the EPSG factory org.geotools.referencing.factory.epsg.ThreadedHsqlEpsgFactory to a 1800000ms timeout What am I missing in my Code? Are there any further Classes and Methods I need to call? Regards, Georg -- Dipl. Geograph Georg Walenciak Chair of GIScience Department of Geography, University of Heidelberg wal...@un... http://giscience.uni-hd.de Berliner Straße 48, D-69120 Heidelberg, Germany fon: +49(0)6221 / 54 5573 // fax: +49(0)6221 / 54 4996 |