Fix: allow to link multiple mapillary-images

This commit is contained in:
Pieter Vander Vennet 2024-01-16 23:55:18 +01:00
parent 5136d20477
commit 286fe72935
6 changed files with 11 additions and 14 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "mapcomplete", "name": "mapcomplete",
"version": "0.36.12", "version": "0.36.13",
"repository": "https://github.com/pietervdvn/MapComplete", "repository": "https://github.com/pietervdvn/MapComplete",
"description": "A small website to edit OSM easily", "description": "A small website to edit OSM easily",
"bugs": "https://github.com/pietervdvn/MapComplete/issues", "bugs": "https://github.com/pietervdvn/MapComplete/issues",

View file

@ -155,7 +155,6 @@ export class Mapillary extends ImageProvider {
Constants.mapillary_client_token_v4 Constants.mapillary_client_token_v4
const response = await Utils.downloadJsonCached(metadataUrl, 60 * 60) const response = await Utils.downloadJsonCached(metadataUrl, 60 * 60)
const url = <string>response["thumb_1024_url"] const url = <string>response["thumb_1024_url"]
console.log(response)
const url_hd = <string>response["thumb_original_url"] const url_hd = <string>response["thumb_original_url"]
return { return {
id: "" + mapillaryId, id: "" + mapillaryId,

View file

@ -1,7 +1,6 @@
import ChangeTagAction from "./ChangeTagAction" import ChangeTagAction from "./ChangeTagAction"
import { Tag } from "../../Tags/Tag" import { Tag } from "../../Tags/Tag"
import OsmChangeAction from "./OsmChangeAction" import OsmChangeAction from "./OsmChangeAction"
import { Changes } from "../Changes"
import { ChangeDescription } from "./ChangeDescription" import { ChangeDescription } from "./ChangeDescription"
import { Store } from "../../UIEventSource" import { Store } from "../../UIEventSource"
@ -40,7 +39,7 @@ export default class LinkImageAction extends OsmChangeAction {
protected CreateChangeDescriptions(): Promise<ChangeDescription[]> { protected CreateChangeDescriptions(): Promise<ChangeDescription[]> {
let key = this._proposedKey let key = this._proposedKey
let i = 0 let i = 0
const currentTags = this._currentTags.data const currentTags: Record<string, string> = this._currentTags.data
const url = this._url const url = this._url
while (currentTags[key] !== undefined && currentTags[key] !== url) { while (currentTags[key] !== undefined && currentTags[key] !== url) {
key = this._proposedKey + ":" + i key = this._proposedKey + ":" + i

View file

@ -539,7 +539,7 @@ export class Changes {
openChangeset openChangeset
) )
console.log("Upload successfull!") console.log("Upload successful!")
return true return true
} }

View file

@ -15,18 +15,15 @@
import SpecialTranslation from "../Popup/TagRendering/SpecialTranslation.svelte" import SpecialTranslation from "../Popup/TagRendering/SpecialTranslation.svelte"
export let tags: UIEventSource<OsmTags> export let tags: UIEventSource<OsmTags>
export let lon: number
export let lat: number
export let state: SpecialVisualizationState export let state: SpecialVisualizationState
export let image: P4CPicture export let image: P4CPicture
export let feature: Feature export let feature: Feature
export let layer: LayerConfig export let layer: LayerConfig
export let linkable = true export let linkable = true
let isLinked = Object.values(tags.data).some((v) => image.pictureUrl === v) let targetValue = Object.values(image.osmTags)[0]
let isLinked = new UIEventSource(Object.values(tags.data).some((v) => targetValue === v))
const t = Translations.t.image.nearby const t = Translations.t.image.nearby
const c = [lon, lat]
const providedImage: ProvidedImage = { const providedImage: ProvidedImage = {
url: image.thumbUrl ?? image.pictureUrl, url: image.thumbUrl ?? image.pictureUrl,
url_hd: image.pictureUrl, url_hd: image.pictureUrl,
@ -36,10 +33,11 @@
id: Object.values(image.osmTags)[0], id: Object.values(image.osmTags)[0],
} }
$: { function applyLink(isLinked :boolean) {
console.log("Applying linked image", isLinked, targetValue)
const currentTags = tags.data const currentTags = tags.data
const key = Object.keys(image.osmTags)[0] const key = Object.keys(image.osmTags)[0]
const url = image.osmTags[key] const url = targetValue
if (isLinked) { if (isLinked) {
const action = new LinkImageAction(currentTags.id, key, url, tags, { const action = new LinkImageAction(currentTags.id, key, url, tags, {
theme: tags.data._orig_theme ?? state.layout.id, theme: tags.data._orig_theme ?? state.layout.id,
@ -59,6 +57,7 @@
} }
} }
} }
isLinked.addCallback(isLinked => applyLink(isLinked))
</script> </script>
<div class="flex w-fit shrink-0 flex-col"> <div class="flex w-fit shrink-0 flex-col">
@ -71,7 +70,7 @@
</div> </div>
{#if linkable} {#if linkable}
<label> <label>
<input bind:checked={isLinked} type="checkbox" /> <input bind:checked={$isLinked} type="checkbox" />
<SpecialTranslation t={t.link} {tags} {state} {layer} {feature} /> <SpecialTranslation t={t.link} {tags} {state} {layer} {feature} />
</label> </label>
{/if} {/if}

View file

@ -55,7 +55,7 @@
<div class="flex w-full space-x-1 overflow-x-auto" style="scroll-snap-type: x proximity"> <div class="flex w-full space-x-1 overflow-x-auto" style="scroll-snap-type: x proximity">
{#each $images as image (image.pictureUrl)} {#each $images as image (image.pictureUrl)}
<span class="w-fit shrink-0" style="scroll-snap-align: start"> <span class="w-fit shrink-0" style="scroll-snap-align: start">
<LinkableImage {tags} {image} {state} {lon} {lat} {feature} {layer} {linkable} /> <LinkableImage {tags} {image} {state} {feature} {layer} {linkable} />
</span> </span>
{/each} {/each}
</div> </div>