mapcomplete/Customizations/Layers/GrbToFix.ts

108 lines
3.9 KiB
TypeScript
Raw Normal View History

2020-07-05 18:59:47 +02:00
import {LayerDefinition} from "../LayerDefinition";
import {And, Regex, Tag} from "../../Logic/TagsFilter";
2020-07-31 17:38:03 +02:00
import {TagRenderingOptions} from "../TagRenderingOptions";
2020-07-05 18:59:47 +02:00
export class GrbToFix extends LayerDefinition {
constructor() {
2020-07-31 04:58:58 +02:00
super("grb");
2020-07-05 18:59:47 +02:00
this.name = "grb";
this.presets = [];
2020-07-05 18:59:47 +02:00
this.icon = "./assets/star.svg";
this.overpassFilter = new Regex("fixme", "GRB");
this.minzoom = 13;
this.style = function (tags) {
return {
icon: {
2020-07-05 18:59:47 +02:00
iconUrl: "assets/star.svg",
iconSize: [40, 40],
},
2020-07-05 18:59:47 +02:00
color: "#ff0000"
};
}
this.title = new TagRenderingOptions({
freeform: {
key: "addr:street",
renderTemplate: "{addr:street} <b>{addr:housenumber}</b>",
2020-07-05 18:59:47 +02:00
template: "Fixme $$$"
},
mappings: [
{
k: new Tag("fixme","*"),
txt: "{fixme}"
}
]
2020-07-05 18:59:47 +02:00
})
this.elementsToShow = [
new TagRenderingOptions(
{
freeform: {
key: "addr:housenumber",
2020-07-05 18:59:47 +02:00
renderTemplate: "Het adres is {addr:street} <b>{addr:housenumber}</b>",
template: "Straat? $$$",
},
question: "Wat is het huisnummer?"
2020-07-05 18:59:47 +02:00
}
2020-08-27 01:03:58 +02:00
),
2020-07-05 18:59:47 +02:00
new TagRenderingOptions({
question: "Wat is het huisnummer?",
tagsPreprocessor: tags => {
const telltale = "GRB thinks that this has number ";
const index = tags.fixme.indexOf(telltale);
if (index >= 0) {
const housenumber = tags.fixme.slice(index + telltale.length);
tags["grb:housenumber:human"] = housenumber;
tags["grb:housenumber"] = housenumber == "no number" ? "" : housenumber;
2020-07-05 18:59:47 +02:00
}
},
2020-07-06 13:47:22 +02:00
freeform: {
key: "addr:housenumber",
template: "Het huisnummer is $$$",
renderTemplate: "Het adres is {addr:street} <b>{addr:housenumber}</b>, GRB denkt <i>{grb:housenumber:human}</i>",
extraTags: new And([new Tag("fixme", ""), new Tag("not:addr:housenumber", "")])
2020-07-06 13:47:22 +02:00
},
2020-07-05 18:59:47 +02:00
mappings: [
{
k: new And([new Tag("addr:housenumber", "{grb:housenumber}"), new Tag("fixme", ""), new Tag("not:addr:housenumber", "")]),
2020-07-05 18:59:47 +02:00
txt: "Volg GRB: <b>{grb:housenumber:human}</b>",
substitute: true
},
{
k: new And([new Tag("addr:housenumber", "{addr:housenumber}"), new Tag("fixme", ""), new Tag("not:addr:housenumber", "")]),
2020-07-05 18:59:47 +02:00
txt: "Volg OSM: <b>{addr:housenumber}</b>",
substitute: true
},
{
k: new And([new Tag("building", "garage"),
new Tag("not:addr:housenumber", "yes"),
new Tag("addr:housenumber", ""), new Tag("fixme", "")]),
txt: "Dit is een garage(poort) zonder nummer",
substitute: true
},
{
k: new And([
new Tag("not:addr:housenumber", "yes"),
new Tag("addr:housenumber", ""), new Tag("fixme", "")]),
txt: "Gewoon een huis zonder nummer",
substitute: true
},
2020-07-05 18:59:47 +02:00
]
}).OnlyShowIf(new Tag("fixme", "*"))
2020-07-05 18:59:47 +02:00
];
}
}