-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
filter.js
301 lines (281 loc) · 9.8 KB
/
filter.js
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
/**
* @module ol/format/filter
*/
import And from './filter/And.js';
import Bbox from './filter/Bbox.js';
import Contains from './filter/Contains.js';
import DWithin from './filter/DWithin.js';
import Disjoint from './filter/Disjoint.js';
import During from './filter/During.js';
import EqualTo from './filter/EqualTo.js';
import GreaterThan from './filter/GreaterThan.js';
import GreaterThanOrEqualTo from './filter/GreaterThanOrEqualTo.js';
import Intersects from './filter/Intersects.js';
import IsBetween from './filter/IsBetween.js';
import IsLike from './filter/IsLike.js';
import IsNull from './filter/IsNull.js';
import LessThan from './filter/LessThan.js';
import LessThanOrEqualTo from './filter/LessThanOrEqualTo.js';
import Not from './filter/Not.js';
import NotEqualTo from './filter/NotEqualTo.js';
import Or from './filter/Or.js';
import ResourceId from './filter/ResourceId.js';
import Within from './filter/Within.js';
/**
* Create a logical `<And>` operator between two or more filter conditions.
*
* @param {...import("./filter/Filter.js").default} conditions Filter conditions.
* @return {!And} `<And>` operator.
* @api
*/
export function and(conditions) {
const params = [null].concat(Array.prototype.slice.call(arguments));
return new (Function.prototype.bind.apply(And, params))();
}
/**
* Create a logical `<Or>` operator between two or more filter conditions.
*
* @param {...import("./filter/Filter.js").default} conditions Filter conditions.
* @return {!Or} `<Or>` operator.
* @api
*/
export function or(conditions) {
const params = [null].concat(Array.prototype.slice.call(arguments));
return new (Function.prototype.bind.apply(Or, params))();
}
/**
* Represents a logical `<Not>` operator for a filter condition.
*
* @param {!import("./filter/Filter.js").default} condition Filter condition.
* @return {!Not} `<Not>` operator.
* @api
*/
export function not(condition) {
return new Not(condition);
}
/**
* Create a `<BBOX>` operator to test whether a geometry-valued property
* intersects a fixed bounding box
*
* @param {!string} geometryName Geometry name to use.
* @param {!import("../extent.js").Extent} extent Extent.
* @param {string} [srsName] SRS name. No srsName attribute will be
* set on geometries when this is not provided.
* @return {!Bbox} `<BBOX>` operator.
* @api
*/
export function bbox(geometryName, extent, srsName) {
return new Bbox(geometryName, extent, srsName);
}
/**
* Create a `<Contains>` operator to test whether a geometry-valued property
* contains a given geometry.
*
* @param {!string} geometryName Geometry name to use.
* @param {!import("../geom/Geometry.js").default} geometry Geometry.
* @param {string} [srsName] SRS name. No srsName attribute will be
* set on geometries when this is not provided.
* @return {!Contains} `<Contains>` operator.
* @api
*/
export function contains(geometryName, geometry, srsName) {
return new Contains(geometryName, geometry, srsName);
}
/**
* Create a `<Intersects>` operator to test whether a geometry-valued property
* intersects a given geometry.
*
* @param {!string} geometryName Geometry name to use.
* @param {!import("../geom/Geometry.js").default} geometry Geometry.
* @param {string} [srsName] SRS name. No srsName attribute will be
* set on geometries when this is not provided.
* @return {!Intersects} `<Intersects>` operator.
* @api
*/
export function intersects(geometryName, geometry, srsName) {
return new Intersects(geometryName, geometry, srsName);
}
/**
* Create a `<Disjoint>` operator to test whether a geometry-valued property
* is disjoint to a given geometry.
*
* @param {!string} geometryName Geometry name to use.
* @param {!import("../geom/Geometry.js").default} geometry Geometry.
* @param {string} [srsName] SRS name. No srsName attribute will be
* set on geometries when this is not provided.
* @return {!Disjoint} `<Disjoint>` operator.
* @api
*/
export function disjoint(geometryName, geometry, srsName) {
return new Disjoint(geometryName, geometry, srsName);
}
/**
* Create a `<Within>` operator to test whether a geometry-valued property
* is within a given geometry.
*
* @param {!string} geometryName Geometry name to use.
* @param {!import("../geom/Geometry.js").default} geometry Geometry.
* @param {string} [srsName] SRS name. No srsName attribute will be
* set on geometries when this is not provided.
* @return {!Within} `<Within>` operator.
* @api
*/
export function within(geometryName, geometry, srsName) {
return new Within(geometryName, geometry, srsName);
}
/**
* Create a `<DWithin>` operator to test whether a geometry-valued property
* is within a distance to a given geometry.
*
* @param {!string} geometryName Geometry name to use.
* @param {!import("../geom/Geometry.js").default} geometry Geometry.
* @param {!number} distance Distance.
* @param {!string} unit Unit.
* @param {string} [srsName] SRS name. No srsName attribute will be
* set on geometries when this is not provided.
* @return {!DWithin} `<DWithin>` operator.
* @api
*/
export function dwithin(geometryName, geometry, distance, unit, srsName) {
return new DWithin(geometryName, geometry, distance, unit, srsName);
}
/**
* Creates a `<PropertyIsEqualTo>` comparison operator.
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!(string|number)} expression The value to compare.
* @param {boolean} [matchCase] Case-sensitive?
* @return {!EqualTo} `<PropertyIsEqualTo>` operator.
* @api
*/
export function equalTo(propertyName, expression, matchCase) {
return new EqualTo(propertyName, expression, matchCase);
}
/**
* Creates a `<PropertyIsNotEqualTo>` comparison operator.
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!(string|number)} expression The value to compare.
* @param {boolean} [matchCase] Case-sensitive?
* @return {!NotEqualTo} `<PropertyIsNotEqualTo>` operator.
* @api
*/
export function notEqualTo(propertyName, expression, matchCase) {
return new NotEqualTo(propertyName, expression, matchCase);
}
/**
* Creates a `<PropertyIsLessThan>` comparison operator.
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!number} expression The value to compare.
* @return {!LessThan} `<PropertyIsLessThan>` operator.
* @api
*/
export function lessThan(propertyName, expression) {
return new LessThan(propertyName, expression);
}
/**
* Creates a `<PropertyIsLessThanOrEqualTo>` comparison operator.
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!number} expression The value to compare.
* @return {!LessThanOrEqualTo} `<PropertyIsLessThanOrEqualTo>` operator.
* @api
*/
export function lessThanOrEqualTo(propertyName, expression) {
return new LessThanOrEqualTo(propertyName, expression);
}
/**
* Creates a `<PropertyIsGreaterThan>` comparison operator.
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!number} expression The value to compare.
* @return {!GreaterThan} `<PropertyIsGreaterThan>` operator.
* @api
*/
export function greaterThan(propertyName, expression) {
return new GreaterThan(propertyName, expression);
}
/**
* Creates a `<PropertyIsGreaterThanOrEqualTo>` comparison operator.
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!number} expression The value to compare.
* @return {!GreaterThanOrEqualTo} `<PropertyIsGreaterThanOrEqualTo>` operator.
* @api
*/
export function greaterThanOrEqualTo(propertyName, expression) {
return new GreaterThanOrEqualTo(propertyName, expression);
}
/**
* Creates a `<PropertyIsNull>` comparison operator to test whether a property value
* is null.
*
* @param {!string} propertyName Name of the context property to compare.
* @return {!IsNull} `<PropertyIsNull>` operator.
* @api
*/
export function isNull(propertyName) {
return new IsNull(propertyName);
}
/**
* Creates a `<PropertyIsBetween>` comparison operator to test whether an expression
* value lies within a range given by a lower and upper bound (inclusive).
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!number} lowerBoundary The lower bound of the range.
* @param {!number} upperBoundary The upper bound of the range.
* @return {!IsBetween} `<PropertyIsBetween>` operator.
* @api
*/
export function between(propertyName, lowerBoundary, upperBoundary) {
return new IsBetween(propertyName, lowerBoundary, upperBoundary);
}
/**
* Represents a `<PropertyIsLike>` comparison operator that matches a string property
* value against a text pattern.
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!string} pattern Text pattern.
* @param {string} [wildCard] Pattern character which matches any sequence of
* zero or more string characters. Default is '*'.
* @param {string} [singleChar] pattern character which matches any single
* string character. Default is '.'.
* @param {string} [escapeChar] Escape character which can be used to escape
* the pattern characters. Default is '!'.
* @param {boolean} [matchCase] Case-sensitive?
* @return {!IsLike} `<PropertyIsLike>` operator.
* @api
*/
export function like(
propertyName,
pattern,
wildCard,
singleChar,
escapeChar,
matchCase,
) {
return new IsLike(
propertyName,
pattern,
wildCard,
singleChar,
escapeChar,
matchCase,
);
}
/**
* Create a `<During>` temporal operator.
*
* @param {!string} propertyName Name of the context property to compare.
* @param {!string} begin The begin date in ISO-8601 format.
* @param {!string} end The end date in ISO-8601 format.
* @return {!During} `<During>` operator.
* @api
*/
export function during(propertyName, begin, end) {
return new During(propertyName, begin, end);
}
export function resourceId(rid) {
return new ResourceId(rid);
}