Merge pull request #334 from bartvde/sldwhitespace

ignore whitespace in filter values (r=@marcjansen,@ahocevar)
This commit is contained in:
Bart van den Eijnden
2012-03-21 05:16:45 -07:00
4 changed files with 91 additions and 27 deletions

View File

@@ -189,13 +189,18 @@ OpenLayers.String = {
*
* Parameters:
* value - {String}
* trimWhitespace - {Boolean}
*
* Returns:
* {Number|String} a Number if the passed value is a number, a String
* otherwise.
*/
numericIf: function(value) {
return OpenLayers.String.isNumeric(value) ? parseFloat(value) : value;
numericIf: function(value, trimWhitespace) {
var originalValue = value;
if (trimWhitespace === true && value != null && value.replace) {
value = value.replace(/^\s*|\s*$/g, "");
}
return OpenLayers.String.isNumeric(value) ? parseFloat(value) : originalValue;
}
};

View File

@@ -27,7 +27,7 @@ OpenLayers.Format.Filter.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
xlink: "http://www.w3.org/1999/xlink",
xsi: "http://www.w3.org/2001/XMLSchema-instance"
},
/**
* Property: defaultPrefix
*/
@@ -180,18 +180,18 @@ OpenLayers.Format.Filter.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
},
"Literal": function(node, obj) {
obj.value = OpenLayers.String.numericIf(
this.getChildValue(node));
this.getChildValue(node), true);
},
"PropertyName": function(node, filter) {
filter.property = this.getChildValue(node);
},
"LowerBoundary": function(node, filter) {
filter.lowerBoundary = OpenLayers.String.numericIf(
this.readers.ogc._expression.call(this, node));
this.readers.ogc._expression.call(this, node), true);
},
"UpperBoundary": function(node, filter) {
filter.upperBoundary = OpenLayers.String.numericIf(
this.readers.ogc._expression.call(this, node));
this.readers.ogc._expression.call(this, node), true);
},
"Intersects": function(node, obj) {
this.readSpatial(node, obj, OpenLayers.Filter.Spatial.INTERSECTS);