forked from MapComplete/MapComplete
Small UI tweaks for studio, improve linting and typing
This commit is contained in:
parent
b03ff4f148
commit
15aa141e15
5 changed files with 14 additions and 14 deletions
|
|
@ -214,7 +214,7 @@ export class OsmNode extends OsmObject {
|
|||
* @constructor
|
||||
*/
|
||||
ChangesetXML(changesetId: string, header?: string): string {
|
||||
let tags = this.TagsXML()
|
||||
const tags = this.TagsXML()
|
||||
return ` <node id="${this.id}" ${header ?? ""} ${
|
||||
changesetId ? ' changeset="' + changesetId + '" ' : ""
|
||||
}${this.VersionXML()} lat="${this.lat}" lon="${this.lon}">
|
||||
|
|
@ -265,7 +265,7 @@ export class OsmWay extends OsmObject {
|
|||
* obj.ChangesetXML("123").trim() // => '<way id="1234" changeset="123" >\n <tag k="key" v="value"/>\n </way>'
|
||||
*/
|
||||
ChangesetXML(changesetId: string, header?: string): string {
|
||||
let tags = this.TagsXML()
|
||||
const tags = this.TagsXML()
|
||||
let nds = ""
|
||||
for (const node in this.nodes) {
|
||||
nds += ' <nd ref="' + this.nodes[node] + '"/>\n'
|
||||
|
|
@ -302,14 +302,14 @@ ${nds}${tags} </way>
|
|||
latSum += node.lat
|
||||
lonSum += node.lon
|
||||
}
|
||||
let count = this.coordinates.length
|
||||
const count = this.coordinates.length
|
||||
this.lat = latSum / count
|
||||
this.lon = lonSum / count
|
||||
this.nodes = element.nodes
|
||||
}
|
||||
|
||||
public asGeoJson(): Feature<Polygon | LineString> & { properties: { id: WayId } } {
|
||||
let coordinates: [number, number][] | [number, number][][] = this.coordinates.map(
|
||||
const coordinates: [number, number][] | [number, number][][] = this.coordinates.map(
|
||||
([lat, lon]) => [lon, lat]
|
||||
)
|
||||
let geometry: LineString | Polygon
|
||||
|
|
@ -375,9 +375,9 @@ export class OsmRelation extends OsmObject {
|
|||
'"/>\n'
|
||||
}
|
||||
|
||||
let tags = this.TagsXML()
|
||||
const tags = this.TagsXML()
|
||||
let cs = ""
|
||||
if (changesetId !== undefined) {
|
||||
if (changesetId) {
|
||||
cs = `changeset="${changesetId}"`
|
||||
}
|
||||
return ` <relation id="${this.id}" ${header ?? ""} ${cs} ${this.VersionXML()}>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import { ImmutableStore, Store } from "../UIEventSource"
|
|||
import { BBox } from "../BBox"
|
||||
import osmtogeojson from "osmtogeojson"
|
||||
import { FeatureCollection } from "@turf/turf"
|
||||
import { Geometry } from "geojson"
|
||||
import { OsmTags } from "../../Models/OsmFeature"
|
||||
|
||||
/**
|
||||
* Interfaces overpass to get all the latest data
|
||||
|
|
@ -33,7 +35,7 @@ export class Overpass {
|
|||
this._includeMeta = includeMeta
|
||||
}
|
||||
|
||||
public async queryGeoJson(bounds: BBox): Promise<[FeatureCollection, Date]> {
|
||||
public async queryGeoJson(bounds: BBox): Promise<[FeatureCollection<Geometry, OsmTags>, Date]> {
|
||||
const bbox =
|
||||
"[bbox:" +
|
||||
bounds.getSouth() +
|
||||
|
|
@ -52,8 +54,8 @@ export class Overpass {
|
|||
return `${this._interpreterUrl}?data=${encodeURIComponent(query)}`
|
||||
}
|
||||
|
||||
private async ExecuteQuery(query: string): Promise<[FeatureCollection, Date]> {
|
||||
const json = await Utils.downloadJson(this.buildUrl(query))
|
||||
private async ExecuteQuery(query: string): Promise<[FeatureCollection<Geometry, OsmTags>, Date]> {
|
||||
const json = await Utils.downloadJson<{elements: [], remark, osm3s: {timestamp_osm_base: string}}>(this.buildUrl(query))
|
||||
|
||||
if (json.elements.length === 0 && json.remark !== undefined) {
|
||||
console.warn("Timeout or other runtime error while querying overpass", json.remark)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue