fix(street-level): Panoramax IC8 round 2 — shared point budget, selected line, cone cache, DP segments

From the round-2 verification (approve with follow-ups), all follow-ups:
- The point budget is shared across the tiles in view once loading
  settles (water-filling): a sparse tile keeps what it has, a dense city
  centre takes the rest instead of drawing thinner than its suburbs. The
  selected sequence is always drawn, and selecting one a cap had left out
  draws it.
- The cones' picture-list cache keeps only finished lists: a re-centre
  while the cones loaded inherited the aborted load's tiles and drew
  none in them.
- Douglas–Peucker measures to the segment, so dead ends and U-turns keep
  their far end.
- Switching Panoramax off lets its decoded tiles and lists go.
- Picture downloads are counted while they stream (a host sending no
  length cannot fill memory before the cap).
- Comments on the via caption and the simplification tolerance match the
  code.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Said TurkseverandClaude Opus 5.5 committed 2026-10-14 15:39:10 +01:00
1 parent 1a546bec72
commit 3ae367d0dd
11 files changed
+343 -33

No files matched your search

@@ -9,7 +9,8 @@ import {
/**
* Douglas–Peucker in tile units: the points of `line` ({x, y}) that keep
* it within `tolerance` of the original, first and last always kept.
* it within `tolerance` of the original (measured to each segment, so
* dead ends and U-turns stay), first and last always kept.
* Iterative, so a long track cannot overflow the stack.
*/
export function simplifyLine(line, tolerance) {
@@ -24,15 +25,20 @@ export function simplifyLine(line, tolerance) {
const b = line[to];
const dx = b.x - a.x;
const dy = b.y - a.y;
const span = Math.hypot(dx, dy);
const span2 = dx * dx + dy * dy;
let far = -1;
let farthest = tolerance;
for (let i = from + 1; i < to; i++) {
const p = line[i];
// Distance to the chord, or to `a` where the chord has no length.
const d = span
? Math.abs((p.x - a.x) * dy - (p.y - a.y) * dx) / span
: Math.hypot(p.x - a.x, p.y - a.y);
// Distance to the segment, not the infinite line: a dead end or a
// U-turn (a point beyond the chord's ends) is kept.
const t = span2
? Math.max(
0,
Math.min(1, ((p.x - a.x) * dx + (p.y - a.y) * dy) / span2),
)
: 0;
const d = Math.hypot(p.x - (a.x + t * dx), p.y - (a.y + t * dy));
if (d > farthest) {
farthest = d;
far = i;