forked from MapComplete/MapComplete
Add _referencing_way property for @thibaultmol
This commit is contained in:
parent
8cfbdb2a7c
commit
74185b852a
1 changed files with 29 additions and 0 deletions
|
@ -10,6 +10,7 @@ import { CountryCoder } from "latlon2country"
|
||||||
import Constants from "../Models/Constants"
|
import Constants from "../Models/Constants"
|
||||||
import { TagUtils } from "./Tags/TagUtils"
|
import { TagUtils } from "./Tags/TagUtils"
|
||||||
import { Feature, LineString } from "geojson"
|
import { Feature, LineString } from "geojson"
|
||||||
|
import { OsmObject } from "./Osm/OsmObject"
|
||||||
|
|
||||||
export class SimpleMetaTagger {
|
export class SimpleMetaTagger {
|
||||||
public readonly keys: string[]
|
public readonly keys: string[]
|
||||||
|
@ -484,6 +485,33 @@ export default class SimpleMetaTaggers {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
public static referencingWays = new SimpleMetaTagger(
|
||||||
|
{
|
||||||
|
keys: ["_referencing_ways"],
|
||||||
|
isLazy: true,
|
||||||
|
doc: "_referencing_ways contains - for a node - which ways use this this node as point in their geometry.",
|
||||||
|
},
|
||||||
|
(feature, _, __, state) => {
|
||||||
|
const id = feature.properties.id
|
||||||
|
if (!id.startsWith("node/")) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
OsmObject.DownloadReferencingWays(id).then((referencingWays) => {
|
||||||
|
const currentTagsSource = state.allElements.getEventSourceById(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 true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
public static metatags: SimpleMetaTagger[] = [
|
public static metatags: SimpleMetaTagger[] = [
|
||||||
SimpleMetaTaggers.latlon,
|
SimpleMetaTaggers.latlon,
|
||||||
SimpleMetaTaggers.layerInfo,
|
SimpleMetaTaggers.layerInfo,
|
||||||
|
@ -499,6 +527,7 @@ export default class SimpleMetaTaggers {
|
||||||
SimpleMetaTaggers.noBothButLeftRight,
|
SimpleMetaTaggers.noBothButLeftRight,
|
||||||
SimpleMetaTaggers.geometryType,
|
SimpleMetaTaggers.geometryType,
|
||||||
SimpleMetaTaggers.levels,
|
SimpleMetaTaggers.levels,
|
||||||
|
SimpleMetaTaggers.referencingWays,
|
||||||
]
|
]
|
||||||
public static readonly lazyTags: string[] = [].concat(
|
public static readonly lazyTags: string[] = [].concat(
|
||||||
...SimpleMetaTaggers.metatags.filter((tagger) => tagger.isLazy).map((tagger) => tagger.keys)
|
...SimpleMetaTaggers.metatags.filter((tagger) => tagger.isLazy).map((tagger) => tagger.keys)
|
||||||
|
|
Loading…
Reference in a new issue