mapcomplete/Customizations/Layers/Park.ts

107 lines
3.4 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 {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";
import {DescriptionQuestion} from "../Questions/DescriptionQuestion";
import {ImageCarouselWithUploadConstructor} from "../../UI/Image/ImageCarouselWithUpload";
2020-06-23 22:35:19 +00:00
export class Park extends LayerDefinition {
2020-07-08 14:11:40 +00:00
2020-07-08 09:23:36 +00:00
private accessByDefault = new TagRenderingOptions({
question: "Is dit park publiek toegankelijk?",
mappings: [
2020-07-08 14:11:40 +00:00
{k: new Tag("access", "yes"), txt: "Publiek toegankelijk"},
{k: new Tag("access", ""), txt: "Publiek toegankelijk"},
{k: new Tag("access", "no"), txt: "Niet publiek toegankelijk"},
{k: new Tag("access", "private"), txt: "Niet publiek toegankelijk, want privaat"},
{k: new Tag("access", "guided"), txt: "Enkel toegankelijk met een gids of op een activiteit"},
],
freeform: {
key: "access",
renderTemplate: "Dit park is niet toegankelijk: {access}",
template: "De toegankelijkheid van dit park is: $$$"
},
priority: 20
2020-07-08 09:23:36 +00:00
})
2020-07-08 14:11:40 +00:00
private operatorByDefault = new
TagRenderingOptions({
question: "Wie beheert dit park?",
freeform: {
key: "operator",
renderTemplate: "Dit park wordt beheerd door {operator}",
template: "$$$",
},
mappings: [{
k: null, txt: "De gemeente beheert dit park"
}],
priority: 15
2020-07-08 14:11:40 +00:00
});
2020-06-23 22:35:19 +00:00
constructor() {
super();
this.name = "Park";
this.icon = undefined;
2020-07-05 16:59:47 +00:00
this.overpassFilter =
new Or([new Tag("leisure", "park"), new Tag("landuse", "village_green")]);
this.newElementTags = [new Tag("leisure", "park"),
2020-06-23 22:35:19 +00:00
new Tag("fixme", "Toegevoegd met MapComplete, geometry nog uit te tekenen")];
2020-06-28 21:33:48 +00:00
this.maxAllowedOverlapPercentage = 25;
2020-06-23 22:35:19 +00:00
this.minzoom = 13;
this.style = this.generateStyleFunction();
2020-07-05 16:59:47 +00:00
this.title = new NameInline("park");
this.elementsToShow = [
new ImageCarouselWithUploadConstructor(),
new NameQuestion(),
2020-07-08 14:11:40 +00:00
this.accessByDefault,
this.operatorByDefault,
new DescriptionQuestion("park"),
2020-07-08 14:07:16 +00:00
2020-07-08 09:23:36 +00:00
];
2020-06-23 22:35:19 +00:00
}
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 instanceof DescriptionQuestion) {
continue;
}
2020-07-05 16:59:47 +00:00
if (qd.IsQuestioning(properties)) {
questionSeverity = Math.max(questionSeverity, qd.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
};
};
}
}