forked from MapComplete/MapComplete
Feature: add link to the original provider, see #2387
This commit is contained in:
parent
991925ba35
commit
3e5b1444cc
10 changed files with 51 additions and 5 deletions
|
|
@ -33,6 +33,7 @@ export default class GenericImageProvider extends ImageProvider {
|
|||
url: value,
|
||||
provider: this,
|
||||
id: value,
|
||||
isSpherical: undefined
|
||||
},
|
||||
]
|
||||
}
|
||||
|
|
@ -45,7 +46,11 @@ export default class GenericImageProvider extends ImageProvider {
|
|||
return undefined
|
||||
}
|
||||
|
||||
getPanoramaInfo(image: { id: string }): undefined {
|
||||
getPanoramaInfo(): undefined {
|
||||
return undefined
|
||||
}
|
||||
|
||||
visitUrl(image: { url: string }): string | undefined {
|
||||
return image.url
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,6 +125,11 @@ export default abstract class ImageProvider {
|
|||
|
||||
public abstract apiUrls(): string[]
|
||||
|
||||
/**
|
||||
* URL to visit the image on the original website
|
||||
*/
|
||||
public abstract visitUrl(image: Partial<ProvidedImage>, location?: { lon: number, lat: number }): string | undefined
|
||||
|
||||
public abstract getPanoramaInfo(image: {
|
||||
id: string
|
||||
}): Promise<Feature<Point, PanoramaView>> | undefined
|
||||
|
|
|
|||
|
|
@ -118,7 +118,11 @@ export class Imgur extends ImageProvider {
|
|||
return license
|
||||
}
|
||||
|
||||
getPanoramaInfo(image: { id: string }): undefined {
|
||||
getPanoramaInfo(): undefined {
|
||||
return undefined
|
||||
}
|
||||
|
||||
visitUrl(): string | undefined {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import MapillaryIcon from "./MapillaryIcon.svelte"
|
|||
import { Feature, Point } from "geojson"
|
||||
|
||||
export class Mapillary extends ImageProvider {
|
||||
|
||||
public static readonly singleton = new Mapillary()
|
||||
public readonly name = "Mapillary"
|
||||
|
||||
|
|
@ -237,4 +238,11 @@ export class Mapillary extends ImageProvider {
|
|||
lon: geometry.coordinates[0],
|
||||
}
|
||||
}
|
||||
|
||||
public visitUrl(image: { id: string }, location?: { lon: number, lat: number }): (string | undefined) {
|
||||
if (!image.id) {
|
||||
return
|
||||
}
|
||||
return Mapillary.createLink(location, 17, image.id)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,15 @@ export default class PanoramaxImageProvider extends ImageProvider {
|
|||
)
|
||||
}
|
||||
|
||||
visitUrl(img: { id: string, url: string }, location?: { lon: number, lat: number }): string | undefined {
|
||||
const host = "https://" + new URL(img.url).host
|
||||
const p = new Panoramax(host)
|
||||
return p.createViewLink({
|
||||
imageId: img?.id,
|
||||
location
|
||||
})
|
||||
}
|
||||
|
||||
public addKnownMeta(meta: ImageData, url?: string) {
|
||||
PanoramaxImageProvider.knownMeta[meta.id] = { data: Promise.resolve({ data: meta, url }), time: new Date() }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,4 +71,8 @@ export class WikidataImageProvider extends ImageProvider {
|
|||
public getPanoramaInfo(image: { id: string }): Promise<Feature<Point, PanoramaView>> {
|
||||
return undefined
|
||||
}
|
||||
|
||||
visitUrl(image: Partial<ProvidedImage>, location?: { lon: number; lat: number }): string | undefined {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -193,7 +193,11 @@ export class WikimediaImageProvider extends ImageProvider {
|
|||
}
|
||||
}
|
||||
|
||||
getPanoramaInfo(image: { id: string }): Promise<Feature<Point, PanoramaView>> | undefined {
|
||||
getPanoramaInfo(): Promise<Feature<Point, PanoramaView>> | undefined {
|
||||
return undefined
|
||||
}
|
||||
|
||||
visitUrl(): string | undefined {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue