Quantcast

How to merge multiple vector (WFS) layers?

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to merge multiple vector (WFS) layers?

Frans Knibbe
Hello everybody,

I have several vector layers that have similar data structures (in fact they are WFS layers using the same application schemas). I would like to merge these layers into one layer. I want to do this because I want to use a GeoExt.data.FeatureStore to be able to display a table with feature data that are coupled with the features in the map. So I think I want to use only the merged layer in my map.

I am looking for help on the best way to merge my vector layers. Looking at the OpenLayers documentation, I see that I could use the addFeatures function to add features to the merged layer. But when could I call this function if I never draw the layers that will be merged? On the other hand, I see there is a OpenLayers.Layer.Vector.RootContainer. It is something that can be used to combine vector layers but it is "not supposed to be instantiated from user space".

Any help, tips, examples or hints will be greatly appreciated!

Greetings,
Frans



_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to merge multiple vector (WFS) layers?

Andreas Hocevar-2
Hi,

configure your WFS protocol with multiple feature types. Look e.g. at the wfs-states.js example. If you wanted "states" and "world" from the WFS, you would configure it like this:

    var wfs = new OpenLayers.Layer.Vector("States", {
        strategies: [new OpenLayers.Strategy.BBOX()],
        protocol: new OpenLayers.Protocol.WFS({
            url: "http://demo.opengeo.org/geoserver/wfs",
            featureType: ["states", "world"],
            featureNS: "http://www.openplans.org/topp"
        })
    });

Regards,
Andreas.

On Sep 22, 2010, at 18:38 , Frans Knibbe wrote:

> Hello everybody,
>
> I have several vector layers that have similar data structures (in fact they are WFS layers using the same application schemas). I would like to merge these layers into one layer. I want to do this because I want to use a GeoExt.data.FeatureStore to be able to display a table with feature data that are coupled with the features in the map. So I think I want to use only the merged layer in my map.
>
> I am looking for help on the best way to merge my vector layers. Looking at the OpenLayers documentation, I see that I could use the addFeatures function to add features to the merged layer. But when could I call this function if I never draw the layers that will be merged? On the other hand, I see there is a OpenLayers.Layer.Vector.RootContainer. It is something that can be used to combine vector layers but it is "not supposed to be instantiated from user space".
>
> Any help, tips, examples or hints will be greatly appreciated!
>
> Greetings,
> Frans
>
>
> _______________________________________________
> Users mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/openlayers-users



--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.

_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to merge multiple vector (WFS) layers?

Frans Knibbe
  Hello Andreas,

Thank you for your thoughts. However, I don't think your suggestion will
work in my case. I am not trying to merge different feature types from
one WFS, but the same feature type from different WFSes.

Regards,
Frans

On 2010-09-23 9:41, Andreas Hocevar wrote:

> Hi,
>
> configure your WFS protocol with multiple feature types. Look e.g. at the wfs-states.js example. If you wanted "states" and "world" from the WFS, you would configure it like this:
>
>      var wfs = new OpenLayers.Layer.Vector("States", {
>          strategies: [new OpenLayers.Strategy.BBOX()],
>          protocol: new OpenLayers.Protocol.WFS({
>              url: "http://demo.opengeo.org/geoserver/wfs",
>              featureType: ["states", "world"],
>              featureNS: "http://www.openplans.org/topp"
>          })
>      });
>
> Regards,
> Andreas.
>
> On Sep 22, 2010, at 18:38 , Frans Knibbe wrote:
>
>> Hello everybody,
>>
>> I have several vector layers that have similar data structures (in fact they are WFS layers using the same application schemas). I would like to merge these layers into one layer. I want to do this because I want to use a GeoExt.data.FeatureStore to be able to display a table with feature data that are coupled with the features in the map. So I think I want to use only the merged layer in my map.
>>
>> I am looking for help on the best way to merge my vector layers. Looking at the OpenLayers documentation, I see that I could use the addFeatures function to add features to the merged layer. But when could I call this function if I never draw the layers that will be merged? On the other hand, I see there is a OpenLayers.Layer.Vector.RootContainer. It is something that can be used to combine vector layers but it is "not supposed to be instantiated from user space".
>>
>> Any help, tips, examples or hints will be greatly appreciated!
>>
>> Greetings,
>> Frans
>>
>>
>> _______________________________________________
>> Users mailing list
>> [hidden email]
>> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
>



_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to merge multiple vector (WFS) layers?

