diff --git a/Logic/Osm/OsmObject.ts b/Logic/Osm/OsmObject.ts index 0dd967bb0..1483628bf 100644 --- a/Logic/Osm/OsmObject.ts +++ b/Logic/Osm/OsmObject.ts @@ -3,6 +3,7 @@ import * as polygon_features from "../../assets/polygon-features.json"; import {Store, UIEventSource} from "../UIEventSource"; import {BBox} from "../BBox"; import * as OsmToGeoJson from "osmtogeojson"; +import {NodeId, OsmId, OsmTags, RelationId, WayId} from "../../Models/OsmFeature"; export abstract class OsmObject { @@ -38,10 +39,12 @@ export abstract class OsmObject { throw "Backend URL must begin with http" } this.backendURL = url; - this.DownloadObject("id/5") } - public static DownloadObject(id: string, forceRefresh: boolean = false): Store { + public static DownloadObject(id: NodeId, forceRefresh?: boolean ): Store ; + public static DownloadObject(id: WayId, forceRefresh?: boolean ): Store ; + public static DownloadObject(id: RelationId, forceRefresh?: boolean ): Store ; + public static DownloadObject(id: OsmId, forceRefresh: boolean = false): Store { let src: UIEventSource; if (OsmObject.objectCache.has(id)) { src = OsmObject.objectCache.get(id) @@ -51,14 +54,14 @@ export abstract class OsmObject { return src; } } else { - src = UIEventSource.FromPromise(OsmObject.DownloadObjectAsync(id)) + src = UIEventSource.FromPromise(OsmObject.DownloadObjectAsync( id)) } OsmObject.objectCache.set(id, src); return src; } - static async DownloadPropertiesOf(id: string): Promise { + static async DownloadPropertiesOf(id: OsmId): Promise { const splitted = id.split("/"); const idN = Number(splitted[1]); if (idN < 0) { @@ -70,7 +73,10 @@ export abstract class OsmObject { return rawData.elements[0].tags } - static async DownloadObjectAsync(id: string): Promise { + static async DownloadObjectAsync(id: NodeId): Promise; + static async DownloadObjectAsync(id: WayId): Promise; + static async DownloadObjectAsync(id: RelationId): Promise; + static async DownloadObjectAsync(id: OsmId): Promise{ const splitted = id.split("/"); const type = splitted[0]; const idN = Number(splitted[1]); diff --git a/Models/OsmFeature.ts b/Models/OsmFeature.ts index 4753287ca..10aad78bc 100644 --- a/Models/OsmFeature.ts +++ b/Models/OsmFeature.ts @@ -1,4 +1,9 @@ import {Feature, Geometry} from "@turf/turf"; -export type OsmTags = Record & {id: string} +export type RelationId = `relation/${number}` +export type WayId = `way/${number}` +export type NodeId = `node/${number}` +export type OsmId = NodeId | WayId | RelationId + +export type OsmTags = Record & {id: OsmId} export type OsmFeature = Feature \ No newline at end of file diff --git a/assets/themes/postboxes/postboxes.json b/assets/themes/postboxes/postboxes.json index e1e657953..8442d88fe 100644 --- a/assets/themes/postboxes/postboxes.json +++ b/assets/themes/postboxes/postboxes.json @@ -41,7 +41,7 @@ "maxZoom": 14, "minNeededElements": 100 }, - "credits": "nicolelaine" + "credits": "nicolelaine", "layers": [ "postboxes", "postoffices", diff --git a/test/Logic/OSM/Actions/RelationSplitHandler.spec.ts b/test/Logic/OSM/Actions/RelationSplitHandler.spec.ts index 3fa54a139..8a5d44268 100644 --- a/test/Logic/OSM/Actions/RelationSplitHandler.spec.ts +++ b/test/Logic/OSM/Actions/RelationSplitHandler.spec.ts @@ -604,7 +604,7 @@ describe("RelationSplitHandler", () => { "should split turn restrictions (split of https://www.openstreetmap.org/way/143298912)", async () => { - const relation: OsmRelation = await OsmObject.DownloadObjectAsync("relation/4374576") + const relation: OsmRelation = await OsmObject.DownloadObjectAsync("relation/4374576") const originalNodeIds = [ 1407529979,