forked from MapComplete/MapComplete
Port bird-hides to new JSON-format, various improvements
This commit is contained in:
parent
00a6611e1f
commit
9e4035befc
22 changed files with 460 additions and 378 deletions
|
@ -15,6 +15,8 @@ import * as drinkingWater from "../../assets/layers/drinking_water/drinking_wate
|
|||
import * as ghostbikes from "../../assets/layers/ghost_bike/ghost_bike.json"
|
||||
import * as viewpoint from "../../assets/layers/viewpoint/viewpoint.json"
|
||||
import * as bike_parking from "../../assets/layers/bike_parking/bike_parking.json"
|
||||
import * as birdhides from "../../assets/layers/bird_hide/birdhides.json"
|
||||
|
||||
import {Utils} from "../../Utils";
|
||||
|
||||
export class FromJSON {
|
||||
|
@ -29,6 +31,7 @@ export class FromJSON {
|
|||
FromJSON.Layer(ghostbikes),
|
||||
FromJSON.Layer(viewpoint),
|
||||
FromJSON.Layer(bike_parking),
|
||||
FromJSON.Layer(birdhides),
|
||||
];
|
||||
|
||||
for (const layer of sharedLayersList) {
|
||||
|
|
|
@ -1,164 +0,0 @@
|
|||
import {LayerDefinition} from "../LayerDefinition";
|
||||
import {And, Or, Tag} from "../../Logic/Tags";
|
||||
import {ImageCarouselWithUploadConstructor} from "../../UI/Image/ImageCarouselWithUpload";
|
||||
import {TagRenderingOptions} from "../TagRenderingOptions";
|
||||
|
||||
export class Birdhide extends LayerDefinition {
|
||||
|
||||
private static readonly birdhide = new Tag("leisure", "bird_hide");
|
||||
|
||||
|
||||
constructor() {
|
||||
super("birdhide",{
|
||||
name: "vogelkijkplaats",
|
||||
description: "Een plaats om vogels te kijken, zoals een vogelkijkhut of kijkwand",
|
||||
overpassFilter: Birdhide.birdhide,
|
||||
elementsToShow: [],
|
||||
icon: "assets/nature/birdhide.svg",
|
||||
minzoom: 12,
|
||||
wayHandling: LayerDefinition.WAYHANDLING_CENTER_AND_WAY,
|
||||
presets: [
|
||||
{
|
||||
title: "Vogelkijkplaats",
|
||||
tags: [Birdhide.birdhide]
|
||||
}
|
||||
],
|
||||
style(): { color: string; icon: any } {
|
||||
return {color: "", icon: undefined};
|
||||
},
|
||||
});
|
||||
|
||||
function rmStart(toRemove: string, title: string): string {
|
||||
if (title.toLowerCase().indexOf(toRemove.toLowerCase()) == 0) {
|
||||
return title.substr(toRemove.length).trim();
|
||||
}
|
||||
return title;
|
||||
|
||||
}
|
||||
|
||||
function rmStarts(toRemove: string[], title: string) {
|
||||
for (const toRm of toRemove) {
|
||||
title = rmStart(toRm, title);
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
this.title = new TagRenderingOptions({
|
||||
tagsPreprocessor: (tags) => {
|
||||
if (tags.name) {
|
||||
const nm =
|
||||
rmStarts(
|
||||
["Vogelkijkhut", "Vogelkijkwand", "Kijkwand", "Kijkhut"],
|
||||
tags.name);
|
||||
|
||||
tags.name = " '" + nm + "'";
|
||||
} else {
|
||||
tags.name = "";
|
||||
}
|
||||
},
|
||||
mappings: [
|
||||
{
|
||||
k: new And([new Tag("shelter", "no"), new Tag("building", "")]),
|
||||
txt: "Vogelkijkwand{name}"
|
||||
},
|
||||
{
|
||||
k: new And([new Tag("amenity", "shelter"), new Tag("building", "yes")]),
|
||||
txt: "Vogelijkhut{name}"
|
||||
},
|
||||
{
|
||||
k: new Tag("amenity", "shelter"),
|
||||
txt: "Vogelijkhut{name}"
|
||||
},
|
||||
{
|
||||
k: new Tag("shelter", "yes"),
|
||||
txt: "Vogelijkhut{name}"
|
||||
},
|
||||
{
|
||||
k: new Tag("amenity", "shelter"),
|
||||
txt: "Vogelijkhut{name}"
|
||||
},
|
||||
{
|
||||
k: new Tag("building", "yes"),
|
||||
txt: "Vogelijkhut{name}"
|
||||
},
|
||||
{k: null, txt: "Vogelkijkplaats{name}"}
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
this.style = (properties) => {
|
||||
let icon = "assets/nature/birdhide.svg";
|
||||
if (new Or([new Tag("amenity", "shelter"), new Tag("building", "yes"), new Tag("shelter", "yes")]).matchesProperties(properties)) {
|
||||
icon = "assets/nature/birdshelter.svg";
|
||||
}
|
||||
|
||||
return {
|
||||
color: "#0000bb",
|
||||
icon: {
|
||||
iconUrl: icon,
|
||||
iconSize: [40,40],
|
||||
iconAnchor: [20,20]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.elementsToShow = [
|
||||
new ImageCarouselWithUploadConstructor(),
|
||||
|
||||
new TagRenderingOptions({
|
||||
question: "Is dit een kijkwand of kijkhut?",
|
||||
mappings: [
|
||||
{
|
||||
k: new And([new Tag("shelter", "no"), new Tag("building", ""), new Tag("amenity", "")]),
|
||||
txt: "Vogelkijkwand"
|
||||
},
|
||||
{
|
||||
k: new And([new Tag("amenity", "shelter"), new Tag("building", "yes"), new Tag("shelter", "yes")]),
|
||||
txt: "Vogelijkhut"
|
||||
},
|
||||
{
|
||||
k: new Or([new Tag("amenity", "shelter"), new Tag("building", "yes"), new Tag("shelter", "yes")]),
|
||||
txt: "Vogelijkhut"
|
||||
},
|
||||
|
||||
]
|
||||
}),
|
||||
new TagRenderingOptions({
|
||||
question: "Is ze rolstoeltoegankelijk?",
|
||||
mappings: [
|
||||
{
|
||||
k: new Tag("wheelchair", "no"),
|
||||
txt: "Niet rolstoeltoegankelijk"
|
||||
},
|
||||
{
|
||||
k: new Tag("wheelchair", "limited"),
|
||||
txt: "Een rolstoel raakt er, maar het is niet makkelijk"
|
||||
},
|
||||
{
|
||||
k: new Tag("wheelchair", "yes"),
|
||||
txt: "Een rolstoel raakt er gemakkelijk"
|
||||
}
|
||||
]
|
||||
}),
|
||||
|
||||
new TagRenderingOptions({
|
||||
question: "Wie beheert deze?",
|
||||
freeform: {
|
||||
key: "operator",
|
||||
template: "Beheer door $$$",
|
||||
renderTemplate: "Beheer door {operator}",
|
||||
placeholder: "organisatie"
|
||||
},
|
||||
mappings: [
|
||||
{k: new Tag("operator", "Natuurpunt"), txt: "Natuurpunt"},
|
||||
{k: new Tag("operator", "Agentschap Natuur en Bos"), txt: "het Agentschap Natuur en Bos (ANB)"},
|
||||
|
||||
]
|
||||
})
|
||||
|
||||
|
||||
];
|
||||
|
||||
}
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
import {Layout} from "../Layout";
|
||||
import {Birdhide} from "../Layers/Birdhide";
|
||||
import {InformationBoard} from "../Layers/InformationBoard";
|
||||
import {NatureReserves} from "../Layers/NatureReserves";
|
||||
|
||||
|
@ -9,7 +8,7 @@ export class Natuurpunt extends Layout{
|
|||
"natuurpunt",
|
||||
["nl"],
|
||||
"De natuur in",
|
||||
[new Birdhide(), new InformationBoard(), new NatureReserves(true), "drinking_water"],
|
||||
["birdhides", new InformationBoard(), new NatureReserves(true), "drinking_water"],
|
||||
12,
|
||||
51.20875,
|
||||
3.22435,
|
||||
|
@ -17,6 +16,6 @@ export class Natuurpunt extends Layout{
|
|||
"",
|
||||
""
|
||||
);
|
||||
this.icon = "./assets/nature/birdhide.svg"
|
||||
this.icon = "./assets/layers/bird_hide/birdhide.svg"
|
||||
}
|
||||
}
|
|
@ -103,8 +103,9 @@ class OnlyShowIf extends UIElement implements TagDependantUIElement {
|
|||
return this._embedded.IsQuestioning();
|
||||
}
|
||||
|
||||
Activate(): void {
|
||||
Activate(): UIElement {
|
||||
this._embedded.Activate();
|
||||
return this;
|
||||
}
|
||||
|
||||
Update(): void {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue