-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgeoRegexFilter.ts
More file actions
38 lines (30 loc) · 970 Bytes
/
geoRegexFilter.ts
File metadata and controls
38 lines (30 loc) · 970 Bytes
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
import { GeoFilter } from "./geoFilter";
import { GeoFilterItem } from "./geoFilterItem";
export class GeoRegexFilter extends GeoFilter {
regex: RegExp;
constructor(filterItems: GeoFilterItem[]) {
super(filterItems);
}
initializeCore() {
let value = this.filterItems[0].value;
value = value.slice(2, value.length - 1);
this.regex = new RegExp(value, "g");
this.key = this.filterItems[0].key;
}
matchFeatureCore(feature: any, zoom: number): boolean {
let currentValue;
if (this.replacedValueToIndex) {
currentValue = feature.properties[this.key];
}
else {
currentValue = feature.properties[this.key];
}
if (!currentValue) {
return false;
}
return currentValue.toString().match(this.regex) !== null;
}
replaceVaulesToPbfIndexCore(pbfLayer) {
this.replacedValueToIndex = true;
}
}