Ticket #412 (closed enhancement: fixed)

Opened 2 years ago

Last modified 2 years ago

GeoExt.data.WFSCapabilitiesReader - default layer options

Reported by: adube Assigned to:
Priority: minor Milestone: 1.1
Component: GeoExt.data.WFSCapabilitiesReader Version: trunk
Keywords: Cc:
State: Review

Description

Current behavior

Layers created by the WFSCapabilitiesReader have the strategy OpenLayers.Strategy.Fixed. It is not possible to define custom ones (in WFSCapabilitiesStore) because the same object(s) would be used for each layers instead of creating new ones, which must not be the case (strategies must be binded to a unique layer).

Proposed fix

If OpenLayers could support text/hash option values instead of objects, that would be perfect. Since it's not currently the case, we could read the options we want to support having text/hash values directly in the widget.

Example :

var store = new GeoExt.data.WFSCapabilitiesStore( {
    url: "/path/to/wfs",
    layerOptions: {
        visibility: false,
        displayInLayerSwitcher: false,
        strategies: [{"BBOX"}]
    }
});

or with value equal to the hash of options to use when creating the object :

var store = new GeoExt.data.WFSCapabilitiesStore( {
    url: "/path/to/wfs",
    layerOptions: {
        visibility: false,
        displayInLayerSwitcher: false,
        strategies: [{"BBOX": {ratio: 1}}]
    }
});

Attachments

patch-wfscapabilitiesreader-412-r2630-A0.diff (1.7 kB) - added by adube on 03/22/11 20:59:48.
First beta version of the patch. Fixes the issue, but is kinda ugly and have no test units.
patch-wfscapabilitiesreader-412-r2631-A1.diff (1.7 kB) - added by adube on 03/23/11 14:11:32.
New patch with alternative fix using {type: "BBOX", ratio: 1} method of defining pure objects as options
patch-wfscapabilitiesreader-412-r2631-A2.diff (1.9 kB) - added by adube on 03/23/11 15:16:58.
Patch with alternative fix using {type: "BBOX", ratio: 1} that applies "meta.layerOptions" first then update the local "layerOptions" variable with defined pure objects and strings as strategy values.
geoext-412.patch (1.5 kB) - added by ahocevar on 05/16/11 11:24:15.
patch-wfscapabilitiesreader-412-r2692-A3.diff (11.7 kB) - added by adube on 05/16/11 16:45:32.
Contains previous patch content + example and test units

Change History

03/22/11 19:22:26 changed by adube

  • summary changed from GeoExt.data.WFSCapabilitiesReader - default layer protocols to GeoExt.data.WFSCapabilitiesReader - default layer options.

03/22/11 20:50:59 changed by adube

The first code block should look more like this (had a typo) :

        strategies: ["Save"]

and combining both methods should look like this

        strategies: [{"BBOX": {ratio: 1}}, "Save"]

03/22/11 20:59:48 changed by adube

  • attachment patch-wfscapabilitiesreader-412-r2630-A0.diff added.

First beta version of the patch. Fixes the issue, but is kinda ugly and have no test units.

03/23/11 14:11:32 changed by adube

  • attachment patch-wfscapabilitiesreader-412-r2631-A1.diff added.

New patch with alternative fix using {type: "BBOX", ratio: 1} method of defining pure objects as options

03/23/11 14:13:33 changed by adube

With the above patch, a "pure object" as a way to define a strategy would look like this, which look more like what Ext does :

var store = new GeoExt.data.WFSCapabilitiesStore( {
    url: "/path/to/wfs",
    layerOptions: {
        visibility: false,
        displayInLayerSwitcher: false,
        strategies: [{type: "BBOX", ratio: 1}]
    }
});

03/23/11 15:15:37 changed by adube

A1 patch is invalid. It modifies the meta layerOptions property which is then used again later for all layers created. The meta layerOptions must first be applied to the local layerOptions variable, then read the 'strategies' array and look for string or pure objects defined there.

03/23/11 15:16:58 changed by adube

  • attachment patch-wfscapabilitiesreader-412-r2631-A2.diff added.

Patch with alternative fix using {type: "BBOX", ratio: 1} that applies "meta.layerOptions" first then update the local "layerOptions" variable with defined pure objects and strings as strategy values.

05/16/11 11:24:15 changed by ahocevar

  • attachment geoext-412.patch added.

05/16/11 11:29:33 changed by ahocevar

@adube: Wouldn't it be simpler if you could pass a function as layerOptions? Then you could do

var store = new GeoExt.data.WFSCapabilitiesStore( {
    url: "/path/to/wfs",
    layerOptions: function() {
        return {
            visibility: false,
            displayInLayerSwitcher: false,
            strategies: [new OpenLayers.Strategy.BBOX({ratio: 1})]
        };
    }
});

geoext-412.patch implements this. Please let us know if this would work for you. If so, we'd be grateful if you could add unit tests and an example.

05/16/11 15:41:58 changed by adube

Yep, it worked fine. You're right, it's more simpler that way. Test units and one example should follow today.

Thanks for your review (and nice short and sweet patch).

05/16/11 16:45:32 changed by adube

  • attachment patch-wfscapabilitiesreader-412-r2692-A3.diff added.

Contains previous patch content + example and test units

05/16/11 16:54:09 changed by adube

  • state changed from None to Review.

This new patch has :

  • the previous patch changes
  • test units
  • a wfs-capabilities example
  • a new wfscap xml file (from TinyOWS demo)

The example doesn't include a "row double-click: open map" feature because of the vector layer cloning issue described in OpenLayers ticket #2749.

Please, let me know if more work needs to be done.

05/16/11 21:02:13 changed by ahocevar

  • status changed from new to closed.
  • resolution set to fixed.

(In [2697]) making it possible to pass a function as layerOptions. With new example. p=adube,me, r=me (closes #412)