[Users] FeatureStore with features from multiple layers
Matt Priour
mpriour at kestrelcomputer.com
Wed Sep 29 15:02:55 CEST 2010
You could avoid the data redundancy by using OpenLayers.Protocol subclasses
rather than layers to collect your features from the multiple WFS services.
You call the read() function on the protocol with a callback option and add
the features to the combined layer that way.
For example:
/* Layer to hold all the features */
var myLayer = new OpenLayers.Layer.Vector('my layer')
/*Protocols*/
var wfs1 = new OpenLayers.Protocol.WFS({ ... configuration options ...})
var wfs2 = new OpenLayers.Protocol.WFS({ ... configuration options ...})
/*WFS Feature processing function*/
var addFeatsToLayer = function(evt){
var feats = evt.features;
myLayer.addFeatures(feats);
}
/* read wfs */
wfs1.read({
callback : addFeatsToLayer,
filter : <optional filter>
})
wfs2.read({
callback : addFeatsToLayer,
filter: <optional filter>
})
Matt Priour
Kestrel Computer Consulting
--------------------------------------------------
From: "Frans Knibbe" <frans at geodan.nl>
Sent: Wednesday, September 29, 2010 6:10 AM
To: <users at geoext.org>
Subject: Re: [Users] FeatureStore with features from multiple layers
> 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. I
> think the main problem with this approach is data redundancy.
>
> Greetings,
> Frans
>
> On 2010-09-23 10:53, Frans Knibbe wrote:
>> Hello Andreas,
>>
>> Thanks again. I should explain here also that I want to combine data
>> from different WFSes. I have multiple WFS layers using exactly the same
>> feature type. So yes, they will have the same attribute fields.
>>
>> You seem to confirm that I can't use GeoExt.data.FeatureStore in my
>> case. So one option is the resort to Ext.data.Store. But then I would
>> have to write all the nice interaction with the layers myself. The
>> layers use a BBOX strategy, so the feature collection changes after each
>> change of the map extent. This has to be reflected in the GridPanel
>> too. Also, I would like to have bidirectional feature highlighting
>> (selecting a feature in the map highlights the feature in the GridPanel
>> and vice versa). These things work 'out of the box' when a
>> GeoExt.data.FeatureStore is used with a single layer. The prospect of
>> having to create this myself with an Ext.data.Store is daunting (for
>> someone with my limited level of experise). Therefore I thought I could
>> try merging the layers into one layer using OpenLayers functionality.
>> The merged layer could then be associated with a FeatureStore and a
>> GridPanel. Which is the best approach in your opinion?
>>
>> Regards,
>> Frans
>>
>>
>> On 2010-09-23 9:04, Andreas Hocevar wrote:
>>> Hi,
>>>
>>> note that your merging approach will only work if the features of all
>>> your layers have the same attribute fields.
>>>
>>> For the merging itself, if you use WFS, it will be enough to configure
>>> the WFS protocol of your vector layer with a list of feature types.
>>>
>>> Synchronisation between GeoExt.data.FeatureStore and features only works
>>> with one layer, because the store has to listen to events of the layer.
>>> However, it should be easy to create an Ext.data.Store instance with
>>> GeoExt.data.FeatureRecord records and keep it in sync with multiple
>>> layers by just registering the appropriate event handlers on all layers
>>> (featuresadded, featuresremoved, featuremodified) and the store (load,
>>> clear, add, remove, update).
>>>
>>> Hope this helps,
>>> Andreas.
>>>
>>> On Sep 22, 2010, at 17:17 , Frans Knibbe wrote:
>>>
>>>> Hello,
>>>>
>>>> I am really having trouble getting this to work. My idea was to create
>>>> a
>>>> GeoExt.data.FeatureStore using the 'features' configuration option
>>>> instead of the 'layers' option, with the features being a concatenated
>>>> array of features from multiple layers. But that only works when the
>>>> store is created. I want to have the store synchronized with the
>>>> features on the map. I could not find a way to change the data in the
>>>> FeatureStore when it is not coupled with a layer.
>>>>
>>>> So now I want to try creating a merged layer in OpenLayers and use that
>>>> in the FeatureStore...
>>>>
>>>> Regards,
>>>> Frans
>>>>
>>>>
>>>> On 2010-09-14 15:22, Frans Knibbe wrote:
>>>>> On 2010-09-08 15:55, "Michael Prieß" wrote:
>>>>>> Hello Frans,
>>>>>>
>>>>>> have you found a solution to sync a GeoExt.data.FeatureStore with
>>>>>> multiple layers ?
>>>>> Not yet, I got distracted by other matters. But I will report my
>>>>> findings in this list.
>>>>>> Regards,
>>>>>>
>>>>>> Michael Prieß
>>>>>>
>>>>>> -------- Original-Nachricht --------
>>>>>>> Datum: Tue, 31 Aug 2010 17:26:25 +0200
>>>>>>> Von: Frans Knibbe<frans at geodan.nl>
>>>>>>> An: "users at geoext.org"<users at geoext.org>
>>>>>>> Betreff: [Users] FeatureStore with features from multiple layers
>>>>>>> Hello all,
>>>>>>>
>>>>>>> I would like to have a Ext.grid.GridPanel displaying data from
>>>>>>> multiple
>>>>>>> WFS layers. I know these WFS use the same schema, so there should be
>>>>>>> no
>>>>>>> conflict in data definitions. To populate the GridPanel I guess I
>>>>>>> need a
>>>>>>> GeoExt.data.FeatureStore. Is it possible to populate a FeatureStore
>>>>>>> with
>>>>>>> data from multiple vector layers? If so, how would I go about doing
>>>>>>> that?
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Frans
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> Users mailing list
>>>>>>> Users at geoext.org
>>>>>>> http://www.geoext.org/cgi-bin/mailman/listinfo/users
>>>>> _______________________________________________
>>>>> Users mailing list
>>>>> Users at geoext.org
>>>>> http://www.geoext.org/cgi-bin/mailman/listinfo/users
>>>>
>>>> _______________________________________________
>>>> Users mailing list
>>>> Users at geoext.org
>>>> http://www.geoext.org/cgi-bin/mailman/listinfo/users
>>>
>>
>>
>> _______________________________________________
>> Users mailing list
>> Users at geoext.org
>> http://www.geoext.org/cgi-bin/mailman/listinfo/users
>
>
>
> _______________________________________________
> Users mailing list
> Users at geoext.org
> http://www.geoext.org/cgi-bin/mailman/listinfo/users
>
More information about the Users
mailing list