[udig-devel] Adding multiple layers using single resource

Maria Comanescu mariaco1984 at yahoo.com
Wed May 21 04:33:05 PDT 2008


Hello,

I'm trying to add multiple layers using a single resource. Using different resources gives me an exception

So, I create the resource like this:
IGeoResource resource = CatalogPlugin.getDefault().getLocalCatalog().createTemporaryResource(SivecoApplication.getEditLayer().getSchema());

Then I run the following code multiple times: 
Layer newLayer = map.getLayerFactory().createLayer(resource);

AddLayerCommand addLayerCommand = new AddLayerCommand(newLayer ,-1);
map.sendCommandSync(addLayerCommand);

FeatureIterator<SimpleFeature> it = collection.features();
SimpleFeature feat;
while (it.hasNext()) {
     feat = it.next();
     ((EditManagerImpl) newLayer.getMap().getEditManager()).addFeature(feat, newLayer);
}

I also tried adding features like this:
//            CopyFeaturesCommand copyFeatureCommand = new CopyFeaturesCommand(layer, filter, newLayer);
//            map.sendCommandSync(copyFeatureCommand);

It works like this:
I create layer A containing features a, b, c
Then I create layer B, and I add features d, e, f.

After this two operations, if I use Zoom to layer I can see that
- A contains feature a, b, c, d, e, f
- B contains features d, e, f
which is not right for me

Also, if I use the TableView I can see that both A and B contain all the a, b, c, d, e, f features.

Could somebody tell me what can I do to make this right?

Thank you in advance, 
Maria


      


More information about the udig-devel mailing list