mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 19:04:02 +00:00
Merge pull request #1030 from rudycelekli/contrib/gods-009-route-cap-truthfulness-20261011-reviewed
fix(directions): report truncation only when a maneuver was actually omitted
This commit is contained in:
5 files changed
+34
-6
No files matched your search
@@ -24,6 +24,9 @@
|
|||||||
the five borough cores load and `CCTV_NYC_MAX_SOURCES` changes the cap. The catalog-wide ceiling is
|
the five borough cores load and `CCTV_NYC_MAX_SOURCES` changes the cap. The catalog-wide ceiling is
|
||||||
unchanged; extra cameras share it round-robin with the other packs.
|
unchanged; extra cameras share it round-robin with the other packs.
|
||||||
|
|
||||||
|
- Directions no longer shows a truncation notice for a route with exactly 200
|
||||||
|
turns, and a roundabout at the 200th turn keeps its exit distance.
|
||||||
|
|
||||||
- Weather records keep missing conditions unknown and refuse summaries without a measured temperature.
|
- Weather records keep missing conditions unknown and refuse summaries without a measured temperature.
|
||||||
|
|
||||||
- Tool string length validation counts Unicode characters correctly, including characters outside the basic multilingual plane.
|
- Tool string length validation counts Unicode characters correctly, including characters outside the basic multilingual plane.
|
||||||
|
|||||||
@@ -3399,9 +3399,10 @@ rate limit from the routing service is reported as one instead of as "no route
|
|||||||
found". `src/data/routeSteps.js` turns OSRM maneuver type / modifier / exit /
|
found". `src/data/routeSteps.js` turns OSRM maneuver type / modifier / exit /
|
||||||
road name into one plain-English sentence per decision, folding
|
road name into one plain-English sentence per decision, folding
|
||||||
`exit roundabout` steps into the roundabout they leave, and caps one route at
|
`exit roundabout` steps into the roundabout they leave, and caps one route at
|
||||||
200 maneuvers — a route past that cap is reported as cut off, in the row
|
200 maneuvers — a route with more is reported as cut off, in the row summary
|
||||||
summary and as the last line of the list, because the arrival step is among
|
and as the last line of the list, because the arrival step is among the ones
|
||||||
the ones dropped.
|
dropped. A route of exactly 200 is complete, and a roundabout exit after the
|
||||||
|
200th keeps folding into it.
|
||||||
|
|
||||||
A step's card opens from its dot on the globe or from its line in the list, and
|
A step's card opens from its dot on the globe or from its line in the list, and
|
||||||
the list covers every step including departure and arrival, which have no dot.
|
the list covers every step including departure and arrival, which have no dot.
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import test from 'node:test';
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { normalizeOsrmSteps, ROUTE_STEPS_MAX } from './routeSteps.js';
|
||||||
|
const step = (type) => ({
|
||||||
|
maneuver: { type, location: [10, 20] },
|
||||||
|
distance: 10,
|
||||||
|
duration: 1,
|
||||||
|
});
|
||||||
|
test('exact-cap routes remain complete and boundary exits retain their distance', () => {
|
||||||
|
const steps = Array.from({ length: ROUTE_STEPS_MAX }, () => step('turn'));
|
||||||
|
assert.equal(normalizeOsrmSteps({ legs: [{ steps }] }).truncated, false);
|
||||||
|
assert.equal(
|
||||||
|
normalizeOsrmSteps({ legs: [{ steps: [...steps, step('turn')] }] })
|
||||||
|
.truncated,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
steps[steps.length - 1] = step('roundabout');
|
||||||
|
const result = normalizeOsrmSteps({
|
||||||
|
legs: [{ steps: [...steps, step('exit roundabout')] }],
|
||||||
|
});
|
||||||
|
assert.equal(result.truncated, false);
|
||||||
|
assert.equal(result.steps.length, ROUTE_STEPS_MAX);
|
||||||
|
assert.equal(result.steps.at(-1).distanceM, 20);
|
||||||
|
});
|
||||||
@@ -185,9 +185,9 @@ export function normalizeOsrmSteps(route) {
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (out.length >= ROUTE_STEPS_MAX) return { steps: out, truncated: true };
|
||||||
step.instruction = instructionFor(step);
|
step.instruction = instructionFor(step);
|
||||||
out.push(step);
|
out.push(step);
|
||||||
if (out.length >= ROUTE_STEPS_MAX) return { steps: out, truncated: true };
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { steps: out, truncated: false };
|
return { steps: out, truncated: false };
|
||||||
|
|||||||
@@ -206,9 +206,9 @@ test('the step list is capped, and the cap is reported rather than hidden', () =
|
|||||||
// would present a route that simply stops in the middle of a road.
|
// would present a route that simply stops in the middle of a road.
|
||||||
assert.equal(cut.truncated, true);
|
assert.equal(cut.truncated, true);
|
||||||
const exact = normalizeOsrmSteps({
|
const exact = normalizeOsrmSteps({
|
||||||
legs: [{ steps: many.slice(0, ROUTE_STEPS_MAX - 1) }],
|
legs: [{ steps: many.slice(0, ROUTE_STEPS_MAX) }],
|
||||||
});
|
});
|
||||||
assert.equal(exact.steps.length, ROUTE_STEPS_MAX - 1);
|
assert.equal(exact.steps.length, ROUTE_STEPS_MAX);
|
||||||
assert.equal(exact.truncated, false, 'a route that fits is not cut');
|
assert.equal(exact.truncated, false, 'a route that fits is not cut');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user