Hello Jody!!
i write this method
public void addJetaLayer(Layer layer) throws IOException {
Map<String, Object> params = new HashMap<String, Object>();
params.put("dbtype", "postgis");
params.put("host", "localhost");
params.put("port", 5432);
params.put("schema", "public");
params.put("database", "postgis_test3");
params.put("user", "postgres");
params.put("passwd", "postgres");
DataStore pgStore = DataStoreFinder.getDataStore(params);
SimpleFeatureStore store1 = (SimpleFeatureStore)
pgStore.getFeatureSource("out3");
SimpleFeatureType featureType =
pgStore.getFeatureSource("out3").getSchema();
List<SimpleFeature> list = new ArrayList<SimpleFeature>();
SimpleFeatureIterator sfit = (SimpleFeatureIterator)
layer.getFeatureSource().getFeatures().features();
while (sfit.hasNext()) {
SimpleFeature f = sfit.next();
list.add(f);
}
SimpleFeatureCollection collection = new ListFeatureCollection(
featureType, list);
Transaction transaction = new DefaultTransaction("Add Example");
store1.setTransaction(transaction);
try {
store1.addFeatures(collection);
transaction.commit();
} catch (Exception eek) {
transaction.rollback();
}
finally{
transaction.close();
}
}
But in table out3 inserts only gid column. ( I have 3 features and after
work this method have 3 new gid records, there is no geometry data in table)
--
View this message in context:
http://osgeo-org.1560.n6.nabble.com/How-to-add-new-feature-to-Postgis-Database-tp5001849p5003145.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://ad.doubleclick.net/clk;258768047;13503038;j?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users