source:
trunk/workshop-routing-foss4g/web/OpenLayers/lib/OpenLayers/Filter/FeatureId.js
@
76
Revision 76, 2.2 KB checked in by djay, 12 years ago (diff) | |
---|---|
|
Rev | Line | |
---|---|---|
[76] | 1 | /* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for |
2 | * full list of contributors). Published under the Clear BSD license. | |
3 | * See http://svn.openlayers.org/trunk/openlayers/license.txt for the | |
4 | * full text of the license. */ | |
5 | ||
6 | ||
7 | /** | |
8 | * @requires OpenLayers/Filter.js | |
9 | */ | |
10 | ||
11 | /** | |
12 | * Class: OpenLayers.Filter.FeatureId | |
13 | * This class represents a ogc:FeatureId Filter, as being used for rule-based SLD | |
14 | * styling | |
15 | * | |
16 | * Inherits from | |
17 | * - <OpenLayers.Filter> | |
18 | */ | |
19 | OpenLayers.Filter.FeatureId = OpenLayers.Class(OpenLayers.Filter, { | |
20 | ||
21 | /** | |
22 | * APIProperty: fids | |
23 | * {Array(String)} Feature Ids to evaluate this rule against. To be passed | |
24 | * To be passed inside the params object. | |
25 | */ | |
26 | fids: null, | |
27 | ||
28 | /** | |
29 | * Constructor: OpenLayers.Filter.FeatureId | |
30 | * Creates an ogc:FeatureId rule. | |
31 | * | |
32 | * Parameters: | |
33 | * options - {Object} An optional object with properties to set on the | |
34 | * rule | |
35 | * | |
36 | * Returns: | |
37 | * {<OpenLayers.Filter.FeatureId>} | |
38 | */ | |
39 | initialize: function(options) { | |
40 | this.fids = []; | |
41 | OpenLayers.Filter.prototype.initialize.apply(this, [options]); | |
42 | }, | |
43 | ||
44 | /** | |
45 | * APIMethod: evaluate | |
46 | * evaluates this rule for a specific feature | |
47 | * | |
48 | * Parameters: | |
49 | * feature - {<OpenLayers.Feature>} feature to apply the rule to. | |
50 | * For vector features, the check is run against the fid, | |
51 | * for plain features against the id. | |
52 | * | |
53 | * Returns: | |
54 | * {Boolean} true if the rule applies, false if it does not | |
55 | */ | |
56 | evaluate: function(feature) { | |
57 | for (var i=0, len=this.fids.length; i<len; i++) { | |
58 | var fid = feature.fid || feature.id; | |
59 | if (fid == this.fids[i]) { | |
60 | return true; | |
61 | } | |
62 | } | |
63 | return false; | |
64 | }, | |
65 | ||
66 | /** | |
67 | * APIMethod: clone | |
68 | * Clones this filter. | |
69 | * | |
70 | * Returns: | |
71 | * {<OpenLayers.Filter.FeatureId>} Clone of this filter. | |
72 | */ | |
73 | clone: function() { | |
74 | var filter = new OpenLayers.Filter.FeatureId(); | |
75 | OpenLayers.Util.extend(filter, this); | |
76 | filter.fids = this.fids.slice(); | |
77 | return filter; | |
78 | }, | |
79 | ||
80 | CLASS_NAME: "OpenLayers.Filter.FeatureId" | |
81 | }); |
Note: See TracBrowser
for help on using the repository browser.