Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[udig-devel] how to add features to a shapefile layer on map

Hi.

I have a shapefile as a map layer and I would like to add multiple features directly into the shapefile. I have done it like this (simplified):

(using uDig 1.2 M7)


Transaction tx = new DefaultTransaction("foo"); 
try {
  featureStore.setTransaction(tx);
  featureStore.addFeatures(featureCollection);
  tx.commit();
}
catch (Exception e) {
  tx.rollback();
}
finally {
  tx.close();
}


Seems to work fine. Features are inserted to the shapefile, appear on the map after refresh and various listeners get notified that features were added. The only problem is that the map thinks that it has been modified (it gets that star '*' next it's name).

So, how to avoid that star. I tried a couple things:

1. I could say "layer.eSetDeliver(false)" before the add (and set back to true after). No more star, but listeners don't get called either.

2. I could use CommitCommand after the transaction but that just seems odd that I would need another commit. Also, I wouldn't be able to add features to shapefile if there were edit in progress in some other layer because those changes would be committed also. (I think.)

Or something else? Or is there something wrong in the way how I add the features?


Some guidance would be appreciated.

-- 
Atte Kemppilä 


Back to the top