diff --git a/src/Logic/ImageProviders/ImageProvider.ts b/src/Logic/ImageProviders/ImageProvider.ts index 8d9f8df17b..d3d14b705e 100644 --- a/src/Logic/ImageProviders/ImageProvider.ts +++ b/src/Logic/ImageProviders/ImageProvider.ts @@ -124,8 +124,7 @@ export default abstract class ImageProvider { ): undefined | ProvidedImage[] | Promise public abstract DownloadAttribution(providedImage: { - url: string - id?: string + id: string }): Promise public abstract apiUrls(): string[] @@ -142,7 +141,7 @@ export default abstract class ImageProvider { id: string }): Promise> | undefined - public static async offerImageAsDownload(image: ProvidedImage) { + public static async offerImageAsDownload(image: { url_hd?: string, url: string }) { const response = await fetch(image.url_hd ?? image.url) const blob = await response.blob() Utils.offerContentsAsDownloadableFile(blob, new URL(image.url).pathname.split("/").at(-1), { diff --git a/src/Logic/ImageProviders/Imgur.ts b/src/Logic/ImageProviders/Imgur.ts index 8b18be9ff7..f7239b2cc3 100644 --- a/src/Logic/ImageProviders/Imgur.ts +++ b/src/Logic/ImageProviders/Imgur.ts @@ -75,27 +75,27 @@ export class Imgur extends ImageProvider { * * const data = {"data":{"id":"I9t6B7B","title":"Station Knokke","description":"author:Pieter Vander Vennet\r\nlicense:CC-BY 4.0\r\nosmid:node\/9812712386","datetime":1655052078,"type":"image\/jpeg","animated":false,"width":2400,"height":1795,"size":910872,"views":2,"bandwidth":1821744,"vote":null,"favorite":false,"nsfw":false,"section":null,"account_url":null,"account_id":null,"is_ad":false,"in_most_viral":false,"has_sound":false,"tags":[],"ad_type":0,"ad_url":"","edited":"0","in_gallery":false,"link":"https:\/\/i.imgur.com\/I9t6B7B.jpg","ad_config":{"safeFlags":["not_in_gallery","share"],"highRiskFlags":[],"unsafeFlags":["sixth_mod_unsafe"],"wallUnsafeFlags":[],"showsAds":false,"showAdLevel":1}},"success":true,"status":200} * Utils.injectJsonDownloadForTests("https://api.imgur.com/3/image/E0RuAK3", data) - * const licenseInfo = await Imgur.singleton.DownloadAttribution({url: "https://i.imgur.com/E0RuAK3.jpg"}) + * const licenseInfo = await Imgur.singleton.DownloadAttribution({id: "https://i.imgur.com/E0RuAK3.jpg"}) * const expected = new LicenseInfo() * expected.licenseShortName = "CC-BY 4.0" * expected.artist = "Pieter Vander Vennet" * expected.date = new Date(1655052078000) * expected.views = 2 * licenseInfo // => expected - * const licenseInfoJpeg = await Imgur.singleton.DownloadAttribution({url:"https://i.imgur.com/E0RuAK3.jpeg"}) + * const licenseInfoJpeg = await Imgur.singleton.DownloadAttribution({id:"https://i.imgur.com/E0RuAK3.jpeg"}) * licenseInfoJpeg // => expected - * const licenseInfoUpperCase = await Imgur.singleton.DownloadAttribution({url: "https://i.imgur.com/E0RuAK3.JPEG"}) + * const licenseInfoUpperCase = await Imgur.singleton.DownloadAttribution({id: "https://i.imgur.com/E0RuAK3.JPEG"}) * licenseInfoUpperCase // => expected * * */ public async DownloadAttribution( providedImage: { - url: string + id: string }, withResponse?: (obj) => void ): Promise { - const url = providedImage.url + const url = providedImage.id const hash = url.substr("https://i.imgur.com/".length).split(/(\.jpe?g)|(\.png)/i)[0] const apiUrl = "https://api.imgur.com/3/image/" + hash diff --git a/src/Logic/ImageProviders/Panoramax.ts b/src/Logic/ImageProviders/Panoramax.ts index 3494c563a2..8227c78d02 100644 --- a/src/Logic/ImageProviders/Panoramax.ts +++ b/src/Logic/ImageProviders/Panoramax.ts @@ -208,8 +208,7 @@ export default class PanoramaxImageProvider extends ImageProvider { } public async DownloadAttribution(providedImage: { - id: string, - url: string // Actually not used + id: string }): Promise { const meta = await this.getInfoFor(providedImage.id) diff --git a/src/Logic/ImageProviders/WikimediaImageProvider.ts b/src/Logic/ImageProviders/WikimediaImageProvider.ts index 3d587e5499..5d247f1ff0 100644 --- a/src/Logic/ImageProviders/WikimediaImageProvider.ts +++ b/src/Logic/ImageProviders/WikimediaImageProvider.ts @@ -155,9 +155,9 @@ export class WikimediaImageProvider extends ImageProvider { return [this.UrlForImage("File:" + value)] } - public async DownloadAttribution(img: { url: string }): Promise { - const filename = "File:" + WikimediaImageProvider.extractFileName(img.url) - console.log("Downloading attribution for", filename, img.url) + public async DownloadAttribution(img: { id: string }): Promise { + const filename = "File:" + WikimediaImageProvider.extractFileName(img.id) + console.log("Downloading attribution for", filename, img.id) if (filename === "") { return undefined } diff --git a/src/Logic/Web/NearbyImagesSearch.ts b/src/Logic/Web/NearbyImagesSearch.ts index 3bcb1de3a9..89d5f749cc 100644 --- a/src/Logic/Web/NearbyImagesSearch.ts +++ b/src/Logic/Web/NearbyImagesSearch.ts @@ -27,7 +27,7 @@ class CachedFetcher implements ImageFetcher { private readonly _zoomlevel: number private readonly cache: Map> = new Map< number, - Promise + Promise<(P4CPicture & { id: string })[]> >() public readonly name: string @@ -124,8 +124,8 @@ class ImagesInLoadedDataFetcher implements ImageFetcher { this._searchRadius = searchRadius } - async fetchImages(lat: number, lon: number): Promise { - const foundImages: P4CPicture[] = [] + async fetchImages(lat: number, lon: number): Promise<(P4CPicture & { id: string })[]> { + const foundImages: (P4CPicture & { id: string })[] = [] this.indexedFeatures.features.data.forEach((feature) => { const props = feature.properties const images = [] @@ -149,6 +149,7 @@ class ImagesInLoadedDataFetcher implements ImageFetcher { foundImages.push({ pictureUrl: image, thumbUrl: image, + id: image, coordinates: { lng: centerpoint[0], lat: centerpoint[1] }, provider: "OpenStreetMap", details: { @@ -182,9 +183,10 @@ class ImagesFromPanoramaxFetcher implements ImageFetcher { } } - private static convert(imageData: ImageData): P4CPicture { + private static convert(imageData: ImageData): P4CPicture & { id: string } { const [lng, lat] = imageData.geometry.coordinates return { + id: imageData.id, pictureUrl: imageData.assets.sd.href, coordinates: { lng, lat }, @@ -205,7 +207,7 @@ class ImagesFromPanoramaxFetcher implements ImageFetcher { } } - public async fetchImages(lat: number, lon: number): Promise { + public async fetchImages(lat: number, lon: number): Promise<(P4CPicture & { id: string })[]> { const radiusSettings = [ { place_fov_tolerance: 180, @@ -372,7 +374,7 @@ export class CombinedFetcher { start_captured_at: maxage, panoramas: "no", }), - new P4CImageFetcher("mapillary"), + // new P4CImageFetcher("mapillary"), new P4CImageFetcher("wikicommons"), ].map((f) => new CachedFetcher(f)) } diff --git a/src/UI/Image/ImagePreview.svelte b/src/UI/Image/ImagePreview.svelte index 6cc6f75479..e9cdc0029c 100644 --- a/src/UI/Image/ImagePreview.svelte +++ b/src/UI/Image/ImagePreview.svelte @@ -42,7 +42,6 @@ provider = panoramaInfo.properties.provider } console.log(">>> Got:", panoramaInfo, "by", provider.name) -UI: //actuallyDisplayed.set(image.properties.imageMeta) }) if (Array.isArray(nearbyFeatures)) {