mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-30 08:30:05 +00:00
feat(tours): import KML and KMZ routes as tours, with a preview first
A route planned in Google My Maps or Google Earth can now become a tour without converting it to GPX first. The import button and a file dropped on the tours workspace take .kml and .kmz files beside .gpx, through the same preview, the same import routes and the same transaction as a GPX file. The preview shows every line of the file on its own, numbered, with its distance and heights; two lines of one placemark are numbered after its name and never joined. Heights count only where they are heights: kept for an absolute line, dropped for any other altitude mode and for the all-zero placeholder My Maps writes, so a missing height stays unknown. What the file holds besides its lines (pins, areas, overlays, links to other files) is counted in a dashed card, and nothing is fetched from elsewhere. The KML reading reuses the place import's codec. A KMZ only ever has its KML entry unpacked, counted byte by byte against the decompressed cap whatever its header claims. A file that cannot be read is refused with its reason (damaged, an archive without KML, too large unpacked), and the toast names the file and the reason. A KML or KMZ import keeps the gpx origin of a file import; its provenance names the real format from the stored file name.
This commit is contained in:
@@ -54,7 +54,7 @@ describe('TourAddMenu (LIB-02)', () => {
|
||||
expect(button).toHaveAttribute('aria-expanded', 'true');
|
||||
expect(entries().map((entry) => entry.textContent)).toEqual([
|
||||
'Plan new tour',
|
||||
'Import GPX',
|
||||
'Import GPX or KML',
|
||||
'Import walk from Google Maps',
|
||||
'Take over a tour from another trip',
|
||||
]);
|
||||
@@ -69,7 +69,7 @@ describe('TourAddMenu (LIB-02)', () => {
|
||||
expect(p.startNewTour).toHaveBeenCalledTimes(1);
|
||||
expect(screen.queryByRole('group')).toBeNull();
|
||||
open();
|
||||
fireEvent.click(screen.getByText('Import GPX'));
|
||||
fireEvent.click(screen.getByText('Import GPX or KML'));
|
||||
expect(gpx.pick).toHaveBeenCalledTimes(1);
|
||||
open();
|
||||
fireEvent.click(screen.getByText('Take over a tour from another trip'));
|
||||
@@ -80,7 +80,7 @@ describe('TourAddMenu (LIB-02)', () => {
|
||||
render(<TourAddMenu planner={planner('neutral')} gpxImport={gpxImport()} onTakenOver={vi.fn()} disabled={false} />);
|
||||
open();
|
||||
expect(entries().map((entry) => entry.textContent)).toEqual([
|
||||
'Import GPX',
|
||||
'Import GPX or KML',
|
||||
'Import walk from Google Maps',
|
||||
'Take over a tour from another trip',
|
||||
]);
|
||||
|
||||
@@ -23,7 +23,7 @@ interface AddEntry {
|
||||
/**
|
||||
* LIB-02: the tours rail's one way to add a tour, as a menu: plan a new one
|
||||
* (while another is open; with none open the map is already planning one),
|
||||
* import GPX files, read a city walk from a Google Maps walking route (CW-07),
|
||||
* import GPX, KML or KMZ files, read a city walk from a Google Maps walking route (CW-07),
|
||||
* or take one over from another trip. The walk and the take-over open their
|
||||
* dialogs from here. A tour taken over comes into the trip and opens in the
|
||||
* editor, unless the editor holds unsaved work; a walk read from Google Maps
|
||||
|
||||
Reference in New Issue
Block a user