Andreas Hocevar-2
Hi,

I would not suggest messing with the RootContainer. Personally, I would create a custom strategy that takes care of fetching features from your different sources. This custom strategy would probably maintain its own OpenLayers.Protocol instances, and your layer would not be configured with a protocol.

Regards,
Andreas.

On Sep 23, 2010, at 09:55 , Frans Knibbe wrote:

> Hello Andreas,
>
> Thank you for your thoughts. However, I don't think your suggestion will work in my case. I am not trying to merge different feature types from one WFS, but the same feature type from different WFSes.
>
> Regards,
> Frans
>
> On 2010-09-23 9:41, Andreas Hocevar wrote:
>> Hi,
>>
>> configure your WFS protocol with multiple feature types. Look e.g. at the wfs-states.js example. If you wanted "states" and "world" from the WFS, you would configure it like this:
>>
>>     var wfs = new OpenLayers.Layer.Vector("States", {
>>         strategies: [new OpenLayers.Strategy.BBOX()],
>>         protocol: new OpenLayers.Protocol.WFS({
>>             url: "http://demo.opengeo.org/geoserver/wfs",
>>             featureType: ["states", "world"],
>>             featureNS: "http://www.openplans.org/topp"
>>         })
>>     });
>>
>> Regards,
>> Andreas.
>>
>> On Sep 22, 2010, at 18:38 , Frans Knibbe wrote:
>>
>>> Hello everybody,
>>>
>>> I have several vector layers that have similar data structures (in fact they are WFS layers using the same application schemas). I would like to merge these layers into one layer. I want to do this because I want to use a GeoExt.data.FeatureStore to be able to display a table with feature data that are coupled with the features in the map. So I think I want to use only the merged layer in my map.
>>>
>>> I am looking for help on the best way to merge my vector layers. Looking at the OpenLayers documentation, I see that I could use the addFeatures function to add features to the merged layer. But when could I call this function if I never draw the layers that will be merged? On the other hand, I see there is a OpenLayers.Layer.Vector.RootContainer. It is something that can be used to combine vector layers but it is "not supposed to be instantiated from user space".
>>>
>>> Any help, tips, examples or hints will be greatly appreciated!
>>>
>>> Greetings,
>>> Frans
>>>
>>>
>>> _______________________________________________
>>> Users mailing list
>>> [hidden email]
>>> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>>
>>
>
>
>
> _______________________________________________
> Users mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/openlayers-users

--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.

_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to merge multiple vector (WFS) layers?

Frans Knibbe
  Hello everybody,

I ended up creating a new OpenLayers vector layer and added the features
from my multiple WFS layers to this layer, using the layer.addFeatures
method. This works well enough, I draw only the new layer in the map and
the features are combined on the map as well as in the data grid.

Greetings,
Frans

On 2010-09-23 10:29, Andreas Hocevar wrote:

> Hi,
>
> I would not suggest messing with the RootContainer. Personally, I would create a custom strategy that takes care of fetching features from your different sources. This custom strategy would probably maintain its own OpenLayers.Protocol instances, and your layer would not be configured with a protocol.
>
> Regards,
> Andreas.
>
> On Sep 23, 2010, at 09:55 , Frans Knibbe wrote:
>
>> Hello Andreas,
>>
>> Thank you for your thoughts. However, I don't think your suggestion will work in my case. I am not trying to merge different feature types from one WFS, but the same feature type from different WFSes.
>>
>> Regards,
>> Frans
>>
>> On 2010-09-23 9:41, Andreas Hocevar wrote:
>>> Hi,
>>>
>>> configure your WFS protocol with multiple feature types. Look e.g. at the wfs-states.js example. If you wanted "states" and "world" from the WFS, you would configure it like this:
>>>
>>>      var wfs = new OpenLayers.Layer.Vector("States", {
>>>          strategies: [new OpenLayers.Strategy.BBOX()],
>>>          protocol: new OpenLayers.Protocol.WFS({
>>>              url: "http://demo.opengeo.org/geoserver/wfs",
>>>              featureType: ["states", "world"],
>>>              featureNS: "http://www.openplans.org/topp"
>>>          })
>>>      });
>>>
>>> Regards,
>>> Andreas.
>>>
>>> On Sep 22, 2010, at 18:38 , Frans Knibbe wrote:
>>>
>>>> Hello everybody,
>>>>
>>>> I have several vector layers that have similar data structures (in fact they are WFS layers using the same application schemas). I would like to merge these layers into one layer. I want to do this because I want to use a GeoExt.data.FeatureStore to be able to display a table with feature data that are coupled with the features in the map. So I think I want to use only the merged layer in my map.
>>>>
>>>> I am looking for help on the best way to merge my vector layers. Looking at the OpenLayers documentation, I see that I could use the addFeatures function to add features to the merged layer. But when could I call this function if I never draw the layers that will be merged? On the other hand, I see there is a OpenLayers.Layer.Vector.RootContainer. It is something that can be used to combine vector layers but it is "not supposed to be instantiated from user space".
>>>>
>>>> Any help, tips, examples or hints will be greatly appreciated!
>>>>
>>>> Greetings,
>>>> Frans
>>>>
>>>>
>>>> _______________________________________________
>>>> Users mailing list
>>>> [hidden email]
>>>> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>>>
>>
>>
>> _______________________________________________
>> Users mailing list
>> [hidden email]
>> http://lists.osgeo.org/mailman/listinfo/openlayers-users



