forked from MapComplete/MapComplete
Merge develop
This commit is contained in:
commit
00c233a2eb
188 changed files with 4982 additions and 1745 deletions
|
|
@ -2,7 +2,7 @@ import ChangeTagAction from "./ChangeTagAction"
|
|||
import { Tag } from "../../Tags/Tag"
|
||||
import OsmChangeAction from "./OsmChangeAction"
|
||||
import { ChangeDescription } from "./ChangeDescription"
|
||||
import { Store, UIEventSource } from "../../UIEventSource"
|
||||
import { UIEventSource } from "../../UIEventSource"
|
||||
|
||||
export default class LinkImageAction extends OsmChangeAction {
|
||||
private readonly _proposedKey: "image" | "mapillary" | "wiki_commons" | string
|
||||
|
|
|
|||
|
|
@ -600,7 +600,7 @@ export class Changes {
|
|||
" trying again before dropping it from the changes (" +
|
||||
e +
|
||||
")"
|
||||
this._reportError(msg)
|
||||
// this._reportError(msg) // We don't report this yet, might be a temporary fluke
|
||||
const osmObj = await downloader.DownloadObjectAsync(id, 0)
|
||||
return { id, osmObj }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import { LocalStorageSource } from "../Web/LocalStorageSource"
|
|||
import { AuthConfig } from "./AuthConfig"
|
||||
import Constants from "../../Models/Constants"
|
||||
import { AndroidPolyfill } from "../Web/AndroidPolyfill"
|
||||
import { Feature, Point } from "geojson"
|
||||
|
||||
interface OsmUserInfo {
|
||||
id: number
|
||||
|
|
@ -41,6 +42,39 @@ export default class UserDetails {
|
|||
|
||||
export type OsmServiceState = "online" | "readonly" | "offline" | "unknown" | "unreachable"
|
||||
|
||||
interface CapabilityResult {
|
||||
version: "0.6" | string
|
||||
generator: "OpenStreetMap server" | string
|
||||
copyright: "OpenStreetMap and contributors" | string
|
||||
attribution: "http://www.openstreetmap.org/copyright" | string
|
||||
license: "http://opendatacommons.org/licenses/odbl/1-0/" | string
|
||||
api: {
|
||||
version: { minimum: "0.6"; maximum: "0.6" }
|
||||
area: { maximum: 0.25 | number }
|
||||
note_area: { maximum: 25 | number }
|
||||
tracepoints: { per_page: 5000 | number }
|
||||
waynodes: { maximum: 2000 | number }
|
||||
relationmembers: { maximum: 32000 | number }
|
||||
changesets: {
|
||||
maximum_elements: 10000 | number
|
||||
default_query_limit: 100 | number
|
||||
maximum_query_limit: 100 | number
|
||||
}
|
||||
notes: { default_query_limit: 100 | number; maximum_query_limit: 10000 | number }
|
||||
timeout: { seconds: 300 | number }
|
||||
status: {
|
||||
database: OsmServiceState
|
||||
api: OsmServiceState
|
||||
gpx: OsmServiceState
|
||||
}
|
||||
}
|
||||
policy: {
|
||||
imagery: {
|
||||
blacklist: { regex: string }[]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class OsmConnection {
|
||||
public auth: osmAuth
|
||||
public userDetails: UIEventSource<UserDetails>
|
||||
|
|
@ -424,6 +458,10 @@ export class OsmConnection {
|
|||
return id
|
||||
}
|
||||
|
||||
public async getNote(id: number): Promise<Feature<Point>> {
|
||||
return JSON.parse(await this.get("notes/" + id + ".json"))
|
||||
}
|
||||
|
||||
public static GpxTrackVisibility = ["private", "public", "trackable", "identifiable"] as const
|
||||
|
||||
public async uploadGpxTrack(
|
||||
|
|
@ -466,7 +504,7 @@ export class OsmConnection {
|
|||
(options.filename ?? "gpx_track_mapcomplete_" + new Date().toISOString()) +
|
||||
"\"\r\nContent-Type: application/gpx+xml",
|
||||
}
|
||||
|
||||
user
|
||||
const boundary = "987654"
|
||||
|
||||
let body = ""
|
||||
|
|
@ -608,20 +646,26 @@ export class OsmConnection {
|
|||
return parsed
|
||||
}
|
||||
|
||||
private async FetchCapabilities(): Promise<{ api: OsmServiceState; gpx: OsmServiceState }> {
|
||||
private async FetchCapabilities(): Promise<{
|
||||
api: OsmServiceState
|
||||
gpx: OsmServiceState
|
||||
database: OsmServiceState
|
||||
}> {
|
||||
if (Utils.runningFromConsole) {
|
||||
return { api: "online", gpx: "online" }
|
||||
return { api: "online", gpx: "online", database: "online" }
|
||||
}
|
||||
const result = await Utils.downloadAdvanced(this.Backend() + "/api/0.6/capabilities")
|
||||
if (result["content"] === undefined) {
|
||||
console.log("Something went wrong:", result)
|
||||
return { api: "unreachable", gpx: "unreachable" }
|
||||
try {
|
||||
const result = await Utils.downloadJson<CapabilityResult>(
|
||||
this.Backend() + "/api/0.6/capabilities.json"
|
||||
)
|
||||
if (result?.api?.status === undefined) {
|
||||
console.log("Something went wrong:", result)
|
||||
return { api: "unreachable", gpx: "unreachable", database: "unreachable" }
|
||||
}
|
||||
return result.api.status
|
||||
} catch (e) {
|
||||
console.error("Could not fetch capabilities")
|
||||
return { api: "offline", gpx: "offline", database: "online" }
|
||||
}
|
||||
const xmlRaw = result["content"]
|
||||
const parsed = new DOMParser().parseFromString(xmlRaw, "text/xml")
|
||||
const statusEl = parsed.getElementsByTagName("status")[0]
|
||||
const api = <OsmServiceState>statusEl.getAttribute("api")
|
||||
const gpx = <OsmServiceState>statusEl.getAttribute("gpx")
|
||||
return { api, gpx }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import osmtogeojson from "osmtogeojson"
|
|||
import { FeatureCollection } from "@turf/turf"
|
||||
import { Geometry } from "geojson"
|
||||
import { OsmTags } from "../../Models/OsmFeature"
|
||||
|
||||
;("use strict")
|
||||
/**
|
||||
* Interfaces overpass to get all the latest data
|
||||
*/
|
||||
|
|
@ -74,9 +74,9 @@ export class Overpass {
|
|||
console.warn("No features for", json)
|
||||
}
|
||||
|
||||
const geojson = osmtogeojson(json)
|
||||
const geojson = <FeatureCollection<Geometry, OsmTags>>osmtogeojson(json)
|
||||
const osmTime = new Date(json.osm3s.timestamp_osm_base)
|
||||
return [<any>geojson, osmTime]
|
||||
return [geojson, osmTime]
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue