SLD format rewrite. Adds a versioned parser with read and write support. This does not come with full support for ogc:expression parsing, but makes for easy future enhancements. r=ahocevar (closes #1458)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@6645 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -107,9 +107,9 @@ OpenLayers.Rule.Comparison = OpenLayers.Class(OpenLayers.Rule, {
|
||||
|
||||
case OpenLayers.Rule.Comparison.BETWEEN:
|
||||
var result =
|
||||
context[this.property] > this.lowerBoundary;
|
||||
context[this.property] >= this.lowerBoundary;
|
||||
result = result &&
|
||||
context[this.property] < this.upperBoundary;
|
||||
context[this.property] <= this.upperBoundary;
|
||||
return result;
|
||||
case OpenLayers.Rule.Comparison.LIKE:
|
||||
var regexp = new RegExp(this.value,
|
||||
@@ -163,6 +163,41 @@ OpenLayers.Rule.Comparison = OpenLayers.Class(OpenLayers.Rule, {
|
||||
return this.value;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: regex2value
|
||||
* Convert the value of this rule from a regular expression string into an
|
||||
* ogc literal string using a wildCard of *, a singleChar of ., and an
|
||||
* escape of !. Leaves the <value> property unmodified.
|
||||
*
|
||||
* Returns:
|
||||
* {String} A string value.
|
||||
*/
|
||||
regex2value: function() {
|
||||
|
||||
var value = this.value;
|
||||
|
||||
// replace ! with !!
|
||||
value = value.replace(/!/g, "!!");
|
||||
|
||||
// replace \. with !. (watching out for \\.)
|
||||
value = value.replace(/(\\)?\\\./g, function($0, $1) {
|
||||
return $1 ? $0 : "!.";
|
||||
});
|
||||
|
||||
// replace \* with #* (watching out for \\*)
|
||||
value = value.replace(/(\\)?\\\*/g, function($0, $1) {
|
||||
return $1 ? $0 : "!*";
|
||||
});
|
||||
|
||||
// replace \\ with \
|
||||
value = value.replace(/\\\\/g, "\\");
|
||||
|
||||
// convert .* to * (the sequence #.* is not allowed)
|
||||
value = value.replace(/\.\*/g, "*");
|
||||
|
||||
return value;
|
||||
},
|
||||
|
||||
/**
|
||||
* Function: binaryCompare
|
||||
* Compares a feature property to a rule value
|
||||
|
||||
Reference in New Issue
Block a user