[udig-devel] Adding multiple layers using single resource

Maria Comanescu mariaco1984 at yahoo.com
Mon May 26 06:48:53 PDT 2008


Hi, 
Thanks Jesse for your answer. 

It worked for me using different schema names than sending CommitCommand. 
Also, thank you for your help with the "How to set 
focus on layer" issue. 
Maria 
------------------------------

Message: 2
Date: Wed, 21 May 2008 16:02:48 +0200
From: Jesse Eichar <jeichar.w at gmail.com>
Subject: Re: [udig-devel] Adding multiple layers using single resource
To: User-friendly Desktop Internet GIS
    <udig-devel at lists.refractions.net>
Message-ID: <4FC3E1E4-AF11-49F8-9C8B-5E93C683D6D2 at gmail.com>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

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