Add mapillary and other nearby images preview

This commit is contained in:
Pieter Vander Vennet 2022-06-03 01:33:41 +02:00
parent fc0afbcc18
commit 44223d0f1c
12 changed files with 418 additions and 130 deletions

View file

@ -2,6 +2,7 @@
* Keeps track of a dictionary 'elementID' -> UIEventSource<tags>
*/
import {UIEventSource} from "./UIEventSource";
import {GeoJSONObject} from "@turf/turf";
export class ElementStorage {

View file

@ -3,6 +3,7 @@ import {BBox} from "./BBox";
import togpx from "togpx"
import Constants from "../Models/Constants";
import LayerConfig from "../Models/ThemeConfig/LayerConfig";
import {Coord} from "@turf/turf";
export class GeoOperations {
@ -729,6 +730,12 @@ export class GeoOperations {
}
/**
* Takes two points and finds the geographic bearing between them, i.e. the angle measured in degrees from the north line (0 degrees)
*/
public static bearing(a: Coord, b: Coord): number {
return turf.bearing(a, b)
}
}

View file

@ -26,7 +26,6 @@ export class Mapillary extends ImageProvider {
return true
}
try {
console.log("COmparing",a,b)
const aUrl = new URL(a)
const bUrl = new URL(b)
if (aUrl.host !== bUrl.host || aUrl.pathname !== bUrl.pathname) {
@ -46,7 +45,7 @@ console.log("COmparing",a,b)
return allSame;
} catch (e) {
Console.debug("Could not compare ", a, "and", b, "due to", e)
console.debug("Could not compare ", a, "and", b, "due to", e)
}
return false;

View file

@ -122,8 +122,8 @@ export class OsmConnection {
return new ChangesetHandler(this._dryRun, this, allElements, changes, this.auth);
}
public GetPreference(key: string, prefix: string = "mapcomplete-"): UIEventSource<string> {
return this.preferencesHandler.GetPreference(key, prefix);
public GetPreference(key: string, defaultValue: string = undefined, prefix: string = "mapcomplete-"): UIEventSource<string> {
return this.preferencesHandler.GetPreference(key, defaultValue, prefix);
}
public GetLongPreference(key: string, prefix: string = "mapcomplete-"): UIEventSource<string> {

View file

@ -106,7 +106,7 @@ export class OsmPreferences {
return source;
}
public GetPreference(key: string, prefix: string = "mapcomplete-"): UIEventSource<string> {
public GetPreference(key: string, defaultValue : string = undefined, prefix: string = "mapcomplete-"): UIEventSource<string> {
key = prefix + key;
key = key.replace(/[:\\\/"' {}.%]/g, '')
if (key.length >= 255) {
@ -120,7 +120,7 @@ export class OsmPreferences {
this.UpdatePreferences();
}
const pref = new UIEventSource<string>(this.preferences.data[key], "osm-preference:" + key);
const pref = new UIEventSource<string>(this.preferences.data[key] ?? defaultValue, "osm-preference:" + key);
pref.addCallback((v) => {
this.UploadPreference(key, v);
});