mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-23 11:42:21 +00:00
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:
1 parent
7df581765d
commit
ca14954636
16 files changed
+503
-70
No files matched your search
@@ -31,11 +31,6 @@ export const getRecentImagery = defineTool({
|
||||
requires: ['imagery'],
|
||||
async run(args, { services, signal }) {
|
||||
const area = await resolveArea(args.area, { services, signal });
|
||||
if (area.west > area.east)
|
||||
throw new ToolError(
|
||||
'invalid_arguments',
|
||||
'The area must not cross the antimeridian',
|
||||
);
|
||||
if (
|
||||
Math.abs(area.south) > MAX_LATITUDE ||
|
||||
Math.abs(area.north) > MAX_LATITUDE
|
||||
@@ -55,6 +50,13 @@ export const getRecentImagery = defineTool({
|
||||
east: area.east,
|
||||
north: area.north,
|
||||
};
|
||||
// Worldview Snapshots rejects a west > east BBOX, so a dateline area can
|
||||
// never produce the image this tool returns: refuse before searching.
|
||||
if (box.west > box.east)
|
||||
throw new ToolError(
|
||||
'invalid_arguments',
|
||||
'A snapshot cannot cross the dateline',
|
||||
);
|
||||
let latest;
|
||||
try {
|
||||
latest = await services.imagery.latest({ box, signal });
|
||||
|
||||
@@ -82,8 +82,29 @@ test('overview fallback, empty results and invalid areas are reported', async ()
|
||||
);
|
||||
await assert.rejects(
|
||||
none.call('get_recent_imagery', { area: { bbox: [170, 0, -170, 5] } }),
|
||||
/antimeridian/,
|
||||
/too large for imagery/,
|
||||
);
|
||||
const crossing = imagery({
|
||||
candidate: {
|
||||
product: 'S30',
|
||||
day: '2026-10-01',
|
||||
cloud: { min: 1, max: 2 },
|
||||
coverage: 'full',
|
||||
},
|
||||
reason: 'clear',
|
||||
errors: [],
|
||||
});
|
||||
const wrapped = composeCatalog({
|
||||
tools: coreTools,
|
||||
services: { imagery: crossing },
|
||||
});
|
||||
await assert.rejects(
|
||||
wrapped.call('get_recent_imagery', {
|
||||
area: { bbox: [179, 0, -179, 1] },
|
||||
}),
|
||||
/snapshot cannot cross the dateline/,
|
||||
);
|
||||
assert.equal(crossing.snapshots.length, 0);
|
||||
await assert.rejects(
|
||||
none.call('get_recent_imagery', { area: { bbox: [0, 85.5, 1, 86] } }),
|
||||
/±85° latitude/,
|
||||
|
||||
Reference in new issue
Block a user