mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 17:52:21 +00:00
Merge branch 'main' into fix/shortcuts-modifier-keys
This commit is contained in:
1214 files changed
+37676
-9143
No files matched your search
@@ -0,0 +1,428 @@
|
||||
import { registerWorldOverlayPaintLane } from '../../overlays/worldOverlay.js';
|
||||
import { fromDegrees } from '../../geo/ellipsoid.js';
|
||||
import {
|
||||
earthquakeContourRings,
|
||||
earthquakeContourScale,
|
||||
earthquakeContourShape,
|
||||
earthquakeRippleRings,
|
||||
EARTHQUAKE_RIPPLE_PERIOD_MS,
|
||||
} from '../../layers/earthquakes/model.js';
|
||||
|
||||
/** Points around each contour line: smooth at the largest disc on screen. */
|
||||
export const RIPPLE_RING_SEGMENTS = 96;
|
||||
/** An index contour's width, and every other line's. */
|
||||
const INDEX_WIDTH_PX = 2;
|
||||
const LINE_WIDTH_PX = 1.1;
|
||||
/**
|
||||
* The overlay lane the lines paint in: the magnitude labels' own. A lane's
|
||||
* custom painters run before its entries, so the lines sit under the labels
|
||||
* and under the selected quake's card.
|
||||
*/
|
||||
export const RIPPLE_PAINT_LANE = 'ambient-label';
|
||||
/**
|
||||
* The selected disc's fill, [offset, alpha] from the epicentre (0) to its
|
||||
* outer circle (1): strongest in the middle, fading out to nothing at the
|
||||
* edge.
|
||||
*/
|
||||
export const DISC_FADE = Object.freeze([
|
||||
[0, 0.42],
|
||||
[0.35, 0.26],
|
||||
[0.75, 0.1],
|
||||
[1, 0],
|
||||
]);
|
||||
/**
|
||||
* Each contour wave's fill, out to its own line: clear inside, tinting
|
||||
* toward the line; times the wave's own fade.
|
||||
*/
|
||||
export const WAVE_FADE = Object.freeze([
|
||||
[0, 0],
|
||||
[0.55, 0],
|
||||
[1, 0.2],
|
||||
]);
|
||||
|
||||
/**
|
||||
* `rgb(r,g,b)` (or `rgba`) as a function of alpha, for gradient stops; any
|
||||
* other colour keeps its own alpha.
|
||||
*/
|
||||
export function cssWithAlpha(color) {
|
||||
const m = /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/.exec(String(color));
|
||||
if (!m) return () => color;
|
||||
const rgb = `${m[1]},${m[2]},${m[3]}`;
|
||||
return (alpha) => `rgba(${rgb},${Math.max(0, Math.min(1, alpha))})`;
|
||||
}
|
||||
|
||||
/**
|
||||
* How many times the lines run out to the edge after a quake is selected
|
||||
* before they rest as still contours and stop asking for frames: earthquakes
|
||||
* otherwise hold no render (docs/CURRENT-STATE.md, "Earthquake discs are
|
||||
* STATIC geometry"), and a quake can stay selected for hours.
|
||||
*/
|
||||
export const RIPPLE_ACTIVE_CYCLES = 3;
|
||||
|
||||
let reducedMotionQuery;
|
||||
/**
|
||||
* The viewer's reduced-motion setting, live: the media query is kept, so a
|
||||
* change mid-session is read at the next paint and tick.
|
||||
*/
|
||||
const reducedMotion = () => {
|
||||
try {
|
||||
reducedMotionQuery ??=
|
||||
globalThis.matchMedia?.('(prefers-reduced-motion: reduce)') ?? null;
|
||||
return reducedMotionQuery?.matches === true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/** How often the rings re-read the ground height under the quake. */
|
||||
const HEIGHT_READ_INTERVAL_MS = 500;
|
||||
/**
|
||||
* A ground height the rings accept, in metres: the Dead Sea shore to above
|
||||
* Everest. Anything else is a bad sample (a hit on something drawn above
|
||||
* the ground, or a broken tile), and the rings stay where they are.
|
||||
*/
|
||||
const groundHeightOk = (h) => Number.isFinite(h) && h >= -500 && h <= 9000;
|
||||
|
||||
/**
|
||||
* The selected earthquake's contour lines, painted on the world overlay:
|
||||
* wavy closed lines, shaped by the quake's id (earthquakeContourShape), run
|
||||
* from the marker out to the disc's edge and fade there, one after another,
|
||||
* for RIPPLE_ACTIVE_CYCLES runs after a quake is selected and only while it
|
||||
* is on screen, then rest as still contours. They never cross, and every third is
|
||||
* a heavier index contour, as on a topographic map. Nothing is drawn, and no
|
||||
* frame is asked for, while no quake is selected. With reduced motion the
|
||||
* lines hold still.
|
||||
*
|
||||
* A line is drawn in the tangent plane at the epicentre: at the largest
|
||||
* disc (M6, 64 km) it sits about 320 m above the curved ground at its edge
|
||||
* (64² / 2R), about 1.5 px off the drawn disc at the 220 km, -45° framing a
|
||||
* label click flies to (900 px tall, 35° field of view); less for smaller
|
||||
* quakes, as the offset grows with the square of the radius.
|
||||
* @param {object} [deps]
|
||||
* @param {Function} [deps.registerLane] `registerWorldOverlayPaintLane`.
|
||||
* @param {() => number} [deps.now] Steady clock, ms.
|
||||
* @param {(cb: Function) => number} [deps.requestFrame]
|
||||
* @param {(handle: number) => void} [deps.cancelFrame]
|
||||
* @param {() => boolean} [deps.prefersReducedMotion]
|
||||
* @returns {{show: Function, hide: Function, dispose: Function}}
|
||||
*/
|
||||
export function createEarthquakeRipples({
|
||||
registerLane = registerWorldOverlayPaintLane,
|
||||
now = () => globalThis.performance?.now?.() ?? Date.now(),
|
||||
requestFrame = (cb) => globalThis.requestAnimationFrame?.(cb) ?? null,
|
||||
cancelFrame = (handle) => globalThis.cancelAnimationFrame?.(handle),
|
||||
prefersReducedMotion = reducedMotion,
|
||||
} = {}) {
|
||||
let lane = null;
|
||||
let target = null;
|
||||
let frameHandle = null;
|
||||
// When the running lines settle into still contours (the selection's
|
||||
// bound), and whether the last paint found the quake on screen.
|
||||
let startedAt = 0;
|
||||
let settlesAt = 0;
|
||||
let onScreen = false;
|
||||
/** Whether the lines run now: in the window, and motion allowed. */
|
||||
const running = () => now() < settlesAt && !prefersReducedMotion();
|
||||
// Unit offsets around the line in the epicentre's tangent plane, packed
|
||||
// x, y, z per point: north·cos + east·sin.
|
||||
const offsets = new Float64Array((RIPPLE_RING_SEGMENTS + 1) * 3);
|
||||
const angles = new Float64Array(RIPPLE_RING_SEGMENTS + 1);
|
||||
for (let i = 0; i <= RIPPLE_RING_SEGMENTS; i++)
|
||||
angles[i] = (2 * Math.PI * i) / RIPPLE_RING_SEGMENTS;
|
||||
|
||||
// Screen points, reused every frame.
|
||||
const at = { x: 0, y: 0 };
|
||||
const centerAt = { x: 0, y: 0 };
|
||||
const eastAt = { x: 0, y: 0 };
|
||||
const northAt = { x: 0, y: 0 };
|
||||
|
||||
/** Project an ECEF point to CSS pixels; false when it is behind the eye. */
|
||||
function project(frame, px, py, pz, out) {
|
||||
const m = frame.viewProjectionMatrix;
|
||||
const w = m[3] * px + m[7] * py + m[11] * pz + m[15];
|
||||
if (w <= 0) return false;
|
||||
out.x =
|
||||
((m[0] * px + m[4] * py + m[8] * pz + m[12]) / w / 2 + 0.5) * frame.width;
|
||||
out.y =
|
||||
(0.5 - (m[1] * px + m[5] * py + m[9] * pz + m[13]) / w / 2) *
|
||||
frame.height;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trace one closed line at `fraction` of the disc's radius (`shaped`:
|
||||
* as a contour, else the disc's own circle). True when all of it is in
|
||||
* front of the eye, so it can be filled.
|
||||
*/
|
||||
function trace(frame, fraction, shaped) {
|
||||
const { ctx } = frame;
|
||||
const center = target.center;
|
||||
const reach = fraction * target.radiusM;
|
||||
ctx.beginPath();
|
||||
let pen = false;
|
||||
let whole = true;
|
||||
for (let i = 0; i <= RIPPLE_RING_SEGMENTS; i++) {
|
||||
// The last point repeats the first angle, so the line closes.
|
||||
const r = shaped
|
||||
? reach * earthquakeContourScale(target.shape, angles[i], fraction)
|
||||
: reach;
|
||||
const visible = project(
|
||||
frame,
|
||||
center.x + offsets[i * 3] * r,
|
||||
center.y + offsets[i * 3 + 1] * r,
|
||||
center.z + offsets[i * 3 + 2] * r,
|
||||
at,
|
||||
);
|
||||
if (!visible) {
|
||||
pen = false;
|
||||
whole = false;
|
||||
continue;
|
||||
}
|
||||
if (pen) ctx.lineTo(at.x, at.y);
|
||||
else ctx.moveTo(at.x, at.y);
|
||||
pen = true;
|
||||
}
|
||||
return whole;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill the traced path with a radial gradient laid on the ground: the
|
||||
* canvas places a path when it is traced and a gradient when it fills, so
|
||||
* under the disc's ground-to-screen transform the gradient's circle
|
||||
* becomes the disc's ellipse on screen while the path stays exact.
|
||||
* @param {Array<[number, number]>} stops [offset, alpha], out to `reach`.
|
||||
*/
|
||||
function fillGround(ctx, reach, stops) {
|
||||
ctx.save();
|
||||
ctx.transform(
|
||||
eastAt.x - centerAt.x,
|
||||
eastAt.y - centerAt.y,
|
||||
northAt.x - centerAt.x,
|
||||
northAt.y - centerAt.y,
|
||||
centerAt.x,
|
||||
centerAt.y,
|
||||
);
|
||||
const gradient = ctx.createRadialGradient(0, 0, 0, 0, 0, reach);
|
||||
for (const [offset, alpha] of stops)
|
||||
gradient.addColorStop(offset, target.rgba(alpha));
|
||||
ctx.fillStyle = gradient;
|
||||
ctx.globalAlpha = 1;
|
||||
ctx.fill();
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether any of the disc is in the viewport: its centre's screen point,
|
||||
* padded by its larger screen radius (or, seen edge-on, the centre alone).
|
||||
*/
|
||||
function discOnScreen(frame, c, e, n) {
|
||||
if (!Number.isFinite(c.x) || !Number.isFinite(c.y)) return false;
|
||||
const pad = Math.max(
|
||||
Math.hypot(e.x - c.x, e.y - c.y) || 0,
|
||||
Math.hypot(n.x - c.x, n.y - c.y) || 0,
|
||||
);
|
||||
return (
|
||||
c.x + pad >= 0 &&
|
||||
c.x - pad <= frame.width &&
|
||||
c.y + pad >= 0 &&
|
||||
c.y - pad <= frame.height
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-read the ground height under the quake, at most twice a second while
|
||||
* painting: the ground loads and refines as the camera comes in, and the
|
||||
* rings move onto it once it differs by more than a metre.
|
||||
*/
|
||||
function settleHeight() {
|
||||
if (!target.heightAt) return;
|
||||
const at = now();
|
||||
if (at - target.heightReadAt < HEIGHT_READ_INTERVAL_MS) return;
|
||||
target.heightReadAt = at;
|
||||
let height = null;
|
||||
try {
|
||||
height = target.heightAt();
|
||||
} catch {
|
||||
height = null;
|
||||
}
|
||||
if (!groundHeightOk(height) || Math.abs(height - target.heightM) <= 1)
|
||||
return;
|
||||
target.heightM = height;
|
||||
target.center = fromDegrees(target.lon, target.lat, height);
|
||||
}
|
||||
|
||||
function paint(frame) {
|
||||
if (!target) return;
|
||||
const { ctx } = frame;
|
||||
settleHeight();
|
||||
const center = target.center;
|
||||
onScreen = false;
|
||||
if (frame.occluder?.isPointVisible?.(center) === false) return;
|
||||
const R = target.radiusM;
|
||||
// The disc's ground frame on screen: its centre, and a radius east and
|
||||
// north. Seen edge-on (or partly behind the eye) it is not filled.
|
||||
const centerOk = project(frame, center.x, center.y, center.z, centerAt);
|
||||
const eastOk = project(
|
||||
frame,
|
||||
center.x + target.east.x * R,
|
||||
center.y + target.east.y * R,
|
||||
center.z + target.east.z * R,
|
||||
eastAt,
|
||||
);
|
||||
const northOk = project(
|
||||
frame,
|
||||
center.x + target.north.x * R,
|
||||
center.y + target.north.y * R,
|
||||
center.z + target.north.z * R,
|
||||
northAt,
|
||||
);
|
||||
let fills = centerOk && eastOk && northOk;
|
||||
if (fills) {
|
||||
const area =
|
||||
(eastAt.x - centerAt.x) * (northAt.y - centerAt.y) -
|
||||
(eastAt.y - centerAt.y) * (northAt.x - centerAt.x);
|
||||
fills = Math.abs(area) > 1;
|
||||
}
|
||||
onScreen =
|
||||
centerOk &&
|
||||
discOnScreen(
|
||||
frame,
|
||||
centerAt,
|
||||
eastOk ? eastAt : centerAt,
|
||||
northOk ? northAt : centerAt,
|
||||
);
|
||||
// The disc: strongest at the epicentre, fading out to its outer circle.
|
||||
if (fills && trace(frame, 1, false)) fillGround(ctx, 1, DISC_FADE);
|
||||
const animate = running();
|
||||
const rings = animate
|
||||
? earthquakeRippleRings(now() - startedAt)
|
||||
: earthquakeContourRings();
|
||||
// Brought back into view while the window lasts: run again.
|
||||
if (animate && onScreen && frameHandle === null && lane)
|
||||
frameHandle = requestFrame(tick);
|
||||
ctx.strokeStyle = target.color;
|
||||
ctx.lineJoin = 'round';
|
||||
for (const { fraction, alpha, index } of rings) {
|
||||
if (!(alpha > 0.01)) continue;
|
||||
const whole = trace(frame, fraction, true);
|
||||
// Each wave: clear inside, tinting toward its own line, as it fades.
|
||||
if (fills && whole)
|
||||
fillGround(
|
||||
ctx,
|
||||
fraction,
|
||||
WAVE_FADE.map(([offset, a]) => [offset, a * alpha]),
|
||||
);
|
||||
ctx.lineWidth = index ? INDEX_WIDTH_PX : LINE_WIDTH_PX;
|
||||
ctx.globalAlpha = alpha;
|
||||
ctx.stroke();
|
||||
}
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
|
||||
/** Ask for one more frame while the lines run (one request at a time). */
|
||||
function tick() {
|
||||
frameHandle = null;
|
||||
if (!target || !lane) return;
|
||||
// Settled, or out of sight: one last paint draws the still contours
|
||||
// (or nothing), and no more frames are asked for. A paint that finds it
|
||||
// on screen again inside the window starts the frames again.
|
||||
if (!running() || !onScreen) {
|
||||
lane.requestPaint();
|
||||
return;
|
||||
}
|
||||
lane.requestPaint();
|
||||
frameHandle = requestFrame(tick);
|
||||
}
|
||||
|
||||
function stopFrames() {
|
||||
if (frameHandle !== null) cancelFrame(frameHandle);
|
||||
frameHandle = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the contour lines around one quake, replacing any other.
|
||||
* @param {{id: string, lon: number, lat: number, heightM?: number, heightAt?: () => number|null, radiusM: number, color: string}} next
|
||||
* @param {{restart?: boolean}} [options] `restart: false` updates the
|
||||
* same quake in place (a feed refresh) without running it again.
|
||||
*/
|
||||
function show(next, { restart = true } = {}) {
|
||||
if (
|
||||
!next ||
|
||||
!Number.isFinite(next.lon) ||
|
||||
!Number.isFinite(next.lat) ||
|
||||
!(next.radiusM > 0)
|
||||
) {
|
||||
hide();
|
||||
return;
|
||||
}
|
||||
const sameQuake = target?.id === next.id;
|
||||
const lon = (next.lon * Math.PI) / 180;
|
||||
const lat = (next.lat * Math.PI) / 180;
|
||||
const [sinLon, cosLon] = [Math.sin(lon), Math.cos(lon)];
|
||||
const [sinLat, cosLat] = [Math.sin(lat), Math.cos(lat)];
|
||||
for (let i = 0; i <= RIPPLE_RING_SEGMENTS; i++) {
|
||||
const [c, s] = [Math.cos(angles[i]), Math.sin(angles[i])];
|
||||
offsets[i * 3] = c * -sinLat * cosLon + s * -sinLon;
|
||||
offsets[i * 3 + 1] = c * -sinLat * sinLon + s * cosLon;
|
||||
offsets[i * 3 + 2] = c * cosLat;
|
||||
}
|
||||
target = {
|
||||
id: next.id,
|
||||
// On the ground the disc is draped on: the height known now, then
|
||||
// re-read while painting (see `settleHeight`), since a label's fly-to
|
||||
// starts from far away, before that ground has loaded.
|
||||
lon: next.lon,
|
||||
lat: next.lat,
|
||||
heightM: groundHeightOk(next.heightM) ? next.heightM : 0,
|
||||
heightAt: typeof next.heightAt === 'function' ? next.heightAt : null,
|
||||
heightReadAt: -Infinity,
|
||||
center: fromDegrees(
|
||||
next.lon,
|
||||
next.lat,
|
||||
groundHeightOk(next.heightM) ? next.heightM : 0,
|
||||
),
|
||||
radiusM: next.radiusM,
|
||||
color: next.color || 'rgb(255,165,0)',
|
||||
shape: earthquakeContourShape(next.id),
|
||||
rgba: cssWithAlpha(next.color || 'rgb(255,165,0)'),
|
||||
// Angle 0 is north and a quarter turn is east (see `offsets`).
|
||||
north: { x: offsets[0], y: offsets[1], z: offsets[2] },
|
||||
east: {
|
||||
x: offsets[(RIPPLE_RING_SEGMENTS / 4) * 3],
|
||||
y: offsets[(RIPPLE_RING_SEGMENTS / 4) * 3 + 1],
|
||||
z: offsets[(RIPPLE_RING_SEGMENTS / 4) * 3 + 2],
|
||||
},
|
||||
};
|
||||
if (restart || !sameQuake) {
|
||||
startedAt = now();
|
||||
settlesAt =
|
||||
startedAt + RIPPLE_ACTIVE_CYCLES * EARTHQUAKE_RIPPLE_PERIOD_MS;
|
||||
// Assume it is in view until a paint says otherwise.
|
||||
onScreen = true;
|
||||
}
|
||||
lane ??= registerLane(RIPPLE_PAINT_LANE, paint, {
|
||||
id: 'earthquake-ripples',
|
||||
});
|
||||
lane.setActive(true);
|
||||
lane.requestPaint();
|
||||
// A refresh while the disc is out of sight asks for no frame; a paint
|
||||
// that finds it on screen again starts them (a restart sets onScreen).
|
||||
if (running() && onScreen && frameHandle === null)
|
||||
frameHandle = requestFrame(tick);
|
||||
}
|
||||
|
||||
function hide() {
|
||||
stopFrames();
|
||||
if (!target) return;
|
||||
target = null;
|
||||
lane?.setActive(false);
|
||||
}
|
||||
|
||||
function dispose() {
|
||||
hide();
|
||||
lane?.unregister();
|
||||
lane = null;
|
||||
}
|
||||
|
||||
return { show, hide, dispose };
|
||||
}
|
||||
@@ -0,0 +1,452 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import {
|
||||
DISC_FADE,
|
||||
cssWithAlpha,
|
||||
RIPPLE_ACTIVE_CYCLES,
|
||||
RIPPLE_PAINT_LANE,
|
||||
RIPPLE_RING_SEGMENTS,
|
||||
createEarthquakeRipples,
|
||||
} from './earthquakeRipples.js';
|
||||
import {
|
||||
EARTHQUAKE_RIPPLE_PERIOD_MS,
|
||||
EARTHQUAKE_RIPPLE_RINGS,
|
||||
} from '../../layers/earthquakes/model.js';
|
||||
import { fromDegrees } from '../../geo/ellipsoid.js';
|
||||
|
||||
/** A paint lane, frame clock and canvas the test steps by hand. */
|
||||
function harness({ reducedMotion = false } = {}) {
|
||||
let motionReduced = reducedMotion;
|
||||
const lanes = [];
|
||||
const frames = new Map();
|
||||
let nextFrame = 1;
|
||||
let clock = 0;
|
||||
const ripples = createEarthquakeRipples({
|
||||
registerLane(laneId, painter, options) {
|
||||
const lane = {
|
||||
laneId,
|
||||
painter,
|
||||
options,
|
||||
active: false,
|
||||
paints: 0,
|
||||
unregistered: false,
|
||||
setActive(next) {
|
||||
lane.active = next;
|
||||
},
|
||||
requestPaint() {
|
||||
lane.paints++;
|
||||
},
|
||||
unregister() {
|
||||
lane.unregistered = true;
|
||||
},
|
||||
};
|
||||
lanes.push(lane);
|
||||
return lane;
|
||||
},
|
||||
now: () => clock,
|
||||
requestFrame(cb) {
|
||||
const handle = nextFrame++;
|
||||
frames.set(handle, cb);
|
||||
return handle;
|
||||
},
|
||||
cancelFrame: (handle) => frames.delete(handle),
|
||||
prefersReducedMotion: () => motionReduced,
|
||||
});
|
||||
const strokes = [];
|
||||
const fills = [];
|
||||
let path = null;
|
||||
const ctx = {
|
||||
globalAlpha: 1,
|
||||
beginPath() {
|
||||
path = { moves: 0, lines: 0 };
|
||||
},
|
||||
moveTo() {
|
||||
path.moves++;
|
||||
},
|
||||
lineTo() {
|
||||
path.lines++;
|
||||
},
|
||||
stroke() {
|
||||
strokes.push({
|
||||
...path,
|
||||
alpha: ctx.globalAlpha,
|
||||
color: ctx.strokeStyle,
|
||||
width: ctx.lineWidth,
|
||||
});
|
||||
},
|
||||
// Fills record their path, gradient and the transform they fill under.
|
||||
saved: 0,
|
||||
transformed: null,
|
||||
save() {
|
||||
ctx.saved++;
|
||||
},
|
||||
restore() {
|
||||
ctx.saved--;
|
||||
ctx.transformed = null;
|
||||
},
|
||||
transform(...args) {
|
||||
ctx.transformed = args;
|
||||
},
|
||||
createRadialGradient(...circles) {
|
||||
const gradient = { circles, stops: [] };
|
||||
gradient.addColorStop = (offset, color) =>
|
||||
gradient.stops.push([offset, color]);
|
||||
return gradient;
|
||||
},
|
||||
fill() {
|
||||
fills.push({
|
||||
...path,
|
||||
gradient: ctx.fillStyle,
|
||||
transform: ctx.transformed,
|
||||
});
|
||||
},
|
||||
};
|
||||
// w = 1 everywhere: every point is in front of the eye.
|
||||
const matrix = new Float64Array(16);
|
||||
matrix[0] = 1e-7;
|
||||
matrix[5] = 1e-7;
|
||||
matrix[15] = 1;
|
||||
const frame = (visible = true) => ({
|
||||
ctx,
|
||||
width: 800,
|
||||
height: 600,
|
||||
viewProjectionMatrix: matrix,
|
||||
occluder: { isPointVisible: () => visible },
|
||||
});
|
||||
return {
|
||||
ripples,
|
||||
lanes,
|
||||
frames,
|
||||
strokes,
|
||||
fills,
|
||||
frame,
|
||||
matrix,
|
||||
setReducedMotion(next) {
|
||||
motionReduced = next;
|
||||
},
|
||||
advance(ms) {
|
||||
clock += ms;
|
||||
},
|
||||
/** Run the pending animation frames once. */
|
||||
step() {
|
||||
const pending = [...frames.entries()];
|
||||
frames.clear();
|
||||
for (const [, cb] of pending) cb();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const target = {
|
||||
id: 'ak1',
|
||||
lon: -153.3,
|
||||
lat: 60,
|
||||
radiusM: 32000,
|
||||
color: 'rgb(255,0,0)',
|
||||
};
|
||||
|
||||
test('nothing is registered or animated until a quake is selected', () => {
|
||||
const h = harness();
|
||||
assert.equal(h.lanes.length, 0);
|
||||
assert.equal(h.frames.size, 0);
|
||||
h.ripples.hide();
|
||||
assert.equal(h.frames.size, 0);
|
||||
});
|
||||
|
||||
test('a selected quake animates one ring set, one frame request at a time', () => {
|
||||
const h = harness();
|
||||
h.ripples.show(target);
|
||||
const [lane] = h.lanes;
|
||||
assert.equal(lane.laneId, RIPPLE_PAINT_LANE);
|
||||
assert.equal(RIPPLE_PAINT_LANE, 'ambient-label', 'under the labels');
|
||||
assert.equal(lane.active, true);
|
||||
assert.equal(h.frames.size, 1);
|
||||
h.ripples.show({ ...target, id: 'ak2' });
|
||||
assert.equal(h.lanes.length, 1, 'the lane is reused');
|
||||
assert.equal(h.frames.size, 1, 'still one frame loop');
|
||||
const before = lane.paints;
|
||||
h.step();
|
||||
h.step();
|
||||
assert.equal(lane.paints, before + 2, 'one repaint per frame');
|
||||
assert.equal(h.frames.size, 1);
|
||||
|
||||
h.advance(600);
|
||||
lane.painter(h.frame());
|
||||
// At 600 ms every line is between the marker and the edge, so all draw.
|
||||
assert.equal(h.strokes.length, EARTHQUAKE_RIPPLE_RINGS);
|
||||
assert.deepEqual(
|
||||
h.strokes.map((stroke) => stroke.width),
|
||||
[2, 1.1, 1.1, 2, 1.1, 1.1],
|
||||
'every third line is an index contour',
|
||||
);
|
||||
for (const stroke of h.strokes) {
|
||||
assert.equal(stroke.moves, 1, 'one unbroken ring');
|
||||
assert.equal(stroke.lines, RIPPLE_RING_SEGMENTS);
|
||||
assert.equal(stroke.color, 'rgb(255,0,0)');
|
||||
assert.ok(stroke.alpha > 0 && stroke.alpha <= 1);
|
||||
}
|
||||
|
||||
h.ripples.hide();
|
||||
assert.equal(lane.active, false);
|
||||
assert.equal(h.frames.size, 0, 'no frames asked for once hidden');
|
||||
h.strokes.length = 0;
|
||||
lane.painter(h.frame());
|
||||
assert.equal(h.strokes.length, 0);
|
||||
});
|
||||
|
||||
test('rings are skipped behind the globe and broken behind the eye', () => {
|
||||
const h = harness();
|
||||
h.ripples.show(target);
|
||||
h.advance(600);
|
||||
const [lane] = h.lanes;
|
||||
lane.painter(h.frame(false));
|
||||
assert.equal(h.strokes.length, 0, 'epicentre over the horizon');
|
||||
|
||||
// Points with negative x fall behind the eye: each ring breaks there.
|
||||
const frame = h.frame();
|
||||
frame.viewProjectionMatrix[3] = 1e-6;
|
||||
const center = fromDegrees(target.lon, target.lat);
|
||||
frame.viewProjectionMatrix[15] = -1e-6 * center.x;
|
||||
lane.painter(frame);
|
||||
assert.equal(h.strokes.length, EARTHQUAKE_RIPPLE_RINGS);
|
||||
for (const stroke of h.strokes)
|
||||
assert.ok(stroke.lines < RIPPLE_RING_SEGMENTS, 'part of each ring hidden');
|
||||
});
|
||||
|
||||
test('reduced motion draws still contour rings and asks for no frames', () => {
|
||||
const h = harness({ reducedMotion: true });
|
||||
h.ripples.show(target);
|
||||
assert.equal(h.frames.size, 0);
|
||||
assert.equal(h.lanes[0].paints, 1, 'painted once');
|
||||
h.lanes[0].painter(h.frame());
|
||||
assert.equal(h.strokes.length, EARTHQUAKE_RIPPLE_RINGS);
|
||||
assert.ok(h.strokes.every((stroke) => stroke.alpha === 0.7));
|
||||
});
|
||||
|
||||
test('an unusable target hides the rings; dispose releases the lane', () => {
|
||||
const h = harness();
|
||||
h.ripples.show(target);
|
||||
h.ripples.show({ ...target, radiusM: 0 });
|
||||
assert.equal(h.lanes[0].active, false);
|
||||
assert.equal(h.frames.size, 0);
|
||||
h.ripples.dispose();
|
||||
assert.equal(h.lanes[0].unregistered, true);
|
||||
// Shown again after dispose, it registers a fresh lane.
|
||||
h.ripples.show(target);
|
||||
assert.equal(h.lanes.length, 2);
|
||||
h.ripples.dispose();
|
||||
});
|
||||
|
||||
test('contour lines are wavy, the same for a quake every time, and inside the disc', () => {
|
||||
const h = harness();
|
||||
h.ripples.show(target);
|
||||
h.advance(600);
|
||||
// An identity-like projection: screen x, y follow ECEF y, z, so the
|
||||
// distance from the projected epicentre measures each point's radius.
|
||||
const frame = h.frame();
|
||||
const m = frame.viewProjectionMatrix;
|
||||
m[0] = 0;
|
||||
m[5] = 0;
|
||||
m[4] = 1e-6;
|
||||
m[9] = 1e-6;
|
||||
const points = [];
|
||||
const ctx = frame.ctx;
|
||||
const record = (x, y) => points.at(-1).push([x, y]);
|
||||
ctx.beginPath = () => points.push([]);
|
||||
ctx.moveTo = record;
|
||||
ctx.lineTo = record;
|
||||
ctx.stroke = () => {};
|
||||
h.lanes[0].painter(frame);
|
||||
const center = fromDegrees(target.lon, target.lat);
|
||||
const cx = (center.y * 1e-6 * 0.5 + 0.5) * 800;
|
||||
const cy = (0.5 - center.z * 1e-6 * 0.5) * 600;
|
||||
const spread = (line) => {
|
||||
const radii = line.map(([x, y]) => Math.hypot(x - cx, y - cy));
|
||||
return Math.max(...radii) / Math.min(...radii);
|
||||
};
|
||||
// The disc's outer circle first (filled, not stroked), then each line.
|
||||
assert.equal(points.length, EARTHQUAKE_RIPPLE_RINGS + 1);
|
||||
points.shift();
|
||||
assert.ok(
|
||||
points.every((line) => spread(line) > 1.05),
|
||||
'not circles: each line dents in and out',
|
||||
);
|
||||
for (const line of points) {
|
||||
const [first, last] = [line[0], line.at(-1)];
|
||||
assert.ok(
|
||||
Math.hypot(first[0] - last[0], first[1] - last[1]) < 1e-6,
|
||||
'closed',
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('the disc fades out to its outer circle; each wave fills with a fade', () => {
|
||||
const h = harness();
|
||||
h.ripples.show(target);
|
||||
h.advance(600);
|
||||
// A projection where east and north span the screen: the disc is seen
|
||||
// from above, so its ground frame can be filled.
|
||||
const frame = h.frame();
|
||||
const m = frame.viewProjectionMatrix;
|
||||
m[0] = 0;
|
||||
m[5] = 0;
|
||||
m[4] = 1e-6;
|
||||
m[9] = 1e-6;
|
||||
h.lanes[0].painter(frame);
|
||||
assert.equal(h.fills.length, 1 + EARTHQUAKE_RIPPLE_RINGS);
|
||||
const [disc, ...waves] = h.fills;
|
||||
assert.equal(disc.lines, RIPPLE_RING_SEGMENTS, 'the whole outer circle');
|
||||
assert.deepEqual(disc.gradient.circles, [0, 0, 0, 0, 0, 1]);
|
||||
assert.deepEqual(
|
||||
disc.gradient.stops,
|
||||
DISC_FADE.map(([offset, alpha]) => [offset, `rgba(255,0,0,${alpha})`]),
|
||||
);
|
||||
assert.equal(disc.gradient.stops.at(-1)[1], 'rgba(255,0,0,0)', 'fades out');
|
||||
assert.ok(disc.transform, 'filled under the ground-to-screen transform');
|
||||
assert.equal(h.fills.length, waves.length + 1);
|
||||
for (const wave of waves) {
|
||||
const reach = wave.gradient.circles[5];
|
||||
assert.ok(reach > 0 && reach < 1, 'out to its own line');
|
||||
assert.equal(wave.gradient.stops[0][1], 'rgba(255,0,0,0)', 'clear inside');
|
||||
}
|
||||
// The transforms were undone: nothing leaks into the labels' painting.
|
||||
assert.equal(frame.ctx.saved, 0);
|
||||
// Seen edge-on, the ground frame has no area: lines only, no fills.
|
||||
h.fills.length = 0;
|
||||
m[9] = 0;
|
||||
m[5] = 0;
|
||||
h.lanes[0].painter(frame);
|
||||
assert.equal(h.fills.length, 0);
|
||||
});
|
||||
|
||||
test('cssWithAlpha turns rgb into rgba stops', () => {
|
||||
assert.equal(cssWithAlpha('rgb(255,165,0)')(0.25), 'rgba(255,165,0,0.25)');
|
||||
assert.equal(cssWithAlpha('rgba(1, 2, 3, 0.5)')(2), 'rgba(1,2,3,1)');
|
||||
assert.equal(cssWithAlpha('red')(0.3), 'red');
|
||||
});
|
||||
|
||||
test('the lines run a bounded time after a selection, then rest without frames', () => {
|
||||
const h = harness();
|
||||
h.ripples.show(target);
|
||||
const [lane] = h.lanes;
|
||||
const window = RIPPLE_ACTIVE_CYCLES * EARTHQUAKE_RIPPLE_PERIOD_MS;
|
||||
assert.ok(window <= 15_000, 'about a quarter of a minute at most');
|
||||
let frames = 0;
|
||||
for (let t = 0; t < window * 3; t += 16) {
|
||||
if (!h.frames.size) break;
|
||||
lane.painter(h.frame());
|
||||
h.advance(16);
|
||||
h.step();
|
||||
frames++;
|
||||
}
|
||||
assert.equal(h.frames.size, 0, 'no frame asked for once settled');
|
||||
assert.ok(frames <= Math.ceil(window / 16) + 2, `bounded: ${frames} frames`);
|
||||
// At rest the lines hold still as readable contours.
|
||||
h.strokes.length = 0;
|
||||
lane.painter(h.frame());
|
||||
assert.equal(h.strokes.length, EARTHQUAKE_RIPPLE_RINGS);
|
||||
assert.ok(h.strokes.every((stroke) => stroke.alpha === 0.7));
|
||||
// A parked camera repainting the overlay does not start them again.
|
||||
lane.painter(h.frame());
|
||||
assert.equal(h.frames.size, 0);
|
||||
// A new selection runs again.
|
||||
h.ripples.show({ ...target, id: 'ak2' });
|
||||
assert.equal(h.frames.size, 1);
|
||||
h.ripples.dispose();
|
||||
});
|
||||
|
||||
test('off screen the frames stop; back in view inside the window they resume', () => {
|
||||
const h = harness();
|
||||
h.ripples.show(target);
|
||||
const [lane] = h.lanes;
|
||||
// Behind the globe.
|
||||
lane.painter(h.frame(false));
|
||||
const paints = lane.paints;
|
||||
h.step();
|
||||
assert.equal(h.frames.size, 0, 'stopped while out of sight');
|
||||
assert.equal(lane.paints, paints + 1, 'one last paint, then none');
|
||||
h.step();
|
||||
assert.equal(lane.paints, paints + 1);
|
||||
// Panned away: the disc is far off the viewport.
|
||||
h.ripples.show(target);
|
||||
const away = h.frame();
|
||||
away.viewProjectionMatrix[12] = 50;
|
||||
lane.painter(away);
|
||||
h.step();
|
||||
assert.equal(h.frames.size, 0);
|
||||
// The camera brings it back while the window lasts.
|
||||
away.viewProjectionMatrix[12] = 0;
|
||||
lane.painter(h.frame());
|
||||
assert.equal(h.frames.size, 1, 'resumed');
|
||||
h.ripples.dispose();
|
||||
});
|
||||
|
||||
test('turning reduced motion on mid-run stills the lines and stops the frames', () => {
|
||||
const h = harness();
|
||||
h.ripples.show(target);
|
||||
const [lane] = h.lanes;
|
||||
lane.painter(h.frame());
|
||||
h.setReducedMotion(true);
|
||||
h.step();
|
||||
assert.equal(h.frames.size, 0);
|
||||
h.strokes.length = 0;
|
||||
lane.painter(h.frame());
|
||||
assert.ok(
|
||||
h.strokes.every((stroke) => stroke.alpha === 0.7),
|
||||
'still',
|
||||
);
|
||||
// Turned off again within the window: the next paint runs them again.
|
||||
h.setReducedMotion(false);
|
||||
lane.painter(h.frame());
|
||||
assert.equal(h.frames.size, 1);
|
||||
h.ripples.dispose();
|
||||
});
|
||||
|
||||
test('a refresh of the same quake does not run a settled selection again', () => {
|
||||
const h = harness();
|
||||
h.ripples.show(target);
|
||||
const [lane] = h.lanes;
|
||||
h.advance(RIPPLE_ACTIVE_CYCLES * EARTHQUAKE_RIPPLE_PERIOD_MS + 1);
|
||||
lane.painter(h.frame());
|
||||
h.step();
|
||||
assert.equal(h.frames.size, 0, 'settled');
|
||||
h.ripples.show({ ...target, radiusM: 40000 }, { restart: false });
|
||||
assert.equal(h.frames.size, 0, 'a refresh keeps it at rest');
|
||||
lane.painter(h.frame());
|
||||
assert.equal(h.frames.size, 0);
|
||||
// A different quake, or a user's restart, runs again.
|
||||
h.ripples.show({ ...target, id: 'other' }, { restart: false });
|
||||
assert.equal(h.frames.size, 1);
|
||||
h.ripples.dispose();
|
||||
});
|
||||
|
||||
// The rings sit on the ground the disc is draped on. A label's fly-to starts
|
||||
// far away, before that ground loads, so the painter reads the height again
|
||||
// while it paints and moves the rings onto it.
|
||||
test('the rings move onto the ground height once it loads', () => {
|
||||
const h = harness();
|
||||
let ground = null;
|
||||
h.ripples.show({ ...target, heightM: 0, heightAt: () => ground });
|
||||
h.advance(600);
|
||||
const [lane] = h.lanes;
|
||||
lane.painter(h.frame());
|
||||
const atSea = h.fills.at(-1).transform;
|
||||
h.fills.length = 0;
|
||||
ground = 4000;
|
||||
h.advance(600);
|
||||
lane.painter(h.frame());
|
||||
const onGround = h.fills.at(-1).transform;
|
||||
assert.notDeepEqual(onGround, atSea, 'the centre moved up onto the ground');
|
||||
// A change of a metre or less, or an impossible height, leaves them put.
|
||||
for (const next of [4000.5, 25000, -2000]) {
|
||||
ground = next;
|
||||
h.advance(600);
|
||||
lane.painter(h.frame());
|
||||
assert.deepEqual(h.fills.at(-1).transform, onGround, String(next));
|
||||
}
|
||||
// Reads are bounded: a second paint within the interval does not ask again.
|
||||
let reads = 0;
|
||||
h.ripples.show({ ...target, id: 'ak2', heightAt: () => (reads++, 4000) });
|
||||
lane.painter(h.frame());
|
||||
lane.painter(h.frame());
|
||||
assert.equal(reads, 1);
|
||||
});
|
||||
@@ -1,6 +1,49 @@
|
||||
import { createEarthquakesLayer } from '../../layers/earthquakes/index.js';
|
||||
import { overlayHost } from './overlayHost.js';
|
||||
/** Wire earthquake observations to the application overlay host. */
|
||||
import { inputFor } from '../../input/dispatcher.js';
|
||||
import * as picking from '../../data/pickRegistry.js';
|
||||
import * as context from '../../data/contextStore.js';
|
||||
import { isPointerFree } from '../../data/inputOwnership.js';
|
||||
import { requestWorldFocus } from '../../worldFocus.js';
|
||||
import { createEarthquakeRipples } from './earthquakeRipples.js';
|
||||
import { heightsOf } from '../../queries/heights.js';
|
||||
import { formatDate, formatNumber, t } from '../../i18n/index.js';
|
||||
|
||||
const EVENT_TIME = Object.freeze({
|
||||
day: 'numeric',
|
||||
month: 'short',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
timeZone: 'UTC',
|
||||
timeZoneName: 'short',
|
||||
});
|
||||
|
||||
/** The clicked quake's card text, in the page's language. */
|
||||
export const earthquakeCardText = Object.freeze({
|
||||
t,
|
||||
formatTime: (time) => formatDate(time, EVENT_TIME),
|
||||
formatDepth: (km) => formatNumber(km, { maximumFractionDigits: 1 }),
|
||||
});
|
||||
|
||||
/**
|
||||
* Wire earthquake observations to the application overlay host, and its
|
||||
* discs to the globe's clicks: a clicked quake shows its detail card.
|
||||
*/
|
||||
export function createApplicationEarthquakes(options) {
|
||||
return createEarthquakesLayer({ overlayHost, ...options });
|
||||
return createEarthquakesLayer({
|
||||
overlayHost,
|
||||
input: (viewer) => inputFor(viewer),
|
||||
picking,
|
||||
context,
|
||||
pointer: { isPointerFree },
|
||||
openExternal: (url) => window.open(url, '_blank', 'noopener,noreferrer'),
|
||||
focus: { requestWorldFocus },
|
||||
ripples: createEarthquakeRipples(),
|
||||
// The loaded ground (terrain or tiles) the clamped disc is draped on.
|
||||
groundHeight: (viewer, lon, lat) =>
|
||||
viewer ? heightsOf(viewer).now({ lon, lat }) : null,
|
||||
text: earthquakeCardText,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
@@ -2,11 +2,12 @@ import { createRocketLaunchesLayer } from '../../layers/launches/index.js';
|
||||
import * as geometry from '../../celestialRing.js';
|
||||
import * as overlays from '../../overlays/worldOverlay.js';
|
||||
import * as render from '../../renderGovernor.js';
|
||||
import * as picking from '../../data/pickRegistry.js';
|
||||
|
||||
/** Construct one layer using the application scene owners and a supplied source. */
|
||||
export function createApplicationLaunches({ source, satellites }) {
|
||||
return createRocketLaunchesLayer({
|
||||
source,
|
||||
services: { satellites, geometry, overlays, render },
|
||||
services: { satellites, geometry, overlays, render, picking },
|
||||
});
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
import { createSubmarineCableLayer } from '../../layers/submarineCables/index.js';
|
||||
import { overlayHost } from './overlayHost.js';
|
||||
import * as picking from '../../data/pickRegistry.js';
|
||||
/** Wire cable source geometry to the application overlay host. */
|
||||
export function createApplicationCables(options) {
|
||||
return createSubmarineCableLayer({
|
||||
overlayHost,
|
||||
picking,
|
||||
mapStackEventTarget: typeof window !== 'undefined' ? window : null,
|
||||
...options,
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { createApplicationOperations } from './operations.js';
|
||||
import { registerDataCredits } from '../data/dataCredits.js';
|
||||
import { mountCreditsView } from '../ui/creditsView.js';
|
||||
import { trackCreditLineHeight } from '../ui/creditLineHeight.js';
|
||||
import { MapStackController } from '../mapStackController.js';
|
||||
import { mapEngineFor } from '../maps/engine.js';
|
||||
import { initLogoGaze } from '../logoGaze.js';
|
||||
@@ -173,6 +174,8 @@ export async function createApplicationScene({
|
||||
// The credits, in the application's own line, unless the renderer shows
|
||||
// them in a display of its own.
|
||||
if (!hooks.ownCreditDisplay) defer(mountCreditsView(viewer));
|
||||
// The HUD corners above the line clear it when it wraps.
|
||||
defer(trackCreditLineHeight(document));
|
||||
loaderStatus.textContent =
|
||||
googleApiKey || googleTokens || cesiumToken
|
||||
? t('Loading Google 3D Tiles...')
|
||||
|
||||
+58
-51
@@ -50,8 +50,11 @@ import { overlayHost } from './layers/overlayHost.js';
|
||||
* runs after each layer disable (a scene without one keeps that memory).
|
||||
* `library.fetchTile` and `library.fetchData` fetch the Data Library's tiles
|
||||
* and proxied datasets in place of the defaults (`createLibrarySource`).
|
||||
* `library.fetchImpl` asks the library server (its catalog) in place of the
|
||||
* page's fetch, for a server that wants the application's own credentials.
|
||||
* `library.requireCatalog` offers only what the server's library catalog
|
||||
* names, and nothing while it does not answer.
|
||||
* names, and nothing while it does not answer. `library: false` leaves the
|
||||
* Data Library out: no catalog is asked, and no Browse button is drawn.
|
||||
*/
|
||||
export function createApplicationTools({
|
||||
scene,
|
||||
@@ -153,56 +156,60 @@ export function createApplicationTools({
|
||||
connect: connectDisplay,
|
||||
});
|
||||
defer(() => geoFileImport?.destroy());
|
||||
// DATA ▸ Library: entries register their layers only when a viewer adds
|
||||
// them, after the core catalog is sealed. The browser dialog and the
|
||||
// controller share the application lifetime.
|
||||
const dataLibrary = createDataLibrary({
|
||||
dataManager,
|
||||
services: localGeoJsonServices,
|
||||
getTileset: () => tileset,
|
||||
mapStackController,
|
||||
shareLink: styleManager.shareLinkManager,
|
||||
requestRender: governorRequestRender,
|
||||
// An application's own tile and dataset fetches, when it keeps them in
|
||||
// its own cache.
|
||||
fetchTile: library.fetchTile ?? null,
|
||||
fetchData: library.fetchData ?? null,
|
||||
requireCatalog: library.requireCatalog === true,
|
||||
// Zoom to layer: an immediate navigation, so Cockpit can refuse it and
|
||||
// the current follow owner is released first (as for imported files).
|
||||
zoomTo: (extent) =>
|
||||
styleManager.runImmediateNavigation('layer', () =>
|
||||
flyToLibraryExtent(viewer, extent),
|
||||
) !== false,
|
||||
});
|
||||
defer(() => dataLibrary.destroy());
|
||||
// Browse: the owner presents the dialog through the store; LayerPanelsView
|
||||
// draws the Browse button and the dialog from it.
|
||||
const libraryStore = useDataLibraryStore(applicationPinia());
|
||||
const libraryBrowser = createLibraryBrowser({
|
||||
library: dataLibrary,
|
||||
publish: (view) => libraryStore.publish(view),
|
||||
});
|
||||
libraryStore.connect(libraryBrowser.controls);
|
||||
defer(() => {
|
||||
libraryBrowser.destroy();
|
||||
libraryStore.connect(null);
|
||||
});
|
||||
dataLibrary.start({ signal }).catch((error) => {
|
||||
if (!signal?.aborted) console.warn('[Library] start failed:', error);
|
||||
});
|
||||
// The live gate's handle (scripts/qa-data-library.mjs).
|
||||
const libraryHandle = {
|
||||
library: dataLibrary,
|
||||
browser: libraryBrowser,
|
||||
// What Copy Link would copy.
|
||||
buildShareLink: () => styleManager.shareLinkManager?.buildLink?.() ?? null,
|
||||
};
|
||||
window.__gevDataLibrary = libraryHandle;
|
||||
defer(() => {
|
||||
if (window.__gevDataLibrary === libraryHandle)
|
||||
delete window.__gevDataLibrary;
|
||||
});
|
||||
if (library !== false) {
|
||||
// DATA ▸ Library: entries register their layers only when a viewer adds
|
||||
// them, after the core catalog is sealed. The browser dialog and the
|
||||
// controller share the application lifetime.
|
||||
const dataLibrary = createDataLibrary({
|
||||
dataManager,
|
||||
services: localGeoJsonServices,
|
||||
getTileset: () => tileset,
|
||||
mapStackController,
|
||||
shareLink: styleManager.shareLinkManager,
|
||||
requestRender: governorRequestRender,
|
||||
// An application's own tile and dataset fetches, when it keeps them in
|
||||
// its own cache.
|
||||
fetchImpl: library.fetchImpl ?? undefined,
|
||||
fetchTile: library.fetchTile ?? null,
|
||||
fetchData: library.fetchData ?? null,
|
||||
requireCatalog: library.requireCatalog === true,
|
||||
// Zoom to layer: an immediate navigation, so Cockpit can refuse it and
|
||||
// the current follow owner is released first (as for imported files).
|
||||
zoomTo: (extent) =>
|
||||
styleManager.runImmediateNavigation('layer', () =>
|
||||
flyToLibraryExtent(viewer, extent),
|
||||
) !== false,
|
||||
});
|
||||
defer(() => dataLibrary.destroy());
|
||||
// Browse: the owner presents the dialog through the store; LayerPanelsView
|
||||
// draws the Browse button and the dialog from it.
|
||||
const libraryStore = useDataLibraryStore(applicationPinia());
|
||||
const libraryBrowser = createLibraryBrowser({
|
||||
library: dataLibrary,
|
||||
publish: (view) => libraryStore.publish(view),
|
||||
});
|
||||
libraryStore.connect(libraryBrowser.controls);
|
||||
defer(() => {
|
||||
libraryBrowser.destroy();
|
||||
libraryStore.connect(null);
|
||||
});
|
||||
dataLibrary.start({ signal }).catch((error) => {
|
||||
if (!signal?.aborted) console.warn('[Library] start failed:', error);
|
||||
});
|
||||
// The live gate's handle (scripts/qa-data-library.mjs).
|
||||
const libraryHandle = {
|
||||
library: dataLibrary,
|
||||
browser: libraryBrowser,
|
||||
// What Copy Link would copy.
|
||||
buildShareLink: () =>
|
||||
styleManager.shareLinkManager?.buildLink?.() ?? null,
|
||||
};
|
||||
window.__gevDataLibrary = libraryHandle;
|
||||
defer(() => {
|
||||
if (window.__gevDataLibrary === libraryHandle)
|
||||
delete window.__gevDataLibrary;
|
||||
});
|
||||
}
|
||||
// DATA ▸ Recent Imagery: the box tool claims the pointer like Draw and the
|
||||
// panel lives on the right rail, so both belong to the application
|
||||
// lifetime. The tileset lets the layer drape while the globe is hidden.
|
||||
|
||||
@@ -403,10 +403,11 @@ test('vessel and fire layers announce valid clicks and never fly cameras', () =>
|
||||
'vessel click',
|
||||
);
|
||||
ordered(vesselClick, [
|
||||
'clickCard?.(event)',
|
||||
'selectAndFocusVessel(carded)',
|
||||
"isOwnedByOtherLayer('ais-live-vessels', pickedId)",
|
||||
'_vesselOverlayHost.hitTest?.(',
|
||||
'selectAndFocusVessel(record)',
|
||||
], 'vessel sibling ownership');
|
||||
], 'vessel card on top, then sibling ownership');
|
||||
const vesselFocus = body(
|
||||
vessels,
|
||||
/function selectAndFocusVessel\(record\) \{([\s\S]*?)\n \}/,
|
||||
@@ -419,8 +420,9 @@ test('vessel and fire layers announce valid clicks and never fly cameras', () =>
|
||||
'fire click',
|
||||
);
|
||||
ordered(fireClick, [
|
||||
'isOwnedByOtherLayer(id, pickedId)',
|
||||
'overlayHost.hitTest?.(',
|
||||
'clickCard?.(event)',
|
||||
'selectAndFocusFire(carded)',
|
||||
], 'fire sibling ownership');
|
||||
'isOwnedByOtherLayer(id, pickedId)',
|
||||
'clearFireSelection()',
|
||||
], 'fire card on top, then sibling ownership');
|
||||
});
|
||||
@@ -595,7 +595,7 @@ test('Cockpit Display portal retains both scroll owners across round trips', ()
|
||||
const portal = CockpitDisplayPortal.toString();
|
||||
assert.match(
|
||||
portal,
|
||||
/this\.standardScrollTop =\s*displayPanelScroller\(standardPanel\)\?\.scrollTop \|\| 0/,
|
||||
/this\.standardScrollTop = standardPanel\?\.scrollTop \|\| 0/,
|
||||
);
|
||||
assert.match(
|
||||
portal,
|
||||
@@ -603,7 +603,7 @@ test('Cockpit Display portal retains both scroll owners across round trips', ()
|
||||
);
|
||||
assert.match(
|
||||
portal,
|
||||
/if \(!this\.active\)[\s\S]*?this\.standardScrollTop =\s*displayPanelScroller\(standardPanel\)\.scrollTop/,
|
||||
/if \(!this\.active\)[\s\S]*?this\.standardScrollTop = standardPanel\.scrollTop/,
|
||||
);
|
||||
assert.match(
|
||||
portal,
|
||||
@@ -611,7 +611,7 @@ test('Cockpit Display portal retains both scroll owners across round trips', ()
|
||||
);
|
||||
assert.match(
|
||||
portal,
|
||||
/this\.cockpitPanel\.scrollTop = this\.cockpitScrollTop[\s\S]*?displayPanelScroller\(this\.standardPanel\)\.scrollTop =\s*this\.standardScrollTop/,
|
||||
/this\.cockpitPanel\.scrollTop = this\.cockpitScrollTop[\s\S]*?this\.standardPanel\.scrollTop = this\.standardScrollTop/,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -680,6 +680,7 @@ test('fresh Cockpit entry temporarily collapses map panels and exit restores the
|
||||
'scene-panel',
|
||||
'pp-toggles',
|
||||
'global-context-panel',
|
||||
'space-missions-panel',
|
||||
'radio-panel',
|
||||
]) {
|
||||
assert.match(
|
||||
@@ -1261,14 +1262,15 @@ test('Global Context uses its dedicated right rail without a duplicate Data Laye
|
||||
);
|
||||
assert.match(html, /id="global-context-panel"/);
|
||||
assert.match(html, /id="global-context-flights-btn"/);
|
||||
assert.match(html, /id="global-context-missions-btn"/);
|
||||
assert.doesNotMatch(html, /id="global-context-missions-btn"/);
|
||||
assert.match(html, /id="space-missions-panel"/);
|
||||
});
|
||||
|
||||
test('Global Context standby describes both chooser modes', () => {
|
||||
test('Global Context standby describes Contacts', () => {
|
||||
const match = html.match(/<div id="context-mode-standby"[\s\S]*?<\/div>/);
|
||||
assert.ok(match, 'Global Context standby is missing');
|
||||
assert.match(match[0], /CONTACTS — nearest planes · vessels · sites/);
|
||||
assert.match(match[0], /SPACE MISSIONS — launches & orbital assets/);
|
||||
assert.doesNotMatch(match[0], /SPACE MISSIONS/);
|
||||
});
|
||||
|
||||
test('cockpit briefing cycle control keeps its state as the accessible name', () => {
|
||||
|
||||
+7
-4
@@ -58,12 +58,15 @@ export function cockpitAnchorCorrectionStep(
|
||||
return Math.min(distanceM, eased, correctionRateMps * dt);
|
||||
}
|
||||
|
||||
/** How late past its interval an update may come and still count in full. */
|
||||
const COCKPIT_SUBJECT_LATE_SEC = 1;
|
||||
|
||||
/**
|
||||
* The seconds an application subject's camera update advances its heading
|
||||
* slew, ground lift and anchor by: the time since the last update, at most
|
||||
* its update interval plus 0.1 s. A subject updated every 500 ms then turns
|
||||
* and eases at its configured rates, while a long stall (a hidden tab) still
|
||||
* moves it no further than one late update would.
|
||||
* its interval plus COCKPIT_SUBJECT_LATE_SEC. A subject updated every 500 ms,
|
||||
* or a browser drawing 5 frames a second, then keeps up, while a long stall
|
||||
* (a hidden tab) counts as one late update.
|
||||
* @param {number} elapsedMs Time since the last camera update.
|
||||
* @param {number} intervalMs The subject's update interval (0: every frame).
|
||||
* @returns {number}
|
||||
@@ -75,7 +78,7 @@ export function cockpitSubjectStepSec(elapsedMs, intervalMs) {
|
||||
const intervalSec = Number.isFinite(intervalMs)
|
||||
? Math.max(0, intervalMs) / 1000
|
||||
: 0;
|
||||
return Math.min(intervalSec + 0.1, elapsedSec);
|
||||
return Math.min(intervalSec + COCKPIT_SUBJECT_LATE_SEC, elapsedSec);
|
||||
}
|
||||
|
||||
/** Return whether a throttled cockpit presentation update is due. */
|
||||
|
||||
+145
-4
@@ -31,6 +31,7 @@ import {
|
||||
speedRulerStep,
|
||||
speedRulerTicks,
|
||||
} from './cockpitMath.js';
|
||||
import { bandBesideMidpointObstacles } from './ui/panelRailGeometry.js';
|
||||
|
||||
test('cockpit presentation updates are throttled independently of camera frames', () => {
|
||||
assert.equal(cockpitUiUpdateDue(1000, 0, 100), true);
|
||||
@@ -73,12 +74,15 @@ test('an application subject steps by its interval, never by a long stall', () =
|
||||
assert.equal(cockpitSubjectStepSec(16, 0), 0.016);
|
||||
assert.equal(cockpitSubjectStepSec(500, 500), 0.5);
|
||||
assert.equal(cockpitSubjectStepSec(520, 500), 0.52);
|
||||
// A hidden tab's minutes count as one late update.
|
||||
assert.equal(cockpitSubjectStepSec(60_000, 500), 0.6);
|
||||
assert.equal(cockpitSubjectStepSec(60_000, 0), 0.1);
|
||||
// Slow frames (5 a second) count in full...
|
||||
assert.equal(cockpitSubjectStepSec(200, 50), 0.2);
|
||||
assert.equal(cockpitSubjectStepSec(1000, 0), 1);
|
||||
// ...and a hidden tab's minutes as one late update.
|
||||
assert.equal(cockpitSubjectStepSec(60_000, 500), 1.5);
|
||||
assert.equal(cockpitSubjectStepSec(60_000, 0), 1);
|
||||
assert.equal(cockpitSubjectStepSec(-5, 500), 0);
|
||||
assert.equal(cockpitSubjectStepSec(Number.NaN, 500), 0);
|
||||
assert.equal(cockpitSubjectStepSec(1000, Number.NaN), 0.1);
|
||||
assert.equal(cockpitSubjectStepSec(1000, Number.NaN), 1);
|
||||
});
|
||||
|
||||
test('cockpit camera clearance never falls below the rendered ground floor', () => {
|
||||
@@ -283,6 +287,143 @@ test('HUD rail layout constrains an oversized panel to the safe corridor', () =>
|
||||
assert.equal(layout.constrained, true);
|
||||
});
|
||||
|
||||
test('HUD rail layout keeps a short window clear of an obstacle across its midpoint', () => {
|
||||
// 480px window: midpoint 240. Each obstacle is neither wholly above nor
|
||||
// wholly below the midpoint, and must still limit the band.
|
||||
const above = resolveHudRailLayout({
|
||||
viewportHeight: 480,
|
||||
panelHeight: 120,
|
||||
laneLeft: 20,
|
||||
laneRight: 340,
|
||||
baseTop: 40,
|
||||
baseBottom: 460,
|
||||
gap: 10,
|
||||
obstacles: [{ left: 0, right: 400, top: 200, bottom: 300 }],
|
||||
});
|
||||
// Room above: 200 - 10 - 40 = 150; below: 460 - 310 = 150. A tie keeps the
|
||||
// band above the obstacle.
|
||||
assert.equal(above.safeTop, 40);
|
||||
assert.equal(above.safeBottom, 190);
|
||||
assert(above.top + Math.min(120, above.maxHeight) <= 190);
|
||||
|
||||
const below = resolveHudRailLayout({
|
||||
viewportHeight: 480,
|
||||
panelHeight: 120,
|
||||
laneLeft: 20,
|
||||
laneRight: 340,
|
||||
baseTop: 40,
|
||||
baseBottom: 460,
|
||||
gap: 10,
|
||||
obstacles: [{ left: 0, right: 400, top: 120, bottom: 260 }],
|
||||
});
|
||||
// Room above: 70; below: 190. The band goes under the obstacle.
|
||||
assert.equal(below.safeTop, 270);
|
||||
assert.equal(below.safeBottom, 460);
|
||||
assert(below.top >= 270);
|
||||
});
|
||||
|
||||
test('HUD rail layout leaves the band as it is when an obstacle across the midpoint leaves no room', () => {
|
||||
const layout = resolveHudRailLayout({
|
||||
viewportHeight: 480,
|
||||
panelHeight: 120,
|
||||
laneLeft: 20,
|
||||
laneRight: 340,
|
||||
baseTop: 100,
|
||||
baseBottom: 400,
|
||||
gap: 10,
|
||||
obstacles: [{ left: 0, right: 400, top: 80, bottom: 420 }],
|
||||
});
|
||||
assert.equal(layout.safeTop, 100);
|
||||
assert.equal(layout.safeBottom, 400);
|
||||
});
|
||||
|
||||
test('HUD rail layout reads several obstacles across the midpoint the same in any order', () => {
|
||||
const a = { left: 0, right: 400, top: 100, bottom: 260 };
|
||||
const b = { left: 0, right: 400, top: 200, bottom: 470 };
|
||||
const layoutWith = (obstacles) =>
|
||||
resolveHudRailLayout({
|
||||
viewportHeight: 480,
|
||||
panelHeight: 120,
|
||||
laneLeft: 20,
|
||||
laneRight: 340,
|
||||
baseTop: 40,
|
||||
baseBottom: 460,
|
||||
gap: 10,
|
||||
obstacles,
|
||||
});
|
||||
// Together they cover 100 to 470: the only room is above, 40 to 90.
|
||||
for (const layout of [layoutWith([a, b]), layoutWith([b, a])]) {
|
||||
assert.equal(layout.safeTop, 40);
|
||||
assert.equal(layout.safeBottom, 90);
|
||||
assert.equal(layout.maxHeight, 50);
|
||||
}
|
||||
});
|
||||
|
||||
test('HUD rail layout counts obstacles beside those across the midpoint', () => {
|
||||
const band = (obstacles) => {
|
||||
const layout = resolveHudRailLayout({
|
||||
viewportHeight: 480,
|
||||
panelHeight: 120,
|
||||
laneLeft: 20,
|
||||
laneRight: 340,
|
||||
baseTop: 40,
|
||||
baseBottom: 460,
|
||||
gap: 10,
|
||||
obstacles: obstacles.map(([top, bottom]) => ({
|
||||
left: 0,
|
||||
right: 400,
|
||||
top,
|
||||
bottom,
|
||||
})),
|
||||
});
|
||||
return [layout.safeTop, layout.safeBottom];
|
||||
};
|
||||
// One inside the span below the midpoint: 150px below the span, 50 above.
|
||||
assert.deepEqual(band([[100, 300], [250, 280]]), [310, 460]);
|
||||
// One touching the midpoint from below: 190px below, 100 above.
|
||||
assert.deepEqual(band([[150, 260], [240, 250]]), [270, 460]);
|
||||
// One inside the span above the midpoint: 150px above, 50 below.
|
||||
assert.deepEqual(band([[200, 400], [210, 230]]), [40, 190]);
|
||||
// A lower obstacle past the span limits the room below it: 100px between
|
||||
// them against 70 above, and with a taller one only 60, so above.
|
||||
assert.deepEqual(band([[120, 260], [380, 420]]), [270, 370]);
|
||||
assert.deepEqual(band([[120, 260], [340, 420]]), [40, 110]);
|
||||
// Neighbours exactly two gaps away leave no room between: one block, 100
|
||||
// to 400, and a tie (50px a side) goes above.
|
||||
assert.deepEqual(band([[100, 180], [200, 300], [320, 400]]), [40, 90]);
|
||||
// A neighbour exactly two gaps below joins it too: 150 to 300, 100px
|
||||
// above against 150 below.
|
||||
assert.deepEqual(band([[150, 250], [270, 300]]), [310, 460]);
|
||||
// A side under 8% of the window (38.4px) is no room: 30px above, none
|
||||
// below, so the band stays as it is.
|
||||
assert.deepEqual(band([[80, 455]]), [40, 460]);
|
||||
// Exactly the minimum is enough.
|
||||
const exact = bandBesideMidpointObstacles({
|
||||
midpoint: 240,
|
||||
top: 40,
|
||||
bottom: 460,
|
||||
obstacles: [{ top: 90, bottom: 465 }],
|
||||
gap: 10,
|
||||
minimum: 40,
|
||||
});
|
||||
assert.deepEqual([exact?.top, exact?.bottom], [40, 80]);
|
||||
});
|
||||
|
||||
test('HUD rail layout keeps a band beside a midpoint obstacle inside its own edges', () => {
|
||||
const layout = resolveHudRailLayout({
|
||||
viewportHeight: 480,
|
||||
panelHeight: 80,
|
||||
laneLeft: 20,
|
||||
laneRight: 340,
|
||||
baseTop: 350,
|
||||
baseBottom: 460,
|
||||
gap: 10,
|
||||
obstacles: [{ left: 0, right: 400, top: 100, bottom: 260 }],
|
||||
});
|
||||
assert.equal(layout.safeTop, 350);
|
||||
assert.equal(layout.safeBottom, 460);
|
||||
});
|
||||
|
||||
test('HUD rail layout can anchor controls to the start of the safe corridor', () => {
|
||||
const layout = resolveHudRailLayout({
|
||||
viewportHeight: 1000,
|
||||
|
||||
+19
-6
@@ -30,13 +30,26 @@ const TONE_RANK = Object.freeze([
|
||||
const stronger = (a, b) =>
|
||||
TONE_RANK.indexOf(b) > TONE_RANK.indexOf(a) ? b : a;
|
||||
|
||||
/** A label's width estimate (px): its longer line in small capitals. */
|
||||
/** Full-width glyphs in the BMP: CJK, kana, Hangul, full-width forms. */
|
||||
const WIDE_GLYPHS =
|
||||
/[\u1100-\u115F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uA960-\uA97F\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE4F\uFF00-\uFF60\uFFE0-\uFFE6]/g;
|
||||
|
||||
/**
|
||||
* One line's width (px) in `.cockpit-progress-label` type (cockpitSubject.css:
|
||||
* 10 px, 0.06 em spacing): 10.6 px a full-width glyph and 6.4 px each UTF-16
|
||||
* unit of any other, so an astral glyph (an emoji, a CJK extension) counts as
|
||||
* two and an emoji in the BMP (☕) as one, narrower than it is drawn. The
|
||||
* detail line's `<small>` draws smaller, so these widths only overestimate it.
|
||||
*/
|
||||
function lineWidthPx(line) {
|
||||
const text = String(line ?? '');
|
||||
const wide = text.match(WIDE_GLYPHS)?.length ?? 0;
|
||||
return wide * 10.6 + (text.length - wide) * 6.4;
|
||||
}
|
||||
|
||||
/** A label's width estimate (px): its wider line and 8 px of padding. */
|
||||
export function estimateProgressLabelPx(label) {
|
||||
const longest = Math.max(
|
||||
String(label?.text ?? '').length,
|
||||
String(label?.detail ?? '').length,
|
||||
);
|
||||
return longest * 6.4 + 8;
|
||||
return Math.max(lineWidthPx(label?.text), lineWidthPx(label?.detail)) + 8;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,10 @@
|
||||
// the travelled part.
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { cockpitProgressLayout } from './cockpitProgress.js';
|
||||
import {
|
||||
cockpitProgressLayout,
|
||||
estimateProgressLabelPx,
|
||||
} from './cockpitProgress.js';
|
||||
|
||||
const tick = (at, label = null, tone = 'normal') => ({ at, tone, label });
|
||||
const label = (text, priority, align = 'center', detail = '') => ({
|
||||
@@ -142,3 +145,59 @@ test('a long run of calls still lays out, every one a tick or part of one', () =
|
||||
assert.ok(narrow.ticks.length < wide.ticks.length);
|
||||
assert.equal(wide.ticks.length, 60);
|
||||
});
|
||||
|
||||
test('a CJK stop name gets the width its full-width glyphs need', () => {
|
||||
const text = '中央駅前広場東口'; // 8 full-width glyphs
|
||||
// 10 px type, 0.06 em apart.
|
||||
const needPx = text.length * (10 + 0.6);
|
||||
const givenPx = estimateProgressLabelPx({ text, detail: '' });
|
||||
assert.ok(
|
||||
givenPx >= needPx,
|
||||
`${givenPx} px given, about ${needPx} px needed`,
|
||||
);
|
||||
// As many Latin letters are narrower; half-width katakana are as narrow.
|
||||
assert.ok(givenPx > estimateProgressLabelPx({ text: 'CENTRALS' }));
|
||||
assert.equal(
|
||||
estimateProgressLabelPx({ text: 'カタカナ' }),
|
||||
estimateProgressLabelPx({ text: 'KANA' }),
|
||||
);
|
||||
});
|
||||
|
||||
test('astral glyphs (emoji outside the BMP, supplementary kana) in a progress label get at least 1 em each', () => {
|
||||
// About 1 em in 10 px type, 0.06 em apart.
|
||||
const emPx = 10 + 0.6;
|
||||
for (const [text, needPx] of [
|
||||
['🚉🚆🚇🚋', 4 * emPx],
|
||||
['🚆'.repeat(8), 8 * emPx],
|
||||
// Supplementary kana, outside the full-width ranges.
|
||||
['𛀁𛀂', 2 * emPx],
|
||||
// Mixed: four emoji, a space and two full-width glyphs.
|
||||
['🚆🚇🚌🚕 乗換', 4 * emPx + 6.4 + 2 * emPx],
|
||||
]) {
|
||||
const givenPx = estimateProgressLabelPx({ text, detail: '' });
|
||||
assert.ok(
|
||||
givenPx >= needPx + 8,
|
||||
`${text}: ${givenPx} px given, about ${needPx} px needed`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('a label is as wide as its wider line, its smaller detail line included', () => {
|
||||
assert.ok(
|
||||
estimateProgressLabelPx({ text: 'GATE', detail: '中央駅前' }) >
|
||||
estimateProgressLabelPx({ text: 'GATE', detail: '' }),
|
||||
'the wider detail line widens the label',
|
||||
);
|
||||
// As headless Chrome draws the detail's <small> (8.333 px JetBrains Mono,
|
||||
// 0.6 px apart): 'WWWWMMMMWWWW' at 67.2 px, '中央駅前広場東口' at 72.9 px.
|
||||
for (const [detail, needPx] of [
|
||||
['W'.repeat(64), 64 * (67.2 / 12)],
|
||||
['駅'.repeat(45), 45 * (72.9 / 8)],
|
||||
]) {
|
||||
const givenPx = estimateProgressLabelPx({ text: 'A', detail });
|
||||
assert.ok(
|
||||
givenPx >= needPx,
|
||||
`${detail.length} × ${detail[0]}: ${givenPx} px given, ${needPx} px needed`,
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -117,20 +117,27 @@ function lookOf(raw) {
|
||||
});
|
||||
}
|
||||
|
||||
/** Promises already given a catch: a pending one is read again on every use. */
|
||||
const caughtWords = new WeakSet();
|
||||
|
||||
/**
|
||||
* A provider's worded member `key` as it reads now, normalized: the value,
|
||||
* or what the function it is returns when called on `provider` (so it can
|
||||
* follow the page's language); null when it is malformed or a read throws.
|
||||
* Reading the member, and reading what it gives, runs provider code too (a
|
||||
* getter), so both are guarded as the call is.
|
||||
* A worded member as `read()` gives it, normalized: called on `provider`
|
||||
* when it is a function (so it can follow the page's language); null when it
|
||||
* is malformed (a promise too) or provider code throws, its getter included
|
||||
* (hence `read`).
|
||||
*/
|
||||
function wordedNow(provider, key, normalize) {
|
||||
function worded(provider, read, normalize) {
|
||||
try {
|
||||
const value = provider[key];
|
||||
return (
|
||||
normalize(typeof value === 'function' ? value.call(provider) : value) ??
|
||||
null
|
||||
);
|
||||
const value = read();
|
||||
const words = typeof value === 'function' ? value.call(provider) : value;
|
||||
if (typeof words?.then === 'function') {
|
||||
if (!caughtWords.has(words)) {
|
||||
caughtWords.add(words);
|
||||
Promise.resolve(words).catch(() => {});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return normalize(words) ?? null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
@@ -146,7 +153,7 @@ function providerName(provider, order) {
|
||||
return `#${order}`;
|
||||
}
|
||||
|
||||
/** Why `provider` cannot be kept, or null. */
|
||||
/** Why `provider` cannot be kept, its worded members aside, or null. */
|
||||
function refusal(provider, kinds) {
|
||||
if (!isObject(provider)) return 'not an object';
|
||||
if (typeof provider.kind !== 'string' || !KIND_PATTERN.test(provider.kind))
|
||||
@@ -165,14 +172,25 @@ function refusal(provider, kinds) {
|
||||
typeof provider.isEntryAllowed !== 'function'
|
||||
)
|
||||
return 'isEntryAllowed is not a function';
|
||||
if (!wordedNow(provider, 'entryFace', faceOf)) return 'malformed entry face';
|
||||
if (!wordedNow(provider, 'labels', labelsOf))
|
||||
return 'labels need view, exit and exitText';
|
||||
if (provider.look != null && !wordedNow(provider, 'look', lookOf))
|
||||
return 'look needs an aheadLabel';
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* A provider's worded members, each read once, to seed its copy (so one that
|
||||
* fails when read again cannot undo this check), or why one is malformed.
|
||||
* @returns {{face: object, labels: object, look: ?object}|string}
|
||||
*/
|
||||
function checkedWords(provider) {
|
||||
const face = worded(provider, () => provider.entryFace, faceOf);
|
||||
if (!face) return 'malformed entry face';
|
||||
const labels = worded(provider, () => provider.labels, labelsOf);
|
||||
if (!labels) return 'labels need view, exit and exitText';
|
||||
const lookValue = provider.look;
|
||||
if (lookValue == null) return { face, labels, look: null };
|
||||
const look = worded(provider, () => lookValue, lookOf);
|
||||
return look ? { face, labels, look } : 'look needs an aheadLabel';
|
||||
}
|
||||
|
||||
/**
|
||||
* The application's subject providers, checked once and frozen, in the order
|
||||
* entry asks them: ascending `priority`, ties in list order. Each has
|
||||
@@ -191,7 +209,8 @@ function refusal(provider, kinds) {
|
||||
* object: it is called on the provider again whenever they are shown and
|
||||
* when the page's language changes, so its words can follow it
|
||||
* (`./i18n`). A read that throws or is malformed keeps the last
|
||||
* good one; `look` is on or off and `restPitchDeg` fixed as first read;
|
||||
* good one; `look` is on or off and `restPitchDeg` fixed as read at
|
||||
* registration;
|
||||
* - `cameraIntervalMs` (optional): 0..1000, null for the Cockpit's default; 0
|
||||
* updates the camera every rendered frame;
|
||||
* - `headingSlewDps` (optional): how fast the view turns to a new heading,
|
||||
@@ -224,7 +243,11 @@ export function cockpitSubjectProviders(
|
||||
let copy = null;
|
||||
try {
|
||||
reason = refusal(provider, kinds);
|
||||
if (!reason) copy = keptProvider(provider, order);
|
||||
if (!reason) {
|
||||
const words = checkedWords(provider);
|
||||
if (typeof words === 'string') reason = words;
|
||||
else copy = keptProvider(provider, order, words);
|
||||
}
|
||||
} catch {
|
||||
reason = 'a member threw when read';
|
||||
}
|
||||
@@ -241,14 +264,12 @@ export function cockpitSubjectProviders(
|
||||
return Object.freeze(kept);
|
||||
}
|
||||
|
||||
/** The frozen copy the Cockpit keeps of a provider `refusal` passed. */
|
||||
function keptProvider(provider, order) {
|
||||
// Worded members are read again on each use (see above); the last good
|
||||
// read stands in for one that is malformed or throws.
|
||||
let face = wordedNow(provider, 'entryFace', faceOf);
|
||||
let labels = wordedNow(provider, 'labels', labelsOf);
|
||||
// On or off, and its rest pitch, as first read.
|
||||
let look = wordedNow(provider, 'look', lookOf);
|
||||
/**
|
||||
* The frozen copy the Cockpit keeps of a provider that passed `refusal`,
|
||||
* seeded with the worded members `checkedWords` read.
|
||||
*/
|
||||
function keptProvider(provider, order, words) {
|
||||
let { face, labels, look } = words;
|
||||
const restPitchDeg = look?.restPitchDeg ?? 0;
|
||||
return Object.freeze({
|
||||
kind: provider.kind,
|
||||
@@ -256,16 +277,16 @@ function keptProvider(provider, order) {
|
||||
priority: finite(provider.priority) ? provider.priority : 0,
|
||||
order,
|
||||
get entryFace() {
|
||||
face = wordedNow(provider, 'entryFace', faceOf) ?? face;
|
||||
face = worded(provider, () => provider.entryFace, faceOf) ?? face;
|
||||
return face;
|
||||
},
|
||||
get labels() {
|
||||
labels = wordedNow(provider, 'labels', labelsOf) ?? labels;
|
||||
labels = worded(provider, () => provider.labels, labelsOf) ?? labels;
|
||||
return labels;
|
||||
},
|
||||
get look() {
|
||||
if (!look) return null;
|
||||
const now = wordedNow(provider, 'look', lookOf);
|
||||
const now = worded(provider, () => provider.look, lookOf);
|
||||
if (now)
|
||||
look = Object.freeze({ restPitchDeg, aheadLabel: now.aheadLabel });
|
||||
return look;
|
||||
@@ -335,11 +356,11 @@ function candidateOf(raw) {
|
||||
* a position that is not finite, an eye with no valid `upM` (0..1000), or a
|
||||
* read of it that throws (a getter runs provider code).
|
||||
* A `heightM` that is not finite or lies outside
|
||||
* COCKPIT_SUBJECT_MIN_HEIGHT_M..COCKPIT_SUBJECT_MAX_HEIGHT_M reads as null:
|
||||
* the eye then stands on the shared floor, or where it last stood while that
|
||||
* is cold. The anchor is `'inertial'` only when asked for and the frame
|
||||
* gives a speed; otherwise it is `'exact'`. An id is compared with `heldId`
|
||||
* trimmed, as `cockpitSubjectCandidate` trims it.
|
||||
* COCKPIT_SUBJECT_MIN_HEIGHT_M..COCKPIT_SUBJECT_MAX_HEIGHT_M reads as null,
|
||||
* for the eye to stand on the shared floor (ui/cockpitCamera.js). The anchor
|
||||
* is `'inertial'` by default for a frame with a valid speed, and `'exact'`
|
||||
* when asked for or with no speed. An id is compared with `heldId` trimmed,
|
||||
* as `cockpitSubjectCandidate` trims it.
|
||||
* @param {unknown} raw What `read()` returned.
|
||||
* @param {string} heldId The subject the view holds.
|
||||
* @returns {object|null} `{id, name, latitude, longitude, heightM, headingDeg,
|
||||
@@ -356,49 +377,57 @@ export function cockpitSubjectFrame(raw, heldId) {
|
||||
}
|
||||
|
||||
function frameOf(raw, heldId) {
|
||||
if (!isObject(raw) || typeof raw.id !== 'string' || raw.id.trim() !== heldId)
|
||||
return null;
|
||||
const latitude = raw.latitude;
|
||||
const longitude = raw.longitude;
|
||||
if (!isObject(raw)) return null;
|
||||
// Each field read once: a getter on the frame runs provider code.
|
||||
const {
|
||||
id,
|
||||
name,
|
||||
latitude,
|
||||
longitude,
|
||||
heightM,
|
||||
headingDeg: rawHeadingDeg,
|
||||
courseDeg,
|
||||
speedMps: rawSpeedMps,
|
||||
stale,
|
||||
groundClamp,
|
||||
anchor,
|
||||
eye: rawEye,
|
||||
} = raw;
|
||||
if (typeof id !== 'string' || id.trim() !== heldId) return null;
|
||||
if (!finite(latitude) || !finite(longitude) || Math.abs(latitude) > 90)
|
||||
return null;
|
||||
const eye = isObject(raw.eye) ? raw.eye : null;
|
||||
if (!eye || !finite(eye.upM) || eye.upM < 0 || eye.upM > 1000) return null;
|
||||
if (!isObject(rawEye)) return null;
|
||||
const { upM, forwardM, pitchDeg, minClearanceM } = rawEye;
|
||||
if (!finite(upM) || upM < 0 || upM > 1000) return null;
|
||||
const heading = (value) =>
|
||||
finite(value) ? ((value % 360) + 360) % 360 : null;
|
||||
const headingDeg = heading(raw.headingDeg);
|
||||
const speedMps =
|
||||
finite(raw.speedMps) && raw.speedMps >= 0 ? raw.speedMps : null;
|
||||
const headingDeg = heading(rawHeadingDeg);
|
||||
const speedMps = finite(rawSpeedMps) && rawSpeedMps >= 0 ? rawSpeedMps : null;
|
||||
return {
|
||||
id: heldId,
|
||||
name: cockpitSubjectText(raw.name, 64) || cockpitSubjectText(heldId, 64),
|
||||
name: cockpitSubjectText(name, 64) || cockpitSubjectText(heldId, 64),
|
||||
latitude,
|
||||
longitude: ((((longitude + 180) % 360) + 360) % 360) - 180,
|
||||
heightM:
|
||||
finite(raw.heightM) &&
|
||||
raw.heightM >= COCKPIT_SUBJECT_MIN_HEIGHT_M &&
|
||||
raw.heightM <= COCKPIT_SUBJECT_MAX_HEIGHT_M
|
||||
? raw.heightM
|
||||
finite(heightM) &&
|
||||
heightM >= COCKPIT_SUBJECT_MIN_HEIGHT_M &&
|
||||
heightM <= COCKPIT_SUBJECT_MAX_HEIGHT_M
|
||||
? heightM
|
||||
: null,
|
||||
headingDeg,
|
||||
courseDeg: heading(raw.courseDeg) ?? headingDeg,
|
||||
courseDeg: heading(courseDeg) ?? headingDeg,
|
||||
speedMps,
|
||||
stale: raw.stale === true,
|
||||
groundClamp: raw.groundClamp !== false,
|
||||
stale: stale === true,
|
||||
groundClamp: groundClamp !== false,
|
||||
// An inertial anchor runs on at the frame's speed; with none it would
|
||||
// close on a moving subject at the correction's floor and fall behind.
|
||||
anchor: raw.anchor === 'exact' || speedMps === null ? 'exact' : 'inertial',
|
||||
anchor: anchor === 'exact' || speedMps === null ? 'exact' : 'inertial',
|
||||
eye: {
|
||||
upM: eye.upM,
|
||||
forwardM:
|
||||
finite(eye.forwardM) && Math.abs(eye.forwardM) <= 500
|
||||
? eye.forwardM
|
||||
: 0,
|
||||
pitchDeg: finite(eye.pitchDeg) ? clamp(eye.pitchDeg, -90, 90) : 0,
|
||||
upM,
|
||||
forwardM: finite(forwardM) && Math.abs(forwardM) <= 500 ? forwardM : 0,
|
||||
pitchDeg: finite(pitchDeg) ? clamp(pitchDeg, -90, 90) : 0,
|
||||
minClearanceM:
|
||||
finite(eye.minClearanceM) && eye.minClearanceM >= 0
|
||||
? eye.minClearanceM
|
||||
: 0,
|
||||
finite(minClearanceM) && minClearanceM >= 0 ? minClearanceM : 0,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -642,11 +642,15 @@ test('a provider whose getter throws is left out with one warning; the next is k
|
||||
]);
|
||||
});
|
||||
|
||||
test('a worded getter that starts throwing keeps the last good words', () => {
|
||||
let failing = false;
|
||||
const words = (value) => () => {
|
||||
if (failing) throw new Error('translations unavailable');
|
||||
return value;
|
||||
test('a worded getter that throws from its second read keeps the last good words', () => {
|
||||
// Registration reads each once: the second read is the first use.
|
||||
const once = (value) => {
|
||||
let read = false;
|
||||
return () => {
|
||||
if (read) throw new Error('translations unavailable');
|
||||
read = true;
|
||||
return value;
|
||||
};
|
||||
};
|
||||
const definition = provider();
|
||||
for (const [key, value] of Object.entries({
|
||||
@@ -654,22 +658,52 @@ test('a worded getter that starts throwing keeps the last good words', () => {
|
||||
entryFace: { icon: 'commute', label: 'RIDE' },
|
||||
look: { restPitchDeg: 10, aheadLabel: 'Look ahead' },
|
||||
}))
|
||||
Object.defineProperty(definition, key, { get: words(value) });
|
||||
Object.defineProperty(definition, key, { get: once(value) });
|
||||
const { kept, warnings } = keep([definition]);
|
||||
assert.deepEqual(warnings, []);
|
||||
const [ride] = kept;
|
||||
failing = true;
|
||||
assert.equal(ride.labels.view, 'Ride view');
|
||||
assert.equal(ride.entryFace.label, 'RIDE');
|
||||
assert.deepEqual(ride.look, { restPitchDeg: 10, aheadLabel: 'Look ahead' });
|
||||
// So does a worded object whose own member throws when read.
|
||||
failing = false;
|
||||
Object.defineProperty(definition, 'labels', {
|
||||
get: () => throwingGetter({ view: 'v', exit: 'e', exitText: 'x' }, 'view'),
|
||||
});
|
||||
assert.equal(ride.labels.view, 'Ride view');
|
||||
});
|
||||
|
||||
test('a worded member that returns a rejected promise keeps the last good words, the rejection caught', async () => {
|
||||
const definition = provider();
|
||||
const words = definition.labels;
|
||||
let reads = 0;
|
||||
definition.labels = () => {
|
||||
reads += 1;
|
||||
return reads === 1 ? words : Promise.reject(new Error('late words'));
|
||||
};
|
||||
const { kept, warnings } = keep([definition]);
|
||||
assert.deepEqual(warnings, []);
|
||||
assert.equal(kept[0].labels.view, words.view);
|
||||
// An unhandled rejection would fail this test once it surfaces.
|
||||
await new Promise((resolve) => setTimeout(resolve, 10));
|
||||
});
|
||||
|
||||
test('a frame field read through a getter is read once', () => {
|
||||
const frame = { id: 'a1', latitude: 1, longitude: 2, eye: { upM: 3 } };
|
||||
const once = (value) => {
|
||||
let read = false;
|
||||
return () => {
|
||||
const answer = read ? undefined : value;
|
||||
read = true;
|
||||
return answer;
|
||||
};
|
||||
};
|
||||
Object.defineProperty(frame, 'heightM', { get: once(420) });
|
||||
Object.defineProperty(frame, 'speedMps', { get: once(12) });
|
||||
const normalized = cockpitSubjectFrame(frame, 'a1');
|
||||
assert.equal(normalized.heightM, 420);
|
||||
assert.equal(normalized.speedMps, 12);
|
||||
});
|
||||
|
||||
test('a candidate, frame or HUD view whose getter throws reads as null', () => {
|
||||
assert.equal(
|
||||
cockpitSubjectCandidate(throwingGetter({ name: 'Example' }, 'id')),
|
||||
|
||||
@@ -17,11 +17,6 @@
|
||||
* @param {number} [input.signalGap] Clearance above the briefing card.
|
||||
* @param {number} [input.minTopFloor] Absolute ceiling for the strip, in px.
|
||||
* @param {number} [input.minTopRatio] Viewport-relative ceiling, 0..1.
|
||||
* @param {boolean} [input.signalCollapsed] Whether the briefing card is collapsed.
|
||||
* @param {boolean} [input.utilityExpanded] Whether Display or Radio is expanded.
|
||||
* @param {number} [input.bottomInset] Reserved viewport space below an expanded panel.
|
||||
* @param {number} [input.signalHeight] Collapsed briefing header reserved below the utility.
|
||||
* @param {boolean} [input.reserveViewportLane] Theme relocates the briefing below the expanded utility.
|
||||
* @returns {{ top: number, maxHeight: number }}
|
||||
*/
|
||||
export function resolveCockpitUtilityAnchor({
|
||||
@@ -34,29 +29,13 @@ export function resolveCockpitUtilityAnchor({
|
||||
signalGap = 8,
|
||||
minTopFloor = 96,
|
||||
minTopRatio = 0.12,
|
||||
signalCollapsed = false,
|
||||
utilityExpanded = false,
|
||||
bottomInset = 80,
|
||||
signalHeight = 0,
|
||||
reserveViewportLane = false,
|
||||
}) {
|
||||
const viewport = Math.max(0, Number(viewportHeight) || 0);
|
||||
const minTop = Math.max(minTopFloor, viewport * minTopRatio);
|
||||
const anchoredTop = Math.max(minTop, (Number(recBottom) || 0) + recGap);
|
||||
const strip = Math.max(0, Number(stripHeight) || 0);
|
||||
const signal = Number(signalTop);
|
||||
const expandedLaneBottom = Math.max(
|
||||
0,
|
||||
viewport -
|
||||
Math.max(0, Number(bottomInset) || 0) -
|
||||
Math.max(0, Number(signalHeight) || 0),
|
||||
);
|
||||
const lowerBound =
|
||||
reserveViewportLane && signalCollapsed && utilityExpanded
|
||||
? expandedLaneBottom
|
||||
: Number.isFinite(signal)
|
||||
? signal
|
||||
: viewport;
|
||||
const lowerBound = Number.isFinite(signal) ? signal : viewport;
|
||||
const clearedTop = lowerBound - signalGap - strip;
|
||||
const top = Math.max(minTop, Math.min(anchoredTop, clearedTop));
|
||||
const floor = Math.max(0, Number(collapsedHeight) || 0) || 50;
|
||||
@@ -100,25 +79,3 @@ export function resolveCockpitUtilityLayout({
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
/** Shared Cyber panel slot, with footer controls above the lower frame (83vh). */
|
||||
export function resolveCyberCockpitPanelLane({
|
||||
viewportHeight,
|
||||
top,
|
||||
launcherHeight = 60,
|
||||
signalHeight = 44,
|
||||
contactHeight = 64,
|
||||
}) {
|
||||
const gap = 8;
|
||||
const footerHeight = Math.max(
|
||||
contactHeight + gap,
|
||||
launcherHeight + signalHeight + gap * 2,
|
||||
);
|
||||
const bottom = viewportHeight * 0.82;
|
||||
const panelHeight = Math.max(120, bottom - top - footerHeight);
|
||||
return {
|
||||
panelHeight,
|
||||
utilityHeight: panelHeight + gap + launcherHeight,
|
||||
signalTop: top + panelHeight + launcherHeight + gap * 2,
|
||||
};
|
||||
}
|
||||
@@ -4,58 +4,11 @@ import assert from 'node:assert/strict';
|
||||
import {
|
||||
resolveCockpitUtilityAnchor,
|
||||
resolveCockpitUtilityLayout,
|
||||
resolveCyberCockpitPanelLane,
|
||||
} from './cockpitUtilityLayout.js';
|
||||
|
||||
// 1512x790, the height the strip used to collide with the briefing card at.
|
||||
const desktop = { viewportHeight: 790, stripHeight: 107, collapsedHeight: 50 };
|
||||
|
||||
test('Cyber shared panel slot reserves both footer lanes above the decorative frame', () => {
|
||||
for (const viewportHeight of [600, 673, 713, 986, 1376]) {
|
||||
for (const signalHeight of [44, 76]) {
|
||||
for (const contactHeight of [44, 84, 120]) {
|
||||
const top = Math.max(164, Math.min(204, viewportHeight * 0.19));
|
||||
const lane = resolveCyberCockpitPanelLane({ viewportHeight, top, signalHeight, contactHeight });
|
||||
assert.ok(lane.panelHeight >= 120);
|
||||
assert.ok(top + lane.panelHeight + 8 + contactHeight <= viewportHeight * 0.82 + .01);
|
||||
assert.ok(lane.signalTop + signalHeight <= viewportHeight * 0.82 + .01);
|
||||
assert.equal(lane.signalTop, top + lane.utilityHeight + 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('Cyber keeps the Data Layers top while reserving briefing clearance', () => {
|
||||
for (const viewportHeight of [673, 713, 986, 1376]) {
|
||||
const leftTop = Math.max(164, Math.min(204, viewportHeight * 0.19));
|
||||
const collapsed = resolveCockpitUtilityAnchor({
|
||||
viewportHeight, stripHeight: 128, collapsedHeight: 60, recBottom: 0,
|
||||
signalTop: leftTop + 128 + 28, minTopFloor: leftTop, minTopRatio: 0,
|
||||
});
|
||||
assert.equal(collapsed.top, leftTop);
|
||||
assert.ok(collapsed.maxHeight >= 128);
|
||||
const expanded = resolveCockpitUtilityAnchor({
|
||||
viewportHeight, stripHeight: 700, collapsedHeight: 60, recBottom: 0,
|
||||
signalTop: 255, minTopFloor: leftTop, minTopRatio: 0,
|
||||
signalCollapsed: true, utilityExpanded: true, reserveViewportLane: true, signalHeight: 44,
|
||||
});
|
||||
assert.equal(expanded.top, leftTop);
|
||||
assert.equal(expanded.top + expanded.maxHeight + 8 + 44 + 80, viewportHeight);
|
||||
}
|
||||
});
|
||||
|
||||
test('expanded utilities reserve the visible collapsed briefing header at every desktop height', () => {
|
||||
for (const viewportHeight of [640, 720, 987, 1376]) {
|
||||
for (const signalHeight of [48, 76, 100]) {
|
||||
const { top, maxHeight } = resolveCockpitUtilityAnchor({
|
||||
...desktop, viewportHeight, recBottom: 0, signalTop: 255,
|
||||
signalCollapsed: true, utilityExpanded: true, signalHeight, reserveViewportLane: true,
|
||||
});
|
||||
assert.equal(top + maxHeight + 8, viewportHeight - 80 - signalHeight);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('the strip hangs 12px under the REC readout when the briefing card leaves room', () => {
|
||||
const { top } = resolveCockpitUtilityAnchor({ ...desktop, recBottom: 148.1, signalTop: 420 });
|
||||
assert.equal(Number(top.toFixed(1)), 160.1);
|
||||
@@ -101,34 +54,11 @@ test('a missing REC readout leaves the strip on the viewport ceiling', () => {
|
||||
assert.equal(top, 96);
|
||||
});
|
||||
|
||||
test('an expanded utility claims the vertical lane released by a collapsed briefing', () => {
|
||||
const { top, maxHeight } = resolveCockpitUtilityAnchor({
|
||||
...desktop,
|
||||
recBottom: 148.1,
|
||||
signalTop: 265.4,
|
||||
signalCollapsed: true,
|
||||
utilityExpanded: true,
|
||||
reserveViewportLane: true,
|
||||
});
|
||||
assert.equal(Number(top.toFixed(1)), 160.1);
|
||||
assert.equal(Number(maxHeight.toFixed(1)), 541.9);
|
||||
});
|
||||
|
||||
test('non-relocating themes preserve the visible briefing boundary even when collapsed', () => {
|
||||
test('the visible briefing card bounds the utility strip, collapsed or not', () => {
|
||||
const { top, maxHeight } = resolveCockpitUtilityAnchor({
|
||||
...desktop, recBottom: 148.1, signalTop: 265.4,
|
||||
signalCollapsed: true, utilityExpanded: true,
|
||||
});
|
||||
assert.equal(Number((top + maxHeight).toFixed(1)), 257.4);
|
||||
});
|
||||
|
||||
test('a collapsed briefing still bounds the utility strip until a panel expands', () => {
|
||||
const { maxHeight } = resolveCockpitUtilityAnchor({
|
||||
...desktop,
|
||||
recBottom: 148.1,
|
||||
signalTop: 265.4,
|
||||
signalCollapsed: true,
|
||||
});
|
||||
assert.equal(Number(maxHeight.toFixed(1)), 107);
|
||||
});
|
||||
|
||||
|
||||
+19
-106
@@ -1,5 +1,3 @@
|
||||
import { msg } from './i18n/marker.js';
|
||||
|
||||
const CONTEXT_DEPENDENCIES = Object.freeze({
|
||||
flights: new Set([
|
||||
'military-awareness',
|
||||
@@ -8,15 +6,18 @@ const CONTEXT_DEPENDENCIES = Object.freeze({
|
||||
'ais-live-vessels',
|
||||
'military-installations',
|
||||
]),
|
||||
'space-missions': new Set(['rocket-launches', 'satellites']),
|
||||
});
|
||||
const CONTEXT_COMPANIONS = new Set(['radio']);
|
||||
/** The Space Missions refusal, with the blocked layer's name as {layer}. */
|
||||
export const SPACE_MISSIONS_LAYER_BLOCK_REASON = msg(
|
||||
'Space Missions isolates replay data. Exit the mode to enable {layer}.',
|
||||
);
|
||||
const [BLOCK_REASON_PREFIX, BLOCK_REASON_SUFFIX] =
|
||||
SPACE_MISSIONS_LAYER_BLOCK_REASON.split('{layer}');
|
||||
/**
|
||||
* Layers Context never touches: Space Missions and the Satellites layer it
|
||||
* depends on. Contacts neither switches them off on entry nor restores them
|
||||
* on exit, so they run beside it in either order and keep their own state
|
||||
* (the mission controller owns the Satellites dependency).
|
||||
*/
|
||||
export const CONTEXT_INDEPENDENT_LAYER_IDS = Object.freeze([
|
||||
'rocket-launches',
|
||||
'satellites',
|
||||
]);
|
||||
/** Return whether an origin represents a direct user choice on this route. */
|
||||
export function isExplicitUserIntentOrigin(origin, layerId = null) {
|
||||
return origin === 'user' || origin === 'voice';
|
||||
@@ -27,7 +28,8 @@ export function recordContextRestoreExplicitChange({ restoreState, change }) {
|
||||
if (
|
||||
!restoreState?.enabledLayerIds ||
|
||||
change?.type !== 'visibility' ||
|
||||
!isExplicitUserIntentOrigin(change.origin, change.layerId)
|
||||
!isExplicitUserIntentOrigin(change.origin, change.layerId) ||
|
||||
CONTEXT_INDEPENDENT_LAYER_IDS.includes(change.layerId)
|
||||
)
|
||||
return false;
|
||||
if (!restoreState.explicitLayerStates)
|
||||
@@ -121,10 +123,7 @@ export async function settleUserFacingContextAction({
|
||||
* one into `userAdded` makes exit restoration re-enable the mode layer the
|
||||
* user just turned off.
|
||||
*/
|
||||
export const CONTEXT_ENTRY_LAYER_IDS = Object.freeze([
|
||||
'military-awareness',
|
||||
'rocket-launches',
|
||||
]);
|
||||
export const CONTEXT_ENTRY_LAYER_IDS = Object.freeze(['military-awareness']);
|
||||
|
||||
/**
|
||||
* Leave a Context transaction: publish the settled coordination flag, then
|
||||
@@ -193,7 +192,8 @@ export function shouldExitContextForLayerChange({
|
||||
change?.type !== 'visibility' ||
|
||||
!isExplicitUserIntentOrigin(change.origin, change.layerId) ||
|
||||
change.layerId === 'military-awareness' ||
|
||||
CONTEXT_COMPANIONS.has(change.layerId)
|
||||
CONTEXT_COMPANIONS.has(change.layerId) ||
|
||||
CONTEXT_INDEPENDENT_LAYER_IDS.includes(change.layerId)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
@@ -215,6 +215,7 @@ export function contextAllowedLayerIds(contextMode) {
|
||||
return new Set([
|
||||
...(CONTEXT_DEPENDENCIES[contextMode] || ['military-awareness']),
|
||||
...CONTEXT_COMPANIONS,
|
||||
...CONTEXT_INDEPENDENT_LAYER_IDS,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -235,21 +236,6 @@ export function shouldCaptureContextSession(change) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether one explicit mission intent superseded an in-flight Clear All
|
||||
* reservation and therefore needs deferred Context adoption.
|
||||
*/
|
||||
export function shouldDeferContextEntryDuringClear({ change, clearInFlight }) {
|
||||
return Boolean(
|
||||
clearInFlight &&
|
||||
change?.type === 'visibility-requested' &&
|
||||
change.layerId === 'rocket-launches' &&
|
||||
change.enabled === true &&
|
||||
isExplicitUserIntentOrigin(change.origin, change.layerId) &&
|
||||
Number.isInteger(change.intentEpoch),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bookkeep a user-owned layer change against the active Context session so
|
||||
* exit restoration can honor layers the user added mid-session. Two rules
|
||||
@@ -273,7 +259,8 @@ export function recordContextSessionUserChange({
|
||||
if (
|
||||
!snapshot?.userAdded ||
|
||||
change?.type !== 'visibility' ||
|
||||
!isExplicitUserIntentOrigin(change.origin, change.layerId)
|
||||
!isExplicitUserIntentOrigin(change.origin, change.layerId) ||
|
||||
CONTEXT_INDEPENDENT_LAYER_IDS.includes(change.layerId)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
@@ -319,83 +306,10 @@ export function contextSnapshotLayerIds(
|
||||
) {
|
||||
const snapshot = new Set(restoringLayerIds || currentEnabledLayerIds || []);
|
||||
for (const layerId of excludeLayerIds || []) snapshot.delete(layerId);
|
||||
for (const layerId of CONTEXT_INDEPENDENT_LAYER_IDS) snapshot.delete(layerId);
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Block layers that would mix unrelated live/current data into Space Missions.
|
||||
* The manager calls this before lifecycle work so a refused layer never starts.
|
||||
* @param {object} input Current mode and requested visibility transition.
|
||||
* @param {string|null} input.contextMode Active Context mode.
|
||||
* @param {object|null} input.change Requested visibility transition.
|
||||
* @param {string|null} [input.layerName] User-facing layer name.
|
||||
* @returns {string|null} Honest user-facing refusal reason, or null when allowed.
|
||||
*/
|
||||
export function contextLayerEnableBlockReason({
|
||||
contextMode,
|
||||
change,
|
||||
layerName = null,
|
||||
}) {
|
||||
if (
|
||||
contextMode !== 'space-missions' ||
|
||||
change?.enabled !== true ||
|
||||
contextAllowedLayerIds('space-missions').has(change.layerId)
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
const label = String(layerName || change.layerId || 'that layer');
|
||||
return SPACE_MISSIONS_LAYER_BLOCK_REASON.replace('{layer}', label);
|
||||
}
|
||||
|
||||
/**
|
||||
* The layer name from a Space Missions refusal, so the UI can rebuild the
|
||||
* sentence in its language.
|
||||
* @param {string} reason
|
||||
* @returns {{layer: string}|null} The blocked layer's name, or null when the
|
||||
* reason is not a Space Missions refusal.
|
||||
*/
|
||||
export function parseContextLayerBlockReason(reason) {
|
||||
if (
|
||||
typeof reason !== 'string' ||
|
||||
!reason.startsWith(BLOCK_REASON_PREFIX) ||
|
||||
!reason.endsWith(BLOCK_REASON_SUFFIX) ||
|
||||
reason.length <= BLOCK_REASON_PREFIX.length + BLOCK_REASON_SUFFIX.length
|
||||
)
|
||||
return null;
|
||||
return {
|
||||
layer: reason.slice(
|
||||
BLOCK_REASON_PREFIX.length,
|
||||
reason.length - BLOCK_REASON_SUFFIX.length,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve who owns a cancelled direct Space Missions entry. A newer ON keeps
|
||||
* the entry shell reserved for its replacement transaction; every other
|
||||
* cancellation must roll back the isolated pre-entry session.
|
||||
*
|
||||
* @param {object} input Cancellation and current manager intent state.
|
||||
* @param {object|null} input.change Manager visibility notification.
|
||||
* @returns {'ignore'|'replacement'|'restore'} Cancellation disposition.
|
||||
*/
|
||||
export function spaceMissionEntryCancellationDisposition({ change }) {
|
||||
if (
|
||||
change?.type !== 'visibility-cancelled' ||
|
||||
change.layerId !== 'rocket-launches' ||
|
||||
change.enabled !== true
|
||||
)
|
||||
return 'ignore';
|
||||
if (
|
||||
change.cancellationReason === 'superseded' &&
|
||||
Number.isInteger(change.successorIntentEpoch) &&
|
||||
change.successorIntentEpoch > change.intentEpoch &&
|
||||
change.successorEnabled === true
|
||||
)
|
||||
return 'replacement';
|
||||
return 'restore';
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge the pre-entry layer snapshot with layers the user enabled during the
|
||||
* Context session so both survive restoration.
|
||||
@@ -510,7 +424,6 @@ export function subjectEntryAllowed({
|
||||
*/
|
||||
export const CONTEXT_MODE_VOICE_NAMES = Object.freeze({
|
||||
flights: 'contacts',
|
||||
'space-missions': 'space-missions',
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
+63
-111
@@ -5,7 +5,6 @@ import {
|
||||
orbitEntryAllowed,
|
||||
cockpitEntryAllowed,
|
||||
contextAllowedLayerIds,
|
||||
contextLayerEnableBlockReason,
|
||||
contextRestoreLayerIds,
|
||||
isExplicitUserIntentOrigin,
|
||||
mergeContextTransitionErrors,
|
||||
@@ -17,9 +16,7 @@ import {
|
||||
settleContextIntentReplay,
|
||||
settleUserFacingContextAction,
|
||||
shouldCaptureContextSession,
|
||||
shouldDeferContextEntryDuringClear,
|
||||
shouldExitContextForLayerChange,
|
||||
spaceMissionEntryCancellationDisposition,
|
||||
} from './contextModePolicy.js';
|
||||
|
||||
test('Context transition errors preserve primary identity and aggregate failed layers', () => {
|
||||
@@ -119,11 +116,6 @@ test('user-enabled layers are additive and do not exit Context', () => {
|
||||
globalContextEnabled: true,
|
||||
change: userEnable('earthquakes'),
|
||||
}), false);
|
||||
assert.equal(shouldExitContextForLayerChange({
|
||||
contextMode: 'space-missions',
|
||||
globalContextEnabled: false,
|
||||
change: userEnable('traffic'),
|
||||
}), false);
|
||||
assert.equal(shouldExitContextForLayerChange({
|
||||
contextMode: null,
|
||||
globalContextEnabled: true,
|
||||
@@ -133,48 +125,16 @@ test('user-enabled layers are additive and do not exit Context', () => {
|
||||
|
||||
test('programmatic Context dependencies and direct mode setup remain allowed', () => {
|
||||
assert.equal(shouldExitContextForLayerChange({
|
||||
contextMode: 'space-missions',
|
||||
contextMode: 'flights',
|
||||
globalContextEnabled: true,
|
||||
change: { ...userEnable('satellites'), origin: 'programmatic' },
|
||||
change: { ...userEnable('military'), enabled: false, origin: 'programmatic' },
|
||||
}), false);
|
||||
});
|
||||
|
||||
test('Space Missions cancellation retains only a newer authoritative ON entry', () => {
|
||||
const cancelledEntry = {
|
||||
type: 'visibility-cancelled',
|
||||
layerId: 'rocket-launches',
|
||||
enabled: true,
|
||||
intentEpoch: 8,
|
||||
cancellationReason: 'superseded',
|
||||
successorIntentEpoch: 9,
|
||||
successorEnabled: true,
|
||||
successorOrigin: 'programmatic',
|
||||
};
|
||||
assert.equal(spaceMissionEntryCancellationDisposition({
|
||||
change: cancelledEntry,
|
||||
}), 'replacement');
|
||||
assert.equal(spaceMissionEntryCancellationDisposition({
|
||||
change: { ...cancelledEntry, successorEnabled: false },
|
||||
}), 'restore', 'a newer OFF releases the entry shell');
|
||||
assert.equal(spaceMissionEntryCancellationDisposition({
|
||||
change: {
|
||||
...cancelledEntry,
|
||||
cancellationReason: 'caller-abort',
|
||||
successorIntentEpoch: undefined,
|
||||
successorEnabled: undefined,
|
||||
},
|
||||
}), 'restore', 'caller abort at the same epoch restores the isolated session');
|
||||
assert.equal(spaceMissionEntryCancellationDisposition({
|
||||
change: { ...cancelledEntry, enabled: false },
|
||||
currentIntentEpoch: 9,
|
||||
effectivelyEnabled: true,
|
||||
}), 'ignore');
|
||||
});
|
||||
|
||||
test('only explicit user-owned shell enables capture a Context restoration snapshot', () => {
|
||||
const userMissionEnable = {
|
||||
type: 'visibility-requested',
|
||||
layerId: 'rocket-launches',
|
||||
layerId: 'military-awareness',
|
||||
enabled: true,
|
||||
origin: 'user',
|
||||
};
|
||||
@@ -186,40 +146,25 @@ test('only explicit user-owned shell enables capture a Context restoration snaps
|
||||
assert.equal(shouldCaptureContextSession({ ...userMissionEnable, origin: 'context-restore' }), false);
|
||||
assert.equal(shouldCaptureContextSession({ ...userMissionEnable, enabled: false }), false);
|
||||
assert.equal(shouldCaptureContextSession({ ...userMissionEnable, layerId: 'satellites' }), false);
|
||||
assert.equal(
|
||||
shouldCaptureContextSession({ ...userMissionEnable, layerId: 'rocket-launches' }),
|
||||
false,
|
||||
'Space Missions is an ordinary layer, not a Context entry',
|
||||
);
|
||||
});
|
||||
|
||||
test('voice dependency OFF exits Space Missions like the equivalent UI action', () => {
|
||||
test('voice dependency OFF exits Contacts like the equivalent UI action', () => {
|
||||
assert.equal(shouldExitContextForLayerChange({
|
||||
contextMode: 'space-missions',
|
||||
contextMode: 'flights',
|
||||
globalContextEnabled: false,
|
||||
change: { type: 'visibility', layerId: 'satellites', enabled: false, origin: 'voice' },
|
||||
change: { type: 'visibility', layerId: 'flights', enabled: false, origin: 'voice' },
|
||||
}), true);
|
||||
});
|
||||
|
||||
test('only a newer explicit mission request is deferred during Clear All', () => {
|
||||
const change = {
|
||||
type: 'visibility-requested',
|
||||
layerId: 'rocket-launches',
|
||||
enabled: true,
|
||||
origin: 'voice',
|
||||
intentEpoch: 12,
|
||||
};
|
||||
assert.equal(shouldDeferContextEntryDuringClear({ change, clearInFlight: true }), true);
|
||||
assert.equal(shouldDeferContextEntryDuringClear({ change, clearInFlight: false }), false);
|
||||
assert.equal(shouldDeferContextEntryDuringClear({
|
||||
change: { ...change, origin: 'programmatic' },
|
||||
clearInFlight: true,
|
||||
}), false);
|
||||
assert.equal(shouldDeferContextEntryDuringClear({
|
||||
change: { ...change, enabled: false },
|
||||
clearInFlight: true,
|
||||
}), false);
|
||||
});
|
||||
|
||||
test('a rapid re-entry snapshots the settled restore target, not partial manager state', () => {
|
||||
assert.deepEqual(
|
||||
[...contextSnapshotLayerIds(
|
||||
new Set(['rocket-launches', 'earthquakes']),
|
||||
new Set(['cctv', 'earthquakes']),
|
||||
new Set(['flights', 'traffic']),
|
||||
)],
|
||||
['flights', 'traffic'],
|
||||
@@ -230,31 +175,15 @@ test('a rapid re-entry snapshots the settled restore target, not partial manager
|
||||
);
|
||||
assert.deepEqual(
|
||||
[...contextSnapshotLayerIds(
|
||||
new Set(['rocket-launches', 'satellites']),
|
||||
new Set(['military-awareness', 'cctv']),
|
||||
null,
|
||||
['rocket-launches'],
|
||||
['military-awareness'],
|
||||
)],
|
||||
['satellites'],
|
||||
['cctv'],
|
||||
'the synchronous entry intent is not part of the pre-entry snapshot',
|
||||
);
|
||||
});
|
||||
|
||||
test('Space Missions blocks unrelated layer enables before replay data can mix', () => {
|
||||
const change = { layerId: 'flights', enabled: true, origin: 'user' };
|
||||
assert.match(
|
||||
contextLayerEnableBlockReason({ contextMode: 'space-missions', change, layerName: 'Live Flights' }),
|
||||
/Exit the mode to enable Live Flights/,
|
||||
);
|
||||
assert.equal(contextLayerEnableBlockReason({
|
||||
contextMode: 'space-missions',
|
||||
change: { ...change, layerId: 'satellites' },
|
||||
}), null);
|
||||
assert.equal(contextLayerEnableBlockReason({
|
||||
contextMode: 'flights',
|
||||
change,
|
||||
}), null, 'live cockpit keeps additive user layers');
|
||||
});
|
||||
|
||||
test('the Global Context shell and layers selected while Context is off remain allowed', () => {
|
||||
assert.equal(shouldExitContextForLayerChange({
|
||||
contextMode: null,
|
||||
@@ -275,14 +204,38 @@ test('manually disabling a mode dependency exits that Context bundle', () => {
|
||||
change: { ...userEnable('military'), enabled: false },
|
||||
}), true);
|
||||
assert.equal(shouldExitContextForLayerChange({
|
||||
contextMode: 'space-missions',
|
||||
contextMode: 'flights',
|
||||
globalContextEnabled: false,
|
||||
change: { ...userEnable('satellites'), enabled: false },
|
||||
}), true);
|
||||
}), false, 'Satellites is not a Contacts dependency');
|
||||
});
|
||||
|
||||
test('Context never isolates, snapshots, restores or bookkeeps Space Missions and Satellites', () => {
|
||||
for (const layerId of ['rocket-launches', 'satellites']) {
|
||||
assert.equal(contextAllowedLayerIds('flights').has(layerId), true);
|
||||
const snapshot = { userAdded: new Set(), userRemoved: new Set() };
|
||||
for (const enabled of [true, false]) {
|
||||
assert.equal(recordContextSessionUserChange({
|
||||
snapshot,
|
||||
change: { type: 'visibility', origin: 'user', layerId, enabled },
|
||||
effectiveContextMode: 'flights',
|
||||
}), false);
|
||||
const restoreState = { enabledLayerIds: new Set() };
|
||||
assert.equal(recordContextRestoreExplicitChange({
|
||||
restoreState,
|
||||
change: { type: 'visibility', origin: 'user', layerId, enabled },
|
||||
}), false);
|
||||
}
|
||||
assert.equal(snapshot.userAdded.size + snapshot.userRemoved.size, 0);
|
||||
}
|
||||
assert.deepEqual(
|
||||
[...contextSnapshotLayerIds(new Set(['rocket-launches', 'satellites', 'cctv']))],
|
||||
['cctv'],
|
||||
);
|
||||
});
|
||||
|
||||
test('Radio remains an independent companion across Context transitions', () => {
|
||||
for (const contextMode of ['flights', 'space-missions']) {
|
||||
for (const contextMode of ['flights', null]) {
|
||||
for (const enabled of [true, false]) {
|
||||
assert.equal(shouldExitContextForLayerChange({
|
||||
contextMode,
|
||||
@@ -292,21 +245,17 @@ test('Radio remains an independent companion across Context transitions', () =>
|
||||
}
|
||||
assert.equal(contextAllowedLayerIds(contextMode).has('radio'), true);
|
||||
}
|
||||
assert.equal(contextLayerEnableBlockReason({
|
||||
contextMode: 'space-missions',
|
||||
change: { type: 'visibility', origin: 'user', layerId: 'radio', enabled: true },
|
||||
layerName: 'Radio',
|
||||
}), null);
|
||||
});
|
||||
|
||||
test('each Context mode exposes only its shell and dependencies', () => {
|
||||
assert.deepEqual(
|
||||
[...contextAllowedLayerIds(null)],
|
||||
['military-awareness', 'radio'],
|
||||
['military-awareness', 'radio', 'rocket-launches', 'satellites'],
|
||||
);
|
||||
assert.deepEqual(
|
||||
[...contextAllowedLayerIds('space-missions')],
|
||||
['rocket-launches', 'satellites', 'radio'],
|
||||
['military-awareness', 'radio', 'rocket-launches', 'satellites'],
|
||||
'Space Missions is not a Context mode',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -332,7 +281,7 @@ test('Context restoration honors an explicit companion disable', () => {
|
||||
});
|
||||
|
||||
test('the latest explicit Radio state wins across a Context session', () => {
|
||||
for (const effectiveContextMode of [null, 'flights', 'space-missions']) {
|
||||
for (const effectiveContextMode of [null, 'flights']) {
|
||||
for (const origin of ['user', 'voice']) {
|
||||
const snapshot = { userAdded: new Set(), userRemoved: new Set() };
|
||||
const record = (enabled) => recordContextSessionUserChange({
|
||||
@@ -368,7 +317,7 @@ test('only direct UI and voice origins count as explicit Context intent', () =>
|
||||
assert.equal(recordContextSessionUserChange({
|
||||
snapshot,
|
||||
change: { type: 'visibility', origin, layerId: 'radio', enabled: true },
|
||||
effectiveContextMode: 'space-missions',
|
||||
effectiveContextMode: 'flights',
|
||||
}), false);
|
||||
assert.equal(snapshot.userAdded.size, 0);
|
||||
}
|
||||
@@ -526,16 +475,8 @@ test('the teardown guard re-publishes on the way out, so a mid-flight exit is no
|
||||
|
||||
test('the session-starting entry layer is never bookkept as user-added (chip ON→OFF restores exactly)', () => {
|
||||
const snapshot = { enabledLayerIds: new Set(['flights', 'ais-live-vessels']), userAdded: new Set() };
|
||||
// The exact left-panel regression: the rockets enable event lands while the
|
||||
// mode is still being entered (or even null); it must not survive its own exit.
|
||||
for (const effectiveContextMode of ['space-missions', null]) {
|
||||
recordContextSessionUserChange({
|
||||
snapshot,
|
||||
change: { type: 'visibility', layerId: 'rocket-launches', enabled: true, origin: 'user' },
|
||||
effectiveContextMode,
|
||||
});
|
||||
assert.equal(snapshot.userAdded.has('rocket-launches'), false);
|
||||
}
|
||||
// The entry layer's enable event lands while the mode is still being
|
||||
// entered; it must not survive its own exit.
|
||||
recordContextSessionUserChange({
|
||||
snapshot,
|
||||
change: { type: 'visibility', layerId: 'military-awareness', enabled: true, origin: 'user' },
|
||||
@@ -559,10 +500,21 @@ test('mid-session user additions are recorded, removed on disable, and judged ag
|
||||
// A dependency of the mode being ENTERED is not a user addition.
|
||||
recordContextSessionUserChange({
|
||||
snapshot,
|
||||
change: { type: 'visibility', layerId: 'satellites', enabled: true, origin: 'user' },
|
||||
effectiveContextMode: 'space-missions',
|
||||
change: { type: 'visibility', layerId: 'military', enabled: true, origin: 'user' },
|
||||
effectiveContextMode: 'flights',
|
||||
});
|
||||
assert.equal(snapshot.userAdded.has('satellites'), false);
|
||||
assert.equal(snapshot.userAdded.has('military'), false);
|
||||
// Space Missions is not Context's: it is never bookkept.
|
||||
recordContextSessionUserChange({
|
||||
snapshot,
|
||||
change: { type: 'visibility', layerId: 'rocket-launches', enabled: true, origin: 'user' },
|
||||
effectiveContextMode: 'flights',
|
||||
});
|
||||
assert.equal(
|
||||
snapshot.userAdded.has('rocket-launches'),
|
||||
false,
|
||||
'Space Missions is not Context state',
|
||||
);
|
||||
// Disabling a recorded addition removes it before any exit restore reads it.
|
||||
recordContextSessionUserChange({
|
||||
snapshot,
|
||||
|
||||
@@ -13,10 +13,7 @@ const radioControlsSource = readRadioSource(new URL('./ui/radioControls.js', imp
|
||||
// - session bookkeeping ran AFTER the exit early-return, so the compensating
|
||||
// userAdded.delete never ran on the left-panel chip exit and restoration
|
||||
// resurrected the mission layer the user just disabled;
|
||||
// - the effective mode was read AFTER the entering flag was cleared, so the
|
||||
// entry layer's own enable event was judged against a null mode;
|
||||
// - a failed Space Missions START from the chip route cleared siblings with
|
||||
// no rollback;
|
||||
// - a failed direct Contacts START cleared siblings with no rollback;
|
||||
// - the right-rail entry ignored the activation result entirely.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
@@ -33,25 +30,20 @@ test('context handler: session bookkeeping runs before the exit early-return', (
|
||||
assert.ok(record < exit, 'bookkeeping must precede the exit check');
|
||||
});
|
||||
|
||||
test('context handler: effective mode is read before the entering flag is cleared', () => {
|
||||
const effective = handler.indexOf('this._contextModeEntering || this._contextMode');
|
||||
const clear = handler.indexOf('this._contextModeEntering = null');
|
||||
assert.ok(effective > 0, 'effective-mode read present');
|
||||
assert.ok(clear > 0, 'entering-flag clear present');
|
||||
assert.ok(effective < clear, 'effective mode must be captured first');
|
||||
test('Space Missions is an ordinary layer the Context handler never enters', () => {
|
||||
assert.doesNotMatch(handler, /'space-missions'/);
|
||||
assert.doesNotMatch(handler, /_contextModeEntering = /);
|
||||
const attach = connectContextManager.toString();
|
||||
assert.doesNotMatch(attach, /rocket-launches|space-missions/);
|
||||
});
|
||||
|
||||
test('cancelled Space Missions entry resolves ownership before settled bookkeeping', () => {
|
||||
test('a cancelled visibility request returns before settled bookkeeping', () => {
|
||||
const cancelled = handler.indexOf("change?.type === 'visibility-cancelled'");
|
||||
const bookkeeping = handler.indexOf('recordContextSessionUserChange(');
|
||||
assert.ok(cancelled > 0, 'cancellation branch present');
|
||||
assert.ok(cancelled < bookkeeping, 'cancellation returns before settled session bookkeeping');
|
||||
const branch = handler.slice(cancelled, handler.indexOf("change?.type === 'visibility-blocked'"));
|
||||
assert.match(branch, /spaceMissionEntryCancellationDisposition\(\{/);
|
||||
assert.match(branch, /cancellationDisposition === 'replacement'[\s\S]*?_contextModeEntering = 'space-missions'[\s\S]*?entryIntent\.intentEpoch === change\.intentEpoch[\s\S]*?_contextModeReplacementIntent = \{[\s\S]*?intentEpoch: change\.successorIntentEpoch/);
|
||||
assert.match(branch, /cancellationDisposition === 'restore'[\s\S]*?_contextModeEntering = null/);
|
||||
assert.match(branch, /_restoreContextSessionAfterLayerSettles\(/);
|
||||
assert.match(branch, /return;/);
|
||||
assert.match(branch, /this\._syncContextModeButtons\(\);\s*return;/);
|
||||
});
|
||||
|
||||
test('direct Context entry captures on the synchronous request boundary', () => {
|
||||
@@ -60,18 +52,29 @@ test('direct Context entry captures on the synchronous request boundary', () =>
|
||||
attach,
|
||||
/subscribeVisibilityRequests\(\(change\) => \{[\s\S]*?shouldCaptureContextSession\(change\)/,
|
||||
);
|
||||
assert.match(
|
||||
attach,
|
||||
/_captureContextSessionSnapshot\(\{\s*excludeLayerIds:\s*\[change\.layerId\],?\s*\}\)/,
|
||||
);
|
||||
});
|
||||
|
||||
test('Clear All defers a newer explicit mission guard until its batch settles', () => {
|
||||
const attach = connectContextManager.toString();
|
||||
assert.match(attach, /shouldDeferContextEntryDuringClear\(\{/);
|
||||
assert.match(attach, /_contextModeDeferredEntryIntent = \{/);
|
||||
assert.match(attach, /await this\._clearSelectedLayersManagerPromise/);
|
||||
assert.match(attach, /await this\._clearLayersOutsideContextMode\(entryMode/);
|
||||
test('only a direct Contacts entry request snapshots the layers', () => {
|
||||
let request;
|
||||
const controls = new ContextControls({
|
||||
elements: {},
|
||||
installations: {},
|
||||
actions: { getCockpit: () => null },
|
||||
});
|
||||
const captures = [];
|
||||
controls._captureContextSessionSnapshot = (options) => captures.push(options);
|
||||
controls._syncContextModeButtons = () => {};
|
||||
controls.connect({
|
||||
subscribe: () => () => {},
|
||||
subscribeVisibilityRequests(listener) {
|
||||
request = listener;
|
||||
return () => {};
|
||||
},
|
||||
});
|
||||
for (const layerId of ['rocket-launches', 'military-awareness'])
|
||||
request({ type: 'visibility-requested', layerId, enabled: true, origin: 'user', intentEpoch: 1 });
|
||||
controls.stop();
|
||||
assert.deepEqual(captures, [{ excludeLayerIds: ['military-awareness'] }]);
|
||||
});
|
||||
|
||||
test('context restore replays explicit companion intent after the stale restore queue drains', () => {
|
||||
@@ -91,7 +94,7 @@ test('context restore settles the Contacts coordinator before dependency fanout'
|
||||
assert.ok(settle > 0, 'Contacts coordinator settlement is present');
|
||||
assert.ok(coordinatorOff > settle, 'Contacts OFF is awaited');
|
||||
assert.ok(fanout > coordinatorOff, 'snapshot fanout starts after Contacts settles');
|
||||
assert.match(restore, /excludeLayerIds: settleContactsCoordinator[\s\S]*?contactsCoordinatorId/);
|
||||
assert.match(restore, /excludeLayerIds: \[[\s\S]*?CONTEXT_INDEPENDENT_LAYER_IDS[\s\S]*?settleContactsCoordinator \? \[contactsCoordinatorId\]/);
|
||||
});
|
||||
|
||||
test('Clear All during the Contacts settle stops the snapshot coming back', () => {
|
||||
@@ -116,7 +119,7 @@ test('context handler: either failed direct Context-shell start rolls the sessio
|
||||
handler.indexOf("change?.type === 'visibility-failed'"),
|
||||
handler.indexOf("change?.type === 'visibility-will-change'"),
|
||||
);
|
||||
assert.match(failedBranch, /\['military-awareness', 'rocket-launches'\]\.includes\(change\.layerId\)/);
|
||||
assert.match(failedBranch, /change\.layerId === 'military-awareness' &&/);
|
||||
assert.match(
|
||||
failedBranch,
|
||||
/_restoreContextSessionAfterLayerSettles\(\s*change\.layerId,\s*\{\s*notificationToken,?\s*\},?\s*\)/,
|
||||
@@ -154,14 +157,14 @@ test('wrapped visibility blocks leave the accessible toast to the wrapper token
|
||||
|
||||
test('every user-facing Context exit route settles through the failure surface', () => {
|
||||
const initPanel = _initGlobalContextPanel.toString();
|
||||
assert.equal((initPanel.match(/void this\._runUserFacingContextAction/g) || []).length, 3);
|
||||
assert.equal((initPanel.match(/void this\._runUserFacingContextAction/g) || []).length, 2);
|
||||
assert.doesNotMatch(initPanel, /falseIsFailure:\s*false/);
|
||||
assert.doesNotMatch(initPanel, /void this\._selectContextMode/);
|
||||
|
||||
const deactivationCalls = [...handler.matchAll(
|
||||
/void this\._trackContextLayerReaction\(\s*this\._runUserFacingContextAction\(\(notificationToken\) =>\s*this\._deactivateContextForLayerChange\(\{ notificationToken \}\),?\s*\),?\s*\)/g,
|
||||
)];
|
||||
assert.equal(deactivationCalls.length, 4, 'dependency and primary layer exits share the caught restore path');
|
||||
assert.equal(deactivationCalls.length, 3, 'dependency and primary layer exits share the caught restore path');
|
||||
assert.doesNotMatch(handler, /void this\._deactivateContextForLayerChange\(\)/);
|
||||
});
|
||||
|
||||
@@ -193,10 +196,7 @@ test('right-rail context entry is transactional: activation result gates the mod
|
||||
const failureBlock = select.slice(activation);
|
||||
assert.match(failureBlock, /activated = await activationIntent\.promise/);
|
||||
assert.match(failureBlock, /catch \(error\) \{\s*activationError = error;/);
|
||||
assert.match(failureBlock, /_contextModeReplacementIntent\?\.generation === generation/);
|
||||
assert.match(failureBlock, /await this\._dataManager\._waitForVisibilityIntent\?\.\(/);
|
||||
assert.match(failureBlock, /outcome\?\.intentEpoch === replacementIntent\.intentEpoch[\s\S]*?outcome\.succeeded === true/);
|
||||
assert.match(failureBlock, /outcome\?\.cancellationReason === 'superseded'[\s\S]*?outcome\.successorEnabled === true[\s\S]*?outcome\.successorIntentEpoch > replacementIntent\.intentEpoch/);
|
||||
assert.match(failureBlock, /activationError\s*\|\|\s*activated === false\s*\|\|\s*!this\._dataManager\.isEnabled\(entryLayerId\)/);
|
||||
assert.match(failureBlock, /cancelledAndSettled\s*=\s*terminalIntentOutcome\?\.succeeded === false/);
|
||||
assert.match(failureBlock, /\['caller-abort', 'resource-abort', 'superseded'\]/);
|
||||
@@ -216,9 +216,11 @@ test('Context entry awaits isolation and direct shell routes isolate in the visi
|
||||
// rests on Context OFF; the honesty lives in the REPORT, not in a racy
|
||||
// attempt to put the prior mode back (see the note above
|
||||
// _restoreContextSessionAfterLayerSettles).
|
||||
const capture = select.indexOf('this._captureContextSessionSnapshot(');
|
||||
assert.ok(capture > 0, 'Context snapshot capture is missing');
|
||||
const crossMode = select.slice(
|
||||
select.indexOf('const crossModeSwitch = Boolean('),
|
||||
select.indexOf('this._captureContextSessionSnapshot();'),
|
||||
capture,
|
||||
);
|
||||
assert.ok(crossMode, 'cross-mode teardown block is missing');
|
||||
assert.doesNotMatch(crossMode, /if \(signal\?\.aborted\)[\s\S]*?await this\._restoreContextSession/);
|
||||
@@ -242,10 +244,10 @@ test('Context entry awaits isolation and direct shell routes isolate in the visi
|
||||
assert.match(ContextControls.prototype.stop.toString(), /this\._contextModeGeneration\+\+/);
|
||||
|
||||
const guard = connectContextManager.toString();
|
||||
assert.match(guard, /\['military-awareness', 'rocket-launches'\]\.includes\(change\.layerId\)/);
|
||||
assert.match(guard, /change\.layerId !== 'military-awareness'/);
|
||||
assert.match(guard, /const notificationToken\s*=\s*change\.notificationToken\s*\|\|\s*Symbol\('direct-context-shell-entry'\)/);
|
||||
assert.match(guard, /this\._userFacingContextNotificationTokens\.add\(notificationToken\)/);
|
||||
assert.match(guard, /await this\._clearLayersOutsideContextMode\(entryMode,\s*\{\s*notificationToken,?\s*\}\)/);
|
||||
assert.match(guard, /await this\._clearLayersOutsideContextMode\(null,\s*\{\s*notificationToken,?\s*\}\)/);
|
||||
assert.match(
|
||||
guard,
|
||||
/await this\._restoreContextSession\(\{\s*excludeLayerIds: \[change\.layerId\],\s*notificationToken,\s*\}\)/,
|
||||
|
||||
@@ -2,7 +2,9 @@ import { renderApplicationHtml } from './testSupport/applicationHtml.mjs';
|
||||
import { readStylesheet } from './testSupport/readStylesheet.mjs';
|
||||
import { _selectContextMode } from './ui/contextTransactions.js';
|
||||
import { _initGlobalContextPanel } from './ui/contextBindings.js';
|
||||
import { ContextControls } from './ui/contextControls.js';
|
||||
import { clearSelectedLayers } from './ui/contextActions.js';
|
||||
import { PANEL_RAIL_ITEMS } from './ui/panelRailCatalog.js';
|
||||
import { readFileSync as readRadioSource } from 'node:fs';
|
||||
const radioBindings = readRadioSource(
|
||||
new URL('./ui/radioBindings.js', import.meta.url),
|
||||
@@ -21,43 +23,24 @@ const html = await renderApplicationHtml(
|
||||
);
|
||||
const css = readStylesheet(new URL('../style.css', import.meta.url));
|
||||
|
||||
test('Contacts and Space Missions both participate in the ordinary Tab sequence', () => {
|
||||
for (const id of [
|
||||
'global-context-flights-btn',
|
||||
'global-context-missions-btn',
|
||||
]) {
|
||||
const button = html.match(
|
||||
new RegExp(`<button id="${id}"[\\s\\S]*?</button>`),
|
||||
);
|
||||
assert.ok(button, `${id} is missing`);
|
||||
assert.match(button[0], /role="tab"/);
|
||||
assert.match(button[0], /tabindex="0"/);
|
||||
}
|
||||
|
||||
// The view keeps both tabs' tabindex static and never disables them; the
|
||||
// transition itself is covered over happy-dom in ui/contextPanel.test.mjs.
|
||||
for (const id of [
|
||||
'global-context-flights-btn',
|
||||
'global-context-missions-btn',
|
||||
]) {
|
||||
const tag = contextView.match(new RegExp(`<button id="${id}"[^>]*>`))?.[0];
|
||||
assert.ok(tag, `${id} is missing from the view`);
|
||||
assert.doesNotMatch(tag, /:tabindex|:disabled|\sdisabled/);
|
||||
}
|
||||
test('Contacts stays in the keyboard sequence and Space Missions owns its rail item', () => {
|
||||
const button = html.match(
|
||||
/<button id="global-context-flights-btn"[\s\S]*?<\/button>/,
|
||||
)?.[0];
|
||||
assert.ok(button, 'Contacts control is missing');
|
||||
assert.match(button, /role="tab"/);
|
||||
assert.match(button, /tabindex="0"/);
|
||||
const tag = contextView.match(/<button id="global-context-flights-btn"[^>]*>/)?.[0];
|
||||
assert.ok(tag, 'Contacts control is missing from the view');
|
||||
assert.doesNotMatch(tag, /:tabindex|:disabled|\sdisabled/);
|
||||
assert.doesNotMatch(html, /id="global-context-missions-btn"/);
|
||||
assert.match(html, /id="space-missions-panel"[^>]*data-panel-id="space-missions-panel"/);
|
||||
assert.equal(PANEL_RAIL_ITEMS['space-missions-panel'].icon, 'rocket_launch');
|
||||
});
|
||||
|
||||
test('Context activation and Clear All never native-disable tabs and guard repeated clicks', () => {
|
||||
const init = _initGlobalContextPanel.toString();
|
||||
const select = _selectContextMode.toString();
|
||||
const clear = clearSelectedLayers.toString();
|
||||
assert.equal(
|
||||
(
|
||||
init.match(
|
||||
/if \(\s*this\.destroyed\s*\|\|\s*this\._contextModeChanging\s*\|\|\s*this\._clearSelectedLayersPromise\s*\)\s*return;/g,
|
||||
) || []
|
||||
).length,
|
||||
2,
|
||||
);
|
||||
assert.doesNotMatch(
|
||||
select,
|
||||
/_globalContext(?:Flights|Missions)Btn\.disabled\s*=\s*true/,
|
||||
@@ -68,17 +51,29 @@ test('Context activation and Clear All never native-disable tabs and guard repea
|
||||
);
|
||||
});
|
||||
|
||||
test('Context tablist retains Left, Right, Home, and End keyboard navigation', () => {
|
||||
const initSource = _initGlobalContextPanel.toString();
|
||||
assert.match(initSource, /event\.key === 'ArrowRight'/);
|
||||
assert.match(initSource, /event\.key === 'ArrowLeft'/);
|
||||
assert.match(initSource, /event\.key === 'Home'/);
|
||||
assert.match(initSource, /event\.key === 'End'/);
|
||||
assert.match(
|
||||
initSource,
|
||||
/contextTabs\[nextIndex\]\.focus\(\{ preventScroll: true \}\)/,
|
||||
);
|
||||
assert.match(initSource, /contextTabs\[nextIndex\]\.click\(\)/);
|
||||
test('a Contacts click while Context is busy is ignored', () => {
|
||||
const button = new EventTarget();
|
||||
const controls = new ContextControls({
|
||||
elements: { _globalContextFlightsBtn: button },
|
||||
installations: {},
|
||||
actions: { getCockpit: () => null, claimVisualAuthority() {} },
|
||||
});
|
||||
const runs = [];
|
||||
controls._runUserFacingContextAction = (operation) => {
|
||||
runs.push(operation);
|
||||
return Promise.resolve(false);
|
||||
};
|
||||
const click = () => button.dispatchEvent(new Event('click'));
|
||||
controls._contextModeChanging = true;
|
||||
click();
|
||||
controls._contextModeChanging = false;
|
||||
controls._clearSelectedLayersPromise = Promise.resolve();
|
||||
click();
|
||||
assert.equal(runs.length, 0, 'a transition or Clear All in flight drops it');
|
||||
controls._clearSelectedLayersPromise = null;
|
||||
click();
|
||||
assert.equal(runs.length, 1, 'an idle panel takes the click');
|
||||
controls.stop();
|
||||
});
|
||||
|
||||
test('Context tabs draw a visible keyboard-focus outline including active tabs', () => {
|
||||
@@ -102,7 +97,6 @@ test('Context tabs draw a visible keyboard-focus outline including active tabs',
|
||||
});
|
||||
|
||||
test('Context async action buttons remain focused while busy', () => {
|
||||
const init = _initGlobalContextPanel.toString();
|
||||
const radio = radioBindings.slice(
|
||||
radioBindings.indexOf('const toggleRadio = async (trigger) => {'),
|
||||
radioBindings.indexOf('this._storeToken = this.store?.connect?.('),
|
||||
@@ -113,6 +107,7 @@ test('Context async action buttons remain focused while busy', () => {
|
||||
);
|
||||
const clear = clearSelectedLayers.toString();
|
||||
|
||||
const init = _initGlobalContextPanel.toString();
|
||||
assert.match(init, /if \(this\._installationsSearchBusy\) return;/);
|
||||
assert.doesNotMatch(init, /\.disabled\s*=\s*true/);
|
||||
const search = contextView.match(
|
||||
@@ -220,7 +215,7 @@ test('Context reads as one segmented control with legible type and no halo', ()
|
||||
// open Context title legible; no Context-only rule dims it again.
|
||||
assert.equal(
|
||||
rule(
|
||||
":root:not([data-ui-theme='cyber']) #global-context-panel:not(.collapsed) .panel-title",
|
||||
":root #global-context-panel:not(.collapsed) .panel-title",
|
||||
),
|
||||
'',
|
||||
);
|
||||
|
||||
+288
-38
@@ -6,6 +6,12 @@ import test from 'node:test';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
// The Omnibar's desktop footer (src/ui/styles/omnibar-dock.css) is part of
|
||||
// the cascade below like every other stylesheet; its rules carry the
|
||||
// Omnibar scope, so they are modelled as a layout of their own.
|
||||
const omnibarCss = readStylesheet(
|
||||
path.join(ROOT, 'src/ui/styles/omnibar-dock.css'),
|
||||
);
|
||||
const css = readStylesheet(path.join(ROOT, 'style.css'));
|
||||
|
||||
/*
|
||||
@@ -125,11 +131,56 @@ function specificity(selector) {
|
||||
return [ids, classes, types];
|
||||
}
|
||||
|
||||
/** Flatten style.css into rules carrying their raw media stack. */
|
||||
/** Collapse whitespace and the padding inside brackets of a selector. */
|
||||
const tidySelector = (part) =>
|
||||
part
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim()
|
||||
.replace(/\(\s+/g, '(')
|
||||
.replace(/\s+\)/g, ')');
|
||||
|
||||
/**
|
||||
* A nested selector resolved against its parent rule's selectors, as CSS
|
||||
* nesting does: `&` stands for the parent, and a selector without one is a
|
||||
* descendant of it.
|
||||
*/
|
||||
function nestSelectors(parents, head) {
|
||||
const own = splitTopLevel(head, ',').map(tidySelector).filter(Boolean);
|
||||
if (!parents) return own;
|
||||
return parents.flatMap((parent) =>
|
||||
own.map((part) =>
|
||||
part.includes('&') ? part.replaceAll('&', parent) : `${parent} ${part}`,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Flatten style.css into rules carrying their raw media stack. Nested style
|
||||
* rules (CSS nesting) and media queries nested in a rule are resolved to
|
||||
* full selectors, so a nested rule is modelled like any other.
|
||||
*/
|
||||
function flattenRules(source) {
|
||||
const src = source.replace(/\/\*[\s\S]*?\*\//g, '');
|
||||
const rules = [];
|
||||
const mediaStack = [];
|
||||
// Open blocks, innermost last: media queries and style rules.
|
||||
const stack = [];
|
||||
const mediaStack = () =>
|
||||
stack.filter((frame) => frame.media).map((frame) => frame.media);
|
||||
const parentRule = () =>
|
||||
[...stack].reverse().find((frame) => frame.rule)?.rule || null;
|
||||
const declare = (text) => {
|
||||
const rule = parentRule();
|
||||
const trimmed = text.trim();
|
||||
if (!rule || !trimmed) return;
|
||||
const colon = trimmed.indexOf(':');
|
||||
if (colon < 0) return;
|
||||
const value = trimmed.slice(colon + 1).trim();
|
||||
rule.decls.push({
|
||||
prop: trimmed.slice(0, colon).trim().toLowerCase(),
|
||||
value: value.replace(/\s*!important$/i, '').trim(),
|
||||
important: /!important\s*$/i.test(value),
|
||||
});
|
||||
};
|
||||
let index = 0;
|
||||
let prelude = '';
|
||||
while (index < src.length) {
|
||||
@@ -137,14 +188,13 @@ function flattenRules(source) {
|
||||
if (char === '{') {
|
||||
const head = prelude.replace(/\s+/g, ' ').trim();
|
||||
prelude = '';
|
||||
index += 1;
|
||||
if (head.startsWith('@media')) {
|
||||
mediaStack.push(head.slice('@media'.length).trim());
|
||||
index += 1;
|
||||
stack.push({ media: head.slice('@media'.length).trim() });
|
||||
continue;
|
||||
}
|
||||
if (head.startsWith('@')) {
|
||||
let level = 1;
|
||||
index += 1;
|
||||
while (index < src.length && level > 0) {
|
||||
if (src[index] === '{') level += 1;
|
||||
else if (src[index] === '}') level -= 1;
|
||||
@@ -152,43 +202,34 @@ function flattenRules(source) {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
const close = src.indexOf('}', index);
|
||||
assert.ok(close > index, `unterminated rule block for "${head}"`);
|
||||
const decls = [];
|
||||
for (const raw of src.slice(index + 1, close).split(';')) {
|
||||
const text = raw.trim();
|
||||
if (!text) continue;
|
||||
const colon = text.indexOf(':');
|
||||
if (colon < 0) continue;
|
||||
const value = text.slice(colon + 1).trim();
|
||||
decls.push({
|
||||
prop: text.slice(0, colon).trim().toLowerCase(),
|
||||
value: value.replace(/\s*!important$/i, '').trim(),
|
||||
important: /!important\s*$/i.test(value),
|
||||
});
|
||||
}
|
||||
rules.push({
|
||||
const rule = {
|
||||
order: rules.length,
|
||||
media: [...mediaStack],
|
||||
parts: splitTopLevel(head, ',')
|
||||
.map((part) =>
|
||||
part.trim().replace(/\(\s+/g, '(').replace(/\s+\)/g, ')'),
|
||||
)
|
||||
.filter(Boolean),
|
||||
decls,
|
||||
});
|
||||
index = close + 1;
|
||||
media: mediaStack(),
|
||||
parts: nestSelectors(parentRule()?.parts, head),
|
||||
decls: [],
|
||||
};
|
||||
rules.push(rule);
|
||||
stack.push({ rule });
|
||||
continue;
|
||||
}
|
||||
if (char === ';') {
|
||||
declare(prelude);
|
||||
prelude = '';
|
||||
index += 1;
|
||||
continue;
|
||||
}
|
||||
if (char === '}') {
|
||||
mediaStack.pop();
|
||||
// The last declaration of a block may omit its semicolon.
|
||||
declare(prelude);
|
||||
prelude = '';
|
||||
stack.pop();
|
||||
index += 1;
|
||||
continue;
|
||||
}
|
||||
prelude += char;
|
||||
index += 1;
|
||||
}
|
||||
assert.equal(stack.length, 0, 'unbalanced braces in style.css');
|
||||
return rules;
|
||||
}
|
||||
|
||||
@@ -227,6 +268,29 @@ const RECOGNIZED = new Set([
|
||||
]);
|
||||
|
||||
const DOCKED_RAIL = 'body.context-docked #right-context-rail';
|
||||
|
||||
// The desktop Omnibar layout: the scope its stylesheet nests every rule in.
|
||||
// It applies on the desktop shell (above the 720px phone breakpoint) while
|
||||
// the Omnibar and the voice control share the dock; outside it the legacy
|
||||
// layout below governs.
|
||||
const OMNIBAR_SCOPE =
|
||||
'body:not(.mobile-shell):not(.cockpit-mode):not(.scene-playback-mode):not(.ui-clean-view):not(.recording-mode):where(:has(#gev-omnibar):has(#command-dock > #gev-voice-control))';
|
||||
const OMNIBAR = Object.freeze({
|
||||
dock: `${OMNIBAR_SCOPE} #command-dock`,
|
||||
credit: `${OMNIBAR_SCOPE} :is(#cesium-credits, #gev-credits)`,
|
||||
minimalCredit: `${OMNIBAR_SCOPE}:has(#intel-hud[data-variant='minimal'].active) :is(#cesium-credits, #gev-credits)`,
|
||||
minimalRail: `${OMNIBAR_SCOPE}:not(.context-docked):has(#intel-hud[data-variant='minimal'].active) #right-context-rail`,
|
||||
trays: `${OMNIBAR_SCOPE} #command-dock > :is(#location-bar, #control-panel)`,
|
||||
});
|
||||
// What each Omnibar-scope rule may set on a modelled box; the Omnibar
|
||||
// clearance test resolves every one of them through the full cascade.
|
||||
const OMNIBAR_RECOGNIZED = new Map([
|
||||
[OMNIBAR.dock, new Set(['top', 'bottom', 'height', 'min-height'])],
|
||||
[OMNIBAR.credit, new Set(['bottom'])],
|
||||
[OMNIBAR.minimalCredit, new Set(['bottom'])],
|
||||
[OMNIBAR.minimalRail, new Set(['max-height'])],
|
||||
]);
|
||||
const OMNIBAR_MIN_WIDTH = 721;
|
||||
const ELEMENT_KEYS = [
|
||||
'#cesium-credits',
|
||||
'#command-dock',
|
||||
@@ -300,8 +364,11 @@ function ownBoxEntries() {
|
||||
// So is Stories, with GEV's chrome stepped aside; storiesCredit.test.mjs
|
||||
// pins its attribution placement.
|
||||
if (
|
||||
/^body\.stories-mode:not\(#gs-a\):not\(#gs-b\) #(cesium|gev)-credits$/.test(part)
|
||||
) continue;
|
||||
/^body\.stories-mode:not\(#gs-a\):not\(#gs-b\) #(cesium|gev)-credits$/.test(
|
||||
part,
|
||||
)
|
||||
)
|
||||
continue;
|
||||
entries.push({ rule, part });
|
||||
}
|
||||
}
|
||||
@@ -372,12 +439,21 @@ function resolve(candidates, prop, width, label) {
|
||||
/** Evaluate a length. Anything the model cannot resolve exactly fails loudly. */
|
||||
function toPx(value, viewportHeight, where) {
|
||||
const trimmed = value.trim();
|
||||
// The larger of its lengths, each resolved the same way.
|
||||
if (/^max\(.*\)$/.test(trimmed))
|
||||
return Math.max(
|
||||
...splitTopLevel(trimmed.slice(4, -1), ',').map((part) =>
|
||||
toPx(part, viewportHeight, where),
|
||||
),
|
||||
);
|
||||
const inner = /^calc\(/.test(trimmed) ? trimmed.slice(5, -1) : trimmed;
|
||||
assert.doesNotMatch(
|
||||
inner,
|
||||
/\bcalc\(/,
|
||||
`nested calc() in ${where}: "${value}"`,
|
||||
);
|
||||
// A calc() is a whole term of its own, resolved below; nowhere else.
|
||||
for (const term of splitTopLevel(inner, '+'))
|
||||
assert.doesNotMatch(
|
||||
term.trim().replace(/^calc\(.*\)$/, ''),
|
||||
/\bcalc\(/,
|
||||
`nested calc() in ${where}: "${value}"`,
|
||||
);
|
||||
assert.doesNotMatch(
|
||||
inner,
|
||||
/\b(min|max|clamp|env|attr|round|mod)\(/,
|
||||
@@ -398,6 +474,18 @@ function toPx(value, viewportHeight, where) {
|
||||
const term = raw.trim();
|
||||
if (!term) continue;
|
||||
if (term === '100%') continue; // the tray's own panel height, added separately
|
||||
// A calc() of its own, as a term ("calc(var(--omnibar-credits-clear) +
|
||||
// 2px)" once substituted).
|
||||
if (/^calc\(.*\)$/.test(term)) {
|
||||
total += toPx(term, viewportHeight, where);
|
||||
continue;
|
||||
}
|
||||
// The credit line's own height (src/ui/creditLineHeight.js), at the
|
||||
// height this pin models it at.
|
||||
if (/^var\(--credit-line-height\b/.test(term)) {
|
||||
total += CREDIT_HEIGHT_PX;
|
||||
continue;
|
||||
}
|
||||
if (term.startsWith('var(')) {
|
||||
const name = term.slice(4, term.lastIndexOf(')')).split(',')[0].trim();
|
||||
assert.ok(
|
||||
@@ -521,6 +609,22 @@ test('the model refuses every cascade construct it cannot resolve', () => {
|
||||
// Expanded Context covers the right edge top to bottom; the credit row
|
||||
// stops short of it instead (the docked-Context test below).
|
||||
if (part === DOCKED_RAIL) continue;
|
||||
if (part.startsWith(OMNIBAR_SCOPE)) {
|
||||
const allowed = OMNIBAR_RECOGNIZED.get(part);
|
||||
for (const decl of guarded) {
|
||||
if (!allowed?.has(decl.prop))
|
||||
complaints.push(
|
||||
`unrecognized Omnibar rule positions a modelled element: "${part}" (${decl.prop})`,
|
||||
);
|
||||
if (decl.important)
|
||||
complaints.push(`!important on ${decl.prop} of "${part}"`);
|
||||
}
|
||||
if (rule.media.length)
|
||||
complaints.push(
|
||||
`media query on Omnibar rule "${part}": ${rule.media.join(' && ')}`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
if (!RECOGNIZED.has(part)) {
|
||||
complaints.push(
|
||||
`unrecognized selector positions a modelled element: "${part}" (${guarded.map((d) => d.prop).join(', ')})`,
|
||||
@@ -771,6 +875,152 @@ test('right rail measurement cannot persist into a painted attribution layout',
|
||||
|
||||
// ── Clearance ───────────────────────────────────────────────────────────────
|
||||
|
||||
/** A custom property's value as the Omnibar scope declares it. */
|
||||
function omnibarVar(name) {
|
||||
const decls = RULES.filter((rule) => rule.parts.includes(OMNIBAR_SCOPE))
|
||||
.flatMap((rule) => rule.decls)
|
||||
.filter((decl) => decl.prop === name);
|
||||
assert.equal(
|
||||
decls.length,
|
||||
1,
|
||||
`${name} is declared once in the Omnibar scope`,
|
||||
);
|
||||
return decls[0].value;
|
||||
}
|
||||
|
||||
/** A length in the Omnibar layout, with its scope's own custom properties. */
|
||||
function omnibarPx(value, viewportHeight, where) {
|
||||
// The scope's properties may name each other ("--omnibar-dock-bottom"
|
||||
// clears "--omnibar-credits-clear"): substitute until none is left.
|
||||
let substituted = value;
|
||||
for (let pass = 0; /var\(--omnibar-/.test(substituted); pass += 1) {
|
||||
assert.ok(
|
||||
pass < 8,
|
||||
`Omnibar properties name each other in a loop: ${value}`,
|
||||
);
|
||||
substituted = substituted.replace(/var\((--omnibar-[\w-]+)\)/g, (_, name) =>
|
||||
omnibarVar(name),
|
||||
);
|
||||
}
|
||||
return toPx(substituted, viewportHeight, where);
|
||||
}
|
||||
|
||||
test('Omnibar reserves a non-overlapping desktop footer at native credit sizing', () => {
|
||||
// The Omnibar layout resolves through the same cascade as the legacy one:
|
||||
// every legacy rule that could still match competes with the scope's.
|
||||
const trayOpen = [
|
||||
'#command-dock:has(#location-bar:not(.collapsed))',
|
||||
'#command-dock:has(#control-panel:not(.collapsed))',
|
||||
];
|
||||
assert.equal(
|
||||
omnibarVar('--world-timeline-lift'),
|
||||
'0px',
|
||||
'the Omnibar layout holds the timeline lift at 0',
|
||||
);
|
||||
for (const width of WIDTHS.filter((w) => w >= OMNIBAR_MIN_WIDTH)) {
|
||||
for (const height of HEIGHTS) {
|
||||
for (const minimal of [false, true]) {
|
||||
const dock = resolve(
|
||||
['#command-dock', ...trayOpen, OMNIBAR.dock],
|
||||
'bottom',
|
||||
width,
|
||||
'Omnibar dock',
|
||||
);
|
||||
assert.equal(
|
||||
dock.part,
|
||||
OMNIBAR.dock,
|
||||
`the Omnibar owns the dock at ${width}px`,
|
||||
);
|
||||
// Its top and height too: a legacy top or height winning here would
|
||||
// move or stretch the dock the clearance below is measured from.
|
||||
for (const [prop, value] of [
|
||||
['top', 'auto'],
|
||||
['height', '56px'],
|
||||
]) {
|
||||
const own = resolve(
|
||||
['#command-dock', ...trayOpen, OMNIBAR.dock],
|
||||
prop,
|
||||
width,
|
||||
`Omnibar dock ${prop}`,
|
||||
);
|
||||
assert.equal(
|
||||
own.part,
|
||||
OMNIBAR.dock,
|
||||
`the Omnibar owns the dock ${prop} at ${width}px`,
|
||||
);
|
||||
assert.equal(
|
||||
own.decl.value,
|
||||
value,
|
||||
`Omnibar dock ${prop} at ${width}px`,
|
||||
);
|
||||
}
|
||||
const credit = resolve(
|
||||
[
|
||||
...CREDIT_SELECTORS,
|
||||
OMNIBAR.credit,
|
||||
...(minimal ? [MINIMAL_HUD_CREDIT, OMNIBAR.minimalCredit] : []),
|
||||
],
|
||||
'bottom',
|
||||
width,
|
||||
'Omnibar credit',
|
||||
);
|
||||
assert.ok(
|
||||
credit.part.startsWith(OMNIBAR_SCOPE),
|
||||
`the Omnibar owns the credit row at ${width}px`,
|
||||
);
|
||||
const dockBottom = omnibarPx(
|
||||
dock.decl.value,
|
||||
height,
|
||||
'Omnibar dock bottom',
|
||||
);
|
||||
const creditTop =
|
||||
omnibarPx(credit.decl.value, height, 'Omnibar credit bottom') +
|
||||
CREDIT_HEIGHT_PX;
|
||||
assert.ok(
|
||||
dockBottom - creditTop >= MIN_CLEARANCE_PX,
|
||||
`at ${width}x${height}${minimal ? ' (minimal HUD)' : ''} the Omnibar dock (${dockBottom}px) must clear the credit line (${creditTop}px)`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
// No legacy tray opens over the credit: both are hidden in this layout,
|
||||
// and no rule elsewhere forces them back.
|
||||
const trays = RULES.find((rule) => rule.parts.includes(OMNIBAR.trays));
|
||||
assert.ok(trays, 'the Omnibar layout hides the legacy trays');
|
||||
assert.equal(
|
||||
trays.decls.find((decl) => decl.prop === 'display')?.value,
|
||||
'none',
|
||||
);
|
||||
for (const rule of RULES) {
|
||||
for (const part of rule.parts) {
|
||||
if (!/#(location-bar|control-panel)$/.test(lastCompound(part))) continue;
|
||||
assert.ok(
|
||||
!rule.decls.some((decl) => decl.prop === 'display' && decl.important),
|
||||
`"${part}" forces a hidden tray back with !important`,
|
||||
);
|
||||
}
|
||||
}
|
||||
// The minimal-HUD rail cap only shortens the rail, which is anchored at
|
||||
// its top, so it can only add room above the credit.
|
||||
const rail = RULES.find((rule) => rule.parts.includes(OMNIBAR.minimalRail));
|
||||
const cap = rail.decls.find(
|
||||
(decl) => decl.prop === '--omnibar-minimal-rail-height',
|
||||
);
|
||||
assert.match(
|
||||
cap?.value || '',
|
||||
/^min\(\s*var\(--right-stack-max-height, 70vh\),/,
|
||||
);
|
||||
assert.equal(
|
||||
rail.decls.find((decl) => decl.prop === 'max-height')?.value,
|
||||
'var(--omnibar-minimal-rail-height)',
|
||||
);
|
||||
assert.doesNotMatch(
|
||||
omnibarCss,
|
||||
/\.cesium-widget-credits|\.cesium-credit-logoContainer|\.cesium-credit-textContainer/,
|
||||
'the footer uses the original credit text and logo sizing',
|
||||
);
|
||||
});
|
||||
|
||||
test('every open dock tray clears the required credit at every modelled viewport', () => {
|
||||
// Below 900px the tray widens to nearly the viewport and lands on the
|
||||
// bottom-left corner where the credit lives. The clearance is NOT one fixed
|
||||
|
||||
+8
-6
@@ -527,10 +527,15 @@ export function cyberSonarLabelIntensity(
|
||||
return labelDimFactor + (1 - labelDimFactor) * normalized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sonar is an opt-in visual style over any HUD layout: it is on only after
|
||||
* the Display panel's Sonar toggle, a voice request or a legacy Cyber link
|
||||
* turns it on.
|
||||
*/
|
||||
export function isCyberSonarEnabled(
|
||||
root = globalThis.document?.documentElement,
|
||||
) {
|
||||
return root?.dataset?.cyberSonar !== 'off';
|
||||
return root?.dataset?.cyberSonar === 'on';
|
||||
}
|
||||
|
||||
export function setCyberSonarEnabled(
|
||||
@@ -539,9 +544,7 @@ export function setCyberSonarEnabled(
|
||||
) {
|
||||
if (!root?.dataset) return false;
|
||||
root.dataset.cyberSonar = enabled ? 'on' : 'off';
|
||||
if (root.dataset.uiTheme === 'cyber') {
|
||||
applyCyberSonarThemePhase(root, enabled);
|
||||
}
|
||||
applyCyberSonarThemePhase(root, enabled);
|
||||
return enabled;
|
||||
}
|
||||
|
||||
@@ -566,7 +569,6 @@ export function isCyberSonarActive({
|
||||
globalThis.matchMedia?.('(prefers-reduced-motion: reduce)')?.matches ??
|
||||
false;
|
||||
return !!(
|
||||
root?.dataset?.uiTheme === 'cyber' &&
|
||||
isCyberSonarEnabled(root) &&
|
||||
(hudActive ?? hud?.classList?.contains?.('active')) &&
|
||||
!body?.classList?.contains?.('cockpit-mode') &&
|
||||
@@ -583,7 +585,7 @@ export function isCyberMapThemeActive({
|
||||
if (hud === undefined)
|
||||
hud = globalThis.document?.getElementById?.('intel-hud');
|
||||
return !!(
|
||||
root?.dataset?.uiTheme === 'cyber' &&
|
||||
isCyberSonarEnabled(root) &&
|
||||
(hudActive ?? hud?.classList?.contains?.('active')) &&
|
||||
!body?.classList?.contains?.('cockpit-mode')
|
||||
);
|
||||
|
||||
+13
-9
@@ -39,7 +39,7 @@ test('production-transformed sonar defaults retain the document method receiver'
|
||||
const previous = Object.getOwnPropertyDescriptor(globalThis, 'document');
|
||||
const hud = { classList: { contains: (name) => name === 'active' } };
|
||||
const document = {
|
||||
documentElement: { dataset: { uiTheme: 'cyber' } },
|
||||
documentElement: { dataset: { cyberSonar: 'on' } },
|
||||
body: { classList: { contains: () => false } },
|
||||
getElementById(id) {
|
||||
assert.equal(this, document);
|
||||
@@ -57,7 +57,7 @@ test('production-transformed sonar defaults retain the document method receiver'
|
||||
assert.ok(
|
||||
Number.isFinite(compiled.createCyberSonarSampler(800, 600).at(400, 300)),
|
||||
);
|
||||
document.documentElement.dataset.uiTheme = 'tactical';
|
||||
document.documentElement.dataset.cyberSonar = 'off';
|
||||
assert.equal(compiled.isCyberSonarActive(), false);
|
||||
assert.equal(compiled.isCyberMapThemeActive(), false);
|
||||
} finally {
|
||||
@@ -139,8 +139,8 @@ test('the sweep brightens contacts inside its sector and dims the remainder', ()
|
||||
);
|
||||
});
|
||||
|
||||
test('the sonar activates only for a visible Cyber map HUD with motion enabled', () => {
|
||||
const root = { dataset: { uiTheme: 'cyber' } };
|
||||
test('the sonar activates only while on, over a visible map HUD with motion enabled', () => {
|
||||
const root = { dataset: { cyberSonar: 'on' } };
|
||||
const classes = (...values) => ({
|
||||
contains: (value) => values.includes(value),
|
||||
});
|
||||
@@ -220,14 +220,18 @@ test('the opacity setting controls every contact floor and preserves brighter la
|
||||
);
|
||||
});
|
||||
|
||||
test('the sonar control defaults on and records explicit operator state', () => {
|
||||
test('the sonar control defaults off and records explicit operator state', () => {
|
||||
const root = { dataset: {} };
|
||||
assert.equal(isCyberSonarEnabled(root), false);
|
||||
// The removed Cyber theme no longer turns it on.
|
||||
root.dataset.uiTheme = 'cyber';
|
||||
assert.equal(isCyberSonarEnabled(root), false);
|
||||
assert.equal(setCyberSonarEnabled(true, root), true);
|
||||
assert.equal(root.dataset.cyberSonar, 'on');
|
||||
assert.equal(isCyberSonarEnabled(root), true);
|
||||
assert.equal(setCyberSonarEnabled(false, root), false);
|
||||
assert.equal(root.dataset.cyberSonar, 'off');
|
||||
assert.equal(isCyberSonarEnabled(root), false);
|
||||
assert.equal(setCyberSonarEnabled(true, root), true);
|
||||
assert.equal(root.dataset.cyberSonar, 'on');
|
||||
});
|
||||
|
||||
test('real Cesium points and billboards recover after repeated low/high opacity cycles', () => {
|
||||
@@ -349,10 +353,10 @@ test('the sweep corrects delayed starts and reacquires restarted animations with
|
||||
assert.doesNotThrow(() => syncCyberSonarAnimation({}));
|
||||
});
|
||||
|
||||
test('the selected Cyber theme seeds and releases the compositor sweep phase', () => {
|
||||
test('turning Sonar on seeds and releases the compositor sweep phase', () => {
|
||||
const values = new Map();
|
||||
const root = {
|
||||
dataset: {},
|
||||
dataset: { cyberSonar: 'on' },
|
||||
style: {
|
||||
setProperty: (name, value) => values.set(name, value),
|
||||
removeProperty: (name) => values.delete(name),
|
||||
|
||||
@@ -45,7 +45,7 @@ test('frame sampler matches reference without per-contact settings access', () =
|
||||
});
|
||||
|
||||
test('removed CSS mode cannot disable GPU contacts; unsupported renderers fail closed', () => {
|
||||
const root = { dataset: { uiTheme: 'cyber' }, style: { setProperty() {} } };
|
||||
const root = { dataset: { cyberSonar: 'on' }, style: { setProperty() {} } };
|
||||
const options = {
|
||||
root,
|
||||
body: { classList: { contains: () => false } },
|
||||
@@ -97,7 +97,7 @@ function fixture({ modulation = true, lists = true } = {}) {
|
||||
document: globalThis.document,
|
||||
matchMedia: globalThis.matchMedia,
|
||||
};
|
||||
const root = { dataset: { uiTheme: 'cyber', cyberSonar: 'on' } };
|
||||
const root = { dataset: { cyberSonar: 'on' } };
|
||||
const status = { textContent: '' };
|
||||
const state = { cockpit: false, reducedMotion: false };
|
||||
globalThis.document = {
|
||||
@@ -232,36 +232,47 @@ test('the sweep sets its sector on drawing ticks and at the cadence, and changes
|
||||
f.tick(false);
|
||||
assert.equal(f.sets.length, 4, 'a resize sets it at once');
|
||||
assert.deepEqual(f.sets[3].center, { x: 300, y: 400 });
|
||||
f.root.dataset.cyberSonar = 'off';
|
||||
f.root.dataset.cyberSonarOpacity = '50';
|
||||
f.tick(false);
|
||||
assert.equal(f.sets[4].radius, 0, 'Sonar OFF rests every contact');
|
||||
assert.equal(f.sets.length, 5, 'a setting change sets it at once');
|
||||
assert.equal(
|
||||
f.sets[4].floor,
|
||||
0.5,
|
||||
'while sweeping the floor is the opacity',
|
||||
);
|
||||
f.state.reducedMotion = true;
|
||||
f.tick(false);
|
||||
assert.equal(f.sets[5].radius, 0, 'reduced motion rests the sweep');
|
||||
assert.equal(f.sets[5].floor, 0.5 + 0.5 * 0.46, 'at rest it lifts');
|
||||
clock += 1000;
|
||||
f.tick(true);
|
||||
f.tick(false);
|
||||
assert.equal(f.sets.length, 5, 'at rest only changes set it');
|
||||
f.root.dataset.cyberSonarOpacity = '50';
|
||||
f.tick(false);
|
||||
assert.equal(f.sets.length, 6);
|
||||
assert.equal(f.sets[5].floor, 0.5 + 0.5 * 0.46);
|
||||
assert.equal(f.sets.length, 6, 'at rest only changes set it');
|
||||
f.state.reducedMotion = false;
|
||||
f.state.cockpit = true;
|
||||
f.tick(false);
|
||||
assert.equal(f.sets[6], null, 'out of the map theme it clears');
|
||||
assert.equal(f.sets[6], null, 'out of the map it clears');
|
||||
f.tick(true);
|
||||
assert.equal(f.sets.length, 7, 'cleared once');
|
||||
f.state.cockpit = false;
|
||||
f.root.dataset.cyberSonar = 'off';
|
||||
f.tick(false);
|
||||
assert.equal(f.sets.length, 7, 'Sonar OFF leaves contacts untreated');
|
||||
f.root.dataset.cyberSonar = 'on';
|
||||
f.state.reducedMotion = true;
|
||||
f.tick(false);
|
||||
assert.equal(f.sets[7].radius, 0, 'reduced motion rests the sweep');
|
||||
f.state.reducedMotion = false;
|
||||
f.root.dataset.uiTheme = 'tactical';
|
||||
assert.ok(f.sets[7]?.radius > 0, 'Sonar ON sweeps at once');
|
||||
f.root.dataset.cyberSonar = 'off';
|
||||
f.tick(false);
|
||||
assert.equal(f.sets[8], null, 'another HUD style clears it');
|
||||
assert.equal(f.sets[8], null, 'Sonar OFF clears it');
|
||||
f.tick(true);
|
||||
assert.equal(f.sets.length, 9);
|
||||
// The removed Cyber theme attribute alone does nothing.
|
||||
f.root.dataset.uiTheme = 'cyber';
|
||||
f.tick(false);
|
||||
assert.ok(f.sets[9]?.radius > 0, 'back in Cyber it sweeps at once');
|
||||
assert.equal(f.sets.length, 9);
|
||||
f.root.dataset.cyberSonar = 'on';
|
||||
f.tick(false);
|
||||
assert.ok(f.sets[9]?.radius > 0, 'back on, it sweeps at once');
|
||||
assert.deepEqual(f.requests, [], 'the scene itself never asks for frames');
|
||||
dispose();
|
||||
assert.equal(f.sets[10], null, 'disposal clears it');
|
||||
|
||||
@@ -32,7 +32,12 @@ import aisLiveVesselsLayer from './aisLiveVessels.js';
|
||||
import { registerEntityContext, selectEntityContext } from './contextStore.js';
|
||||
import { WORLD_FOCUS_REQUEST_EVENT } from '../worldFocus.js';
|
||||
import { ensureGeoidReady, geoidHeight } from './geoid.js';
|
||||
import { registerPickOwner, unregisterPickOwner } from './pickRegistry.js';
|
||||
import {
|
||||
isUnderOtherCard,
|
||||
registerPickOwner,
|
||||
setClickCardHitTest,
|
||||
unregisterPickOwner,
|
||||
} from './pickRegistry.js';
|
||||
import { applyVesselOverlayPolicy } from './vesselLabels.js';
|
||||
import { fakeInput } from '../input/testDoubles.mjs';
|
||||
import { layerFeedState } from './manager.js';
|
||||
@@ -490,7 +495,7 @@ test('first accepted position ends grace and warm data survives later open silen
|
||||
const clock = makeFakeAisRuntime(7000);
|
||||
const record = makeRecord();
|
||||
_setAisRuntimeForTest(clock.runtime);
|
||||
_setVesselOverlayHostForTest({
|
||||
useVesselHost({
|
||||
setEntries() {},
|
||||
setVisible() {},
|
||||
clearSource() {},
|
||||
@@ -540,7 +545,7 @@ test('first accepted position ends grace and warm data survives later open silen
|
||||
assert.equal(feed.error, 'awaiting usable AIS positions…');
|
||||
} finally {
|
||||
_setVesselStateForTest({ enabled: false });
|
||||
_setVesselOverlayHostForTest();
|
||||
useVesselHost();
|
||||
_setAisRuntimeForTest();
|
||||
}
|
||||
});
|
||||
@@ -1012,7 +1017,12 @@ function makeCesiumEvent() {
|
||||
};
|
||||
}
|
||||
|
||||
function installWireHarness(picked, stateOverrides = {}) {
|
||||
function installWireHarness(
|
||||
picked,
|
||||
stateOverrides = {},
|
||||
sceneExtras = {},
|
||||
firstClick = null,
|
||||
) {
|
||||
const hadWindow = Object.hasOwn(globalThis, 'window');
|
||||
const hadDocument = Object.hasOwn(globalThis, 'document');
|
||||
const priorWindow = globalThis.window;
|
||||
@@ -1038,9 +1048,11 @@ function installWireHarness(picked, stateOverrides = {}) {
|
||||
},
|
||||
};
|
||||
const viewer = {
|
||||
scene: { pick: () => picked },
|
||||
scene: { pick: () => picked, ...sceneExtras },
|
||||
};
|
||||
const input = fakeInput(viewer);
|
||||
// A subscriber that runs before the layer's own (an aircraft layer).
|
||||
if (firstClick) input.input.onClick(firstClick);
|
||||
// The camera port other layers follow through, with no pose to read; its
|
||||
// followChanged event counts who listens.
|
||||
const followChanged = makeCesiumEvent();
|
||||
@@ -1666,7 +1678,7 @@ test('vessel host publication preserves the shipped grid winner and separation s
|
||||
},
|
||||
},
|
||||
});
|
||||
_setVesselOverlayHostForTest({
|
||||
useVesselHost({
|
||||
setEntries(sourceId, entries, options) {
|
||||
publications.push({ sourceId, entries, options });
|
||||
},
|
||||
@@ -1690,7 +1702,7 @@ test('vessel host publication preserves the shipped grid winner and separation s
|
||||
} finally {
|
||||
unbind();
|
||||
_setVesselStateForTest({ enabled: false });
|
||||
_setVesselOverlayHostForTest();
|
||||
useVesselHost();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1717,7 +1729,7 @@ test('vessel real layer lifecycle publishes protected selection and leaves no st
|
||||
globalThis.window.addEventListener('gev:world-request-focus', (event) => {
|
||||
focusRequests.push(event.detail);
|
||||
});
|
||||
_setVesselOverlayHostForTest(host);
|
||||
useVesselHost(host);
|
||||
_setVesselStateForTest({
|
||||
viewer: {
|
||||
get canvas() {
|
||||
@@ -1766,7 +1778,7 @@ test('vessel real layer lifecycle publishes protected selection and leaves no st
|
||||
);
|
||||
} finally {
|
||||
_setVesselStateForTest({ enabled: false });
|
||||
_setVesselOverlayHostForTest();
|
||||
useVesselHost();
|
||||
if (hadWindow) globalThis.window = priorWindow;
|
||||
else delete globalThis.window;
|
||||
globalThis.document = priorDocument;
|
||||
@@ -1872,17 +1884,31 @@ test('vessel interaction wire: a vessel with an id and no MMSI is selected by cl
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Hand the vessel layer an overlay host, and answer the pick registry's
|
||||
* card-on-top question from the same host, as the application does.
|
||||
*/
|
||||
function useVesselHost(host) {
|
||||
_setVesselOverlayHostForTest(host);
|
||||
setClickCardHitTest(host ? (x, y) => host.hitTest(x, y) : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overlay-host recorder whose hitTest answers with one card id. The real host
|
||||
* only publishes rects for `interactive` entries, so a stub returning a hit is
|
||||
* the same contract a painted, actionable card presents.
|
||||
*/
|
||||
function hostWithCardHit(entryId) {
|
||||
function hostWithCardHit(entryId, topHit) {
|
||||
return {
|
||||
setEntries() {},
|
||||
setVisible() {},
|
||||
clearSource() {},
|
||||
hitTest: () => (entryId ? { sourceId: 'ais-live-vessels', entryId } : null),
|
||||
hitTest: (_x, _y, { sourceId } = {}) =>
|
||||
!sourceId && topHit
|
||||
? topHit
|
||||
: entryId
|
||||
? { sourceId: 'ais-live-vessels', entryId }
|
||||
: null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1898,9 +1924,7 @@ test('vessel interaction wire: clicking a card selects and transfers, like the s
|
||||
harness.windowTarget.addEventListener(WORLD_FOCUS_REQUEST_EVENT, (event) =>
|
||||
requests.push(event.detail),
|
||||
);
|
||||
_setVesselOverlayHostForTest(
|
||||
hostWithCardHit(`vessel:${harness.record.mmsi}`),
|
||||
);
|
||||
useVesselHost(hostWithCardHit(`vessel:${harness.record.mmsi}`));
|
||||
try {
|
||||
harness.handler.click({ position: { x: 10, y: 20 } });
|
||||
assert.equal(
|
||||
@@ -1911,7 +1935,7 @@ test('vessel interaction wire: clicking a card selects and transfers, like the s
|
||||
assert.equal(requests[0].kind, 'vessel');
|
||||
assert.equal(requests[0].id, harness.record.mmsi);
|
||||
} finally {
|
||||
_setVesselOverlayHostForTest(null);
|
||||
useVesselHost(null);
|
||||
harness.cleanup();
|
||||
}
|
||||
});
|
||||
@@ -1926,9 +1950,7 @@ test('vessel interaction wire: clicking the selected vessel card refocuses exact
|
||||
harness.windowTarget.addEventListener(WORLD_FOCUS_REQUEST_EVENT, (event) =>
|
||||
requests.push(event.detail),
|
||||
);
|
||||
_setVesselOverlayHostForTest(
|
||||
hostWithCardHit(`vessel:${harness.record.mmsi}`),
|
||||
);
|
||||
useVesselHost(hostWithCardHit(`vessel:${harness.record.mmsi}`));
|
||||
try {
|
||||
harness.handler.click({ position: { x: 10, y: 20 } });
|
||||
assert.equal(
|
||||
@@ -1939,11 +1961,36 @@ test('vessel interaction wire: clicking the selected vessel card refocuses exact
|
||||
assert.equal(requests[0].id, harness.record.mmsi);
|
||||
assert.equal(harness.trail.clearCalls, 0);
|
||||
} finally {
|
||||
_setVesselOverlayHostForTest(null);
|
||||
useVesselHost(null);
|
||||
harness.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
// Another layer's card on top takes the click from the vessel card under it
|
||||
// and from a vessel icon under it alike.
|
||||
test('vessel interaction wire: a covered card and a covered vessel pick both yield', () => {
|
||||
for (const ownPick of [false, true]) {
|
||||
const harness = installWireHarness(ownPick ? { id: makeRecord().mmsi } : null);
|
||||
const requests = [];
|
||||
harness.windowTarget.addEventListener(WORLD_FOCUS_REQUEST_EVENT, (event) =>
|
||||
requests.push(event.detail),
|
||||
);
|
||||
useVesselHost(
|
||||
hostWithCardHit(`vessel:${harness.record.mmsi}`, {
|
||||
sourceId: 'earthquakes', entryId: 'quake:cover',
|
||||
}),
|
||||
);
|
||||
try {
|
||||
harness.handler.click({ position: { x: 10, y: 20 } });
|
||||
assert.equal(requests.length, 0, `own pick: ${ownPick}`);
|
||||
assert.equal(aisLiveVesselsLayer.getSelectedInfo()?.mmsi, harness.record.mmsi);
|
||||
} finally {
|
||||
useVesselHost(null);
|
||||
harness.cleanup();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('vessel interaction wire: an unknown card id preserves selection and never flies', () => {
|
||||
const harness = installWireHarness({
|
||||
primitive: {},
|
||||
@@ -1955,7 +2002,7 @@ test('vessel interaction wire: an unknown card id preserves selection and never
|
||||
requests.push(event.detail),
|
||||
);
|
||||
// An evicted vessel's card id resolves to no live record.
|
||||
_setVesselOverlayHostForTest(hostWithCardHit('vessel:999999999'));
|
||||
useVesselHost(hostWithCardHit('vessel:999999999'));
|
||||
try {
|
||||
harness.handler.click({ position: { x: 10, y: 20 } });
|
||||
assert.equal(
|
||||
@@ -1964,37 +2011,135 @@ test('vessel interaction wire: an unknown card id preserves selection and never
|
||||
);
|
||||
assert.equal(requests.length, 0);
|
||||
} finally {
|
||||
_setVesselOverlayHostForTest(null);
|
||||
useVesselHost(null);
|
||||
harness.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test('vessel interaction wire: a sibling-owned pick wins without selection mutation', () => {
|
||||
// Another layer is already acting on this click; two camera commands is the
|
||||
// worse failure, so the card is not consulted.
|
||||
test('vessel interaction wire: the vessel card on top wins over a sibling-owned pick', () => {
|
||||
// The card painted on top takes the click; the sibling (an aircraft)
|
||||
// stands aside under it, so there is one camera command, not two.
|
||||
registerPickOwner('flights', (pickedId) => pickedId === 'a1b2c3');
|
||||
const harness = installWireHarness({ id: 'a1b2c3' });
|
||||
const requests = [];
|
||||
harness.windowTarget.addEventListener(WORLD_FOCUS_REQUEST_EVENT, (event) =>
|
||||
requests.push(event.detail),
|
||||
);
|
||||
_setVesselOverlayHostForTest(
|
||||
hostWithCardHit(`vessel:${harness.record.mmsi}`),
|
||||
);
|
||||
useVesselHost(hostWithCardHit(`vessel:${harness.record.mmsi}`));
|
||||
try {
|
||||
harness.handler.click({ position: { x: 10, y: 20 } });
|
||||
assert.equal(
|
||||
aisLiveVesselsLayer.getSelectedInfo()?.mmsi,
|
||||
harness.record.mmsi,
|
||||
);
|
||||
assert.equal(requests.length, 0);
|
||||
assert.equal(requests.length, 1);
|
||||
} finally {
|
||||
_setVesselOverlayHostForTest(null);
|
||||
useVesselHost(null);
|
||||
harness.cleanup();
|
||||
unregisterPickOwner('flights');
|
||||
}
|
||||
});
|
||||
|
||||
// The aircraft layer runs first. Under the vessel's card it stands aside, so
|
||||
// the card takes the click: one action.
|
||||
test('vessel interaction wire: a card over an aircraft takes the click; the aircraft does not track', (t) => {
|
||||
let tracked = null;
|
||||
registerPickOwner('test-planes', (pickedId) => pickedId === 'plane:9');
|
||||
t.after(() => unregisterPickOwner('test-planes'));
|
||||
const harness = installWireHarness(
|
||||
{ id: 'plane:9' },
|
||||
{ selectedRecord: null },
|
||||
{},
|
||||
(event) => {
|
||||
if (isUnderOtherCard(event)) return;
|
||||
if (event.hit?.id === 'plane:9') tracked = 'plane:9';
|
||||
},
|
||||
);
|
||||
const requests = [];
|
||||
harness.windowTarget.addEventListener(WORLD_FOCUS_REQUEST_EVENT, (event) =>
|
||||
requests.push(event.detail),
|
||||
);
|
||||
useVesselHost(hostWithCardHit(`vessel:${harness.record.mmsi}`));
|
||||
try {
|
||||
harness.handler.click({ position: { x: 10, y: 20 } });
|
||||
assert.equal(tracked, null, 'the aircraft does not track');
|
||||
assert.equal(requests.length, 1, 'the vessel card acts');
|
||||
assert.equal(
|
||||
aisLiveVesselsLayer.getSelectedInfo()?.mmsi,
|
||||
harness.record.mmsi,
|
||||
);
|
||||
} finally {
|
||||
useVesselHost(null);
|
||||
harness.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
// A trail acts for nobody: the vessel's card painted over it still selects,
|
||||
// and a bare trail pick stays a no-op that keeps the selection.
|
||||
test('vessel interaction wire: a card over a trail selects; a bare trail is a no-op', () => {
|
||||
for (const carded of [true, false]) {
|
||||
const harness = installWireHarness(
|
||||
{ id: 'gev-trail:fl-a1b2c3:head' },
|
||||
{ selectedRecord: null },
|
||||
);
|
||||
const requests = [];
|
||||
harness.windowTarget.addEventListener(WORLD_FOCUS_REQUEST_EVENT, (event) =>
|
||||
requests.push(event.detail),
|
||||
);
|
||||
useVesselHost(
|
||||
hostWithCardHit(carded ? `vessel:${harness.record.mmsi}` : null),
|
||||
);
|
||||
try {
|
||||
harness.handler.click({ position: { x: 10, y: 20 } });
|
||||
assert.equal(requests.length, carded ? 1 : 0, `card: ${carded}`);
|
||||
assert.equal(
|
||||
aisLiveVesselsLayer.getSelectedInfo()?.mmsi ?? null,
|
||||
carded ? harness.record.mmsi : null,
|
||||
);
|
||||
} finally {
|
||||
useVesselHost(null);
|
||||
harness.cleanup();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// A coarse tap on the vessel's card over a fire, nearby or exact: the card on
|
||||
// top keeps the tap.
|
||||
test('vessel interaction wire: the card keeps a tap over a nearby or exact fire', (t) => {
|
||||
const previous = globalThis.matchMedia;
|
||||
globalThis.matchMedia = () => ({ matches: true });
|
||||
t.after(() => {
|
||||
if (previous) globalThis.matchMedia = previous;
|
||||
else delete globalThis.matchMedia;
|
||||
});
|
||||
const fire = 'fire:near-miss';
|
||||
registerPickOwner('test-exact-fires', (pickedId) => pickedId === fire);
|
||||
t.after(() => unregisterPickOwner('test-exact-fires'));
|
||||
for (const exact of [false, true]) {
|
||||
const harness = installWireHarness(
|
||||
exact ? { id: fire } : null,
|
||||
{ selectedRecord: null },
|
||||
{ drillPick: () => [{ id: fire }] },
|
||||
);
|
||||
const requests = [];
|
||||
harness.windowTarget.addEventListener(WORLD_FOCUS_REQUEST_EVENT, (event) =>
|
||||
requests.push(event.detail),
|
||||
);
|
||||
useVesselHost(hostWithCardHit(`vessel:${harness.record.mmsi}`));
|
||||
try {
|
||||
harness.handler.click({ position: { x: 10, y: 20 } });
|
||||
assert.equal(requests.length, 1, `exact fire: ${exact}`);
|
||||
assert.equal(
|
||||
aisLiveVesselsLayer.getSelectedInfo()?.mmsi,
|
||||
harness.record.mmsi,
|
||||
);
|
||||
} finally {
|
||||
useVesselHost(null);
|
||||
harness.cleanup();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
for (const card of ['live', 'stale', 'absent', 'covered']) {
|
||||
test(`vessel interaction wire: ${card} foreground card over registered cyclone`, () => {
|
||||
const id = 'cyclone:fixture:cone:0';
|
||||
@@ -2020,7 +2165,7 @@ for (const card of ['live', 'stale', 'absent', 'covered']) {
|
||||
);
|
||||
return { sourceId: 'cctv', entryId: 'vessel:999999999' };
|
||||
};
|
||||
_setVesselOverlayHostForTest(host);
|
||||
useVesselHost(host);
|
||||
try {
|
||||
harness.handler.click({ position: { x: 10, y: 20 } });
|
||||
assert.equal(
|
||||
@@ -2029,7 +2174,7 @@ for (const card of ['live', 'stale', 'absent', 'covered']) {
|
||||
);
|
||||
assert.equal(requests.length, card === 'live' ? 1 : 0);
|
||||
} finally {
|
||||
_setVesselOverlayHostForTest(null);
|
||||
useVesselHost(null);
|
||||
harness.cleanup();
|
||||
unregisterPickOwner('weather-cyclones');
|
||||
}
|
||||
|
||||
@@ -2959,11 +2959,12 @@ export function createBhoteKoshiEventLayer({
|
||||
: Number.isFinite(clientY) && bounds
|
||||
? clientY - bounds.top
|
||||
: Number.NaN;
|
||||
const hit = overlayHost.hitTest?.(x, y, {
|
||||
sourceId: BHOTE_KOSHI_OVERLAY_SOURCE_ID,
|
||||
filter: (entry) => String(entry?.id || '').startsWith('evidence-card-'),
|
||||
});
|
||||
if (typeof hit?.entry?.activate !== 'function') return;
|
||||
// Only the card painted on top acts: an evidence card covered by
|
||||
// another layer's card or label leaves the click to that card.
|
||||
const hit = overlayHost.hitTest?.(x, y);
|
||||
if (hit?.sourceId !== BHOTE_KOSHI_OVERLAY_SOURCE_ID) return;
|
||||
if (!String(hit.entry?.id || '').startsWith('evidence-card-')) return;
|
||||
if (typeof hit.entry.activate !== 'function') return;
|
||||
hit.entry.activate();
|
||||
}
|
||||
|
||||
|
||||
@@ -2114,6 +2114,7 @@ test('Debris-Dammed Lake card opens its source and is armed for approved local v
|
||||
};
|
||||
const viewer = eventViewer();
|
||||
let activeCard = null;
|
||||
let coveredBy = null;
|
||||
const layer = createBhoteKoshiEventLayer({
|
||||
eventLoader: async () => event,
|
||||
imagerySpecFactory: async (url) => ({ url }),
|
||||
@@ -2131,9 +2132,11 @@ test('Debris-Dammed Lake card opens its source and is armed for approved local v
|
||||
},
|
||||
setVisible() {},
|
||||
clearSource() {},
|
||||
// As the host does: unfiltered, the topmost entry.
|
||||
hitTest(_x, _y, options) {
|
||||
if (coveredBy && !options?.sourceId) return coveredBy;
|
||||
if (!activeCard || options?.filter?.(activeCard) === false) return null;
|
||||
return { entry: activeCard };
|
||||
return { sourceId: 'bhote-koshi-witnesses', entry: activeCard };
|
||||
},
|
||||
},
|
||||
renderHost: { request() {}, hold() {}, release() {} },
|
||||
@@ -2160,6 +2163,11 @@ test('Debris-Dammed Lake card opens its source and is armed for approved local v
|
||||
} finally {
|
||||
releasePointer(lease);
|
||||
}
|
||||
// Another layer's card painted over the evidence card takes the click.
|
||||
coveredBy = { sourceId: 'earthquake-card', entryId: 'earthquake-card:q' };
|
||||
viewer._test.canvas.dispatch('click', { offsetX: 640, offsetY: 420 });
|
||||
assert.equal(opened.length, 0, 'a covered evidence card does not open');
|
||||
coveredBy = null;
|
||||
viewer._test.canvas.dispatch('click', { offsetX: 640, offsetY: 420 });
|
||||
assert.deepEqual(opened, [[
|
||||
event.evidenceSpine[1].media.sourceUrl,
|
||||
|
||||
@@ -2,6 +2,9 @@ import {
|
||||
clearOverlaySource,
|
||||
setOverlayEntries,
|
||||
} from '../overlays/worldOverlay.js';
|
||||
import { inputFor } from '../input/dispatcher.js';
|
||||
import { clickCard } from './pickRegistry.js';
|
||||
import { isTrackingSelectionGesture } from './trackingClickGesture.js';
|
||||
import { governorRequestRender } from '../renderGovernor.js';
|
||||
import { drawOf, findCamera } from '../render/rendererOf.js';
|
||||
import { hexColor } from '../render/color.js';
|
||||
@@ -279,8 +282,11 @@ export function createBhoteKoshiLocatorLayer({
|
||||
cancelFrame = (handle) => cancelAnimationFrame(handle),
|
||||
scheduleDelay = (callback, delayMs) => setTimeout(callback, delayMs),
|
||||
cancelDelay = (handle) => clearTimeout(handle),
|
||||
input = inputFor,
|
||||
} = {}) {
|
||||
let _viewer = null;
|
||||
// The globe click that opens an actionable callout of ours on top.
|
||||
let _removeClick = null;
|
||||
const _serial = ++layerSerial;
|
||||
// Whether the layer draws: from enable until it is let go.
|
||||
let _drawing = false;
|
||||
@@ -1107,6 +1113,7 @@ export function createBhoteKoshiLocatorLayer({
|
||||
renderPresentation();
|
||||
registerDynamicCredit(viewer, BHOTE_KOSHI_LOCATOR_CREDIT);
|
||||
showOsmCredit(viewer, BHOTE_KOSHI_LOCATOR_LAYER_ID);
|
||||
installCalloutClick(viewer);
|
||||
requestRender('bhote-koshi-locator-callout');
|
||||
|
||||
try {
|
||||
@@ -1141,8 +1148,34 @@ export function createBhoteKoshiLocatorLayer({
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An actionable callout of ours (the trigger record's) is a card painted
|
||||
* over the globe: a click on it opens its source, as its keyboard action
|
||||
* does. Like the other cards, it leaves a drag alone and, on top, takes the
|
||||
* click over whatever is drawn under it.
|
||||
*/
|
||||
function installCalloutClick(viewer) {
|
||||
if (_removeClick) return;
|
||||
let clicks = null;
|
||||
try {
|
||||
clicks = input?.(viewer) ?? null;
|
||||
} catch {
|
||||
clicks = null;
|
||||
}
|
||||
_removeClick =
|
||||
clicks?.onClick?.((event) => {
|
||||
if (!_enabled || !isTrackingSelectionGesture(event.gesture)) return;
|
||||
// The card painted on top, read once per click so every layer agrees.
|
||||
const top = clickCard(event);
|
||||
if (top?.sourceId !== BHOTE_KOSHI_LOCATOR_OVERLAY_SOURCE_ID) return;
|
||||
if (typeof top.entry?.activate === 'function') top.entry.activate();
|
||||
}) ?? null;
|
||||
}
|
||||
|
||||
async function disable() {
|
||||
hideOsmCredit(_viewer, BHOTE_KOSHI_LOCATOR_LAYER_ID);
|
||||
_removeClick?.();
|
||||
_removeClick = null;
|
||||
_enabled = false;
|
||||
_boundaryReady = false;
|
||||
_boundaryResolved = false;
|
||||
|
||||
@@ -11,6 +11,11 @@ import {
|
||||
import { BHOTE_KOSHI_FLOOD_PATH } from './bhoteKoshiFloodPath.js';
|
||||
import * as Cesium from 'cesium';
|
||||
import { setLocale } from '../i18n/index.js';
|
||||
import {
|
||||
registerPickOwner,
|
||||
setClickCardHitTest,
|
||||
unregisterPickOwner,
|
||||
} from './pickRegistry.js';
|
||||
import { SceneDirector } from '../scenes/director.js';
|
||||
import { createPlaybackClock } from '../director/clock.js';
|
||||
import { createDefaultScenePacks } from '../scenes/packs/defaults.js';
|
||||
@@ -1049,3 +1054,74 @@ test('Bhote Koshi locator layers draw sets of their own, and halos only as they
|
||||
assert.equal(await second.disable(), true);
|
||||
assert.equal(viewer._test.live().length, 0);
|
||||
});
|
||||
|
||||
// The trigger record's callout is an actionable card: the layers under it
|
||||
// stand aside for it, so a click on it opens its source, as its keyboard
|
||||
// action does; anything else on top is left alone.
|
||||
test('a click on the locator callout runs its action', async () => {
|
||||
const viewer = viewerFixture();
|
||||
let onClick = null;
|
||||
let top = null;
|
||||
const activated = [];
|
||||
const layer = createBhoteKoshiLocatorLayer({
|
||||
overlayHost: overlayHostFixture(),
|
||||
requestRender() {},
|
||||
...nonRunningAnimation(),
|
||||
input: () => ({
|
||||
onClick(callback) {
|
||||
onClick = callback;
|
||||
return () => {
|
||||
onClick = null;
|
||||
};
|
||||
},
|
||||
}),
|
||||
});
|
||||
// The card on top at a click, as the host answers the pick registry.
|
||||
setClickCardHitTest(() => top);
|
||||
await layer.init(viewer);
|
||||
await layer.enable(viewer);
|
||||
const click = (extra = {}) =>
|
||||
onClick?.({
|
||||
screenPosition: { x: 5, y: 5 },
|
||||
gesture: { travelPx: 0, durationMs: 80 },
|
||||
topHit: null,
|
||||
hit: null,
|
||||
...extra,
|
||||
});
|
||||
top = {
|
||||
sourceId: BHOTE_KOSHI_LOCATOR_OVERLAY_SOURCE_ID,
|
||||
entryId: 'bhote-koshi-trigger-record-callout',
|
||||
entry: { activate: () => activated.push('trigger') },
|
||||
};
|
||||
click();
|
||||
assert.deepEqual(activated, ['trigger']);
|
||||
top = {
|
||||
sourceId: 'earthquake-card',
|
||||
entry: { activate: () => activated.push('other') },
|
||||
};
|
||||
click();
|
||||
assert.deepEqual(activated, ['trigger'], 'another layer on top is its own');
|
||||
// A drag that ends on it is not a click on it.
|
||||
top = {
|
||||
sourceId: BHOTE_KOSHI_LOCATOR_OVERLAY_SOURCE_ID,
|
||||
entry: { activate: () => activated.push('trigger') },
|
||||
};
|
||||
click({ gesture: { travelPx: 30, durationMs: 80 } });
|
||||
assert.deepEqual(activated, ['trigger'], 'a drag does not open it');
|
||||
// On top, it takes the click over an aircraft or a camera under it, exact
|
||||
// or a touch contact: those layers stand aside under a card.
|
||||
registerPickOwner('test-planes', (id) => id === 'plane:1');
|
||||
try {
|
||||
const plane = { set: 'planes:1', id: 'plane:1' };
|
||||
const cam = { set: 'cams:1', id: 'cam:1' };
|
||||
click({ topHit: plane, hit: plane });
|
||||
click({ topHit: null, hit: plane });
|
||||
click({ topHit: cam, hit: cam });
|
||||
assert.equal(activated.length, 4, 'the callout on top acts each time');
|
||||
} finally {
|
||||
unregisterPickOwner('test-planes');
|
||||
setClickCardHitTest(null);
|
||||
}
|
||||
await layer.disable();
|
||||
assert.equal(onClick, null, 'disable removes the click handler');
|
||||
});
|
||||
+4
-11
@@ -1020,11 +1020,7 @@ test('CCTV repeated in-world clicks dispatch focus only for the one real activat
|
||||
);
|
||||
assert.match(
|
||||
componentFunctionSource(cctvLayer.init),
|
||||
/_cctvOverlayHost\.hitTest/,
|
||||
);
|
||||
assert.match(
|
||||
componentFunctionSource(cctvLayer.init),
|
||||
/sourceId: CCTV_OVERLAY_SOURCE_ID/,
|
||||
/clickCard\?\.\(event\)/,
|
||||
);
|
||||
assert.match(
|
||||
componentFunctionSource(cctvLayer.init),
|
||||
@@ -1032,7 +1028,7 @@ test('CCTV repeated in-world clicks dispatch focus only for the one real activat
|
||||
);
|
||||
assert.match(
|
||||
componentFunctionSource(cctvLayer.init),
|
||||
/activateCctvCameraFromWorldClick\(cardId, setActiveCamera\)/,
|
||||
/activateCctvCameraFromWorldClick\(\s*top\.entryId,/,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1157,11 +1153,8 @@ test('CCTV empty-click gate excludes every identified scene object, ADJUST, and
|
||||
);
|
||||
|
||||
const initSource = componentFunctionSource(cctvLayer.init);
|
||||
assert.ok(
|
||||
initSource.indexOf('if (pickedId !== null) return') <
|
||||
initSource.indexOf('_cctvOverlayHost.hitTest'),
|
||||
'every identified sibling must win before an overlapping CCTV card hit test',
|
||||
);
|
||||
// The real init-bound click route, including identified-object barriers,
|
||||
// is exercised in layers/cctv/lifecycle.test.mjs.
|
||||
assert.match(initSource, /activeCameraId: _activeCameraId/);
|
||||
assert.match(initSource, /calibrationMode: _calibrationMode/);
|
||||
});
|
||||
|
||||
@@ -53,7 +53,7 @@ test('the echo bracket pulses outward from the contact bracket and fades', (t) =
|
||||
assert.ok(half.spreadPx > echo.spreadPx * 0.5);
|
||||
assert.ok(half.spreadPx < echo.spreadPx);
|
||||
assert.ok(half.band < STEPS && half.band >= 1);
|
||||
// The bracket's own dimming (keyhole fade, Cyber sonar sweep) carries
|
||||
// The bracket's own dimming (keyhole fade, sonar sweep) carries
|
||||
// over, and the echo is never drawn brighter than its bracket: a bracket
|
||||
// too dim for even one band draws no echo.
|
||||
assert.equal(at(arrival, 0.25).band, 2);
|
||||
|
||||
@@ -941,13 +941,13 @@ test('a Global Context echo bracket is drawn outside its contact bracket and dim
|
||||
}
|
||||
});
|
||||
|
||||
test('under the Cyber sonar sweep an echo is never brighter than its own bracket', () => {
|
||||
test('under the sonar sweep an echo is never brighter than its own bracket', () => {
|
||||
const env = installEnvironment();
|
||||
// The cyber theme with its HUD open turns the contact sonar on; its sweep
|
||||
// dims brackets it is not passing over.
|
||||
// Sonar on with its HUD open turns the contact sonar on; its sweep dims
|
||||
// brackets it is not passing over.
|
||||
env.document.documentElement = {
|
||||
// The lowest sweep floor, so dimmed brackets drop a whole alpha band.
|
||||
dataset: { uiTheme: 'cyber', cyberSonarOpacity: '35' },
|
||||
dataset: { cyberSonar: 'on', cyberSonarOpacity: '35' },
|
||||
style: { setProperty() {}, removeProperty() {} },
|
||||
};
|
||||
const hud = env.document.createElement('div');
|
||||
|
||||
@@ -28,6 +28,8 @@ import {
|
||||
createApplicationDirectionsLayer,
|
||||
} from './directions.js';
|
||||
import { GROUND_FLOOR_LIFT_M } from './groundFloor.js';
|
||||
import { isOwnedByOtherLayer, setClickCardHitTest } from './pickRegistry.js';
|
||||
import { fakeInput } from '../input/testDoubles.mjs';
|
||||
import { instructionFor } from './routeSteps.js';
|
||||
import { setLocale } from '../i18n/index.js';
|
||||
import {
|
||||
@@ -465,6 +467,65 @@ function ownershipFixture(t) {
|
||||
});
|
||||
}
|
||||
|
||||
// Directions owns its route, markers and steps while enabled: none of them
|
||||
// is empty space to other layers.
|
||||
test('enabled, directions owns its picks', (t) => {
|
||||
ownershipFixture(t);
|
||||
const viewer = {
|
||||
scene: {
|
||||
pick: () => null,
|
||||
canvas: { clientWidth: 100, clientHeight: 100 },
|
||||
},
|
||||
};
|
||||
const input = fakeInput(viewer);
|
||||
t.after(() => input.destroy());
|
||||
directionsLayer.enable(viewer);
|
||||
try {
|
||||
for (const id of [
|
||||
'directions:route',
|
||||
'directions:marker:a',
|
||||
'directions:step:3',
|
||||
])
|
||||
assert.equal(isOwnedByOtherLayer('earthquakes', id), true, id);
|
||||
} finally {
|
||||
directionsLayer.disable(viewer);
|
||||
}
|
||||
assert.equal(isOwnedByOtherLayer('earthquakes', 'directions:route'), false);
|
||||
});
|
||||
|
||||
// The card or label painted on top takes the click: directions does not even
|
||||
// pick under another layer's card, so no step is selected or cleared there.
|
||||
test("another layer's card over directions keeps the click", (t) => {
|
||||
ownershipFixture(t);
|
||||
let picks = 0;
|
||||
const viewer = {
|
||||
scene: {
|
||||
pick: () => {
|
||||
picks++;
|
||||
return null;
|
||||
},
|
||||
canvas: { clientWidth: 100, clientHeight: 100 },
|
||||
},
|
||||
};
|
||||
const input = fakeInput(viewer);
|
||||
let top = { sourceId: 'earthquake-card', entryId: 'earthquake-card:ak1' };
|
||||
setClickCardHitTest(() => top);
|
||||
t.after(() => {
|
||||
setClickCardHitTest(null);
|
||||
input.destroy();
|
||||
});
|
||||
directionsLayer.enable(viewer);
|
||||
try {
|
||||
input.tap({ x: 10, y: 10 });
|
||||
assert.equal(picks, 0, 'covered: the scene under the card is not picked');
|
||||
top = null;
|
||||
input.tap({ x: 10, y: 10 });
|
||||
assert.ok(picks > 0, 'open map: the click reaches the scene');
|
||||
} finally {
|
||||
directionsLayer.disable(viewer);
|
||||
}
|
||||
});
|
||||
|
||||
test('placing an endpoint takes the pointer, and every exit path gives it back', (t) => {
|
||||
ownershipFixture(t);
|
||||
|
||||
|
||||
@@ -11,7 +11,12 @@ import {
|
||||
buildCellCard,
|
||||
} from './firmsHeatmap.js';
|
||||
import { fireDetectionKey } from './firmsLabels.js';
|
||||
import { registerPickOwner, unregisterPickOwner } from './pickRegistry.js';
|
||||
import {
|
||||
isUnderOtherCard,
|
||||
registerPickOwner,
|
||||
setClickCardHitTest,
|
||||
unregisterPickOwner,
|
||||
} from './pickRegistry.js';
|
||||
import { getSelectedEntityContext } from './contextStore.js';
|
||||
import { setLocale } from '../i18n/index.js';
|
||||
import { shownEntityLabel } from '../voice/speech.js';
|
||||
@@ -25,6 +30,8 @@ import { fakeDrawPort } from '../testSupport/fakeDrawPort.mjs';
|
||||
import { fakeGlobePort } from '../testSupport/fakeGlobePort.mjs';
|
||||
import { bindRenderer } from '../render/rendererOf.js';
|
||||
import { HEAT_REBUILD_MS } from '../layers/firms/policy.js';
|
||||
import { registerStyleStages } from '../styles/styleStages.js';
|
||||
import { sensorPickPosition } from '../input/sensorPick.js';
|
||||
|
||||
const LAYER_SOURCE = readLayerSource(
|
||||
path.join(path.dirname(fileURLToPath(import.meta.url)), 'firmsHeatmap.js'),
|
||||
@@ -58,10 +65,13 @@ function harness({
|
||||
fires = [makeFire()],
|
||||
picked = null,
|
||||
cardHit = null,
|
||||
topCard = null,
|
||||
cameraPosition = null,
|
||||
withDataSource = false,
|
||||
withGlobe = false,
|
||||
feed = null,
|
||||
drilled = null,
|
||||
firstClick = null,
|
||||
} = {}) {
|
||||
const hadWindow = Object.hasOwn(globalThis, 'window');
|
||||
const priorWindow = globalThis.window;
|
||||
@@ -77,16 +87,24 @@ function harness({
|
||||
};
|
||||
|
||||
const published = [];
|
||||
const overlayHost = {
|
||||
setEntries: (sourceId, entries) => published.push(...entries),
|
||||
setVisible() {},
|
||||
clearSource() {},
|
||||
hitTest: (_x, _y, { sourceId } = {}) =>
|
||||
!sourceId && topCard
|
||||
? topCard
|
||||
: cardHit
|
||||
? { sourceId: 'firms', entryId: cardHit }
|
||||
: null,
|
||||
};
|
||||
// The card on top at a click, as the host answers the pick registry.
|
||||
setClickCardHitTest((x, y) => overlayHost.hitTest(x, y));
|
||||
const layer = createFirmsHeatmapLayer({
|
||||
...(feed ? { feed } : {}),
|
||||
id: 'firms-test',
|
||||
name: 'Fires',
|
||||
overlayHost: {
|
||||
setEntries: (sourceId, entries) => published.push(...entries),
|
||||
setVisible() {},
|
||||
clearSource() {},
|
||||
hitTest: () => (cardHit ? { sourceId: 'firms', entryId: cardHit } : null),
|
||||
},
|
||||
overlayHost,
|
||||
});
|
||||
|
||||
const draw = fakeDrawPort();
|
||||
@@ -106,6 +124,7 @@ function harness({
|
||||
const viewer = {
|
||||
scene: {
|
||||
pick,
|
||||
...(drilled ? { drillPick: () => drilled } : {}),
|
||||
canvas: { clientWidth: 1280, clientHeight: 800 },
|
||||
camera: cameraPosition ? { positionWC: cameraPosition } : undefined,
|
||||
globe: { ellipsoid: Cesium.Ellipsoid.WGS84 },
|
||||
@@ -129,6 +148,8 @@ function harness({
|
||||
if (!withGlobe)
|
||||
layer.attachShellServices({ imageryHost: () => ({ kind: 'none' }) });
|
||||
const input = fakeInput(viewer);
|
||||
// A subscriber that runs before the layer's own (an aircraft layer).
|
||||
if (firstClick) input.input.onClick(firstClick);
|
||||
// The LOD rebuild (and with it the context-registration sweep) is inert
|
||||
// without a data source, so tests that drive a real refresh need one.
|
||||
if (withDataSource) layer.init(viewer);
|
||||
@@ -153,7 +174,14 @@ function harness({
|
||||
(record) => record.kind === 'icons' && !record.disposed,
|
||||
),
|
||||
click: () => input.click({ x: 400, y: 300 }),
|
||||
cover: (hit) => {
|
||||
topCard = hit;
|
||||
},
|
||||
setPicked: (next) => {
|
||||
picked = next;
|
||||
},
|
||||
cleanup() {
|
||||
setClickCardHitTest(null);
|
||||
Cesium.SceneTransforms.worldToWindowCoordinates = priorProjection;
|
||||
if (hadWindow) globalThis.window = priorWindow;
|
||||
else delete globalThis.window;
|
||||
@@ -308,8 +336,16 @@ test('far-side detections cannot consume the bounded ambient-card cohort', () =>
|
||||
|
||||
test('clicking a fire sprite selects it and requests the camera transfer', () => {
|
||||
const fire = makeFire();
|
||||
const h = harness({ fires: [fire], picked: glowPick('firms-7') });
|
||||
const h = harness({
|
||||
fires: [fire],
|
||||
picked: glowPick('firms-7'),
|
||||
topCard: { sourceId: 'earthquakes', entryId: 'quake:cover' },
|
||||
});
|
||||
try {
|
||||
// Under another layer's card the sprite is that card's click.
|
||||
h.click();
|
||||
assert.equal(h.requests.length, 0, 'covered: the card takes it');
|
||||
h.cover(null);
|
||||
h.click();
|
||||
assert.equal(h.requests.length, 1);
|
||||
assert.equal(h.requests[0].kind, 'fire');
|
||||
@@ -355,6 +391,34 @@ test('clicking a fire CARD behaves exactly like clicking its sprite', () => {
|
||||
}
|
||||
});
|
||||
|
||||
test('a covered fire card does not act, and keeps an existing selection', () => {
|
||||
const fire = makeFire();
|
||||
const h = harness({
|
||||
fires: [fire],
|
||||
cardHit: `fire:${fireDetectionKey(fire)}`,
|
||||
});
|
||||
try {
|
||||
// Covered by another layer's card from the start: nothing selects or flies.
|
||||
h.cover({ sourceId: 'earthquakes', entryId: 'quake:cover' });
|
||||
h.click();
|
||||
assert.equal(h.requests.length, 0);
|
||||
assert.equal(h.layer.getSelectedInfo(), null);
|
||||
// Uncovered, the card selects; covered again, the click is the other
|
||||
// layer's and leaves that selection alone.
|
||||
h.cover(null);
|
||||
h.click();
|
||||
assert.equal(h.requests.length, 1);
|
||||
const selected = h.layer.getSelectedInfo();
|
||||
assert.ok(selected);
|
||||
h.cover({ sourceId: 'earthquakes', entryId: 'quake:cover' });
|
||||
h.click();
|
||||
assert.equal(h.requests.length, 1);
|
||||
assert.deepEqual(h.layer.getSelectedInfo(), selected);
|
||||
} finally {
|
||||
h.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
// The voice model reads these labels as data (track_entity, get_entity_context,
|
||||
// pointer_context); the voice card translates them where it shows them.
|
||||
test('fire labels stay English data in a translated interface', () => {
|
||||
@@ -386,9 +450,9 @@ test('a click on neither sprite nor card clears without moving the camera', () =
|
||||
}
|
||||
});
|
||||
|
||||
// Sibling layers surface heterogeneous pick shapes. Reading `picked.id`
|
||||
// directly recognized only bare strings, so an AIS sprite (or satellite, or
|
||||
// entity) under a fire card let BOTH layers issue a camera command.
|
||||
// Sibling layers surface heterogeneous pick shapes. Whatever is drawn under
|
||||
// it, the fire card painted on top takes the click (those layers stand aside
|
||||
// under another layer's card, so one click does one thing).
|
||||
const SIBLING_PICKS = [
|
||||
['flights', 'a1b2c3', { id: 'a1b2c3' }],
|
||||
['flights', 'a1b2c3', { primitive: { id: 'a1b2c3' } }],
|
||||
@@ -398,7 +462,7 @@ const SIBLING_PICKS = [
|
||||
];
|
||||
|
||||
for (const [layerId, ownedId, picked] of SIBLING_PICKS) {
|
||||
test(`a ${layerId} pick shaped ${JSON.stringify(picked)} wins over a card hit`, () => {
|
||||
test(`a fire card wins over a ${layerId} pick shaped ${JSON.stringify(picked)}`, () => {
|
||||
const fire = makeFire();
|
||||
registerPickOwner(layerId, (pickedId) => pickedId === ownedId);
|
||||
const h = harness({
|
||||
@@ -408,11 +472,7 @@ for (const [layerId, ownedId, picked] of SIBLING_PICKS) {
|
||||
});
|
||||
try {
|
||||
h.click();
|
||||
assert.equal(
|
||||
h.requests.length,
|
||||
0,
|
||||
`the ${layerId} layer is already acting on this click`,
|
||||
);
|
||||
assert.equal(h.requests.length, 1, 'the card on top acts');
|
||||
} finally {
|
||||
h.cleanup();
|
||||
unregisterPickOwner(layerId);
|
||||
@@ -420,6 +480,135 @@ for (const [layerId, ownedId, picked] of SIBLING_PICKS) {
|
||||
});
|
||||
}
|
||||
|
||||
// A passive owner's pick (a directions route, a flight trail) acts for nobody:
|
||||
// a fire card over it still takes the click, and with no card the pick is
|
||||
// still not empty space, so the selection stays.
|
||||
test('a fire card acts over a passive pick; the bare pick leaves the selection', () => {
|
||||
const fire = makeFire();
|
||||
registerPickOwner('test-route', (pickedId) => pickedId === 'route:line');
|
||||
const carded = harness({
|
||||
fires: [fire],
|
||||
picked: { id: 'route:line' },
|
||||
cardHit: `fire:${fireDetectionKey(fire)}`,
|
||||
});
|
||||
try {
|
||||
carded.click();
|
||||
assert.equal(carded.requests.length, 1, 'the card acts over the route');
|
||||
assert.ok(carded.layer.getSelectedInfo());
|
||||
} finally {
|
||||
carded.cleanup();
|
||||
}
|
||||
const bare = harness({ fires: [fire], picked: { id: 'route:line' } });
|
||||
try {
|
||||
bare.click();
|
||||
assert.equal(bare.requests.length, 0);
|
||||
assert.equal(
|
||||
bare.layer.getSelectedInfo(),
|
||||
null,
|
||||
'nothing to clear or pick',
|
||||
);
|
||||
} finally {
|
||||
bare.cleanup();
|
||||
unregisterPickOwner('test-route');
|
||||
}
|
||||
});
|
||||
|
||||
// A coarse tap on a fire card finds an aircraft nearby through the shared
|
||||
// touch contact. The card on top takes it; the aircraft layer stands aside.
|
||||
test('a fire card takes a tap over a touch contact its layer acts on', (t) => {
|
||||
const previous = globalThis.matchMedia;
|
||||
globalThis.matchMedia = () => ({ matches: true });
|
||||
t.after(() => {
|
||||
if (previous) globalThis.matchMedia = previous;
|
||||
else delete globalThis.matchMedia;
|
||||
});
|
||||
const fire = makeFire();
|
||||
registerPickOwner('test-planes', (pickedId) => pickedId === 'plane:1');
|
||||
t.after(() => unregisterPickOwner('test-planes'));
|
||||
const h = harness({
|
||||
fires: [fire],
|
||||
drilled: [{ id: 'plane:1' }],
|
||||
cardHit: `fire:${fireDetectionKey(fire)}`,
|
||||
});
|
||||
try {
|
||||
h.click();
|
||||
assert.equal(h.requests.length, 1, 'the card takes the tap');
|
||||
assert.ok(h.layer.getSelectedInfo());
|
||||
} finally {
|
||||
h.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
// A touch contact whose layer acts only on exact hits does not take the tap
|
||||
// from our card; with no card, a coarse tap near an aircraft still clears.
|
||||
test('a fire card keeps a tap whose contact does not act; bare taps still clear', (t) => {
|
||||
const previous = globalThis.matchMedia;
|
||||
globalThis.matchMedia = () => ({ matches: true });
|
||||
t.after(() => {
|
||||
if (previous) globalThis.matchMedia = previous;
|
||||
else delete globalThis.matchMedia;
|
||||
});
|
||||
const fire = makeFire();
|
||||
registerPickOwner('test-cameras', (pickedId) => pickedId === 'cam:1');
|
||||
registerPickOwner('test-planes', (pickedId) => pickedId === 'plane:1');
|
||||
t.after(() => {
|
||||
unregisterPickOwner('test-cameras');
|
||||
unregisterPickOwner('test-planes');
|
||||
});
|
||||
const carded = harness({
|
||||
fires: [fire],
|
||||
drilled: [{ id: 'cam:1' }],
|
||||
cardHit: `fire:${fireDetectionKey(fire)}`,
|
||||
});
|
||||
try {
|
||||
carded.click();
|
||||
assert.equal(carded.requests.length, 1, 'the card acts');
|
||||
} finally {
|
||||
carded.cleanup();
|
||||
}
|
||||
const bare = harness({
|
||||
fires: [fire],
|
||||
picked: glowPick('firms-7'),
|
||||
drilled: [{ id: 'plane:1' }],
|
||||
});
|
||||
try {
|
||||
bare.click();
|
||||
assert.ok(bare.layer.getSelectedInfo(), 'a fire is selected');
|
||||
// Nothing exact now; the touch contact is an aircraft, with no card.
|
||||
bare.setPicked(null);
|
||||
bare.click();
|
||||
assert.equal(bare.layer.getSelectedInfo(), null, 'the bare tap clears');
|
||||
} finally {
|
||||
bare.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
// The aircraft layer runs first. Under the fire card painted over its plane
|
||||
// it stands aside, so the card takes the click: one action, in either order.
|
||||
test('a fire card over an aircraft takes the click; the aircraft does not track', (t) => {
|
||||
const fire = makeFire();
|
||||
let tracked = null;
|
||||
registerPickOwner('test-planes', (pickedId) => pickedId === 'plane:9');
|
||||
t.after(() => unregisterPickOwner('test-planes'));
|
||||
const h = harness({
|
||||
fires: [fire],
|
||||
picked: { id: 'plane:9' },
|
||||
cardHit: `fire:${fireDetectionKey(fire)}`,
|
||||
firstClick: (event) => {
|
||||
if (isUnderOtherCard(event)) return;
|
||||
if (event.hit?.id === 'plane:9') tracked = 'plane:9';
|
||||
},
|
||||
});
|
||||
try {
|
||||
h.click();
|
||||
assert.equal(tracked, null, 'the aircraft does not track');
|
||||
assert.equal(h.requests.length, 1, 'the fire card acts');
|
||||
assert.ok(h.layer.getSelectedInfo());
|
||||
} finally {
|
||||
h.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test('a stale card id resolves to nothing instead of an arbitrary fire', () => {
|
||||
const h = harness({
|
||||
picked: { primitive: {}, content: {}, featureId: 0 },
|
||||
@@ -649,6 +838,16 @@ test('far zoom drapes one heatmap and the hand-off cross-fades it with the marke
|
||||
assert.equal(added[0].alpha, 0.5);
|
||||
assert.equal(glow(1).alpha, 0.5, 'rebuilt markers get the fade');
|
||||
|
||||
// An application drawing the detections in their place hides both.
|
||||
h.layer.setMarkerStandIn({ hitTest: () => null });
|
||||
assert.equal(added[0].show, false, 'a stand-in hides the heatmap');
|
||||
assert.equal(markers().show, false, 'and the markers');
|
||||
h.layer._renderLodForTest('global');
|
||||
assert.equal(added[0].show, false, 'through a rebuild too');
|
||||
h.layer.setMarkerStandIn(null);
|
||||
assert.equal(added[0].show, true);
|
||||
assert.equal(markers().show, true);
|
||||
|
||||
h.layer.disable();
|
||||
assert.equal(added[0].show, false, 'disable hides the heatmap');
|
||||
|
||||
@@ -660,3 +859,161 @@ test('far zoom drapes one heatmap and the hand-off cross-fades it with the marke
|
||||
restoreDocument();
|
||||
}
|
||||
});
|
||||
|
||||
test('a click on a fire an application draws in place of the markers selects it as a marker click does', () => {
|
||||
const fire = makeFire();
|
||||
const other = makeFire({ index: 8, lat: 31.2, lon: -97.9, frp: 40 });
|
||||
// The application's records come from the same source, adapted on their own.
|
||||
let answer = { ...fire };
|
||||
const asked = [];
|
||||
const h = harness({ fires: [fire, other], picked: glowPick('firms-8') });
|
||||
try {
|
||||
h.layer.setMarkerStandIn({
|
||||
hitTest: (screen) => {
|
||||
asked.push(screen);
|
||||
return answer;
|
||||
},
|
||||
});
|
||||
assert.equal(h.icons().show, false, 'the glows are hidden');
|
||||
h.published.length = 0;
|
||||
h.click();
|
||||
assert.deepEqual(asked, [{ x: 400, y: 300 }]);
|
||||
assert.equal(h.requests.length, 1, 'the camera moves as for a marker');
|
||||
assert.equal(h.requests[0].kind, 'fire');
|
||||
assert.equal(
|
||||
h.requests[0].id,
|
||||
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(
|
||||
h.published.map((entry) => entry.id),
|
||||
[`selected-fire:${fireDetectionKey(fire)}`],
|
||||
"only the selected fire's card shows",
|
||||
);
|
||||
|
||||
// Nothing of the application's under the click: empty space.
|
||||
answer = null;
|
||||
h.click();
|
||||
assert.equal(h.requests.length, 1, 'no camera move');
|
||||
assert.equal(h.layer.getSelectedInfo(), null, 'the selection is cleared');
|
||||
} finally {
|
||||
h.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
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] });
|
||||
try {
|
||||
h.layer.setMarkerStandIn({
|
||||
hitTest: () => makeFire({ lat: 12.5, lon: 40.1 }),
|
||||
});
|
||||
h.click();
|
||||
assert.equal(h.requests.length, 0);
|
||||
assert.equal(h.layer.getSelectedInfo(), null);
|
||||
} finally {
|
||||
h.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test('taking the stand-in away brings the markers and their cards back and keeps the selection', () => {
|
||||
const fire = makeFire();
|
||||
const h = harness({
|
||||
fires: [fire],
|
||||
// Near enough for the markers rather than the heatmap.
|
||||
cameraPosition: Cesium.Cartesian3.fromDegrees(fire.lon, fire.lat, 500_000),
|
||||
});
|
||||
try {
|
||||
h.layer.setMarkerStandIn({ hitTest: () => fire });
|
||||
assert.equal(h.icons().show, false);
|
||||
h.click();
|
||||
h.layer.setMarkerStandIn(null);
|
||||
assert.equal(h.icons().show, true);
|
||||
assert.equal(h.layer.getSelectedInfo().id, fireDetectionKey(fire));
|
||||
const ids = h.published.map((entry) => entry.id);
|
||||
assert.ok(ids.includes(`selected-fire:${fireDetectionKey(fire)}`));
|
||||
} finally {
|
||||
h.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test('the stand-in is asked where a marker is picked: the click as the sensor style draws it', () => {
|
||||
const fire = makeFire();
|
||||
const asked = [];
|
||||
const h = harness({ fires: [fire] });
|
||||
try {
|
||||
registerStyleStages(h.viewer.scene, {
|
||||
surveillance: {
|
||||
enabled: true,
|
||||
uniforms: { intensity: 1, pixelation: 4 },
|
||||
},
|
||||
});
|
||||
h.layer.setMarkerStandIn({
|
||||
hitTest: (screen) => {
|
||||
asked.push(screen);
|
||||
return fire;
|
||||
},
|
||||
});
|
||||
h.click();
|
||||
const expected = sensorPickPosition(
|
||||
h.viewer.scene,
|
||||
{ x: 400, y: 300 },
|
||||
h.viewer.scene.canvas,
|
||||
);
|
||||
assert.notDeepEqual([expected.x, expected.y], [400, 300]);
|
||||
assert.deepEqual([asked[0].x, asked[0].y], [expected.x, expected.y]);
|
||||
} finally {
|
||||
h.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test("a sibling layer's item over a stand-in fire wins the click", () => {
|
||||
const fire = makeFire();
|
||||
let asked = 0;
|
||||
registerPickOwner('flights', (pickedId) => pickedId === 'a1b2c3');
|
||||
const h = harness({ fires: [fire], picked: { id: 'a1b2c3' } });
|
||||
try {
|
||||
h.layer.setMarkerStandIn({
|
||||
hitTest: () => {
|
||||
asked++;
|
||||
return fire;
|
||||
},
|
||||
});
|
||||
h.click();
|
||||
assert.equal(asked, 0, 'the stand-in is not asked');
|
||||
assert.equal(h.requests.length, 0, 'no camera move');
|
||||
assert.equal(h.layer.getSelectedInfo(), null);
|
||||
} finally {
|
||||
h.cleanup();
|
||||
unregisterPickOwner('flights');
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* How a fleet model's draw item is turned, stretched and coloured
|
||||
* (`fleetModelInstances.js`): pure, no renderer, so it can be read without
|
||||
* the draw port.
|
||||
*/
|
||||
|
||||
/** Every fleet GLB is nose -X: opposite the draw contract's heading 0. */
|
||||
export const FLEET_HEADING_OFFSET_DEG = 180;
|
||||
|
||||
/**
|
||||
* A colour as the draw contract takes it: a CSS string or `[r, g, b, a]`
|
||||
* as given, `{red, green, blue, alpha}` as an array; null for none.
|
||||
*/
|
||||
export function fleetColor(color) {
|
||||
if (color === undefined || color === null) return null;
|
||||
if (typeof color === 'string' || Array.isArray(color)) return color;
|
||||
if (typeof color.red === 'number')
|
||||
return [color.red, color.green, color.blue, color.alpha ?? 1];
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The per-axis stretch a fleet spec draws with on top of its length scale,
|
||||
* along the model's glTF axes (`x` its length, `y` its height, `z` its
|
||||
* beam), or undefined when it keeps its proportions.
|
||||
* @param {object} spec `fleetModelSpec`.
|
||||
* @returns {[number, number, number]|undefined}
|
||||
*/
|
||||
export function fleetAxisScale(spec) {
|
||||
const [length, beam, height] = spec?.scaleXYZ ?? [];
|
||||
if (!(length > 0) || (beam === length && height === length)) return;
|
||||
return [1, height / length, beam / length];
|
||||
}
|
||||
@@ -1,4 +1,9 @@
|
||||
import { selectModelEligible } from './modelEligibility.js';
|
||||
import {
|
||||
FLEET_HEADING_OFFSET_DEG,
|
||||
fleetAxisScale,
|
||||
fleetColor,
|
||||
} from './fleetModelDraw.js';
|
||||
import { AIRCRAFT_ENVIRONMENT_MAP_OPTIONS } from './aircraftModelLighting.js';
|
||||
import { fleetModelSet, fleetPartTable } from './fleetModels.js';
|
||||
import { findCamera, findDraw } from '../render/rendererOf.js';
|
||||
@@ -17,8 +22,11 @@ import {
|
||||
* and Rail layers share.
|
||||
*/
|
||||
|
||||
/** Every fleet GLB is nose -X: opposite the draw contract's heading 0. */
|
||||
export const FLEET_HEADING_OFFSET_DEG = 180;
|
||||
export {
|
||||
FLEET_HEADING_OFFSET_DEG,
|
||||
fleetAxisScale,
|
||||
fleetColor,
|
||||
} from './fleetModelDraw.js';
|
||||
|
||||
/** How long (ms) a model whose load failed waits before it loads again. */
|
||||
const RETRY_MS = 5000;
|
||||
@@ -26,31 +34,6 @@ const RETRY_MS = 5000;
|
||||
/** A white tint: what a model under the NVG/FLIR styles draws with. */
|
||||
const WHITE = Object.freeze([1, 1, 1, 1]);
|
||||
|
||||
/**
|
||||
* A colour as the draw contract takes it: a CSS string or `[r, g, b, a]`
|
||||
* as given, `{red, green, blue, alpha}` as an array; null for none.
|
||||
*/
|
||||
export function fleetColor(color) {
|
||||
if (color === undefined || color === null) return null;
|
||||
if (typeof color === 'string' || Array.isArray(color)) return color;
|
||||
if (typeof color.red === 'number')
|
||||
return [color.red, color.green, color.blue, color.alpha ?? 1];
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The per-axis stretch a fleet spec draws with on top of its length scale,
|
||||
* along the model's glTF axes (`x` its length, `y` its height, `z` its
|
||||
* beam), or undefined when it keeps its proportions.
|
||||
* @param {object} spec `fleetModelSpec`.
|
||||
* @returns {[number, number, number]|undefined}
|
||||
*/
|
||||
export function fleetAxisScale(spec) {
|
||||
const [length, beam, height] = spec?.scaleXYZ ?? [];
|
||||
if (!(length > 0) || (beam === length && height === length)) return;
|
||||
return [1, height / length, beam / length];
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether `point` is inside the eye's view cone (`pose`), a metre's slack.
|
||||
* @param {object} pose The camera port's pose.
|
||||
|
||||
@@ -1827,6 +1827,44 @@ export class LayerLifecycle {
|
||||
await entry.toggleChain.catch(() => {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait until a layer's lifecycle queue is idle, following any request that
|
||||
* joins it while waiting, but no longer than `timeoutMs` or `signal` allows.
|
||||
* @param {string} layerId Layer id.
|
||||
* @param {{signal?: AbortSignal, timeoutMs?: number}} [options]
|
||||
* @returns {Promise<boolean>} true once idle; false on timeout or abort.
|
||||
*/
|
||||
async waitForLayerIdle(layerId, { signal, timeoutMs = 30000 } = {}) {
|
||||
const entry = this.layers.get(layerId);
|
||||
if (!entry) return true;
|
||||
if (signal?.aborted) return false;
|
||||
let timer = null;
|
||||
let onAbort = null;
|
||||
const givenUp = new Promise((resolve) => {
|
||||
timer = setTimeout(() => resolve(false), timeoutMs);
|
||||
onAbort = () => resolve(false);
|
||||
signal?.addEventListener('abort', onAbort, { once: true });
|
||||
});
|
||||
try {
|
||||
let pending;
|
||||
do {
|
||||
pending = entry.toggleChain;
|
||||
const idle = await Promise.race([
|
||||
pending.then(
|
||||
() => true,
|
||||
() => true,
|
||||
),
|
||||
givenUp,
|
||||
]);
|
||||
if (!idle) return false;
|
||||
} while (pending !== entry.toggleChain);
|
||||
return true;
|
||||
} finally {
|
||||
clearTimeout(timer);
|
||||
signal?.removeEventListener('abort', onAbort);
|
||||
}
|
||||
}
|
||||
|
||||
_reserveLayerParamsIntent(layerId, params, origin = 'programmatic') {
|
||||
const entry = this.layers.get(layerId);
|
||||
if (
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
import { createInfrastructureOverlayEntry } from './infrastructureOverlayEntry.js';
|
||||
import { createGeojsonPins } from './geojsonPins.js';
|
||||
import { inputFor as defaultInputFor } from '../input/dispatcher.js';
|
||||
import { isUnderOtherCard } from './pickRegistry.js';
|
||||
import {
|
||||
selectInfraLod,
|
||||
applyInfraEvictionGrace,
|
||||
@@ -1114,6 +1115,9 @@ export function createLocalGeoJsonLayer(
|
||||
const input = inputFor(viewer);
|
||||
_clickSubscription = input.onClick((event) => {
|
||||
if (!_enabled || !_drawn) return;
|
||||
// Another layer's card or label on top takes the click: the
|
||||
// item under it neither acts nor reads as empty space.
|
||||
if (isUnderOtherCard(event)) return;
|
||||
const hit = event.drawHit;
|
||||
if (!hit || !hit.set.startsWith(`${setPrefix}:`)) return;
|
||||
const part = _drawn.parts.get(hit.id);
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
} from './localGeojsonCore.js';
|
||||
import { localGeoJsonServices } from '../app/localGeojsonServices.js';
|
||||
import { getContextStore } from './contextStore.js';
|
||||
import { setClickCardHitTest } from './pickRegistry.js';
|
||||
import { readEntityRecord } from './entityRecords.js';
|
||||
import { bindFakeGroundRenderer } from '../testSupport/fakeGroundRenderer.mjs';
|
||||
const feature = (id, geometry, properties = { name: `Feature ${id}` }) => ({
|
||||
@@ -161,6 +162,24 @@ test('polygons fill the ground, lines drape, points stand on pins, all shown', a
|
||||
assert.equal(record?.label, 'Feature p');
|
||||
});
|
||||
|
||||
// The card or label painted on top takes the click: a feature under another
|
||||
// layer's card is not selected.
|
||||
test("another layer's card over a drawn part keeps the click", async (t) => {
|
||||
const env = await enabledLayer(t, [
|
||||
feature('p', { type: 'Polygon', coordinates: square(0, 0) }),
|
||||
]);
|
||||
let top = { sourceId: 'earthquake-card', entryId: 'earthquake-card:ak1' };
|
||||
setClickCardHitTest(() => top);
|
||||
t.after(() => setClickCardHitTest(null));
|
||||
const fills = env.fake.set('fills');
|
||||
const at = { x: 5, y: 5 };
|
||||
env.click({ screenPosition: at, drawHit: { set: fills.spec.id, id: 'p' } });
|
||||
assert.equal(env.fake.flights.length, 0, 'covered: not selected');
|
||||
top = null;
|
||||
env.click({ screenPosition: at, drawHit: { set: fills.spec.id, id: 'p' } });
|
||||
assert.equal(env.fake.flights.length, 1);
|
||||
});
|
||||
|
||||
test('a click on a drawn part selects its feature and flies above it', async (t) => {
|
||||
const env = await enabledLayer(t, [
|
||||
feature('p', { type: 'Polygon', coordinates: square(0, 0) }),
|
||||
|
||||
@@ -36,7 +36,13 @@ places without an English label.
|
||||
The build runs one query at a time with pauses and honours the service's
|
||||
Retry-After; it takes about ten minutes. It fails if a short list of
|
||||
well-known cities is missing from the result, or a known grouping gets in.
|
||||
`meta.built` keeps its earlier date when the rows are unchanged.
|
||||
|
||||
**Limits:** populations are whatever Wikidata states and differ in date and
|
||||
definition between places (city proper, municipality, urban district). Some
|
||||
districts and suburbs appear as their own rows.
|
||||
|
||||
**Finding a place by name:** `findPlace` takes the nearest place of the name
|
||||
within 150 km of the view, else the largest city of the name. When asked,
|
||||
the smaller places of `../wikidata_places` near the view count too, so a
|
||||
village in view comes before a bigger namesake far away.
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["São Vicente",-7.442,-37.093,2601,"BR","Q120069910"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Acrelândia",-9.828,-66.883,14021,"BR","Q953086"],["Manoel Urbano",-8.839,-69.26,11996,"BR","Q1772688"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Rodrigues Alves",-7.742,-72.647,14938,"BR","Q1800776"],["Porto Walter",-8.269,-72.744,10735,"BR","Q1772588"],["Jordão",-9.434,-71.884,9222,"BR","Q1800793"],["Santa Rosa do Purus",-9.433,-70.493,6723,"BR","Q1772719"],["Esperanza",-9.799,-70.753,4405,"PE","Q3344870"],["Puerto Inca",-9.379,-74.964,2856,"PE","Q3348305"],["Tournavista",-8.934,-74.703,1472,"PE","Q137700491"],["Honoria",-8.769,-74.709,1422,"PE","Q137700481"],["Yuyapichis",-9.628,-74.975,1286,"PE","Q137700493"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["San José de Sisa",-6.614,-76.694,14639,"PE","Q11034041"],["Soritor",-6.139,-77.104,14310,"PE","Q27194589"],["Saposoa",-6.936,-76.772,12951,"PE","Q3344065"],["Castillo Grande",-9.278,-76.009,12438,"PE","Q137700501"],["Cayaltí",-6.892,-79.562,12257,"PE","Q116762746"],["Bellavista",-7.067,-76.585,12117,"PE","Q3344055"],["Salaverry",-8.221,-78.976,11751,"PE","Q7403730"],["Lamas",-6.422,-76.516,11165,"PE","Q3139869"],["Ascope",-7.714,-79.108,10560,"PE","Q3344017"],["Namballe District",-5.003,-79.088,10492,"PE","Q6319417"],["Picsi",-6.718,-79.77,9251,"PE","Q49278067"],["Morropón",-5.187,-79.971,8949,"PE","Q6024431"],["Picota",-6.921,-76.33,8376,"PE","Q3344087"],["Yungay",-9.139,-77.744,8000,"PE","Q919678"],["Chongoyape",-6.637,-79.394,7842,"PE","Q5767159"],["Lagunas",-5.227,-75.675,7215,"PE","Q27194615"],["Mochumí",-6.548,-79.864,7188,"PE","Q27194530"],["Uchiza",-8.459,-76.463,6997,"PE","Q20621865"],["Tabalosos",-6.388,-76.634,6642,"PE","Q27194591"],["Pucalá",-6.781,-79.611,6445,"PE","Q106098771"],["Llata",-9.55,-76.817,6027,"PE","Q3344864"],["Naranjos",-5.739,-77.504,5913,"PE","Q137684978"],["Oyotún",-6.85,-79.304,5735,"PE","Q27557971"],["Chicama",-7.845,-79.145,5692,"PE","Q5095918"],["Pomabamba",-8.82,-77.461,5667,"PE","Q3322611"],["Orellana",-6.912,-75.157,5432,"PE","Q7101524"],["Pedro Ruiz Gallo",-5.946,-77.977,5361,"PE","Q27194454"],["Quiruvilca",-8.001,-78.31,5181,"PE","Q16623750"],["Huallanca",-9.899,-76.941,5064,"PE","Q5903856"],["Illimo",-6.474,-79.855,5037,"PE","Q17073502"],["Chocopeu",-7.792,-79.223,5037,"PE","Q5103685"],["Mendoza",-6.394,-77.486,4989,"PE","Q3305659"],["Panao",-9.901,-75.998,4848,"PE","Q3344024"],["Mocupe",-6.991,-79.622,4818,"PE","Q116763392"],["Chazuta",-6.571,-76.138,4595,"PE","Q49277326"],["Huicungo",-7.319,-76.776,4548,"PE","Q33446632"],["Pulán",-6.739,-78.92,4492,"PE","Q16623296"],["Zaña",-6.923,-79.584,4253,"PE","Q6171043"],["Pueblo Nuevo",-7.189,-79.514,4014,"PE","Q7258457"],["San Miguel de Pallaques",-7.001,-78.849,3989,"PE","Q11002429"],["Naranjillo",-9.249,-75.994,3945,"PE","Q2884961"],["Huacrachuco",-8.607,-77.149,3945,"PE","Q3344853"],["Moro",-9.139,-78.183,3926,"PE","Q130326439"],["Juan Guerra",-6.584,-76.324,3745,"PE","Q137684968"],["Pomacochas",-5.826,-77.969,3739,"PE","Q27194453"],["Santa Lucía",-8.345,-76.386,3636,"PE","Q137715155"],["Pacanga",-7.171,-79.486,3593,"PE","Q7121871"],["Calzada",-6.03,-77.067,3550,"PE","Q137684952"],["Nuevo Progreso",-8.451,-76.326,3532,"PE","Q130388430"],["Yuracyacu",-5.931,-77.226,3428,"PE","Q137684991"],["Buenos Aires",-5.267,-79.968,3418,"PE","Q49277301"],["Tembladera",-7.252,-79.13,3238,"PE","Q13190929"],["Jesús",-7.249,-78.38,3209,"PE","Q131323854"],["Chaglla",-9.845,-75.903,3108,"PE","Q137700471"],["Hualgayoc",-6.764,-78.607,3101,"PE","Q130336639"],["La Peca",-5.611,-78.437,3081,"PE","Q11982882"],["Jepelacio",-6.108,-76.915,3081,"PE","Q49277624"],["Cacatachi",-6.462,-76.451,3019,"PE","Q137684951"],["Salas",-6.274,-79.605,3008,"PE","Q107851677"],["Molino",-9.91,-76.016,2931,"PE","Q137700498"],["Lonya Grande",-6.096,-78.423,2896,"PE","Q131451947"],["Cátac",-9.802,-77.431,2776,"PE","Q1050130"],["Ripán",-9.829,-76.803,2755,"PE","Q13190560"],["Sócota",-6.315,-78.7,2698,"PE","Q131323944"],["San Martín",-6.514,-76.741,2644,"PE","Q137684992"],["Yaután",-9.512,-77.997,2446,"PE","Q130316672"],["La Jalca",-6.486,-77.816,2390,"PE","Q3374297"],["Chavín de Huántar",-9.589,-77.178,2384,"PE","Q17449251"],["Luya",-6.165,-77.945,2358,"PE","Q13189994"],["Roque",-6.356,-76.775,2339,"PE","Q137684944"],["Jequetepeque",-7.338,-79.563,2313,"PE","Q15229508"],["Chiriaco",-5.161,-78.286,2278,"PE","Q11963566"],["Julcán",-8.05,-78.5,2260,"PE","Q3344059"],["Piscobamba",-8.883,-77.35,2252,"PE","Q3319310"],["Samanco",-9.262,-78.496,2233,"PE","Q130327433"],["Bigote",-5.319,-79.786,2205,"PE","Q124738480"],["Piscoyacu",-6.981,-76.77,2181,"PE","Q137684979"],["San Fernando",-5.901,-77.269,2173,"PE","Q137684964"],["Barranquita",-6.252,-76.033,2163,"PE","Q137684949"],["Huipoca",-8.979,-75.445,2102,"PE","Q107569131"],["Yacus",-9.986,-76.505,2094,"PE","Q137700499"],["Santiago de Cao",-7.959,-79.242,2090,"PE","Q15275280"],["Santa María del Valle",-9.863,-76.17,2064,"PE","Q137700457"],["Chilete",-7.221,-78.84,2023,"PE","Q131323858"],["Acomayo",-9.802,-76.071,2012,"PE","Q135194231"],["Lámud",-6.139,-77.952,1996,"PE","Q2475775"],["Codo del Pozuzo",-9.67,-75.463,1988,"PE","Q20024777"],["Yorongos",-6.139,-77.144,1962,"PE","Q137684990"],["Shamboyacu",-7.024,-76.132,1914,"PE","Q137684984"],["Tres Unidos",-6.806,-76.233,1911,"PE","Q137684989"],["Copallín",-5.675,-78.423,1907,"PE","Q11964086"],["Lluchubamba",-7.519,-77.969,1896,"PE","Q130336589"],["Nepeña",-9.172,-78.359,1873,"PE","Q15919329"],["Cabana",-8.396,-78.016,1858,"PE","Q3305646"],["Malacasí",-5.344,-79.858,1850,"PE","Q125712172"],["Magdalena",-7.251,-78.659,1846,"PE","Q130336591"],["Cajaruro",-5.737,-78.43,1829,"PE","Q49277314"],["Llamellín",-9.101,-77.017,1817,"PE","Q3317415"],["ChontalLine truncated
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["La Legua",-5.235,-80.658,8863,"PE","Q125828154"],["Mórrope",-6.542,-80.015,8680,"PE","Q27194532"],["La Matanza",-5.211,-80.088,6787,"PE","Q27194507"],["Vice",-5.422,-80.774,5972,"PE","Q49278395"],["Bernal",-5.463,-80.742,4007,"PE","Q49277262"],["Laynas",-5.232,-80.052,2493,"PE","Q130436047"],["Yacila",-5.133,-81.173,1690,"PE","Q27968636"],["Port of Bayóvar",-5.824,-81.035,1538,"PE","Q7231083"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Bula Atumba",-8.675,14.795,13454,"AO","Q979174"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Sindang Jaya",-6.903,107.68,14896,"ID","Q11175510"],["Sukawarna",-6.886,107.578,14324,"ID","Q11186629"],["Cipadung Kulon",-6.922,107.706,13997,"ID","Q11173868"],["Isola",-6.852,107.593,13513,"ID","Q11176203"],["Karasak",-6.95,107.608,13493,"ID","Q11174115"],["Sukarasa",-6.877,107.589,13442,"ID","Q11183012"],["Pasir Impun",-6.895,107.677,13333,"ID","Q12503577"],["Cibaduyut",-6.953,107.592,13265,"ID","Q11197161"],["Kebon Pisang",-6.919,107.617,12445,"ID","Q11182775"],["Margasuka",-6.954,107.575,12444,"ID","Q14641123"],["Cisaranten Bina Harapan",-6.914,107.684,12328,"ID","Q12479313"],["Cirangrang",-6.959,107.585,11777,"ID","Q11173692"],["Cipaganti",-6.89,107.604,11694,"ID","Q11175864"],["Ancol",-6.94,107.614,11628,"ID","Q12471984"],["Rancabolang",-6.964,107.692,11340,"ID","Q12507881"],["Cigereleng",-6.94,107.611,11233,"ID","Q12478819"],["Merdeka",-6.913,107.621,11222,"ID","Q12498194"],["Lebak Gede",-6.892,107.616,11063,"ID","Q13199701"],["Mekar Wangi",-6.955,107.606,10935,"ID","Q11174976"],["Ledeng",-6.863,107.599,10792,"ID","Q12494268"],["Situsaeur",-6.945,107.595,10720,"ID","Q11175419"],["Garuda",-6.912,107.576,10565,"ID","Q12483556"],["Cibaduyut Kidul",-6.961,107.592,9461,"ID","Q11190536"],["Pasirkaliki",-6.907,107.602,9148,"ID","Q12503629"],["Cibaduyut Wetan",-6.959,107.599,8630,"ID","Q12478700"],["Babakan Ciamis",-6.913,107.606,8501,"ID","Q11182550"],["Balong Gede",-6.925,107.607,8269,"ID","Q12473848"],["Pamoyanan",-6.903,107.593,7803,"ID","Q12502373"],["Pungkur",-6.93,107.608,7498,"ID","Q13200180"],["Babakan Penghulu",-6.941,107.692,7385,"ID","Q13544024"],["Pakemitan",-6.914,107.698,6481,"ID","Q13544023"],["Braga",-6.918,107.609,6155,"ID","Q11184258"],["Cipetir",-6.839,106.946,5716,"ID","Q11161898"],["Cihapit",-6.907,107.626,4058,"ID","Q12478837"],["Cipadung Wetan",-6.932,107.713,3583,"ID","Q12479213"],["Palugon",-7.237,108.671,2672,"ID","Q10969606"],["Citarum",-6.905,107.616,2250,"ID","Q12479343"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Wukirsari",-7.658,110.444,11500,"ID","Q12524899"],["Sambungmacan",-7.361,111.112,5009,"ID","Q4264536"],["Musi",-8.171,114.743,3085,"ID","Q18366899"],["Sumberejo",-7.93,110.861,2654,"ID","Q4208636"],["Tambong",-8.255,114.303,2579,"ID","Q12519030"],["Solor",-7.829,114.067,2527,"ID","Q12515858"],["Kecer",-6.95,113.802,2154,"ID","Q14634390"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Ubud",-8.497,115.263,10873,"ID","Q12522907"],["Kediri",-8.565,115.132,10353,"ID","Q20463891"],["Besakih",-8.375,115.45,7197,"ID","Q2899831"],["Canggu",-8.641,115.143,7088,"ID","Q2543000"],["Padangbai",-8.532,115.51,3294,"ID","Q1910262"],["Bengkala",-8.114,115.175,3000,"ID","Q13568788"],["Bengkel",-8.59,115.093,2390,"ID","Q13490146"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Pante Macassar",-9.2,124.383,8793,"TL","Q263005"],["Batugade",-8.959,124.951,3164,"TL","Q811044"],["Fatukoto",-9.709,124.216,2030,"ID","Q14627747"],["Inbate",-9.426,124.375,1187,"ID","Q12486427"],["Pulau Buaya",-8.176,124.373,1171,"ID","Q12506723"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Baucau",-8.467,126.45,14961,"TL","Q811130"],["Ermera",-8.752,125.397,13142,"TL","Q1355919"],["Lospalos",-8.517,127.033,12782,"TL","Q1017098"],["Turiscai",-8.823,125.707,11258,"TL","Q2460763"],["Manatuto",-8.517,126.017,9022,"TL","Q1011873"],["Suai",-9.3,125.25,8243,"TL","Q582712"],["Gleno",-8.723,125.435,8133,"TL","Q1018872"],["Bobonaro",-9.032,125.325,6110,"TL","Q55574072"],["Viqueque",-8.85,126.367,6078,"TL","Q1011863"],["Liquiçá",-8.594,125.327,5152,"TL","Q946959"],["Metinaro",-8.533,125.733,4316,"TL","Q18201468"],["Maubisse",-8.838,125.597,3370,"TL","Q1506450"],["Ainaro",-8.983,125.5,3085,"TL","Q108908310"],["Aileu",-8.717,125.567,2927,"TL","Q405087"],["Acanuno",-8.556,125.648,2562,"TL","Q22045079"],["Same",-9,125.65,2100,"TL","Q932640"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Daru",-9.083,143.2,12879,"PG","Q499375"],["Kiunga",-6.117,141.3,8265,"PG","Q985928"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Alexishaven",-5.083,145.8,10377,"PG","Q1626709"],["Wau",-7.339,146.717,9442,"PG","Q954956"],["Finschhafen",-6.6,147.85,1240,"PG","Q15217719"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Gizo",-8.1,156.85,7177,"SB","Q1236908"],["Munda",-8.328,157.271,4850,"SB","Q617069"],["Wagina Island",-7.439,157.767,1636,"SB","Q2713838"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Auki",-8.768,160.697,6811,"SB","Q538476"],["Burns Creek, Honiara",-9.423,160.024,5000,"SB","Q25042019"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Funafuti",-8.505,179.117,6025,"TV","Q34126"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Kaputa",-8.517,29.317,9210,"ZM","Q770286"],["Chienge",-8.774,29.08,9161,"ZM","Q996085"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Imalinyi",-9.183,34.633,10272,"TZ","Q10998287"],["Mdandu",-9.147,34.692,9497,"TZ","Q6802855"],["Lupata",-9.3,33.85,8552,"TZ","Q6704665"],["Matamba",-8.983,33.967,7505,"TZ","Q13123967"],["Lusungo",-9.5,33.983,7337,"TZ","Q6705340"],["Kabula",-9.267,33.767,6368,"TZ","Q6344457"],["Masukulu",-9.4,33.75,5521,"TZ","Q6785674"],["Wangama",-6.933,34.317,5387,"TZ","Q7967795"],["Ikama",-9.267,33.833,4732,"TZ","Q5995334"],["Ikolo",-9.65,33.9,4647,"TZ","Q5996092"],["Mwansanga",-8.767,33.533,2939,"TZ","Q6944690"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Makunduchi",-6.413,39.552,14728,"TZ","Q3843701"],["Mwaya",-8.917,36.833,12122,"TZ","Q6272943"],["Kalenga",-7.8,35.6,11491,"TZ","Q6352119"],["Ikondo, Njombe",-9.1,35.266,6655,"TZ","Q5996149"],["Mahanje",-9.933,35.333,6002,"TZ","Q35722686"],["Nyamisati",-7.795,39.275,1142,"TZ","Q10604328"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Tafuna",-14.336,-170.72,7988,"US","Q1019488"],["Vaitele",-13.82,-171.78,7972,"WS","Q9368101"],["Nuʻuuli",-14.319,-170.724,6345,"US","Q3879172"],["Pago Pago",-14.279,-170.701,3656,"US","Q51678"],["Faleniu",-14.332,-170.744,3426,"US","Q3738616"],["Leone",-14.344,-170.785,2902,"AS","Q1773774"],["'Ili'ili",-14.352,-170.747,2497,"US","Q3596207"],["Aua",-14.267,-170.65,2336,"US","Q609232"],["Afega",-13.8,-171.817,1998,"WS","Q2038921"],["Fagatogo",-14.283,-170.69,1445,"US","Q1257213"],["Lepa, Samoa",-14.033,-171.517,1429,"WS","Q2586194"],["Leulumoega",-13.817,-171.917,1184,"WS","Q1944685"],["Fagaʻalu",-14.296,-170.684,1122,"US","Q3738319"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Mata-Utu",-13.283,-176.174,1075,"FR","Q31002"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Historic Centre of Salvador da Bahia",-12.967,-38.5,2253,"BR","Q5572706"],["Maragogipinho",-13.054,-38.965,1720,"BR","Q61727521"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Alvorada",-12.48,-49.125,8802,"BR","Q22060164"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Costa Marques",-12.445,-64.227,12627,"BR","Q656758"],["Alto Alegre dos Parecis",-12.128,-61.851,11479,"BR","Q1802050"],["Cabixi",-13.498,-60.554,8174,"BR","Q940433"],["Pimenteiras do Oeste",-13.482,-61.047,2156,"BR","Q1803105"],["Baures",-13.583,-63.583,2127,"BO","Q811831"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Santa Ana del Yacuma",-13.744,-65.427,12783,"BO","Q1819433"],["Reyes",-14.296,-67.335,11478,"BO","Q913102"],["Capixaba",-10.573,-67.676,10392,"BR","Q1800737"],["Assis Brasil",-10.911,-69.582,8100,"BR","Q1754403"],["Sandia",-14.233,-69.433,8000,"PE","Q3344209"],["Usicayos",-14.125,-69.967,2409,"PE","Q130541387"],["Quilcapuncu",-14.893,-69.73,2280,"PE","Q130541411"],["San Buenaventura",-14.435,-67.541,2264,"BO","Q164003"],["Apolo",-14.716,-68.418,2123,"BO","Q2307341"],["Iñapari",-10.945,-69.577,1890,"PE","Q1899785"],["Muñani",-14.768,-69.953,1885,"PE","Q130541380"],["Putina Punco",-14.112,-69.048,1756,"PE","Q131399964"],["Ixiamas",-13.768,-68.126,1733,"BO","Q2068157"],["San Juan del Oro",-14.221,-69.154,1582,"PE","Q130541416"],["Limbani",-14.15,-69.691,1497,"PE","Q130541414"],["Phara",-14.152,-69.665,1306,"PE","Q130541419"],["Planchón",-12.278,-69.153,1297,"PE","Q107860650"],["Massiapo",-14.09,-69.243,1200,"PE","Q130541420"],["Cuyocuyo",-14.47,-69.537,1106,"PE","Q130541417"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Ascensión",-12.784,-74.978,14915,"PE","Q131451556"],["Atalaya",-10.733,-73.75,12946,"PE","Q3322627"],["Pichari",-12.52,-73.828,12050,"PE","Q7190625"],["Macusani",-14.069,-70.431,11707,"PE","Q3348229"],["Talavera de la Reyna",-13.654,-73.429,11691,"PE","Q9355344"],["Urcos",-13.686,-71.623,10614,"PE","Q2989619"],["Satipo",-11.254,-74.637,10052,"PE","Q3057885"],["Pampas",-12.399,-74.867,9973,"PE","Q2725364"],["Písac",-13.421,-71.85,9796,"PE","Q950398"],["Tamburco",-13.622,-72.873,9171,"PE","Q131187833"],["Puerto Bermúdez",-10.296,-74.938,6168,"PE","Q27213542"],["Kimbiri",-12.488,-73.842,5913,"PE","Q11687201"],["Mariscal Cáceres",-12.39,-74.858,5420,"PE","Q131176125"],["Río Negro",-11.208,-74.66,5262,"PE","Q130483344"],["Nuñoa",-14.478,-70.636,4641,"PE","Q27194667"],["Acomayo",-13.917,-71.681,4532,"PE","Q2582682"],["Paucartambo",-13.316,-71.592,4309,"PE","Q2989631"],["Chalhuanca",-14.295,-73.244,4297,"PE","Q879065"],["Tambobamba",-13.946,-72.175,4063,"PE","Q879051"],["Chinchero",-13.396,-72.06,3765,"PE","Q26764442"],["Palmapampa",-12.768,-73.656,3608,"PE","Q130369727"],["Coasa",-13.987,-70.018,3388,"PE","Q130541388"],["Yanaoca",-14.218,-71.432,3307,"PE","Q2989624"],["Churcampa",-12.723,-74.421,3306,"PE","Q3348281"],["Llochegua",-12.41,-73.906,3224,"PE","Q130369715"],["Chuquibambilla",-14.105,-72.708,3105,"PE","Q879071"],["Ollantaytambo",-13.258,-72.263,3050,"PE","Q916382"],["Antauta",-14.3,-70.292,2908,"PE","Q130541403"],["Maranganí",-14.357,-71.169,2887,"PE","Q13190024"],["Velille",-14.508,-71.886,2883,"PE","Q131399783"],["Santa Rosa",-14.607,-70.787,2858,"PE","Q131399949"],["Quichuas",-12.473,-74.767,2706,"PE","Q130371068"],["Ollachea",-13.794,-70.472,2700,"PE","Q130541390"],["Urubamba",-13.304,-72.117,2700,"PE","Q2304483"],["Ayapata",-13.777,-70.323,2622,"PE","Q130541385"],["Lucre",-13.635,-71.746,2612,"PE","Q13189987"],["Vilcashuamán",-13.653,-73.954,2577,"PE","Q2475760"],["Macari",-14.772,-70.903,2527,"PE","Q13190027"],["Huancabamba",-13.734,-73.35,2492,"PE","Q131187838"],["Quebrada Honda",-12.682,-72.278,2433,"PE","Q13191015"],["Boca Colorado",-12.619,-70.394,2252,"PE","Q107860921"],["Huancarama",-13.645,-73.086,2225,"PE","Q131451845"],["Pampa Cangallo",-13.558,-74.196,2115,"PE","Q130369697"],["Antabamba",-14.365,-72.878,2061,"PE","Q879057"],["Mantaro",-12.324,-73.94,2039,"PE","Q130492438"],["Ancahuasi",-13.457,-72.3,1921,"PE","Q130492417"],["Cabana",-14.289,-73.967,1891,"PE","Q131324820"],["Pillcopata",-12.911,-71.405,1858,"PE","Q21294423"],["Pucyura",-13.479,-72.112,1853,"PE","Q130492418"],["Huancarani",-13.503,-71.655,1842,"PE","Q130492443"],["Huaro",-13.69,-71.641,1833,"PE","Q20622303"],["Querobamba",-14.012,-73.839,1799,"PE","Q2918849"],["Chincheros",-13.518,-73.723,1797,"PE","Q878820"],["Quince Mil",-13.231,-70.754,1759,"PE","Q5573415"],["Paruro",-13.763,-71.849,1750,"PE","Q2989645"],["Huancapi",-13.75,-74.064,1748,"PE","Q950080"],["Maras",-13.333,-72.156,1730,"PE","Q1026235"],["Llalli",-14.933,-70.881,1709,"PE","Q130541405"],["Cachimayo",-13.477,-72.068,1673,"PE","Q130492416"],["Huyro",-13.007,-72.554,1619,"PE","Q130492433"],["Cotabambas",-13.747,-72.356,1604,"PE","Q13189891"],["Mollepata",-13.509,-72.528,1589,"PE","Q130489438"],["Lanlacuni Bajo",-13.439,-70.402,1572,"PE","Q130541389"],["Limatambo",-13.48,-72.443,1562,"PE","Q11161861"],["Huanoquite",-13.682,-72.018,1546,"PE","Q130492440"],["Poroy",-13.497,-72.043,1502,"PE","Q20619475"],["Quellouno",-12.636,-72.557,1496,"PE","Q130312712"],["San Pedro de Coris",-12.578,-74.412,1460,"PE","Q131176072"],["Huando",-12.564,-74.947,1447,"PE","Q131176078"],["Acopía",-14.057,-71.493,1440,"PE","Q13189157"],["Zurite",-13.456,-72.255,1437,"PE","Q130492420"],["El Descanso",-14.534,-71.307,1434,"PE","Q130492423"],["Colquemarca",-14.284,-72.04,1427,"PE","Q131399801"],["Canayre",-12.282,-74.023,1413,"PE","Q130369710"],["Livitaca",-14.313,-71.689,1407,"PE","Q130492427"],["Huamanguilla",-13.011,-74.173,1400,"PE","Q130369713"],["Ajoyani",-14.23,-70.224,1381,"PE","Q130541384"],["San Salvador",-13.492,-71.778,1372,"PE","Q20620856"],["Tawantinsuyo",-12.792,-73.622,1362,"PE","Q130492439"],["San Pedro de Hualla",-13.85,-73.951,1360,"PE","Q62779711"],["Sarhua",-13.667,-74.317,1322,"PE","Q13190743"],["Lucanas",-14.622,-74.233,1297,"PE","Q130369735"],["Acoria",-12.643,-74.862,1280,"PE","Q130312758"],["San José",-14.68,-70.16,1258,"PE","Q130541379"],["Huaccana",-13.388,-73.69,1246,"PE","Q131187855"],["Chuschi",-13.585,-74.352,1245,"PE","Q3655811"],["Accha",-13.971,-71.832,1217,"PE","Q96972647"],["Challabamba",-13.216,-71.648,1205,"PE","Q98550153"],["Villa Virgen",-13.002,-73.513,1155,"PE","Q130492435"],["Mara",-14.086,-72.102,1146,"PE","Q131187857"],["San Cristóbal",-14.743,-74.222,1125,"PE","Q130369740"],["Chirumpiari",-12.808,-73.604,1122,"PE","Q130492437"],["Progreso",-14.073,-72.476,1113,"PE","Q131187866"],["Julcamarca",-13.014,-74.445,1099,"PE","Q131451558"],["La Esmeralda",-12.683,-74.587,1063,"PE","Q131176066"],["Huachocolpa",-13.032,-74.947,1053,Line truncated
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Pucusana",-12.482,-76.798,14891,"PE","Q7258273"],["San Agustín",-11.972,-75.256,14310,"PE","Q49278126"],["Chilca",-12.519,-76.739,13920,"PE","Q16890238"],["Oxapampa",-10.58,-75.4,12826,"PE","Q1014523"],["Supe Puerto",-10.805,-77.743,12786,"PE","Q3504032"],["Supe",-10.797,-77.713,12492,"PE","Q33499647"],["San Jerónimo de Tunán",-11.949,-75.283,11601,"PE","Q33479561"],["Pativilca",-10.696,-77.774,11467,"PE","Q3368805"],["Yanahuanca",-10.491,-76.514,11333,"PE","Q3344095"],["Quilmaná",-12.95,-76.384,10491,"PE","Q27194717"],["Santa Eulalia",-11.897,-76.663,9941,"PE","Q33481268"],["Chupaca",-12.062,-75.287,9877,"PE","Q3344173"],["Santa Rosa de Sacco",-11.567,-75.956,8956,"PE","Q130483348"],["Yauyos",-11.781,-75.499,8637,"PE","Q130483296"],["Caleta de Carquín",-11.092,-77.627,8049,"PE","Q34789278"],["Ambo",-10.131,-76.205,7444,"PE","Q3317423"],["Huayllay",-11.001,-76.373,6736,"PE","Q13191218"],["Huamancaca Chico",-12.081,-75.242,6581,"PE","Q130483323"],["Aucallama",-11.562,-77.173,6504,"PE","Q137716780"],["Huayucachi",-12.138,-75.223,6477,"PE","Q49277584"],["Huariaca",-10.442,-76.19,6175,"PE","Q137708733"],["Saño",-11.957,-75.257,5491,"PE","Q130483293"],["Ricardo Palma",-11.924,-76.66,5358,"PE","Q33475284"],["Hualhuas",-11.972,-75.251,5251,"PE","Q130483291"],["Sayán",-11.133,-77.195,4422,"PE","Q33481992"],["Chongos Bajo",-12.134,-75.268,3764,"PE","Q131394414"],["San Mateo, Huarochirí Province",-11.761,-76.309,3669,"PE","Q27783597"],["Chiquián",-10.151,-77.156,3641,"PE","Q1074644"],["Matahuasi",-11.894,-75.344,3268,"PE","Q130483339"],["Ahuac",-12.086,-75.321,3137,"PE","Q27194427"],["Sausa",-11.794,-75.484,3060,"PE","Q131394441"],["Yauli",-11.666,-76.087,2993,"PE","Q130483360"],["Quilcas",-11.937,-75.259,2989,"PE","Q130483295"],["Palca",-11.346,-75.569,2724,"PE","Q115164510"],["Tres de Diciembre",-12.11,-75.246,2665,"PE","Q130483326"],["El Carmen",-13.5,-76.058,2639,"PE","Q28314364"],["Santa Ana de Tusi",-10.472,-76.354,2632,"PE","Q137708743"],["Lunahuaná",-12.963,-76.142,2617,"PE","Q1877336"],["Viques",-12.16,-75.232,2589,"PE","Q130483294"],["Tate de La Capilla",-14.156,-75.708,2544,"PE","Q33505671"],["San Pedro de Cajas",-11.251,-75.861,2495,"PE","Q25400021"],["Pucucho",-11.822,-75.392,2459,"PE","Q130483300"],["Ninacaca",-10.856,-76.113,2400,"PE","Q55129680"],["Muquiyauyo",-11.814,-75.454,2311,"PE","Q131394979"],["Pucará",-12.172,-75.145,2220,"PE","Q131395032"],["San Lorenzo",-11.847,-75.382,2165,"PE","Q130483315"],["San Rafael",-10.338,-76.182,2056,"PE","Q137700490"],["Santo Domingo del Prado",-11.898,-75.318,2023,"PE","Q130483338"],["Huácar",-10.16,-76.237,2019,"PE","Q137700482"],["Ocros",-10.404,-77.396,2000,"PE","Q3317427"],["Leticia",-11.377,-75.752,1999,"PE","Q119109056"],["Tomayquichua",-10.078,-76.213,1950,"PE","Q26980595"],["Churin",-10.817,-76.883,1834,"PE","Q5118292"],["Iscozacín",-10.184,-75.15,1814,"PE","Q137708750"],["Cauri",-10.142,-76.626,1704,"PE","Q113368834"],["Canta",-11.467,-76.624,1646,"PE","Q3322638"],["Tapuc",-10.455,-76.462,1644,"PE","Q137708744"],["Sincos",-11.892,-75.387,1454,"PE","Q131394982"],["Castrovirreyna",-13.278,-75.316,1449,"PE","Q3348254"],["Vicco",-10.841,-76.236,1400,"PE","Q42894269"],["Río Grande",-14.52,-75.201,1394,"PE","Q33476950"],["San Miguel",-12.015,-75.346,1387,"PE","Q130483331"],["Vilcabamba",-10.479,-76.447,1364,"PE","Q137708746"],["Margos",-10.005,-76.523,1324,"PE","Q137700452"],["Huancaní",-11.864,-75.414,1321,"PE","Q131395005"],["Goyllarisquizga",-10.475,-76.408,1320,"PE","Q137708737"],["Huáchac",-12.02,-75.341,1311,"PE","Q130483322"],["Pazos",-12.259,-75.07,1301,"PE","Q131176134"],["Huacrapuquio",-12.174,-75.219,1297,"PE","Q130483290"],["Huamalí",-11.807,-75.424,1290,"PE","Q130483306"],["Cajatambo",-10.473,-76.994,1275,"PE","Q2638247"],["Chontabamba",-10.603,-75.439,1221,"PE","Q137708736"],["Huachón",-10.636,-75.951,1221,"PE","Q137708738"],["Paccha",-11.473,-75.96,1213,"PE","Q130312656"],["Ticlacayán",-10.534,-76.164,1212,"PE","Q137708742"],["Aco",-11.958,-75.368,1209,"PE","Q130483333"],["Apata",-11.855,-75.354,1206,"PE","Q131394386"],["Asia",-12.779,-76.557,1198,"PE","Q126021564"],["Santa Rosa",-11.877,-75.295,1198,"PE","Q13190718"],["Pozuzo",-10.067,-75.533,1194,"PE","Q278871"],["San Antonio de Rancas",-10.69,-76.317,1193,"PE","Q137708741"],["Marca",-10.089,-77.474,1191,"PE","Q13190032"],["Huay-Huay",-11.723,-75.905,1130,"PE","Q130483346"],["Quichuay",-11.89,-75.286,1128,"PE","Q13190448"],["San Pedro de Pillao",-10.439,-76.495,1099,"PE","Q137708749"],["Jarpa",-12.126,-75.436,1073,"PE","Q131394496"],["Muqui",-11.833,-75.434,1013,"PE","Q130483302"],["Huancabamba",-10.426,-75.524,1012,"PE","Q137708739"],["Huaricolca",-11.512,-75.653,1011,"PE","Q115239543"],["Ataura",-11.803,-75.438,1006,"PE","Q131394405"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Flying Fish Cove",-10.422,105.678,1599,"AU","Q30980"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Wadeye",-14.233,129.517,2280,"AU","Q18028"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Darwin",-12.462,130.842,6464,"AU","Q5225948"],["Katherine",-14.467,132.267,5980,"AU","Q17980"],["Howard Springs",-12.492,131.053,5132,"AU","Q5920924"],["Karama",-12.401,130.917,4944,"AU","Q6368250"],["Leanyer",-12.379,130.898,4597,"AU","Q6509883"],["Humpty Doo",-12.575,131.102,4380,"AU","Q17966"],["Rosebery",-12.505,130.992,4218,"AU","Q7368077"],["Stuart Park",-12.449,130.842,4149,"AU","Q7626934"],["Zuccoli",-12.512,131.003,4131,"AU","Q30694176"],["Larrakeyah",-12.459,130.822,3943,"AU","Q6489783"],["Nightcliff",-12.383,130.849,3884,"AU","Q7033778"],["Durack",-12.475,130.973,3730,"AU","Q5316121"],["Muirhead",-12.358,130.896,3689,"AU","Q6933244"],["Gray",-12.492,130.979,3288,"AU","Q5598128"],["Rapid Creek",-12.381,130.862,3282,"AU","Q7294152"],["Woodroffe",-12.499,130.981,3233,"AU","Q8033152"],["Katherine East",-14.466,132.285,3114,"AU","Q6376354"],["Bakewell",-12.499,130.993,3091,"AU","Q4849343"],["Moulden",-12.51,130.976,3053,"AU","Q6918971"],["Coconut Grove",-12.399,130.852,3050,"AU","Q5139826"],["Malak",-12.393,130.904,3013,"AU","Q6741113"],["Driver",-12.485,130.973,2884,"AU","Q5307982"],["Fannie Bay",-12.425,130.836,2875,"AU","Q5433948"],["Parap",-12.421,130.844,2819,"AU","Q7135606"],["Gunn",-12.489,130.992,2664,"AU","Q5618901"],["Millner",-12.391,130.863,2576,"AU","Q6859897"],["Tiwi",-12.363,130.88,2562,"AU","Q7810475"],["Maningrida",-12.05,134.217,2518,"AU","Q17988"],["Wulagi",-12.384,130.893,2510,"AU","Q8039143"],["Bellamack",-12.521,130.98,2458,"AU","Q4883440"],["Johnston",-12.486,131.01,2386,"AU","Q6268601"],["Anula",-12.393,130.89,2385,"AU","Q4777772"],["Lyons",-12.379,130.888,2302,"AU","Q6709756"],["Wagaman",-12.383,130.885,2163,"AU","Q7959471"],["Alawa",-12.38,130.873,2127,"AU","Q4708892"],["Moil",-12.389,130.879,2000,"AU","Q6894595"],["Nakara",-12.369,130.878,1978,"AU","Q6960299"],["Holtze",-12.461,130.984,1940,"AU","Q5884778"],["Wanguri",-12.373,130.888,1876,"AU","Q7967917"],["Jingili",-12.387,130.875,1841,"AU","Q6202323"],["Virginia",-12.548,131.017,1836,"AU","Q7934081"],["Ludmilla",-12.43,130.852,1743,"AU","Q6698920"],["Herbert",-12.542,131.157,1730,"AU","Q5733379"],["Bayview",-12.44,130.86,1702,"AU","Q4874996"],["Girraween",-12.524,131.092,1668,"AU","Q5564818"],["Farrar",-12.478,130.991,1650,"AU","Q5436240"],["Wurrumiyanga",-11.759,130.635,1563,"AU","Q18034"],["Marrara",-12.398,130.88,1549,"AU","Q6772795"],["Katherine South",-14.469,132.259,1507,"AU","Q18165876"],["Cossack",-14.447,132.176,1293,"AU","Q31203555"],["Brinkin",-12.37,130.867,1268,"AU","Q4968417"],["Milingimbi",-12.103,134.921,1225,"AU","Q1934778"],["Berrimah",-12.434,130.923,1199,"AU","Q4894715"],["Gunbalanya",-12.317,133.05,1177,"AU","Q18002"],["Ngukurr",-14.73,134.731,1149,"AU","Q21074864"],["Jabiru",-12.667,132.833,1081,"AU","Q17969"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Nhulunbuy",-12.182,136.782,3350,"AU","Q17996"],["Galiwinku",-12.024,135.566,2206,"AU","Q30400333"],["East Arnhem",-12.635,135.84,1194,"AU","Q31230672"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Weipa",-12.643,141.864,4097,"AU","Q1026439"],["Thursday Island",-10.579,142.22,2805,"AU","Q20669958"],["Rocky Point",-12.619,141.886,2214,"AU","Q31202450"],["Aurukun",-13.35,141.717,1269,"AU","Q1879882"],["Bamaga",-10.883,142.383,1186,"AU","Q3604590"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Sola",-13.88,167.55,1065,"VU","Q1423143"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Manyinga",-13.419,24.331,12760,"ZM","Q123174109"],["Lukulu",-14.408,23.267,10575,"ZM","Q1629398"],["Zambezi",-13.55,23.117,10299,"ZM","Q145470"],["Kabompo",-13.583,24.231,9865,"ZM","Q1001226"],["Chavuma",-13.075,22.688,4652,"ZM","Q1022152"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Mpongwe",-13.513,28.155,14979,"ZM","Q996118"],["Lubwe",-11.114,29.647,12643,"ZM","Q132861372"],["Luwingu",-10.262,29.927,10766,"ZM","Q1878272"],["Kasempa",-13.461,25.839,10700,"ZM","Q1734917"],["Mufumbwe",-13.139,25.006,9576,"ZM","Q996108"],["Chibombo",-14.664,28.078,4310,"ZM","Q1071771"],["Chilubi",-11.15,29.917,4295,"ZM","Q1022154"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Ntcheu",-14.817,34.633,14642,"MW","Q1022517"],["Monkey Bay",-14.083,34.917,14591,"MW","Q1944901"],["Nyoni, Tanzania",-11.084,34.919,12899,"TZ","Q65331304"],["Litembo",-10.967,34.85,12432,"TZ","Q6647539"],["Mungwi",-10.167,31.367,7831,"ZM","Q1952800"],["Chama",-11.208,33.158,7029,"ZM","Q1060403"],["Nyimba",-14.443,31.087,6821,"ZM","Q162131"],["Chadiza",-14.064,32.435,5670,"ZM","Q1058666"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Kigonsera",-10.8,35.067,13323,"TZ","Q6405967"],["Lilambo",-10.683,35.549,12642,"TZ","Q6547546"],["Maposeni",-10.583,35.4,4670,"TZ","Q13123938"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Tsimbeo",-12.2,44.467,12472,"KM","Q1885248"],["Ongoujou",-12.312,44.508,11736,"KM","Q3120986"],["Adda-Douéni",-12.3,44.5,11165,"KM","Q2824136"],["Sima",-12.199,44.274,11000,"KM","Q3110104"],["Ouani",-12.135,44.428,10000,"KM","Q3143004"],["Bazimini",-12.179,44.449,9205,"KM","Q548071"],["Iconi",-11.745,43.233,8817,"KM","Q3120964"],["Ivémbéni-Bandasamoulini",-11.478,43.318,8786,"KM","Q3156386"],["Moya",-12.3,44.433,8475,"KM","Q786648"],["Mkazi",-11.732,43.267,8438,"KM","Q939788"],["Dindri",-12.214,44.453,8037,"KM","Q3028292"],["Mbéni",-11.5,43.383,7725,"KM","Q3121010"],["Mitsamiouli",-11.382,43.3,7235,"KM","Q3109029"],["Koni-Djodjo",-12.23,44.482,7232,"KM","Q3119166"],["Barakani",-12.136,44.432,6854,"KM","Q2883788"],["Chandra",-12.2,44.467,6354,"KM","Q2956006"],["Chezani",-11.428,43.388,6250,"KM","Q2963196"],["Ngandzalé",-12.27,44.51,6097,"KM","Q3339276"],["Foumbouni",-11.867,43.483,5331,"KM","Q3043023"],["Mbambao Mtsanga",-12.31,44.44,5067,"KM","Q3303484"],["Mitsoudjé",-11.817,43.267,5004,"KM","Q3317188"],["Dembéni",-11.877,43.406,4723,"KM","Q3022078"],["Moidja",-11.468,43.287,4441,"KM","Q17076248"],["Hahaya-Aéroport",-11.537,43.271,4005,"KM","Q3125727"],["Hajoho",-12.117,44.483,3873,"KM","Q3125818"],["Ntsaweni",-11.466,43.263,3846,"KM","Q3345984"],["Bandracouni",-11.86,43.404,3309,"KM","Q2878564"],["Djoièzi",-12.297,43.773,3271,"KM","Q3033049"],["Djomani-Mchenazi",-11.43,43.259,3029,"KM","Q3033054"],["Daji",-12.333,44.483,3012,"KM","Q14525823"],["Itsinkoundi",-11.584,43.376,2859,"KM","Q2399910"],["Boungoueni",-12.2,44.3,2775,"KM","Q2922202"],["Bandra Lamahalé",-12.147,44.499,2771,"KM","Q2882377"],["Heroumbili",-11.544,43.38,2745,"KM","Q3134319"],["Chironkamba",-12.191,44.352,2692,"KM","Q2963954"],["Dzidri-I",-12.22,44.45,2675,"KM","Q3042208"],["Chouani",-11.819,43.284,2615,"KM","Q2964567"],["Singani",-11.847,43.328,2552,"KM","Q3484935"],["Bangoi-Hamtsaha-Madjeoué",-11.717,43.368,2514,"KM","Q2882482"],["Djoumoichongo-Nyoumbadjou",-11.807,43.286,2478,"KM","Q3033071"],["Chiroroni",-12.377,44.501,2395,"KM","Q2963964"],["Hantsindzi",-11.429,43.402,2290,"KM","Q507363"],["Idjinkoundzi",-11.711,43.414,2241,"KM","Q3147877"],["Akibani",-12.193,44.362,2170,"KM","Q2829022"],["Boeni ya Bambao",-11.631,43.352,2077,"KM","Q601473"],["Batsa",-11.628,43.26,2075,"KM","Q2891632"],["Bandajou",-12.183,44.283,2044,"KM","Q2882134"],["Hamchako",-12.371,44.513,2036,"KM","Q2384497"],["Douniani",-11.421,43.289,2031,"KM","Q3038137"],["Dzahadjou",-11.848,43.34,2002,"KM","Q3042177"],["Bandamadji-Ladomba",-11.784,43.444,1995,"KM","Q2882144"],["Dziani",-12.183,44.483,1974,"KM","Q3042198"],["Harembo",-12.15,44.5,1911,"KM","Q3127418"],["Héléindjé-Salimani-Zounda",-11.437,43.305,1757,"KM","Q3144897"],["Chindini",-11.921,43.481,1680,"KM","Q2963751"],["Hachimpenda",-12.2,44.256,1657,"KM","Q3125454"],["Dimadjou",-11.474,43.364,1655,"KM","Q3028026"],["Dzahani",-11.657,43.276,1587,"KM","Q3042180"],["Itsandzéni",-11.473,43.384,1578,"KM","Q3155989"],["Bambadjani",-11.479,43.377,1549,"KM","Q923118"],["Hantsambou",-11.66,43.256,1542,"KM","Q2385256"],["Bahani",-11.64,43.284,1454,"KM","Q2879261"],["Bandrani",-12.073,44.471,1377,"KM","Q4854696"],["Dzahadjou Lamzandé",-11.853,43.349,1349,"KM","Q3042179"],["Chamlé",-11.445,43.267,1345,"KM","Q2948523"],["Antsahé",-12.356,44.523,1328,"KM","Q2857608"],["Bouni",-11.492,43.398,1261,"KM","Q2922203"],["Assimpao",-12.233,44.32,1252,"KM","Q2867178"],["Hoani",-12.25,43.667,1245,"KM","Q3138871"],["Bandar Salama",-12.29,43.759,1232,"KM","Q2882147"],["Chitrouni",-12.186,44.336,1218,"KM","Q2964025"],["Bambani",-12.233,44.32,1214,"KM","Q4853332"],["Hadjambou",-11.736,43.233,1202,"KM","Q3125556"],["Founga-Anihani",-11.411,43.295,1112,"KM","Q3079943"],["Dar-Salama",-12.251,44.388,1089,"KM","Q3015900"],["Ifoundihé Chamboini",-11.9,43.412,1085,"KM","Q3148105"],["Bada la Djandza",-12.299,44.497,1040,"KM","Q2878567"],["Bangoi-Mafousa Nkoa",-11.717,43.368,1015,"KM","Q2882481"],["Dimadjou-Mdé",-11.476,43.374,1010,"KM","Q3028029"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Handrema",-12.681,45.1,1829,"FR","Q5647547"],["Mtsangamboua",-12.69,45.11,1304,"FR","Q6930490"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Jamestown",-15.925,-5.718,1516,"SH","Q30970"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Bora Bora",-16.498,-151.736,10605,"FR","Q183113"],["Vaitape",-16.506,-151.749,4927,"FR","Q3498189"],["Opoa",-16.836,-151.365,1205,"FR","Q39483295"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Neiafu",-18.651,-173.983,6000,"TO","Q1025393"],["Pangai",-19.803,-174.349,2000,"TO","Q1027037"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Trancoso",-16.593,-39.103,11006,"BR","Q938536"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Vera Cruz de Minas",-19.698,-44.05,4208,"BR","Q10389767"],["Lapinha",-19.571,-43.953,3921,"BR","Q61767236"],["Cocais",-19.865,-43.457,2803,"BR","Q62128689"],["Fidalgo (Pedro Leopoldo)",-19.534,-43.966,2595,"BR","Q61767099"],["Senador Mourão",-17.808,-43.419,2390,"BR","Q10370003"],["Brejaubinha",-18.776,-42.216,2328,"BR","Q18464151"],["Boa Vista da Serra",-19.929,-44.402,2305,"BR","Q61793444"],["Desembargador Otoni",-17.695,-43.333,2102,"BR","Q10265519"],["Hematita",-19.502,-43.009,1992,"BR","Q10294609"],["São João da Chapada",-18.088,-43.741,1581,"BR","Q10375812"],["Tabajara",-19.586,-41.769,1558,"BR","Q10377696"],["São Gonçalo do Rio das Pedras",-18.415,-43.495,1479,"BR","Q10267312"],["Planalto de Minas",-17.651,-43.322,1318,"BR","Q10350224"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Cana-Brava",-17.393,-45.834,3107,"BR","Q62032011"],["Luislândia do Oeste",-17.987,-45.607,3017,"BR","Q62030713"],["Canoeiros",-18.041,-45.521,1662,"BR","Q62032111"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Porto Esperidião",-15.853,-58.46,10204,"BR","Q2012385"],["Paradero",-18.992,-57.791,2022,"BO","Q1149273"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Zudáñez",-19.119,-64.701,13694,"BO","Q228153"],["Villa Vaca Guzmán",-19.894,-63.75,13282,"BO","Q842347"],["Pampagrande",-18.097,-64.116,10500,"BO","Q931053"],["Charagua",-19.792,-63.201,6780,"BO","Q1712242"],["San Javier",-16.275,-62.507,6048,"BO","Q281844"],["Rivas Palacio Colony",-18.171,-63.029,5728,"BO","Q134127576"],["Concepción",-16.132,-62.026,5586,"BO","Q751077"],["San Miguel de Velasco",-16.699,-60.968,4484,"BO","Q473144"],["Puerto Rico",-18.008,-63.393,4219,"BO","Q2117446"],["Nueva Esperanza Colony",-17.457,-60.57,3925,"BO","Q141708152"],["Mairana",-18.119,-63.956,3884,"BO","Q1003511"],["Entre Ríos",-17.197,-64.535,3796,"BO","Q1345127"],["Kansas Colony",-19.859,-63.059,3750,"BO","Q141635808"],["Pinondi",-19.771,-63.014,3139,"BO","Q141698923"],["Campanero",-17.734,-62.951,3020,"BO","Q1030202"],["Swift Current",-18.067,-63.043,2925,"BO","Q134127632"],["Durango Colony",-19.823,-62.848,2917,"BO","Q141706678"],["Villa Serrano",-19.123,-64.324,2877,"BO","Q842355"],["Valle Hermoso (Schöntal) Colony",-17.52,-61.111,2569,"BO","Q141708189"],["Belize Colony",-17.532,-62.113,2502,"BO","Q141708284"],["California Colony",-17.402,-61.448,2462,"BO","Q141708294"],["Tarabuco",-19.183,-64.915,2442,"BO","Q1982115"],["Abapó",-18.906,-63.399,2386,"BO","Q305531"],["Canadiense II Colony",-17.888,-62.577,2300,"BO","Q31838708"],["Valle Nuevo Colony",-17.817,-62.338,2262,"BO","Q56293233"],["El Dorado (Gnadenhof) Colony",-18.395,-63.024,2247,"BO","Q141680563"],["Manitoba Colony",-17.398,-61.974,2208,"BO","Q16888523"],["Santa Rita Colony",-17.948,-62.894,2194,"BO","Q141680520"],["Nuevo Mexico Colony",-17.576,-61,2150,"BO","Q141708170"],["Valle Esperanza",-17.178,-62.513,2121,"BO","Q141618235"],["Valle Esperanza Colony",-17.178,-62.513,2121,"BO","Q141711326"],["Santa Anita",-16.115,-64.828,2100,"BO","Q111770581"],["Pucará",-18.715,-64.184,2076,"BO","Q1563343"],["San Rafael de Velasco",-16.787,-60.674,2057,"BO","Q746773"],["La Honda Colony",-17.738,-60.29,1990,"BO","Q141707819"],["Berlin Colony",-17.562,-60.431,1943,"BO","Q141707821"],["Chihuahua Colony",-17.21,-62.117,1811,"BO","Q141618380"],["La Milagrosa Colony",-18.083,-62.014,1713,"BO","Q141710895"],["Tajibo (Nordenheim) Colony",-16.18,-61.341,1431,"BO","Q141706918"],["Valle de Merced",-16.325,-61.548,1396,"BO","Q141621054"],["El Tinto Colony",-17.774,-61.544,1332,"BO","Q141708249"],["Del Norte Colony",-17.112,-62.476,1290,"BO","Q141619105"],["Valle Roca Colony",-16.175,-61.59,1280,"BO","Q141706826"],["Yanahigua Colony",-17.003,-62.356,1262,"BO","Q141711319"],["Casa Grande",-19.708,-62.897,1229,"BO","Q141635833"],["Porvenir Oriente (Nordenhof) Colony",-16.214,-61.478,1197,"BO","Q141706910"],["Primavera Colony",-17.817,-61.247,1085,"BO","Q141708226"],["Oriente Colony",-17.826,-62.208,1063,"BO","Q105211245"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["San Benito",-17.523,-65.894,13562,"BO","Q1416961"],["Chulumani",-16.41,-67.525,13204,"BO","Q1766619"],["Yunguyo",-16.244,-69.093,12625,"PE","Q2306609"],["Colquencha",-16.934,-68.249,12490,"BO","Q491521"],["Torotoro",-18.134,-65.763,10535,"BO","Q1001951"],["Achocalla",-16.568,-68.171,10369,"BO","Q340576"],["Achacachi",-16.044,-68.685,8857,"BO","Q1553175"],["Aiquile",-18.167,-65.167,7381,"BO","Q1617416"],["Colquiri",-17.397,-67.131,6610,"BO","Q1014448"],["Lahuachaca",-17.377,-67.675,5874,"BO","Q1800652"],["Uncía",-18.468,-66.565,5709,"BO","Q1642052"],["Betanzos",-19.553,-65.454,5021,"BO","Q830983"],["Ironcollo",-17.358,-66.284,4778,"BO","Q916733"],["Yucumo",-15.146,-67.034,4693,"BO","Q1646153"],["Santiago de Machaca",-17.067,-69.193,4593,"BO","Q1002013"],["Villa Porvenir",-16.826,-65.347,4258,"BO","Q21044734"],["Santuario de Quillacas",-19.233,-66.942,3983,"BO","Q2223784"],["Guanay",-15.498,-67.879,3890,"BO","Q959746"],["Sica Sica",-17.333,-67.739,3831,"BO","Q494377"],["Colomi",-17.338,-65.868,3699,"BO","Q990698"],["Arani",-17.573,-65.768,3512,"BO","Q1026281"],["Huara",-19.967,-69.767,3510,"CL","Q13081"],["Tarata",-17.611,-66.023,3323,"BO","Q1016289"],["Irpa Irpa",-17.717,-66.283,2721,"BO","Q1673170"],["Tipuani",-15.561,-67.983,2563,"BO","Q1026260"],["Huacullani",-16.63,-69.322,2466,"PE","Q130541392"],["Moho",-15.361,-69.5,2365,"PE","Q934450"],["Coroico",-16.189,-67.728,2319,"BO","Q1026263"],["Sorata",-15.774,-68.649,2217,"BO","Q1428069"],["Tolata",-17.534,-65.963,2207,"BO","Q590883"],["Ocurí",-18.843,-65.796,2200,"BO","Q2014005"],["German Busch",-16.994,-65.255,2000,"BO","Q130482643"],["Senda III",-16.995,-65.182,1980,"BO","Q106944598"],["Collana",-16.904,-68.284,1936,"BO","Q1108876"],["Coro Coro",-17.177,-68.454,1884,"BO","Q1353228"],["Irupana",-16.466,-67.455,1882,"BO","Q1014423"],["Colquechaca",-18.7,-66.004,1816,"BO","Q338235"],["Taraco",-15.298,-69.978,1804,"PE","Q130541372"],["Santa Rosa Eñe",-17.078,-65.223,1800,"BO","Q116908135"],["Amarete",-15.239,-68.984,1741,"BO","Q454982"],["Taquile Island",-15.777,-69.684,1700,"PE","Q1761551"],["Colchane",-19.275,-68.64,1649,"CL","Q3839"],["Totora",-17.736,-65.191,1597,"BO","Q2038566"],["Anzaldo",-17.833,-65.917,1576,"BO","Q614151"],["Apillapampa",-17.861,-66.257,1523,"BO","Q618627"],["Senda F",-16.874,-65.132,1511,"BO","Q106939562"],["Zepita",-16.497,-69.103,1503,"PE","Q8069335"],["Teoponte",-15.496,-67.819,1421,"BO","Q1026231"],["Santiváñez",-17.55,-66.25,1400,"BO","Q990723"],["Cojata",-15.015,-69.365,1378,"PE","Q130541369"],["Huatasani",-15.06,-69.802,1358,"PE","Q130541370"],["Camiña",-19.3,-69.417,1250,"CL","Q3731"],["Pisacoma",-16.908,-69.371,1225,"PE","Q130541391"],["Anapia",-16.314,-68.853,1207,"PE","Q130541422"],["Tacachi",-17.641,-65.806,1198,"BO","Q1516800"],["Palca",-16.561,-67.953,1180,"BO","Q1001975"],["Pilcuyo",-16.111,-69.554,1155,"PE","Q130541395"],["Puerto Acosta",-15.533,-69.252,1123,"BO","Q1866555"],["San Pedro de Buena Vista",-18.271,-65.981,1100,"BO","Q1001985"],["Paractito",-17.012,-65.456,1030,"BO","Q104878856"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Camaná",-16.624,-72.711,13304,"PE","Q1028011"],["Characato",-16.469,-71.484,12411,"PE","Q131412532"],["Tiabaya",-16.45,-71.591,10870,"PE","Q131412534"],["La Pampa",-16.614,-72.699,9194,"PE","Q17075166"],["Samegua",-17.182,-70.9,7950,"PE","Q137709489"],["Santa Rita de Siguas",-16.494,-72.094,6119,"PE","Q130598977"],["Cocachacra",-17.089,-71.759,5477,"PE","Q5775805"],["Islay",-17.002,-72.105,5132,"PE","Q27995444"],["Chivay",-15.633,-71.6,5000,"PE","Q2351933"],["Caravelí",-15.773,-73.366,5000,"PE","Q968765"],["San Gregorio",-16.573,-72.716,4532,"PE","Q130598988"],["Pueblo Nuevo",-17.612,-71.34,4437,"PE","Q137709501"],["Sabandia",-16.457,-71.495,3771,"PE","Q130598979"],["El Algarrobal",-17.617,-71.317,3694,"PE","Q5350720"],["Omate",-16.674,-70.97,3158,"PE","Q3322634"],["Estación de Pucará",-15.034,-70.338,3028,"PE","Q130541377"],["Bella Unión",-15.45,-74.658,2882,"PE","Q130598995"],["Aplao",-16.083,-72.5,2860,"PE","Q2423691"],["Mañazo",-15.801,-70.343,2658,"PE","Q130541434"],["La Curva",-17.144,-71.821,2536,"PE","Q130598984"],["Deustua",-15.642,-70.35,2231,"PE","Q130541439"],["Laraqueri",-16.15,-70.064,2202,"PE","Q130541429"],["Pucará",-15.042,-70.368,1832,"PE","Q11286696"],["Cotahuasi",-15.213,-72.888,1529,"PE","Q2638258"],["Arapa",-15.139,-70.11,1502,"PE","Q130541374"],["Yauca",-15.662,-74.527,1468,"PE","Q129209417"],["Pampacolca",-15.714,-72.574,1438,"PE","Q131412525"],["Lomas",-15.57,-74.851,1402,"PE","Q130598993"],["Jaquí",-15.479,-74.444,1400,"PE","Q130598997"],["Ocoña",-16.432,-73.105,1365,"PE","Q130598989"],["Huancarqui",-16.096,-72.472,1256,"PE","Q130599002"],["Uchumayo",-16.425,-71.673,1244,"PE","Q27500860"],["Vítor",-16.466,-71.935,1126,"PE","Q130598982"],["Viraco",-15.658,-72.525,1102,"PE","Q131412527"],["Cabanilla",-15.62,-70.346,1098,"PE","Q27831775"],["San José",-16.62,-72.736,1090,"PE","Q130598986"],["Chumpi",-15.095,-73.748,1080,"PE","Q131324815"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Outapi",-17.503,14.986,13664,"NA","Q1758215"],["Opuwo",-18.061,13.84,12331,"NA","Q1024089"],["Ruacana",-17.433,14.35,5939,"NA","Q1013946"],["Kamanjab",-19.629,14.845,3915,"NA","Q1699191"],["Eheke",-17.833,14.867,1115,"NA","Q5348569"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Broome",-17.962,122.236,14660,"AU","Q606294"],["Cable Beach",-17.933,122.214,5730,"AU","Q55819367"],["Djugun",-17.941,122.231,3291,"AU","Q31436896"],["Derby",-17.311,123.635,3222,"AU","Q1018373"],["Bilingurr",-17.925,122.234,1540,"AU","Q31440680"],["St George Ranges",-18.795,124.166,1240,"AU","Q31431747"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Kununurra",-15.774,128.739,5494,"AU","Q1110973"],["Halls Creek",-18.23,127.67,1605,"AU","Q992686"],["Fitzroy Crossing",-18.178,125.591,1297,"AU","Q1421393"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Tennant Creek",-19.647,134.19,3080,"AU","Q18015"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Lumina",-16.225,137.123,2558,"","Q104434355"],["Doomadgee",-17.942,138.828,1405,"AU","Q2022784"],["Wellesley Islands",-16.573,139.349,1136,"AU","Q1756163"],["Gununa",-16.666,139.181,1022,"AU","Q13365146"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Normanton",-17.676,141.084,1391,"AU","Q1021888"],["Kowanyama",-15.477,141.744,1079,"AU","Q6435007"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Mareeba",-16.983,145.417,11825,"AU","Q1894520"],["Edmonton",-17.017,145.75,11409,"AU","Q5338982"],["Kelso",-19.397,146.721,10599,"AU","Q6386527"],["Redlynch",-16.883,145.7,10571,"AU","Q21905016"],["Mount Louisa",-19.283,146.733,9227,"AU","Q6921896"],["Mount Sheridan",-16.984,145.729,8678,"AU","Q30749753"],["Ayr",-19.583,147.4,8603,"AU","Q2875020"],["Annandale",-19.318,146.775,8574,"AU","Q4767920"],["Bentley Park",-17.004,145.738,8360,"AU","Q4890491"],["Douglas",-19.317,146.75,7780,"AU","Q5301158"],["Atherton",-17.266,145.474,7724,"AU","Q755507"],["Mooroobool",-16.935,145.731,7222,"AU","Q6908439"],["Innisfail",-17.524,146.029,7173,"AU","Q690795"],["Burdell",-19.246,146.7,7171,"AU","Q30979764"],["Gordonvale",-17.097,145.779,6944,"AU","Q5586063"],["Smithfield",-16.831,145.691,6664,"AU","Q7545487"],["Bushland Beach",-19.189,146.681,6641,"AU","Q5001524"],["Trinity Beach",-16.783,145.7,6594,"AU","Q7842589"],["Manoora",-16.92,145.74,6175,"AU","Q19875371"],["Kewarra Beach",-16.788,145.676,6133,"AU","Q14935459"],["Cranbrook",-19.309,146.751,5908,"AU","Q5181943"],["Condon",-19.332,146.724,5894,"AU","Q5159319"],["Brinsmead",-16.903,145.711,5537,"AU","Q18754859"],["Mount Low",-19.225,146.681,5488,"AU","Q30890908"],["Manunda",-16.919,145.748,5390,"AU","Q31049999"],["Cairns North",-16.91,145.762,5334,"AU","Q24189752"],["Woree",-16.95,145.75,5127,"AU","Q8034505"],["North Ward",-19.25,146.817,5073,"AU","Q7057186"],["White Rock",-16.979,145.757,4918,"AU","Q31202461"],["Aitkenvale",-19.283,146.8,4797,"AU","Q4699323"],["Rasmussen",-19.35,146.716,4669,"AU","Q7295132"],["Wulguru",-19.333,146.817,4570,"AU","Q8039200"],["Idalia",-19.3,146.817,4563,"AU","Q5987581"],["Ingham",-18.65,146.167,4455,"AU","Q976153"],["Whitfield",-16.902,145.728,4275,"AU","Q24190484"],["Deeragun",-19.25,146.667,4273,"AU","Q5250870"],["Bayview Heights",-16.963,145.73,4238,"AU","Q4875008"],["Earlville",-16.949,145.733,4200,"AU","Q30992079"],["Edge Hill",-16.902,145.743,4088,"AU","Q24190459"],["West End",-19.265,146.793,4064,"AU","Q7985038"],["Heatley",-19.293,146.753,4038,"AU","Q31053515"],["Bohle Plains",-19.314,146.692,3989,"AU","Q16945893"],["Westcourt",-16.935,145.72,3918,"AU","Q21898860"],["Port Douglas",-16.484,145.465,3650,"AU","Q1364325"],["Parramatta Park",-16.924,145.762,3621,"AU","Q31038342"],["Mundingburra",-19.3,146.783,3620,"AU","Q6935818"],["Cairns City",-16.923,145.773,3616,"AU","Q16890097"],["Trinity Park",-16.805,145.704,3536,"AU","Q31202245"],["Hermit Park",-19.283,146.8,3512,"AU","Q5741738"],["Kuranda",-16.817,145.633,3273,"AU","Q451609"],["Clifton Beach",-16.766,145.67,3192,"AU","Q5133179"],["Tolga",-17.217,145.483,3177,"AU","Q3530583"],["Home Hill",-19.659,147.412,2954,"AU","Q2272457"],["Townsville City",-19.258,146.818,2945,"AU","Q7830276"],["Gulliver",-19.282,146.771,2884,"AU","Q5617793"],["Railway Estate",-19.283,146.817,2871,"AU","Q7284149"],["Kanimbla",-16.917,145.724,2827,"AU","Q18754879"],["Yorkeys Knob",-16.823,145.716,2794,"AU","Q21924820"],["Cooktown",-15.468,145.25,2746,"AU","Q1020734"],["Alice River",-19.329,146.606,2685,"AU","Q4726066"],["Yarrabah",-16.909,145.87,2559,"AU","Q8049518"],["Pimlico",-19.283,146.783,2557,"AU","Q7194652"],["Currajong",-19.277,146.777,2548,"AU","Q16890779"],["Palm Cove",-16.744,145.671,2450,"AU","Q7128027"],["South Townsville",-19.267,146.833,2424,"AU","Q7568670"],["Holloways Beach",-16.842,145.739,2398,"AU","Q5881831"],["Garbutt",-19.267,146.767,2396,"AU","Q5522045"],["Tully",-17.933,145.933,2390,"AU","Q121706"],["Bungalow",-16.938,145.756,2358,"AU","Q30979699"],["Vincent",-19.288,146.763,2357,"AU","Q7931637"],["Caravonica",-16.867,145.683,2183,"AU","Q5037805"],["Freshwater",-16.883,145.717,2142,"AU","Q5503094"],["Belgian Gardens",-19.25,146.8,2073,"AU","Q4882466"],["Oonoonba",-19.3,146.823,2050,"AU","Q7095370"],["Thuringowa Central",-19.317,146.733,2023,"AU","Q7799299"],["Malanda",-17.354,145.594,2000,"AU","Q1886714"],["Mossman",-16.45,145.367,1937,"AU","Q2241511"],["Rosslea",-19.298,146.8,1903,"AU","Q24189972"],["East Innisfail",-17.55,146.083,1855,"AU","Q5328645"],["Jensen",-19.257,146.641,1797,"AU","Q16889180"],["Murray",-19.34,146.777,1739,"AU","Q31202335"],["Stuart",-19.317,146.817,1576,"AU","Q7626232"],["Alligator Creek",-19.424,146.946,1550,"AU","Q16868938"],["Black River",-19.222,146.619,1493,"AU","Q15733741"],["Innisfail Estate",-17.516,146.046,1454,"AU","Q30766194"],["Ravenshoe",-17.609,145.484,1400,"AU","Q1528286"],["Hyde Park",-19.28,146.797,1387,"AU","Q5953604"],["Forrest Beach",-18.709,146.295,1364,"AU","Q15218047"],["Arriga",-17.078,145.316,1323,"AU","Q28110041"],["Wongaling Beach",-17.915,146.097,1323,"AU","Q55819321"],["Cardwell",-18.267,146.033,1320,"AU","Q1005913"],["Babinda",-17.345,145.925,1287,"AU","Q2877892"],["Allingham",-18.708,146.295,1277,"AU","Q30481480"],["Yungaburra",-17.271,145.583,1272,"AU","Q1580463"],["Millstream",-17.626,145.381,1246,"AU","Q31202239"],["Nelly Bay",-19.158,146.85,1213,"AU","Q6990222"],["Stratford",-16.877,145.732,1198,"AU","Q762191Line truncated
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Olukonda",-17.983,16.017,14318,"NA","Q1654926"],["Cuangar",-17.6,18.617,12681,"AO","Q203050"],["Otavi",-19.638,17.34,10756,"NA","Q1013965"],["Nkurenkuru",-17.617,18.6,10463,"NA","Q918461"],["Omuthiya",-18.359,16.58,7560,"NA","Q1005584"],["Okahao",-17.883,15.1,7486,"NA","Q2017063"],["Oshikuku",-17.658,15.473,5499,"NA","Q2033305"],["Oniipa",-17.912,16.041,4740,"NA","Q2024282"],["Tsintsabis",-18.772,17.964,4000,"NA","Q28401753"],["Oshivelo",-18.617,17.167,2700,"NA","Q914118"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Norsup",-16.065,167.4,2998,"VU","Q11792967"],["Port Olry",-15.042,167.07,1951,"VU","Q1050300"],["Lenakel",-19.533,169.267,1507,"VU","Q2390976"],["Isangel",-19.55,169.267,1437,"VU","Q1070178"],["Hog Harbour",-15.133,167.1,1000,"VU","Q5876947"]]}
|
||||
@@ -0,0 +1 @@
|
||||
{"rows":[["Sigatoka",-18.15,177.5,9622,"FJ","Q26720"],["Navua",-18.22,178.18,5812,"FJ","Q2999039"],["Vaileka",-17.367,178.15,5078,"FJ","Q2705079"],["Savusavu",-16.747,179.358,5000,"FJ","Q619440"],["Namatakula",-18.229,177.783,2522,"FJ","Q26920"],["Tavua",-17.441,177.863,2388,"FJ","Q26690"]]}
|
||||
Loaded 100 of 1214 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user