_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to merge multiple vector (WFS) layers?

Mondi
Hi Andreas,

I have a similar problem to Frans, which means trying to merge several wfs layers with the same data structure to one wfs layer. I am trying to follow your suggestion, by passing to FeatureType of OpenLayers.Protocol, an array of strings, which represent the elements in a mapfile. But the layer recognizes only my first feature type of the array, and not the others. In the documentation too, the FeatureType is explained as a string field and not as an array of strings.
Should this be my problem (some bad configurations in mapfile) or the FeatureType doesn't accept an array of strings? And if the latter, how can I merge my layers in another way? I am not sure about how to use the AddFeatures functionality too, if this might help me...

Thanks in advance for any answers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to merge multiple vector (WFS) layers?

Andreas Hocevar-2
Hi,

what happens if you use a comma separated list of layer names instead of an array?

Andreas.

On Feb 9, 2011, at 13:02 , Mondi wrote:

>
> Hi Andreas,
>
> I have a similar problem to Frans, which means trying to merge several wfs
> layers with the same data structure to one wfs layer. I am trying to follow
> your suggestion, by passing to FeatureType of OpenLayers.Protocol, an array
> of strings, which represent the elements in a mapfile. But the layer
> recognizes only my first feature type of the array, and not the others. In
> the documentation too, the FeatureType is explained as a string field and
> not as an array of strings.
> Should this be my problem (some bad configurations in mapfile) or the
> FeatureType doesn't accept an array of strings? And if the latter, how can I
> merge my layers in another way? I am not sure about how to use the
> AddFeatures functionality too, if this might help me...
>
> Thanks in advance for any answers
> --
> View this message in context: http://osgeo-org.1803224.n2.nabble.com/How-to-merge-multiple-vector-WFS-layers-tp5559811p6007411.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/openlayers-users



--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.

_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to merge multiple vector (WFS) layers?

Mondi
It will recognize it as one whole string, and not as an array, i.e., it won't show me even the first feature type.

Thanks
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to merge multiple vector (WFS) layers?

Mondi
So, any other ideas how can I merge two wfs layers in one?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

AW: [OpenLayers-Users] Re: How to merge multiple vector (WFS) layers?

Arnd Wippermann
You could do it by use of depricated code


http://dev.openlayers.org/releases/OpenLayers-2.8/examples/wfs-states.html

layer = new OpenLayers.Layer.WFS( "States WFS",
        "http://sigma.openplans.org/geoserver/ows",
        { typename: 'topp:states' } );

typename could be a list of layers ("layer1,layer2,layer3").

Online example:
http://gis.ibbeck.de/ginfo/apps/OLExamples/OL26/examples/styles_unique_with_
group_wfs.html

I woukd like to do the same with OpenLayers.Layer.Vector and protocol WFS.

Arnd
 

-----Urspr√ľngliche Nachricht-----
Von: [hidden email]
[mailto:[hidden email]] Im Auftrag von Mondi
Gesendet: Donnerstag, 10. Februar 2011 13:05
An: [hidden email]
Betreff: [OpenLayers-Users] Re: How to merge multiple vector (WFS) layers?


So, any other ideas how can I merge two wfs layers in one?
--
View this message in context:
http://osgeo-org.1803224.n2.nabble.com/How-to-merge-multiple-vector-WFS-laye
rs-tp5559811p6011358.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Loading...