{#if renderingExternal}
diff --git a/src/UI/Comparison/ComparisonState.ts b/src/UI/Comparison/ComparisonState.ts
new file mode 100644
index 000000000..dd0743374
--- /dev/null
+++ b/src/UI/Comparison/ComparisonState.ts
@@ -0,0 +1,80 @@
+import { Store, UIEventSource } from "../../Logic/UIEventSource"
+import { OsmTags } from "../../Models/OsmFeature"
+import { SpecialVisualizationState } from "../SpecialVisualization"
+
+export class ComparisonState {
+ public readonly hasDifferencesAtStart: boolean
+ public readonly different: Store
+ public readonly missing: Store
+ public readonly unknownImages: Store
+ public readonly propertyKeysExternal: string[]
+ public readonly knownImages: Store>
+
+ constructor(tags: UIEventSource, externalProperties: Record) {
+
+ externalProperties = { ...externalProperties }
+ delete externalProperties["@context"]
+
+ let externalKeys: string[] = Object.keys(externalProperties).sort()
+
+ const imageKeyRegex = /image|image:[0-9]+/
+
+ this.knownImages = tags.map(
+ (osmProperties) =>
+ new Set(
+ Object.keys(osmProperties)
+ .filter((k) => k.match(imageKeyRegex))
+ .map((k) => osmProperties[k])
+ )
+ )
+
+ this.unknownImages = this.knownImages.map((images) =>
+ externalKeys
+ .filter((k) => k.match(imageKeyRegex))
+ .map((k) => externalProperties[k])
+ .filter((i) => !images.has(i))
+ )
+
+ this.propertyKeysExternal = externalKeys.filter((k) => k.match(imageKeyRegex) === null)
+ let propertyKeysExternal = this.propertyKeysExternal
+ this.missing = tags.map((osmProperties) =>
+ propertyKeysExternal.filter((k) => {
+ if (k.startsWith("_")) {
+ return false
+ }
+ return osmProperties[k] === undefined && typeof externalProperties[k] === "string"
+ })
+ )
+ // let same = propertyKeysExternal.filter((key) => osmProperties[key] === externalProperties[key])
+ this.different = tags.map((osmProperties) =>
+ propertyKeysExternal.filter((key) => {
+ if (key.startsWith("_")) {
+ return false
+ }
+ if (osmProperties[key] === undefined) {
+ return false
+ }
+ if (typeof externalProperties[key] !== "string") {
+ return false
+ }
+ if (osmProperties[key] === externalProperties[key]) {
+ return false
+ }
+
+ if (key === "website") {
+ const osmCanon = new URL(osmProperties[key]).toString()
+ const externalCanon = new URL(externalProperties[key]).toString()
+ if (osmCanon === externalCanon) {
+ return false
+ }
+ }
+
+ return true
+ })
+ )
+
+ this.hasDifferencesAtStart =
+ this. different.data.length + this.missing.data.length + this.unknownImages.data.length > 0
+
+ }
+}
diff --git a/src/UI/Comparison/ComparisonTable.svelte b/src/UI/Comparison/ComparisonTable.svelte
index f742db602..1aa70517b 100644
--- a/src/UI/Comparison/ComparisonTable.svelte
+++ b/src/UI/Comparison/ComparisonTable.svelte
@@ -1,6 +1,6 @@
-{#if propertyKeysExternal.length === 0 && $knownImages.size + $unknownImages.length === 0}
-
-{:else if !hasDifferencesAtStart}
-
-
-
-{:else if $unknownImages.length === 0 && $missing.length === 0 && $different.length === 0}
+
+{#if $unknownImages.length === 0 && $missing.length === 0 && $different.length === 0}
{:else}
-
{#if !readonly}
{/if}
@@ -218,9 +160,8 @@
{/if}
{/if}
{#if externalProperties["_last_edit_timestamp"] !== undefined}
-
- External data has been last modified on {externalProperties["_last_edit_timestamp"]}
+
+
{/if}
-
{/if}
diff --git a/src/UI/Comparison/ComparisonTool.svelte b/src/UI/Comparison/ComparisonTool.svelte
index d083b98e1..f72a295ca 100644
--- a/src/UI/Comparison/ComparisonTool.svelte
+++ b/src/UI/Comparison/ComparisonTool.svelte
@@ -14,6 +14,7 @@
import Tr from "../Base/Tr.svelte"
import AccordionSingle from "../Flowbite/AccordionSingle.svelte"
import GlobeAlt from "@babeard/svelte-heroicons/mini/GlobeAlt"
+ import { ComparisonState } from "./ComparisonState"
export let externalData: Store<
| { success: { content: Record } }
@@ -28,7 +29,20 @@
export let readonly = false
export let sourceUrl: Store
- export let collapsed : boolean
+ export let collapsed: boolean
+ const t = Translations.t.external
+
+ let comparisonState: Store = externalData.mapD(external => {
+ if (external["success"]) {
+ return new ComparisonState(tags, external["success"])
+ }
+ return undefined
+ })
+ let unknownImages = comparisonState.bindD(ct => ct.unknownImages)
+ let knownImages = comparisonState.bindD(ct => ct.knownImages)
+ let propertyKeysExternal = comparisonState.mapD(ct => ct.propertyKeysExternal)
+ let hasDifferencesAtStart = comparisonState.mapD(ct => ct.hasDifferencesAtStart)
+
{#if !$sourceUrl}
@@ -39,20 +53,27 @@
-{:else if $externalData["success"] !== undefined}
-
+{:else if $propertyKeysExternal.length === 0 && $knownImages.size + $unknownImages.length === 0}
+
+{:else if !$hasDifferencesAtStart}
+
+
+
+{:else if $comparisonState !== undefined}
+
-
-
+
+
-
+
{/if}
diff --git a/src/UI/Map/RasterLayerHandler.ts b/src/UI/Map/RasterLayerHandler.ts
index a1cffc7b7..933a130cd 100644
--- a/src/UI/Map/RasterLayerHandler.ts
+++ b/src/UI/Map/RasterLayerHandler.ts
@@ -97,6 +97,15 @@ class SingleBackgroundHandler {
}
}
+ private tryEnableSafe(): boolean{
+ try {
+ return this.tryEnable()
+ }catch (e) {
+ console.log("Error: could not enable due to error", e)
+ return false
+ }
+ }
+
/**
* Returns 'false' if should be attempted again
* @private
diff --git a/src/UI/Popup/MoveWizardState.ts b/src/UI/Popup/MoveWizardState.ts
index cdb9255e8..d3e0a669a 100644
--- a/src/UI/Popup/MoveWizardState.ts
+++ b/src/UI/Popup/MoveWizardState.ts
@@ -134,11 +134,16 @@ export class MoveWizardState {
// This is a new point. Check if it was snapped to an existing way due to the '_referencing_ways'-tag
const store = this._state.featureProperties.getStore(id)
store?.addCallbackAndRunD((tags) => {
- if (tags._referencing_ways !== undefined && tags._referencing_ways !== "[]") {
- console.log("Got referencing ways according to the tags")
- this.moveDisallowedReason.setData(t.partOfAWay)
- return true
- }
+ try{
+
+ if (tags._referencing_ways !== undefined && tags._referencing_ways !== "[]") {
+ console.log("Got referencing ways according to the tags")
+ this.moveDisallowedReason.setData(t.partOfAWay)
+ return true // unregister
+ }
+ }catch (e) {
+ console.error("Could not get '_referencing_ways'-attribute of tags due to", e)
+ }
})
}
}