forked from MapComplete/MapComplete
Merge master
This commit is contained in:
commit
c3041af5f7
50 changed files with 2313 additions and 1152 deletions
|
@ -55,10 +55,14 @@ export class NewGeometryFromChangesFeatureSource implements WritableFeatureSourc
|
|||
* @private
|
||||
*/
|
||||
private handleChange(change: ChangeDescription): boolean {
|
||||
const backend = this._backend
|
||||
const allElementStorage = this._allElementStorage
|
||||
if (change.changes === undefined) {
|
||||
// The geometry is not described - not a new point or geometry change, but probably a tagchange to a newly created point
|
||||
// Not something that should be handled here
|
||||
return false
|
||||
}
|
||||
|
||||
console.log("Handling pending change")
|
||||
const allElementStorage = this._allElementStorage
|
||||
console.log("Handling pending change", change)
|
||||
if (change.id > 0) {
|
||||
// This is an already existing object
|
||||
// In _most_ of the cases, this means that this _isn't_ a new object
|
||||
|
@ -86,10 +90,6 @@ export class NewGeometryFromChangesFeatureSource implements WritableFeatureSourc
|
|||
this._featureProperties.trackFeature(feature)
|
||||
this.addNewFeature(feature)
|
||||
return true
|
||||
} else if (change.changes === undefined) {
|
||||
// The geometry is not described - not a new point or geometry change, but probably a tagchange to a newly created point
|
||||
// Not something that should be handled here
|
||||
return false
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -151,7 +151,7 @@ export class NewGeometryFromChangesFeatureSource implements WritableFeatureSourc
|
|||
continue
|
||||
}
|
||||
|
||||
somethingChanged ||= this.handleChange(change)
|
||||
somethingChanged = this.handleChange(change) || somethingChanged // important: _first_ evaluate the method, to avoid shortcutting
|
||||
}
|
||||
if (somethingChanged) {
|
||||
this.features.ping()
|
||||
|
|
|
@ -525,11 +525,14 @@ export class Changes {
|
|||
pending = pending.map((ch) => ChangeDescriptionTools.rewriteIds(ch, remappings))
|
||||
console.log("Result is", pending)
|
||||
}
|
||||
|
||||
const changes: {
|
||||
newObjects: OsmObject[]
|
||||
modifiedObjects: OsmObject[]
|
||||
deletedObjects: OsmObject[]
|
||||
} = self.CreateChangesetObjects(pending, objects)
|
||||
|
||||
|
||||
return Changes.createChangesetFor("" + csId, changes)
|
||||
},
|
||||
metatags,
|
||||
|
@ -558,19 +561,8 @@ export class Changes {
|
|||
const successes = await Promise.all(
|
||||
Array.from(pendingPerTheme, async ([theme, pendingChanges]) => {
|
||||
try {
|
||||
const openChangeset = this.state.osmConnection
|
||||
.GetPreference("current-open-changeset-" + theme)
|
||||
.sync(
|
||||
(str) => {
|
||||
const n = Number(str)
|
||||
if (isNaN(n)) {
|
||||
return undefined
|
||||
}
|
||||
return n
|
||||
},
|
||||
[],
|
||||
(n) => "" + n
|
||||
)
|
||||
const openChangeset = UIEventSource.asInt(this.state.osmConnection
|
||||
.GetPreference("current-open-changeset-" + theme))
|
||||
console.log(
|
||||
"Using current-open-changeset-" +
|
||||
theme +
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
import { UIEventSource } from "../UIEventSource"
|
||||
import UserDetails, { OsmConnection } from "./OsmConnection"
|
||||
import { Utils } from "../../Utils"
|
||||
import { LocalStorageSource } from "../Web/LocalStorageSource";
|
||||
|
||||
export class OsmPreferences {
|
||||
public preferences = new UIEventSource<Record<string, string>>({}, "all-osm-preferences")
|
||||
/**
|
||||
* A dictionary containing all the preferences. The 'preferenceSources' will be initialized from this
|
||||
* We keep a local copy of them, to init mapcomplete with the previous choices and to be able to get the open changesets right away
|
||||
*/
|
||||
public preferences = LocalStorageSource.GetParsed<Record<string, string>>( "all-osm-preferences", {})
|
||||
private readonly preferenceSources = new Map<string, UIEventSource<string>>()
|
||||
private auth: any
|
||||
private userDetails: UIEventSource<UserDetails>
|
||||
|
|
|
@ -165,7 +165,7 @@ export default class FeatureSwitchState extends OsmConnectionFeatureSwitches {
|
|||
(urls) => urls?.join(",")
|
||||
)
|
||||
|
||||
this.overpassTimeout = UIEventSource.asFloat(
|
||||
this.overpassTimeout = UIEventSource.asInt(
|
||||
QueryParameters.GetQueryParameter(
|
||||
"overpassTimeout",
|
||||
"" + layoutToUse?.overpassTimeout,
|
||||
|
@ -181,7 +181,7 @@ export default class FeatureSwitchState extends OsmConnectionFeatureSwitches {
|
|||
)
|
||||
)
|
||||
|
||||
this.osmApiTileSize = UIEventSource.asFloat(
|
||||
this.osmApiTileSize = UIEventSource.asInt(
|
||||
QueryParameters.GetQueryParameter(
|
||||
"osmApiTileSize",
|
||||
"" + layoutToUse?.osmApiTileSize,
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
import { Utils } from "../Utils"
|
||||
import { Readable, Subscriber, Unsubscriber, Updater, Writable } from "svelte/store"
|
||||
import { Utils } from "../Utils";
|
||||
import { Readable, Subscriber, Unsubscriber, Updater, Writable } from "svelte/store";
|
||||
|
||||
/**
|
||||
* Various static utils
|
||||
*/
|
||||
export class Stores {
|
||||
public static Chronic(millis: number, asLong: () => boolean = undefined): Store<Date> {
|
||||
const source = new UIEventSource<Date>(undefined)
|
||||
const source = new UIEventSource<Date>(undefined);
|
||||
|
||||
function run() {
|
||||
source.setData(new Date())
|
||||
source.setData(new Date());
|
||||
if (asLong === undefined || asLong()) {
|
||||
window.setTimeout(run, millis)
|
||||
window.setTimeout(run, millis);
|
||||
}
|
||||
}
|
||||
|
||||
run()
|
||||
return source
|
||||
run();
|
||||
return source;
|
||||
}
|
||||
|
||||
public static FromPromiseWithErr<T>(
|
||||
promise: Promise<T>
|
||||
): Store<{ success: T } | { error: any }> {
|
||||
return UIEventSource.FromPromiseWithErr(promise)
|
||||
return UIEventSource.FromPromiseWithErr(promise);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,14 +32,14 @@ export class Stores {
|
|||
* @constructor
|
||||
*/
|
||||
public static FromPromise<T>(promise: Promise<T>): Store<T> {
|
||||
const src = new UIEventSource<T>(undefined)
|
||||
promise?.then((d) => src.setData(d))
|
||||
promise?.catch((err) => console.warn("Promise failed:", err))
|
||||
return src
|
||||
const src = new UIEventSource<T>(undefined);
|
||||
promise?.then((d) => src.setData(d));
|
||||
promise?.catch((err) => console.warn("Promise failed:", err));
|
||||
return src;
|
||||
}
|
||||
|
||||
public static flatten<X>(source: Store<Store<X>>, possibleSources?: Store<any>[]): Store<X> {
|
||||
return UIEventSource.flatten(source, possibleSources)
|
||||
return UIEventSource.flatten(source, possibleSources);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -57,39 +57,39 @@ export class Stores {
|
|||
* @constructor
|
||||
*/
|
||||
public static ListStabilized<T>(src: Store<T[]>): Store<T[]> {
|
||||
const stable = new UIEventSource<T[]>(undefined)
|
||||
const stable = new UIEventSource<T[]>(undefined);
|
||||
src.addCallbackAndRun((list) => {
|
||||
if (list === undefined) {
|
||||
stable.setData(undefined)
|
||||
return
|
||||
stable.setData(undefined);
|
||||
return;
|
||||
}
|
||||
if (Utils.sameList(stable.data, list)) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
stable.setData(list)
|
||||
})
|
||||
return stable
|
||||
stable.setData(list);
|
||||
});
|
||||
return stable;
|
||||
}
|
||||
}
|
||||
|
||||
export abstract class Store<T> implements Readable<T> {
|
||||
abstract readonly data: T
|
||||
abstract readonly data: T;
|
||||
|
||||
/**
|
||||
* Optional value giving a title to the UIEventSource, mainly used for debugging
|
||||
*/
|
||||
public readonly tag: string | undefined
|
||||
public readonly tag: string | undefined;
|
||||
|
||||
constructor(tag: string = undefined) {
|
||||
this.tag = tag
|
||||
this.tag = tag;
|
||||
if (tag === undefined || tag === "") {
|
||||
let createStack = Utils.runningFromConsole
|
||||
let createStack = Utils.runningFromConsole;
|
||||
if (!Utils.runningFromConsole) {
|
||||
createStack = window.location.hostname === "127.0.0.1"
|
||||
createStack = window.location.hostname === "127.0.0.1";
|
||||
}
|
||||
if (createStack) {
|
||||
const callstack = new Error().stack.split("\n")
|
||||
this.tag = callstack[1]
|
||||
const callstack = new Error().stack.split("\n");
|
||||
this.tag = callstack[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -100,13 +100,13 @@ export abstract class Store<T> implements Readable<T> {
|
|||
public mapD<J>(f: (t: T) => J, extraStoresToWatch?: Store<any>[]): Store<J> {
|
||||
return this.map((t) => {
|
||||
if (t === undefined) {
|
||||
return undefined
|
||||
return undefined;
|
||||
}
|
||||
if (t === null) {
|
||||
return null
|
||||
return null;
|
||||
}
|
||||
return f(t)
|
||||
}, extraStoresToWatch)
|
||||
return f(t);
|
||||
}, extraStoresToWatch);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -135,17 +135,17 @@ export abstract class Store<T> implements Readable<T> {
|
|||
public withEqualityStabilized(
|
||||
comparator: (t: T | undefined, t1: T | undefined) => boolean
|
||||
): Store<T> {
|
||||
let oldValue = undefined
|
||||
let oldValue = undefined;
|
||||
return this.map((v) => {
|
||||
if (v == oldValue) {
|
||||
return oldValue
|
||||
return oldValue;
|
||||
}
|
||||
if (comparator(oldValue, v)) {
|
||||
return oldValue
|
||||
return oldValue;
|
||||
}
|
||||
oldValue = v
|
||||
return v
|
||||
})
|
||||
oldValue = v;
|
||||
return v;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -195,49 +195,49 @@ export abstract class Store<T> implements Readable<T> {
|
|||
* lastValue // => "def"
|
||||
*/
|
||||
public bind<X>(f: (t: T) => Store<X>): Store<X> {
|
||||
const mapped = this.map(f)
|
||||
const sink = new UIEventSource<X>(undefined)
|
||||
const seenEventSources = new Set<Store<X>>()
|
||||
const mapped = this.map(f);
|
||||
const sink = new UIEventSource<X>(undefined);
|
||||
const seenEventSources = new Set<Store<X>>();
|
||||
mapped.addCallbackAndRun((newEventSource) => {
|
||||
if (newEventSource === null) {
|
||||
sink.setData(null)
|
||||
sink.setData(null);
|
||||
} else if (newEventSource === undefined) {
|
||||
sink.setData(undefined)
|
||||
sink.setData(undefined);
|
||||
} else if (!seenEventSources.has(newEventSource)) {
|
||||
seenEventSources.add(newEventSource)
|
||||
seenEventSources.add(newEventSource);
|
||||
newEventSource.addCallbackAndRun((resultData) => {
|
||||
if (mapped.data === newEventSource) {
|
||||
sink.setData(resultData)
|
||||
sink.setData(resultData);
|
||||
}
|
||||
})
|
||||
});
|
||||
} else {
|
||||
// Already seen, so we don't have to add a callback, just update the value
|
||||
sink.setData(newEventSource.data)
|
||||
sink.setData(newEventSource.data);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
return sink
|
||||
return sink;
|
||||
}
|
||||
|
||||
public stabilized(millisToStabilize): Store<T> {
|
||||
if (Utils.runningFromConsole) {
|
||||
return this
|
||||
return this;
|
||||
}
|
||||
|
||||
const newSource = new UIEventSource<T>(this.data)
|
||||
const newSource = new UIEventSource<T>(this.data);
|
||||
|
||||
const self = this
|
||||
const self = this;
|
||||
this.addCallback((latestData) => {
|
||||
window.setTimeout(() => {
|
||||
if (self.data == latestData) {
|
||||
// compare by reference.
|
||||
// Note that 'latestData' and 'self.data' are both from the same UIEVentSource, but both are dereferenced at a different time
|
||||
newSource.setData(latestData)
|
||||
newSource.setData(latestData);
|
||||
}
|
||||
}, millisToStabilize)
|
||||
})
|
||||
}, millisToStabilize);
|
||||
});
|
||||
|
||||
return newSource
|
||||
return newSource;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -247,23 +247,23 @@ export abstract class Store<T> implements Readable<T> {
|
|||
* @constructor
|
||||
*/
|
||||
public AsPromise(condition?: (t: T) => boolean): Promise<T> {
|
||||
const self = this
|
||||
condition = condition ?? ((t) => t !== undefined)
|
||||
const self = this;
|
||||
condition = condition ?? ((t) => t !== undefined);
|
||||
return new Promise((resolve) => {
|
||||
const data = self.data
|
||||
const data = self.data;
|
||||
if (condition(data)) {
|
||||
resolve(data)
|
||||
resolve(data);
|
||||
} else {
|
||||
self.addCallbackD((data) => {
|
||||
if (condition(data)) {
|
||||
resolve(data)
|
||||
return true // return true to unregister as we only need to be called once
|
||||
resolve(data);
|
||||
return true; // return true to unregister as we only need to be called once
|
||||
} else {
|
||||
return false // We didn't resolve yet, wait for the next ping
|
||||
return false; // We didn't resolve yet, wait for the next ping
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -275,50 +275,51 @@ export abstract class Store<T> implements Readable<T> {
|
|||
|
||||
// Note: run is wrapped in an anonymous function. 'Run' returns the value. If this value happens to be true, it would unsubscribe
|
||||
return this.addCallbackAndRun((v) => {
|
||||
run(v)
|
||||
})
|
||||
run(v);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class ImmutableStore<T> extends Store<T> {
|
||||
public readonly data: T
|
||||
public readonly data: T;
|
||||
|
||||
constructor(data: T) {
|
||||
super()
|
||||
this.data = data
|
||||
super();
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
private static readonly pass: () => void = () => {}
|
||||
private static readonly pass: () => void = () => {
|
||||
};
|
||||
|
||||
addCallback(_: (data: T) => void): () => void {
|
||||
// pass: data will never change
|
||||
return ImmutableStore.pass
|
||||
return ImmutableStore.pass;
|
||||
}
|
||||
|
||||
addCallbackAndRun(callback: (data: T) => void): () => void {
|
||||
callback(this.data)
|
||||
callback(this.data);
|
||||
// no callback registry: data will never change
|
||||
return ImmutableStore.pass
|
||||
return ImmutableStore.pass;
|
||||
}
|
||||
|
||||
addCallbackAndRunD(callback: (data: T) => void): () => void {
|
||||
if (this.data !== undefined) {
|
||||
callback(this.data)
|
||||
callback(this.data);
|
||||
}
|
||||
// no callback registry: data will never change
|
||||
return ImmutableStore.pass
|
||||
return ImmutableStore.pass;
|
||||
}
|
||||
|
||||
addCallbackD(_: (data: T) => void): () => void {
|
||||
// pass: data will never change
|
||||
return ImmutableStore.pass
|
||||
return ImmutableStore.pass;
|
||||
}
|
||||
|
||||
map<J>(f: (t: T) => J, extraStores: Store<any>[] = undefined): ImmutableStore<J> {
|
||||
if (extraStores?.length > 0) {
|
||||
return new MappedStore(this, f, extraStores, undefined, f(this.data))
|
||||
return new MappedStore(this, f, extraStores, undefined, f(this.data));
|
||||
}
|
||||
return new ImmutableStore<J>(f(this.data))
|
||||
return new ImmutableStore<J>(f(this.data));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -326,8 +327,8 @@ export class ImmutableStore<T> extends Store<T> {
|
|||
* Keeps track of the callback functions
|
||||
*/
|
||||
class ListenerTracker<T> {
|
||||
public pingCount = 0
|
||||
private readonly _callbacks: ((t: T) => boolean | void | any)[] = []
|
||||
public pingCount = 0;
|
||||
private readonly _callbacks: ((t: T) => boolean | void | any)[] = [];
|
||||
|
||||
/**
|
||||
* Adds a callback which can be called; a function to unregister is returned
|
||||
|
@ -335,17 +336,17 @@ class ListenerTracker<T> {
|
|||
public addCallback(callback: (t: T) => boolean | void | any): () => void {
|
||||
if (callback === console.log) {
|
||||
// This ^^^ actually works!
|
||||
throw "Don't add console.log directly as a callback - you'll won't be able to find it afterwards. Wrap it in a lambda instead."
|
||||
throw "Don't add console.log directly as a callback - you'll won't be able to find it afterwards. Wrap it in a lambda instead.";
|
||||
}
|
||||
this._callbacks.push(callback)
|
||||
this._callbacks.push(callback);
|
||||
|
||||
// Give back an unregister-function!
|
||||
return () => {
|
||||
const index = this._callbacks.indexOf(callback)
|
||||
const index = this._callbacks.indexOf(callback);
|
||||
if (index >= 0) {
|
||||
this._callbacks.splice(index, 1)
|
||||
this._callbacks.splice(index, 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -353,40 +354,40 @@ class ListenerTracker<T> {
|
|||
* Returns the number of registered callbacks
|
||||
*/
|
||||
public ping(data: T): number {
|
||||
this.pingCount++
|
||||
let toDelete = undefined
|
||||
let startTime = new Date().getTime() / 1000
|
||||
this.pingCount++;
|
||||
let toDelete = undefined;
|
||||
let startTime = new Date().getTime() / 1000;
|
||||
for (const callback of this._callbacks) {
|
||||
try {
|
||||
if (callback(data) === true) {
|
||||
// This callback wants to be deleted
|
||||
// Note: it has to return precisely true in order to avoid accidental deletions
|
||||
if (toDelete === undefined) {
|
||||
toDelete = [callback]
|
||||
toDelete = [callback];
|
||||
} else {
|
||||
toDelete.push(callback)
|
||||
toDelete.push(callback);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Got an error while running a callback:", e)
|
||||
console.error("Got an error while running a callback:", e);
|
||||
}
|
||||
}
|
||||
let endTime = new Date().getTime() / 1000
|
||||
let endTime = new Date().getTime() / 1000;
|
||||
if (endTime - startTime > 500) {
|
||||
console.trace(
|
||||
"Warning: a ping took more then 500ms; this is probably a performance issue"
|
||||
)
|
||||
);
|
||||
}
|
||||
if (toDelete !== undefined) {
|
||||
for (const toDeleteElement of toDelete) {
|
||||
this._callbacks.splice(this._callbacks.indexOf(toDeleteElement), 1)
|
||||
this._callbacks.splice(this._callbacks.indexOf(toDeleteElement), 1);
|
||||
}
|
||||
}
|
||||
return this._callbacks.length
|
||||
return this._callbacks.length;
|
||||
}
|
||||
|
||||
length() {
|
||||
return this._callbacks.length
|
||||
return this._callbacks.length;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -394,16 +395,16 @@ class ListenerTracker<T> {
|
|||
* The mapped store is a helper type which does the mapping of a function.
|
||||
*/
|
||||
class MappedStore<TIn, T> extends Store<T> {
|
||||
private static readonly pass: () => {}
|
||||
private readonly _upstream: Store<TIn>
|
||||
private readonly _upstreamCallbackHandler: ListenerTracker<TIn> | undefined
|
||||
private _upstreamPingCount: number = -1
|
||||
private _unregisterFromUpstream: () => void
|
||||
private readonly _f: (t: TIn) => T
|
||||
private readonly _extraStores: Store<any>[] | undefined
|
||||
private _unregisterFromExtraStores: (() => void)[] | undefined
|
||||
private _callbacks: ListenerTracker<T> = new ListenerTracker<T>()
|
||||
private _callbacksAreRegistered = false
|
||||
private static readonly pass: () => {};
|
||||
private readonly _upstream: Store<TIn>;
|
||||
private readonly _upstreamCallbackHandler: ListenerTracker<TIn> | undefined;
|
||||
private _upstreamPingCount: number = -1;
|
||||
private _unregisterFromUpstream: () => void;
|
||||
private readonly _f: (t: TIn) => T;
|
||||
private readonly _extraStores: Store<any>[] | undefined;
|
||||
private _unregisterFromExtraStores: (() => void)[] | undefined;
|
||||
private _callbacks: ListenerTracker<T> = new ListenerTracker<T>();
|
||||
private _callbacksAreRegistered = false;
|
||||
|
||||
constructor(
|
||||
upstream: Store<TIn>,
|
||||
|
@ -413,20 +414,20 @@ class MappedStore<TIn, T> extends Store<T> {
|
|||
initialState: T,
|
||||
onDestroy?: (f: () => void) => void
|
||||
) {
|
||||
super()
|
||||
this._upstream = upstream
|
||||
this._upstreamCallbackHandler = upstreamListenerHandler
|
||||
this._f = f
|
||||
this._data = initialState
|
||||
this._upstreamPingCount = upstreamListenerHandler?.pingCount
|
||||
this._extraStores = extraStores
|
||||
this.registerCallbacksToUpstream()
|
||||
super();
|
||||
this._upstream = upstream;
|
||||
this._upstreamCallbackHandler = upstreamListenerHandler;
|
||||
this._f = f;
|
||||
this._data = initialState;
|
||||
this._upstreamPingCount = upstreamListenerHandler?.pingCount;
|
||||
this._extraStores = extraStores;
|
||||
this.registerCallbacksToUpstream();
|
||||
if (onDestroy !== undefined) {
|
||||
onDestroy(() => this.unregisterFromUpstream())
|
||||
onDestroy(() => this.unregisterFromUpstream());
|
||||
}
|
||||
}
|
||||
|
||||
private _data: T
|
||||
private _data: T;
|
||||
|
||||
/**
|
||||
* Gets the current data from the store
|
||||
|
@ -442,27 +443,27 @@ class MappedStore<TIn, T> extends Store<T> {
|
|||
// Callbacks are not registered, so we haven't been listening for updates from the upstream which might have changed
|
||||
if (this._upstreamCallbackHandler?.pingCount != this._upstreamPingCount) {
|
||||
// Upstream has pinged - let's update our data first
|
||||
this._data = this._f(this._upstream.data)
|
||||
this._data = this._f(this._upstream.data);
|
||||
}
|
||||
return this._data
|
||||
return this._data;
|
||||
}
|
||||
return this._data
|
||||
return this._data;
|
||||
}
|
||||
|
||||
map<J>(f: (t: T) => J, extraStores: Store<any>[] = undefined): Store<J> {
|
||||
let stores: Store<any>[] = undefined
|
||||
let stores: Store<any>[] = undefined;
|
||||
if (extraStores?.length > 0 || this._extraStores?.length > 0) {
|
||||
stores = []
|
||||
stores = [];
|
||||
}
|
||||
if (extraStores?.length > 0) {
|
||||
stores.push(...extraStores)
|
||||
stores.push(...extraStores);
|
||||
}
|
||||
if (this._extraStores?.length > 0) {
|
||||
this._extraStores?.forEach((store) => {
|
||||
if (stores.indexOf(store) < 0) {
|
||||
stores.push(store)
|
||||
stores.push(store);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
return new MappedStore(
|
||||
this,
|
||||
|
@ -470,111 +471,111 @@ class MappedStore<TIn, T> extends Store<T> {
|
|||
stores,
|
||||
this._callbacks,
|
||||
f(this.data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
addCallback(callback: (data: T) => any | boolean | void): () => void {
|
||||
if (!this._callbacksAreRegistered) {
|
||||
// This is the first callback that is added
|
||||
// We register this 'map' to the upstream object and all the streams
|
||||
this.registerCallbacksToUpstream()
|
||||
this.registerCallbacksToUpstream();
|
||||
}
|
||||
const unregister = this._callbacks.addCallback(callback)
|
||||
const unregister = this._callbacks.addCallback(callback);
|
||||
return () => {
|
||||
unregister()
|
||||
unregister();
|
||||
if (this._callbacks.length() == 0) {
|
||||
this.unregisterFromUpstream()
|
||||
this.unregisterFromUpstream();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
addCallbackAndRun(callback: (data: T) => any | boolean | void): () => void {
|
||||
const unregister = this.addCallback(callback)
|
||||
const doRemove = callback(this.data)
|
||||
const unregister = this.addCallback(callback);
|
||||
const doRemove = callback(this.data);
|
||||
if (doRemove === true) {
|
||||
unregister()
|
||||
return MappedStore.pass
|
||||
unregister();
|
||||
return MappedStore.pass;
|
||||
}
|
||||
return unregister
|
||||
return unregister;
|
||||
}
|
||||
|
||||
addCallbackAndRunD(callback: (data: T) => any | boolean | void): () => void {
|
||||
return this.addCallbackAndRun((data) => {
|
||||
if (data !== undefined) {
|
||||
return callback(data)
|
||||
return callback(data);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
addCallbackD(callback: (data: T) => any | boolean | void): () => void {
|
||||
return this.addCallback((data) => {
|
||||
if (data !== undefined) {
|
||||
return callback(data)
|
||||
return callback(data);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
private unregisterFromUpstream() {
|
||||
console.debug("Unregistering callbacks for", this.tag)
|
||||
this._callbacksAreRegistered = false
|
||||
this._unregisterFromUpstream()
|
||||
this._unregisterFromExtraStores?.forEach((unr) => unr())
|
||||
console.debug("Unregistering callbacks for", this.tag);
|
||||
this._callbacksAreRegistered = false;
|
||||
this._unregisterFromUpstream();
|
||||
this._unregisterFromExtraStores?.forEach((unr) => unr());
|
||||
}
|
||||
|
||||
private registerCallbacksToUpstream() {
|
||||
const self = this
|
||||
const self = this;
|
||||
|
||||
this._unregisterFromUpstream = this._upstream.addCallback((_) => self.update())
|
||||
this._unregisterFromUpstream = this._upstream.addCallback((_) => self.update());
|
||||
this._unregisterFromExtraStores = this._extraStores?.map((store) =>
|
||||
store?.addCallback((_) => self.update())
|
||||
)
|
||||
this._callbacksAreRegistered = true
|
||||
);
|
||||
this._callbacksAreRegistered = true;
|
||||
}
|
||||
|
||||
private update(): void {
|
||||
const newData = this._f(this._upstream.data)
|
||||
this._upstreamPingCount = this._upstreamCallbackHandler?.pingCount
|
||||
const newData = this._f(this._upstream.data);
|
||||
this._upstreamPingCount = this._upstreamCallbackHandler?.pingCount;
|
||||
if (this._data == newData) {
|
||||
return
|
||||
return;
|
||||
}
|
||||
this._data = newData
|
||||
this._callbacks.ping(this._data)
|
||||
this._data = newData;
|
||||
this._callbacks.ping(this._data);
|
||||
}
|
||||
}
|
||||
|
||||
export class UIEventSource<T> extends Store<T> implements Writable<T> {
|
||||
private static readonly pass: () => {}
|
||||
public data: T
|
||||
_callbacks: ListenerTracker<T> = new ListenerTracker<T>()
|
||||
private static readonly pass: () => {};
|
||||
public data: T;
|
||||
_callbacks: ListenerTracker<T> = new ListenerTracker<T>();
|
||||
|
||||
constructor(data: T, tag: string = "") {
|
||||
super(tag)
|
||||
this.data = data
|
||||
super(tag);
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public static flatten<X>(
|
||||
source: Store<Store<X>>,
|
||||
possibleSources?: Store<any>[]
|
||||
): UIEventSource<X> {
|
||||
const sink = new UIEventSource<X>(source.data?.data)
|
||||
const sink = new UIEventSource<X>(source.data?.data);
|
||||
|
||||
source.addCallback((latestData) => {
|
||||
sink.setData(latestData?.data)
|
||||
sink.setData(latestData?.data);
|
||||
latestData.addCallback((data) => {
|
||||
if (source.data !== latestData) {
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
sink.setData(data)
|
||||
})
|
||||
})
|
||||
sink.setData(data);
|
||||
});
|
||||
});
|
||||
|
||||
for (const possibleSource of possibleSources ?? []) {
|
||||
possibleSource?.addCallback(() => {
|
||||
sink.setData(source.data?.data)
|
||||
})
|
||||
sink.setData(source.data?.data);
|
||||
});
|
||||
}
|
||||
|
||||
return sink
|
||||
return sink;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -585,16 +586,16 @@ export class UIEventSource<T> extends Store<T> implements Writable<T> {
|
|||
promise: Promise<T>,
|
||||
onError: (e: any) => void = undefined
|
||||
): UIEventSource<T> {
|
||||
const src = new UIEventSource<T>(undefined)
|
||||
promise?.then((d) => src.setData(d))
|
||||
const src = new UIEventSource<T>(undefined);
|
||||
promise?.then((d) => src.setData(d));
|
||||
promise?.catch((err) => {
|
||||
if (onError !== undefined) {
|
||||
onError(err)
|
||||
onError(err);
|
||||
} else {
|
||||
console.warn("Promise failed:", err)
|
||||
console.warn("Promise failed:", err);
|
||||
}
|
||||
})
|
||||
return src
|
||||
});
|
||||
return src;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -606,26 +607,68 @@ export class UIEventSource<T> extends Store<T> implements Writable<T> {
|
|||
public static FromPromiseWithErr<T>(
|
||||
promise: Promise<T>
|
||||
): UIEventSource<{ success: T } | { error: any }> {
|
||||
const src = new UIEventSource<{ success: T } | { error: any }>(undefined)
|
||||
promise?.then((d) => src.setData({ success: d }))
|
||||
promise?.catch((err) => src.setData({ error: err }))
|
||||
return src
|
||||
const src = new UIEventSource<{ success: T } | { error: any }>(undefined);
|
||||
promise?.then((d) => src.setData({ success: d }));
|
||||
promise?.catch((err) => src.setData({ error: err }));
|
||||
return src;
|
||||
}
|
||||
|
||||
public static asFloat(source: UIEventSource<string>): UIEventSource<number> {
|
||||
/**
|
||||
*
|
||||
* @param source
|
||||
* UIEventSource.asInt(new UIEventSource("123")).data // => 123
|
||||
* UIEventSource.asInt(new UIEventSource("123456789")).data // => 123456789
|
||||
*
|
||||
* const srcStr = new UIEventSource("123456789"))
|
||||
* const srcInt = UIEventSource.asInt(srcStr)
|
||||
* srcInt.setData(987654321)
|
||||
* srcStr.data // => "987654321"
|
||||
*/
|
||||
public static asInt(source: UIEventSource<string>): UIEventSource<number> {
|
||||
return source.sync(
|
||||
(str) => {
|
||||
let parsed = parseFloat(str)
|
||||
return isNaN(parsed) ? undefined : parsed
|
||||
let parsed = parseInt(str);
|
||||
return isNaN(parsed) ? undefined : parsed;
|
||||
},
|
||||
[],
|
||||
(fl) => {
|
||||
if (fl === undefined || isNaN(fl)) {
|
||||
return undefined
|
||||
return undefined;
|
||||
}
|
||||
return ("" + fl).substr(0, 8)
|
||||
return ("" + fl);
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* UIEventSource.asFloat(new UIEventSource("123")).data // => 123
|
||||
* UIEventSource.asFloat(new UIEventSource("123456789")).data // => 123456789
|
||||
* UIEventSource.asFloat(new UIEventSource("0.5")).data // => 0.5
|
||||
* UIEventSource.asFloat(new UIEventSource("0.125")).data // => 0.125
|
||||
* UIEventSource.asFloat(new UIEventSource("0.0000000001")).data // => 0.0000000001
|
||||
*
|
||||
*
|
||||
* const srcStr = new UIEventSource("123456789"))
|
||||
* const srcInt = UIEventSource.asFloat(srcStr)
|
||||
* srcInt.setData(987654321)
|
||||
* srcStr.data // => "987654321"
|
||||
* @param source
|
||||
*/
|
||||
|
||||
public static asFloat(source: UIEventSource<string>): UIEventSource<number> {
|
||||
return source.sync(
|
||||
(str) => {
|
||||
let parsed = parseFloat(str);
|
||||
return isNaN(parsed) ? undefined : parsed;
|
||||
},
|
||||
[],
|
||||
(fl) => {
|
||||
if (fl === undefined || isNaN(fl)) {
|
||||
return undefined;
|
||||
}
|
||||
return ("" + fl);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
static asBoolean(stringUIEventSource: UIEventSource<string>) {
|
||||
|
@ -633,7 +676,7 @@ export class UIEventSource<T> extends Store<T> implements Writable<T> {
|
|||
(str) => str === "true",
|
||||
[],
|
||||
(b) => "" + b
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -641,9 +684,9 @@ export class UIEventSource<T> extends Store<T> implements Writable<T> {
|
|||
* However, this value can be overriden without affecting source
|
||||
*/
|
||||
static feedFrom<T>(store: Store<T>): UIEventSource<T> {
|
||||
const src = new UIEventSource(store.data)
|
||||
store.addCallback((t) => src.setData(t))
|
||||
return src
|
||||
const src = new UIEventSource(store.data);
|
||||
store.addCallback((t) => src.setData(t));
|
||||
return src;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -653,46 +696,46 @@ export class UIEventSource<T> extends Store<T> implements Writable<T> {
|
|||
* @param callback
|
||||
*/
|
||||
public addCallback(callback: (latestData: T) => boolean | void | any): () => void {
|
||||
return this._callbacks.addCallback(callback)
|
||||
return this._callbacks.addCallback(callback);
|
||||
}
|
||||
|
||||
public addCallbackAndRun(callback: (latestData: T) => boolean | void | any): () => void {
|
||||
const doDeleteCallback = callback(this.data)
|
||||
const doDeleteCallback = callback(this.data);
|
||||
if (doDeleteCallback !== true) {
|
||||
return this.addCallback(callback)
|
||||
return this.addCallback(callback);
|
||||
} else {
|
||||
return UIEventSource.pass
|
||||
return UIEventSource.pass;
|
||||
}
|
||||
}
|
||||
|
||||
public addCallbackAndRunD(callback: (data: T) => void): () => void {
|
||||
return this.addCallbackAndRun((data) => {
|
||||
if (data !== undefined && data !== null) {
|
||||
return callback(data)
|
||||
return callback(data);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
public addCallbackD(callback: (data: T) => void): () => void {
|
||||
return this.addCallback((data) => {
|
||||
if (data !== undefined && data !== null) {
|
||||
return callback(data)
|
||||
return callback(data);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
public setData(t: T): UIEventSource<T> {
|
||||
if (this.data == t) {
|
||||
// MUST COMPARE BY REFERENCE!
|
||||
return
|
||||
return;
|
||||
}
|
||||
this.data = t
|
||||
this._callbacks.ping(t)
|
||||
return this
|
||||
this.data = t;
|
||||
this._callbacks.ping(t);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ping(): void {
|
||||
this._callbacks.ping(this.data)
|
||||
this._callbacks.ping(this.data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -724,7 +767,7 @@ export class UIEventSource<T> extends Store<T> implements Writable<T> {
|
|||
extraSources: Store<any>[] = [],
|
||||
onDestroy?: (f: () => void) => void
|
||||
): Store<J> {
|
||||
return new MappedStore(this, f, extraSources, this._callbacks, f(this.data), onDestroy)
|
||||
return new MappedStore(this, f, extraSources, this._callbacks, f(this.data), onDestroy);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -736,14 +779,14 @@ export class UIEventSource<T> extends Store<T> implements Writable<T> {
|
|||
this,
|
||||
(t) => {
|
||||
if (t === undefined) {
|
||||
return undefined
|
||||
return undefined;
|
||||
}
|
||||
return f(t)
|
||||
return f(t);
|
||||
},
|
||||
extraSources,
|
||||
this._callbacks,
|
||||
this.data === undefined ? undefined : f(this.data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -760,53 +803,53 @@ export class UIEventSource<T> extends Store<T> implements Writable<T> {
|
|||
g: (j: J, t: T) => T,
|
||||
allowUnregister = false
|
||||
): UIEventSource<J> {
|
||||
const self = this
|
||||
const self = this;
|
||||
|
||||
const stack = new Error().stack.split("\n")
|
||||
const callee = stack[1]
|
||||
const stack = new Error().stack.split("\n");
|
||||
const callee = stack[1];
|
||||
|
||||
const newSource = new UIEventSource<J>(f(this.data), "map(" + this.tag + ")@" + callee)
|
||||
const newSource = new UIEventSource<J>(f(this.data), "map(" + this.tag + ")@" + callee);
|
||||
|
||||
const update = function () {
|
||||
newSource.setData(f(self.data))
|
||||
return allowUnregister && newSource._callbacks.length() === 0
|
||||
}
|
||||
const update = function() {
|
||||
newSource.setData(f(self.data));
|
||||
return allowUnregister && newSource._callbacks.length() === 0;
|
||||
};
|
||||
|
||||
this.addCallback(update)
|
||||
this.addCallback(update);
|
||||
for (const extraSource of extraSources) {
|
||||
extraSource?.addCallback(update)
|
||||
extraSource?.addCallback(update);
|
||||
}
|
||||
|
||||
if (g !== undefined) {
|
||||
newSource.addCallback((latest) => {
|
||||
self.setData(g(latest, self.data))
|
||||
})
|
||||
self.setData(g(latest, self.data));
|
||||
});
|
||||
}
|
||||
|
||||
return newSource
|
||||
return newSource;
|
||||
}
|
||||
|
||||
public syncWith(otherSource: UIEventSource<T>, reverseOverride = false): UIEventSource<T> {
|
||||
this.addCallback((latest) => otherSource.setData(latest))
|
||||
const self = this
|
||||
otherSource.addCallback((latest) => self.setData(latest))
|
||||
this.addCallback((latest) => otherSource.setData(latest));
|
||||
const self = this;
|
||||
otherSource.addCallback((latest) => self.setData(latest));
|
||||
if (reverseOverride) {
|
||||
if (otherSource.data !== undefined) {
|
||||
this.setData(otherSource.data)
|
||||
this.setData(otherSource.data);
|
||||
}
|
||||
} else if (this.data === undefined) {
|
||||
this.setData(otherSource.data)
|
||||
this.setData(otherSource.data);
|
||||
} else {
|
||||
otherSource.setData(this.data)
|
||||
otherSource.setData(this.data);
|
||||
}
|
||||
return this
|
||||
return this;
|
||||
}
|
||||
|
||||
set(value: T): void {
|
||||
this.setData(value)
|
||||
this.setData(value);
|
||||
}
|
||||
|
||||
update(f: Updater<T> & ((value: T) => T)): void {
|
||||
this.setData(f(this.data))
|
||||
this.setData(f(this.data));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
import { ImmutableStore, Store, UIEventSource } from "../../Logic/UIEventSource";
|
||||
import type { Map as MlMap } from "maplibre-gl";
|
||||
import { GeoJSONSource, Marker } from "maplibre-gl";
|
||||
import { ShowDataLayerOptions } from "./ShowDataLayerOptions";
|
||||
import { GeoOperations } from "../../Logic/GeoOperations";
|
||||
import LayerConfig from "../../Models/ThemeConfig/LayerConfig";
|
||||
import PointRenderingConfig from "../../Models/ThemeConfig/PointRenderingConfig";
|
||||
import { OsmTags } from "../../Models/OsmFeature";
|
||||
import { FeatureSource, FeatureSourceForLayer } from "../../Logic/FeatureSource/FeatureSource";
|
||||
import { BBox } from "../../Logic/BBox";
|
||||
import { Feature, Point } from "geojson";
|
||||
import LineRenderingConfig from "../../Models/ThemeConfig/LineRenderingConfig";
|
||||
import { Utils } from "../../Utils";
|
||||
import * as range_layer from "../../../assets/layers/range/range.json";
|
||||
import { LayerConfigJson } from "../../Models/ThemeConfig/Json/LayerConfigJson";
|
||||
import PerLayerFeatureSourceSplitter from "../../Logic/FeatureSource/PerLayerFeatureSourceSplitter";
|
||||
import FilteredLayer from "../../Models/FilteredLayer";
|
||||
import SimpleFeatureSource from "../../Logic/FeatureSource/Sources/SimpleFeatureSource";
|
||||
import { ImmutableStore, Store, UIEventSource } from "../../Logic/UIEventSource"
|
||||
import type { Map as MlMap } from "maplibre-gl"
|
||||
import { GeoJSONSource, Marker } from "maplibre-gl"
|
||||
import { ShowDataLayerOptions } from "./ShowDataLayerOptions"
|
||||
import { GeoOperations } from "../../Logic/GeoOperations"
|
||||
import LayerConfig from "../../Models/ThemeConfig/LayerConfig"
|
||||
import PointRenderingConfig from "../../Models/ThemeConfig/PointRenderingConfig"
|
||||
import { OsmTags } from "../../Models/OsmFeature"
|
||||
import { FeatureSource, FeatureSourceForLayer } from "../../Logic/FeatureSource/FeatureSource"
|
||||
import { BBox } from "../../Logic/BBox"
|
||||
import { Feature, Point } from "geojson"
|
||||
import LineRenderingConfig from "../../Models/ThemeConfig/LineRenderingConfig"
|
||||
import { Utils } from "../../Utils"
|
||||
import * as range_layer from "../../../assets/layers/range/range.json"
|
||||
import { LayerConfigJson } from "../../Models/ThemeConfig/Json/LayerConfigJson"
|
||||
import PerLayerFeatureSourceSplitter from "../../Logic/FeatureSource/PerLayerFeatureSourceSplitter"
|
||||
import FilteredLayer from "../../Models/FilteredLayer"
|
||||
import SimpleFeatureSource from "../../Logic/FeatureSource/Sources/SimpleFeatureSource"
|
||||
|
||||
class PointRenderingLayer {
|
||||
private readonly _config: PointRenderingConfig
|
||||
|
@ -289,16 +289,16 @@ class LineRenderingLayer {
|
|||
{
|
||||
// Add source to the map or update the feature source
|
||||
if (src === undefined) {
|
||||
this.currentSourceData = features;
|
||||
this.currentSourceData = features
|
||||
map.addSource(this._layername, {
|
||||
type: "geojson",
|
||||
data: {
|
||||
type: "FeatureCollection",
|
||||
features
|
||||
features,
|
||||
},
|
||||
promoteId: "id"
|
||||
});
|
||||
const linelayer = this._layername + "_line";
|
||||
promoteId: "id",
|
||||
})
|
||||
const linelayer = this._layername + "_line"
|
||||
map.addLayer({
|
||||
source: this._layername,
|
||||
id: linelayer,
|
||||
|
@ -307,12 +307,12 @@ class LineRenderingLayer {
|
|||
"line-color": ["feature-state", "color"],
|
||||
"line-opacity": ["feature-state", "color-opacity"],
|
||||
"line-width": ["feature-state", "width"],
|
||||
"line-offset": ["feature-state", "offset"]
|
||||
"line-offset": ["feature-state", "offset"],
|
||||
},
|
||||
layout: {
|
||||
"line-cap": "round"
|
||||
}
|
||||
});
|
||||
"line-cap": "round",
|
||||
},
|
||||
})
|
||||
|
||||
for (const feature of features) {
|
||||
if(!feature.properties.id){
|
||||
|
@ -327,10 +327,10 @@ class LineRenderingLayer {
|
|||
|
||||
map.on("click", linelayer, (e) => {
|
||||
// line-layer-listener
|
||||
e.originalEvent["consumed"] = true;
|
||||
this._onClick(e.features[0]);
|
||||
});
|
||||
const polylayer = this._layername + "_polygon";
|
||||
e.originalEvent["consumed"] = true
|
||||
this._onClick(e.features[0])
|
||||
})
|
||||
const polylayer = this._layername + "_polygon"
|
||||
|
||||
map.addLayer({
|
||||
source: this._layername,
|
||||
|
@ -340,40 +340,40 @@ class LineRenderingLayer {
|
|||
layout: {},
|
||||
paint: {
|
||||
"fill-color": ["feature-state", "fillColor"],
|
||||
"fill-opacity": ["feature-state", "fillColor-opacity"]
|
||||
}
|
||||
});
|
||||
"fill-opacity": ["feature-state", "fillColor-opacity"],
|
||||
},
|
||||
})
|
||||
if (this._onClick) {
|
||||
map.on("click", polylayer, (e) => {
|
||||
// polygon-layer-listener
|
||||
if (e.originalEvent["consumed"]) {
|
||||
// This is a polygon beneath a marker, we can ignore it
|
||||
return;
|
||||
return
|
||||
}
|
||||
e.originalEvent["consumed"] = true;
|
||||
this._onClick(e.features[0]);
|
||||
});
|
||||
e.originalEvent["consumed"] = true
|
||||
this._onClick(e.features[0])
|
||||
})
|
||||
}
|
||||
|
||||
this._visibility?.addCallbackAndRunD((visible) => {
|
||||
try {
|
||||
map.setLayoutProperty(linelayer, "visibility", visible ? "visible" : "none");
|
||||
map.setLayoutProperty(polylayer, "visibility", visible ? "visible" : "none");
|
||||
map.setLayoutProperty(linelayer, "visibility", visible ? "visible" : "none")
|
||||
map.setLayoutProperty(polylayer, "visibility", visible ? "visible" : "none")
|
||||
} catch (e) {
|
||||
console.warn(
|
||||
"Error while setting visibility of layers ",
|
||||
linelayer,
|
||||
polylayer,
|
||||
e
|
||||
);
|
||||
)
|
||||
}
|
||||
});
|
||||
})
|
||||
} else {
|
||||
this.currentSourceData = features;
|
||||
this.currentSourceData = features
|
||||
src.setData({
|
||||
type: "FeatureCollection",
|
||||
features: this.currentSourceData
|
||||
});
|
||||
features: this.currentSourceData,
|
||||
})
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < features.length; i++) {
|
||||
|
@ -407,7 +407,7 @@ class LineRenderingLayer {
|
|||
this.calculatePropsFor(feature.properties)
|
||||
)
|
||||
tags.addCallbackD((properties) => {
|
||||
if(!map.getLayer(this._layername)){
|
||||
if (!map.getLayer(this._layername)) {
|
||||
return
|
||||
}
|
||||
map.setFeatureState(
|
||||
|
|
|
@ -50,6 +50,9 @@
|
|||
$: isHardDelete = changedProperties[DeleteConfig.deleteReasonKey] !== undefined
|
||||
|
||||
async function onDelete() {
|
||||
if(selectedTags === undefined){
|
||||
return
|
||||
}
|
||||
currentState = "applying"
|
||||
let actionToTake: OsmChangeAction
|
||||
const changedProperties = TagUtils.changeAsProperties(selectedTags.asChange(tags?.data ?? {}))
|
||||
|
|
896
src/Utils.ts
896
src/Utils.ts
File diff suppressed because it is too large
Load diff
|
@ -1,11 +1,11 @@
|
|||
{
|
||||
"contributors": [
|
||||
{
|
||||
"commits": 6039,
|
||||
"commits": 6055,
|
||||
"contributor": "Pieter Vander Vennet"
|
||||
},
|
||||
{
|
||||
"commits": 408,
|
||||
"commits": 414,
|
||||
"contributor": "Robin van der Linde"
|
||||
},
|
||||
{
|
||||
|
@ -52,6 +52,10 @@
|
|||
"commits": 24,
|
||||
"contributor": "Ward"
|
||||
},
|
||||
{
|
||||
"commits": 21,
|
||||
"contributor": "dependabot[bot]"
|
||||
},
|
||||
{
|
||||
"commits": 21,
|
||||
"contributor": "wjtje"
|
||||
|
@ -60,10 +64,6 @@
|
|||
"commits": 21,
|
||||
"contributor": "AlexanderRebai"
|
||||
},
|
||||
{
|
||||
"commits": 20,
|
||||
"contributor": "dependabot[bot]"
|
||||
},
|
||||
{
|
||||
"commits": 19,
|
||||
"contributor": "Niels Elgaard Larsen"
|
||||
|
@ -106,11 +106,11 @@
|
|||
},
|
||||
{
|
||||
"commits": 11,
|
||||
"contributor": "RobJN"
|
||||
"contributor": "Thibault Molleman"
|
||||
},
|
||||
{
|
||||
"commits": 10,
|
||||
"contributor": "Thibault Molleman"
|
||||
"commits": 11,
|
||||
"contributor": "RobJN"
|
||||
},
|
||||
{
|
||||
"commits": 10,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"contributors": [
|
||||
{
|
||||
"commits": 306,
|
||||
"commits": 308,
|
||||
"contributor": "kjon"
|
||||
},
|
||||
{
|
||||
|
@ -9,7 +9,7 @@
|
|||
"contributor": "Pieter Vander Vennet"
|
||||
},
|
||||
{
|
||||
"commits": 171,
|
||||
"commits": 176,
|
||||
"contributor": "paunofu"
|
||||
},
|
||||
{
|
||||
|
|
17
src/test.ts
17
src/test.ts
|
@ -1,15 +1,8 @@
|
|||
import LayoutConfig from "./Models/ThemeConfig/LayoutConfig"
|
||||
import * as theme from "./assets/generated/themes/bookcases.json"
|
||||
import ThemeViewState from "./Models/ThemeViewState"
|
||||
import Combine from "./UI/Base/Combine"
|
||||
import SpecialVisualizations from "./UI/SpecialVisualizations"
|
||||
import ValidatedInput from "./UI/InputElement/ValidatedInput.svelte"
|
||||
import SvelteUIElement from "./UI/Base/SvelteUIElement"
|
||||
import { UIEventSource } from "./Logic/UIEventSource"
|
||||
import { Unit } from "./Models/Unit"
|
||||
import { Denomination } from "./Models/Denomination"
|
||||
import { VariableUiElement } from "./UI/Base/VariableUIElement"
|
||||
import { FixedUiElement } from "./UI/Base/FixedUiElement"
|
||||
import LayoutConfig from "./Models/ThemeConfig/LayoutConfig";
|
||||
import * as theme from "./assets/generated/themes/bookcases.json";
|
||||
import ThemeViewState from "./Models/ThemeViewState";
|
||||
import Combine from "./UI/Base/Combine";
|
||||
import SpecialVisualizations from "./UI/SpecialVisualizations";
|
||||
|
||||
function testspecial() {
|
||||
const layout = new LayoutConfig(<any>theme, true) // qp.data === "" ? : new AllKnownLayoutsLazy().get(qp.data)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue