[udig-devel] Adding multiple layers using single resource
Jesse Eichar
jeichar.w at gmail.com
Wed May 21 07:02:48 PDT 2008
I think the reason is probably because there is a bug in
createTemporaryResource where the FeatureTypeName must be different
for each layer otherwise it may return two resources backed by the
same FeatureStore. I suspect that if you commit then you will see
that both layers have all the features. Although I could be wrong.
Try by changing the schema name.
Remember that to change a name you have to create a new featuretype
with a new name. SimpleFeatureTypeBuilder should make this easy.
Jesse
On 21-May-08, at 1:33 PM, Maria Comanescu wrote:
> 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
>
>
>
> _______________________________________________
> User-friendly Desktop Internet GIS (uDig)
> http://udig.refractions.net
> http://lists.refractions.net/mailman/listinfo/udig-devel
More information about the udig-devel
mailing list