forked from MapComplete/MapComplete
Refactoring: move uploadGPXToOSm into svelte
This commit is contained in:
parent
7b9a748199
commit
34d8527718
9 changed files with 222 additions and 198 deletions
|
@ -153,11 +153,7 @@ export default class GeoLocationHandler {
|
|||
const features: UIEventSource<Feature[]> = new UIEventSource<Feature[]>([])
|
||||
this.currentUserLocation = new StaticFeatureSource(features)
|
||||
let i = 0
|
||||
this.geolocationState.currentGPSLocation.addCallbackAndRun((location) => {
|
||||
if (location === undefined) {
|
||||
return
|
||||
}
|
||||
|
||||
this.geolocationState.currentGPSLocation.addCallbackAndRunD((location) => {
|
||||
const properties = {
|
||||
id: "gps-" + i,
|
||||
"user:location": "yes",
|
||||
|
@ -200,7 +196,6 @@ export default class GeoLocationHandler {
|
|||
)
|
||||
})
|
||||
features.ping()
|
||||
let i = 0
|
||||
this.currentUserLocation?.features?.addCallbackAndRunD(([location]: [Feature<Point>]) => {
|
||||
if (location === undefined) {
|
||||
return
|
||||
|
@ -231,7 +226,6 @@ export default class GeoLocationHandler {
|
|||
|
||||
const feature = JSON.parse(JSON.stringify(location))
|
||||
feature.properties.id = "gps/" + features.data.length
|
||||
i++
|
||||
features.data.push(feature)
|
||||
features.ping()
|
||||
})
|
||||
|
|
|
@ -399,11 +399,12 @@ export class OsmConnection {
|
|||
return id
|
||||
}
|
||||
|
||||
public static GpxTrackVisibility = ["private", "public", "trackable", "identifiable"] as const
|
||||
public async uploadGpxTrack(
|
||||
gpx: string,
|
||||
options: {
|
||||
description: string
|
||||
visibility: "private" | "public" | "trackable" | "identifiable"
|
||||
visibility: (typeof OsmConnection.GpxTrackVisibility)[number]
|
||||
filename?: string
|
||||
/**
|
||||
* Some words to give some properties;
|
||||
|
@ -425,11 +426,14 @@ export class OsmConnection {
|
|||
|
||||
const contents = {
|
||||
file: gpx,
|
||||
description: options.description ?? "",
|
||||
description: options.description,
|
||||
tags: options.labels?.join(",") ?? "",
|
||||
visibility: options.visibility,
|
||||
}
|
||||
|
||||
if (!contents.description) {
|
||||
throw "The description of a GPS-trace cannot be the empty string, undefined or null"
|
||||
}
|
||||
const extras = {
|
||||
file:
|
||||
'; filename="' +
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue