mapcomplete/UI/Popup/UploadToOsmViz.ts

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

28 lines
1,009 B
TypeScript
Raw Normal View History

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,
2023-06-02 08:42:08 +02:00
_: UIEventSource<Record<string, string>>,
__: string[]
2023-03-28 05:13:48 +02:00
) {
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
},
})
}
}