mapcomplete/UI/Popup/UploadToOsmViz.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
1.2 KiB
TypeScript
Raw Normal View History

2022-11-02 14:44:06 +01:00
import { Utils } from "../../Utils"
import { Feature } from "geojson"
import { Point } from "@turf/turf"
import { GeoLocationPointProperties } from "../../Logic/State/GeoLocationState"
2022-11-02 14:44:06 +01:00
import UploadTraceToOsmUI from "../BigComponents/UploadTraceToOsmUI"
2023-03-28 05:13:48 +02:00
import { SpecialVisualization, SpecialVisualizationState } from "../SpecialVisualization"
import { UIEventSource } from "../../Logic/UIEventSource"
2023-04-20 18:58:31 +02:00
import { GeoOperations } from "../../Logic/GeoOperations"
/**
* Wrapper around 'UploadTraceToOsmUI'
*/
export class UploadToOsmViz implements SpecialVisualization {
funcName = "upload_to_osm"
2022-11-02 14:44:06 +01:00
docs =
"Uploads the GPS-history as GPX to OpenStreetMap.org; clears the history afterwards. The actual feature is ignored."
args = []
2023-03-28 05:13:48 +02:00
constr(
state: SpecialVisualizationState,
featureTags: UIEventSource<Record<string, string>>,
args: string[]
) {
2023-04-20 18:58:31 +02:00
const locations = state.historicalUserLocations.features.data
return new UploadTraceToOsmUI((title) => GeoOperations.toGpx(locations, title), state, {
whenUploaded: async () => {
state.historicalUserLocations.features.setData([])
2022-11-02 14:44:06 +01:00
},
})
}
}