forked from MapComplete/MapComplete
Refactoring: add metatagging, add 'last edited by' element, add 'metacondition'
This commit is contained in:
parent
771783a31c
commit
105120060d
31 changed files with 217 additions and 142 deletions
|
@ -62,7 +62,11 @@ export default class DetermineLayout {
|
|||
layoutId,
|
||||
"The layout to load into MapComplete"
|
||||
).data
|
||||
return AllKnownLayouts.allKnownLayouts.get(layoutId?.toLowerCase())
|
||||
const layout = AllKnownLayouts.allKnownLayouts.get(layoutId?.toLowerCase())
|
||||
if (layout === undefined) {
|
||||
throw "No layout with name " + layoutId + " exists"
|
||||
}
|
||||
return layout
|
||||
}
|
||||
|
||||
public static LoadLayoutFromHash(userLayoutParam: UIEventSource<string>): LayoutConfig | null {
|
||||
|
|
|
@ -6,7 +6,7 @@ import { UIEventSource } from "../../UIEventSource"
|
|||
*/
|
||||
export default class FeaturePropertiesStore {
|
||||
private readonly _source: FeatureSource & IndexedFeatureSource
|
||||
private readonly _elements = new Map<string, UIEventSource<any>>()
|
||||
private readonly _elements = new Map<string, UIEventSource<Record<string, string>>>()
|
||||
|
||||
constructor(source: FeatureSource & IndexedFeatureSource) {
|
||||
this._source = source
|
||||
|
@ -83,7 +83,9 @@ export default class FeaturePropertiesStore {
|
|||
return changeMade
|
||||
}
|
||||
|
||||
addAlias(oldId: string, newId: string): void {
|
||||
// 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)
|
||||
|
|
|
@ -94,8 +94,9 @@ export default class MetaTagging {
|
|||
let definedTags = new Set(Object.getOwnPropertyNames(feature.properties))
|
||||
for (const metatag of metatagsToApply) {
|
||||
try {
|
||||
if (!metatag.keys.some((key) => feature.properties[key] === undefined)) {
|
||||
if (!metatag.keys.some((key) => !(key in feature.properties))) {
|
||||
// All keys are already defined, we probably already ran this one
|
||||
// Note that we use 'key in properties', not 'properties[key] === undefined'. The latter will cause evaluation of lazy properties
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
|
@ -96,16 +96,11 @@ export class ReferencingWaysMetaTagger extends SimpleMetaTagger {
|
|||
return false
|
||||
}
|
||||
|
||||
console.trace("Downloading referencing ways for", feature.properties.id)
|
||||
OsmObject.DownloadReferencingWays(id).then((referencingWays) => {
|
||||
const currentTagsSource = state.allElements?.getEventSourceById(id) ?? []
|
||||
Utils.AddLazyPropertyAsync(feature.properties, "_referencing_ways", async () => {
|
||||
const referencingWays = await OsmObject.DownloadReferencingWays(id)
|
||||
const wayIds = referencingWays.map((w) => "way/" + w.id)
|
||||
wayIds.sort()
|
||||
const wayIdsStr = wayIds.join(";")
|
||||
if (wayIdsStr !== "" && currentTagsSource.data["_referencing_ways"] !== wayIdsStr) {
|
||||
currentTagsSource.data["_referencing_ways"] = wayIdsStr
|
||||
currentTagsSource.ping()
|
||||
}
|
||||
return wayIds.join(";")
|
||||
})
|
||||
|
||||
return true
|
||||
|
@ -221,6 +216,7 @@ class RewriteMetaInfoTags extends SimpleMetaTagger {
|
|||
return movedSomething
|
||||
}
|
||||
}
|
||||
|
||||
export default class SimpleMetaTaggers {
|
||||
/**
|
||||
* A simple metatagger which rewrites various metatags as needed
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue