mapcomplete/Customizations/Layers/NatureReserves.ts

69 lines
2.4 KiB
TypeScript
Raw Normal View History

2020-06-24 00:35:19 +02:00
import {LayerDefinition} from "../LayerDefinition";
2020-07-05 18:59:47 +02:00
import {Or, Tag} from "../../Logic/TagsFilter";
import {TagRenderingOptions} from "../TagRendering";
import {AccessTag} from "../Questions/AccessTag";
import {OperatorTag} from "../Questions/OperatorTag";
import {NameQuestion} from "../Questions/NameQuestion";
import {NameInline} from "../Questions/NameInline";
import {DescriptionQuestion} from "../Questions/DescriptionQuestion";
import {ImageCarouselWithUploadConstructor} from "../../UI/Image/ImageCarouselWithUpload";
2020-06-24 00:35:19 +02:00
export class NatureReserves extends LayerDefinition {
constructor() {
super();
this.name = "natuurgebied";
this.icon = "./assets/tree_white_background.svg";
this.overpassFilter =
new Or([new Tag("leisure", "nature_reserve"), new Tag("boundary","protected_area")]);
2020-06-28 23:33:48 +02:00
this.maxAllowedOverlapPercentage = 10;
2020-06-24 00:35:19 +02:00
this.newElementTags = [new Tag("leisure", "nature_reserve"),
new Tag("fixme", "Toegevoegd met MapComplete, geometry nog uit te tekenen")]
this.minzoom = 13;
2020-07-05 18:59:47 +02:00
this.title = new NameInline("natuurreservaat");
2020-06-24 00:35:19 +02:00
this.style = this.generateStyleFunction();
this.elementsToShow = [
new ImageCarouselWithUploadConstructor(),
2020-07-05 18:59:47 +02:00
new NameQuestion(),
new AccessTag(),
new OperatorTag(),
new DescriptionQuestion("natuurgebied")
2020-06-24 00:35:19 +02:00
];
}
private generateStyleFunction() {
const self = this;
return function (properties: any) {
let questionSeverity = 0;
2020-07-05 18:59:47 +02:00
for (const qd of self.elementsToShow) {
if(qd instanceof DescriptionQuestion){
continue;
}
2020-07-05 18:59:47 +02:00
if (qd.IsQuestioning(properties)) {
questionSeverity = Math.max(questionSeverity, qd.Priority() ?? 0);
2020-06-24 00:35:19 +02:00
}
}
let colormapping = {
0: "#00bb00",
1: "#00ff00",
10: "#dddd00",
20: "#ff0000"
};
let colour = colormapping[questionSeverity];
while (colour == undefined) {
questionSeverity--;
2020-07-05 18:59:47 +02:00
colour = colormapping[questionSeverity];
2020-06-24 00:35:19 +02:00
}
return {
color: colour,
icon: undefined
2020-06-24 00:35:19 +02:00
};
};
}
}