you will want to send questions to geotools-users email list; see the website for details.
On Mon, Mar 15, 2010 at 9:24 PM, VeNüsschen <[email protected]> wrote: > > Hello there, > > i am currently playing around with GeoTools' latest version and i am trying > to create a SimpleFeatureType "Location" with the properties "location" of > class "Point" and "name" of class "String" - just like in your examples. > After creating them i wanted to instantiate 2 objects of this Type and store > them in my PostGIS database. > > I have run the following code, but the line > "featureStore.addFeatures(collection);" threw me an exception: > > > *SNIPP* > DataStore dataStore = null; > try { > dataStore =DataStoreFinder.getDataStore(params); > } catch (IOException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > /////////////////////////////////////////////////////// > > DataStoreFactorySpi dataStoreFactory = new > ShapefileDataStoreFactory(); > > /////////////// CREATE THE FEATURE TYPE > ///////////////////////////////////// > FeatureCollection<SimpleFeatureType, SimpleFeature> collection > = > FeatureCollections.newCollection(); > > SimpleFeatureTypeBuilder builder = new > SimpleFeatureTypeBuilder(); > builder.setName( "Location" ); > builder.setCRS( CRS.decode("EPSG:4326") ); > builder.add( "Location", Point.class ); > builder.add( "Name", String.class ); > > SimpleFeatureType TYPE = builder.buildFeatureType(); > > GeometryFactory geometryFactory = > JTSFactoryFinder.getGeometryFactory(null); > > > SimpleFeatureBuilder featureBuilder = new > SimpleFeatureBuilder(TYPE); > > double longitude = 12; > double latitude = 110; > String name = "Somewhere over the rainbow"; > > Point point = geometryFactory.createPoint(new > Coordinate(longitude, > latitude)); > > featureBuilder.add(point); > featureBuilder.add(name); > SimpleFeature feature1 = > featureBuilder.buildFeature("feature1"); > > > longitude = 66; > latitude = 66; > name = "Hell"; > > Point point2 = geometryFactory.createPoint(new > Coordinate(longitude, > latitude)); > > featureBuilder.add(point); > featureBuilder.add(name); > SimpleFeature feature2 = > featureBuilder.buildFeature("feature2"); > > collection.add(feature1); > collection.add(feature2); > > > /////////////////////////////////////////////////////////////////////////// > > Transaction transaction = new DefaultTransaction("create"); > > > > > > try { > //dataStore.createSchema(TYPE); > FeatureStore<SimpleFeatureType, SimpleFeature> > featureStore = > (FeatureStore<SimpleFeatureType, SimpleFeature>) > ((DataStore) > dataStore).getFeatureSource("Location"); > > featureStore.addFeatures(collection); //<- throws the > exception > } catch (IOException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > *SNIPP* > > > The stack trace looks like that: > > > *SNIPP* > org.geotools.data.jdbc.JDBCTextFeatureWriter doInsert > SCHWERWIEGEND: SQL Exception writing geometry columnFEHLER: neue Zeile für > Relation »Location« verletzt Check-Constraint »enforce_geotype_location« > org.postgresql.util.PSQLException: FEHLER: neue Zeile für Relation > »Location« verletzt Check-Constraint »enforce_geotype_location« > at > org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2062) > at > org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1795) > at > org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257) > at > org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479) > at > org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:353) > at > org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:299) > at > org.apache.commons.dbcp.DelegatingStatement.executeUpdate(DelegatingStatement.java:228) > at > org.geotools.data.jdbc.JDBCTextFeatureWriter.doInsert(JDBCTextFeatureWriter.java:121) > at > org.geotools.data.jdbc.JDBCFeatureWriter.write(JDBCFeatureWriter.java:217) > at > org.geotools.data.InProcessLockingManager$1.write(InProcessLockingManager.java:335) > at > org.geotools.data.jdbc.JDBCFeatureStore.addFeatures(JDBCFeatureStore.java:385) > at test.test.App.main(App.java:124) > 15.03.2010 11:05:54 org.geotools.data.jdbc.JDBCFeatureWriter close > WARNUNG: Feature writer calling close when queryData is already closed > org.geotools.data.DataSourceException: SQL Exception writing geometry > columnFEHLER: neue Zeile für Relation »Location« verletzt Check-Constraint > »enforce_geotype_location« > at > org.geotools.data.jdbc.JDBCTextFeatureWriter.doInsert(JDBCTextFeatureWriter.java:134) > at > org.geotools.data.jdbc.JDBCFeatureWriter.write(JDBCFeatureWriter.java:217) > at > org.geotools.data.InProcessLockingManager$1.write(InProcessLockingManager.java:335) > at > org.geotools.data.jdbc.JDBCFeatureStore.addFeatures(JDBCFeatureStore.java:385) > at test.test.App.main(App.java:124) > Caused by: org.postgresql.util.PSQLException: FEHLER: neue Zeile für > Relation »Location« verletzt Check-Constraint »enforce_geotype_location« > at > org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2062) > at > org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1795) > at > org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257) > at > org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479) > at > org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:353) > at > org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:299) > at > org.apache.commons.dbcp.DelegatingStatement.executeUpdate(DelegatingStatement.java:228) > at > org.geotools.data.jdbc.JDBCTextFeatureWriter.doInsert(JDBCTextFeatureWriter.java:121) > ... 4 more > > *SNIPP* > > I have googled the "enforce_geotype_location" have looked into several > tutorials about storing data, but anything i trie doesnt change the result > of executing this snippet of code. > > Can anybody tell me, what i am doing wrong please? > > Thanks in advance! :) > Björn > -- > View this message in context: > http://old.nabble.com/Constraint-%C2%BBenforce_geotype_location%C2%AB-violated...-tp27902410p27902410.html > Sent from the geotools - dev mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > > ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Geotools-gt2-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
