diff --git a/front/src/common/Map/WarpedMap/SimulationWarpedMap.tsx b/front/src/common/Map/WarpedMap/SimulationWarpedMap.tsx index c3a96917c97..f8941cdce4a 100644 --- a/front/src/common/Map/WarpedMap/SimulationWarpedMap.tsx +++ b/front/src/common/Map/WarpedMap/SimulationWarpedMap.tsx @@ -99,7 +99,8 @@ const SimulationWarpedMap: FC<{ collapsed?: boolean }> = ({ collapsed }) => { const chartEnd = !rotate ? y(l) : x(l); const size = !rotate ? height : width; - const transformedPath = transform(path) as typeof path; + // we don't clip the path + const transformedPath = transform(path, false) as typeof path; const latStart = (first(transformedPath.geometry.coordinates) as Position)[1]; const latEnd = (last(transformedPath.geometry.coordinates) as Position)[1]; @@ -175,7 +176,9 @@ const SimulationWarpedMap: FC<{ collapsed?: boolean }> = ({ collapsed }) => { }, [selectedTrain, state.type, simulation]); const warpedItinerary = useMemo(() => { const itinerary = getAsyncMemoData(itineraryState); - if (itinerary && state.type === 'dataLoaded') return state.transform(itinerary) || undefined; + if (itinerary && state.type === 'dataLoaded') + // we don't clip the path + return state.transform(itinerary, false) || undefined; return undefined; }, [itineraryState, state]); diff --git a/front/src/common/Map/WarpedMap/core/projection.ts b/front/src/common/Map/WarpedMap/core/projection.ts index 4dd13a37abe..02e7da6b92a 100644 --- a/front/src/common/Map/WarpedMap/core/projection.ts +++ b/front/src/common/Map/WarpedMap/core/projection.ts @@ -150,19 +150,22 @@ export function projectGeometry( export function clipAndProjectGeoJSON( geojson: T, projection: Projection, - zone: Zone + zone: Zone, + shouldClip: boolean ): T | null { if (geojson.type === 'FeatureCollection') return { ...geojson, features: geojson.features.flatMap((f) => { - const res = clipAndProjectGeoJSON(f, projection, zone); + const res = clipAndProjectGeoJSON(f, projection, zone, shouldClip); return res ? [res] : []; }), }; if (geojson.type === 'Feature') { - const clippedFeature = clip(geojson, zone) as Feature | null; + const clippedFeature = shouldClip + ? (clip(geojson, zone) as Feature | null) + : (geojson as Feature); if (clippedFeature) { const newGeometry = projectGeometry(clippedFeature.geometry, projection); diff --git a/front/src/common/Map/WarpedMap/getWarping.ts b/front/src/common/Map/WarpedMap/getWarping.ts index 051290044c4..cfe8884fd34 100644 --- a/front/src/common/Map/WarpedMap/getWarping.ts +++ b/front/src/common/Map/WarpedMap/getWarping.ts @@ -54,7 +54,7 @@ export default function getWarping(warpPath: Feature) { // regular grid: return { warpedBBox: bbox(warped) as BBox2d, - transform: (f: T): T | null => - clipAndProjectGeoJSON(f, projection, zone), + transform: (f: T, clip = true): T | null => + clipAndProjectGeoJSON(f, projection, zone, clip), }; }