forked from MapComplete/MapComplete
Refactoring: image providers use ID everywhere
This commit is contained in:
parent
d9c1fe3f74
commit
1ddfffcee0
6 changed files with 19 additions and 20 deletions
|
|
@ -27,7 +27,7 @@ class CachedFetcher implements ImageFetcher {
|
|||
private readonly _zoomlevel: number
|
||||
private readonly cache: Map<number, Promise<(P4CPicture & { id: string })[]>> = new Map<
|
||||
number,
|
||||
Promise<P4CPicture[]>
|
||||
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<P4CPicture[]> {
|
||||
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<P4CPicture[]> {
|
||||
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))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue