forked from MapComplete/MapComplete
Better filtering of some LOD-properties
This commit is contained in:
parent
087c099e2e
commit
6b381e05c6
2 changed files with 80 additions and 53 deletions
|
@ -24,7 +24,8 @@ export default class LinkedDataLoader {
|
||||||
image: { "@id": "http://schema.org/image", "@type": "@id" },
|
image: { "@id": "http://schema.org/image", "@type": "@id" },
|
||||||
opening_hours: { "@id": "http://schema.org/openingHoursSpecification" },
|
opening_hours: { "@id": "http://schema.org/openingHoursSpecification" },
|
||||||
openingHours: { "@id": "http://schema.org/openingHours", "@container": "@set" },
|
openingHours: { "@id": "http://schema.org/openingHours", "@container": "@set" },
|
||||||
geo: { "@id": "http://schema.org/geo" }
|
geo: { "@id": "http://schema.org/geo" },
|
||||||
|
"alt_name": {"@id":"http://schema.org/alternateName"}
|
||||||
}
|
}
|
||||||
private static COMPACTING_CONTEXT_OH = {
|
private static COMPACTING_CONTEXT_OH = {
|
||||||
dayOfWeek: { "@id": "http://schema.org/dayOfWeek", "@container": "@set" },
|
dayOfWeek: { "@id": "http://schema.org/dayOfWeek", "@container": "@set" },
|
||||||
|
@ -188,6 +189,11 @@ export default class LinkedDataLoader {
|
||||||
compacted["geo"] = <any>await LinkedDataLoader.geoToGeometry(compacted["geo"])
|
compacted["geo"] = <any>await LinkedDataLoader.geoToGeometry(compacted["geo"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(compacted["alt_name"]){
|
||||||
|
if(compacted["alt_name"] === compacted["name"]){
|
||||||
|
delete compacted["alt_name"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (const k in compacted) {
|
for (const k in compacted) {
|
||||||
if (compacted[k] === "") {
|
if (compacted[k] === "") {
|
||||||
|
|
|
@ -1,66 +1,87 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import LinkableImage from "../Image/LinkableImage.svelte"
|
import LinkableImage from "../Image/LinkableImage.svelte"
|
||||||
import { UIEventSource } from "../../Logic/UIEventSource"
|
import { UIEventSource } from "../../Logic/UIEventSource"
|
||||||
import type { OsmTags } from "../../Models/OsmFeature"
|
import type { OsmTags } from "../../Models/OsmFeature"
|
||||||
import type { SpecialVisualizationState } from "../SpecialVisualization"
|
import type { SpecialVisualizationState } from "../SpecialVisualization"
|
||||||
import type { Feature } from "geojson"
|
import type { Feature } from "geojson"
|
||||||
import LayerConfig from "../../Models/ThemeConfig/LayerConfig"
|
import LayerConfig from "../../Models/ThemeConfig/LayerConfig"
|
||||||
import ComparisonAction from "./ComparisonAction.svelte"
|
import ComparisonAction from "./ComparisonAction.svelte"
|
||||||
import Party from "../../assets/svg/Party.svelte"
|
import Party from "../../assets/svg/Party.svelte"
|
||||||
import ChangeTagAction from "../../Logic/Osm/Actions/ChangeTagAction"
|
import ChangeTagAction from "../../Logic/Osm/Actions/ChangeTagAction"
|
||||||
import { Tag } from "../../Logic/Tags/Tag"
|
import { Tag } from "../../Logic/Tags/Tag"
|
||||||
import { And } from "../../Logic/Tags/And"
|
import { And } from "../../Logic/Tags/And"
|
||||||
import Loading from "../Base/Loading.svelte"
|
import Loading from "../Base/Loading.svelte"
|
||||||
import AttributedImage from "../Image/AttributedImage.svelte"
|
import AttributedImage from "../Image/AttributedImage.svelte"
|
||||||
import Translations from "../i18n/Translations"
|
import Translations from "../i18n/Translations"
|
||||||
import Tr from "../Base/Tr.svelte"
|
import Tr from "../Base/Tr.svelte"
|
||||||
|
|
||||||
export let osmProperties: Record<string, string>
|
export let osmProperties: Record<string, string>
|
||||||
export let externalProperties: Record<string, string>
|
export let externalProperties: Record<string, string>
|
||||||
export let sourceUrl: string
|
export let sourceUrl: string
|
||||||
|
|
||||||
export let tags: UIEventSource<OsmTags>
|
export let tags: UIEventSource<OsmTags>
|
||||||
export let state: SpecialVisualizationState
|
export let state: SpecialVisualizationState
|
||||||
export let feature: Feature
|
export let feature: Feature
|
||||||
export let layer: LayerConfig
|
export let layer: LayerConfig
|
||||||
|
|
||||||
export let readonly = false
|
export let readonly = false
|
||||||
|
|
||||||
const t = Translations.t.external
|
const t = Translations.t.external
|
||||||
|
|
||||||
let externalKeys: string[] = Object.keys(externalProperties).sort()
|
let externalKeys: string[] = Object.keys(externalProperties).sort()
|
||||||
|
|
||||||
const imageKeyRegex = /image|image:[0-9]+/
|
const imageKeyRegex = /image|image:[0-9]+/
|
||||||
let knownImages = new Set(
|
let knownImages = new Set(
|
||||||
Object.keys(osmProperties)
|
Object.keys(osmProperties)
|
||||||
.filter((k) => k.match(imageKeyRegex))
|
.filter((k) => k.match(imageKeyRegex))
|
||||||
.map((k) => osmProperties[k]),
|
.map((k) => osmProperties[k])
|
||||||
)
|
)
|
||||||
let unknownImages = externalKeys
|
let unknownImages = externalKeys
|
||||||
.filter((k) => k.match(imageKeyRegex))
|
.filter((k) => k.match(imageKeyRegex))
|
||||||
.map((k) => externalProperties[k])
|
.map((k) => externalProperties[k])
|
||||||
.filter((i) => !knownImages.has(i))
|
.filter((i) => !knownImages.has(i))
|
||||||
|
|
||||||
let propertyKeysExternal = externalKeys.filter((k) => k.match(imageKeyRegex) === null)
|
let propertyKeysExternal = externalKeys.filter((k) => k.match(imageKeyRegex) === null)
|
||||||
let missing = propertyKeysExternal.filter((k) => osmProperties[k] === undefined && typeof externalProperties[k] === "string")
|
let missing = propertyKeysExternal.filter((k) => osmProperties[k] === undefined && typeof externalProperties[k] === "string")
|
||||||
let same = propertyKeysExternal.filter((key) => osmProperties[key] === externalProperties[key])
|
// let same = propertyKeysExternal.filter((key) => osmProperties[key] === externalProperties[key])
|
||||||
let different = propertyKeysExternal.filter(
|
let different = propertyKeysExternal.filter(
|
||||||
(key) => osmProperties[key] !== undefined && osmProperties[key] !== externalProperties[key] && typeof externalProperties[key] === "string",
|
(key) => {
|
||||||
)
|
if (osmProperties[key] === undefined) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (typeof externalProperties[key] !== "string") {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (osmProperties[key] === externalProperties[key]) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
let currentStep: "init" | "applying_all" | "all_applied" = "init"
|
if (key === "website")
|
||||||
let applyAllHovered = false
|
{
|
||||||
|
const osmCanon = new URL(osmProperties[key]).toString()
|
||||||
|
const externalCanon = new URL(externalProperties[key]).toString()
|
||||||
|
if(osmCanon === externalCanon){
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function applyAllMissing() {
|
return true
|
||||||
currentStep = "applying_all"
|
|
||||||
const tagsToApply = missing.map((k) => new Tag(k, externalProperties[k]))
|
|
||||||
const change = new ChangeTagAction(tags.data.id, new And(tagsToApply), tags.data, {
|
|
||||||
theme: state.layout.id,
|
|
||||||
changeType: "import",
|
|
||||||
})
|
|
||||||
await state.changes.applyChanges(await change.CreateChangeDescriptions())
|
|
||||||
currentStep = "all_applied"
|
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
let currentStep: "init" | "applying_all" | "all_applied" = "init"
|
||||||
|
let applyAllHovered = false
|
||||||
|
|
||||||
|
async function applyAllMissing() {
|
||||||
|
currentStep = "applying_all"
|
||||||
|
const tagsToApply = missing.map((k) => new Tag(k, externalProperties[k]))
|
||||||
|
const change = new ChangeTagAction(tags.data.id, new And(tagsToApply), tags.data, {
|
||||||
|
theme: state.layout.id,
|
||||||
|
changeType: "import"
|
||||||
|
})
|
||||||
|
await state.changes.applyChanges(await change.CreateChangeDescriptions())
|
||||||
|
currentStep = "all_applied"
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
{#if unknownImages.length === 0 && missing.length === 0 && different.length === 0}
|
{#if unknownImages.length === 0 && missing.length === 0 && different.length === 0}
|
||||||
<div class="thanks m-0 flex items-center gap-x-2 px-2">
|
<div class="thanks m-0 flex items-center gap-x-2 px-2">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue