From a55767c1e9c34749d8b75a4f8735315366f3d0ab Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Sat, 22 Aug 2020 16:00:33 +0200 Subject: [PATCH] Add Open Toilet Map, fix #34 --- Customizations/AllKnownLayouts.ts | 2 + Customizations/Layers/Toilets.ts | 84 ---------- Customizations/Layouts/Toilets.ts | 25 --- State.ts | 4 +- UI/MoreScreen.ts | 7 +- assets/bookcase.svg | 73 --------- assets/themes/toilets/toilets.json | 169 +++++++++++++++++++++ assets/{ => themes/toilets}/toilets.svg | 0 assets/{ => themes/toilets}/wheelchair.svg | 0 customGenerator.ts | 11 +- index.css | 1 + 11 files changed, 188 insertions(+), 188 deletions(-) delete mode 100644 Customizations/Layers/Toilets.ts delete mode 100644 Customizations/Layouts/Toilets.ts delete mode 100644 assets/bookcase.svg create mode 100644 assets/themes/toilets/toilets.json rename assets/{ => themes/toilets}/toilets.svg (100%) rename assets/{ => themes/toilets}/wheelchair.svg (100%) diff --git a/Customizations/AllKnownLayouts.ts b/Customizations/AllKnownLayouts.ts index 6a08c9336..8d04ef78a 100644 --- a/Customizations/AllKnownLayouts.ts +++ b/Customizations/AllKnownLayouts.ts @@ -15,6 +15,7 @@ import {GhostBikes} from "./Layouts/GhostBikes"; import {CustomLayoutFromJSON} from "./JSON/CustomLayoutFromJSON"; import * as bookcases from "../assets/themes/bookcases/Bookcases.json"; import * as aed from "../assets/themes/aed/aed.json"; +import * as toilets from "../assets/themes/toilets/toilets.json"; export class AllKnownLayouts { @@ -28,6 +29,7 @@ export class AllKnownLayouts { new GhostBikes(), CustomLayoutFromJSON.LayoutFromJSON(bookcases), CustomLayoutFromJSON.LayoutFromJSON(aed), + CustomLayoutFromJSON.LayoutFromJSON(toilets), new MetaMap(), new StreetWidth(), diff --git a/Customizations/Layers/Toilets.ts b/Customizations/Layers/Toilets.ts deleted file mode 100644 index af41d6cfd..000000000 --- a/Customizations/Layers/Toilets.ts +++ /dev/null @@ -1,84 +0,0 @@ -import {LayerDefinition} from "../LayerDefinition"; -import {FixedUiElement} from "../../UI/Base/FixedUiElement"; -import L from "leaflet"; -import {Tag} from "../../Logic/TagsFilter"; - -export class Toilets extends LayerDefinition{ - - constructor() { - super("toilets"); - - this.name="toilet"; - this.newElementTags = [new Tag( "amenity", "toilets")]; - this.icon = "./assets/toilets.svg"; - this.overpassFilter = new Tag("amenity","toilets"); - this.minzoom = 13; - this.questions = [Quests.hasFee, - Quests.toiletsWheelChairs, - Quests.toiletsChangingTable, - Quests.toiletsChangingTableLocation, - Quests.toiletsPosition]; - - this.style = function(tags){ - if(tags.wheelchair == "yes"){ - - return {icon : new L.icon({ - iconUrl: "assets/wheelchair.svg", - iconSize: [40, 40] - })}; - } - return {icon : new L.icon({ - iconUrl: "assets/toilets.svg", - iconSize: [40, 40] - })}; - } - - this.elementsToShow = [ - new FixedUiElement("Toiletten"), - - new TagMappingOptions({ - key: "access", - mapping: { - yes: "Toegankelijk", - no: "Niet toegankelijk", - private: "Niet toegankelijk", - customers: "Enkel voor klanten", - } - }), - - new TagMappingOptions({ - key: "fee", - mapping: { - yes: "Betalend", - no: "Gratis", - ["0"]: "Gratis" - }, - template: "Betalend, men vraagt {fee}" - }), - - new TagMappingOptions({ - key: "toilets:position", - mapping: { - seated: 'Gewone zittoiletten', - urinal: 'Een enkele urinoir', - urinals: 'Urinoirs', - ['urinals;seated']: "Urinoirs en gewone toiletten", - ['seated;urinals']: "Urinoirs en gewone toiletten", - - } - }), - - new TagMappingOptions({ - key: "wheelchair", - mapping: { - yes: "Rolstoeltoegankelijk", - no: "Niet Rolstoeltoegankelijk", - limited: "Beperkt rolstoeltoegankelijk", - - } - }), - ]; - } - - -} \ No newline at end of file diff --git a/Customizations/Layouts/Toilets.ts b/Customizations/Layouts/Toilets.ts deleted file mode 100644 index 1598c0f5a..000000000 --- a/Customizations/Layouts/Toilets.ts +++ /dev/null @@ -1,25 +0,0 @@ -import {Layout} from "../Layout"; -import * as Layer from "../Layers/Toilets"; - -export class Toilets extends Layout{ - constructor() { - super( "toilets", - ["en"], - "Open Toilet Map", - [new Layer.Toilets()], - 12, - 51.2, - 3.2, - - - "

