feat(tours): bike tours in the planner, CyclOSM, and the planned cards' last points (BIK-01 to BIK-06, RTE-01, IO-01, LIB-02)

The tour type is a dropdown; a bike tour picks its profile, routes for it,
says when a point lies off every way, and shows what it runs on: surfaces,
kinds of way and, for a mountain bike, the trail grades, each pointed at on
the map. A type's own map (OpenHikingMap for a hike, CyclOSM for a bike tour)
is offered while a tour of that type is open, with an admin switch each.

From the planned cards: a hike avoids steep climbs, steps or ferries, nothing
else; a saved tour can be shared where the platform takes GPX files; and the
tours rail adds a tour from one menu: plan new, import GPX, or take one over
from another trip.
This commit is contained in:
Maurice
2026-10-19 21:33:49 +02:00
parent adcaca3c5f
commit 73237ffedb
85 changed files with 3728 additions and 647 deletions
@@ -385,6 +385,17 @@ describe('TourTerrainMap', () => {
expect(gl.map.addLayer).toHaveBeenCalledTimes(3);
});
it('FE-COMP-TERRAIN-013b: a map on terms shows its credit above the controls, the others none (MAP-01, BIK-06)', async () => {
const { rerender } = await renderTerrain({ samples: TOUR, baseLayer: 'cycle' });
const credit = screen.getByTestId('base-map-credit');
expect(credit).toHaveTextContent('CyclOSM');
expect(credit.querySelectorAll('a')).toHaveLength(2);
rerender(<TourTerrainMap {...props({ samples: TOUR, baseLayer: 'hiking' })} />);
expect(screen.getByTestId('base-map-credit')).toHaveTextContent('Donation');
rerender(<TourTerrainMap {...props({ samples: TOUR, baseLayer: 'topo' })} />);
expect(screen.queryByTestId('base-map-credit')).toBeNull();
});
it('FE-COMP-TERRAIN-014: removes the map with the view', async () => {
const { unmount } = await renderTerrain({
waypoints: { points: [{ id: 'a', lat: 46, lng: 7 }], selectedId: null, onSelect: vi.fn() },
@@ -14,6 +14,7 @@ import {
type TourLayerOffer,
} from '../../Map/MapLayerSwitcher';
import { MAP_CONTROL_SHADOW } from '../../Map/mapControlShadow';
import { tourRasterBaseOf } from '../../Map/tourRasterBases';
import { SoftPill } from '../../Planner/planParts';
import { fs } from '../../shared/DialogShell';
import { Tooltip } from '../../shared/Tooltip';
@@ -108,7 +109,7 @@ export default function TourTerrainMap(props: TourTerrainMapProps) {
insetInlineEnd: rightWidth + MAP_LAYER_SWITCHER_INSET,
}}
>
{baseLayer === 'hiking' && <HikingMapCredit />}
<BaseMapCredit layer={baseLayer} />
{legendAbove && legend}
<div ref={attachRow} className="flex w-full items-end gap-3" data-fit={fit} data-testid="terrain-control-row">
<div className="flex-none">
@@ -144,29 +145,28 @@ export default function TourTerrainMap(props: TourTerrainMapProps) {
}
/**
* OpenHikingMap's credit and donation link, which its operator wants readable without a
* click (MAP-01). The 3D map's own attribution is folded away and sits under the panel,
* so it rides above the control row while that map is shown.
* The credit of a map on terms (OpenHikingMap with its donation link, CyclOSM), which its
* operator wants readable without a click (MAP-01, BIK-06). The 3D map's own attribution is
* folded away and sits under the panel, so it rides above the control row while that map is shown.
*/
function HikingMapCredit() {
function BaseMapCredit({ layer }: { layer: TourBaseLayer }) {
const credit = tourRasterBaseOf(layer)?.onTerms?.credit;
if (!credit) return null;
const link = 'text-content-secondary underline-offset-2 hover:underline';
return (
<div
className="pointer-events-auto flex items-center gap-1.5 rounded-full px-3 py-1 text-content-faint"
style={{ ...GLASS, ...fs(10) }}
data-testid="hiking-map-credit"
data-testid="base-map-credit"
>
<a className={link} href="https://wiki.openstreetmap.org/wiki/OpenHikingMap" target="_blank" rel="noreferrer">
&copy; OpenHikingMap
</a>
<span aria-hidden>|</span>
<a className={link} href="https://www.openstreetmap.org/copyright" target="_blank" rel="noreferrer">
&copy; OpenStreetMap
</a>
<span aria-hidden>|</span>
<a className={link} href="https://openmaps.fr/donate" target="_blank" rel="noreferrer">
{'❤️'} Donation
</a>
{credit.map((part, index) => (
<span key={part.href} className="flex items-center gap-1.5">
{index > 0 && <span aria-hidden>|</span>}
<a className={link} href={part.href} target="_blank" rel="noreferrer">
{part.label}
</a>
</span>
))}
</div>
);
}
@@ -51,7 +51,7 @@ export function sidePadding(panels: PanelWidths, margin: number) {
}
/**
* The source of a base map whose operator forbids prefetching (OpenHikingMap, MAP-01): it
* The source of a base map whose operator forbids prefetching (OpenHikingMap, CyclOSM): it
* loads only what the camera shows, and the flyover's warm-up passes it by.
*/
const VIEW_ONLY_SOURCE = 'base-view-only';
@@ -68,8 +68,8 @@ function rasterStyle(tiles: string[], maxzoom: number, sourceId = 'base', attrib
export function styleFor(layer: TourBaseLayer): string | StyleSpecification {
if (layer === 'satellite') return rasterStyle([SATELLITE_TILE_URL], 19);
if (layer === 'topo') return rasterStyle(TOUR_RASTER_BASES.topo.tiles, TOUR_RASTER_BASES.topo.maxZoom);
if (layer === 'hiking') {
const { tiles, maxZoom, attribution } = TOUR_RASTER_BASES.hiking;
if (layer === 'hiking' || layer === 'cycle') {
const { tiles, maxZoom, attribution } = TOUR_RASTER_BASES[layer];
return rasterStyle(tiles, maxZoom, VIEW_ONLY_SOURCE, attribution);
}
return OPENFREEMAP_DEFAULT_STYLE;