feat(firms): a marker stand-in can set how far the camera stands from a fire it draws (#1832)

setMarkerStandIn takes an optional focusRangeM(record): when a click on a fire the stand-in draws moves the camera there, it stands off that many metres instead of the usual fire framing. A world focus request may carry its own rangeM; past the framed radius it replaces the kind's range.
This commit is contained in:
Sameh Khamis authored and GitHub committed 2026-11-18 17:46:31 -08:00
1 parent 0a9235cc69
commit cd144ecad5
6 files changed
+63 -3

No files matched your search

+27
View File
@@ -698,6 +698,7 @@ test('a click on a fire an application draws in place of the markers selects it
fireDetectionKey(fire),
'the stand-in decides, not the hidden glow under the click',
);
assert.equal('rangeM' in h.requests[0], false, 'the usual fire framing');
assert.equal(h.layer.getSelectedInfo().id, fireDetectionKey(fire));
assert.equal(getSelectedEntityContext().label, 'Fire · FRP 1520 MW');
assert.deepEqual(
@@ -716,6 +717,32 @@ test('a click on a fire an application draws in place of the markers selects it
}
});
test('a stand-in that draws a fire larger says how far the camera stands from it', () => {
const fire = makeFire();
const asked = [];
let range = 24_000;
const h = harness({ fires: [fire] });
try {
h.layer.setMarkerStandIn({
hitTest: () => ({ ...fire }),
focusRangeM: (record) => {
asked.push(fireDetectionKey(record));
return range;
},
});
h.click();
assert.deepEqual(asked, [fireDetectionKey(fire)]);
assert.equal(h.requests.at(-1).rangeM, 24_000);
// No range for this fire: the usual fire framing.
range = null;
h.click();
assert.equal(h.requests.length, 2);
assert.equal('rangeM' in h.requests.at(-1), false);
} finally {
h.cleanup();
}
});
test('a stand-in hit on a fire the layer does not show selects nothing', () => {
const fire = makeFire();
const h = harness({ fires: [fire] });
+4 -1
View File
@@ -78,8 +78,11 @@ export function createLifecycle({
* answers a detection record from the same source, or null) selects it
* and moves the camera to it as a click on its marker does, the selected
* fire's card shows, and a click on empty space clears the selection.
* Its optional `focusRangeM(record)` gives how far, in metres, the camera
* stands from a fire it draws when moving to it, for fires drawn larger
* than a marker; without one, or for null, the usual fire framing holds.
* `null` brings the markers back. The selection is kept either way.
* @param {?{hitTest: (screenPosition: {x: number, y: number}) => ?Object}} standIn
* @param {?{hitTest: (screenPosition: {x: number, y: number}) => ?Object, focusRangeM?: (record: Object) => ?number}} standIn
*/
setMarkerStandIn(standIn) {
layerState._standIn =
+4
View File
@@ -77,11 +77,15 @@ export function createSelection({
function selectAndFocusFire(fire) {
selectFire(fire);
// A stand-in that draws the fire larger than a marker says how far the
// camera stands from it (`setMarkerStandIn`).
const rangeM = layerState._standIn?.focusRangeM?.(fire);
requestWorldFocus({
kind: 'fire',
id: fireDetectionKey(fire),
label: t('FIRE'),
position: components.model.firePosition(fire),
...(Number.isFinite(rangeM) && rangeM > 0 ? { rangeM } : {}),
});
}
+6 -2
View File
@@ -85,7 +85,8 @@ export function routeWorldFocusRequest(event, runExplicitFocus, fly) {
* `keepView` (a click on it) keeps the camera's distance and angle: the eye
* moves, on a straight path, to where it sees the target in the centre with
* the view it has now (`keptViewFrom`). Any other is framed by its kind
* (`WORLD_FOCUS_FRAMING`).
* (`WORLD_FOCUS_FRAMING`); a target's own `rangeM`, past the framed radius,
* stands the camera off that far instead (a target larger than its kind).
*/
export function flyToWorldTarget(viewer, target = {}) {
const camera = findCamera(viewer);
@@ -118,7 +119,10 @@ export function flyToWorldTarget(viewer, target = {}) {
offset: {
heading,
pitch: toRadians(framing.pitchDeg),
range: framing.rangeM,
range:
Number.isFinite(target.rangeM) && target.rangeM > framing.radiusM
? target.rangeM
: framing.rangeM,
},
durationS: duration,
easing: 'cubicInOut',
+19
View File
@@ -206,6 +206,25 @@ test('fires frame wider than vessels — a fire is read by its surroundings', ()
);
});
test("a target's own range stands the camera off that far, past the framed radius", () => {
const range = (rangeM) => {
const camera = stubCamera();
flyToWorldTarget(bindFakeCesiumCamera({ camera }), {
kind: 'fire',
id: 'fire-1',
position: POSITION,
rangeM,
});
const { sphere, options } = camera.calls.flights[0];
assert.equal(sphere.radius, WORLD_FOCUS_FRAMING.fire.radiusM);
return options.offset.range;
};
assert.equal(range(24_000), 24_000);
// Inside the framed sphere, or not a number: the kind's own range.
for (const value of [WORLD_FOCUS_FRAMING.fire.radiusM, 0, -5, NaN, '9000'])
assert.equal(range(value), WORLD_FOCUS_FRAMING.fire.rangeM);
});
test('every framing is a real oblique standoff, not a nadir or an inside-out sphere', () => {
const kinds = Object.keys(WORLD_FOCUS_FRAMING);
assert.deepEqual(kinds.sort(), [