aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2018-12-12 16:24:50 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2019-02-19 22:48:08 +0000
commit1fcda0014022042efb17920699638c30156b04d2 (patch)
tree6291909a3b91b0dbdb8942f707c84f46b03c2ff1
parent7ebaa72586c9673a6c56476baacb9509e8f703f8 (diff)
Fix server-side WFS property filtering
The previous approach of filtering features that match one of many values worked client side for e.g. GeoJSON format WFS layers, but crashed when attemping to build the XML request for server-side feature filtering (e.g. Bristol). This code instead builds a proper Logical filter which OpenLayers can use in both situations.
-rw-r--r--web/cobrands/fixmystreet/assets.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/web/cobrands/fixmystreet/assets.js b/web/cobrands/fixmystreet/assets.js
index 0134991e9..1761e6a3e 100644
--- a/web/cobrands/fixmystreet/assets.js
+++ b/web/cobrands/fixmystreet/assets.js
@@ -574,11 +574,15 @@ fixmystreet.assets = {
// Add this filter to the layer, so it can potentially be used
// in the request (though only Bristol currently does this).
if (OpenLayers.Util.isArray(options.filter_value)) {
- layer_options.filter = new OpenLayers.Filter.FeatureId({
- type: OpenLayers.Filter.Function,
- evaluate: function(f) {
- return OpenLayers.Util.indexOf(options.filter_value, f.attributes[options.filter_key]) != -1;
- }
+ layer_options.filter = new OpenLayers.Filter.Logical({
+ type: OpenLayers.Filter.Logical.OR,
+ filters: $.map(options.filter_value, function(value) {
+ return new OpenLayers.Filter.Comparison({
+ type: OpenLayers.Filter.Comparison.EQUAL_TO,
+ property: options.filter_key,
+ value: value
+ });
+ })
});
} else if (typeof options.filter_value === 'function') {
layer_options.filter = new OpenLayers.Filter.FeatureId({