Permalink
Browse files

Allow filters in WFST for multiple geometry columns. r=bartvde (close…

…s #3370)
  • Loading branch information...
1 parent 00e2e1b commit 0afb5207e28fcdf4707d29518a7a30be56589799 @ahocevar ahocevar committed Oct 6, 2011
Showing with 24 additions and 2 deletions.
  1. +2 −2 lib/OpenLayers/Format/WFST/v1.js
  2. +22 −0 tests/Format/WFST/v1.html
View
4 lib/OpenLayers/Format/WFST/v1.js
@@ -432,8 +432,8 @@ OpenLayers.Format.WFST.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
this.setFilterProperty(filter.filters[i]);
}
} else {
- if(filter instanceof OpenLayers.Filter.Spatial) {
- // got a spatial filter, set its property
+ if(filter instanceof OpenLayers.Filter.Spatial && !filter.property) {
+ // got a spatial filter without property, so set it
filter.property = this.geometryName;
}
}
View
22 tests/Format/WFST/v1.html
@@ -133,6 +133,28 @@
t.xml_eq(got, expected, snippet + " request without geometry created correctly");
}
}
+
+ function test_setFilterProperty(t) {
+ t.plan(2);
+ var format = new OpenLayers.Format.WFST({
+ geometryName: "foo"
+ });
+ var filter = new OpenLayers.Filter.Logical({
+ type: OpenLayers.Filter.Logical.AND,
+ filters: [new OpenLayers.Filter.Spatial({
+ type: OpenLayers.Filter.Spatial.BBOX,
+ value: new OpenLayers.Bounds(1,2,3,4)
+ }), new OpenLayers.Filter.Spatial({
+ type: OpenLayers.Filter.Spatial.DWITHIN,
+ property: "bar",
+ value: new OpenLayers.Geometry.Point(1,2),
+ distance: 10
+ })]
+ });
+ format.setFilterProperty(filter);
+ t.eq(filter.filters[0].property, "foo", "property set if not set on filter");
+ t.eq(filter.filters[1].property, "bar", "property not set if set on filter");
+ }
function test_update_null_geometry(t) {
var format = new OpenLayers.Format.WFST({

0 comments on commit 0afb520

Please sign in to comment.