forked from MapComplete/MapComplete
Fix: license info in 'nearby images' now works for mapillary, add bbox search for panoramax
This commit is contained in:
parent
14fd4e0f4f
commit
7f5544c1e5
6 changed files with 47 additions and 15 deletions
|
@ -9,6 +9,7 @@ import { Utils } from "../../Utils"
|
|||
import { Point } from "geojson"
|
||||
import { Imgur } from "../ImageProviders/Imgur"
|
||||
import { ImageData, Panoramax, PanoramaxXYZ } from "panoramax-js/dist"
|
||||
import { Mapillary } from "../ImageProviders/Mapillary"
|
||||
|
||||
interface ImageFetcher {
|
||||
/**
|
||||
|
@ -222,6 +223,11 @@ class ImagesFromPanoramaxFetcher implements ImageFetcher {
|
|||
const promises: Promise<ImageData[]>[] = []
|
||||
const maxRadius = this._radius
|
||||
let prevRadius = 0
|
||||
|
||||
const nearby = this._panoramax.search({
|
||||
bbox: new BBox([[lon, lat]]).pad(0.001).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) {
|
||||
const promise = this._panoramax.search({
|
||||
place: [lon, lat],
|
||||
|
@ -265,7 +271,7 @@ class MapillaryFetcher implements ImageFetcher {
|
|||
async fetchImages(lat: number, lon: number): Promise<P4CPicture[]> {
|
||||
const boundingBox = new BBox([[lon, lat]]).padAbsolute(0.003)
|
||||
let url =
|
||||
"https://graph.mapillary.com/images?fields=geometry,computed_geometry,creator,id,thumb_256_url,thumb_original_url,compass_angle&bbox=" +
|
||||
"https://graph.mapillary.com/images?fields=geometry,computed_geometry,creator,id,captured_at,thumb_256_url,thumb_original_url,compass_angle&bbox=" +
|
||||
[
|
||||
boundingBox.getWest(),
|
||||
boundingBox.getSouth(),
|
||||
|
@ -293,13 +299,14 @@ class MapillaryFetcher implements ImageFetcher {
|
|||
const response = await Utils.downloadJson<{
|
||||
data: {
|
||||
id: string
|
||||
creator: string
|
||||
creator: { username: string }
|
||||
geometry: Point
|
||||
computed_geometry: Point
|
||||
is_pano: boolean
|
||||
thumb_256_url: string
|
||||
thumb_original_url: string
|
||||
compass_angle: number
|
||||
captured_at: number
|
||||
}[]
|
||||
}>(url)
|
||||
const pics: P4CPicture[] = []
|
||||
|
@ -308,6 +315,7 @@ class MapillaryFetcher implements ImageFetcher {
|
|||
if (img.thumb_original_url === undefined) {
|
||||
continue
|
||||
}
|
||||
const [lon, lat] = img.computed_geometry.coordinates
|
||||
pics.push({
|
||||
pictureUrl: img.thumb_original_url,
|
||||
provider: "Mapillary",
|
||||
|
@ -319,6 +327,12 @@ class MapillaryFetcher implements ImageFetcher {
|
|||
details: {
|
||||
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
|
||||
})
|
||||
}
|
||||
return pics
|
||||
|
@ -367,7 +381,6 @@ export class CombinedFetcher {
|
|||
): Promise<void> {
|
||||
try {
|
||||
const pics = await source.fetchImages(lat, lon)
|
||||
console.log(source.name, "==>>", pics)
|
||||
state.data[source.name] = "done"
|
||||
state.ping()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue