Fix lots of EOL SSTyle line ending problems.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@6131 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -1,206 +1,206 @@
|
||||
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
|
||||
* license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Rule.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Rule.Comparison
|
||||
* This class represents the comparison rules, as being used for rule-based
|
||||
* SLD styling
|
||||
*
|
||||
* Inherits from
|
||||
* - <OpenLayers.Rule>
|
||||
*/
|
||||
OpenLayers.Rule.Comparison = OpenLayers.Class(OpenLayers.Rule, {
|
||||
|
||||
/**
|
||||
* APIProperty: type
|
||||
* {String} type: type of the comparison. This is one of
|
||||
* - OpenLayers.Rule.Comparison.EQUAL_TO = "==";
|
||||
* - OpenLayers.Rule.Comparison.NOT_EQUAL_TO = "!=";
|
||||
* - OpenLayers.Rule.Comparison.LESS_THAN = "<";
|
||||
* - OpenLayers.Rule.Comparison.GREATER_THAN = ">";
|
||||
* - OpenLayers.Rule.Comparison.LESS_THAN_OR_EQUAL_TO = "<=";
|
||||
* - OpenLayers.Rule.Comparison.GREATER_THAN_OR_EQUAL_TO = ">=";
|
||||
* - OpenLayers.Rule.Comparison.BETWEEN = "..";
|
||||
* - OpenLayers.Rule.Comparison.LIKE = "~";
|
||||
*/
|
||||
type: null,
|
||||
|
||||
/**
|
||||
* APIProperty: property
|
||||
* {String}
|
||||
* name of the context property to compare
|
||||
*/
|
||||
property: null,
|
||||
|
||||
/**
|
||||
* APIProperty: value
|
||||
* {Number} or {String}
|
||||
* comparison value for binary comparisons. In the case of a String, this
|
||||
* can be a combination of text and propertyNames in the form
|
||||
* "literal ${propertyName}"
|
||||
*/
|
||||
value: null,
|
||||
|
||||
/**
|
||||
* APIProperty: lowerBoundary
|
||||
* {Number} or {String}
|
||||
* lower boundary for between comparisons. In the case of a String, this
|
||||
* can be a combination of text and propertyNames in the form
|
||||
* "literal ${propertyName}"
|
||||
*/
|
||||
lowerBoundary: null,
|
||||
|
||||
/**
|
||||
* APIProperty: upperBoundary
|
||||
* {Number} or {String}
|
||||
* upper boundary for between comparisons. In the case of a String, this
|
||||
* can be a combination of text and propertyNames in the form
|
||||
* "literal ${propertyName}"
|
||||
*/
|
||||
upperBoundary: null,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Rule.Comparison
|
||||
* Creates a comparison rule.
|
||||
*
|
||||
* Parameters:
|
||||
* params - {Object} Hash of parameters for this rule:
|
||||
* -
|
||||
* - value:
|
||||
* options - {Object} An optional object with properties to set on the
|
||||
* rule
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Rule.Comparison>}
|
||||
*/
|
||||
initialize: function(options) {
|
||||
OpenLayers.Rule.prototype.initialize.apply(this, [options]);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: evaluate
|
||||
* evaluates this rule for a specific context
|
||||
*
|
||||
* Parameters:
|
||||
* context - {Object} context to apply the rule to.
|
||||
*
|
||||
* Returns:
|
||||
* {boolean} true if the rule applies, false if it does not
|
||||
*/
|
||||
evaluate: function(feature) {
|
||||
if (!OpenLayers.Rule.prototype.evaluate.apply(this, arguments)) {
|
||||
return false;
|
||||
}
|
||||
var context = this.getContext(feature);
|
||||
switch(this.type) {
|
||||
case OpenLayers.Rule.Comparison.EQUAL_TO:
|
||||
case OpenLayers.Rule.Comparison.LESS_THAN:
|
||||
case OpenLayers.Rule.Comparison.GREATER_THAN:
|
||||
case OpenLayers.Rule.Comparison.LESS_THAN_OR_EQUAL_TO:
|
||||
case OpenLayers.Rule.Comparison.GREATER_THAN_OR_EQUAL_TO:
|
||||
return this.binaryCompare(context, this.property, this.value);
|
||||
|
||||
case OpenLayers.Rule.Comparison.BETWEEN:
|
||||
var result =
|
||||
context[this.property] > this.lowerBoundary;
|
||||
result = result &&
|
||||
context[this.property] < this.upperBoundary;
|
||||
return result;
|
||||
case OpenLayers.Rule.Comparison.LIKE:
|
||||
var regexp = new RegExp(this.value,
|
||||
"gi");
|
||||
return regexp.test(context[this.property]);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: value2regex
|
||||
* Converts the value of this rule into a regular expression string,
|
||||
* according to the wildcard characters specified. This method has to
|
||||
* be called after instantiation of this class, if the value is not a
|
||||
* regular expression already.
|
||||
*
|
||||
* Parameters:
|
||||
* wildCard - {<Char>} wildcard character in the above value, default
|
||||
* is "*"
|
||||
* singleChar - {<Char>) single-character wildcard in the above value
|
||||
* default is "."
|
||||
* escape - {<Char>) escape character in the above value, default is
|
||||
* "!"
|
||||
*
|
||||
* Returns:
|
||||
* {String} regular expression string
|
||||
*/
|
||||
value2regex: function(wildCard, singleChar, escapeChar) {
|
||||
if (wildCard == ".") {
|
||||
var msg = "'.' is an unsupported wildCard character for "+
|
||||
"OpenLayers.Rule.Comparison";
|
||||
OpenLayers.Console.error(msg);
|
||||
return null;
|
||||
}
|
||||
|
||||
// set UMN MapServer defaults for unspecified parameters
|
||||
wildCard = wildCard ? wildCard : "*";
|
||||
singleChar = singleChar ? singleChar : ".";
|
||||
escapeChar = escapeChar ? escapeChar : "!";
|
||||
|
||||
this.value = this.value.replace(
|
||||
new RegExp("\\"+escapeChar, "g"), "\\");
|
||||
this.value = this.value.replace(
|
||||
new RegExp("\\"+singleChar, "g"), ".");
|
||||
this.value = this.value.replace(
|
||||
new RegExp("\\"+wildCard, "g"), ".*");
|
||||
this.value = this.value.replace(
|
||||
new RegExp("\\\\.\\*", "g"), "\\"+wildCard);
|
||||
this.value = this.value.replace(
|
||||
new RegExp("\\\\\\.", "g"), "\\"+singleChar);
|
||||
|
||||
return this.value;
|
||||
},
|
||||
|
||||
/**
|
||||
* Function: binaryCompare
|
||||
* Compares a feature property to a rule value
|
||||
*
|
||||
* Parameters:
|
||||
* context - {Object}
|
||||
* property - {String} or {Number}
|
||||
* value - {String} or {Number}, same as property
|
||||
*
|
||||
* Returns:
|
||||
* {boolean}
|
||||
*/
|
||||
binaryCompare: function(context, property, value) {
|
||||
switch (this.type) {
|
||||
case OpenLayers.Rule.Comparison.EQUAL_TO:
|
||||
return context[property] == value;
|
||||
case OpenLayers.Rule.Comparison.NOT_EQUAL_TO:
|
||||
return context[property] != value;
|
||||
case OpenLayers.Rule.Comparison.LESS_THAN:
|
||||
return context[property] < value;
|
||||
case OpenLayers.Rule.Comparison.GREATER_THAN:
|
||||
return context[property] > value;
|
||||
case OpenLayers.Rule.Comparison.LESS_THAN_OR_EQUAL_TO:
|
||||
return context[property] <= value;
|
||||
case OpenLayers.Rule.Comparison.GREATER_THAN_OR_EQUAL_TO:
|
||||
return context[property] >= value;
|
||||
}
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Rule.Comparison"
|
||||
});
|
||||
|
||||
|
||||
OpenLayers.Rule.Comparison.EQUAL_TO = "==";
|
||||
OpenLayers.Rule.Comparison.NOT_EQUAL_TO = "!=";
|
||||
OpenLayers.Rule.Comparison.LESS_THAN = "<";
|
||||
OpenLayers.Rule.Comparison.GREATER_THAN = ">";
|
||||
OpenLayers.Rule.Comparison.LESS_THAN_OR_EQUAL_TO = "<=";
|
||||
OpenLayers.Rule.Comparison.GREATER_THAN_OR_EQUAL_TO = ">=";
|
||||
OpenLayers.Rule.Comparison.BETWEEN = "..";
|
||||
OpenLayers.Rule.Comparison.LIKE = "~";
|
||||
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
|
||||
* license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Rule.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Rule.Comparison
|
||||
* This class represents the comparison rules, as being used for rule-based
|
||||
* SLD styling
|
||||
*
|
||||
* Inherits from
|
||||
* - <OpenLayers.Rule>
|
||||
*/
|
||||
OpenLayers.Rule.Comparison = OpenLayers.Class(OpenLayers.Rule, {
|
||||
|
||||
/**
|
||||
* APIProperty: type
|
||||
* {String} type: type of the comparison. This is one of
|
||||
* - OpenLayers.Rule.Comparison.EQUAL_TO = "==";
|
||||
* - OpenLayers.Rule.Comparison.NOT_EQUAL_TO = "!=";
|
||||
* - OpenLayers.Rule.Comparison.LESS_THAN = "<";
|
||||
* - OpenLayers.Rule.Comparison.GREATER_THAN = ">";
|
||||
* - OpenLayers.Rule.Comparison.LESS_THAN_OR_EQUAL_TO = "<=";
|
||||
* - OpenLayers.Rule.Comparison.GREATER_THAN_OR_EQUAL_TO = ">=";
|
||||
* - OpenLayers.Rule.Comparison.BETWEEN = "..";
|
||||
* - OpenLayers.Rule.Comparison.LIKE = "~";
|
||||
*/
|
||||
type: null,
|
||||
|
||||
/**
|
||||
* APIProperty: property
|
||||
* {String}
|
||||
* name of the context property to compare
|
||||
*/
|
||||
property: null,
|
||||
|
||||
/**
|
||||
* APIProperty: value
|
||||
* {Number} or {String}
|
||||
* comparison value for binary comparisons. In the case of a String, this
|
||||
* can be a combination of text and propertyNames in the form
|
||||
* "literal ${propertyName}"
|
||||
*/
|
||||
value: null,
|
||||
|
||||
/**
|
||||
* APIProperty: lowerBoundary
|
||||
* {Number} or {String}
|
||||
* lower boundary for between comparisons. In the case of a String, this
|
||||
* can be a combination of text and propertyNames in the form
|
||||
* "literal ${propertyName}"
|
||||
*/
|
||||
lowerBoundary: null,
|
||||
|
||||
/**
|
||||
* APIProperty: upperBoundary
|
||||
* {Number} or {String}
|
||||
* upper boundary for between comparisons. In the case of a String, this
|
||||
* can be a combination of text and propertyNames in the form
|
||||
* "literal ${propertyName}"
|
||||
*/
|
||||
upperBoundary: null,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Rule.Comparison
|
||||
* Creates a comparison rule.
|
||||
*
|
||||
* Parameters:
|
||||
* params - {Object} Hash of parameters for this rule:
|
||||
* -
|
||||
* - value:
|
||||
* options - {Object} An optional object with properties to set on the
|
||||
* rule
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Rule.Comparison>}
|
||||
*/
|
||||
initialize: function(options) {
|
||||
OpenLayers.Rule.prototype.initialize.apply(this, [options]);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: evaluate
|
||||
* evaluates this rule for a specific context
|
||||
*
|
||||
* Parameters:
|
||||
* context - {Object} context to apply the rule to.
|
||||
*
|
||||
* Returns:
|
||||
* {boolean} true if the rule applies, false if it does not
|
||||
*/
|
||||
evaluate: function(feature) {
|
||||
if (!OpenLayers.Rule.prototype.evaluate.apply(this, arguments)) {
|
||||
return false;
|
||||
}
|
||||
var context = this.getContext(feature);
|
||||
switch(this.type) {
|
||||
case OpenLayers.Rule.Comparison.EQUAL_TO:
|
||||
case OpenLayers.Rule.Comparison.LESS_THAN:
|
||||
case OpenLayers.Rule.Comparison.GREATER_THAN:
|
||||
case OpenLayers.Rule.Comparison.LESS_THAN_OR_EQUAL_TO:
|
||||
case OpenLayers.Rule.Comparison.GREATER_THAN_OR_EQUAL_TO:
|
||||
return this.binaryCompare(context, this.property, this.value);
|
||||
|
||||
case OpenLayers.Rule.Comparison.BETWEEN:
|
||||
var result =
|
||||
context[this.property] > this.lowerBoundary;
|
||||
result = result &&
|
||||
context[this.property] < this.upperBoundary;
|
||||
return result;
|
||||
case OpenLayers.Rule.Comparison.LIKE:
|
||||
var regexp = new RegExp(this.value,
|
||||
"gi");
|
||||
return regexp.test(context[this.property]);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: value2regex
|
||||
* Converts the value of this rule into a regular expression string,
|
||||
* according to the wildcard characters specified. This method has to
|
||||
* be called after instantiation of this class, if the value is not a
|
||||
* regular expression already.
|
||||
*
|
||||
* Parameters:
|
||||
* wildCard - {<Char>} wildcard character in the above value, default
|
||||
* is "*"
|
||||
* singleChar - {<Char>) single-character wildcard in the above value
|
||||
* default is "."
|
||||
* escape - {<Char>) escape character in the above value, default is
|
||||
* "!"
|
||||
*
|
||||
* Returns:
|
||||
* {String} regular expression string
|
||||
*/
|
||||
value2regex: function(wildCard, singleChar, escapeChar) {
|
||||
if (wildCard == ".") {
|
||||
var msg = "'.' is an unsupported wildCard character for "+
|
||||
"OpenLayers.Rule.Comparison";
|
||||
OpenLayers.Console.error(msg);
|
||||
return null;
|
||||
}
|
||||
|
||||
// set UMN MapServer defaults for unspecified parameters
|
||||
wildCard = wildCard ? wildCard : "*";
|
||||
singleChar = singleChar ? singleChar : ".";
|
||||
escapeChar = escapeChar ? escapeChar : "!";
|
||||
|
||||
this.value = this.value.replace(
|
||||
new RegExp("\\"+escapeChar, "g"), "\\");
|
||||
this.value = this.value.replace(
|
||||
new RegExp("\\"+singleChar, "g"), ".");
|
||||
this.value = this.value.replace(
|
||||
new RegExp("\\"+wildCard, "g"), ".*");
|
||||
this.value = this.value.replace(
|
||||
new RegExp("\\\\.\\*", "g"), "\\"+wildCard);
|
||||
this.value = this.value.replace(
|
||||
new RegExp("\\\\\\.", "g"), "\\"+singleChar);
|
||||
|
||||
return this.value;
|
||||
},
|
||||
|
||||
/**
|
||||
* Function: binaryCompare
|
||||
* Compares a feature property to a rule value
|
||||
*
|
||||
* Parameters:
|
||||
* context - {Object}
|
||||
* property - {String} or {Number}
|
||||
* value - {String} or {Number}, same as property
|
||||
*
|
||||
* Returns:
|
||||
* {boolean}
|
||||
*/
|
||||
binaryCompare: function(context, property, value) {
|
||||
switch (this.type) {
|
||||
case OpenLayers.Rule.Comparison.EQUAL_TO:
|
||||
return context[property] == value;
|
||||
case OpenLayers.Rule.Comparison.NOT_EQUAL_TO:
|
||||
return context[property] != value;
|
||||
case OpenLayers.Rule.Comparison.LESS_THAN:
|
||||
return context[property] < value;
|
||||
case OpenLayers.Rule.Comparison.GREATER_THAN:
|
||||
return context[property] > value;
|
||||
case OpenLayers.Rule.Comparison.LESS_THAN_OR_EQUAL_TO:
|
||||
return context[property] <= value;
|
||||
case OpenLayers.Rule.Comparison.GREATER_THAN_OR_EQUAL_TO:
|
||||
return context[property] >= value;
|
||||
}
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Rule.Comparison"
|
||||
});
|
||||
|
||||
|
||||
OpenLayers.Rule.Comparison.EQUAL_TO = "==";
|
||||
OpenLayers.Rule.Comparison.NOT_EQUAL_TO = "!=";
|
||||
OpenLayers.Rule.Comparison.LESS_THAN = "<";
|
||||
OpenLayers.Rule.Comparison.GREATER_THAN = ">";
|
||||
OpenLayers.Rule.Comparison.LESS_THAN_OR_EQUAL_TO = "<=";
|
||||
OpenLayers.Rule.Comparison.GREATER_THAN_OR_EQUAL_TO = ">=";
|
||||
OpenLayers.Rule.Comparison.BETWEEN = "..";
|
||||
OpenLayers.Rule.Comparison.LIKE = "~";
|
||||
|
||||
@@ -1,69 +1,69 @@
|
||||
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
|
||||
* license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
* full text of the license. */
|
||||
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Rule.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Rule.FeatureId
|
||||
* This class represents a ogc:FeatureId Rule, as being used for rule-based SLD
|
||||
* styling
|
||||
*
|
||||
* Inherits from
|
||||
* - <OpenLayers.Rule>
|
||||
*/
|
||||
OpenLayers.Rule.FeatureId = OpenLayers.Class(OpenLayers.Rule, {
|
||||
|
||||
/**
|
||||
* APIProperty: fids
|
||||
* {Array(<String>)} Feature Ids to evaluate this rule against. To be passed
|
||||
* To be passed inside the params object.
|
||||
*/
|
||||
fids: null,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Rule.FeatureId
|
||||
* Creates an ogc:FeatureId rule.
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object} An optional object with properties to set on the
|
||||
* rule
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Rule.FeatureId>}
|
||||
*/
|
||||
initialize: function(options) {
|
||||
this.fids = [];
|
||||
OpenLayers.Rule.prototype.initialize.apply(this, [options]);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: evaluate
|
||||
* evaluates this rule for a specific feature
|
||||
*
|
||||
* Parameters:
|
||||
* feature - {<OpenLayers.Feature>} feature to apply the rule to.
|
||||
* For vector features, the check is run against the fid,
|
||||
* for plain features against the id.
|
||||
*
|
||||
* Returns:
|
||||
* {boolean} true if the rule applies, false if it does not
|
||||
*/
|
||||
evaluate: function(feature) {
|
||||
if (!OpenLayers.Rule.prototype.evaluate.apply(this, arguments)) {
|
||||
return false;
|
||||
}
|
||||
for (var i=0; i<this.fids.length; i++) {
|
||||
var fid = feature.fid || feature.id;
|
||||
if (fid == this.fids[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Rule.FeatureId"
|
||||
});
|
||||
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
|
||||
* license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
* full text of the license. */
|
||||
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Rule.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Rule.FeatureId
|
||||
* This class represents a ogc:FeatureId Rule, as being used for rule-based SLD
|
||||
* styling
|
||||
*
|
||||
* Inherits from
|
||||
* - <OpenLayers.Rule>
|
||||
*/
|
||||
OpenLayers.Rule.FeatureId = OpenLayers.Class(OpenLayers.Rule, {
|
||||
|
||||
/**
|
||||
* APIProperty: fids
|
||||
* {Array(<String>)} Feature Ids to evaluate this rule against. To be passed
|
||||
* To be passed inside the params object.
|
||||
*/
|
||||
fids: null,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Rule.FeatureId
|
||||
* Creates an ogc:FeatureId rule.
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object} An optional object with properties to set on the
|
||||
* rule
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Rule.FeatureId>}
|
||||
*/
|
||||
initialize: function(options) {
|
||||
this.fids = [];
|
||||
OpenLayers.Rule.prototype.initialize.apply(this, [options]);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: evaluate
|
||||
* evaluates this rule for a specific feature
|
||||
*
|
||||
* Parameters:
|
||||
* feature - {<OpenLayers.Feature>} feature to apply the rule to.
|
||||
* For vector features, the check is run against the fid,
|
||||
* for plain features against the id.
|
||||
*
|
||||
* Returns:
|
||||
* {boolean} true if the rule applies, false if it does not
|
||||
*/
|
||||
evaluate: function(feature) {
|
||||
if (!OpenLayers.Rule.prototype.evaluate.apply(this, arguments)) {
|
||||
return false;
|
||||
}
|
||||
for (var i=0; i<this.fids.length; i++) {
|
||||
var fid = feature.fid || feature.id;
|
||||
if (fid == this.fids[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Rule.FeatureId"
|
||||
});
|
||||
|
||||
@@ -1,104 +1,104 @@
|
||||
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
|
||||
* license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
* full text of the license. */
|
||||
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Rule.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Rule.Logical
|
||||
* This class represents ogc:And, ogc:Or and ogc:Not rules.
|
||||
*
|
||||
* Inherits from
|
||||
* - <OpenLayers.Rule>
|
||||
*/
|
||||
OpenLayers.Rule.Logical = OpenLayers.Class(OpenLayers.Rule, {
|
||||
|
||||
/**
|
||||
* APIProperty: children
|
||||
* {Array(<OpenLayers.Rule>)} child rules for this rule
|
||||
*/
|
||||
rules: null,
|
||||
|
||||
/**
|
||||
* APIProperty: type
|
||||
* {String} type of logical operator. Available types are:
|
||||
* - OpenLayers.Rule.Locical.AND = "&&";
|
||||
* - OpenLayers.Rule.Logical.OR = "||";
|
||||
* - OpenLayers.Rule.Logical.NOT = "!";
|
||||
*/
|
||||
type: null,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Rule.Logical
|
||||
* Creates a logical rule (And, Or, Not).
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object} An optional object with properties to set on the
|
||||
* rule
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Rule.Logical>}
|
||||
*/
|
||||
initialize: function(options) {
|
||||
this.rules = [];
|
||||
OpenLayers.Rule.prototype.initialize.apply(this, [options]);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: destroy
|
||||
* nullify references to prevent circular references and memory leaks
|
||||
*/
|
||||
destroy: function() {
|
||||
for (var i=0; i<this.rules.length; i++) {
|
||||
this.rules[i].destroy();
|
||||
}
|
||||
this.rules = null;
|
||||
OpenLayers.Rule.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: evaluate
|
||||
* evaluates this rule for a specific feature
|
||||
*
|
||||
* Parameters:
|
||||
* feature - {<OpenLayers.Feature>} feature to apply the rule to.
|
||||
*
|
||||
* Returns:
|
||||
* {boolean} true if the rule applies, false if it does not
|
||||
*/
|
||||
evaluate: function(feature) {
|
||||
if (!OpenLayers.Rule.prototype.evaluate.apply(this, arguments)) {
|
||||
return false;
|
||||
}
|
||||
switch(this.type) {
|
||||
case OpenLayers.Rule.Logical.AND:
|
||||
for (var i=0; i<this.rules.length; i++) {
|
||||
if (this.rules[i].evaluate(feature) == false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
case OpenLayers.Rule.Logical.OR:
|
||||
for (var i=0; i<this.rules.length; i++) {
|
||||
if (this.rules[i].evaluate(feature) == true) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
case OpenLayers.Rule.Logical.NOT:
|
||||
return (!this.rules[0].evaluate(feature));
|
||||
}
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Rule.Logical"
|
||||
});
|
||||
|
||||
|
||||
OpenLayers.Rule.Logical.AND = "&&";
|
||||
OpenLayers.Rule.Logical.OR = "||";
|
||||
OpenLayers.Rule.Logical.NOT = "!";
|
||||
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
|
||||
* license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
* full text of the license. */
|
||||
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Rule.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Rule.Logical
|
||||
* This class represents ogc:And, ogc:Or and ogc:Not rules.
|
||||
*
|
||||
* Inherits from
|
||||
* - <OpenLayers.Rule>
|
||||
*/
|
||||
OpenLayers.Rule.Logical = OpenLayers.Class(OpenLayers.Rule, {
|
||||
|
||||
/**
|
||||
* APIProperty: children
|
||||
* {Array(<OpenLayers.Rule>)} child rules for this rule
|
||||
*/
|
||||
rules: null,
|
||||
|
||||
/**
|
||||
* APIProperty: type
|
||||
* {String} type of logical operator. Available types are:
|
||||
* - OpenLayers.Rule.Locical.AND = "&&";
|
||||
* - OpenLayers.Rule.Logical.OR = "||";
|
||||
* - OpenLayers.Rule.Logical.NOT = "!";
|
||||
*/
|
||||
type: null,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Rule.Logical
|
||||
* Creates a logical rule (And, Or, Not).
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object} An optional object with properties to set on the
|
||||
* rule
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Rule.Logical>}
|
||||
*/
|
||||
initialize: function(options) {
|
||||
this.rules = [];
|
||||
OpenLayers.Rule.prototype.initialize.apply(this, [options]);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: destroy
|
||||
* nullify references to prevent circular references and memory leaks
|
||||
*/
|
||||
destroy: function() {
|
||||
for (var i=0; i<this.rules.length; i++) {
|
||||
this.rules[i].destroy();
|
||||
}
|
||||
this.rules = null;
|
||||
OpenLayers.Rule.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: evaluate
|
||||
* evaluates this rule for a specific feature
|
||||
*
|
||||
* Parameters:
|
||||
* feature - {<OpenLayers.Feature>} feature to apply the rule to.
|
||||
*
|
||||
* Returns:
|
||||
* {boolean} true if the rule applies, false if it does not
|
||||
*/
|
||||
evaluate: function(feature) {
|
||||
if (!OpenLayers.Rule.prototype.evaluate.apply(this, arguments)) {
|
||||
return false;
|
||||
}
|
||||
switch(this.type) {
|
||||
case OpenLayers.Rule.Logical.AND:
|
||||
for (var i=0; i<this.rules.length; i++) {
|
||||
if (this.rules[i].evaluate(feature) == false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
case OpenLayers.Rule.Logical.OR:
|
||||
for (var i=0; i<this.rules.length; i++) {
|
||||
if (this.rules[i].evaluate(feature) == true) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
case OpenLayers.Rule.Logical.NOT:
|
||||
return (!this.rules[0].evaluate(feature));
|
||||
}
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Rule.Logical"
|
||||
});
|
||||
|
||||
|
||||
OpenLayers.Rule.Logical.AND = "&&";
|
||||
OpenLayers.Rule.Logical.OR = "||";
|
||||
OpenLayers.Rule.Logical.NOT = "!";
|
||||
|
||||
Reference in New Issue
Block a user