mapcomplete/Customizations/Layers/Bos.ts

73 lines
2.1 KiB
TypeScript
Raw Normal View History

2020-06-23 22:35:19 +00:00
import {LayerDefinition} from "../LayerDefinition";
2020-07-05 16:59:47 +00:00
import {Quests} from "../../Quests";
import {And, Or, Tag} from "../../Logic/TagsFilter";
import {AccessTag} from "../Questions/AccessTag";
import {OperatorTag} from "../Questions/OperatorTag";
import {TagRenderingOptions} from "../TagRendering";
import {NameQuestion} from "../Questions/NameQuestion";
import {NameInline} from "../Questions/NameInline";
2020-06-23 22:35:19 +00:00
export class Bos extends LayerDefinition {
constructor() {
super();
this.name = "bos";
this.icon = "./assets/tree_white_background.svg";
this.overpassFilter = new Or([
new Tag("natural", "wood"),
new Tag("landuse", "forest"),
new Tag("natural", "scrub")
]
);
this.newElementTags = [
new Tag("landuse", "forest"),
new Tag("fixme", "Toegevoegd met MapComplete, geometry nog uit te tekenen")
];
2020-06-28 21:33:48 +00:00
this.maxAllowedOverlapPercentage = 10;
2020-06-23 22:35:19 +00:00
2020-07-01 19:21:29 +00:00
this.minzoom = 13;
2020-06-23 22:35:19 +00:00
this.style = this.generateStyleFunction();
2020-07-05 16:59:47 +00:00
this.title = new NameInline("bos");
2020-06-23 22:35:19 +00:00
this.elementsToShow = [
2020-07-05 16:59:47 +00:00
new NameQuestion(),
new AccessTag(),
new OperatorTag()
2020-06-23 22:35:19 +00:00
];
}
private generateStyleFunction() {
const self = this;
return function (properties: any) {
let questionSeverity = 0;
2020-07-05 16:59:47 +00:00
for (const qd of self.elementsToShow) {
if (qd.IsQuestioning(properties)) {
questionSeverity = Math.max(questionSeverity, qd.options.priority ?? 0);
2020-06-23 22:35:19 +00:00
}
}
let colormapping = {
0: "#00bb00",
1: "#00ff00",
10: "#dddd00",
20: "#ff0000"
};
let colour = colormapping[questionSeverity];
while (colour == undefined) {
questionSeverity--;
2020-07-05 16:59:47 +00:00
colour = colormapping[questionSeverity];
2020-06-23 22:35:19 +00:00
}
return {
color: colour,
icon: undefined
2020-06-23 22:35:19 +00:00
};
};
}
}