Hi,
I am a bit helpless, how to write a feature to a postgis datastore.
I managed to read, but not to write.
For simplicity I show my example code for deleting a feature from the
database.
public static void main(String[] args) throws Exception {
Map params = new HashMap();
params.put("dbtype", "postgis");
params.put("host", "localhost");
params.put("port", new Integer(5432));
params.put("database", "my_db");
params.put("user", "postgres");
params.put("passwd", "postgres");
PostgisDataStore dataStore = (PostgisDataStore) DataStoreFinder
.getDataStore(params);
Transaction t = new DefaultTransaction("handle");
FeatureSource<SimpleFeatureType, SimpleFeature> fs = dataStore
.getFeatureSource("points");
Filter filter = CQL.toFilter("id=1");
FeatureCollection fc = fs.getFeatures(filter);
FeatureIterator fi = fc.features();
while (fi.hasNext()) {
SimpleFeature f = (SimpleFeature) fi.next();
System.out.println(f);
fs.getFeatures().remove(f);
}
t.commit();
}
Thanks for Your help
Rainer
--
SDDB Consulting GmbH
Wilhelm-Busch Str. 3
31832 Springe
Phone +49 5045 962773
Mobil +49 178 716 20 11
Mail [email protected]
------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery,
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now.
http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users