UX: immediately download a feature that has the ID via the hash to display it faster

This commit is contained in:
Pieter Vander Vennet 2025-08-18 14:00:42 +02:00
parent ccdcb86044
commit 20f4f6b869
3 changed files with 29 additions and 18 deletions

View file

@ -2,7 +2,7 @@ import { Utils } from "../../Utils"
import polygon_features from "../../assets/polygon-features.json"
import { OsmFeature, OsmId, OsmTags, WayId } from "../../Models/OsmFeature"
import OsmToGeoJson from "osmtogeojson"
import { Feature, LineString, Polygon } from "geojson"
import { Feature, LineString, Point, Polygon } from "geojson"
import Constants from "../../Models/Constants"
export abstract class OsmObject {
@ -131,7 +131,7 @@ export abstract class OsmObject {
*/
public abstract centerpoint(): [number, number]
public abstract asGeoJson(): any
public abstract asGeoJson(): OsmFeature
abstract SaveExtraData(element: any, allElements: OsmObject[] | any)
@ -228,7 +228,7 @@ ${tags} </node>
return [this.lat, this.lon]
}
asGeoJson(): OsmFeature {
asGeoJson(): Feature<Point, OsmTags> {
return {
type: "Feature",
properties: this.tags,
@ -305,7 +305,7 @@ ${nds}${tags} </way>
this.nodes = element.nodes
}
public asGeoJson(): Feature<Polygon | LineString> & { properties: { id: WayId } } {
public asGeoJson(): Feature<Polygon | LineString, OsmTags> & { properties: { id: WayId } } {
const coordinates: [number, number][] | [number, number][][] = this.coordinates.map(
([lat, lon]) => [lon, lat]
)
@ -384,7 +384,7 @@ ${members}${tags} </relation>
this.geojson = geojson
}
asGeoJson(): any {
asGeoJson(): OsmFeature {
if (this.geojson !== undefined) {
return this.geojson
}