From ca15688a391aa050e7f74f2eca52587768bd862a Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Mon, 4 Jan 2021 15:21:43 +0100 Subject: [PATCH 1/3] Add bicycle associations to cycling themed layer --- State.ts | 2 +- .../cycling_themed_objects.json | 44 +++++++------------ 2 files changed, 17 insertions(+), 29 deletions(-) diff --git a/State.ts b/State.ts index 934b7e3b1..3970bfbdb 100644 --- a/State.ts +++ b/State.ts @@ -25,7 +25,7 @@ export default class State { // The singleton of the global state public static state: State; - public static vNumber = "0.2.6a"; + public static vNumber = "0.2.6b"; // The user journey states thresholds when a new feature gets unlocked public static userJourney = { diff --git a/assets/layers/cycling_themed_object/cycling_themed_objects.json b/assets/layers/cycling_themed_object/cycling_themed_objects.json index 7e57106d7..14dfcb4c1 100644 --- a/assets/layers/cycling_themed_object/cycling_themed_objects.json +++ b/assets/layers/cycling_themed_object/cycling_themed_objects.json @@ -7,7 +7,14 @@ "de": "Mit Fahrrad zusammenhängendes Objekt" }, "minzoom": 13, - "overpassTags": {"or": ["theme~cycling|bicycle", "sport=cycling"]}, + "overpassTags": { + "or": [ + "theme~cycling|bicycle", + "sport=cycling", + "association=cycling|bicycle", + "ngo=cycling|bicycle" + ] + }, "title": { "render": { "en": "Bike related object", @@ -18,7 +25,7 @@ "mappings": [ { "if": "name~*", - "then":"{name}" + "then": "{name}" }, { "if": "leisure=track", @@ -30,32 +37,13 @@ ] }, "description": {}, - "tagRenderings": [ "images", - - { - "render": "{website}", - "freeform": { - "key": "website" - } - }, - { - "render": "{phone}", - "freeform": { - "key": "phone" - } - }, - { - "render": "{email}", - "freeform": { - "key": "email" - } - }, - { - "render": "{opening_hours_table(opening_hours)}", - "freeform": { - "key": "opening_hours" - } - } + "tagRenderings": [ + "images", + "description", + "website", + "email", + "phone", + "opening_hours" ], "hideUnderlayingFeaturesMinPercentage": 0, "icon": { From c2a2306d1837ad0d42fc7a90357c3b959a82033a Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Mon, 4 Jan 2021 15:30:02 +0100 Subject: [PATCH 2/3] Add club=cycling to cyclofix --- .../layers/cycling_themed_object/cycling_themed_objects.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/assets/layers/cycling_themed_object/cycling_themed_objects.json b/assets/layers/cycling_themed_object/cycling_themed_objects.json index 14dfcb4c1..845dca767 100644 --- a/assets/layers/cycling_themed_object/cycling_themed_objects.json +++ b/assets/layers/cycling_themed_object/cycling_themed_objects.json @@ -12,7 +12,8 @@ "theme~cycling|bicycle", "sport=cycling", "association=cycling|bicycle", - "ngo=cycling|bicycle" + "ngo=cycling|bicycle", + "club=bicycle|cycling" ] }, "title": { From cc48d34804c6f9769310eb39392786ef2ef4d926 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Mon, 4 Jan 2021 16:02:54 +0100 Subject: [PATCH 3/3] Fix associations --- Logic/MetaTagging.ts | 73 +++++++++---------- State.ts | 2 +- .../cycling_themed_objects.json | 6 +- 3 files changed, 40 insertions(+), 41 deletions(-) diff --git a/Logic/MetaTagging.ts b/Logic/MetaTagging.ts index f7377098f..958bac653 100644 --- a/Logic/MetaTagging.ts +++ b/Logic/MetaTagging.ts @@ -6,10 +6,9 @@ import {Utils} from "../Utils"; import CountryCoder from "latlon2country" class SimpleMetaTagger { - private _f: (feature: any, index: number) => void; public readonly keys: string[]; public readonly doc: string; - + private _f: (feature: any, index: number) => void; constructor(keys: string[], doc: string, f: ((feature: any, index: number) => void)) { this.keys = keys; @@ -89,39 +88,39 @@ export default class MetaTagging { if (tags.opening_hours === undefined || tags._country === undefined) { return; } - try{ - - const oh = new opening_hours(tags["opening_hours"], { - lat: tags._lat, - lon: tags._lon, - address: { - country_code: tags._country.toLowerCase() - } - }, {tag_key: "opening_hours"}); - // AUtomatically triggered on the next change + try { + + const oh = new opening_hours(tags["opening_hours"], { + lat: tags._lat, + lon: tags._lon, + address: { + country_code: tags._country.toLowerCase() + } + }, {tag_key: "opening_hours"}); + // AUtomatically triggered on the next change const updateTags = () => { - const oldValueIsOpen = tags["_isOpen"]; - tags["_isOpen"] = oh.getState() ? "yes" : "no"; - const comment = oh.getComment(); - if (comment) { - tags["_isOpen:description"] = comment; - } + const oldValueIsOpen = tags["_isOpen"]; + tags["_isOpen"] = oh.getState() ? "yes" : "no"; + const comment = oh.getComment(); + if (comment) { + tags["_isOpen:description"] = comment; + } - if (oldValueIsOpen !== tags._isOpen) { - tagsSource.ping(); - } + if (oldValueIsOpen !== tags._isOpen) { + tagsSource.ping(); + } - const nextChange = oh.getNextChange(); + const nextChange = oh.getNextChange(); if (nextChange !== undefined) { - window.setTimeout( - updateTags, - (nextChange.getTime() - (new Date()).getTime()) - ) + window.setTimeout( + updateTags, + (nextChange.getTime() - (new Date()).getTime()) + ) + } } - } - updateTags(); - }catch(e){ - console.error(e); + updateTags(); + } catch (e) { + console.error("Error while parsing opening hours of ", tags.id, e); tags["_isOpen"] = "parse_error"; } @@ -234,8 +233,8 @@ export default class MetaTagging { let carWidthUsed = (onewayCar ? 1 : 2) * carWidth; properties["_width:needed:cars"] = Utils.Round(carWidthUsed); properties["_width:needed:parking"] = Utils.Round(parallelParkingCount * carWidth) - - + + let cyclistWidthUsed = 0; if (cyclingAllowed) { cyclistWidthUsed = (onewayBike ? 1 : 2) * cyclistWidth; @@ -250,16 +249,16 @@ export default class MetaTagging { carWidthUsed + cyclistWidthUsed + parallelParkingCount * carWidthUsed; - properties["_width:needed:no_pedestrians"] =Utils.Round(targetWidthIgnoringPedestrians); - + properties["_width:needed:no_pedestrians"] = Utils.Round(targetWidthIgnoringPedestrians); + const pedestriansNeed = Math.max(0, pedestrianFlowNeeded) * pedestrianWidth; - const targetWidth = targetWidthIgnoringPedestrians + pedestriansNeed ; + const targetWidth = targetWidthIgnoringPedestrians + pedestriansNeed; properties["_width:needed"] = Utils.Round(targetWidth); properties["_width:needed:pedestrians"] = Utils.Round(pedestriansNeed) - properties["_width:difference"] = Utils.Round(targetWidth - width ); - properties["_width:difference:no_pedestrians"] = Utils.Round(targetWidthIgnoringPedestrians - width) ; + properties["_width:difference"] = Utils.Round(targetWidth - width); + properties["_width:difference:no_pedestrians"] = Utils.Round(targetWidthIgnoringPedestrians - width); } ); diff --git a/State.ts b/State.ts index 3970bfbdb..dc1edd238 100644 --- a/State.ts +++ b/State.ts @@ -25,7 +25,7 @@ export default class State { // The singleton of the global state public static state: State; - public static vNumber = "0.2.6b"; + public static vNumber = "0.2.6c"; // The user journey states thresholds when a new feature gets unlocked public static userJourney = { diff --git a/assets/layers/cycling_themed_object/cycling_themed_objects.json b/assets/layers/cycling_themed_object/cycling_themed_objects.json index 845dca767..8396ea555 100644 --- a/assets/layers/cycling_themed_object/cycling_themed_objects.json +++ b/assets/layers/cycling_themed_object/cycling_themed_objects.json @@ -11,9 +11,9 @@ "or": [ "theme~cycling|bicycle", "sport=cycling", - "association=cycling|bicycle", - "ngo=cycling|bicycle", - "club=bicycle|cycling" + "association~cycling|bicycle", + "ngo~cycling|bicycle", + "club~bicycle|cycling" ] }, "title": {