632a63a0a9f3b190aed740cbe70007aaf66c6bc0.svn-base
2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for
* full list of contributors). Published under the Clear BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
* full text of the license. */
/**
* @requires OpenLayers/Filter.js
*/
/**
* Class: OpenLayers.Filter.FeatureId
* This class represents a ogc:FeatureId Filter, as being used for rule-based SLD
* styling
*
* Inherits from
* - <OpenLayers.Filter>
*/
OpenLayers.Filter.FeatureId = OpenLayers.Class(OpenLayers.Filter, {
/**
* APIProperty: fids
* {Array(String)} Feature Ids to evaluate this rule against. To be passed
* To be passed inside the params object.
*/
fids: null,
/**
* Property: type
* {String} Type to identify this filter.
*/
type: "FID",
/**
* Constructor: OpenLayers.Filter.FeatureId
* Creates an ogc:FeatureId rule.
*
* Parameters:
* options - {Object} An optional object with properties to set on the
* rule
*
* Returns:
* {<OpenLayers.Filter.FeatureId>}
*/
initialize: function(options) {
this.fids = [];
OpenLayers.Filter.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) {
for (var i=0, len=this.fids.length; i<len; i++) {
var fid = feature.fid || feature.id;
if (fid == this.fids[i]) {
return true;
}
}
return false;
},
/**
* APIMethod: clone
* Clones this filter.
*
* Returns:
* {<OpenLayers.Filter.FeatureId>} Clone of this filter.
*/
clone: function() {
var filter = new OpenLayers.Filter.FeatureId();
OpenLayers.Util.extend(filter, this);
filter.fids = this.fids.slice();
return filter;
},
CLASS_NAME: "OpenLayers.Filter.FeatureId"
});