Open Toilet Map

\n" + - "\n" + - "

Help us to create the most complete map about all the toilets in the world, based on openStreetMap." + - "One can answer questions here, which help users all over the world to find an accessible toilet, close to them.

" - , - "

Start by creating an account\n" + - " or by " + - " logging in.

", - "Start by clicking a pin and answering the questions"); - } -} \ No newline at end of file diff --git a/State.ts b/State.ts index 137603c4f..6a6f565a5 100644 --- a/State.ts +++ b/State.ts @@ -24,7 +24,7 @@ export class State { // The singleton of the global state public static state: State; - public static vNumber = "0.0.5b"; + public static vNumber = "0.0.5c"; public static runningFromConsole: boolean = false; @@ -47,7 +47,7 @@ export class State { */ public bm; /** - The user crednetials + The user credentials */ public osmConnection: OsmConnection; diff --git a/UI/MoreScreen.ts b/UI/MoreScreen.ts index 66d071d2c..e1dc2c947 100644 --- a/UI/MoreScreen.ts +++ b/UI/MoreScreen.ts @@ -44,14 +44,17 @@ export class MoreScreen extends UIElement { const currentLocation = State.state.locationControl.data; const linkText = `https://pietervdvn.github.io/MapComplete/${layout.name}.html?z=${currentLocation.zoom}&lat=${currentLocation.lat}&lon=${currentLocation.lon}` + let description = Translations.W(layout.description); + if(description !== undefined){ + description = new Combine(["
", description]); + } const link = new SubtleButton(layout.icon, new Combine([ "", Translations.W(layout.title), "", - "
", - Translations.W(layout.description), + description ?? "", ]), {url: linkText, newTab: false}); els.push(link) diff --git a/assets/bookcase.svg b/assets/bookcase.svg deleted file mode 100644 index d6feeeb74..000000000 --- a/assets/bookcase.svg +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - image/svg+xml - - - - - - - - - - - - - diff --git a/assets/themes/toilets/toilets.json b/assets/themes/toilets/toilets.json new file mode 100644 index 000000000..b8d522055 --- /dev/null +++ b/assets/themes/toilets/toilets.json @@ -0,0 +1,169 @@ +{ + "layers": [ + { + "id": "Toilet", + "title": { + "key": "*", + "render": "Toilet" + }, + "icon": { + "key": "*", + "render": "./assets/themes/toilets/toilets.svg", + "mappings": [ + { + "then": "./assets/themes/toilets/wheelchair.svg", + "if": "wheelchair=yes" + } + ] + }, + "color": { + "key": "*", + "render": "#0000ff" + }, + "description": "A toilet", + "minzoom": "14", + "wayHandling": 2, + "presets": [ + { + "title": "Toilet", + "tags": "amenity=toilets", + "description": "Only add public toilets" + } + ], + "tagRenderings": [ + { + "key": "access", + "mappings": [ + { + "then": "Public access", + "if": "access=yes" + }, + { + "then": "Only access to customers", + "if": "access=customers" + }, + { + "if": "access=no", + "then": "Not accessible" + }, + { + "then": "Accessible, but one has to ask a key to enter", + "if": "access=key" + } + ], + "question": "Are these toilets publicly accessible?", + "type": "text", + "addExtraTags": "fixme=the tag access was filled out by the user and might need refinement", + "render": "Access is {access}" + }, + { + "mappings": [ + { + "then": "These are paid toilets", + "if": "fee=yes" + }, + { + "if": "fee=no", + "then": "Free to use" + } + ], + "type": "text", + "question": "Are these toilets free to use?" + }, + { + "key": "charge", + "mappings": [], + "question": "How much does one have to pay for these toilets?", + "type": "string", + "render": "The fee is {charge}", + "condition": "fee=yes" + }, + { + "mappings": [ + { + "then": "There is a dedicated toilet for wheelchair users", + "if": "wheelchair=yes" + }, + { + "if": "wheelchair=no", + "then": "No wheelchair access" + } + ], + "type": "text", + "question": "Is there a dedicated toilet for wheelchair users" + }, + { + "mappings": [ + { + "if": "toilets:position=seated", + "then": "There are only seated toilets" + }, + { + "if": "toilets:position=urinals", + "then": "There are only urinals here" + }, + { + "if": "toilets:position=squat", + "then": "There are only squat toilets here" + }, + { + "if": "toilets:position=seated;urinals", + "then": "Both seated toilets and urinals are available here" + } + ], + "question": "Which kind of toilets are this?", + "type": "text" + }, + { + "mappings": [ + { + "then": "A changing table is available", + "if": "changing_table=yes" + }, + { + "if": "changing_table=no", + "then": "No changing table is available" + } + ], + "question": "Is a changing table (to change diapers) available?", + "type": "text" + }, + { + "key": "changing_table:location", + "mappings": [ + { + "then": "The changing table is in the toilet for women. ", + "if": "changing_table:location=female_toilet" + }, + { + "then": "The changing table is in the toilet for men. ", + "if": "changing_table:location=male_toilet" + }, + { + "if": "changing_table:location=wheelchair_toilet", + "then": "The changing table is in the toilet for wheelchair users. " + }, + { + "if": "changing_table:location=dedicated_room", + "then": "The changing table is in a dedicated room. " + } + ], + "type": "text", + "question": "Where is the changing table located?", + "condition": "changing_table=yes", + "render": "The changing table is located at {changing_table:location}" + } + ], + "overpassTags": "amenity=toilets" + } + ], + "startLat": "51.2095", + "startZoom": "12", + "maintainer": "Pieter Vander Vennet", + "title": "Open Toilet Map", + "startLon": "3.2222", + "icon": "./assets/themes/toilets/toilets.svg", + "description": "A map of public toilets", + "language": "en", + "name": "toilets" +} \ No newline at end of file diff --git a/assets/toilets.svg b/assets/themes/toilets/toilets.svg similarity index 100% rename from assets/toilets.svg rename to assets/themes/toilets/toilets.svg diff --git a/assets/wheelchair.svg b/assets/themes/toilets/wheelchair.svg similarity index 100% rename from assets/wheelchair.svg rename to assets/themes/toilets/wheelchair.svg diff --git a/customGenerator.ts b/customGenerator.ts index d4caf42d7..cdb6102ed 100644 --- a/customGenerator.ts +++ b/customGenerator.ts @@ -7,6 +7,8 @@ import {LocalStorageSource} from "./Logic/Web/LocalStorageSource"; import {createHash} from "crypto"; import Combine from "./UI/Base/Combine"; import {Button} from "./UI/Base/Button"; +import {FixedUiElement} from "./UI/Base/FixedUiElement"; +import {State} from "./State"; const connection = new OsmConnection(true, new UIEventSource(undefined), false); connection.AttemptLogin(); @@ -16,7 +18,7 @@ const localStorage = LocalStorageSource.Get("last-custom-save"); console.log("hash", hash) console.log("Saved: ", localStorage.data) -if (hash === undefined || hash === "") { +if (hash === undefined || hash === "" && localStorage.data !== undefined) { const previous = localStorage.data.split("#"); hash = previous[1]; console.log("Using previously saved data ", hash) @@ -41,4 +43,9 @@ new Combine([ themeGenerator.themeObject.data.maintainer = connection.userDetails.data.name; themeGenerator.themeObject.data.layers = []; themeGenerator.themeObject.ping(); - })]).AttachTo("preview"); + }), + "
", + "Version: ", + State.vNumber + +]).AttachTo("preview"); diff --git a/index.css b/index.css index 80d05f706..670d4eb76 100644 --- a/index.css +++ b/index.css @@ -1193,6 +1193,7 @@ form { border-right:1px solid gray; border-top: 1px solid gray; border-bottom: 1px solid lightgray; + min-width: 4em; }