forked from MapComplete/MapComplete
Merge branch 'develop'
This commit is contained in:
commit
cc8b218ea1
20 changed files with 122 additions and 69 deletions
|
@ -1,4 +1,5 @@
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- 'v*'
|
||||||
|
@ -42,7 +43,10 @@ jobs:
|
||||||
run: npm run android:prepare
|
run: npm run android:prepare
|
||||||
|
|
||||||
- name: Decode keystore
|
- name: Decode keystore
|
||||||
run: echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 -d > ~/.gradle/release-key.jks
|
run: |
|
||||||
|
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 -d > ./android/app/release-key.jks
|
||||||
|
pwd
|
||||||
|
echo "Saved release key to ./android/app/release-key.jks"
|
||||||
|
|
||||||
- name: Grant execute permission to gradlew
|
- name: Grant execute permission to gradlew
|
||||||
run: cd android && chmod +x ./gradlew
|
run: cd android && chmod +x ./gradlew
|
||||||
|
@ -52,7 +56,8 @@ jobs:
|
||||||
cd android
|
cd android
|
||||||
export ANDROID_SDK_HOME=/home/runner/.android/sdk/
|
export ANDROID_SDK_HOME=/home/runner/.android/sdk/
|
||||||
export PATH=$ANDROID_SDK_HOME/tools:$ANDROID_SDK_HOME/platform-tools:$ANDROID_SDK_HOME/:$ANDROID_SDK_HOME/cmdline-tools/latest/tools/bin:$PATH
|
export PATH=$ANDROID_SDK_HOME/tools:$ANDROID_SDK_HOME/platform-tools:$ANDROID_SDK_HOME/:$ANDROID_SDK_HOME/cmdline-tools/latest/tools/bin:$PATH
|
||||||
export storeFile=my-release-key.jks
|
# Those variables are used in MapComplete/android/app/build.gradle
|
||||||
|
export storeFile="./release-key.jks"
|
||||||
export storePassword=${{ secrets.KEYSTORE_PASSWORD }}
|
export storePassword=${{ secrets.KEYSTORE_PASSWORD }}
|
||||||
export keyAlias=${{ secrets.KEY_ALIAS }}
|
export keyAlias=${{ secrets.KEY_ALIAS }}
|
||||||
export keyPassword=${{ secrets.KEY_PASSWORD }}
|
export keyPassword=${{ secrets.KEY_PASSWORD }}
|
||||||
|
|
|
@ -29,7 +29,7 @@ jobs:
|
||||||
DATE=$(echo $TIMESTAMP | sed "s/T.*//")
|
DATE=$(echo $TIMESTAMP | sed "s/T.*//")
|
||||||
echo $DATE
|
echo $DATE
|
||||||
# Create a new database in postgres
|
# Create a new database in postgres
|
||||||
npm run create:database -- -- $DATE
|
npm run create:database -- -- $DATE --overwrite
|
||||||
echo "Seeding database '$DATE'"
|
echo "Seeding database '$DATE'"
|
||||||
osm2pgsql -O flex -S build_db.lua -s --flat-nodes=import-help-file -d postgresql://user:password@localhost:5444/osm-poi.${DATE} /data/planet-latest.osm.pbf
|
osm2pgsql -O flex -S build_db.lua -s --flat-nodes=import-help-file -d postgresql://user:password@localhost:5444/osm-poi.${DATE} /data/planet-latest.osm.pbf
|
||||||
npm run delete:database:old
|
npm run delete:database:old
|
||||||
|
|
2
android
2
android
|
@ -1 +1 @@
|
||||||
Subproject commit 921863589c14e1a3002a6be491337de6fe8778dd
|
Subproject commit fc597bf3c9ebf1280af4e991557d66f5d5838a24
|
Before Width: | Height: | Size: 236 KiB After Width: | Height: | Size: 236 KiB |
|
@ -0,0 +1,2 @@
|
||||||
|
SPDX-FileCopyrightText: Zeitlupe
|
||||||
|
SPDX-License-Identifier: CC-BY-SA-4.0
|
|
@ -166,7 +166,7 @@
|
||||||
"it": "Questa stazione fitness ha una sbarra orizzontale, abbastanza alta per le trazioni."
|
"it": "Questa stazione fitness ha una sbarra orizzontale, abbastanza alta per le trazioni."
|
||||||
},
|
},
|
||||||
"icon": {
|
"icon": {
|
||||||
"path": "./assets/layers/fitness_station/Trimm-Dich-Pfad_Grünwalder_Forst_Klimmzüge.jpg",
|
"path": "./assets/layers/fitness_station/Trimm-Dich-Pfad_Grunwalder_Forst_Klimmzuge.jpg",
|
||||||
"class": "large"
|
"class": "large"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -242,7 +242,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "Trimm-Dich-Pfad_Grünwalder_Forst_Klimmzüge.jpg",
|
"path": "Trimm-Dich-Pfad_Grunwalder_Forst_Klimmzuge.jpg",
|
||||||
"license": "CC-BY-SA-4.0",
|
"license": "CC-BY-SA-4.0",
|
||||||
"authors": [
|
"authors": [
|
||||||
"Zeitlupe"
|
"Zeitlupe"
|
||||||
|
|
|
@ -9,8 +9,18 @@ class CreateNewDatabase extends Script {
|
||||||
}
|
}
|
||||||
|
|
||||||
async main(args: string[]): Promise<void> {
|
async main(args: string[]): Promise<void> {
|
||||||
|
const targetName = args[0]
|
||||||
|
const overwrite = args[1] === "--overwrite"
|
||||||
const db = new OsmPoiDatabase("postgresql://user:password@localhost:5444")
|
const db = new OsmPoiDatabase("postgresql://user:password@localhost:5444")
|
||||||
await db.createNew(args[0])
|
const knownDatabases = await db.findSuitableDatabases()
|
||||||
|
if (knownDatabases.indexOf(OsmPoiDatabase.databaseNameFor(targetName)) > 0) {
|
||||||
|
if (overwrite) {
|
||||||
|
await db.deleteDatabase(targetName)
|
||||||
|
} else {
|
||||||
|
throw "ERROR: the target database " + targetName + " already exists"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await db.createNew(targetName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,8 +104,12 @@ export class OsmPoiDatabase {
|
||||||
return "osm-poi." + latest
|
return "osm-poi." + latest
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static databaseNameFor(date: string) {
|
||||||
|
return `${OsmPoiDatabase._prefix}.${date}`
|
||||||
|
}
|
||||||
|
|
||||||
async createNew(date: string) {
|
async createNew(date: string) {
|
||||||
const dbname = `${OsmPoiDatabase._prefix}.${date}`
|
const dbname = OsmPoiDatabase.databaseNameFor(date)
|
||||||
console.log("Attempting to create a new database with name", dbname)
|
console.log("Attempting to create a new database with name", dbname)
|
||||||
const metaclient = this.getMetaClient()
|
const metaclient = this.getMetaClient()
|
||||||
await metaclient.connect()
|
await metaclient.connect()
|
||||||
|
|
|
@ -36,6 +36,7 @@ export interface PanoramaView {
|
||||||
*/
|
*/
|
||||||
northOffset?: number
|
northOffset?: number
|
||||||
pitchOffset?: number
|
pitchOffset?: number
|
||||||
|
provider: ImageProvider | string
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -123,7 +124,6 @@ export default abstract class ImageProvider {
|
||||||
): undefined | ProvidedImage[] | Promise<ProvidedImage[]>
|
): undefined | ProvidedImage[] | Promise<ProvidedImage[]>
|
||||||
|
|
||||||
public abstract DownloadAttribution(providedImage: {
|
public abstract DownloadAttribution(providedImage: {
|
||||||
url: string
|
|
||||||
id: string
|
id: string
|
||||||
}): Promise<LicenseInfo>
|
}): Promise<LicenseInfo>
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ export default abstract class ImageProvider {
|
||||||
id: string
|
id: string
|
||||||
}): Promise<Feature<Point, PanoramaView>> | undefined
|
}): Promise<Feature<Point, PanoramaView>> | 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 response = await fetch(image.url_hd ?? image.url)
|
||||||
const blob = await response.blob()
|
const blob = await response.blob()
|
||||||
Utils.offerContentsAsDownloadableFile(blob, new URL(image.url).pathname.split("/").at(-1), {
|
Utils.offerContentsAsDownloadableFile(blob, new URL(image.url).pathname.split("/").at(-1), {
|
||||||
|
|
|
@ -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}
|
* 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)
|
* 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()
|
* const expected = new LicenseInfo()
|
||||||
* expected.licenseShortName = "CC-BY 4.0"
|
* expected.licenseShortName = "CC-BY 4.0"
|
||||||
* expected.artist = "Pieter Vander Vennet"
|
* expected.artist = "Pieter Vander Vennet"
|
||||||
* expected.date = new Date(1655052078000)
|
* expected.date = new Date(1655052078000)
|
||||||
* expected.views = 2
|
* expected.views = 2
|
||||||
* licenseInfo // => expected
|
* 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
|
* 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
|
* licenseInfoUpperCase // => expected
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public async DownloadAttribution(
|
public async DownloadAttribution(
|
||||||
providedImage: {
|
providedImage: {
|
||||||
url: string
|
id: string
|
||||||
},
|
},
|
||||||
withResponse?: (obj) => void
|
withResponse?: (obj) => void
|
||||||
): Promise<LicenseInfo> {
|
): Promise<LicenseInfo> {
|
||||||
const url = providedImage.url
|
const url = providedImage.id
|
||||||
const hash = url.substr("https://i.imgur.com/".length).split(/(\.jpe?g)|(\.png)/i)[0]
|
const hash = url.substr("https://i.imgur.com/".length).split(/(\.jpe?g)|(\.png)/i)[0]
|
||||||
|
|
||||||
const apiUrl = "https://api.imgur.com/3/image/" + hash
|
const apiUrl = "https://api.imgur.com/3/image/" + hash
|
||||||
|
|
|
@ -169,6 +169,8 @@ export class Mapillary extends ImageProvider {
|
||||||
properties: {
|
properties: {
|
||||||
url: response.thumb_2048_url,
|
url: response.thumb_2048_url,
|
||||||
northOffset: response.computed_compass_angle,
|
northOffset: response.computed_compass_angle,
|
||||||
|
provider: this,
|
||||||
|
imageMeta: <any>image
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,7 +208,6 @@ export default class PanoramaxImageProvider extends ImageProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async DownloadAttribution(providedImage: {
|
public async DownloadAttribution(providedImage: {
|
||||||
url: string
|
|
||||||
id: string
|
id: string
|
||||||
}): Promise<LicenseInfo> {
|
}): Promise<LicenseInfo> {
|
||||||
const meta = await this.getInfoFor(providedImage.id)
|
const meta = await this.getInfoFor(providedImage.id)
|
||||||
|
@ -245,10 +244,12 @@ export default class PanoramaxImageProvider extends ImageProvider {
|
||||||
return <Feature<Point, PanoramaView>>{
|
return <Feature<Point, PanoramaView>>{
|
||||||
type: "Feature",
|
type: "Feature",
|
||||||
geometry: imageInfo.geometry,
|
geometry: imageInfo.geometry,
|
||||||
properties: {
|
properties: <PanoramaView>{
|
||||||
url,
|
url,
|
||||||
northOffset,
|
northOffset,
|
||||||
pitchOffset,
|
pitchOffset,
|
||||||
|
provider: this,
|
||||||
|
imageMeta: imageInfo
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,9 +155,9 @@ export class WikimediaImageProvider extends ImageProvider {
|
||||||
return [this.UrlForImage("File:" + value)]
|
return [this.UrlForImage("File:" + value)]
|
||||||
}
|
}
|
||||||
|
|
||||||
public async DownloadAttribution(img: { url: string }): Promise<LicenseInfo> {
|
public async DownloadAttribution(img: { id: string }): Promise<LicenseInfo> {
|
||||||
const filename = "File:" + WikimediaImageProvider.extractFileName(img.url)
|
const filename = "File:" + WikimediaImageProvider.extractFileName(img.id)
|
||||||
console.log("Downloading attribution for", filename, img.url)
|
console.log("Downloading attribution for", filename, img.id)
|
||||||
if (filename === "") {
|
if (filename === "") {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ interface ImageFetcher {
|
||||||
* @param lat
|
* @param lat
|
||||||
* @param lon
|
* @param lon
|
||||||
*/
|
*/
|
||||||
fetchImages(lat: number, lon: number): Promise<P4CPicture[]>
|
fetchImages(lat: number, lon: number): Promise<(P4CPicture & { id: string })[]>
|
||||||
|
|
||||||
readonly name: string
|
readonly name: string
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,9 @@ interface ImageFetcher {
|
||||||
class CachedFetcher implements ImageFetcher {
|
class CachedFetcher implements ImageFetcher {
|
||||||
private readonly _fetcher: ImageFetcher
|
private readonly _fetcher: ImageFetcher
|
||||||
private readonly _zoomlevel: number
|
private readonly _zoomlevel: number
|
||||||
private readonly cache: Map<number, Promise<P4CPicture[]>> = new Map<
|
private readonly cache: Map<number, Promise<(P4CPicture & { id: string })[]>> = new Map<
|
||||||
number,
|
number,
|
||||||
Promise<P4CPicture[]>
|
Promise<(P4CPicture & { id: string })[]>
|
||||||
>()
|
>()
|
||||||
public readonly name: string
|
public readonly name: string
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class CachedFetcher implements ImageFetcher {
|
||||||
this.name = fetcher.name
|
this.name = fetcher.name
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchImages(lat: number, lon: number): Promise<P4CPicture[]> {
|
fetchImages(lat: number, lon: number): Promise<(P4CPicture & { id: string })[]> {
|
||||||
const tile = Tiles.embedded_tile(lat, lon, this._zoomlevel)
|
const tile = Tiles.embedded_tile(lat, lon, this._zoomlevel)
|
||||||
const tileIndex = Tiles.tile_index(tile.z, tile.x, tile.y)
|
const tileIndex = Tiles.tile_index(tile.z, tile.x, tile.y)
|
||||||
if (this.cache.has(tileIndex)) {
|
if (this.cache.has(tileIndex)) {
|
||||||
|
@ -80,7 +80,7 @@ class NearbyImageUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
class P4CImageFetcher implements ImageFetcher {
|
class P4CImageFetcher implements ImageFetcher {
|
||||||
public static readonly services = ["mapillary", "flickr", "kartaview", "wikicommons"] as const
|
public static readonly services = ["flickr", "kartaview", "wikicommons"] as const
|
||||||
public static readonly apiUrls = ["https://api.flickr.com"]
|
public static readonly apiUrls = ["https://api.flickr.com"]
|
||||||
private _options: { maxDaysOld: number; searchRadius: number }
|
private _options: { maxDaysOld: number; searchRadius: number }
|
||||||
public readonly name: P4CService
|
public readonly name: P4CService
|
||||||
|
@ -90,7 +90,7 @@ class P4CImageFetcher implements ImageFetcher {
|
||||||
this._options = options
|
this._options = options
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchImages(lat: number, lon: number): Promise<P4CPicture[]> {
|
async fetchImages(lat: number, lon: number): Promise<(P4CPicture & { id: string })[]> {
|
||||||
const picManager = new P4C.PicturesManager({ usefetchers: [this.name] })
|
const picManager = new P4C.PicturesManager({ usefetchers: [this.name] })
|
||||||
const maxAgeSeconds = (this._options?.maxDaysOld ?? 3 * 365) * 24 * 60 * 60 * 1000
|
const maxAgeSeconds = (this._options?.maxDaysOld ?? 3 * 365) * 24 * 60 * 60 * 1000
|
||||||
const searchRadius = this._options?.searchRadius ?? 100
|
const searchRadius = this._options?.searchRadius ?? 100
|
||||||
|
@ -124,8 +124,8 @@ class ImagesInLoadedDataFetcher implements ImageFetcher {
|
||||||
this._searchRadius = searchRadius
|
this._searchRadius = searchRadius
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchImages(lat: number, lon: number): Promise<P4CPicture[]> {
|
async fetchImages(lat: number, lon: number): Promise<(P4CPicture & { id: string })[]> {
|
||||||
const foundImages: P4CPicture[] = []
|
const foundImages: (P4CPicture & { id: string })[] = []
|
||||||
this.indexedFeatures.features.data.forEach((feature) => {
|
this.indexedFeatures.features.data.forEach((feature) => {
|
||||||
const props = feature.properties
|
const props = feature.properties
|
||||||
const images = []
|
const images = []
|
||||||
|
@ -149,6 +149,7 @@ class ImagesInLoadedDataFetcher implements ImageFetcher {
|
||||||
foundImages.push({
|
foundImages.push({
|
||||||
pictureUrl: image,
|
pictureUrl: image,
|
||||||
thumbUrl: image,
|
thumbUrl: image,
|
||||||
|
id: image,
|
||||||
coordinates: { lng: centerpoint[0], lat: centerpoint[1] },
|
coordinates: { lng: centerpoint[0], lat: centerpoint[1] },
|
||||||
provider: "OpenStreetMap",
|
provider: "OpenStreetMap",
|
||||||
details: {
|
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
|
const [lng, lat] = imageData.geometry.coordinates
|
||||||
return {
|
return {
|
||||||
|
id: imageData.id,
|
||||||
pictureUrl: imageData.assets.sd.href,
|
pictureUrl: imageData.assets.sd.href,
|
||||||
coordinates: { lng, lat },
|
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 = [
|
const radiusSettings = [
|
||||||
{
|
{
|
||||||
place_fov_tolerance: 180,
|
place_fov_tolerance: 180,
|
||||||
|
@ -272,7 +274,7 @@ class MapillaryFetcher implements ImageFetcher {
|
||||||
this.end_captured_at = options?.end_captured_at
|
this.end_captured_at = options?.end_captured_at
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchImages(lat: number, lon: number): Promise<P4CPicture[]> {
|
async fetchImages(lat: number, lon: number): Promise<(P4CPicture & { id: string })[]> {
|
||||||
const boundingBox = new BBox([[lon, lat]]).padAbsolute(0.003)
|
const boundingBox = new BBox([[lon, lat]]).padAbsolute(0.003)
|
||||||
let url =
|
let url =
|
||||||
"https://graph.mapillary.com/images?fields=geometry,computed_geometry,creator,id,captured_at,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=" +
|
||||||
|
@ -313,7 +315,7 @@ class MapillaryFetcher implements ImageFetcher {
|
||||||
captured_at: number
|
captured_at: number
|
||||||
}[]
|
}[]
|
||||||
}>(url)
|
}>(url)
|
||||||
const pics: P4CPicture[] = []
|
const pics: (P4CPicture & { id: string })[] = []
|
||||||
for (const img of response.data) {
|
for (const img of response.data) {
|
||||||
const c = img.computed_geometry?.coordinates ?? img.geometry.coordinates
|
const c = img.computed_geometry?.coordinates ?? img.geometry.coordinates
|
||||||
if (img.thumb_original_url === undefined) {
|
if (img.thumb_original_url === undefined) {
|
||||||
|
@ -322,6 +324,7 @@ class MapillaryFetcher implements ImageFetcher {
|
||||||
const [lon, lat] = img.computed_geometry.coordinates
|
const [lon, lat] = img.computed_geometry.coordinates
|
||||||
pics.push({
|
pics.push({
|
||||||
pictureUrl: img.thumb_original_url,
|
pictureUrl: img.thumb_original_url,
|
||||||
|
id: img.id,
|
||||||
provider: "Mapillary",
|
provider: "Mapillary",
|
||||||
coordinates: { lng: c[0], lat: c[1] },
|
coordinates: { lng: c[0], lat: c[1] },
|
||||||
thumbUrl: img.thumb_256_url,
|
thumbUrl: img.thumb_256_url,
|
||||||
|
@ -371,7 +374,7 @@ export class CombinedFetcher {
|
||||||
start_captured_at: maxage,
|
start_captured_at: maxage,
|
||||||
panoramas: "no",
|
panoramas: "no",
|
||||||
}),
|
}),
|
||||||
new P4CImageFetcher("mapillary"),
|
// new P4CImageFetcher("mapillary"),
|
||||||
new P4CImageFetcher("wikicommons"),
|
new P4CImageFetcher("wikicommons"),
|
||||||
].map((f) => new CachedFetcher(f))
|
].map((f) => new CachedFetcher(f))
|
||||||
}
|
}
|
||||||
|
@ -411,7 +414,7 @@ export class CombinedFetcher {
|
||||||
lon: number,
|
lon: number,
|
||||||
lat: number
|
lat: number
|
||||||
): {
|
): {
|
||||||
images: Store<P4CPicture[]>
|
images: Store<(P4CPicture & { provider })[]>
|
||||||
state: Store<Record<string, "loading" | "done" | "error">>
|
state: Store<Record<string, "loading" | "done" | "error">>
|
||||||
} {
|
} {
|
||||||
const sink = new UIEventSource<P4CPicture[]>([])
|
const sink = new UIEventSource<P4CPicture[]>([])
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
import type { ProvidedImage } from "../../Logic/ImageProviders/ImageProvider"
|
import type { ProvidedImage } from "../../Logic/ImageProviders/ImageProvider"
|
||||||
import ImageAttribution from "./ImageAttribution.svelte"
|
import ImageAttribution from "./ImageAttribution.svelte"
|
||||||
import ImagePreview from "./ImagePreview.svelte"
|
import ImagePreview from "./ImagePreview.svelte"
|
||||||
import { DownloadIcon } from "@rgossiaux/svelte-heroicons/solid"
|
import { DownloadIcon, ExternalLinkIcon } from "@rgossiaux/svelte-heroicons/solid"
|
||||||
import { twMerge } from "tailwind-merge"
|
import { twMerge } from "tailwind-merge"
|
||||||
import { UIEventSource } from "../../Logic/UIEventSource"
|
import { UIEventSource } from "../../Logic/UIEventSource"
|
||||||
import Loading from "../Base/Loading.svelte"
|
import Loading from "../Base/Loading.svelte"
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
export let nearbyFeatures:
|
export let nearbyFeatures:
|
||||||
| Feature<Geometry, HotspotProperties>[]
|
| Feature<Geometry, HotspotProperties>[]
|
||||||
| Store<Feature<Geometry, HotspotProperties>[]> = []
|
| Store<Feature<Geometry, HotspotProperties>[]> = []
|
||||||
|
let visitUrl = image.provider?.visitUrl(image)
|
||||||
let isLoaded = new UIEventSource(false)
|
let isLoaded = new UIEventSource(false)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -39,22 +39,28 @@
|
||||||
|
|
||||||
{#if $$slots["dot-menu-actions"]}
|
{#if $$slots["dot-menu-actions"]}
|
||||||
<DotMenu dotsPosition="top-0 left-0" dotsSize="w-8 h-8" hideBackground>
|
<DotMenu dotsPosition="top-0 left-0" dotsSize="w-8 h-8" hideBackground>
|
||||||
<slot name="dot-menu-actions">
|
<slot name="dot-menu-actions" />
|
||||||
<button
|
<button
|
||||||
class="no-image-background pointer-events-auto flex items-center"
|
class="no-image-background pointer-events-auto flex items-center"
|
||||||
on:click={() => ImageProvider.offerImageAsDownload(image)}
|
on:click={() => ImageProvider.offerImageAsDownload(image)}
|
||||||
>
|
>
|
||||||
<DownloadIcon class="h-6 w-6 px-2 opacity-100" />
|
<DownloadIcon class="h-6 w-6 px-2 opacity-100" />
|
||||||
<Tr t={Translations.t.general.download.downloadImage} />
|
<Tr t={Translations.t.general.download.downloadImage} />
|
||||||
</button>
|
</button>
|
||||||
</slot>
|
|
||||||
|
{#if visitUrl !== undefined}
|
||||||
|
<a href={visitUrl} target="_blank" rel="noopener">
|
||||||
|
<ExternalLinkIcon class="w-6" />
|
||||||
|
<Tr t={Translations.t.image.openOnWebsite.Subs(image.provider)} />
|
||||||
|
</a>
|
||||||
|
{/if}
|
||||||
</DotMenu>
|
</DotMenu>
|
||||||
{/if}
|
{/if}
|
||||||
<div
|
<div
|
||||||
class="pointer-events-none absolute bottom-0 left-0 flex w-full flex-wrap items-end justify-between"
|
class="pointer-events-none absolute bottom-0 left-0 flex w-full flex-wrap items-end justify-between"
|
||||||
>
|
>
|
||||||
<div class="pointer-events-auto m-1 w-fit transition-colors duration-200">
|
<div class="pointer-events-auto m-1 w-fit transition-colors duration-200">
|
||||||
<ImageAttribution {image} attributionFormat="large" />
|
<ImageAttribution image={$image} attributionFormat="large" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<slot />
|
<slot />
|
||||||
|
|
|
@ -3,24 +3,22 @@
|
||||||
* The image preview allows to drag and zoom in to the image
|
* The image preview allows to drag and zoom in to the image
|
||||||
*/
|
*/
|
||||||
import panzoom from "panzoom"
|
import panzoom from "panzoom"
|
||||||
import type { HotspotProperties, ProvidedImage } from "../../Logic/ImageProviders/ImageProvider"
|
import type { HotspotProperties, PanoramaView, ProvidedImage } from "../../Logic/ImageProviders/ImageProvider"
|
||||||
import { UIEventSource } from "../../Logic/UIEventSource"
|
import ImageProvider from "../../Logic/ImageProviders/ImageProvider"
|
||||||
|
import { Store, UIEventSource } from "../../Logic/UIEventSource"
|
||||||
import Zoomcontrol from "../Zoomcontrol"
|
import Zoomcontrol from "../Zoomcontrol"
|
||||||
import { onDestroy } from "svelte"
|
import { onDestroy } from "svelte"
|
||||||
import type { PanoramaView } from "../../Logic/ImageProviders/ImageProvider"
|
|
||||||
import { PhotoSphereViewerWrapper } from "./photoSphereViewerWrapper"
|
import { PhotoSphereViewerWrapper } from "./photoSphereViewerWrapper"
|
||||||
|
|
||||||
import type { Feature, Geometry, Point } from "geojson"
|
import type { Feature, Geometry, Point } from "geojson"
|
||||||
import { Store } from "../../Logic/UIEventSource"
|
import AllImageProviders from "../../Logic/ImageProviders/AllImageProviders"
|
||||||
|
|
||||||
export let nearbyFeatures:
|
export let nearbyFeatures:
|
||||||
| Feature<Geometry, HotspotProperties>[]
|
| Feature<Geometry, HotspotProperties>[]
|
||||||
| Store<Feature<Geometry, HotspotProperties>[]> = []
|
| Store<Feature<Geometry, HotspotProperties>[]> = []
|
||||||
export let image: Partial<ProvidedImage>
|
export let image: Partial<ProvidedImage> & { url: string, id: string }
|
||||||
let panzoomInstance = undefined
|
let panzoomInstance = undefined
|
||||||
let panzoomEl: HTMLElement
|
let panzoomEl: HTMLElement
|
||||||
let viewerEl: HTMLElement
|
let viewerEl: HTMLElement
|
||||||
|
|
||||||
export let isLoaded: UIEventSource<boolean> = undefined
|
export let isLoaded: UIEventSource<boolean> = undefined
|
||||||
|
|
||||||
onDestroy(Zoomcontrol.createLock())
|
onDestroy(Zoomcontrol.createLock())
|
||||||
|
@ -32,10 +30,20 @@
|
||||||
async function initPhotosphere() {
|
async function initPhotosphere() {
|
||||||
const imageInfo: Feature<Point, PanoramaView> = await image.provider.getPanoramaInfo(image)
|
const imageInfo: Feature<Point, PanoramaView> = await image.provider.getPanoramaInfo(image)
|
||||||
if (imageInfo === undefined) {
|
if (imageInfo === undefined) {
|
||||||
console.error("Image info is apperently undefined for", image)
|
console.error("Image info is apparently undefined for", image)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const viewer = new PhotoSphereViewerWrapper(viewerEl, imageInfo)
|
const viewer = new PhotoSphereViewerWrapper(viewerEl, imageInfo)
|
||||||
|
viewer.imageInfo.addCallbackAndRunD(panoramaInfo => {
|
||||||
|
let provider: ImageProvider
|
||||||
|
if (typeof panoramaInfo.properties.provider === "string") {
|
||||||
|
provider = AllImageProviders.byName(panoramaInfo.properties.provider)
|
||||||
|
} else {
|
||||||
|
provider = panoramaInfo.properties.provider
|
||||||
|
}
|
||||||
|
console.log(">>> Got:", panoramaInfo, "by", provider.name)
|
||||||
|
//actuallyDisplayed.set(image.properties.imageMeta)
|
||||||
|
})
|
||||||
if (Array.isArray(nearbyFeatures)) {
|
if (Array.isArray(nearbyFeatures)) {
|
||||||
viewer.setNearbyFeatures(nearbyFeatures)
|
viewer.setNearbyFeatures(nearbyFeatures)
|
||||||
} else {
|
} else {
|
||||||
|
@ -77,5 +85,6 @@
|
||||||
isLoaded?.setData(true)
|
isLoaded?.setData(true)
|
||||||
}}
|
}}
|
||||||
src={image.url_hd ?? image.url}
|
src={image.url_hd ?? image.url}
|
||||||
|
alt=""
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -7,10 +7,10 @@
|
||||||
import LinkImageAction from "../../Logic/Osm/Actions/LinkImageAction"
|
import LinkImageAction from "../../Logic/Osm/Actions/LinkImageAction"
|
||||||
import ChangeTagAction from "../../Logic/Osm/Actions/ChangeTagAction"
|
import ChangeTagAction from "../../Logic/Osm/Actions/ChangeTagAction"
|
||||||
import { Tag } from "../../Logic/Tags/Tag"
|
import { Tag } from "../../Logic/Tags/Tag"
|
||||||
import type { Feature } from "geojson"
|
import type { Feature, Point } from "geojson"
|
||||||
import Translations from "../i18n/Translations"
|
import Translations from "../i18n/Translations"
|
||||||
import LayerConfig from "../../Models/ThemeConfig/LayerConfig"
|
import LayerConfig from "../../Models/ThemeConfig/LayerConfig"
|
||||||
import type { ProvidedImage } from "../../Logic/ImageProviders/ImageProvider"
|
import type { HotspotProperties, ProvidedImage } from "../../Logic/ImageProviders/ImageProvider"
|
||||||
import AttributedImage from "./AttributedImage.svelte"
|
import AttributedImage from "./AttributedImage.svelte"
|
||||||
import SpecialTranslation from "../Popup/TagRendering/SpecialTranslation.svelte"
|
import SpecialTranslation from "../Popup/TagRendering/SpecialTranslation.svelte"
|
||||||
import LoginToggle from "../Base/LoginToggle.svelte"
|
import LoginToggle from "../Base/LoginToggle.svelte"
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
|
|
||||||
export let highlighted: UIEventSource<string> = undefined
|
export let highlighted: UIEventSource<string> = undefined
|
||||||
export let nearbyFeatures: Feature[] | Store<Feature[]> = []
|
export let nearbyFeatures: Feature<Point, HotspotProperties>[] | Store<Feature<Point, HotspotProperties>[]> = []
|
||||||
export let linkable = true
|
export let linkable = true
|
||||||
let targetValue = Object.values(image.osmTags)[0]
|
let targetValue = Object.values(image.osmTags)[0]
|
||||||
let isLinked = new UIEventSource(Object.values(tags.data).some((v) => targetValue === v))
|
let isLinked = new UIEventSource(Object.values(tags.data).some((v) => targetValue === v))
|
||||||
|
|
|
@ -68,6 +68,7 @@
|
||||||
northOffset: p4c.direction,
|
northOffset: p4c.direction,
|
||||||
rotation: p4c.direction,
|
rotation: p4c.direction,
|
||||||
spherical: p4c.details.isSpherical ? "yes" : "no",
|
spherical: p4c.details.isSpherical ? "yes" : "no",
|
||||||
|
provider: p4c.provider
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,18 +3,26 @@ import "pannellum"
|
||||||
import { Feature, Geometry, Point } from "geojson"
|
import { Feature, Geometry, Point } from "geojson"
|
||||||
import { GeoOperations } from "../../Logic/GeoOperations"
|
import { GeoOperations } from "../../Logic/GeoOperations"
|
||||||
import { HotspotProperties, PanoramaView } from "../../Logic/ImageProviders/ImageProvider"
|
import { HotspotProperties, PanoramaView } from "../../Logic/ImageProviders/ImageProvider"
|
||||||
|
import { Store, UIEventSource } from "../../Logic/UIEventSource"
|
||||||
|
|
||||||
export class PhotoSphereViewerWrapper {
|
export class PhotoSphereViewerWrapper {
|
||||||
private imageInfo: Feature<Point, PanoramaView>
|
private _imageInfo: UIEventSource<NonNullable<Feature<Point, PanoramaView>>> = new UIEventSource(undefined)
|
||||||
|
public imageInfo: Store<NonNullable<Feature<Point, PanoramaView>>> = this._imageInfo
|
||||||
private readonly viewer: Pannellum.Viewer
|
private readonly viewer: Pannellum.Viewer
|
||||||
private nearbyFeatures: Feature<Geometry, HotspotProperties>[] = []
|
private nearbyFeatures: Feature<Geometry, HotspotProperties>[] = []
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param container The HTML-element to bind to
|
||||||
|
* @param imageInfo An eventSource containing the panorama-info. Might be changed by this component if walking around;
|
||||||
|
* @param nearbyFeatures Nearby features to show a point about, e.g. to walk around
|
||||||
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
container: HTMLElement,
|
container: HTMLElement,
|
||||||
imageInfo: Feature<Point, PanoramaView>,
|
imageInfo: Feature<Point, PanoramaView>,
|
||||||
nearbyFeatures?: Feature<Geometry, HotspotProperties>[]
|
nearbyFeatures?: Feature<Geometry, HotspotProperties>[]
|
||||||
) {
|
) {
|
||||||
this.imageInfo = imageInfo
|
this._imageInfo.set(imageInfo)
|
||||||
this.viewer = pannellum.viewer(container, <any>{
|
this.viewer = pannellum.viewer(container, <any>{
|
||||||
default: {
|
default: {
|
||||||
firstScene: imageInfo.properties.url,
|
firstScene: imageInfo.properties.url,
|
||||||
|
@ -31,16 +39,17 @@ export class PhotoSphereViewerWrapper {
|
||||||
compass: true,
|
compass: true,
|
||||||
showControls: false,
|
showControls: false,
|
||||||
northOffset: imageInfo.properties.northOffset,
|
northOffset: imageInfo.properties.northOffset,
|
||||||
horizonPitch: imageInfo.properties.pitchOffset,
|
horizonPitch: imageInfo.properties.pitchOffset
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
this.setNearbyFeatures(nearbyFeatures)
|
this.setNearbyFeatures(nearbyFeatures)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public calculatePitch(feature: Feature): number {
|
public calculatePitch(feature: Feature): number {
|
||||||
const coors = this.imageInfo.geometry.coordinates
|
const coors = this.imageInfo.data.geometry.coordinates
|
||||||
const distance = GeoOperations.distanceBetween(
|
const distance = GeoOperations.distanceBetween(
|
||||||
coors,
|
coors,
|
||||||
GeoOperations.centerpointCoordinates(feature)
|
GeoOperations.centerpointCoordinates(feature)
|
||||||
|
@ -72,7 +81,6 @@ export class PhotoSphereViewerWrapper {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.clearHotspots()
|
this.clearHotspots()
|
||||||
this.imageInfo = imageInfo
|
|
||||||
this.viewer.addScene(imageInfo.properties.url, <any>{
|
this.viewer.addScene(imageInfo.properties.url, <any>{
|
||||||
panorama: imageInfo.properties.url,
|
panorama: imageInfo.properties.url,
|
||||||
northOffset: imageInfo.properties.northOffset,
|
northOffset: imageInfo.properties.northOffset,
|
||||||
|
@ -82,27 +90,29 @@ export class PhotoSphereViewerWrapper {
|
||||||
|
|
||||||
this.viewer.loadScene(imageInfo.properties.url, 0, imageInfo.properties.northOffset)
|
this.viewer.loadScene(imageInfo.properties.url, 0, imageInfo.properties.northOffset)
|
||||||
this.setNearbyFeatures(this.nearbyFeatures)
|
this.setNearbyFeatures(this.nearbyFeatures)
|
||||||
|
this._imageInfo.set(imageInfo)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private clearHotspots() {
|
private clearHotspots() {
|
||||||
const hotspots =
|
const currentUrl = this.imageInfo.data.properties.url
|
||||||
this.viewer.getConfig()["scenes"][this.imageInfo.properties.url].hotSpots ?? []
|
const hotspots = this.viewer.getConfig()["scenes"][currentUrl].hotSpots ?? []
|
||||||
for (const hotspot of hotspots) {
|
for (const hotspot of hotspots) {
|
||||||
this.viewer.removeHotSpot(hotspot?.id, this.imageInfo.properties.url)
|
this.viewer.removeHotSpot(hotspot?.id, currentUrl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public setNearbyFeatures(nearbyFeatures: Feature<Geometry, HotspotProperties>[]) {
|
public setNearbyFeatures(nearbyFeatures: Feature<Geometry, HotspotProperties>[]) {
|
||||||
const imageInfo = this.imageInfo
|
const imageInfo = this.imageInfo.data
|
||||||
if (!this.imageInfo) {
|
if (!this.imageInfo) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const northOffs = imageInfo.properties.northOffset
|
const northOffs = imageInfo.properties.northOffset
|
||||||
this.nearbyFeatures = nearbyFeatures
|
this.nearbyFeatures = nearbyFeatures
|
||||||
this.clearHotspots()
|
this.clearHotspots()
|
||||||
const centralImageLocation = this.imageInfo.geometry.coordinates
|
const centralImageLocation = imageInfo.geometry.coordinates
|
||||||
for (const f of nearbyFeatures ?? []) {
|
for (const f of nearbyFeatures ?? []) {
|
||||||
if (f.properties.gotoPanorama?.properties?.url === this.imageInfo.properties.url) {
|
if (f.properties.gotoPanorama?.properties?.url === imageInfo.properties.url) {
|
||||||
continue // This is the current panorama, no need to show it
|
continue // This is the current panorama, no need to show it
|
||||||
}
|
}
|
||||||
const yaw = GeoOperations.bearing(imageInfo, GeoOperations.centerpoint(f))
|
const yaw = GeoOperations.bearing(imageInfo, GeoOperations.centerpoint(f))
|
||||||
|
@ -128,7 +138,7 @@ export class PhotoSphereViewerWrapper {
|
||||||
this.setPanorama(f.properties.gotoPanorama)
|
this.setPanorama(f.properties.gotoPanorama)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
this.imageInfo.properties.url
|
imageInfo.properties.url
|
||||||
)
|
)
|
||||||
if (f.properties.focus) {
|
if (f.properties.focus) {
|
||||||
this.viewer.setYaw(yaw - northOffs)
|
this.viewer.setYaw(yaw - northOffs)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue