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

+18 -2
View File
@@ -239,10 +239,10 @@ test('an invalid box or clock is refused before any request', async () => {
};
await assert.rejects(
searchHls({
box: { west: 179, south: 0, east: -179, north: 1 },
box: { west: -181, south: 0, east: -179, north: 1 },
fetchImpl,
}),
/dateline/,
/±180/,
);
await assert.rejects(
searchHls({ box: BOX, now: 'never', fetchImpl }),
@@ -251,6 +251,22 @@ test('an invalid box or clock is refused before any request', async () => {
assert.equal(called, false);
});
test('a dateline box goes to CMR as it is: CMR reads west > east as the short box', async () => {
const calls = [];
const result = await searchHls({
box: { west: 179, south: 0, east: -179, north: 1 },
days: 2,
now: '2026-09-21T00:00:00Z',
fetchImpl: async (url) => {
calls.push(url);
return response({ json: { hits: 1, items: [ummItem({})] } });
},
});
assert.equal(calls.length, 2, 'one search per product');
assert.ok(calls.every((url) => url.includes('bounding_box=179,0,-179,1')));
assert.ok(result.candidates.some((candidate) => candidate.product === 'S30'));
});
test('CMR pages follow the CMR-Search-After cursor up to 2,000 records and truncation stays honest', async () => {
const items = (count) =>
Array.from({ length: count }, (_, i) => ummItem({ conceptId: `G-${i}` }));