From 7e2904d3c0f4a8e889b07f1082e9ff8f0ed22b6b Mon Sep 17 00:00:00 2001 From: Pieter Fiers Date: Mon, 13 Jul 2020 17:16:12 +0200 Subject: [PATCH] Added bike services layer and questions --- Customizations/Layers/BikeParkings.ts | 15 +--- Customizations/Layers/BikePumps.ts | 77 ------------------- Customizations/Layers/BikeServices.ts | 56 ++++++++++++++ Customizations/Layouts/Cyclofix.ts | 12 +-- Customizations/Questions/BikeParkingType.ts | 5 +- Customizations/Questions/BikeStationBrand.ts | 22 ++++++ Customizations/Questions/BikeStationChain.ts | 18 +++++ .../Questions/BikeStationOperator.ts | 25 ++++++ .../Questions/BikeStationPumpTools.ts | 19 +++++ Customizations/Questions/BikeStationStand.ts | 18 +++++ Customizations/Questions/PumpManual.ts | 15 ++-- assets/parking.svg | 7 ++ assets/wrench.svg | 7 ++ 13 files changed, 188 insertions(+), 108 deletions(-) delete mode 100644 Customizations/Layers/BikePumps.ts create mode 100644 Customizations/Layers/BikeServices.ts create mode 100644 Customizations/Questions/BikeStationBrand.ts create mode 100644 Customizations/Questions/BikeStationChain.ts create mode 100644 Customizations/Questions/BikeStationOperator.ts create mode 100644 Customizations/Questions/BikeStationPumpTools.ts create mode 100644 Customizations/Questions/BikeStationStand.ts create mode 100644 assets/parking.svg create mode 100644 assets/wrench.svg diff --git a/Customizations/Layers/BikeParkings.ts b/Customizations/Layers/BikeParkings.ts index 2f032c2..205ca33 100644 --- a/Customizations/Layers/BikeParkings.ts +++ b/Customizations/Layers/BikeParkings.ts @@ -10,15 +10,8 @@ export class BikeParkings extends LayerDefinition { constructor() { super(); this.name = "bike_parking"; - this.icon = "./assets/bike_pump.svg"; - - this.overpassFilter = new Or([ - new And([ - new Tag("amenity", "bicycle_parking") - ]) - ]); - - + this.icon = "./assets/parking.svg"; + this.overpassFilter = new Tag("amenity", "bicycle_parking"); this.newElementTags = [ new Tag("amenity", "bicycle_parking"), ]; @@ -26,7 +19,7 @@ export class BikeParkings extends LayerDefinition { this.minzoom = 13; this.style = this.generateStyleFunction(); - this.title = new FixedName("fietsparking"); + this.title = new FixedName("Fietsparking"); this.elementsToShow = [ new OperatorTag(), new BikeParkingType() @@ -62,7 +55,7 @@ export class BikeParkings extends LayerDefinition { color: "#00bb00", icon: new L.icon({ iconUrl: self.icon, - iconSize: [40, 40] + iconSize: [30, 30] }) }; }; diff --git a/Customizations/Layers/BikePumps.ts b/Customizations/Layers/BikePumps.ts deleted file mode 100644 index 4da60d6..0000000 --- a/Customizations/Layers/BikePumps.ts +++ /dev/null @@ -1,77 +0,0 @@ -import {LayerDefinition} from "../LayerDefinition"; -import {And, Or, Tag} from "../../Logic/TagsFilter"; -import {OperatorTag} from "../Questions/OperatorTag"; -import * as L from "leaflet"; -import { PumpManual } from "../Questions/PumpManual"; -import FixedName from "../Questions/FixedName"; - -export class BikePumps extends LayerDefinition { - - constructor() { - super(); - this.name = "pomp"; - this.icon = "./assets/bike_pump.svg"; - - this.overpassFilter = new Or([ - new And([ - new Tag("amenity", "compressed_air"), - new Tag("bicycle", "yes"), - ]) - ] - ); - - - this.newElementTags = [ - new Tag("amenity", "compressed_air"), - new Tag("bicycle", "yes"), - // new Tag("fixme", "Toegevoegd met MapComplete, geometry nog uit te tekenen") - ]; - this.maxAllowedOverlapPercentage = 10; - - this.minzoom = 13; - this.style = this.generateStyleFunction(); - this.title = new FixedName("pomp"); - this.elementsToShow = [ - // new NameQuestion(), - // new AccessTag(), - new OperatorTag(), - new PumpManual() - ]; - - } - - - private generateStyleFunction() { - const self = this; - return function (properties: any) { - // let questionSeverity = 0; - // for (const qd of self.elementsToShow) { - // if (qd.IsQuestioning(properties)) { - // questionSeverity = Math.max(questionSeverity, qd.options.priority ?? 0); - // } - // } - - // let colormapping = { - // 0: "#00bb00", - // 1: "#00ff00", - // 10: "#dddd00", - // 20: "#ff0000" - // }; - - // let colour = colormapping[questionSeverity]; - // while (colour == undefined) { - // questionSeverity--; - // colour = colormapping[questionSeverity]; - // } - - return { - color: "#00bb00", - icon: new L.icon({ - iconUrl: self.icon, - iconSize: [40, 40] - }) - }; - }; - } - -} \ No newline at end of file diff --git a/Customizations/Layers/BikeServices.ts b/Customizations/Layers/BikeServices.ts new file mode 100644 index 0000000..8c14ea5 --- /dev/null +++ b/Customizations/Layers/BikeServices.ts @@ -0,0 +1,56 @@ +import {LayerDefinition} from "../LayerDefinition"; +import {And, Tag} from "../../Logic/TagsFilter"; +import * as L from "leaflet"; +import FixedName from "../Questions/FixedName"; +import BikeStationChain from "../Questions/BikeStationChain"; +import BikeStationPumpTools from "../Questions/BikeStationPumpTools"; +import BikeStationStand from "../Questions/BikeStationStand"; +import PumpManual from "../Questions/PumpManual"; +import BikeStationOperator from "../Questions/BikeStationOperator"; +import BikeStationBrand from "../Questions/BikeStationBrand"; + +export default class BikeServices extends LayerDefinition { + constructor() { + super(); + this.name = "bike station or pump"; + this.icon = "./assets/wrench.svg"; + + this.overpassFilter = new And([ + new Tag("amenity", "bicycle_repair_station") + ]); + + this.newElementTags = [ + new Tag("amenity", "bicycle_repair_station") + // new Tag("fixme", "Toegevoegd met MapComplete, geometry nog uit te tekenen") + ]; + this.maxAllowedOverlapPercentage = 10; + + this.minzoom = 13; + this.style = this.generateStyleFunction(); + this.title = new FixedName("Bike station"); + this.elementsToShow = [ + new BikeStationPumpTools(), + new BikeStationChain().OnlyShowIf(new Tag("service:bicycle:tools", "yes")), + new BikeStationStand().OnlyShowIf(new Tag("service:bicycle:tools", "yes")), + new PumpManual().OnlyShowIf(new Tag("service:bicycle:pump", "yes")), + new BikeStationOperator(), + new BikeStationBrand() + ]; + + } + + private generateStyleFunction() { + const self = this; + return function (properties: any) { + const onlyPump = properties["service:bicycle:tools"] == "no" && properties["service:bicycle:pump"] == "yes"; + const iconUrl = onlyPump ? "./assets/pump.svg" : "./assets/wrench.svg" + return { + color: "#00bb00", + icon: new L.icon({ + iconUrl: iconUrl, + iconSize: [40, 40] + }) + }; + }; + } +} \ No newline at end of file diff --git a/Customizations/Layouts/Cyclofix.ts b/Customizations/Layouts/Cyclofix.ts index 7ba29ad..a3b0a2d 100644 --- a/Customizations/Layouts/Cyclofix.ts +++ b/Customizations/Layouts/Cyclofix.ts @@ -1,17 +1,17 @@ import {Layout} from "../Layout"; import {GrbToFix} from "../Layers/GrbToFix"; -import { BikePumps } from "../Layers/BikePumps"; import { BikeParkings } from "../Layers/BikeParkings"; +import BikeServices from "../Layers/BikeServices"; export default class Cyclofix extends Layout { constructor() { super( "pomp", - "Grb import fix tool", - [new BikePumps(), new BikeParkings()], - 15, - 51.2083, - 3.2279, + "Cyclofix bicycle infrastructure", + [new BikeParkings(), new BikeServices()], + 16, + 50.8465573, + 4.3516970, "

Cyclofix bicycle infrastructure

\n" + diff --git a/Customizations/Questions/BikeParkingType.ts b/Customizations/Questions/BikeParkingType.ts index b9d0754..ebd7d57 100644 --- a/Customizations/Questions/BikeParkingType.ts +++ b/Customizations/Questions/BikeParkingType.ts @@ -3,8 +3,6 @@ import {Tag} from "../../Logic/TagsFilter"; export class BikeParkingType extends TagRenderingOptions { - - private static options = { priority: 5, question: "Van welk type is deze fietsenparking?", @@ -27,5 +25,4 @@ export class BikeParkingType extends TagRenderingOptions { constructor() { super(BikeParkingType.options); } - -} \ No newline at end of file +} diff --git a/Customizations/Questions/BikeStationBrand.ts b/Customizations/Questions/BikeStationBrand.ts new file mode 100644 index 0000000..ba3c4d2 --- /dev/null +++ b/Customizations/Questions/BikeStationBrand.ts @@ -0,0 +1,22 @@ +import {TagRenderingOptions} from "../TagRendering"; +import {Tag} from "../../Logic/TagsFilter"; + +export default class BikeStationBrand extends TagRenderingOptions { + private static options = { + priority: 15, + question: "What is the brand of this bike station (name of university, shop, city...)?", + freeform: { + key: "brand", + template: "The brand of this bike station is $$$", + renderTemplate: "The brand of this bike station is {operator}", + placeholder: "brand" + }, + mappings: [ + {k: new Tag("brand", "Velo Fix Station"), txt: "Velo Fix Station"} + ] + } + + constructor() { + super(BikeStationBrand.options); + } +} diff --git a/Customizations/Questions/BikeStationChain.ts b/Customizations/Questions/BikeStationChain.ts new file mode 100644 index 0000000..280c18b --- /dev/null +++ b/Customizations/Questions/BikeStationChain.ts @@ -0,0 +1,18 @@ +import {TagRenderingOptions} from "../TagRendering"; +import {Tag} from "../../Logic/TagsFilter"; + + +export default class BikeStationChain extends TagRenderingOptions { + private static options = { + priority: 5, + question: "Does this bike station have a special tool to repair your bike chain?", + mappings: [ + {k: new Tag("service:bicycle:chain_tool", "yes"), txt: "There is a chain tool."}, + {k: new Tag("service:bicycle:chain_tool", "no"), txt: "There is no chain tool."}, + ] + } + + constructor() { + super(BikeStationChain.options); + } +} diff --git a/Customizations/Questions/BikeStationOperator.ts b/Customizations/Questions/BikeStationOperator.ts new file mode 100644 index 0000000..a5731d6 --- /dev/null +++ b/Customizations/Questions/BikeStationOperator.ts @@ -0,0 +1,25 @@ +import {TagRenderingOptions} from "../TagRendering"; +import {Tag} from "../../Logic/TagsFilter"; + +export default class BikeStationOperator extends TagRenderingOptions { + private static options = { + priority: 15, + question: "Who operates this bike station (name of university, shop, city...)?", + freeform: { + key: "operator", + template: "This bike station is operated by $$$", + renderTemplate: "This bike station is operated by {operator}", + placeholder: "organisatie" + }, + mappings: [ + {k: new Tag("operator", "KU Leuven"), txt: "KU Leuven"}, + {k: new Tag("operator", "Stad Halle"), txt: "Stad Halle"}, + {k: new Tag("operator", "Saint Gilles - Sint Gillis"), txt: "Saint Gilles - Sint Gillis"}, + {k: new Tag("operator", "private"), txt: "Beheer door een privépersoon"} + ] + } + + constructor() { + super(BikeStationOperator.options); + } +} diff --git a/Customizations/Questions/BikeStationPumpTools.ts b/Customizations/Questions/BikeStationPumpTools.ts new file mode 100644 index 0000000..b0a40cb --- /dev/null +++ b/Customizations/Questions/BikeStationPumpTools.ts @@ -0,0 +1,19 @@ +import {TagRenderingOptions} from "../TagRendering"; +import {Tag, And} from "../../Logic/TagsFilter"; + + +export default class BikeStationPumpTools extends TagRenderingOptions { + private static options = { + priority: 15, + question: "Which services are available at this bike station?", + mappings: [ + {k: new And([new Tag("service:bicycle:tools", "no"), new Tag("service:bicycle:pump", "yes")]), txt: "There is only a pump available."}, + {k: new And([new Tag("service:bicycle:tools", "yes"), new Tag("service:bicycle:pump", "no")]), txt: "There are only tools (screwdrivers, pliers...) available."}, + {k: new And([new Tag("service:bicycle:tools", "yes"), new Tag("service:bicycle:pump", "yes")]), txt: "There are both tools and a pump available."} + ] + } + + constructor() { + super(BikeStationPumpTools.options); + } +} diff --git a/Customizations/Questions/BikeStationStand.ts b/Customizations/Questions/BikeStationStand.ts new file mode 100644 index 0000000..5a6ef35 --- /dev/null +++ b/Customizations/Questions/BikeStationStand.ts @@ -0,0 +1,18 @@ +import {TagRenderingOptions} from "../TagRendering"; +import {Tag} from "../../Logic/TagsFilter"; + + +export default class BikeStationStand extends TagRenderingOptions { + private static options = { + priority: 10, + question: "Does this bike station have a hook to suspend your bike with or a stand to elevate it?", + mappings: [ + {k: new Tag("service:bicycle:stand", "yes"), txt: "There is a hook or stand."}, + {k: new Tag("service:bicycle:stand", "no"), txt: "There is no hook or stand"}, + ] + } + + constructor() { + super(BikeStationStand.options); + } +} diff --git a/Customizations/Questions/PumpManual.ts b/Customizations/Questions/PumpManual.ts index cfb8356..26bd36e 100644 --- a/Customizations/Questions/PumpManual.ts +++ b/Customizations/Questions/PumpManual.ts @@ -1,23 +1,18 @@ import {TagRenderingOptions} from "../TagRendering"; -import {UIEventSource} from "../../UI/UIEventSource"; -import {Changes} from "../../Logic/Changes"; import {Tag} from "../../Logic/TagsFilter"; -export class PumpManual extends TagRenderingOptions { - - +export default class PumpManual extends TagRenderingOptions { private static options = { priority: 5, - question: "Is dit een manuele pomp?", + question: "Is the pump at this bike station manual or automatic (compressed air)?", mappings: [ - {k: new Tag("manual", "yes"), txt: "Manuele pomp"}, - {k: new Tag("manual", "no"), txt: "Automatische pomp"} + {k: new Tag("manual", "yes"), txt: "Manual"}, + {k: new Tag("manual", "no"), txt: "Automatic (with compressed air)"} ] } constructor() { super(PumpManual.options); } - -} \ No newline at end of file +} diff --git a/assets/parking.svg b/assets/parking.svg new file mode 100644 index 0000000..07cb1be --- /dev/null +++ b/assets/parking.svg @@ -0,0 +1,7 @@ + + + + + Svg Vector Icons : http://www.onlinewebfonts.com/icon + + \ No newline at end of file diff --git a/assets/wrench.svg b/assets/wrench.svg new file mode 100644 index 0000000..dd729c2 --- /dev/null +++ b/assets/wrench.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file