From 74185b852a3e2bd2df1e3a992a14f09aa520206f Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Tue, 17 Jan 2023 18:23:08 +0100 Subject: [PATCH] Add _referencing_way property for @thibaultmol --- Logic/SimpleMetaTagger.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Logic/SimpleMetaTagger.ts b/Logic/SimpleMetaTagger.ts index 8e20b784c5..5a978f7bd6 100644 --- a/Logic/SimpleMetaTagger.ts +++ b/Logic/SimpleMetaTagger.ts @@ -10,6 +10,7 @@ import { CountryCoder } from "latlon2country" import Constants from "../Models/Constants" import { TagUtils } from "./Tags/TagUtils" import { Feature, LineString } from "geojson" +import { OsmObject } from "./Osm/OsmObject" export class SimpleMetaTagger { public readonly keys: string[] @@ -484,6 +485,33 @@ export default class SimpleMetaTaggers { return true } ) + + public static referencingWays = new SimpleMetaTagger( + { + keys: ["_referencing_ways"], + isLazy: true, + doc: "_referencing_ways contains - for a node - which ways use this this node as point in their geometry.", + }, + (feature, _, __, state) => { + const id = feature.properties.id + if (!id.startsWith("node/")) { + return false + } + OsmObject.DownloadReferencingWays(id).then((referencingWays) => { + const currentTagsSource = state.allElements.getEventSourceById(id) + const wayIds = referencingWays.map((w) => "way/" + w.id) + wayIds.sort() + const wayIdsStr = wayIds.join(";") + if (wayIdsStr !== "" && currentTagsSource.data["_referencing_ways"] !== wayIdsStr) { + currentTagsSource.data["_referencing_ways"] = wayIdsStr + currentTagsSource.ping() + } + }) + + return true + } + ) + public static metatags: SimpleMetaTagger[] = [ SimpleMetaTaggers.latlon, SimpleMetaTaggers.layerInfo, @@ -499,6 +527,7 @@ export default class SimpleMetaTaggers { SimpleMetaTaggers.noBothButLeftRight, SimpleMetaTaggers.geometryType, SimpleMetaTaggers.levels, + SimpleMetaTaggers.referencingWays, ] public static readonly lazyTags: string[] = [].concat( ...SimpleMetaTaggers.metatags.filter((tagger) => tagger.isLazy).map((tagger) => tagger.keys)