forked from MapComplete/MapComplete
Merge typescript-4 branch
This commit is contained in:
commit
af76bf9916
7 changed files with 248 additions and 127 deletions
|
@ -44,7 +44,7 @@ export default class GeoLocationHandler extends VariableUiElement {
|
|||
* @private
|
||||
*/
|
||||
private readonly _hasLocation: Store<boolean>;
|
||||
private readonly _currentGPSLocation: UIEventSource<Coordinates>;
|
||||
private readonly _currentGPSLocation: UIEventSource<GeolocationCoordinates>;
|
||||
/**
|
||||
* Kept in order to update the marker
|
||||
* @private
|
||||
|
@ -76,7 +76,7 @@ export default class GeoLocationHandler extends VariableUiElement {
|
|||
featureSwitchGeolocation: UIEventSource<boolean>
|
||||
}
|
||||
) {
|
||||
const currentGPSLocation = new UIEventSource<Coordinates>(undefined, "GPS-coordinate")
|
||||
const currentGPSLocation = new UIEventSource<GeolocationCoordinates>(undefined, "GPS-coordinate")
|
||||
const leafletMap = state.leafletMap
|
||||
const initedAt = new Date()
|
||||
let autozoomDone = false;
|
||||
|
|
|
@ -4,6 +4,7 @@ import FeatureSource from "../FeatureSource";
|
|||
import {UIEventSource} from "../../UIEventSource";
|
||||
import {ChangeDescription} from "../../Osm/Actions/ChangeDescription";
|
||||
import {ElementStorage} from "../../ElementStorage";
|
||||
import {OsmId, OsmTags} from "../../../Models/OsmFeature";
|
||||
|
||||
export class NewGeometryFromChangesFeatureSource implements FeatureSource {
|
||||
// This class name truly puts the 'Java' into 'Javascript'
|
||||
|
@ -86,11 +87,12 @@ export class NewGeometryFromChangesFeatureSource implements FeatureSource {
|
|||
|
||||
|
||||
try {
|
||||
const tags = {}
|
||||
const tags: OsmTags = {
|
||||
id: <OsmId> (change.type + "/" + change.id)
|
||||
}
|
||||
for (const kv of change.tags) {
|
||||
tags[kv.k] = kv.v
|
||||
}
|
||||
tags["id"] = change.type + "/" + change.id
|
||||
|
||||
tags["_backend"] = backendUrl
|
||||
|
||||
|
|
|
@ -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, OsmFeature, OsmId, OsmTags, RelationId, WayId} from "../../Models/OsmFeature";
|
||||
|
||||
export abstract class OsmObject {
|
||||
|
||||
|
@ -16,7 +17,7 @@ export abstract class OsmObject {
|
|||
/**
|
||||
* The OSM tags as simple object
|
||||
*/
|
||||
tags: {} = {};
|
||||
tags: OsmTags ;
|
||||
version: number;
|
||||
public changed: boolean = false;
|
||||
timestamp: Date;
|
||||
|
@ -69,7 +70,12 @@ export abstract class OsmObject {
|
|||
return rawData.elements[0].tags
|
||||
}
|
||||
|
||||
static async DownloadObjectAsync(id: string): Promise<OsmObject | undefined> {
|
||||
static async DownloadObjectAsync(id: NodeId): Promise<OsmNode | undefined>;
|
||||
static async DownloadObjectAsync(id: WayId): Promise<OsmWay | undefined>;
|
||||
static async DownloadObjectAsync(id: RelationId): Promise<OsmRelation | undefined>;
|
||||
static async DownloadObjectAsync(id: OsmId): Promise<OsmObject | undefined>;
|
||||
static async DownloadObjectAsync(id: string): Promise<OsmObject | undefined>;
|
||||
static async DownloadObjectAsync(id: string): Promise<OsmObject | undefined>{
|
||||
const splitted = id.split("/");
|
||||
const type = splitted[0];
|
||||
const idN = Number(splitted[1]);
|
||||
|
@ -315,7 +321,7 @@ export abstract class OsmObject {
|
|||
tgs["_last_edit:changeset"] = element.changeset
|
||||
tgs["_last_edit:timestamp"] = element.timestamp
|
||||
tgs["_version_number"] = element.version
|
||||
tgs["id"] = this.type + "/" + this.id;
|
||||
tgs["id"] =<OsmId> ( this.type + "/" + this.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -347,7 +353,7 @@ export class OsmNode extends OsmObject {
|
|||
return [this.lat, this.lon];
|
||||
}
|
||||
|
||||
asGeoJson() {
|
||||
asGeoJson() : OsmFeature{
|
||||
return {
|
||||
"type": "Feature",
|
||||
"properties": this.tags,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue