fix(street-level): Panoramax functional QA — nearest lookup, line cap order, hostile data

From an adversarial functional QA round against the live API:
- The nearest lookup missed pictures looking away from the click
  (place_position leaves them out at any tolerance): it now runs a
  bounding-box search beside it and ranks both by distance. A line
  clicked from high up searches its sequence within height / 100
  (50–400 m).
- The per-tile line cap kept the newest sequences, not the longest
  (lineCoverage re-sorted them): providers can now keep their decoded
  order (`keepOrder`).
- A long producer name froze the tab (quadratic email regex): linear
  check. A malformed link escape no longer fails the lookup; null or
  string coordinates no longer land at 0,0.
- A line with no camera type or day stays drawn under the filters.
- A sky click on a line changes nothing (as KartaView), instead of
  selecting a sequence with no cones.
- An unreadable tile reads as such; a failed neighbour z15 tile only
  thins the cones; unknown or refused ids say the picture is gone.
- Shared viewer: the sharp-panorama guard is per open (a late download
  of the previous photo no longer lets a second one start); an HD-only
  360° picture is shrunk or skipped like any original; panorama.js read
  the bitmap size after closing it, so 2:1 power-of-two panoramas
  clamped instead of wrapping.
- Tests for each, and for the gaps mutation testing found (preferred
  point, cone order, no reload within drawn tiles, newest-first gate,
  stale bitmap release, flat upgrade retry).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Said TurkseverandClaude Opus 5.5 committed 2026-10-14 13:34:25 +01:00
1 parent 00d2b73b6a
commit bce3044e0c
18 files changed
+699 -98

No files matched your search

+14 -9
View File
@@ -90,8 +90,8 @@ export function panoSizeFor(canvasPixels, fovDeg) {
/**
* @typedef {object} PhotoSources Where a provider's photo comes from.
* @property {(photo: object) => boolean} hasPano A 360° photo with an equirectangular image.
* @property {(photo: object) => {url: string, width: number}|null} panoFirst
* The panorama shown first, and its texture width (0 when it is only a preview).
* @property {(photo: object) => {url: string, width: number, resize?: [number, number]|null}|null} panoFirst
* The panorama shown first, its texture width (0 when it is only a preview), and a size to shrink it to.
* @property {(photo: object, size: [number, number]) => {url: string, resize?: [number, number]|null, timeoutMs?: number}|null} panoSharp
* A sharper panorama for a canvas that needs `size`, or null.
* @property {(photo: object) => Array<string>} flatFirst Flat versions to try in turn.
@@ -158,8 +158,8 @@ export function createPhotoViewer({
let restoreView = null;
/** Width of the panorama texture on screen (0: the preview). */
let panoWidth = 0;
/** Width of a sharper panorama on its way (resizes come in bursts). */
let panoComing = 0;
/** The sharper panorama on its way, for which open (resizes come in bursts). */
let panoComing = null;
/** The sharper flat version on screen or on its way (one download each). */
let flatSharpUrl = null;
/** The photo an open is fetching: ‹ › step on from it, not the old one. */
@@ -520,10 +520,12 @@ export function createPhotoViewer({
if (kind === 'flat' && target.isPano) return;
if (kind === 'pano') {
const size = panoSizeNow();
if (size[0] <= Math.max(panoWidth, panoComing)) return;
if (size[0] <= panoWidth) return;
if (panoComing?.seq === seq && size[0] <= panoComing.width) return;
const sharp = sources.panoSharp(target, size);
if (!sharp?.url) return;
panoComing = size[0];
const coming = { seq, width: size[0] };
panoComing = coming;
try {
const image = await loadAs(sharp.url, {
crossOrigin: true,
@@ -544,7 +546,7 @@ export function createPhotoViewer({
} catch {
/* the first version stays */
} finally {
if (panoComing === size[0]) panoComing = 0;
if (panoComing === coming) panoComing = null;
}
return;
}
@@ -574,7 +576,10 @@ export function createPhotoViewer({
// waiting on it twice.
const first = sources.panoFirst(target);
if (!first?.url) throw new Error(LOAD_FAILED);
const image = await loadAs(first.url, { crossOrigin: true });
const image = await loadAs(first.url, {
crossOrigin: true,
resize: first.resize ?? null,
});
if (seq !== openSeq) {
image.close?.();
return false;
@@ -592,7 +597,7 @@ export function createPhotoViewer({
show('pano');
renderer.setImage(image);
panoWidth = first.width || 0;
panoComing = 0;
panoComing = null;
return true;
}