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
@@ -1,13 +1,16 @@
|
||||
/**
|
||||
* Draped-imagery renderer for the Recent Imagery layer: at most two GIBS
|
||||
* imagery layers (slot `a`, left of a swipe; slot `b`, right) on whichever
|
||||
* host the map stack offers. Against the basemap slot `a` splits left and
|
||||
* slot `b` stays empty. Every layer is removed from the collection that owns it, so a
|
||||
* host switch or a replaced image never strands one. Tile requests pass a
|
||||
* small semaphore of our own; Cesium's global request limits stay untouched.
|
||||
* Draped-imagery renderer for the Recent Imagery layer: at most two slots
|
||||
* (slot `a`, left of a swipe; slot `b`, right) on whichever host the map
|
||||
* stack offers. A box that crosses the dateline drapes two imagery layers
|
||||
* in that slot, one on each side of ±180, each a plain west <= east
|
||||
* rectangle (see `nonCrossingBoxes`). Against the
|
||||
* basemap slot `a` splits left and slot `b` stays empty. Every layer is
|
||||
* removed from the collection that owns it, so a host switch or a replaced
|
||||
* image never strands one. Tile requests pass a small semaphore of our own;
|
||||
* Cesium's global request limits stay untouched.
|
||||
*/
|
||||
import * as Cesium from 'cesium';
|
||||
import { PRODUCTS, gibsTemplate } from './model.js';
|
||||
import { PRODUCTS, gibsTemplate, nonCrossingBoxes } from './model.js';
|
||||
|
||||
const SLOT_IDS = ['a', 'b'];
|
||||
const SPLIT_ENUM = { left: 'LEFT', right: 'RIGHT', none: 'NONE' };
|
||||
@@ -80,7 +83,7 @@ export function createRecentImageryRenderer({
|
||||
let host = NO_HOST;
|
||||
let destroyed = false;
|
||||
const admission = { limit: maxTileRequests, inFlight: 0 };
|
||||
/** @type {Record<'a'|'b', null | { layer: object, collection: object, candidate: object, box: object, alpha: number, split: string }>} */
|
||||
/** @type {Record<'a'|'b', null | { layers: Array<object>, collection: object, candidate: object, box: object, alpha: number, split: string }>} */
|
||||
const owned = { a: null, b: null };
|
||||
|
||||
// One timer for both slots: any number of upstream deferrals while it is
|
||||
@@ -124,26 +127,48 @@ export function createRecentImageryRenderer({
|
||||
const record = owned[slotId];
|
||||
if (!record) return false;
|
||||
owned[slotId] = null;
|
||||
try {
|
||||
record.collection.remove(record.layer, true);
|
||||
} catch {
|
||||
/* the collection is already gone */
|
||||
for (const layer of record.layers) {
|
||||
try {
|
||||
record.collection.remove(layer, true);
|
||||
} catch {
|
||||
/* the collection is already gone */
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function applyLook(record) {
|
||||
record.layer.alpha = record.alpha;
|
||||
record.layer.splitDirection =
|
||||
const alpha = record.alpha;
|
||||
const splitDirection =
|
||||
cesium.SplitDirection?.[SPLIT_ENUM[record.split] || 'NONE'] ?? 0;
|
||||
for (const layer of record.layers) {
|
||||
layer.alpha = alpha;
|
||||
layer.splitDirection = splitDirection;
|
||||
}
|
||||
}
|
||||
|
||||
function mount(slotId, { candidate, box, alpha, split }) {
|
||||
const layer = host.collection.addImageryProvider(
|
||||
createProvider(candidate, box),
|
||||
);
|
||||
const rectangles = nonCrossingBoxes(box);
|
||||
const parts = rectangles.length ? rectangles : [box];
|
||||
// Build every provider before adding any layer, so a throw on the second
|
||||
// half of a dateline box cannot leave the first layer untracked.
|
||||
const providers = parts.map((part) => createProvider(candidate, part));
|
||||
const layers = [];
|
||||
try {
|
||||
for (const provider of providers)
|
||||
layers.push(host.collection.addImageryProvider(provider));
|
||||
} catch (error) {
|
||||
for (const layer of layers) {
|
||||
try {
|
||||
host.collection.remove(layer, true);
|
||||
} catch {
|
||||
/* the collection is already gone */
|
||||
}
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
owned[slotId] = {
|
||||
layer,
|
||||
layers,
|
||||
collection: host.collection,
|
||||
candidate,
|
||||
box,
|
||||
@@ -248,7 +273,7 @@ export function createRecentImageryRenderer({
|
||||
return out;
|
||||
},
|
||||
|
||||
/** Number of layers this renderer owns (never above two). */
|
||||
/** Number of slots this renderer owns (never above two). A dateline box uses two imagery layers in its slot. */
|
||||
ownedCount() {
|
||||
return SLOT_IDS.filter((slotId) => owned[slotId]).length;
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user