Hi all,
I would be please if someone could help me to understand what's happening on
my layer...
Actually, I created a layer and added a feature on it. I've programmed a
visual tool with arrows that let me move my feature on screen. The problem
is, as I thought I created only one feature, a clone one has been created
too. The cloned layer disappear if I refresh the screen but reappear if I
move the othe feature over it...
here are the code extract if that can help:
*To create a feature : *
Feature[] features = new Feature[1];
features[0] = feature;
System.out.println("feature créé : "+
features[0].getID());
String featureTypeName = myLayer.getSchema().getTypeName();
try {
FeatureSource source = myLayer.getResource(FeatureSource.class,
ProgressManager.instance().get());
DataStore dataStore = source.getDataStore();
FeatureStore store = (FeatureStore)
dataStore.getFeatureSource(featureTypeName);
store.setTransaction(transaction);
store.addFeatures(DataUtilities.collection(features));
transaction.commit();
} catch (IOException e) {
transaction.rollback();
e.printStackTrace();
} finally {
transaction.close();
}
*To move the feature : *
DefaultTransaction transaction = new DefaultTransaction("Example1");
try {
FeatureStore store = (FeatureStore)
dataStore.getFeatureSource(featureTypeName);
store.setTransaction( transaction );
FilterFactory ff = FilterFactoryFinder.createFilterFactory();
//To filter only the selected feature, the featureId has previously
been captured
FidFilter filter2 = ff.createFidFilter();
filter2.addFid(featureId);
FeatureType featureType = store.getSchema();
AttributeType att = featureType.getDefaultGeometry();
//geo is the modified Geometry
store.modifyFeatures(att, geo, filter2);
transaction.commit();
System.out.println("Transaction effectué");
} catch (Exception e) {
transaction.rollback();
System.out.println("Rollback effectué");
} finally {
transaction.close();
}
The 'cloned' feature ID is like new0 and the created feature ID is like
fid-_61883d49_120a475c79a__7ffd
I have the feeling that new0 is not in datastore and has only been created
on the graphic layer... but I'm not sure at all...
Any suggestions ?
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel