Geometries lost when storing features to shapefile

المشرف العام

Administrator
طاقم الإدارة
As you know, the geometry column name of schema for saving into a shapefile must be "the_geom". I have a SimpleFeatureCollection with a schema, geometry name of which is not "the_geom"; It is "geometry". I want to save this collection into an esri shapefile. But I loose geoemetries when storing.

Attribute table before save:

| FeatureIdentifier | name | people | geometry |----------------------------------------------------------| jahan_0 | ali | 23 | POINT(67.0 35.0) || jahan_1 | gh | 245 | POINT(67.2 34.4) | ---------------------------------------------------------Attribute table after reading shapefile:

| FeatureIdentifier | the_geom | name | people |--------------------------------------------------| mesal_0 | | ali | 23 || mesal_1 | | gh | 245 | -------------------------------------------------How can I save my feature collection into shapefile without loosing geometries? The problem is on storing. I tested the saved shp file by QGIS and saw geometries lost.

more code on saving shapefile:

DataStore dataStore = ...; // shapefile data store// My FeatureCollection containing two featuresSimpleFeatureCollection collection = ...; dataStore.createSchema(schema);String typeName = dataStore.getTypeNames()[0];SimpleFeatureSource fs = dataStore.getFeatureSource(typeName);MyUtil.saveToFeatureStore(collection,(FeatureStore) fs);MyUtil.java:

public class MyUtil{ public static void saveToFeatureStore(SimpleFeatureCollection collection, FeatureStore featureStore){ Transaction tx = new DefaultTransaction("create"); featureStore.setTransaction(tx); try{ featureStore.addFeatures(collection); tx.commit(); } catch(Exception ex){ tx.rollback(); } finally{ tx.close(); } }}

أكثر...
 
أعلى