fix(recent-imagery): take the short arc when a box is dragged across the dateline

A drag across ±180° was turned into a min/max box about 360° wide and refused
as "Box is 38,332 km wide", and validateBox() refused any west > east box. A
drag whose corners are more than 180° apart is now the short box (west > east),
and the layer handles it end to end:

- model: lonSpanDeg() and nonCrossingBoxes(); validateBox, boxSideKm,
  boxCentre, boxFromPin and coverageFor read a west > east box as the short arc.
- catalog: CMR reads a west > east bounding_box as the short box, so the box
  is sent as it is.
- rendering: the slot drapes one imagery layer per side of ±180°.
- Worldview Snapshots rejects a west > east BBOX, so snapshot URLs, EXPORT and
  get_recent_imagery refuse a dateline box and request nothing; thumbnail and
  Data-Present probes use the box's wider side.
This commit is contained in:
Byrd-IT committed 2026-11-13 17:12:47 -06:00
1 parent 7df581765d
commit ca14954636
16 files changed
+503 -70

No files matched your search

+29
View File
@@ -152,3 +152,32 @@ test('destroy mid-drag restores the camera, releases the claim and detaches the
assert.equal(f.tool.start(), false);
assert.equal(initImageryBoxTool({ viewer: null, onBox() {} }), null);
});
test('a drag across the dateline is the short box, not a box round the world', async () => {
const pickWorld = (_viewer, nx, ny) =>
ny < 0.05 ? null : { lon: nx < 0.5 ? 179.99 : -179.99, lat: ny };
const f = fixture({ pickWorld });
f.tool.start();
f.fire('LEFT_DOWN', { position: { x: 100, y: 200 } });
f.fire('LEFT_UP', { position: { x: 800, y: 250 } });
assert.deepEqual(f.cancels, []);
assert.equal(f.boxes.length, 1);
const { west, east } = f.boxes[0];
assert.ok(west > east, `west ${west} is east of east ${east}`);
assert.ok(Math.abs(east + 360 - west - 0.02) < 1e-9, 'a 0.02 degree span');
await f.tool.destroy();
});
test('a drag whose short arc is still over the size limit is refused as too large', async () => {
const pickWorld = (_viewer, nx, ny) => ({
lon: nx < 0.5 ? 100 : -100,
lat: ny,
});
const f = fixture({ pickWorld });
f.tool.start();
f.fire('LEFT_DOWN', { position: { x: 100, y: 200 } });
f.fire('LEFT_UP', { position: { x: 800, y: 250 } });
assert.equal(f.boxes.length, 0);
assert.equal(f.cancels.at(-1)[0], 'too-large');
await f.tool.destroy();
});