| 
									
										
										
										
											2022-11-02 14:44:06 +01:00
										 |  |  | import Translations from "../i18n/Translations" | 
					
						
							|  |  |  | import { SubtleButton } from "../Base/SubtleButton" | 
					
						
							|  |  |  | import Svg from "../../Svg" | 
					
						
							|  |  |  | import Combine from "../Base/Combine" | 
					
						
							|  |  |  | import { GeoOperations } from "../../Logic/GeoOperations" | 
					
						
							|  |  |  | import { Utils } from "../../Utils" | 
					
						
							| 
									
										
										
										
											2023-03-28 05:13:48 +02:00
										 |  |  | import { SpecialVisualization, SpecialVisualizationState } from "../SpecialVisualization" | 
					
						
							|  |  |  | import { UIEventSource } from "../../Logic/UIEventSource" | 
					
						
							| 
									
										
										
										
											2022-10-28 04:33:05 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | export class ExportAsGpxViz implements SpecialVisualization { | 
					
						
							|  |  |  |     funcName = "export_as_gpx" | 
					
						
							|  |  |  |     docs = "Exports the selected feature as GPX-file" | 
					
						
							|  |  |  |     args = [] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-28 05:13:48 +02:00
										 |  |  |     constr(state: SpecialVisualizationState, tagSource: UIEventSource<Record<string, string>>) { | 
					
						
							| 
									
										
										
										
											2022-10-28 04:33:05 +02:00
										 |  |  |         const t = Translations.t.general.download | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return new SubtleButton( | 
					
						
							|  |  |  |             Svg.download_ui(), | 
					
						
							|  |  |  |             new Combine([ | 
					
						
							|  |  |  |                 t.downloadFeatureAsGpx.SetClass("font-bold text-lg"), | 
					
						
							|  |  |  |                 t.downloadGpxHelper.SetClass("subtle"), | 
					
						
							|  |  |  |             ]).SetClass("flex flex-col") | 
					
						
							|  |  |  |         ).onClick(() => { | 
					
						
							|  |  |  |             console.log("Exporting as GPX!") | 
					
						
							|  |  |  |             const tags = tagSource.data | 
					
						
							| 
									
										
										
										
											2023-03-28 05:13:48 +02:00
										 |  |  |             const feature = state.indexedFeatures.featuresById.data.get(tags.id) | 
					
						
							|  |  |  |             const layer = state?.layout?.getMatchingLayer(tags) | 
					
						
							|  |  |  |             const gpx = GeoOperations.AsGpx(feature, { layer }) | 
					
						
							|  |  |  |             const title = layer.title?.GetRenderValue(tags)?.Subs(tags)?.txt ?? "gpx_track" | 
					
						
							| 
									
										
										
										
											2022-11-02 14:44:06 +01:00
										 |  |  |             Utils.offerContentsAsDownloadableFile(gpx, title + "_mapcomplete_export.gpx", { | 
					
						
							|  |  |  |                 mimetype: "{gpx=application/gpx+xml}", | 
					
						
							|  |  |  |             }) | 
					
						
							| 
									
										
										
										
											2022-10-28 04:33:05 +02:00
										 |  |  |         }) | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |