Merge develop

This commit is contained in:
Pieter Vander Vennet 2024-09-17 02:36:38 +02:00
commit 5a9f8f0a0a
62 changed files with 4448 additions and 710 deletions

View file

@ -9,7 +9,14 @@ export interface ProvidedImage {
key: string
provider: ImageProvider
id: string
date?: Date
date?: Date,
/**
* Compass angle of the taken image
* 0 = north, 90° = East
*/
rotation?: number
lat?: number,
lon?: number
}
export default abstract class ImageProvider {

View file

@ -162,12 +162,14 @@ export class Mapillary extends ImageProvider {
const metadataUrl =
"https://graph.mapillary.com/" +
mapillaryId +
"?fields=thumb_1024_url,thumb_original_url,captured_at,creator&access_token=" +
"?fields=thumb_1024_url,thumb_original_url,captured_at,compass_angle,geometry,creator&access_token=" +
Constants.mapillary_client_token_v4
const response = await Utils.downloadJsonCached(metadataUrl, 60 * 60)
const url = <string>response["thumb_1024_url"]
const url_hd = <string>response["thumb_original_url"]
const date = new Date()
const rotation = (720 - Number(response["compass_angle"])) % 360
const geometry = response["geometry"]
date.setTime(response["captured_at"])
return <ProvidedImage>{
id: "" + mapillaryId,
@ -176,6 +178,9 @@ export class Mapillary extends ImageProvider {
provider: this,
date,
key,
rotation,
lat: geometry.coordinates[1],
lon: geometry.coordinates[0]
}
}
}

View file

@ -4,11 +4,14 @@ import { WikimediaImageProvider } from "./WikimediaImageProvider"
import Wikidata from "../Web/Wikidata"
import SvelteUIElement from "../../UI/Base/SvelteUIElement"
import * as Wikidata_icon from "../../assets/svg/Wikidata.svelte"
import { Utils } from "../../Utils"
export class WikidataImageProvider extends ImageProvider {
public static readonly singleton = new WikidataImageProvider()
public readonly defaultKeyPrefixes = ["wikidata"]
public readonly name = "Wikidata"
private static readonly keyBlacklist: ReadonlySet<string> = new Set(
["mapillary", ...Utils.Times(i => "mapillary:" + i, 10)])
private constructor() {
super()
@ -23,6 +26,9 @@ export class WikidataImageProvider extends ImageProvider {
}
public async ExtractUrls(key: string, value: string): Promise<Promise<ProvidedImage>[]> {
if (WikidataImageProvider.keyBlacklist.has(key)) {
return []
}
const entity = await Wikidata.LoadWikidataEntryAsync(value)
if (entity === undefined) {
return []

View file

@ -164,6 +164,8 @@ export default class UserRelatedState {
"button" | "button_click_right" | "button_click" | "click" | "click_right"
>("button_click_right")
public readonly showScale : UIEventSource<boolean>
/**
* Preferences as tags exposes many preferences and state properties as record.
* This is used to bridge the internal state with the usersettings.json layerconfig file
@ -209,6 +211,7 @@ export default class UserRelatedState {
"preferences-add-new-mode",
"button_click_right",
)
this.showScale = UIEventSource.asBoolean(this.osmConnection.GetPreference("preference-show-scale","false"))
this.imageLicense = this.osmConnection.getPreference("pictures-license", "CC0")
this.installedUserThemes = UserRelatedState.initInstalledUserThemes(osmConnection)

View file

@ -56,7 +56,7 @@ export interface P4CPicture {
author?
license?
detailsUrl?: string
direction?
direction?: number,
osmTags?: object /*To copy straight into OSM!*/
thumbUrl: string
details: {