forked from MapComplete/MapComplete
Chore: housekeeping, linting
This commit is contained in:
parent
f942529755
commit
30d00eb06d
74 changed files with 998 additions and 623 deletions
|
|
@ -361,7 +361,13 @@ export default class NameSuggestionIndex {
|
|||
return nsi.generateMappings(key, tags, country, center, options)
|
||||
}
|
||||
|
||||
private static readonly brandPrefix = ["name", "alt_name", "operator", "brand", "official_name"] as const
|
||||
private static readonly brandPrefix = [
|
||||
"name",
|
||||
"alt_name",
|
||||
"operator",
|
||||
"brand",
|
||||
"official_name",
|
||||
] as const
|
||||
|
||||
/**
|
||||
* An NSI-item might have tags such as `name=X`, `alt_name=brand X`, `brand=X`, `brand:wikidata`, `shop=Y`, `service:abc=yes`
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ class P4CImageFetcher implements ImageFetcher {
|
|||
searchRadius,
|
||||
{
|
||||
mindate: new Date().getTime() - maxAgeSeconds,
|
||||
towardscenter: false
|
||||
towardscenter: false,
|
||||
}
|
||||
)
|
||||
} catch (e) {
|
||||
|
|
@ -152,9 +152,9 @@ class ImagesInLoadedDataFetcher implements ImageFetcher {
|
|||
coordinates: { lng: centerpoint[0], lat: centerpoint[1] },
|
||||
provider: "OpenStreetMap",
|
||||
details: {
|
||||
isSpherical: false
|
||||
isSpherical: false,
|
||||
},
|
||||
osmTags: { image }
|
||||
osmTags: { image },
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
@ -170,7 +170,7 @@ class ImagesFromPanoramaxFetcher implements ImageFetcher {
|
|||
public static readonly apiUrls: ReadonlyArray<string> = [
|
||||
"https://panoramax.openstreetmap.fr",
|
||||
"https://api.panoramax.xyz",
|
||||
"https://panoramax.mapcomplete.org"
|
||||
"https://panoramax.mapcomplete.org",
|
||||
]
|
||||
|
||||
constructor(url?: string, radius: number = 50) {
|
||||
|
|
@ -191,7 +191,7 @@ class ImagesFromPanoramaxFetcher implements ImageFetcher {
|
|||
provider: "panoramax",
|
||||
direction: imageData.properties["view:azimuth"],
|
||||
osmTags: {
|
||||
panoramax: imageData.id
|
||||
panoramax: imageData.id,
|
||||
},
|
||||
thumbUrl: imageData.assets.thumb.href,
|
||||
date: new Date(imageData.properties.datetime).getTime(),
|
||||
|
|
@ -200,8 +200,8 @@ class ImagesFromPanoramaxFetcher implements ImageFetcher {
|
|||
detailsUrl: imageData.id,
|
||||
details: {
|
||||
isSpherical:
|
||||
imageData.properties["exif"]["Xmp.GPano.ProjectionType"] === "equirectangular"
|
||||
}
|
||||
imageData.properties["exif"]["Xmp.GPano.ProjectionType"] === "equirectangular",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -209,23 +209,26 @@ class ImagesFromPanoramaxFetcher implements ImageFetcher {
|
|||
const radiusSettings = [
|
||||
{
|
||||
place_fov_tolerance: 180,
|
||||
radius: 15
|
||||
radius: 15,
|
||||
},
|
||||
{
|
||||
place_fov_tolerance: 180,
|
||||
radius: 25
|
||||
radius: 25,
|
||||
},
|
||||
{
|
||||
place_fov_tolerance: 90,
|
||||
radius: 50
|
||||
}
|
||||
radius: 50,
|
||||
},
|
||||
]
|
||||
const promises: Promise<ImageData[]>[] = []
|
||||
const maxRadius = this._radius
|
||||
let prevRadius = 0
|
||||
|
||||
const nearby = this._panoramax.search({
|
||||
bbox: new BBox([[lon - 0.0001, lat - 0.0001], [lon + 0.0001, lat + 0.0001]]).toLngLatFlat()
|
||||
bbox: new BBox([
|
||||
[lon - 0.0001, lat - 0.0001],
|
||||
[lon + 0.0001, lat + 0.0001],
|
||||
]).toLngLatFlat(),
|
||||
})
|
||||
promises.push(nearby) // We do a nearby search with bbox, see https://source.mapcomplete.org/MapComplete/MapComplete/issues/2384
|
||||
for (const radiusSetting of radiusSettings) {
|
||||
|
|
@ -233,7 +236,7 @@ class ImagesFromPanoramaxFetcher implements ImageFetcher {
|
|||
place: [lon, lat],
|
||||
place_distance: [prevRadius, Math.min(maxRadius, radiusSetting.radius)],
|
||||
place_fov_tolerance: radiusSetting.place_fov_tolerance,
|
||||
limit: 50
|
||||
limit: 50,
|
||||
})
|
||||
promises.push(promise)
|
||||
prevRadius = radiusSetting.radius
|
||||
|
|
@ -277,7 +280,7 @@ class MapillaryFetcher implements ImageFetcher {
|
|||
boundingBox.getWest(),
|
||||
boundingBox.getSouth(),
|
||||
boundingBox.getEast(),
|
||||
boundingBox.getNorth()
|
||||
boundingBox.getNorth(),
|
||||
].join(",") +
|
||||
"&access_token=" +
|
||||
encodeURIComponent(Constants.mapillary_client_token_v4) +
|
||||
|
|
@ -323,17 +326,17 @@ class MapillaryFetcher implements ImageFetcher {
|
|||
coordinates: { lng: c[0], lat: c[1] },
|
||||
thumbUrl: img.thumb_256_url,
|
||||
osmTags: {
|
||||
mapillary: img.id
|
||||
mapillary: img.id,
|
||||
},
|
||||
details: {
|
||||
isSpherical: this._panoramas === "only"
|
||||
isSpherical: this._panoramas === "only",
|
||||
},
|
||||
|
||||
detailsUrl: Mapillary.singleton.visitUrl(img, { lon, lat }),
|
||||
date: img.captured_at,
|
||||
license: "CC-BY-SA",
|
||||
author: img.creator.username,
|
||||
direction: img.compass_angle
|
||||
direction: img.compass_angle,
|
||||
})
|
||||
}
|
||||
return pics
|
||||
|
|
@ -349,7 +352,7 @@ export class CombinedFetcher {
|
|||
Imgur.apiUrl,
|
||||
...Imgur.supportingUrls,
|
||||
...MapillaryFetcher.apiUrls,
|
||||
...ImagesFromPanoramaxFetcher.apiUrls
|
||||
...ImagesFromPanoramaxFetcher.apiUrls,
|
||||
]
|
||||
|
||||
constructor(radius: number, maxage: Date, indexedFeatures: IndexedFeatureSource) {
|
||||
|
|
@ -361,15 +364,15 @@ export class CombinedFetcher {
|
|||
new MapillaryFetcher({
|
||||
max_images: 25,
|
||||
start_captured_at: maxage,
|
||||
panoramas: "only"
|
||||
panoramas: "only",
|
||||
}),
|
||||
new MapillaryFetcher({
|
||||
max_images: 25,
|
||||
start_captured_at: maxage,
|
||||
panoramas: "no"
|
||||
panoramas: "no",
|
||||
}),
|
||||
new P4CImageFetcher("mapillary"),
|
||||
new P4CImageFetcher("wikicommons")
|
||||
new P4CImageFetcher("wikicommons"),
|
||||
].map((f) => new CachedFetcher(f))
|
||||
}
|
||||
|
||||
|
|
@ -387,7 +390,7 @@ export class CombinedFetcher {
|
|||
|
||||
const newList = []
|
||||
const seenIds = new Set<string>()
|
||||
for (const p4CPicture of [...sink.data ?? [], ...pics]) {
|
||||
for (const p4CPicture of [...(sink.data ?? []), ...pics]) {
|
||||
const id = p4CPicture.pictureUrl
|
||||
if (seenIds.has(id)) {
|
||||
continue
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue