Refactoring: fix GPX-track view

This commit is contained in:
Pieter Vander Vennet 2023-04-20 18:58:31 +02:00
parent 4172af6a72
commit c6e12fdd6b
23 changed files with 217 additions and 347 deletions

View file

@ -5,11 +5,19 @@ import { UIEventSource } from "../../UIEventSource"
* Constructs a UIEventStore for the properties of every Feature, indexed by id
*/
export default class FeaturePropertiesStore {
private readonly _source: FeatureSource & IndexedFeatureSource
private readonly _elements = new Map<string, UIEventSource<Record<string, string>>>()
constructor(source: FeatureSource & IndexedFeatureSource) {
this._source = source
constructor(...sources: FeatureSource[]) {
for (const source of sources) {
this.trackFeatureSource(source)
}
}
public getStore(id: string): UIEventSource<Record<string, string>> {
return this._elements.get(id)
}
public trackFeatureSource(source: FeatureSource) {
const self = this
source.features.addCallbackAndRunD((features) => {
console.log("Re-indexing features")
@ -41,14 +49,6 @@ export default class FeaturePropertiesStore {
})
}
public getStore(id: string): UIEventSource<Record<string, string>> {
return this._elements.get(id)
}
public addSpecial(id: string, store: UIEventSource<Record<string, string>>) {
this._elements.set(id, store)
}
/**
* Overwrites the tags of the old properties object, returns true if a change was made.
* Metatags are overriden if they are in the new properties, but not removed
@ -87,7 +87,6 @@ export default class FeaturePropertiesStore {
// noinspection JSUnusedGlobalSymbols
public addAlias(oldId: string, newId: string): void {
console.log("FeaturePropertiesStore: adding alias for", oldId, newId)
if (newId === undefined) {
// We removed the node/way/relation with type 'type' and id 'oldId' on openstreetmap!
const element = this._elements.get(oldId)