Performance: cache panoramax requests more aggressively; reuse license information that comes from the search-api; lower picture limit; should relieve #2384 greatly

This commit is contained in:
Pieter Vander Vennet 2025-04-22 02:53:31 +02:00
parent bd287fd8b0
commit 549129671a
7 changed files with 53 additions and 45 deletions

View file

@ -172,7 +172,7 @@ class ImagesFromPanoramaxFetcher implements ImageFetcher {
"https://panoramax.mapcomplete.org",
]
constructor(url?: string, radius: number = 100) {
constructor(url?: string, radius: number = 50) {
this._radius = radius
if (url) {
this._panoramax = new Panoramax(url)
@ -182,12 +182,11 @@ class ImagesFromPanoramaxFetcher implements ImageFetcher {
}
public async fetchImages(lat: number, lon: number): Promise<P4CPicture[]> {
const bboxObj = new BBox([
GeoOperations.destination([lon, lat], this._radius * Math.sqrt(2), -45),
GeoOperations.destination([lon, lat], this._radius * Math.sqrt(2), 135),
])
const bbox: [number, number, number, number] = bboxObj.toLngLatFlat()
const images = await this._panoramax.search({ bbox, limit: 1000 })
const images = await this._panoramax.search({
place: [lon, lat],
place_distance: this._radius ?? 50,
limit: 50
})
return images.map((i) => {
const [lng, lat] = i.geometry.coordinates