|
From: johann S. <sor...@in...> - 2008-02-04 13:32:02
|
hello,
I'm still working on the editableMap2D and I felt
on a new kind of error when trying to edit or add
a new feature in a indexedShapefileDatastore.
It looks like this error happen on big shapefiles (>5000 features) and not
on small ones.
First time I see this error :
java.io.IOException: Current fid index is null, next must be called before =
write()
at =
org.geotools.data.shapefile.indexed.IndexedFidWriter.write(IndexedFidWriter=
=2Ejava:244)
at =
org.geotools.data.shapefile.indexed.IndexedShapefileFeatureWriter.write(Ind=
exedShapefileFeatureWriter.java:80)
at =
org.geotools.data.shapefile.ShapefileFeatureWriter.close(ShapefileFeatureWr=
iter.java:212)
at =
org.geotools.data.shapefile.indexed.IndexedShapefileFeatureWriter.close(Ind=
exedShapefileFeatureWriter.java:88)
at =
org.geotools.data.TransactionStateDiff.applyDiff(TransactionStateDiff.java:=
264)
at =
org.geotools.data.TransactionStateDiff.commit(TransactionStateDiff.java:149)
at =
org.geotools.data.DefaultTransaction.commit(DefaultTransaction.java:181)
at =
org.geotools.gui.swing.map.map2d.JDefaultEditableMap2D.editAddGeometry(JDef=
aultEditableMap2D.java:361)
here is the method I use:
I already checked that the geometry and the String ID exists and are valid.
String ID is like : =22BATIMENT_SURF.9475=22 and Geometry is a JTS geometry.
private synchronized void validateModifiedGeometry(Geometry geo, String =
ID) =7B
FeatureStore store;
if (editionLayer.getFeatureSource() instanceof FeatureStore) =7B
String name =3D =
editionLayer.getFeatureSource().getSchema().getTypeName();
try =7B
FeatureSource source =3D =
editionLayer.getFeatureSource().getDataStore().getFeatureSource(name);
store =3D (FeatureStore) source;
=7D catch (IOException e) =7B
store =3D (FeatureStore) editionLayer.getFeatureSource();
=7D
DefaultTransaction transaction =3D new =
DefaultTransaction(=22trans_maj=22);
store.setTransaction(transaction);
FilterFactory ff =3D =
CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
Filter filter =3D =
ff.id(Collections.singleton(ff.featureId(ID)));
SimpleFeatureType featureType =3D =
editionLayer.getFeatureSource().getSchema();
AttributeDescriptor geomAttribut =3D =
featureType.getDefaultGeometry();
geo =3D projectGeometry(geo, editionLayer);
try =7B
store.modifyFeatures(geomAttribut, geo, filter);
transaction.commit();
=7D catch (IOException ex) =7B
ex.printStackTrace();
try =7B
transaction.rollback();
=7D catch (IOException e) =7B
e.printStackTrace();
=7D
=7D finally =7B
transaction.close();
=7D
=7D
=7D
johann sorel
|