From 96c819ea40343f9699cf53218ebd5e40c27ce385 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Wed, 15 Mar 2023 15:21:09 +0100 Subject: [PATCH] Fix bug in presets which generated incorrect 'referencingWays' --- Logic/SimpleMetaTagger.ts | 2 +- Logic/Tags/RegexTag.ts | 4 ++++ UI/BigComponents/SimpleAddUI.ts | 6 +++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Logic/SimpleMetaTagger.ts b/Logic/SimpleMetaTagger.ts index fba7308e9..7b38d85bc 100644 --- a/Logic/SimpleMetaTagger.ts +++ b/Logic/SimpleMetaTagger.ts @@ -69,7 +69,7 @@ export class ReferencingWaysMetaTagger extends SimpleMetaTagger { { keys: ["_referencing_ways"], isLazy: true, - doc: "_referencing_ways contains - for a node - which ways use this this node as point in their geometry. If the preset has 'snapToLayer' defined, the icon will be calculated based on the preset tags with `_referencing_ways=[way/-1]` added.", + doc: "_referencing_ways contains - for a node - which ways use this this node as point in their geometry. If the preset has 'snapToLayer' defined, the icon will be calculated based on the preset tags with `_referencing_ways=[\"way/-1\"]` added.", }, (feature, _, __, state) => { if (!ReferencingWaysMetaTagger.enabled) { diff --git a/Logic/Tags/RegexTag.ts b/Logic/Tags/RegexTag.ts index 988f9987c..c6f448fcb 100644 --- a/Logic/Tags/RegexTag.ts +++ b/Logic/Tags/RegexTag.ts @@ -25,6 +25,10 @@ export class RegexTag extends TagsFilter { if (typeof possibleRegex === "string") { return fromTag === possibleRegex } + if (typeof fromTag.match !== "function") { + console.error("Error: fromTag is not a regex: ", fromTag, possibleRegex) + throw "Error: fromTag is not a regex: " + fromTag + possibleRegex + } return fromTag.match(possibleRegex) !== null } diff --git a/UI/BigComponents/SimpleAddUI.ts b/UI/BigComponents/SimpleAddUI.ts index adba53cba..cc2d72e6c 100644 --- a/UI/BigComponents/SimpleAddUI.ts +++ b/UI/BigComponents/SimpleAddUI.ts @@ -26,7 +26,7 @@ import BaseLayer from "../../Models/BaseLayer" import Loading from "../Base/Loading" import Hash from "../../Logic/Web/Hash" import { GlobalFilter } from "../../Logic/State/MapState" -import { WayId } from "../../Models/OsmFeature" +import { OsmTags, WayId } from "../../Models/OsmFeature" import { Tag } from "../../Logic/Tags/Tag" import { LoginToggle } from "../Popup/LoginButton" @@ -290,8 +290,8 @@ export default class SimpleAddUI extends LoginToggle { let icon: () => BaseUIElement = () => layer.layerDef.mapRendering[0] .GenerateLeafletStyle( - new ImmutableStore( - isSnapping ? tags : { _referencing_ways: ["way/-1"], ...tags } + new ImmutableStore( + isSnapping ? tags : { _referencing_ways: '["way/-1"]', ...tags } ), false, { noSize: true }