mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 01:02:23 +00:00
Merge remote-tracking branch 'origin/main' into german/zh-hant-generated
This commit is contained in:
commit
0f5869fadd
1614 files changed
+215882
-48326
No files matched your search
@@ -0,0 +1,455 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Build the bundled world cities pack read by `src/data/wikidataCities.js`:
|
||||
*
|
||||
* src/data/local_data/wikidata_cities/cities.json
|
||||
*
|
||||
* Source: Wikidata (CC0), read once from the public query service at build
|
||||
* time. The app itself never calls Wikidata: it reads this file.
|
||||
*
|
||||
* What goes in: items that are a human settlement (an instance of any subclass
|
||||
* of Q486972), have coordinates (P625) and a population (P1082) at or above
|
||||
* the cut-off. Each row keeps the English label, coordinates to three
|
||||
* decimals, the largest stated population, the ISO 3166-1 alpha-2 country
|
||||
* code and the Wikidata id. Groupings of settlements (metropolitan areas,
|
||||
* agglomerations, conurbations) and places that no longer stand are left out.
|
||||
*
|
||||
* The query service limits each query to 60 s, so the population range is
|
||||
* read in bands without labels, the settlement test runs here against the
|
||||
* class list, and labels and countries are read afterwards in batches. One
|
||||
* request runs at a time, with a pause between requests, and a refusal's
|
||||
* Retry-After is honoured.
|
||||
*
|
||||
* Usage:
|
||||
* node scripts/build-wikidata-cities.mjs [--min-population 15000]
|
||||
*/
|
||||
|
||||
import { mkdir, writeFile } from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const ENDPOINT = 'https://query.wikidata.org/sparql';
|
||||
const USER_AGENT =
|
||||
'gods-eye-view-places-builder/0.2 (offline data pack; one-off build; https://github.com/bilawalsidhu/gods-eye-view)';
|
||||
const SETTLEMENT = 'Q486972';
|
||||
const PAUSE_MS = 1500;
|
||||
const LABEL_BATCH = 400;
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const flag = (name) =>
|
||||
args.includes(name) ? Number(args[args.indexOf(name) + 1]) : NaN;
|
||||
const minPopulation = flag('--min-population') || 15000;
|
||||
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const outDir = path.join(root, 'src/data/local_data/wikidata_cities');
|
||||
|
||||
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
const qid = (uri) => uri.slice(uri.lastIndexOf('/') + 1);
|
||||
|
||||
/** The service ran out of time on a query: a smaller one may still answer. */
|
||||
class QueryTimeout extends Error {}
|
||||
|
||||
async function sparql(query, attempt = 1) {
|
||||
let response;
|
||||
try {
|
||||
response = await fetch(ENDPOINT, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'User-Agent': USER_AGENT,
|
||||
Accept: 'application/sparql-results+json',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
body: `query=${encodeURIComponent(query)}`,
|
||||
// The service stops a query at 60 s; past that the answer is lost.
|
||||
signal: AbortSignal.timeout(90000),
|
||||
});
|
||||
} catch (error) {
|
||||
// Our own time limit: the query is too big, as with a 504.
|
||||
if (error.name === 'TimeoutError' && attempt >= 2)
|
||||
throw new QueryTimeout('Wikidata did not answer in time');
|
||||
if (attempt >= 4) throw error;
|
||||
console.warn(` ${error.message}; waiting ${20 * attempt} s`);
|
||||
await sleep(20000 * attempt);
|
||||
return sparql(query, attempt + 1);
|
||||
}
|
||||
if (response.status === 504 && attempt >= 2)
|
||||
throw new QueryTimeout('Wikidata answered 504');
|
||||
// A malformed query fails the same way every time.
|
||||
if (
|
||||
response.status >= 400 &&
|
||||
response.status < 500 &&
|
||||
response.status !== 429
|
||||
)
|
||||
throw new Error(
|
||||
`Wikidata answered ${response.status}: ${(await response.text()).slice(0, 300)}`,
|
||||
);
|
||||
if (!response.ok) {
|
||||
if (attempt >= 4) throw new Error(`Wikidata answered ${response.status}`);
|
||||
const wait =
|
||||
Number(response.headers.get('retry-after')) * 1000 || 20000 * attempt;
|
||||
console.warn(` ${response.status}; waiting ${Math.round(wait / 1000)} s`);
|
||||
await sleep(wait);
|
||||
return sparql(query, attempt + 1);
|
||||
}
|
||||
// The service can stop a long answer partway; that arrives as broken JSON.
|
||||
let rows;
|
||||
try {
|
||||
rows = JSON.parse(await response.text()).results.bindings;
|
||||
} catch (error) {
|
||||
// The service stops a query that runs too long partway through its answer.
|
||||
if (attempt >= 2)
|
||||
throw new QueryTimeout(`Wikidata answer was cut short: ${error.message}`);
|
||||
console.warn(` answer cut short; waiting ${20 * attempt} s`);
|
||||
await sleep(20000 * attempt);
|
||||
return sparql(query, attempt + 1);
|
||||
}
|
||||
await sleep(PAUSE_MS);
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Population bands, narrow where places are many, so each answer stays well
|
||||
* under the service's 60 s limit (about 35,000 places a band).
|
||||
*/
|
||||
function bands(min, max) {
|
||||
const stepAt = (pop) =>
|
||||
pop < 2000
|
||||
? 200
|
||||
: pop < 5000
|
||||
? 500
|
||||
: pop < 10000
|
||||
? 1000
|
||||
: pop < 20000
|
||||
? 2500
|
||||
: pop < 30000
|
||||
? 10000
|
||||
: pop < 50000
|
||||
? 20000
|
||||
: pop < 100000
|
||||
? 50000
|
||||
: Infinity;
|
||||
const list = [];
|
||||
for (let low = min; low < max;) {
|
||||
const high = Math.min(max, low + stepAt(low));
|
||||
list.push([low, high]);
|
||||
low = high;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
console.log('Settlement classes…');
|
||||
const classes = new Set(
|
||||
(await sparql(`SELECT ?c WHERE { ?c wdt:P279* wd:${SETTLEMENT} }`)).map(
|
||||
(row) => qid(row.c.value),
|
||||
),
|
||||
);
|
||||
console.log(` ${classes.size} classes`);
|
||||
|
||||
// Groupings of settlements (metropolitan areas, agglomerations, conurbations,
|
||||
// capital regions)
|
||||
// are settlements in Wikidata too, and are left out so a view is named after
|
||||
// the city rather than the area around it. An item stated as one of these
|
||||
// classes goes, whatever else it is ("New York metropolitan area" is also a
|
||||
// megacity). An item of a narrower kind only goes when it is nothing else:
|
||||
// Istanbul is a "metropolitan municipality in Turkey", a kind of
|
||||
// metropolitan area, and a megacity, so it stays.
|
||||
const GROUPING_TREES = [
|
||||
'Q1907114', // metropolitan area
|
||||
'Q159313', // urban agglomeration
|
||||
'Q245260', // conurbation
|
||||
'Q1062177', // capital region
|
||||
'Q1768043', // metropolitan statistical area
|
||||
'Q3175539', // functional urban area
|
||||
];
|
||||
// Left out as stated only: "city in the United States" is a subclass of
|
||||
// these, so their subclasses must stay.
|
||||
const GROUPING_CLASSES = [
|
||||
'Q702492', // urban area
|
||||
'Q2342385', // urban area (statistical)
|
||||
'Q5951278', // urban area of the United States
|
||||
];
|
||||
// Places that no longer stand as settlements (former entities, ghost towns,
|
||||
// abandoned villages, archaeological sites) are settlements in Wikidata too.
|
||||
// An item typed only as one of these, with every subclass, is left out; one
|
||||
// that is also a living settlement (a city that is also a former capital)
|
||||
// stays.
|
||||
const HISTORICAL_TREES = [
|
||||
'Q15893266', // former entity
|
||||
'Q19953632', // former administrative territorial entity
|
||||
'Q74047', // ghost town
|
||||
'Q350895', // abandoned village
|
||||
'Q839954', // archaeological site
|
||||
];
|
||||
const former = new Set(
|
||||
(
|
||||
await sparql(
|
||||
`SELECT ?c WHERE { VALUES ?top { ${HISTORICAL_TREES.map((id) => `wd:${id}`).join(' ')} } ?c wdt:P279* ?top }`,
|
||||
)
|
||||
).map((row) => qid(row.c.value)),
|
||||
);
|
||||
console.log(` ${former.size} former-place classes`);
|
||||
const groupings = new Set([
|
||||
...(
|
||||
await sparql(
|
||||
`SELECT ?c WHERE { VALUES ?top { ${GROUPING_TREES.map((id) => `wd:${id}`).join(' ')} } ?c wdt:P279* ?top }`,
|
||||
)
|
||||
).map((row) => qid(row.c.value)),
|
||||
...GROUPING_CLASSES,
|
||||
]);
|
||||
console.log(` ${groupings.size} grouping classes left out`);
|
||||
// A band's rows; one the service cannot answer in time is asked again in two
|
||||
// halves.
|
||||
async function bandRows(low, high) {
|
||||
const range = Number.isFinite(high)
|
||||
? `?pop >= ${low} && ?pop < ${high}`
|
||||
: `?pop >= ${low}`;
|
||||
try {
|
||||
return await sparql(
|
||||
`SELECT ?item ?pop ?coord ?type WHERE { ?item wdt:P1082 ?pop . FILTER(${range}) ?item wdt:P625 ?coord ; wdt:P31 ?type . }`,
|
||||
);
|
||||
} catch (error) {
|
||||
const mid = Number.isFinite(high) ? Math.round((low + high) / 2) : low * 4;
|
||||
if (!(error instanceof QueryTimeout) || mid <= low || mid === high)
|
||||
throw error;
|
||||
console.warn(` splitting ${low}–${high} at ${mid}`);
|
||||
return [...(await bandRows(low, mid)), ...(await bandRows(mid, high))];
|
||||
}
|
||||
}
|
||||
|
||||
const GROUPING_STATED = new Set([...GROUPING_TREES, ...GROUPING_CLASSES]);
|
||||
const living = new Set();
|
||||
const stated = new Set();
|
||||
const grouped = new Set();
|
||||
const settled = new Set();
|
||||
|
||||
const places = new Map();
|
||||
for (const [low, high] of bands(minPopulation, Infinity)) {
|
||||
console.log(`Population ${low}–${Number.isFinite(high) ? high : '∞'}…`);
|
||||
const rows = await bandRows(low, high);
|
||||
let kept = 0;
|
||||
for (const row of rows) {
|
||||
const type = qid(row.type.value);
|
||||
if (GROUPING_STATED.has(type)) stated.add(qid(row.item.value));
|
||||
if (groupings.has(type)) grouped.add(qid(row.item.value));
|
||||
if (!classes.has(type)) continue;
|
||||
if (!groupings.has(type) && !former.has(type))
|
||||
settled.add(qid(row.item.value));
|
||||
if (!former.has(type)) living.add(qid(row.item.value));
|
||||
const match = /^Point\(([-\d.eE]+) ([-\d.eE]+)\)$/.exec(row.coord.value);
|
||||
if (!match) continue;
|
||||
const id = qid(row.item.value);
|
||||
const pop = Math.round(Number(row.pop.value));
|
||||
const known = places.get(id);
|
||||
if (known) {
|
||||
known.pop = Math.max(known.pop, pop);
|
||||
// Of several stated coordinates, the same one on every build.
|
||||
const lon = Number(match[1]);
|
||||
const lat = Number(match[2]);
|
||||
if (lat < known.lat || (lat === known.lat && lon < known.lon)) {
|
||||
known.lat = lat;
|
||||
known.lon = lon;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
places.set(id, { id, pop, lon: Number(match[1]), lat: Number(match[2]) });
|
||||
kept++;
|
||||
}
|
||||
console.log(` ${rows.length} rows, ${kept} new settlements`);
|
||||
}
|
||||
|
||||
let groupingsLeftOut = 0;
|
||||
for (const id of grouped) {
|
||||
if ((settled.has(id) && !stated.has(id)) || !places.delete(id)) continue;
|
||||
groupingsLeftOut++;
|
||||
}
|
||||
console.log(`${groupingsLeftOut} groupings left out`);
|
||||
// A place typed only as a former kind is held until its end date is known: a
|
||||
// unit dissolved in a recent reform still stands (below).
|
||||
for (const [id, place] of places) if (!living.has(id)) place.formerOnly = true;
|
||||
const ids = [...places.keys()];
|
||||
console.log(`Labels and countries for ${ids.length} places…`);
|
||||
for (let start = 0; start < ids.length; start += LABEL_BATCH) {
|
||||
const values = ids
|
||||
.slice(start, start + LABEL_BATCH)
|
||||
.map((id) => `wd:${id}`)
|
||||
.join(' ');
|
||||
const rows = await sparql(
|
||||
`SELECT ?item ?label ?iso ?ended WHERE { VALUES ?item { ${values} } OPTIONAL { ?item rdfs:label ?label . FILTER(LANG(?label) = "en") } OPTIONAL { ?item wdt:P17 ?country . ?country wdt:P297 ?iso } OPTIONAL { ?item wdt:P576 ?ended } }`,
|
||||
);
|
||||
for (const row of rows) {
|
||||
const place = places.get(qid(row.item.value));
|
||||
if (!place) continue;
|
||||
if (row.label && !place.name) place.name = row.label.value;
|
||||
// Of several stated countries, the same one on every build.
|
||||
if (row.iso && (!place.cc || row.iso.value < place.cc))
|
||||
place.cc = row.iso.value;
|
||||
// Dissolved, abolished or merged as a unit (P576), and when.
|
||||
if (row.ended) {
|
||||
place.ended = true;
|
||||
const year = Number(/^-?\d+/.exec(row.ended.value)?.[0]);
|
||||
if (Number.isFinite(year))
|
||||
place.endedYear = Math.max(place.endedYear ?? -Infinity, year);
|
||||
}
|
||||
}
|
||||
if ((start / LABEL_BATCH) % 10 === 0)
|
||||
console.log(
|
||||
` ${Math.min(start + LABEL_BATCH, ids.length)} / ${ids.length}`,
|
||||
);
|
||||
}
|
||||
|
||||
// A dissolved place goes only where another place still names the spot (a
|
||||
// city merged into its neighbour, a former district inside its city). Where
|
||||
// nothing else does, the town is still there under its name and stays: many
|
||||
// of Vietnam's provincial cities ended as units in 2025, and with them their
|
||||
// class, so they are typed only as a former kind. A place typed only as a
|
||||
// former kind stays only that way: dissolved within the last ten years with
|
||||
// nothing else near it. Ghost towns and ancient cities go.
|
||||
const SUCCESSOR_KM = 15;
|
||||
const RECENT_YEARS = 10;
|
||||
const recent = new Date().getUTCFullYear() - RECENT_YEARS;
|
||||
const standing = [...places.values()].filter(
|
||||
(place) => place.name && !place.ended && !place.formerOnly,
|
||||
);
|
||||
const near = (a, b) => {
|
||||
const rad = Math.PI / 180;
|
||||
const h =
|
||||
Math.sin(((b.lat - a.lat) * rad) / 2) ** 2 +
|
||||
Math.cos(a.lat * rad) *
|
||||
Math.cos(b.lat * rad) *
|
||||
Math.sin(((b.lon - a.lon) * rad) / 2) ** 2;
|
||||
return 2 * 6371 * Math.asin(Math.min(1, Math.sqrt(h))) <= SUCCESSOR_KM;
|
||||
};
|
||||
const byCell = new Map();
|
||||
const cellOf = (lat, lon) => `${Math.floor(lat)},${Math.floor(lon)}`;
|
||||
for (const place of standing) {
|
||||
const key = cellOf(place.lat, place.lon);
|
||||
if (!byCell.has(key)) byCell.set(key, []);
|
||||
byCell.get(key).push(place);
|
||||
}
|
||||
let dissolved = 0;
|
||||
let formerOnly = 0;
|
||||
for (const [id, place] of places) {
|
||||
if (place.formerOnly && !(place.ended && place.endedYear >= recent)) {
|
||||
places.delete(id);
|
||||
formerOnly++;
|
||||
continue;
|
||||
}
|
||||
if (!place.ended) continue;
|
||||
let succeeded = false;
|
||||
for (let dLat = -1; dLat <= 1 && !succeeded; dLat++)
|
||||
for (let dLon = -1; dLon <= 1 && !succeeded; dLon++)
|
||||
succeeded = (
|
||||
byCell.get(cellOf(place.lat + dLat, place.lon + dLon)) || []
|
||||
).some((other) => near(place, other));
|
||||
if (succeeded) dissolved++;
|
||||
else place.ended = false;
|
||||
}
|
||||
console.log(`${formerOnly} former places left out`);
|
||||
console.log(`${dissolved} dissolved places left out`);
|
||||
|
||||
// A place whose stated country is a former one (no ISO code) takes the
|
||||
// country of the area it lies in, one area level up at a time (a path of
|
||||
// several levels in one query runs past the service's time limit).
|
||||
const COUNTRY_BATCH = 50;
|
||||
const countryless = () =>
|
||||
[...places.values()]
|
||||
.filter((place) => place.name && !place.cc && !place.ended)
|
||||
.map((place) => place.id);
|
||||
for (const hops of [1, 2, 3]) {
|
||||
const ids = countryless();
|
||||
if (!ids.length) break;
|
||||
console.log(`Countries ${hops} area level(s) up for ${ids.length} places…`);
|
||||
const pathToArea = Array.from({ length: hops }, () => 'wdt:P131').join('/');
|
||||
for (let start = 0; start < ids.length; start += COUNTRY_BATCH) {
|
||||
const values = ids
|
||||
.slice(start, start + COUNTRY_BATCH)
|
||||
.map((id) => `wd:${id}`)
|
||||
.join(' ');
|
||||
const rows = await sparql(
|
||||
`SELECT ?item ?iso WHERE { VALUES ?item { ${values} } ?item ${pathToArea} ?area . ?area wdt:P17 ?country . ?country wdt:P297 ?iso }`,
|
||||
);
|
||||
for (const row of rows) {
|
||||
const place = places.get(qid(row.item.value));
|
||||
if (!place || (place.cc && place.hops !== hops)) continue;
|
||||
if (!place.cc || row.iso.value < place.cc) {
|
||||
place.cc = row.iso.value;
|
||||
place.hops = hops;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(` ${countryless().length} places still without a country`);
|
||||
|
||||
const rows = [...places.values()]
|
||||
.filter(
|
||||
(place) =>
|
||||
place.name &&
|
||||
!place.ended &&
|
||||
Math.abs(place.lat) <= 90 &&
|
||||
Math.abs(place.lon) <= 180,
|
||||
)
|
||||
.sort((a, b) => b.pop - a.pop || a.id.localeCompare(b.id))
|
||||
.map((place) => [
|
||||
place.name,
|
||||
Number(place.lat.toFixed(3)),
|
||||
Number(place.lon.toFixed(3)),
|
||||
place.pop,
|
||||
place.cc || '',
|
||||
place.id,
|
||||
]);
|
||||
|
||||
// A filter that is too wide drops real cities without any error; these must
|
||||
// survive, and no settlement grouping may.
|
||||
const MUST_HAVE = {
|
||||
Q1490: 'Tokyo',
|
||||
Q84: 'London',
|
||||
Q16559: 'Austin',
|
||||
Q16555: 'Houston',
|
||||
Q1355: 'Bengaluru',
|
||||
Q3630: 'Jakarta',
|
||||
Q174: 'São Paulo',
|
||||
Q34600: 'Kyoto',
|
||||
Q656: 'Saint Petersburg',
|
||||
Q406: 'Istanbul',
|
||||
Q8678: 'Rio de Janeiro',
|
||||
Q1345: 'Philadelphia',
|
||||
Q586: 'Bonn',
|
||||
Q1449: 'Genoa',
|
||||
Q1563: 'Havana',
|
||||
// Provincial cities dissolved as units in 2025 that still stand.
|
||||
Q19491: 'Nha Trang',
|
||||
Q36081: 'Quy Nhon',
|
||||
};
|
||||
// Groupings that are also typed as cities; none may get in.
|
||||
const MUST_NOT = {
|
||||
Q683705: 'New York metropolitan area',
|
||||
Q665894: 'Greater Mexico City',
|
||||
Q13580: 'Metro Manila',
|
||||
Q3114019: 'Katowice urban area',
|
||||
};
|
||||
const present = new Set(rows.map((row) => row[5]));
|
||||
const missing = Object.entries(MUST_HAVE).filter(([id]) => !present.has(id));
|
||||
const intruders = Object.entries(MUST_NOT).filter(([id]) => present.has(id));
|
||||
if (intruders.length) {
|
||||
throw new Error(
|
||||
`Groupings got in: ${intruders.map(([id, name]) => `${name} (${id})`).join(', ')}`,
|
||||
);
|
||||
}
|
||||
if (missing.length) {
|
||||
throw new Error(
|
||||
`Expected cities are missing: ${missing.map(([id, name]) => `${name} (${id})`).join(', ')}`,
|
||||
);
|
||||
}
|
||||
|
||||
const meta = {
|
||||
source: 'Wikidata (https://www.wikidata.org), via the Wikidata Query Service',
|
||||
license: 'CC0 1.0',
|
||||
built: new Date().toISOString(),
|
||||
minPopulation,
|
||||
count: rows.length,
|
||||
columns: ['name', 'lat', 'lon', 'population', 'country', 'wikidata'],
|
||||
};
|
||||
|
||||
await mkdir(outDir, { recursive: true });
|
||||
const file = path.join(outDir, 'cities.json');
|
||||
await writeFile(file, `${JSON.stringify({ meta, rows })}\n`);
|
||||
console.log(`Wrote ${rows.length} places to ${path.relative(root, file)}`);
|
||||
@@ -15,6 +15,11 @@ const tests = (file) =>
|
||||
file.endsWith('.test.mjs') ||
|
||||
file.startsWith('src/testSupport/') ||
|
||||
file.startsWith('src/tooling/') ||
|
||||
// Test doubles outside src/testSupport, imported by tests only.
|
||||
file === 'src/input/testDoubles.mjs' ||
|
||||
file === 'src/layers/recentImagery/testDoubles.mjs' ||
|
||||
file === 'src/voice/voiceWorkflowHarness.mjs' ||
|
||||
file === 'src/layers/wildlifeSightings/renderPerformanceFixtures.mjs' ||
|
||||
file === 'src/overlays/worldOverlayAllocation.worker.mjs';
|
||||
const source = (file) =>
|
||||
file.startsWith('src/sources/') ||
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
#!/usr/bin/env node
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
advanceSpriteFocus,
|
||||
} from '../src/data/focusDeemphasis.js';
|
||||
import {
|
||||
applyAircraftBillboardTreatment,
|
||||
} from '../src/data/aircraftRecession.js';
|
||||
import { advanceSpriteFocus } from '../src/data/focusDeemphasis.js';
|
||||
import { aircraftTreatmentAlpha } from '../src/data/aircraftRecession.js';
|
||||
import { createIconSet } from '../src/data/iconSet.js';
|
||||
|
||||
if (typeof global.gc !== 'function') {
|
||||
throw new Error('focus-allocation-check.mjs requires node --expose-gc');
|
||||
@@ -66,17 +63,14 @@ const focusInput = {
|
||||
target,
|
||||
};
|
||||
|
||||
const baseColor = { withAlpha: (alpha) => ({ alpha }) };
|
||||
const billboard = { scale: 1, color: { alpha: 1 } };
|
||||
const aircraftInput = {
|
||||
billboard,
|
||||
baseScale: 1,
|
||||
baseAlpha: 1,
|
||||
baseColor,
|
||||
focusFactor: 1,
|
||||
cameraDistanceM: 100,
|
||||
cameraHeightM: 1000,
|
||||
};
|
||||
const icons = createIconSet({ capacity: 4 });
|
||||
const row = icons.add('sprite', {});
|
||||
|
||||
const baseline = bytesPerCall(() => focusInput.nowMs);
|
||||
const focus = netOfLoopBaseline(
|
||||
@@ -84,30 +78,22 @@ const focus = netOfLoopBaseline(
|
||||
baseline,
|
||||
);
|
||||
const aircraft = netOfLoopBaseline(
|
||||
bytesPerCall(() => applyAircraftBillboardTreatment(aircraftInput).alpha),
|
||||
bytesPerCall(() => aircraftTreatmentAlpha(aircraftInput)),
|
||||
baseline,
|
||||
);
|
||||
const productionSpriteTick = netOfLoopBaseline(
|
||||
bytesPerCall(() => {
|
||||
// Match the hot civilian/military sprite path: the caller constructs fresh
|
||||
// option literals, consumes the shared focus result immediately, and then
|
||||
// constructs the composed aircraft-treatment options for the same sprite.
|
||||
// Match the hot icon-set focus pass: the caller constructs a fresh option
|
||||
// literal, consumes the shared focus result immediately and writes it to
|
||||
// the row's focus column (the shader composes it with limb recession).
|
||||
const focusResult = advanceSpriteFocus(sprite, {
|
||||
screenPosition: focusInput.screenPosition,
|
||||
cameraDistance: focusInput.cameraDistance,
|
||||
nowMs: focusInput.nowMs,
|
||||
target,
|
||||
});
|
||||
const treatment = applyAircraftBillboardTreatment({
|
||||
billboard,
|
||||
baseScale: aircraftInput.baseScale,
|
||||
baseAlpha: aircraftInput.baseAlpha,
|
||||
baseColor,
|
||||
focusFactor: focusResult.factor,
|
||||
cameraDistanceM: aircraftInput.cameraDistanceM,
|
||||
cameraHeightM: aircraftInput.cameraHeightM,
|
||||
});
|
||||
return focusResult.factor + treatment.alpha;
|
||||
icons.setFocus(row, focusResult.factor);
|
||||
return focusResult.factor;
|
||||
}),
|
||||
baseline,
|
||||
);
|
||||
@@ -118,22 +104,24 @@ assert.ok(
|
||||
);
|
||||
assert.ok(
|
||||
aircraft.roundedMedian <= PURE_CALL_BUDGET,
|
||||
`applyAircraftBillboardTreatment allocated ${aircraft.rawMedian.toFixed(3)} B/call median`,
|
||||
`aircraftTreatmentAlpha allocated ${aircraft.rawMedian.toFixed(3)} B/call median`,
|
||||
);
|
||||
assert.ok(
|
||||
productionSpriteTick.roundedMedian <= PRODUCTION_SPRITE_TICK_BUDGET,
|
||||
`production sprite tick allocated ${productionSpriteTick.rawMedian.toFixed(3)} B/call median`,
|
||||
);
|
||||
|
||||
console.log(JSON.stringify({
|
||||
callsPerTrial: CALLS,
|
||||
trials: TRIALS,
|
||||
budgets: {
|
||||
pureCall: PURE_CALL_BUDGET,
|
||||
productionSpriteTick: PRODUCTION_SPRITE_TICK_BUDGET,
|
||||
},
|
||||
loopBaseline: baseline,
|
||||
advanceSpriteFocus: focus,
|
||||
applyAircraftBillboardTreatment: aircraft,
|
||||
productionSpriteTick,
|
||||
}));
|
||||
console.log(
|
||||
JSON.stringify({
|
||||
callsPerTrial: CALLS,
|
||||
trials: TRIALS,
|
||||
budgets: {
|
||||
pureCall: PURE_CALL_BUDGET,
|
||||
productionSpriteTick: PRODUCTION_SPRITE_TICK_BUDGET,
|
||||
},
|
||||
loopBaseline: baseline,
|
||||
advanceSpriteFocus: focus,
|
||||
aircraftTreatmentAlpha: aircraft,
|
||||
productionSpriteTick,
|
||||
}),
|
||||
);
|
||||
+169
-16
@@ -43,6 +43,34 @@
|
||||
"scripts/build-admin-packs.mjs",
|
||||
"scripts/qa-admin-outlines.mjs",
|
||||
"src/data/inputOwnership.test.mjs",
|
||||
"src/input/dispatcher.test.mjs",
|
||||
"src/input/testDoubles.mjs",
|
||||
"src/input/sensorPick.js",
|
||||
"src/input/dispatcher.js",
|
||||
"src/queries/heights.js",
|
||||
"src/render/cesium/internals.js",
|
||||
"src/render/cesium/cameraInput.js",
|
||||
"src/render/cesium/ctrlWheelZoom.js",
|
||||
"src/render/cesium/input.js",
|
||||
"src/render/cesium/nativeClick.js",
|
||||
"src/render/cesium/nativeClick.test.mjs",
|
||||
"src/render/cesium/pickMemo.js",
|
||||
"src/render/cesium/input.test.mjs",
|
||||
"src/render/cesium/cameraInput.test.mjs",
|
||||
"src/render/cesium/cameraControls.js",
|
||||
"src/render/cesium/cameraControls.test.mjs",
|
||||
"src/render/input/router.js",
|
||||
"src/render/input/router.test.mjs",
|
||||
"src/render/motion/iconMotion.test.mjs",
|
||||
"src/render/motion/iconBook.test.mjs",
|
||||
"src/render/camera/poseSignature.test.mjs",
|
||||
"src/render/cesium/internals.test.mjs",
|
||||
"src/render/cesium/uploadProbe.js",
|
||||
"src/render/cesium/uploadProbe.test.mjs",
|
||||
"src/render/cesium/tileRequests.js",
|
||||
"src/render/cesium/tileRequests.test.mjs",
|
||||
"src/queries/heights.test.mjs",
|
||||
"src/render/cesium/heights.test.mjs",
|
||||
"docs/CODE-BOUNDARIES.md",
|
||||
"src/main.js",
|
||||
"docs/APPLICATION.md",
|
||||
@@ -56,10 +84,8 @@
|
||||
"src/app/application.test.mjs",
|
||||
"src/app/mapLifecycle.test.mjs",
|
||||
"src/app/startupCamera.test.mjs",
|
||||
"src/app/viewer.js",
|
||||
"src/app/zoomOutGuard.test.mjs",
|
||||
"src/app/controls.test.mjs",
|
||||
"scripts/qa-zoom-out-guard.mjs",
|
||||
"src/render/cesium/applicationViewer.js",
|
||||
"src/sky/icrf.js",
|
||||
"src/app/atmosphereCompat.test.mjs",
|
||||
"src/standalone/application.js",
|
||||
"src/standalone/controls.js",
|
||||
@@ -180,6 +206,9 @@
|
||||
"src/search/google.js",
|
||||
"src/search/coordinateParser.js",
|
||||
"src/search/coordinateParser.test.mjs",
|
||||
"src/search/gridReference.js",
|
||||
"src/search/gridReference.test.mjs",
|
||||
"src/search/plusCode.js",
|
||||
"src/search/coordinateGeocoder.js",
|
||||
"src/search/presetGeocoder.js",
|
||||
"src/search/offlineGeocoders.test.mjs",
|
||||
@@ -291,6 +320,9 @@
|
||||
"src/ui/scenes.js",
|
||||
"src/ui/sceneControls.js",
|
||||
"src/ui/scenePresentation.js",
|
||||
"src/scenes/storyThumb.test.mjs",
|
||||
"src/scenes/storyThumb.js",
|
||||
"src/scenes/storyTags.js",
|
||||
"src/ui/sceneControls.test.mjs",
|
||||
"scripts/qa-scene-controls.mjs",
|
||||
"scripts/qa-action-buttons.mjs",
|
||||
@@ -355,7 +387,6 @@
|
||||
"src/layers/flights/tracking.js",
|
||||
"src/layers/flights/rendering.js",
|
||||
"src/layers/flights/testing.js",
|
||||
"src/layers/flights/hiddenContactRotation.test.mjs",
|
||||
"src/layers/flights/evidence.js",
|
||||
"src/layers/flights/ingestion.js",
|
||||
"src/layers/flights/queries.js",
|
||||
@@ -456,6 +487,7 @@
|
||||
"src/layers/satellites/ingestion.js",
|
||||
"src/layers/satellites/index.js",
|
||||
"src/layers/satellites/orbits.js",
|
||||
"src/layers/satellites/motion.js",
|
||||
"src/layers/launches/lifecycle.js",
|
||||
"src/layers/launches/controls.js",
|
||||
"src/layers/launches/panel.js",
|
||||
@@ -483,6 +515,8 @@
|
||||
"src/data/rocketLaunches.js",
|
||||
"src/layers/satellites/source.test.mjs",
|
||||
"src/layers/satellites/stale.test.mjs",
|
||||
"src/layers/satellites/motion.test.mjs",
|
||||
"src/layers/satellites/reckon.test.mjs",
|
||||
"src/layers/launches/source.test.mjs",
|
||||
"src/layers/launches/ingestion.test.mjs",
|
||||
"src/layers/launches/failedEntry.test.mjs",
|
||||
@@ -532,6 +566,8 @@
|
||||
"src/layers/traffic/model.js",
|
||||
"src/layers/traffic/timing.js",
|
||||
"src/layers/traffic/style.js",
|
||||
"src/layers/traffic/style.test.mjs",
|
||||
"src/layers/traffic/timing.test.mjs",
|
||||
"src/layers/bikeshare/lifecycle.js",
|
||||
"src/layers/bikeshare/viewport.js",
|
||||
"src/layers/bikeshare/registry.js",
|
||||
@@ -557,6 +593,13 @@
|
||||
"src/ui/frameRateMonitor.js",
|
||||
"src/ui/frameRateMonitor.test.mjs",
|
||||
"src/ui/frameRateView.test.mjs",
|
||||
"src/render/cesium/renderFailure.test.mjs",
|
||||
"src/ui/renderFailureView.test.mjs",
|
||||
"src/render/cesium/renderFailureLoopErrors.test.mjs",
|
||||
"src/render/cesium/renderFailureEventRetry.test.mjs",
|
||||
"src/app/renderFailureInlineRetry.test.mjs",
|
||||
"src/render/cesium/renderFailureSecondLoop.test.mjs",
|
||||
"src/render/cesium/renderLoopFixture.mjs",
|
||||
"src/layers/cctv/lifecycle.js",
|
||||
"src/layers/cctv/controls.js",
|
||||
"src/layers/cctv/geometry.js",
|
||||
@@ -637,6 +680,7 @@
|
||||
"src/layers/radio/volume.js",
|
||||
"src/data/radio.js",
|
||||
"src/layers/radio/source.test.mjs",
|
||||
"src/layers/radio/lifecycle.test.mjs",
|
||||
"src/layers/submarineCables/bundledSource.js",
|
||||
"src/layers/submarineCables/geometry.js",
|
||||
"src/layers/submarineCables/index.js",
|
||||
@@ -661,10 +705,14 @@
|
||||
"src/maps/imageryComparison.js",
|
||||
"src/maps/credits.js",
|
||||
"src/maps/defaultSources.js",
|
||||
"src/maps/google3d.js",
|
||||
"src/maps/imagery.js",
|
||||
"src/render/cesium/google3d.js",
|
||||
"src/render/cesium/mapImagery.js",
|
||||
"src/maps/registry.js",
|
||||
"src/maps/terrain.js",
|
||||
"src/render/cesium/mapTerrain.js",
|
||||
"src/maps/engine.js",
|
||||
"src/maps/startupRoute.js",
|
||||
"src/maps/attribution.js",
|
||||
"src/render/cesium/mapEngine.js",
|
||||
"src/maps/terrainRetry.js",
|
||||
"src/maps/terrainRetry.test.mjs",
|
||||
"src/mapStackController.js",
|
||||
@@ -672,7 +720,7 @@
|
||||
"src/mapStackChips.test.mjs",
|
||||
"src/mapStackUnavailableReason.test.mjs",
|
||||
"src/mapStartup.test.mjs",
|
||||
"src/maps/sourceFactories.test.mjs",
|
||||
"src/render/cesium/mapSources.test.mjs",
|
||||
"src/search/geospatial.js",
|
||||
"src/search/http.js",
|
||||
"src/search/defaults.js",
|
||||
@@ -689,6 +737,16 @@
|
||||
"src/services/application.js",
|
||||
"src/services/requests.js",
|
||||
"src/app/scene.js",
|
||||
"src/render/cesium/appRenderer.test.mjs",
|
||||
"src/render/noCesiumOutsideRender.test.mjs",
|
||||
"src/render/cesiumAllowList.json",
|
||||
"src/render/viewerAccess.test.mjs",
|
||||
"src/render/viewerAccessAllowList.json",
|
||||
"src/testSupport/viewerAccess.mjs",
|
||||
"scripts/viewer-access-baseline.mjs",
|
||||
"src/geo/geo.test.mjs",
|
||||
"src/geo/celestial.test.mjs",
|
||||
"src/geo/quaternion.test.mjs",
|
||||
"src/app/controls.js",
|
||||
"src/app/data.js",
|
||||
"src/app/tools.js",
|
||||
@@ -744,6 +802,7 @@
|
||||
"src/layers/flights/snapshotRenderer.js",
|
||||
"src/layers/flights/records.test.mjs",
|
||||
"src/layers/flights/ingestion.test.mjs",
|
||||
"src/layers/flights/controller.test.mjs",
|
||||
"src/layers/military/records.js",
|
||||
"src/layers/military/recordPolicy.js",
|
||||
"src/layers/military/snapshotRenderer.js",
|
||||
@@ -827,7 +886,6 @@
|
||||
"src/tooling/transitProvider.test.mjs",
|
||||
"src/app/layers/transit.js",
|
||||
"src/data/transitIcons.js",
|
||||
"src/data/cameraSensitivity.js",
|
||||
"src/data/contactPlayback.js",
|
||||
"src/data/contactTrailRenderer.js",
|
||||
"src/data/contactTrailRenderer.test.mjs",
|
||||
@@ -899,6 +957,10 @@
|
||||
"src/layers/weather/rendering.js",
|
||||
"src/layers/weather/shellRendering.js",
|
||||
"src/layers/weather/shellRendering.test.mjs",
|
||||
"src/render/cesium/drawFields.js",
|
||||
"src/render/cesium/drawFields.test.mjs",
|
||||
"src/render/cesium/drawStreamlines.js",
|
||||
"src/render/cesium/drawStreamlines.test.mjs",
|
||||
"src/layers/weather/infraredAlpha.js",
|
||||
"src/layers/weather/infraredAlpha.test.mjs",
|
||||
"src/layers/weather/infraredImage.js",
|
||||
@@ -929,8 +991,6 @@
|
||||
"src/ui/weatherPanel.test.mjs",
|
||||
"src/ui/railCards.js",
|
||||
"src/ui/railCards.test.mjs",
|
||||
"src/ui/railTimeline.js",
|
||||
"src/ui/railTimeline.test.mjs",
|
||||
"src/layers/weather/imageryOrder.js",
|
||||
"src/layers/weather/imageryOrder.test.mjs",
|
||||
"server/providers/cyclones.js",
|
||||
@@ -1119,7 +1179,6 @@
|
||||
"src/layers/traffic/roadModes.test.mjs",
|
||||
"scripts/qa-traffic-motion.mjs",
|
||||
"src/layers/traffic/motion.test.mjs",
|
||||
"src/layers/traffic/lineRebuild.test.mjs",
|
||||
"scripts/qa-journey-recorder.mjs",
|
||||
"scripts/qa-alpr-journey.mjs",
|
||||
"scripts/qa-context-arrivals.mjs",
|
||||
@@ -1152,6 +1211,9 @@
|
||||
"src/view/index.test.mjs",
|
||||
"src/tools/views.test.mjs",
|
||||
"src/app/embed.test.mjs",
|
||||
"src/app/panelRendering.js",
|
||||
"src/render/cesium/application.js",
|
||||
"src/app/panelRendering.test.mjs",
|
||||
"src/tools/globePanel.test.mjs",
|
||||
"src/costEndpointThrottle.test.mjs",
|
||||
"src/sources/gbfsStations.test.mjs",
|
||||
@@ -1168,7 +1230,7 @@
|
||||
"scripts/build-bright-stars.mjs",
|
||||
"scripts/build-milky-way.mjs",
|
||||
"src/sky/stars.test.mjs",
|
||||
"src/sky/starrySky.test.mjs",
|
||||
"src/render/cesium/starrySky.test.mjs",
|
||||
"src/tooling/skyAssets.test.mjs",
|
||||
"src/tooling/skyAssets.paintOut.test.mjs",
|
||||
"src/tooling/responseCompression.test.mjs",
|
||||
@@ -1186,6 +1248,31 @@
|
||||
"src/ui/shellFacade.test.mjs",
|
||||
"src/voice/globeResetConfirmation.test.mjs",
|
||||
"src/hudDms.test.mjs",
|
||||
"server/providers/common/rateLimitKeys.test.mjs",
|
||||
"src/render/contract/contract.test.mjs",
|
||||
"src/render/contract/common.d.ts",
|
||||
"src/render/contract/renderer.d.ts",
|
||||
"src/render/contract/frame.d.ts",
|
||||
"src/render/contract/globe.d.ts",
|
||||
"src/render/contract/draw.d.ts",
|
||||
"src/render/contract/camera.d.ts",
|
||||
"src/render/contract/query.d.ts",
|
||||
"src/render/contract/input.d.ts",
|
||||
"src/render/contract/effects.d.ts",
|
||||
"src/render/contract/credits.d.ts",
|
||||
"src/render/contract/quality.d.ts",
|
||||
"src/render/contract/index.d.ts",
|
||||
"src/render/stub/stub.test.mjs",
|
||||
"src/render/conformance/scenes.test.mjs",
|
||||
"src/render/cesium/cameraGoldens.test.mjs",
|
||||
"scripts/record-camera-goldens.mjs",
|
||||
"server/standalone/conformance-references.js",
|
||||
"dev/conformance/index.html",
|
||||
"dev/conformance/main.js",
|
||||
"docs/RENDERER-CONTRACT.md",
|
||||
"src/render/cesium/zoomOutGuard.test.mjs",
|
||||
"src/app/controls.test.mjs",
|
||||
"scripts/qa-zoom-out-guard.mjs",
|
||||
"src/hudSummaryGate.test.mjs",
|
||||
"src/hudSummaryLine.test.mjs",
|
||||
"src/testSupport/stubMgrs.mjs",
|
||||
@@ -1234,6 +1321,30 @@
|
||||
"src/ui/stores/owners.test.mjs",
|
||||
"src/ui/stores/panels.test.mjs",
|
||||
"src/ui/stores/status.js",
|
||||
"src/stories/catalog.js",
|
||||
"src/stories/format.js",
|
||||
"src/stories/gevLogo.js",
|
||||
"src/stories/storyMeta.js",
|
||||
"src/stories/thumbs.js",
|
||||
"src/stories/thumbs.test.mjs",
|
||||
"src/stories/controller.js",
|
||||
"src/stories/gevPlayer.js",
|
||||
"src/stories/gevPlayer.test.mjs",
|
||||
"src/stories/boot.js",
|
||||
"src/stories/keyboard.js",
|
||||
"src/stories/keyboard.test.mjs",
|
||||
"src/stories/boot.test.mjs",
|
||||
"src/stories/controller.test.mjs",
|
||||
"src/ui/storiesCredit.test.mjs",
|
||||
"src/ui/styles/stories.css",
|
||||
"src/ui/styles/stories-entry.css",
|
||||
"src/ui/views/stories/ExploreScreen.vue",
|
||||
"src/ui/views/stories/StoriesHeader.vue",
|
||||
"src/ui/views/stories/StoryContext.vue",
|
||||
"src/ui/views/stories/StoryRail.vue",
|
||||
"src/ui/views/stories/StoryScreen.vue",
|
||||
"src/ui/views/stories/StoryTimeline.vue",
|
||||
"src/ui/stores/stories.js",
|
||||
"src/ui/statusChipsView.test.mjs",
|
||||
"src/ui/statusChipOwners.test.mjs",
|
||||
"src/ui/toast.js",
|
||||
@@ -1291,7 +1402,6 @@
|
||||
"src/tooling/nominatimGuardLifecycle.test.mjs",
|
||||
"src/tooling/nominatimLockOwnership.test.mjs",
|
||||
"src/tooling/nominatimOutlineRoute.test.mjs",
|
||||
"server/providers/common/rateLimitKeys.test.mjs",
|
||||
"src/voice/areaCandidateContract.js",
|
||||
"src/voice/layerActionOwnership.js",
|
||||
"src/data/areaGeometry.test.mjs",
|
||||
@@ -1334,6 +1444,7 @@
|
||||
"src/layers/shipwrecks/index.test.mjs",
|
||||
"src/layers/shipwrecks/source.test.mjs",
|
||||
"src/data/shipwrecksProxy.test.mjs",
|
||||
"src/data/aircraftIconLayer.test.mjs",
|
||||
"src/app/sourceComposition.js",
|
||||
"src/app/sourceComposition.test.mjs",
|
||||
"src/data/dataCredits.js",
|
||||
@@ -1428,5 +1539,47 @@
|
||||
"src/ui/ownerFlagSheet.js",
|
||||
"src/data/placePacksLoading.test.mjs",
|
||||
"src/ui/placePacksLoading.js",
|
||||
"src/ui/placePacksLoading.test.mjs"
|
||||
"src/ui/placePacksLoading.test.mjs",
|
||||
"src/render/applicationHooks.js",
|
||||
"src/maps/globeEngine.js",
|
||||
"src/maps/globeEngine.test.mjs",
|
||||
"src/render/cesium/viewers.js",
|
||||
"src/app/scene.test.mjs",
|
||||
"dev/stub-app/main.js",
|
||||
"scripts/qa-stub-boot.mjs",
|
||||
"src/ui/creditsView.js",
|
||||
"src/ui/creditsView.test.mjs",
|
||||
"src/cockpitSubjectProviders.js",
|
||||
"src/cockpitSubjectProviders.test.mjs",
|
||||
"src/cockpitProgress.js",
|
||||
"src/cockpitProgress.test.mjs",
|
||||
"src/ui/cockpitSubjectView.test.mjs",
|
||||
"src/ui/styles/cockpitSubject.css",
|
||||
"src/layers/rail/cockpitSubject.js",
|
||||
"src/layers/rail/cockpitSubject.test.mjs",
|
||||
"src/layers/transit/cockpitSubject.js",
|
||||
"src/data/fleetModels.test.mjs",
|
||||
"src/data/fleetModelInstances.test.mjs",
|
||||
"src/testSupport/fleetGlb.mjs",
|
||||
"src/testSupport/fleetModelFakes.mjs",
|
||||
"scripts/measure-fleet-trail-anchors.mjs",
|
||||
"src/ui/panelEdge.js",
|
||||
"src/ui/railEdgeScroll.js",
|
||||
"src/ui/railEdgeScroll.test.mjs",
|
||||
"src/ui/kit/UiPanelEdge.vue",
|
||||
"src/ui/styles/rail-edge.css",
|
||||
"src/ui/styles/rail-split.css",
|
||||
"src/ui/styles/left-tools.css",
|
||||
"src/ui/styles/panel-edge.css",
|
||||
"src/data/placementProvider.test.mjs",
|
||||
"src/layers/vessels/placement.test.mjs",
|
||||
"src/ui/styles/visual-panel.css",
|
||||
"src/ui/styles/scope-off-shadows.css",
|
||||
"src/ui/styles/cockpit-panels.css",
|
||||
"src/ui/styles/layer-section-index.css",
|
||||
"src/ui/styles/layer-finder.css",
|
||||
"src/ui/layerFinder.test.mjs",
|
||||
"src/data/wikidataCities.js",
|
||||
"src/data/wikidataCities.test.mjs",
|
||||
"scripts/build-wikidata-cities.mjs"
|
||||
]
|
||||
+2
-1
@@ -483,7 +483,8 @@ function readMarkup(file) {
|
||||
|
||||
// Text that never reaches the page as UI: tool results and descriptions for
|
||||
// AI clients (MCP and the voice model).
|
||||
const NOT_UI = [/^src\/tools\//];
|
||||
// The conformance suite's check titles are developer output, not UI.
|
||||
const NOT_UI = [/^src\/tools\//, /^src\/render\/conformance\//];
|
||||
|
||||
function sourceFiles() {
|
||||
return trackedFiles(
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Re-measure the trail attachment point of every aircraft-layer fleet model
|
||||
* and print `src/data/fleetTrailAnchors.js`.
|
||||
*
|
||||
* node scripts/measure-fleet-trail-anchors.mjs > src/data/fleetTrailAnchors.js
|
||||
*
|
||||
* Run it whenever a model under `public/models/fleet/` changes; the unit
|
||||
* suite (`src/data/fleetModels.test.mjs`) re-derives each value and fails
|
||||
* on a table that no longer matches its GLB.
|
||||
*/
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { projectRoot } from './project-root.mjs';
|
||||
import {
|
||||
fleetMesh,
|
||||
measuredTrailAnchor,
|
||||
} from '../src/testSupport/fleetGlb.mjs';
|
||||
|
||||
/** Catalog categories the aircraft layers draw (ADS-B ground vehicles and balloons included). */
|
||||
export const TRAIL_ANCHOR_CATEGORIES = ['aircraft', 'helicopters', 'other'];
|
||||
|
||||
const root = projectRoot(import.meta.url);
|
||||
const dir = path.join(root, 'public', 'models', 'fleet');
|
||||
const catalog = JSON.parse(
|
||||
fs.readFileSync(path.join(dir, 'catalog.json'), 'utf8'),
|
||||
);
|
||||
const rows = [];
|
||||
for (const [name, model] of Object.entries(catalog)) {
|
||||
if (!TRAIL_ANCHOR_CATEGORIES.includes(model.category)) continue;
|
||||
const anchor = measuredTrailAnchor(
|
||||
await fleetMesh(path.join(dir, model.file)),
|
||||
);
|
||||
if (!anchor) continue;
|
||||
const [x, y] = anchor.map((value) => Number(value.toFixed(4)) || 0);
|
||||
rows.push(
|
||||
` ${/^[a-z_]\w*$/.test(name) ? name : `'${name}'`}: Object.freeze([${x}, ${y}, 0]),`,
|
||||
);
|
||||
}
|
||||
process.stdout.write(`/**
|
||||
* Aft-belly trail attachment points of the fleet models the aircraft layers
|
||||
* draw, in raw glTF axes (X along the body, nose toward -X; Y up), metres
|
||||
* before scale, node transforms applied. Each is the point of the model's
|
||||
* centreline profile (its z = 0 slice) nearest its aft-belly bounding-box
|
||||
* corner: on the hull, aft, and on the centreline (see modelVisualAnchor.js).
|
||||
*
|
||||
* Written by scripts/measure-fleet-trail-anchors.mjs; re-measured against the
|
||||
* GLBs by fleetModels.test.mjs.
|
||||
*/
|
||||
export const FLEET_TRAIL_ANCHORS = Object.freeze({
|
||||
${rows.join('\n')}
|
||||
});
|
||||
`);
|
||||
+2564
-256
File diff suppressed because it is too large.
Load diff
+113
-48
@@ -12,10 +12,11 @@
|
||||
* and finally Brandenburg (Berlin is a hole) and Hawaii (eight islands).
|
||||
*
|
||||
* Asserts for every outline: it resolves from the bundled packs (no geocode,
|
||||
* boundary or Overpass request), is drawn as a draped outline within the
|
||||
* budget, and holds still — no rebuilt primitives and no new entities while
|
||||
* the camera is still. The whole journey must log zero console/page errors and
|
||||
* send zero requests to any Overpass host or nominatim.openstreetmap.org.
|
||||
* boundary or Overpass request), shows its first frame within the budget,
|
||||
* has its draped fill and outline built (their time is reported), and holds
|
||||
* still — none of its primitives rebuilt while the camera is still. The whole
|
||||
* journey must log zero console/page errors and send zero requests to any
|
||||
* Overpass host or nominatim.openstreetmap.org.
|
||||
*
|
||||
* Evidence in qa-shots/ (gitignored): admin-outlines-<step>.png screenshots,
|
||||
* admin-outlines-journey.mp4 (CDP screencast at ~24 fps, frames re-timed from
|
||||
@@ -210,56 +211,84 @@ try {
|
||||
requestAnimationFrame(step);
|
||||
});
|
||||
},
|
||||
annotationSource() {
|
||||
for (let i = 0; i < viewer.dataSources.length; i++) {
|
||||
const source = viewer.dataSources.get(i);
|
||||
if (source.name === 'gev-annotations') return source;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
groundPrimitives() {
|
||||
/**
|
||||
* The annotations' primitives in the scene, each with the marks its
|
||||
* instances draw (their pick ids carry `meta.annotation`); only those
|
||||
* of `mark` when given.
|
||||
*/
|
||||
annotationPrimitives(mark) {
|
||||
const marksOf = (primitive) => {
|
||||
let inner = primitive;
|
||||
for (let depth = 0; inner && depth < 4; depth++) {
|
||||
if (Array.isArray(inner._instanceIds))
|
||||
return inner._instanceIds
|
||||
.map((id) => id?.meta?.annotation)
|
||||
.filter((id) => id !== undefined);
|
||||
inner = inner._primitive;
|
||||
}
|
||||
return [];
|
||||
};
|
||||
const list = [];
|
||||
const walk = (collection) => {
|
||||
for (let i = 0; i < collection.length; i++) {
|
||||
const item = collection.get(i);
|
||||
if (item?.length !== undefined && typeof item.get === 'function')
|
||||
walk(item);
|
||||
else list.push(item);
|
||||
else {
|
||||
const marks = marksOf(item);
|
||||
if (marks.length && (mark === undefined || marks.includes(mark)))
|
||||
list.push(item);
|
||||
}
|
||||
}
|
||||
};
|
||||
walk(viewer.scene.groundPrimitives);
|
||||
walk(viewer.scene.primitives);
|
||||
return list;
|
||||
},
|
||||
snapshot() {
|
||||
const source = this.annotationSource();
|
||||
const entities = source ? source.entities.values : [];
|
||||
const primitives = this.groundPrimitives();
|
||||
/** What `mark` draws (every annotation's, without one). */
|
||||
snapshot(mark) {
|
||||
const primitives = this.annotationPrimitives(mark);
|
||||
window.__qaPrimitiveIds ??= new WeakMap();
|
||||
let next = window.__qaPrimitiveNext ?? 1;
|
||||
const ids = primitives.map((primitive) => {
|
||||
if (!window.__qaPrimitiveIds.has(primitive))
|
||||
window.__qaPrimitiveIds.set(primitive, next++);
|
||||
return window.__qaPrimitiveIds.get(primitive);
|
||||
});
|
||||
// By identity only: hosts may trade places without a rebuild.
|
||||
const ids = primitives
|
||||
.map((primitive) => {
|
||||
if (!window.__qaPrimitiveIds.has(primitive))
|
||||
window.__qaPrimitiveIds.set(primitive, next++);
|
||||
return window.__qaPrimitiveIds.get(primitive);
|
||||
})
|
||||
.sort((a, b) => a - b);
|
||||
window.__qaPrimitiveNext = next;
|
||||
return {
|
||||
entities: entities.length,
|
||||
polygons: entities.filter((e) => e.polygon).length,
|
||||
polylines: entities.filter((e) => e.polyline).length,
|
||||
primitives: primitives.length,
|
||||
fills: primitives.filter((p) => p instanceof Cesium.GroundPrimitive)
|
||||
.length,
|
||||
lines: primitives.filter(
|
||||
(p) => p instanceof Cesium.GroundPolylinePrimitive,
|
||||
).length,
|
||||
// Draped on terrain and tiles alike.
|
||||
draped:
|
||||
entities.every(
|
||||
(e) =>
|
||||
!e.polygon ||
|
||||
e.polygon.classificationType?.getValue() ===
|
||||
Cesium.ClassificationType.BOTH,
|
||||
) &&
|
||||
entities.every(
|
||||
(e) => !e.polyline || e.polyline.clampToGround?.getValue(),
|
||||
primitives.length > 0 &&
|
||||
primitives.every(
|
||||
(p) => p.classificationType === Cesium.ClassificationType.BOTH,
|
||||
),
|
||||
primitiveIds: ids,
|
||||
ready: viewer.dataSourceDisplay.ready,
|
||||
ready: primitives.every((p) => p.ready),
|
||||
};
|
||||
},
|
||||
/** The annotations drawn under the middle of the view. */
|
||||
marksAtCentre() {
|
||||
const { canvas } = viewer.scene;
|
||||
const centre = new Cesium.Cartesian2(
|
||||
canvas.clientWidth / 2,
|
||||
canvas.clientHeight / 2,
|
||||
);
|
||||
const marks = new Set();
|
||||
for (const hit of viewer.scene.drillPick(centre, 16)) {
|
||||
const mark = hit?.id?.meta?.annotation;
|
||||
if (mark !== undefined) marks.add(mark);
|
||||
}
|
||||
return [...marks];
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
@@ -313,17 +342,31 @@ try {
|
||||
{ flyTo },
|
||||
);
|
||||
const resolvedMs = performance.now() - started;
|
||||
// "Drawn" = the first rendered frame after the entity visualizers have
|
||||
// built the mark's primitives (each tick updates them before render).
|
||||
// "Drawn" = the first rendered frame after the mark is drawn (as
|
||||
// before, when it was the entities' first frame); "ready" = the first
|
||||
// with its primitives all built, which may wait on Cesium's workers.
|
||||
const { viewer } = window.__godsEyeView;
|
||||
const markId = response.ids?.[0];
|
||||
let drawnMs = null;
|
||||
let readyMs = null;
|
||||
await new Promise((resolve) => {
|
||||
const off = viewer.scene.postRender.addEventListener(() => {
|
||||
if (!viewer.dataSourceDisplay.ready) return;
|
||||
const giveUp = setTimeout(done, 15_000);
|
||||
function done() {
|
||||
clearTimeout(giveUp);
|
||||
off();
|
||||
resolve();
|
||||
}
|
||||
const off = viewer.scene.postRender.addEventListener(() => {
|
||||
const now = performance.now() - started;
|
||||
drawnMs ??= now;
|
||||
const drawn = window.__qaOutlines.annotationPrimitives(markId);
|
||||
if (drawn.length && drawn.every((p) => p.ready)) {
|
||||
readyMs = now;
|
||||
done();
|
||||
}
|
||||
});
|
||||
viewer.scene.requestRender();
|
||||
});
|
||||
const drawnMs = performance.now() - started;
|
||||
const mark = window.__godsEyeView.annotations
|
||||
.list()
|
||||
.find((m) => m.id === response.ids?.[0]);
|
||||
@@ -331,6 +374,7 @@ try {
|
||||
response: response.results?.[0] ?? null,
|
||||
resolvedMs,
|
||||
drawnMs,
|
||||
readyMs,
|
||||
parts: mark?.polygons?.length ?? (mark?.ring ? 1 : 0),
|
||||
holes: (mark?.polygons ?? []).reduce(
|
||||
(n, part) => n + part.length - 1,
|
||||
@@ -338,6 +382,7 @@ try {
|
||||
),
|
||||
ringVertices: mark?.ring?.length ?? 0,
|
||||
pending: Boolean(mark?.pendingOutline),
|
||||
markId,
|
||||
};
|
||||
},
|
||||
target,
|
||||
@@ -347,23 +392,29 @@ try {
|
||||
await settle();
|
||||
// Hold still: the drawn mark must not rebuild or grow.
|
||||
marker = `still:${name}`;
|
||||
const before = await page.evaluate(() => window.__qaOutlines.snapshot());
|
||||
const before = await page.evaluate(
|
||||
(mark) => window.__qaOutlines.snapshot(mark),
|
||||
timing.markId,
|
||||
);
|
||||
const stillStart = frames.length;
|
||||
const times = await page.evaluate(
|
||||
(ms) => window.__qaOutlines.frameTimes(ms),
|
||||
STILL_MS,
|
||||
);
|
||||
const after = await page.evaluate(() => window.__qaOutlines.snapshot());
|
||||
const after = await page.evaluate(
|
||||
(mark) => window.__qaOutlines.snapshot(mark),
|
||||
timing.markId,
|
||||
);
|
||||
const step = {
|
||||
step: `outline:${name}`,
|
||||
target,
|
||||
...timing,
|
||||
entities: after.entities,
|
||||
polygons: after.polygons,
|
||||
polylines: after.polylines,
|
||||
primitives: after.primitives,
|
||||
fills: after.fills,
|
||||
lines: after.lines,
|
||||
draped: after.draped,
|
||||
stableWhileStill:
|
||||
before.entities === after.entities &&
|
||||
after.primitives > 0 &&
|
||||
JSON.stringify(before.primitiveIds) ===
|
||||
JSON.stringify(after.primitiveIds),
|
||||
stillFrameTimes: stats(times),
|
||||
@@ -375,6 +426,7 @@ try {
|
||||
result.steps.push(step);
|
||||
console.log(
|
||||
`${name}: resolved ${timing.resolvedMs.toFixed(0)} ms, drawn ${timing.drawnMs.toFixed(0)} ms, ` +
|
||||
`ready ${timing.readyMs?.toFixed(0)} ms, ` +
|
||||
`${timing.parts} part(s), ${timing.holes} hole(s), via ${timing.response?.resolvedVia}; ` +
|
||||
`still p50/p95 ${step.stillFrameTimes.p50}/${step.stillFrameTimes.p95} ms; ` +
|
||||
`stable=${step.stableWhileStill}`,
|
||||
@@ -387,6 +439,11 @@ try {
|
||||
timing.drawnMs < OUTLINE_BUDGET_MS,
|
||||
`${name}: drawn in ${timing.drawnMs} ms`,
|
||||
);
|
||||
assert.notEqual(timing.readyMs, null, `${name}: its primitives built`);
|
||||
assert.ok(
|
||||
step.fills > 0 && step.lines > 0,
|
||||
`${name}: drawn as a fill and an outline`,
|
||||
);
|
||||
assert.equal(step.draped, true, `${name}: draped on terrain/tiles`);
|
||||
assert.equal(step.stableWhileStill, true, `${name}: no redraw when still`);
|
||||
assert.deepEqual(step.lookups, [], `${name}: no network lookups`);
|
||||
@@ -512,8 +569,15 @@ try {
|
||||
await move(name, { lat, lon, height, pitch: -90 }, 1);
|
||||
await outline(name, target);
|
||||
await shot(name);
|
||||
const rendered = await page.evaluate(() => window.__qaOutlines.snapshot());
|
||||
assert.ok(rendered.polygons > 0, `${target} polygon renders`);
|
||||
const rendered = await page.evaluate(() => ({
|
||||
marks: window.__godsEyeView.annotations.list().map((m) => m.id),
|
||||
atCentre: window.__qaOutlines.marksAtCentre(),
|
||||
}));
|
||||
assert.ok(
|
||||
rendered.marks.length === 1 &&
|
||||
rendered.atCentre.includes(rendered.marks[0]),
|
||||
`${target} polygon renders`,
|
||||
);
|
||||
}
|
||||
|
||||
if (recordVideo) {
|
||||
@@ -632,6 +696,7 @@ console.table(
|
||||
step: s.step,
|
||||
resolvedMs: s.resolvedMs?.toFixed(0),
|
||||
drawnMs: s.drawnMs?.toFixed(0),
|
||||
readyMs: s.readyMs?.toFixed(0),
|
||||
parts: s.parts,
|
||||
stable: s.stableWhileStill,
|
||||
p50: (s.stillFrameTimes || s.frameTimes)?.p50,
|
||||
|
||||
@@ -127,7 +127,7 @@ try {
|
||||
let animeOn = false;
|
||||
for (let i = 0; i < s.postProcessStages.length; i++) {
|
||||
const stage = s.postProcessStages.get(i);
|
||||
if (stage.name === 'godsEyeView_anime')
|
||||
if (stage.name === 'effects_style_anime')
|
||||
animeOn = stage.enabled && stage.uniforms.intensity > 0.99;
|
||||
}
|
||||
return {
|
||||
|
||||
@@ -339,6 +339,45 @@ try {
|
||||
'#cctv-frame',
|
||||
(image) => !image.getAttribute('src') && image.dataset.cameraId === '',
|
||||
);
|
||||
// The address bar follows the share state after a short delay: wait for the
|
||||
// CCTV panel token (1 collapsed, 0 open) the step expects.
|
||||
const panelState = async (expectedToken) => {
|
||||
const settled = await page
|
||||
.waitForFunction(
|
||||
(token) =>
|
||||
new RegExp(`(?:^|_)v\\.c\\.${token}(?:_|$)`).test(
|
||||
new URLSearchParams(location.hash.slice(1)).get('ui') || '',
|
||||
),
|
||||
{ timeout: 5000 },
|
||||
expectedToken,
|
||||
)
|
||||
.then(
|
||||
() => true,
|
||||
() => false,
|
||||
);
|
||||
return page.evaluate(
|
||||
(shared) => ({
|
||||
collapsed: document
|
||||
.getElementById('cctv-panel')
|
||||
.classList.contains('collapsed'),
|
||||
shared,
|
||||
ui: new URLSearchParams(location.hash.slice(1)).get('ui'),
|
||||
}),
|
||||
settled ? expectedToken : null,
|
||||
);
|
||||
};
|
||||
const closedOnDisable = await panelState('1');
|
||||
check(
|
||||
'disable collapses the panel and its share preference',
|
||||
closedOnDisable.collapsed && closedOnDisable.shared === '1',
|
||||
JSON.stringify(closedOnDisable),
|
||||
);
|
||||
// The switch sits inside the collapsed panel: reopen it from the right rail.
|
||||
await page.click('[data-rail-item="cctv-panel"]');
|
||||
await page.waitForFunction(
|
||||
() =>
|
||||
!document.getElementById('cctv-panel').classList.contains('collapsed'),
|
||||
);
|
||||
await page.click('#cctv-enable-btn');
|
||||
await page.waitForFunction(
|
||||
() =>
|
||||
@@ -351,6 +390,42 @@ try {
|
||||
'disable clears the preview and re-enable reacquires the camera frame',
|
||||
disabledCleanly,
|
||||
);
|
||||
// Contacts switches CCTV off to isolate itself and restores it on the way
|
||||
// out: the open panel and its share preference survive the round trip.
|
||||
const cameraBeforeContacts = await page.evaluate(
|
||||
() =>
|
||||
window.__godsEyeView.styleManager._cctvControls.getState()
|
||||
?.activeCameraId,
|
||||
);
|
||||
const entered = await page.evaluate(() =>
|
||||
window.__godsEyeView.styleManager.setContextMode('flights'),
|
||||
);
|
||||
await page.waitForFunction(
|
||||
() => !window.__godsEyeView.dataManager.isEnabled('cctv'),
|
||||
);
|
||||
const duringContacts = await panelState('0');
|
||||
await page.evaluate(() =>
|
||||
window.__godsEyeView.styleManager.setContextMode(null),
|
||||
);
|
||||
await page.waitForFunction(() =>
|
||||
window.__godsEyeView.dataManager.isEnabled('cctv'),
|
||||
);
|
||||
const afterContacts = await panelState('0');
|
||||
check(
|
||||
'Contacts isolation keeps the open CCTV panel and restores its camera',
|
||||
entered?.ok === true &&
|
||||
!duringContacts.collapsed &&
|
||||
duringContacts.shared === '0' &&
|
||||
!afterContacts.collapsed &&
|
||||
afterContacts.shared === '0' &&
|
||||
(await page.evaluate(
|
||||
(cameraId) =>
|
||||
window.__godsEyeView.styleManager._cctvControls.getState()
|
||||
?.activeCameraId === cameraId,
|
||||
cameraBeforeContacts,
|
||||
)),
|
||||
JSON.stringify({ entered, duringContacts, afterContacts }),
|
||||
);
|
||||
await page.$eval('#cctv-frame', (image) =>
|
||||
image.scrollIntoView({ block: 'nearest' }),
|
||||
);
|
||||
|
||||
+61
-67
@@ -263,32 +263,30 @@ function installRenderFramesHelper(page) {
|
||||
|
||||
// In-page helper (stringified and re-defined inside each evaluate that needs
|
||||
// it, since functions can't cross the puppeteer boundary): serializes the
|
||||
// 5 frustum polylines + plane position/orientation/dimensions for a camera
|
||||
// into plain arrays of numbers, using only the camera's own clock time (no
|
||||
// Cesium namespace needed — Property.getValue just needs *a* JulianDate,
|
||||
// and the viewer's own clock.currentTime is a valid live instance of one).
|
||||
// 5 frustum lines + plane position/orientation/dimensions for a camera
|
||||
// into plain arrays of numbers, from what the layer reports it draws.
|
||||
const SERIALIZE_GEOM_SRC = `
|
||||
function serializeGeom(camId) {
|
||||
const viewer = window.__godsEyeView.viewer;
|
||||
const time = viewer.clock.currentTime;
|
||||
const drawn = window.__godsEyeView.dataManager.layers
|
||||
.get('cctv')
|
||||
.module._cctvDrawnForTest();
|
||||
const roles = ['ray-tl', 'ray-tr', 'ray-br', 'ray-bl', 'cap'];
|
||||
const poly = {};
|
||||
for (const role of roles) {
|
||||
const ent = viewer.entities.getById('cctv-' + camId + '-' + role);
|
||||
poly[role] = ent && ent.polyline
|
||||
? ent.polyline.positions.getValue(time).map((p) => [p.x, p.y, p.z])
|
||||
const line = drawn.coverage['cctv-' + camId + '-' + role];
|
||||
poly[role] = line?.positions
|
||||
? line.positions.map((p) => [p.x, p.y, p.z])
|
||||
: null;
|
||||
}
|
||||
const planeEnt = viewer.entities.getById('cctv-' + camId + '-plane');
|
||||
const quad = drawn.planes['cctv-' + camId + '-plane'];
|
||||
let plane = null;
|
||||
if (planeEnt) {
|
||||
const pos = planeEnt.position.getValue(time);
|
||||
const orient = planeEnt.orientation.getValue(time);
|
||||
const dims = planeEnt.plane.dimensions.getValue(time);
|
||||
if (quad) {
|
||||
const pos = quad.center;
|
||||
const orient = quad.orientation;
|
||||
plane = {
|
||||
position: [pos.x, pos.y, pos.z],
|
||||
orientation: [orient.x, orient.y, orient.z, orient.w],
|
||||
dimensions: [dims.x, dims.y],
|
||||
dimensions: [quad.size[0], quad.size[1]],
|
||||
};
|
||||
}
|
||||
return { poly, plane };
|
||||
@@ -695,10 +693,9 @@ async function main() {
|
||||
const camera = dataManager.layers
|
||||
.get('cctv')
|
||||
.module.getUIState().activeCamera;
|
||||
const ray = viewer.entities.getById(`cctv-${camera.id}-ray-tl`);
|
||||
const mount = ray?.polyline?.positions.getValue(
|
||||
viewer.clock.currentTime,
|
||||
)?.[0];
|
||||
const ray = dataManager.layers.get('cctv').module._cctvDrawnForTest()
|
||||
.coverage[`cctv-${camera.id}-ray-tl`];
|
||||
const mount = ray?.positions?.[0];
|
||||
const height =
|
||||
mount &&
|
||||
viewer.scene.globe.ellipsoid.cartesianToCartographic(mount)
|
||||
@@ -849,8 +846,10 @@ async function main() {
|
||||
// source. Assert the migrated surface via the host diagnostics.
|
||||
const diag = window.__gevWorldOverlay?.getDiagnostics?.();
|
||||
g.hasLabel = (diag?.entriesBySource?.['cctv-projection'] || 0) >= 1;
|
||||
const planeEnt = viewer.entities.getById('cctv-' + camId + '-plane');
|
||||
g.planeShow = planeEnt ? planeEnt.show : null;
|
||||
const quad = window.__godsEyeView.dataManager.layers
|
||||
.get('cctv')
|
||||
.module._cctvDrawnForTest().planes['cctv-' + camId + '-plane'];
|
||||
g.planeShow = quad ? quad.show : null;
|
||||
return g;
|
||||
})(${JSON.stringify(activeId)})`);
|
||||
|
||||
@@ -1212,26 +1211,22 @@ async function main() {
|
||||
console.log(
|
||||
'Checking frame-loop health (placeholder -> frame swap, URL family)...',
|
||||
);
|
||||
// The plane's material.image is always defined (placeholder canvas from
|
||||
// the moment the runtime is created, real frame content painted onto the
|
||||
// The plane's image is always defined (placeholder canvas from the
|
||||
// moment the runtime is created, real frame content painted onto the
|
||||
// same canvas/video reference once the fetch resolves) — assert it's
|
||||
// never null/undefined once the runtime exists, i.e. there's no gap where
|
||||
// the plane shows nothing.
|
||||
const materialInfo = await page.evaluate((camId) => {
|
||||
const viewer = window.__godsEyeView.viewer;
|
||||
const time = viewer.clock.currentTime;
|
||||
const planeEnt = viewer.entities.getById('cctv-' + camId + '-plane');
|
||||
const mat = planeEnt?.plane?.material;
|
||||
const image = mat?.image;
|
||||
const resolved =
|
||||
image && typeof image.getValue === 'function'
|
||||
? image.getValue(time)
|
||||
: image;
|
||||
const quad = window.__godsEyeView.dataManager.layers
|
||||
.get('cctv')
|
||||
.module._cctvDrawnForTest().planes['cctv-' + camId + '-plane'];
|
||||
const source = quad?.source;
|
||||
const resolved = source?.video || source?.canvas || source?.image;
|
||||
return {
|
||||
hasMaterial: !!mat,
|
||||
hasMaterial: !!source,
|
||||
hasImage: !!resolved,
|
||||
tagName: resolved?.tagName || null,
|
||||
show: planeEnt?.show,
|
||||
show: quad?.show,
|
||||
};
|
||||
}, activeId);
|
||||
record(
|
||||
@@ -1665,14 +1660,12 @@ async function main() {
|
||||
'Checking viewshed mode (coverage tri-state + color-coded volumes)...',
|
||||
);
|
||||
const countVolumes = () =>
|
||||
page.evaluate(() => {
|
||||
const prims = window.__godsEyeView.viewer.scene.primitives;
|
||||
let n = 0;
|
||||
for (let i = 0; i < prims.length; i++) {
|
||||
if (prims.get(i) && prims.get(i)._gevViewshed) n += 1;
|
||||
}
|
||||
return n;
|
||||
});
|
||||
page.evaluate(
|
||||
() =>
|
||||
window.__godsEyeView.dataManager.layers
|
||||
.get('cctv')
|
||||
.module._cctvDrawnForTest().viewsheds.length,
|
||||
);
|
||||
|
||||
const cBeforeViewshed = await readCounters();
|
||||
const modeAfterSet = await page.evaluate(() => {
|
||||
@@ -1725,26 +1718,26 @@ async function main() {
|
||||
mod.setParams({ coverageMode: 'viewshed' });
|
||||
});
|
||||
await sleep(400);
|
||||
await page.evaluate(() => {
|
||||
const prims = window.__godsEyeView.viewer.scene.primitives;
|
||||
window.__qaViewshedRefs = [];
|
||||
for (let i = 0; i < prims.length; i++) {
|
||||
if (prims.get(i) && prims.get(i)._gevViewshed)
|
||||
window.__qaViewshedRefs.push(prims.get(i));
|
||||
}
|
||||
});
|
||||
// Volumes are draw-port mesh items: "no churn" is no volume written.
|
||||
const drawnViewsheds = () =>
|
||||
page.evaluate(() => {
|
||||
const drawn = window.__godsEyeView.dataManager.layers
|
||||
.get('cctv')
|
||||
.module._cctvDrawnForTest();
|
||||
return { ids: drawn.viewsheds, writes: drawn.viewshedWrites };
|
||||
});
|
||||
const viewshedsBefore = await drawnViewsheds();
|
||||
await sleep(8000);
|
||||
const viewshedIdle = await page.evaluate(() => {
|
||||
const prims = window.__godsEyeView.viewer.scene.primitives;
|
||||
const now = [];
|
||||
for (let i = 0; i < prims.length; i++) {
|
||||
if (prims.get(i) && prims.get(i)._gevViewshed) now.push(prims.get(i));
|
||||
}
|
||||
const before = window.__qaViewshedRefs || [];
|
||||
const sameCount = now.length === before.length;
|
||||
const sameIdentity = sameCount && before.every((p) => now.includes(p));
|
||||
return { sameCount, sameIdentity, count: now.length };
|
||||
});
|
||||
const viewshedsAfter = await drawnViewsheds();
|
||||
const viewshedIdle = (() => {
|
||||
const sameCount =
|
||||
viewshedsAfter.ids.length === viewshedsBefore.ids.length;
|
||||
const sameIdentity =
|
||||
sameCount &&
|
||||
viewshedsBefore.ids.every((id) => viewshedsAfter.ids.includes(id)) &&
|
||||
viewshedsAfter.writes === viewshedsBefore.writes;
|
||||
return { sameCount, sameIdentity, count: viewshedsAfter.ids.length };
|
||||
})();
|
||||
const cAfterViewshed = await readCounters();
|
||||
const lateFloorSamples =
|
||||
cAfterViewshed.sampleHeight - cBeforeViewshed.sampleHeight;
|
||||
@@ -1785,9 +1778,9 @@ async function main() {
|
||||
const gizmoStates = await page.evaluate((parts) => {
|
||||
const mod = window.__godsEyeView.dataManager.layers.get('cctv').module;
|
||||
mod.setParams({ calibrationMode: true });
|
||||
const viewer = window.__godsEyeView.viewer;
|
||||
const drawn = mod._cctvDrawnForTest().gizmo;
|
||||
return parts.map((p) => {
|
||||
const e = viewer.entities.getById('cctv-gizmo-' + p);
|
||||
const e = drawn['cctv-gizmo-' + p];
|
||||
return e ? (e.show ? 'shown' : 'hidden') : 'missing';
|
||||
});
|
||||
}, GIZMO_PARTS);
|
||||
@@ -1802,9 +1795,10 @@ async function main() {
|
||||
// stay frozen until release, with no transient sampleHeight calls.
|
||||
const eastDrag = await page.evaluate(() => {
|
||||
const viewer = window.__godsEyeView.viewer;
|
||||
const e = viewer.entities.getById('cctv-gizmo-move-east');
|
||||
const mod = window.__godsEyeView.dataManager.layers.get('cctv').module;
|
||||
const e = mod._cctvDrawnForTest().gizmo['cctv-gizmo-move-east'];
|
||||
if (!e) return null;
|
||||
const pts = e.polyline.positions.getValue(viewer.clock.currentTime);
|
||||
const pts = e.positions;
|
||||
const scene = viewer.scene;
|
||||
const w = scene.canvas.clientWidth;
|
||||
const h = scene.canvas.clientHeight;
|
||||
@@ -2082,9 +2076,9 @@ async function main() {
|
||||
const mod = window.__godsEyeView.dataManager.layers.get('cctv').module;
|
||||
mod.setParams({ calibrationMode: false });
|
||||
mod.setParams({ calibration: { reset: true } });
|
||||
const viewer = window.__godsEyeView.viewer;
|
||||
const drawn = mod._cctvDrawnForTest().gizmo;
|
||||
return parts.map((p) => {
|
||||
const e = viewer.entities.getById('cctv-gizmo-' + p);
|
||||
const e = drawn['cctv-gizmo-' + p];
|
||||
return e ? (e.show ? 'shown' : 'hidden') : 'missing';
|
||||
});
|
||||
}, GIZMO_PARTS);
|
||||
|
||||
@@ -765,7 +765,7 @@ try {
|
||||
} : null,
|
||||
navigation: snapshot?.navigation || null,
|
||||
afterId: trackedInfo?.icao24 || null,
|
||||
viewerTrackedId: viewer.trackedEntity?.gevTrackedId || null,
|
||||
viewerTrackedId: window.__godsEyeView.entityRecords.read(viewer.trackedEntity)?.trackedId || null,
|
||||
contextVisible: !document.getElementById('military-awareness-panel')?.hidden,
|
||||
entryAvailableAfterSettlement: Boolean(entry && !entry.hidden),
|
||||
blockerStillRegistered: dataManager.layers.has(blockerId),
|
||||
@@ -1365,7 +1365,7 @@ try {
|
||||
contextMode: styleManager._contextControls._contextMode,
|
||||
contextChanging: styleManager._contextControls._contextModeChanging,
|
||||
subject: context?.subject ? `${context.subject.layerId}:${context.subject.id}` : null,
|
||||
tracked: tracker?.gevTrackedId || null,
|
||||
tracked: window.__godsEyeView.entityRecords.read(tracker)?.trackedId || null,
|
||||
density: styleManager.getDetectionState().densityPct,
|
||||
detectionMode: styleManager.getDetectionState().detectionMode,
|
||||
installations: dataManager.getLayerLifecycleState('military-installations'),
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Run the renderer conformance logic suite on the Cesium renderer in
|
||||
* headless Chromium (`dev/conformance/`, `window.conformance.runLogic`),
|
||||
* and fail on any failed check, or on a skip that is not expected.
|
||||
*
|
||||
* Without `--url` it starts a Vite dev server of this checkout on `--port`
|
||||
* (default 5289) and stops it after. WebGL runs on SwiftShader, so the run
|
||||
* needs no GPU. `--only id,id` runs just those checks; `--json path` writes
|
||||
* the report.
|
||||
*
|
||||
* npm run qa:conformance [-- --url http://127.0.0.1:5280] [--only ids]
|
||||
* [--json path]
|
||||
*/
|
||||
import { writeFileSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import puppeteer from 'puppeteer';
|
||||
|
||||
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
|
||||
/** Checks the run skips, with why: anything else skipped fails it. */
|
||||
export const EXPECTED_SKIPS = Object.freeze({
|
||||
// The page scripts no heights for the Cesium renderer.
|
||||
'query.heights': 'no scripted heights in this harness',
|
||||
});
|
||||
|
||||
/** A whole run has this long; a check that hangs fails it rather than CI. */
|
||||
const RUN_TIMEOUT_MS = 15 * 60_000;
|
||||
|
||||
function parseArgs(argv) {
|
||||
const args = { port: 5289 };
|
||||
for (let i = 0; i < argv.length; i++) {
|
||||
const arg = argv[i];
|
||||
if (arg === '--url') args.url = argv[++i];
|
||||
else if (arg === '--port') args.port = Number(argv[++i]);
|
||||
else if (arg === '--only') args.only = argv[++i].split(',');
|
||||
else if (arg === '--json') args.json = argv[++i];
|
||||
else throw new Error(`Unknown argument: ${arg}`);
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
async function startViteServer(port) {
|
||||
const { createServer } = await import('vite');
|
||||
const server = await createServer({
|
||||
root: ROOT,
|
||||
configFile: path.join(ROOT, 'vite.config.js'),
|
||||
// No hot reload: the page is loaded once and nothing edits it.
|
||||
server: { port, strictPort: true, host: '127.0.0.1', hmr: false },
|
||||
logLevel: 'warn',
|
||||
});
|
||||
await server.listen();
|
||||
return server;
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const args = parseArgs(process.argv.slice(2));
|
||||
const server = args.url ? null : await startViteServer(args.port);
|
||||
try {
|
||||
await run(args);
|
||||
} finally {
|
||||
await server?.close();
|
||||
}
|
||||
}
|
||||
|
||||
async function run(args) {
|
||||
const base = (args.url ?? `http://127.0.0.1:${args.port}`).replace(/\/$/, '');
|
||||
const browser = await puppeteer.launch({
|
||||
headless: true,
|
||||
executablePath:
|
||||
process.env.PUPPETEER_EXECUTABLE_PATH ||
|
||||
(await puppeteer.executablePath()),
|
||||
defaultViewport: { width: 1280, height: 800 },
|
||||
protocolTimeout: RUN_TIMEOUT_MS,
|
||||
args: ['--no-sandbox', '--use-gl=angle', '--use-angle=swiftshader'],
|
||||
});
|
||||
const pageErrors = [];
|
||||
let report;
|
||||
try {
|
||||
const page = await browser.newPage();
|
||||
page.on('pageerror', (error) => pageErrors.push(error.message));
|
||||
await page.goto(`${base}/dev/conformance/`, { waitUntil: 'load' });
|
||||
await page.waitForFunction(() => window.conformance?.runLogic, {
|
||||
timeout: 120_000,
|
||||
});
|
||||
report = await page.evaluate(
|
||||
(only) => window.conformance.runLogic('cesium', { only }),
|
||||
args.only ?? null,
|
||||
);
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
if (args.json) writeFileSync(args.json, JSON.stringify(report, null, 2));
|
||||
console.log(
|
||||
`cesium: ${report.passed} passed, ${report.failed} failed, ${report.skipped} skipped`,
|
||||
);
|
||||
const problems = [];
|
||||
for (const failure of report.failures) {
|
||||
console.error(`fail\t${failure.id}\t${failure.detail ?? ''}`);
|
||||
problems.push(failure.id);
|
||||
}
|
||||
for (const skip of report.skips) {
|
||||
const expected = EXPECTED_SKIPS[skip.id] === skip.detail;
|
||||
console.log(`skip\t${skip.id}\t${skip.detail ?? ''}`);
|
||||
if (!expected) problems.push(`${skip.id} skipped`);
|
||||
}
|
||||
if (!args.only && report.passed === 0) problems.push('nothing passed');
|
||||
if (problems.length) {
|
||||
console.error(`FAIL: ${problems.join('; ')}`);
|
||||
process.exitCode = 1;
|
||||
} else console.log('ok: the Cesium renderer passes the conformance suite');
|
||||
}
|
||||
|
||||
if (import.meta.url === `file://${process.argv[1]}`)
|
||||
main().catch((error) => {
|
||||
console.error(error);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
@@ -362,7 +362,9 @@ async function contacts() {
|
||||
entities: ds?.entities.values.length ?? 0,
|
||||
created,
|
||||
tracked:
|
||||
window.__godsEyeView.viewer.trackedEntity?.gevTrackedId ?? null,
|
||||
window.__godsEyeView.entityRecords.read(
|
||||
window.__godsEyeView.viewer.trackedEntity,
|
||||
)?.trackedId ?? null,
|
||||
cockpit: document.body.classList.contains('cockpit-mode'),
|
||||
});
|
||||
if (samples.length > 5000) samples.splice(0, 1000);
|
||||
@@ -377,8 +379,9 @@ async function contacts() {
|
||||
await page
|
||||
.waitForFunction(
|
||||
() =>
|
||||
window.__godsEyeView.viewer.trackedEntity?.gevTrackedId ===
|
||||
'flights:aaa051',
|
||||
window.__godsEyeView.entityRecords.read(
|
||||
window.__godsEyeView.viewer.trackedEntity,
|
||||
)?.trackedId === 'flights:aaa051',
|
||||
{ timeout: 60_000 },
|
||||
)
|
||||
.catch(() => {});
|
||||
|
||||
+18
-28
@@ -645,44 +645,34 @@ try {
|
||||
`owner=${afterClear.pointerOwner}`,
|
||||
);
|
||||
|
||||
// ── 8. A tool holding the pointer blocks placement, and says so. ─────────
|
||||
// ── 8. Arming takes the pointer from a tool holding it, which is told. ──
|
||||
await page.evaluate(() => {
|
||||
window.__gevQaDrawLost = 0;
|
||||
// A claim answers with a lease; the release takes that lease back.
|
||||
window.__gevQaDrawLease = window.__gevQa.claimPointer('draw');
|
||||
window.__gevQaDrawLease = window.__gevQa.claimPointer('draw', {
|
||||
onLost: () => (window.__gevQaDrawLost += 1),
|
||||
});
|
||||
});
|
||||
await clickChip('set-a');
|
||||
const blocked = await layerState();
|
||||
const taken = await layerState();
|
||||
const lost = await page.evaluate(() => window.__gevQaDrawLost);
|
||||
check(
|
||||
"another tool's pointer claim is never stolen",
|
||||
blocked.pointerOwner === 'draw',
|
||||
`owner=${blocked.pointerOwner}`,
|
||||
'the newest claim takes over: Directions holds the pointer',
|
||||
taken.pointerOwner === 'directions',
|
||||
`owner=${taken.pointerOwner}`,
|
||||
);
|
||||
check('the tool it replaced is told once', lost === 1, `told=${lost}`);
|
||||
check(
|
||||
'nothing is armed, and the row says why the click would do nothing',
|
||||
blocked.chips.find((chip) => chip.id === 'set-a')?.active === false &&
|
||||
/Another map tool/.test(blocked.stats.error || ''),
|
||||
blocked.stats.error,
|
||||
'SET A is armed, and the row has nothing to complain of',
|
||||
taken.chips.find((chip) => chip.id === 'set-a')?.active === true &&
|
||||
!taken.stats.error,
|
||||
taken.stats.error,
|
||||
);
|
||||
// The row is not where the operator is looking after pressing a chip, so the
|
||||
// refusal also has to reach the app's toast (owner field test).
|
||||
const toast = await page.evaluate(() => {
|
||||
const node = document.getElementById('toast');
|
||||
return {
|
||||
text: node?.textContent || '',
|
||||
visible: !!node?.classList.contains('visible'),
|
||||
};
|
||||
});
|
||||
check(
|
||||
'the refusal reaches the app toast, naming the tool and how to leave it',
|
||||
/Draw is active/.test(toast.text) && /then set A/.test(toast.text),
|
||||
JSON.stringify(toast.text),
|
||||
);
|
||||
check('and that toast is actually on screen', toast.visible);
|
||||
await shot(`05-${LABEL}-pointer-blocked-toast.jpg`);
|
||||
const released = await page.evaluate(() =>
|
||||
const staleReleased = await page.evaluate(() =>
|
||||
window.__gevQa.releasePointer(window.__gevQaDrawLease),
|
||||
);
|
||||
check('and it gets the pointer back when it lets go', released);
|
||||
check("the replaced tool's late release frees nothing", !staleReleased);
|
||||
await clickChip('set-a');
|
||||
|
||||
// ── 9. Denver: maneuver dots sit on the ground, not at sea level. ────────
|
||||
if (!SKIP.has('denver')) {
|
||||
|
||||
@@ -116,7 +116,7 @@ try {
|
||||
document.getElementById('loading-screen')?.classList.contains('hidden'),
|
||||
{ timeout: 60000 },
|
||||
);
|
||||
await page.click('[data-collapse-target="scene-panel"]');
|
||||
await page.click('[data-rail-item="scene-panel"]');
|
||||
const before = await page.evaluate(() =>
|
||||
JSON.stringify(window.__godsEyeView.sceneDirector._project),
|
||||
);
|
||||
@@ -304,18 +304,17 @@ try {
|
||||
window.__godsEyeView.sceneDirector.getInteractionState().count === 1,
|
||||
)),
|
||||
);
|
||||
await page.waitForFunction(
|
||||
() => window.__godsEyeView.tileset?.tilesLoaded === true,
|
||||
{ timeout: 60000 },
|
||||
);
|
||||
const activeMapReady = () => {
|
||||
const { viewer, mapStackController } = window.__godsEyeView;
|
||||
const tileset = mapStackController.getImageryHostTileset();
|
||||
if (tileset) return tileset.tilesLoaded;
|
||||
return viewer.scene.globe.show && viewer.scene.globe.tilesLoaded;
|
||||
};
|
||||
await page.waitForFunction(activeMapReady, { timeout: 60000 });
|
||||
await page.screenshot({ path: path.join(output, 'rendered.png') });
|
||||
fs.writeFileSync(
|
||||
path.join(output, 'report.json'),
|
||||
JSON.stringify(
|
||||
await page.evaluate(() => ({
|
||||
tilesSettled: window.__godsEyeView.tileset?.tilesLoaded === true,
|
||||
})),
|
||||
),
|
||||
JSON.stringify({ tilesSettled: await page.evaluate(activeMapReady) }),
|
||||
);
|
||||
await page.evaluate(() => window.__godsEyeView.sceneDirector.stopScene());
|
||||
check(
|
||||
@@ -368,6 +367,16 @@ try {
|
||||
);
|
||||
await page.screenshot({ path: path.join(output, 'narrow.png') });
|
||||
await page.keyboard.press('Escape');
|
||||
await page.setViewport({ width: 1440, height: 900 });
|
||||
await page.waitForSelector('[data-rail-item="scene-panel"]', {
|
||||
visible: true,
|
||||
});
|
||||
if (
|
||||
await page.$eval('#scene-panel', (panel) =>
|
||||
panel.classList.contains('collapsed'),
|
||||
)
|
||||
)
|
||||
await page.click('[data-rail-item="scene-panel"]');
|
||||
const pending = await page.evaluate(async () => {
|
||||
const d = window.__godsEyeView.sceneDirector;
|
||||
let finish;
|
||||
|
||||
+299
-148
@@ -65,6 +65,27 @@ const LINE_CLIP = { x: 390, y: 200, width: 510, height: 380 };
|
||||
const canvasShot = () =>
|
||||
page.screenshot({ clip: LINE_CLIP, type: 'png', encoding: 'base64' });
|
||||
|
||||
/**
|
||||
* `canvasShot` once the globe has no imagery or terrain tiles left to load
|
||||
* (bounded: a view that never settles is shot as it is, and the comparison
|
||||
* then reports what it sees). `globe.tilesLoaded` covers the globe only: a
|
||||
* 3D Tiles tileset on a keyed server can still be refining when it is true.
|
||||
*/
|
||||
async function settledCanvasShot() {
|
||||
await page
|
||||
.waitForFunction(
|
||||
() => {
|
||||
const scene = window.__godsEyeView.viewer.scene;
|
||||
scene.requestRender();
|
||||
return scene.globe.tilesLoaded;
|
||||
},
|
||||
{ timeout: 15_000, polling: 100 },
|
||||
)
|
||||
.catch(() => {});
|
||||
await wait(200);
|
||||
return canvasShot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Amber pixels in one shot that are not amber in another of the same view:
|
||||
* a mark's own pixels, apart from imagery and panels that both shots share.
|
||||
@@ -263,39 +284,16 @@ try {
|
||||
}),
|
||||
);
|
||||
|
||||
// The viewer's OWN click actions, captured before the tool ever runs. Both
|
||||
// must be absent while drawing and back — as the SAME functions — after.
|
||||
await page.evaluate(() => {
|
||||
const Cesium = window.__CESIUM__;
|
||||
const stock = window.__godsEyeView.viewer.screenSpaceEventHandler;
|
||||
window.__qaStock = {
|
||||
click:
|
||||
stock.getInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK) || null,
|
||||
double:
|
||||
stock.getInputAction(Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK) ||
|
||||
null,
|
||||
// The viewer's own select and follow, which the input port runs: on before
|
||||
// the tool runs, off while drawing, and on again after.
|
||||
const stockActions = async () => {
|
||||
const state = await drawState();
|
||||
return {
|
||||
clickOn: state.stockSingleClick,
|
||||
doubleOn: state.stockDoubleClick,
|
||||
};
|
||||
});
|
||||
const stockActions = () =>
|
||||
page.evaluate(() => {
|
||||
const Cesium = window.__CESIUM__;
|
||||
const stock = window.__godsEyeView.viewer.screenSpaceEventHandler;
|
||||
const live = {
|
||||
click:
|
||||
stock.getInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK) || null,
|
||||
double:
|
||||
stock.getInputAction(Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK) ||
|
||||
null,
|
||||
};
|
||||
return {
|
||||
clickPresent: Boolean(live.click),
|
||||
doublePresent: Boolean(live.double),
|
||||
clickIsOriginal: live.click === window.__qaStock.click,
|
||||
doubleIsOriginal: live.double === window.__qaStock.double,
|
||||
hadClick: Boolean(window.__qaStock.click),
|
||||
hadDouble: Boolean(window.__qaStock.double),
|
||||
};
|
||||
});
|
||||
};
|
||||
const beforeDraw = await stockActions();
|
||||
|
||||
// ── enable / disable cycles leave nothing behind ────────────────────────
|
||||
const before = await drawState();
|
||||
@@ -307,35 +305,32 @@ try {
|
||||
}
|
||||
const after = await drawState();
|
||||
check(
|
||||
'three enable/disable cycles add no listener, handler or preview data source',
|
||||
'three enable/disable cycles add no listener, handler or preview set',
|
||||
after.domListeners === before.domListeners &&
|
||||
after.previewDataSources === 1 &&
|
||||
before.previewDataSources === 1 &&
|
||||
after.previewSets === 2 &&
|
||||
before.previewSets === 2 &&
|
||||
after.sceneHandler === false &&
|
||||
after.pointerOwner === null &&
|
||||
after.stockDoubleClick === before.stockDoubleClick,
|
||||
`listeners ${before.domListeners}→${after.domListeners}, previews ${after.previewDataSources}, ` +
|
||||
`listeners ${before.domListeners}→${after.domListeners}, previews ${after.previewSets}, ` +
|
||||
`handler ${after.sceneHandler}, owner ${after.pointerOwner}, stock dblclick ${after.stockDoubleClick}`,
|
||||
);
|
||||
|
||||
// ── the viewer's own click actions are borrowed, then given back ────────
|
||||
// ── the viewer's own click actions are held off, then given back ───────
|
||||
await page.click('#draw-toggle');
|
||||
const duringDraw = await stockActions();
|
||||
check(
|
||||
"Cesium's own selecting click and tracking double-click are both borrowed while drawing",
|
||||
duringDraw.clickPresent === false && duringDraw.doublePresent === false,
|
||||
`click present ${duringDraw.clickPresent}, double present ${duringDraw.doublePresent} ` +
|
||||
`(viewer had click ${duringDraw.hadClick}, double ${duringDraw.hadDouble})`,
|
||||
"Cesium's own selecting click and tracking double-click are both off while drawing",
|
||||
duringDraw.clickOn === false && duringDraw.doubleOn === false,
|
||||
JSON.stringify({ beforeDraw, duringDraw }),
|
||||
);
|
||||
await page.click('#draw-toggle');
|
||||
const afterDraw = await stockActions();
|
||||
check(
|
||||
'and both are restored as the SAME functions, not replacements',
|
||||
afterDraw.clickPresent === duringDraw.hadClick &&
|
||||
afterDraw.doublePresent === duringDraw.hadDouble &&
|
||||
afterDraw.clickIsOriginal &&
|
||||
afterDraw.doubleIsOriginal,
|
||||
JSON.stringify(afterDraw),
|
||||
'and both are back after',
|
||||
afterDraw.clickOn === beforeDraw.clickOn &&
|
||||
afterDraw.doubleOn === beforeDraw.doubleOn,
|
||||
JSON.stringify({ beforeDraw, afterDraw }),
|
||||
);
|
||||
|
||||
// ── a pin, finished with Enter ──────────────────────────────────────────
|
||||
@@ -531,12 +526,26 @@ try {
|
||||
await page.click(rowControl(lineId, 'swatch'));
|
||||
await page.click(rowControl(lineId, 'color-amber'));
|
||||
await markReaches(lineId, { color: 'amber', alpha: 1 });
|
||||
// Only the Line is on the board for its shots. The area's fill pulses, and
|
||||
// under it borderline roofs drift into and out of amber between two shots
|
||||
// of an unchanged scene, on the old build as on this one.
|
||||
const others = await page.evaluate((id) => {
|
||||
const marks = window.__gevAnnotations.list();
|
||||
const ids = marks.filter((m) => m.id !== id && !m.hidden).map((m) => m.id);
|
||||
for (const other of ids) window.__gevAnnotations.setHidden(other, true);
|
||||
return ids;
|
||||
}, lineId);
|
||||
for (const other of others)
|
||||
await markReaches(other, { hidden: true, alpha: 0 });
|
||||
await wait(800);
|
||||
const shown = await canvasShot();
|
||||
// The fly-to above is still refining imagery near the camera at this
|
||||
// point; a tile that sharpens between the two shots repaints roofs into
|
||||
// and out of amber, so each shot waits for the globe to finish loading.
|
||||
const shown = await settledCanvasShot();
|
||||
await page.click(rowControl(lineId, 'toggle'));
|
||||
await markReaches(lineId, { hidden: true, alpha: 0 });
|
||||
await wait(800);
|
||||
const hiddenShot = await canvasShot();
|
||||
const hiddenShot = await settledCanvasShot();
|
||||
// Amber the shown line had and the hidden one lost; amber that appears
|
||||
// only once it is hidden is noise, and must stay small beside it.
|
||||
const gone = await amberOnlyIn(shown, hiddenShot);
|
||||
@@ -548,12 +557,24 @@ try {
|
||||
);
|
||||
await page.click(rowControl(lineId, 'toggle'));
|
||||
await wait(1200);
|
||||
const back = await amberOnlyIn(await canvasShot(), hiddenShot);
|
||||
const back = await amberOnlyIn(await settledCanvasShot(), hiddenShot);
|
||||
check(
|
||||
'and paints again when shown',
|
||||
back > gone * 0.5,
|
||||
`${back} of ${gone} line pixels back`,
|
||||
);
|
||||
await page.evaluate((ids) => {
|
||||
for (const other of ids) window.__gevAnnotations.setHidden(other, false);
|
||||
}, others);
|
||||
const restored = [];
|
||||
for (const other of others)
|
||||
if (await markReaches(other, { hidden: false, alpha: 1 }))
|
||||
restored.push(other);
|
||||
check(
|
||||
'the marks set aside for the Line shots are back on the board',
|
||||
restored.length === others.length,
|
||||
`${restored.length} of ${others.length} back`,
|
||||
);
|
||||
await shot('03-pins-and-shapes');
|
||||
|
||||
// ── Escape cancels the shape, a second Escape leaves draw mode ──────────
|
||||
@@ -601,32 +622,87 @@ try {
|
||||
: 'no CCTV camera or bundled site could be reached — the ownership case cannot be proved',
|
||||
);
|
||||
if (target) {
|
||||
// The camera pose the target was found at: a selecting click flies the
|
||||
// camera to what it picked, so the drawing click has to come back here
|
||||
// and find the target again, or it would land on plain ground.
|
||||
await page.evaluate(() => {
|
||||
const camera = window.__godsEyeView.viewer.camera;
|
||||
window.__qaTargetView = {
|
||||
destination: camera.positionWC.clone(),
|
||||
orientation: {
|
||||
heading: camera.heading,
|
||||
pitch: camera.pitch,
|
||||
roll: camera.roll,
|
||||
},
|
||||
};
|
||||
});
|
||||
await page.evaluate(clearSelection);
|
||||
await page.evaluate(startSelectionCount);
|
||||
await clickWorld(target.x, target.y, { settle: 900 });
|
||||
const selectedNormally = await page.evaluate(() =>
|
||||
Boolean(window.__godsEyeView.viewer.selectedEntity),
|
||||
);
|
||||
const normal = await page.evaluate(readSelectionCount, target.key);
|
||||
check(
|
||||
`clicking a ${target.layer} selects it when nothing owns the pointer`,
|
||||
selectedNormally,
|
||||
// The CCTV branch looks for `CAM-` Cesium entities and reads the
|
||||
// viewer's selection; neither build draws cameras that way any more, so
|
||||
// it is not reached and the bundled data centre is the target.
|
||||
normal.item > 0 || (target.layerId === 'cctv' && normal.entity),
|
||||
`${normal.item} selection(s) of ${target.key}, ${normal.all} in all, entity ${normal.entity}`,
|
||||
);
|
||||
await page.evaluate(clearSelection);
|
||||
await page.evaluate(() => {
|
||||
window.__godsEyeView.viewer.selectedEntity = undefined;
|
||||
const viewer = window.__godsEyeView.viewer;
|
||||
viewer.camera.cancelFlight?.();
|
||||
viewer.camera.setView(window.__qaTargetView);
|
||||
viewer.scene.requestRender();
|
||||
});
|
||||
await page.click('#draw-toggle');
|
||||
await page.click('.pp-mode-btn[data-shape="area"]');
|
||||
await clickWorld(target.x, target.y, { settle: 900 });
|
||||
const whileDrawing = await drawState();
|
||||
const selectedWhileDrawing = await page.evaluate(() =>
|
||||
Boolean(window.__godsEyeView.viewer.selectedEntity),
|
||||
await wait(1500);
|
||||
const again = await onScreen(
|
||||
target.belongs,
|
||||
target.contextPrefix,
|
||||
target.key,
|
||||
);
|
||||
check(
|
||||
`clicking the same ${target.layer} while drawing adds a vertex and selects nothing`,
|
||||
whileDrawing.vertices === 1 && selectedWhileDrawing === false,
|
||||
`vertices ${whileDrawing.vertices}, selected ${selectedWhileDrawing}`,
|
||||
`the ${target.layer} is picked again after the camera returns`,
|
||||
Boolean(again),
|
||||
again ? `at ${again.x},${again.y}` : 'not picked on screen any more',
|
||||
);
|
||||
await page.keyboard.press('Escape');
|
||||
await page.keyboard.press('Escape');
|
||||
await wait(150);
|
||||
if (again) {
|
||||
await page.click('#draw-toggle');
|
||||
await page.click('.pp-mode-btn[data-shape="area"]');
|
||||
// Draw mode's own panel must not have covered it: the drawing click has
|
||||
// to land on the same item, not on plain ground.
|
||||
const drawingSpot = await onScreen(
|
||||
target.belongs,
|
||||
target.contextPrefix,
|
||||
target.key,
|
||||
);
|
||||
check(
|
||||
`the ${target.layer} is still picked once draw mode is open`,
|
||||
Boolean(drawingSpot),
|
||||
drawingSpot
|
||||
? `at ${drawingSpot.x},${drawingSpot.y}`
|
||||
: 'not picked on screen in draw mode',
|
||||
);
|
||||
if (drawingSpot) {
|
||||
await page.evaluate(startSelectionCount);
|
||||
await clickWorld(drawingSpot.x, drawingSpot.y, { settle: 900 });
|
||||
const whileDrawing = await drawState();
|
||||
const drawingSelection = await page.evaluate(
|
||||
readSelectionCount,
|
||||
target.key,
|
||||
);
|
||||
check(
|
||||
`clicking the same ${target.layer} while drawing adds a vertex and selects nothing`,
|
||||
whileDrawing.vertices === 1 &&
|
||||
drawingSelection.all === 0 &&
|
||||
!drawingSelection.entity,
|
||||
`vertices ${whileDrawing.vertices}, ${drawingSelection.all} selection(s), entity ${drawingSelection.entity}`,
|
||||
);
|
||||
}
|
||||
await page.keyboard.press('Escape');
|
||||
await page.keyboard.press('Escape');
|
||||
await wait(150);
|
||||
}
|
||||
}
|
||||
|
||||
// ── what a reload actually does ─────────────────────────────────────────
|
||||
@@ -664,19 +740,6 @@ try {
|
||||
document.getElementById('draw-toggle')?.getBoundingClientRect().width > 0,
|
||||
{ timeout: 10_000 },
|
||||
);
|
||||
// The reload built a new page context: re-capture the viewer's own click
|
||||
// actions so the identity comparisons below still mean something.
|
||||
await page.evaluate(() => {
|
||||
const Cesium = window.__CESIUM__;
|
||||
const stock = window.__godsEyeView.viewer.screenSpaceEventHandler;
|
||||
window.__qaStock = {
|
||||
click:
|
||||
stock.getInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK) || null,
|
||||
double:
|
||||
stock.getInputAction(Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK) ||
|
||||
null,
|
||||
};
|
||||
});
|
||||
await page.evaluate((view) => {
|
||||
const viewer = window.__godsEyeView.viewer;
|
||||
viewer.camera.cancelFlight?.();
|
||||
@@ -813,13 +876,10 @@ try {
|
||||
finalState.active === false &&
|
||||
finalState.pointerOwner === null &&
|
||||
finalState.sceneHandler === false &&
|
||||
finalState.previewDataSources === 1,
|
||||
finalState.previewSets === 2,
|
||||
JSON.stringify(finalState),
|
||||
);
|
||||
// ── destroy(): the shell disposing the tool leaves nothing behind ───────
|
||||
const beforeDestroy = await page.evaluate(
|
||||
() => window.__godsEyeView.viewer.dataSources.length,
|
||||
);
|
||||
await page.click('#draw-toggle'); // destroy from an ACTIVE session: the harder case
|
||||
await wait(200);
|
||||
const destroyed = await page.evaluate(async () => {
|
||||
@@ -827,24 +887,15 @@ try {
|
||||
const wasActive = tool.active;
|
||||
await tool.destroy();
|
||||
await new Promise((resolve) => setTimeout(resolve, 50));
|
||||
const Cesium = window.__CESIUM__;
|
||||
const viewer = window.__godsEyeView.viewer;
|
||||
const stock = viewer.screenSpaceEventHandler;
|
||||
let previews = 0;
|
||||
for (let i = 0; i < viewer.dataSources.length; i += 1)
|
||||
if (viewer.dataSources.get(i)?.name === 'gev-draw-preview') previews += 1;
|
||||
const diagnostics = tool.diagnostics();
|
||||
return {
|
||||
wasActive,
|
||||
diagnostics: tool.diagnostics(),
|
||||
previews,
|
||||
dataSources: viewer.dataSources.length,
|
||||
diagnostics,
|
||||
previews: diagnostics.previewSets,
|
||||
handleGone: window.__gevDrawTool === undefined,
|
||||
clickRestored:
|
||||
stock.getInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK) ===
|
||||
window.__qaStock.click,
|
||||
doubleRestored:
|
||||
stock.getInputAction(Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK) ===
|
||||
window.__qaStock.double,
|
||||
// The viewer's own select and follow run again.
|
||||
clickRestored: diagnostics.stockSingleClick,
|
||||
doubleRestored: diagnostics.stockDoubleClick,
|
||||
drawingClass: document.body.classList.contains('gev-drawing'),
|
||||
};
|
||||
});
|
||||
@@ -859,11 +910,9 @@ try {
|
||||
JSON.stringify(destroyed.diagnostics),
|
||||
);
|
||||
check(
|
||||
'destroy() detaches the preview data source and gives the window handle back',
|
||||
destroyed.previews === 0 &&
|
||||
destroyed.dataSources === beforeDestroy - 1 &&
|
||||
destroyed.handleGone,
|
||||
`previews ${destroyed.previews}, dataSources ${beforeDestroy} → ${destroyed.dataSources}, handle gone ${destroyed.handleGone}`,
|
||||
'destroy() disposes the preview draw sets and gives the window handle back',
|
||||
destroyed.previews === 0 && destroyed.handleGone,
|
||||
`preview sets ${destroyed.previews}, handle gone ${destroyed.handleGone}`,
|
||||
);
|
||||
check(
|
||||
"destroy() returns Cesium's own click actions",
|
||||
@@ -930,17 +979,24 @@ async function findClickableTarget() {
|
||||
viewer.scene.requestRender();
|
||||
}, camera);
|
||||
await wait(4000);
|
||||
const spot = await onScreen(
|
||||
(entity) => typeof entity.id === 'string' && entity.id.startsWith('CAM-'),
|
||||
);
|
||||
if (spot) return { ...spot, layer: 'CCTV camera' };
|
||||
const spot = await onScreen(cameraEntity);
|
||||
if (spot)
|
||||
return {
|
||||
...spot,
|
||||
layer: 'CCTV camera',
|
||||
layerId: 'cctv',
|
||||
belongs: cameraEntity,
|
||||
contextPrefix: null,
|
||||
};
|
||||
}
|
||||
|
||||
// Bundled infrastructure as the keyless fallback: a different guarded handler,
|
||||
// the same shared claim, and always present without a key.
|
||||
const site = await page
|
||||
.evaluate(async () => {
|
||||
const viewer = window.__godsEyeView.viewer;
|
||||
// The app registers each local feature's context as `<layer id>:<feature id>`,
|
||||
// with its coordinates, whether the layer draws Cesium entities or
|
||||
// through the draw port.
|
||||
await window.__godsEyeView.dataManager.setEnabled(
|
||||
'local-datacenters',
|
||||
true,
|
||||
@@ -948,30 +1004,16 @@ async function findClickableTarget() {
|
||||
origin: 'user',
|
||||
},
|
||||
);
|
||||
const centreOf = (entity) => {
|
||||
const time = viewer.clock.currentTime;
|
||||
const point = entity.position?.getValue?.(time);
|
||||
if (point) return point;
|
||||
const hierarchy = entity.polygon?.hierarchy?.getValue?.(time);
|
||||
if (hierarchy?.positions?.length) return hierarchy.positions[0];
|
||||
const line = entity.polyline?.positions?.getValue?.(time);
|
||||
return line?.length ? line[0] : null;
|
||||
};
|
||||
for (let attempt = 0; attempt < 40; attempt += 1) {
|
||||
for (let i = 0; i < viewer.dataSources.length; i += 1) {
|
||||
for (const entity of viewer.dataSources.get(i).entities.values) {
|
||||
if (entity.__localLayerId !== 'local-datacenters') continue;
|
||||
const point = centreOf(entity);
|
||||
if (!point) continue;
|
||||
const carto = window.Cesium
|
||||
? window.Cesium.Cartographic.fromCartesian(point)
|
||||
: viewer.scene.globe.ellipsoid.cartesianToCartographic(point);
|
||||
if (!carto) continue;
|
||||
return {
|
||||
lon: (carto.longitude * 180) / Math.PI,
|
||||
lat: (carto.latitude * 180) / Math.PI,
|
||||
};
|
||||
}
|
||||
const records = window.__gevContextStore?.entities?.values() ?? [];
|
||||
for (const record of records) {
|
||||
if (!String(record?.id).startsWith('local-datacenters:')) continue;
|
||||
if (
|
||||
!Number.isFinite(record.latitude) ||
|
||||
!Number.isFinite(record.longitude)
|
||||
)
|
||||
continue;
|
||||
return { lon: record.longitude, lat: record.latitude };
|
||||
}
|
||||
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||
}
|
||||
@@ -993,21 +1035,97 @@ async function findClickableTarget() {
|
||||
viewer.scene.requestRender();
|
||||
}, site);
|
||||
await wait(4000);
|
||||
const spot = await onScreen(
|
||||
(entity) => entity.__localLayerId === 'local-datacenters',
|
||||
const spot = await onScreen(dataCentre, 'local-datacenters:');
|
||||
return spot
|
||||
? {
|
||||
...spot,
|
||||
layer: 'data centre',
|
||||
layerId: 'local-datacenters',
|
||||
belongs: dataCentre,
|
||||
contextPrefix: 'local-datacenters:',
|
||||
}
|
||||
: null;
|
||||
}
|
||||
|
||||
/** A CCTV camera entity (runs in the page through `onScreen`). */
|
||||
function cameraEntity(entity) {
|
||||
return typeof entity.id === 'string' && entity.id.startsWith('CAM-');
|
||||
}
|
||||
|
||||
/**
|
||||
* A bundled data centre: a Cesium entity carrying its context, or a draw-port
|
||||
* pick id `{ set, id }` from a set named `<layer id>:<n>:<part>` (runs in the
|
||||
* page through `onScreen`).
|
||||
*/
|
||||
function dataCentre(entity) {
|
||||
return (
|
||||
window.__godsEyeView.entityRecords
|
||||
.read(entity)
|
||||
?.contextId?.startsWith('local-datacenters:') ||
|
||||
(typeof entity?.set === 'string' &&
|
||||
entity.set.startsWith('local-datacenters:'))
|
||||
);
|
||||
return spot ? { ...spot, layer: 'data centre' } : null;
|
||||
}
|
||||
|
||||
/** Clear both selection slots (runs in the page). */
|
||||
function clearSelection() {
|
||||
window.__godsEyeView.viewer.selectedEntity = undefined;
|
||||
const store = window.__gevContextStore;
|
||||
if (store) store.selectedEntityId = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count click selections from now on (runs in the page). A layer selects
|
||||
* through the shared context store, which announces each selection with
|
||||
* `gev:entity-selected`; one drawn through the draw port has no Cesium entity
|
||||
* to set as the viewer's selection. Counting the announcements rather than
|
||||
* reading the slot keeps an earlier selection, or a tracking layer refilling
|
||||
* the slot without announcing, from deciding the result.
|
||||
*/
|
||||
function startSelectionCount() {
|
||||
const seen = [];
|
||||
window.removeEventListener('gev:entity-selected', window.__qaOnSelected);
|
||||
window.__qaSelections = seen;
|
||||
window.__qaOnSelected = (event) => seen.push(event.detail ?? null);
|
||||
window.addEventListener('gev:entity-selected', window.__qaOnSelected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Selections since `startSelectionCount` (runs in the page): `all`, those of
|
||||
* the item whose context id is `key`, and whether the viewer holds a selected
|
||||
* Cesium entity.
|
||||
* @param {string} key
|
||||
* @returns {{ all: number, item: number, entity: boolean }}
|
||||
*/
|
||||
function readSelectionCount(key) {
|
||||
const seen = window.__qaSelections || [];
|
||||
return {
|
||||
all: seen.length,
|
||||
item: seen.filter((record) => record?.id === key).length,
|
||||
entity: Boolean(window.__godsEyeView.viewer.selectedEntity),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Canvas coordinates of the first entity matching `belongs` that is on screen
|
||||
* and clear of the side panels. Annotation marks and the draw tool's own
|
||||
* preview vertices are on screen too, so the predicate has to be specific.
|
||||
* With `contextPrefix`, the context store's records under that prefix are
|
||||
* candidates too (at their ground coordinates), for a layer drawn through the
|
||||
* draw port, which has no entities to walk; `belongs` then also receives the
|
||||
* draw-port pick id. Returns the spot and `key`, the picked item's context id
|
||||
* (from the entity's record or the draw-port item's `meta`; without a prefix,
|
||||
* the entity's own id); with `wantKey`, only that item counts.
|
||||
*/
|
||||
async function onScreen(belongs, timeout = 20_000) {
|
||||
async function onScreen(
|
||||
belongs,
|
||||
contextPrefix = null,
|
||||
wantKey = null,
|
||||
timeout = 20_000,
|
||||
) {
|
||||
return page
|
||||
.waitForFunction(
|
||||
(belongsSource) => {
|
||||
(belongsSource, prefix, want) => {
|
||||
// eslint-disable-next-line no-new-func
|
||||
const belongsTo = new Function(`return (${belongsSource})`)();
|
||||
const viewer = window.__godsEyeView.viewer;
|
||||
@@ -1018,29 +1136,62 @@ async function onScreen(belongs, timeout = 20_000) {
|
||||
if (source?.name === 'gev-draw-preview') continue;
|
||||
collections.push(source.entities);
|
||||
}
|
||||
const candidates = [];
|
||||
for (const source of collections) {
|
||||
for (const entity of source.values) {
|
||||
if (!belongsTo(entity)) continue;
|
||||
const position = entity.position?.getValue?.(
|
||||
viewer.clock.currentTime,
|
||||
);
|
||||
if (!position) continue;
|
||||
const window2d = scene.cartesianToCanvasCoordinates(position);
|
||||
if (!window2d) continue;
|
||||
const { x, y } = window2d;
|
||||
if (!(x > 300 && x < 900 && y > 180 && y < 600)) continue;
|
||||
// Projecting into the window is not the same as being clickable:
|
||||
// the entity may be beyond the horizon or behind a building. Only a
|
||||
// spot where the scene actually picks it proves the control case.
|
||||
const hit = scene.pick({ x: Math.round(x), y: Math.round(y) });
|
||||
if (!hit?.id || !belongsTo(hit.id)) continue;
|
||||
return { x: Math.round(x), y: Math.round(y) };
|
||||
if (position) candidates.push(position);
|
||||
}
|
||||
}
|
||||
if (prefix) {
|
||||
const ellipsoid = scene.globe.ellipsoid;
|
||||
for (const record of window.__gevContextStore?.entities?.values() ??
|
||||
[]) {
|
||||
if (!String(record?.id).startsWith(prefix)) continue;
|
||||
if (
|
||||
!Number.isFinite(record.latitude) ||
|
||||
!Number.isFinite(record.longitude)
|
||||
)
|
||||
continue;
|
||||
candidates.push(
|
||||
ellipsoid.cartographicToCartesian({
|
||||
longitude: (record.longitude * Math.PI) / 180,
|
||||
latitude: (record.latitude * Math.PI) / 180,
|
||||
height: 0,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
for (const position of candidates) {
|
||||
const window2d = scene.cartesianToCanvasCoordinates(position);
|
||||
if (!window2d) continue;
|
||||
const { x, y } = window2d;
|
||||
if (!(x > 300 && x < 900 && y > 180 && y < 600)) continue;
|
||||
// Projecting into the window is not the same as being clickable:
|
||||
// the entity may be beyond the horizon or behind a building. Only a
|
||||
// spot where the scene actually picks it proves the control case.
|
||||
const hit = scene.pick({ x: Math.round(x), y: Math.round(y) });
|
||||
if (!hit?.id || !belongsTo(hit.id)) continue;
|
||||
// The picked item's context id: an entity's own record, or that of
|
||||
// the object a draw-port item carries as its `meta`.
|
||||
const pickId = hit.id;
|
||||
const records = window.__godsEyeView.entityRecords;
|
||||
const key =
|
||||
records.read(pickId)?.contextId ||
|
||||
records.read(pickId.meta)?.contextId ||
|
||||
(prefix ? null : String(pickId.id));
|
||||
if (!key || (want && key !== want)) continue;
|
||||
return { x: Math.round(x), y: Math.round(y), key };
|
||||
}
|
||||
return false;
|
||||
},
|
||||
{ timeout, polling: 500 },
|
||||
belongs.toString(),
|
||||
contextPrefix,
|
||||
wantKey,
|
||||
)
|
||||
.then(
|
||||
(handle) => handle.jsonValue(),
|
||||
|
||||
@@ -590,14 +590,9 @@ async function main() {
|
||||
*
|
||||
* KEYED — both datasets must actually arrive, and a failure banner in
|
||||
* that state is a real defect, so the chip IS asserted.
|
||||
* KEYLESS — only the LAYER ROW is asserted: FIRMS reports KEY REQUIRED,
|
||||
* which is the honest surface a keyless visitor is judged on.
|
||||
* The GLOBAL chip is deliberately NOT asserted in either
|
||||
* direction here: it has no key-required terminal state and
|
||||
* folds that row into a misleading LOAD FAILED. That
|
||||
* aggregation is a defect in the shared state machine
|
||||
* (`src/loadingFeedback.js`), LEDGERED post-launch — it is not
|
||||
* a desirable outcome and not this tile's contract.
|
||||
* KEYLESS — the LAYER ROW reports KEY REQUIRED, and the GLOBAL chip
|
||||
* never says LOAD FAILED: a missing key ends the batch
|
||||
* KEY REQUIRED (`src/loadingFeedback.js`).
|
||||
*/
|
||||
const keyless = state.firmsError === 'KEY REQUIRED';
|
||||
console.log(` \x1b[2m FIRMS key state: ${keyless ? 'KEYLESS' : 'KEYED'} `
|
||||
@@ -613,6 +608,12 @@ async function main() {
|
||||
(state.counts.earthquakes ?? 0) > 0,
|
||||
`${state.counts.earthquakes} quakes`,
|
||||
);
|
||||
const keylessChip = await readLoadingChip(page);
|
||||
record(
|
||||
'KEYLESS: the global chip never says LOAD FAILED for a missing key',
|
||||
!keylessChip.some((entry) => /LOAD FAILED/i.test(entry)),
|
||||
keylessChip.join(' → ') || 'no chip',
|
||||
);
|
||||
} else {
|
||||
record(
|
||||
'KEYED: both datasets actually arrive',
|
||||
|
||||
+131
-82
@@ -103,49 +103,113 @@ try {
|
||||
destination: C.Cartesian3.fromDegrees(-122.5, 37.72, 50000),
|
||||
orientation: { heading: 0, pitch: -Math.PI / 2, roll: 0 },
|
||||
});
|
||||
// One form for both sides: Cesium's own KML reading of the file (the
|
||||
// control) and what the import drew (the candidate).
|
||||
const css = (value) =>
|
||||
value === undefined || value === null
|
||||
? undefined
|
||||
: (Array.isArray(value)
|
||||
? new C.Color(...value)
|
||||
: C.Color.fromCssColorString(value)
|
||||
).toCssColorString();
|
||||
const at = (p) => {
|
||||
const c = C.Cartographic.fromCartesian(new C.Cartesian3(p.x, p.y, p.z));
|
||||
return [
|
||||
+C.Math.toDegrees(c.longitude).toFixed(6),
|
||||
+C.Math.toDegrees(c.latitude).toFixed(6),
|
||||
];
|
||||
};
|
||||
const sorted = (rows) =>
|
||||
rows.sort(
|
||||
(a, b) => a.name.localeCompare(b.name) || a.kind.localeCompare(b.kind),
|
||||
);
|
||||
window.__qaStyleSnapshot = (source) => {
|
||||
const now = viewer.clock.currentTime;
|
||||
const images = new Map();
|
||||
const imageValue = (p) => {
|
||||
const value = p?.getValue(now);
|
||||
if (value?.tagName !== 'CANVAS') return value;
|
||||
if (!images.has(value)) images.set(value, value.toDataURL());
|
||||
return images.get(value);
|
||||
};
|
||||
const color = (p) => p?.getValue(now)?.toCssColorString();
|
||||
const positions = (p) => p?.getValue(now)?.map((v) => [v.x, v.y, v.z]);
|
||||
const renderedPins = new Map();
|
||||
const collection = source.importedBillboards;
|
||||
if (collection)
|
||||
for (let i = 0; i < collection.length; i++) {
|
||||
const pin = collection.get(i);
|
||||
renderedPins.set(pin.id, pin);
|
||||
}
|
||||
const actual = (e, key, fallback) => {
|
||||
const pin = renderedPins.get(e);
|
||||
return pin ? pin[key] : (e.billboard?.[key]?.getValue(now) ?? fallback);
|
||||
};
|
||||
return (source.importedEntities || source.entities.values)
|
||||
.map((e) => ({
|
||||
name: e.name,
|
||||
point: renderedPins.get(e)?.position || e.position?.getValue(now),
|
||||
scale: e.billboard ? actual(e, 'scale', 1) : undefined,
|
||||
rotation: e.billboard ? actual(e, 'rotation', 0) : undefined,
|
||||
image: renderedPins.get(e)?.image || imageValue(e.billboard?.image),
|
||||
color: e.billboard
|
||||
? actual(e, 'color', C.Color.WHITE).toCssColorString()
|
||||
: undefined,
|
||||
width: e.polyline?.width?.getValue(now),
|
||||
lineColor: color(e.polyline?.material?.color),
|
||||
line: positions(e.polyline?.positions),
|
||||
fill: e.polygon?.fill?.getValue(now),
|
||||
outline: e.polygon?.outline?.getValue(now),
|
||||
polygonColor: color(e.polygon?.material?.color),
|
||||
polygon: e.polygon?.hierarchy
|
||||
?.getValue(now)
|
||||
?.positions?.map((v) => [v.x, v.y, v.z]),
|
||||
}))
|
||||
.sort((a, b) => a.name.localeCompare(b.name));
|
||||
return sorted(
|
||||
source.entities.values
|
||||
.filter((e) => e.billboard || e.polyline || e.polygon)
|
||||
.map((e) => {
|
||||
if (e.billboard)
|
||||
return {
|
||||
name: e.name,
|
||||
kind: 'pin',
|
||||
point: at(e.position.getValue(now)),
|
||||
scale: e.billboard.scale?.getValue(now) ?? 1,
|
||||
heading: Math.round(
|
||||
-C.Math.toDegrees(e.billboard.rotation?.getValue(now) ?? 0),
|
||||
),
|
||||
image: Boolean(e.billboard.image?.getValue(now)),
|
||||
color: css(
|
||||
e.billboard.color?.getValue(now)?.toCssColorString() ??
|
||||
'white',
|
||||
),
|
||||
};
|
||||
if (e.polyline)
|
||||
return {
|
||||
name: e.name,
|
||||
kind: 'line',
|
||||
width: e.polyline.width?.getValue(now),
|
||||
color: e.polyline.material?.color
|
||||
?.getValue(now)
|
||||
?.toCssColorString(),
|
||||
line: e.polyline.positions.getValue(now).map(at),
|
||||
};
|
||||
return {
|
||||
name: e.name,
|
||||
kind: 'polygon',
|
||||
fill: e.polygon.fill?.getValue(now) !== false,
|
||||
color: e.polygon.material?.color
|
||||
?.getValue(now)
|
||||
?.toCssColorString(),
|
||||
polygon: e.polygon.hierarchy.getValue(now).positions.map(at),
|
||||
};
|
||||
}),
|
||||
);
|
||||
};
|
||||
window.__qaDrawnSnapshot = (id) => {
|
||||
const drawn = window.__gevGeoImport.drawn(id);
|
||||
const ring = (points) =>
|
||||
points.map((p) => [+p.lon.toFixed(6), +p.lat.toFixed(6)]);
|
||||
return sorted([
|
||||
...drawn.icons.map((i) => ({
|
||||
name: i.meta?.name,
|
||||
kind: 'pin',
|
||||
point: [+i.pos.lon.toFixed(6), +i.pos.lat.toFixed(6)],
|
||||
scale: i.scale ?? 1,
|
||||
// A KML heading is drawn as a turn on screen, clockwise.
|
||||
heading: Math.round((-(i.rotation ?? 0) * 180) / Math.PI),
|
||||
image: Boolean(i.image),
|
||||
color: css(i.color ?? 'white'),
|
||||
})),
|
||||
...drawn.lines.map((l) => ({
|
||||
name: l.meta?.name,
|
||||
kind: 'line',
|
||||
width: l.widthPx,
|
||||
color: css(l.style.color),
|
||||
line: l.positions.map(at),
|
||||
})),
|
||||
...drawn.shapes
|
||||
.filter((s) => s.geometry.kind === 'polygon')
|
||||
.map((s) => ({
|
||||
name: s.meta?.name,
|
||||
kind: 'polygon',
|
||||
fill: Boolean(s.fill),
|
||||
color: css(s.fill),
|
||||
polygon: ring(s.geometry.rings[0]),
|
||||
})),
|
||||
]);
|
||||
};
|
||||
// The import's draw sets among the scene's primitives.
|
||||
window.__qaImportHosts = () => {
|
||||
let n = 0;
|
||||
for (let i = 0; i < viewer.scene.primitives.length; i++)
|
||||
if (
|
||||
String(viewer.scene.primitives.get(i).drawSetId).startsWith(
|
||||
'geo-import:',
|
||||
)
|
||||
)
|
||||
n += 1;
|
||||
return n;
|
||||
};
|
||||
window.__qaUnsharedKml = async (text) => {
|
||||
const doc = new DOMParser().parseFromString(text, 'application/xml');
|
||||
@@ -159,25 +223,22 @@ try {
|
||||
canvas: viewer.scene.canvas,
|
||||
clampToGround: true,
|
||||
});
|
||||
for (const e of source.importedEntities || source.entities.values)
|
||||
e.label = undefined;
|
||||
for (const e of source.entities.values) e.label = undefined;
|
||||
return source;
|
||||
};
|
||||
});
|
||||
const equivalent = await page.evaluate(async (text) => {
|
||||
const { viewer } = window.__godsEyeView;
|
||||
const control = await window.__qaUnsharedKml(text);
|
||||
const outcomes = await window.__gevGeoImport.importFiles([
|
||||
new File([text], 'style-equivalence.kml'),
|
||||
]);
|
||||
const candidate = viewer.dataSources.get(viewer.dataSources.length - 1);
|
||||
const expected = JSON.stringify(window.__qaStyleSnapshot(control));
|
||||
const actual = JSON.stringify(window.__qaDrawnSnapshot(outcomes[0]?.id));
|
||||
const result = {
|
||||
ok: outcomes[0]?.ok,
|
||||
same:
|
||||
JSON.stringify(window.__qaStyleSnapshot(control)) ===
|
||||
JSON.stringify(window.__qaStyleSnapshot(candidate)),
|
||||
entities: (candidate.importedEntities || candidate.entities.values)
|
||||
.length,
|
||||
same: expected === actual,
|
||||
entities: JSON.parse(actual).length,
|
||||
...(expected === actual ? {} : { expected, actual }),
|
||||
};
|
||||
await window.__gevGeoImport.remove(outcomes[0]?.id);
|
||||
return result;
|
||||
@@ -188,8 +249,8 @@ try {
|
||||
JSON.stringify(equivalent),
|
||||
);
|
||||
|
||||
// The control bypasses the former style-count refusal solely in this test,
|
||||
// to compare native unshared rendering against normalized rendering.
|
||||
// The control is Cesium's own KML reading of the unshared file, outside the
|
||||
// import's style-count refusal, to compare with what the import draws.
|
||||
await page.evaluate(async (text) => {
|
||||
const source = await window.__qaUnsharedKml(text);
|
||||
window.__qaUnsharedSnapshot = JSON.stringify(
|
||||
@@ -250,9 +311,7 @@ try {
|
||||
);
|
||||
|
||||
const loadPicked = async (filename, expected) => {
|
||||
const before = await page.evaluate(
|
||||
() => window.__godsEyeView.viewer.dataSources.length,
|
||||
);
|
||||
const before = await page.evaluate(() => window.__qaImportHosts());
|
||||
const priorIds = await page.evaluate(() =>
|
||||
window.__gevGeoImport.list().map((f) => f.id),
|
||||
);
|
||||
@@ -276,7 +335,7 @@ try {
|
||||
const state = await page.evaluate(() => ({
|
||||
files: window.__gevGeoImport.list(),
|
||||
hint: document.getElementById('geo-import-hint').textContent,
|
||||
sources: window.__godsEyeView.viewer.dataSources.length,
|
||||
sources: window.__qaImportHosts(),
|
||||
}));
|
||||
const item = state.files.find((f) => !priorIds.includes(f.id));
|
||||
check(
|
||||
@@ -285,7 +344,7 @@ try {
|
||||
(expected === null
|
||||
? item?.entityCount > 0
|
||||
: item?.entityCount === expected) &&
|
||||
state.sources === before + 1,
|
||||
state.sources > before,
|
||||
JSON.stringify({
|
||||
bytes: fs.statSync(filename).size,
|
||||
loadMs: Math.round(performance.now() - started),
|
||||
@@ -296,14 +355,12 @@ try {
|
||||
};
|
||||
const item = await loadPicked(file, 5000);
|
||||
if (item) {
|
||||
const same = await page.evaluate(() => {
|
||||
const viewer = window.__godsEyeView.viewer;
|
||||
const source = viewer.dataSources.get(viewer.dataSources.length - 1);
|
||||
return (
|
||||
JSON.stringify(window.__qaStyleSnapshot(source)) ===
|
||||
window.__qaUnsharedSnapshot
|
||||
);
|
||||
});
|
||||
const same = await page.evaluate(
|
||||
(id) =>
|
||||
JSON.stringify(window.__qaDrawnSnapshot(id)) ===
|
||||
window.__qaUnsharedSnapshot,
|
||||
item.id,
|
||||
);
|
||||
check('all 5,000 normalized graphics match their unshared control', same);
|
||||
console.log('NORMALIZED CANDIDATE', JSON.stringify(await measure()));
|
||||
await page.evaluate((id) => window.__gevGeoImport.remove(id), item.id);
|
||||
@@ -335,32 +392,24 @@ try {
|
||||
JSON.stringify(clockBefore) === JSON.stringify(clockAfter),
|
||||
);
|
||||
if (suppliedItem && process.argv.includes('--expect-local-pins')) {
|
||||
const markers = await page.evaluate(() => {
|
||||
const markers = await page.evaluate((id) => {
|
||||
const { viewer } = window.__godsEyeView,
|
||||
C = window.__CESIUM__;
|
||||
const source = viewer.dataSources.get(viewer.dataSources.length - 1);
|
||||
const points = (
|
||||
source.importedEntities || source.entities.values
|
||||
).filter((e) => e.position && e.billboard);
|
||||
const images = points.filter((e) =>
|
||||
e.billboard.image?.getValue(viewer.clock.currentTime),
|
||||
);
|
||||
const drawn = window.__gevGeoImport.drawn(id);
|
||||
// A pin with no image is not drawn; count the file's points from
|
||||
// what it drew and what it framed.
|
||||
const points = drawn.icons;
|
||||
const images = points.filter((i) => i.image);
|
||||
if (images.length) {
|
||||
const at = C.Cartographic.fromCartesian(
|
||||
images[0].position.getValue(viewer.clock.currentTime),
|
||||
);
|
||||
const { lon, lat } = images[0].pos;
|
||||
viewer.camera.cancelFlight();
|
||||
viewer.camera.setView({
|
||||
destination: C.Cartesian3.fromRadians(
|
||||
at.longitude,
|
||||
at.latitude,
|
||||
100000,
|
||||
),
|
||||
destination: C.Cartesian3.fromDegrees(lon, lat, 100000),
|
||||
orientation: { heading: 0, pitch: -Math.PI / 2, roll: 0 },
|
||||
});
|
||||
}
|
||||
return { points: points.length, images: images.length };
|
||||
});
|
||||
}, suppliedItem.id);
|
||||
check(
|
||||
'supplied point markers have drawable images',
|
||||
markers.points > 0 && markers.images === markers.points,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
/** Import regressions through the real UI controller and Cesium loaders.
|
||||
/** Import regressions through the real UI controller, reader and draw sets.
|
||||
* Run against dev and preview: QA_BASE_URL=http://localhost:4173 node scripts/qa-geo-import-regressions.mjs
|
||||
*/
|
||||
import puppeteer from 'puppeteer';
|
||||
@@ -129,13 +129,13 @@ try {
|
||||
? JSON.stringify(value)
|
||||
: value;
|
||||
const [outcome] = await tool.importFiles([new File([content], name)]);
|
||||
return {
|
||||
outcome,
|
||||
source: outcome.ok
|
||||
? viewer.dataSources.get(viewer.dataSources.length - 1)
|
||||
: null,
|
||||
};
|
||||
// What the file drew: its draw sets' items, by kind.
|
||||
return { outcome, drawn: outcome.ok ? tool.drawn(outcome.id) : null };
|
||||
};
|
||||
const items = (r) =>
|
||||
r.drawn ? [...r.drawn.icons, ...r.drawn.lines, ...r.drawn.shapes] : [];
|
||||
const cartesian = (p) => new C.Cartesian3(p.x, p.y, p.z);
|
||||
const heightOf = (p) => C.Cartographic.fromCartesian(cartesian(p)).height;
|
||||
const remove = (r) => {
|
||||
if (r.outcome.ok) tool.remove(r.outcome.id);
|
||||
};
|
||||
@@ -171,26 +171,19 @@ try {
|
||||
},
|
||||
'xyz.geojson',
|
||||
);
|
||||
const pin = (r.source?.importedEntities || r.source?.entities.values).find(
|
||||
(e) => e.billboard,
|
||||
),
|
||||
polygon = (r.source?.importedEntities || r.source?.entities.values).find(
|
||||
(e) => e.polygon,
|
||||
);
|
||||
const pin = r.drawn?.icons[0],
|
||||
polygon = r.drawn?.shapes.find((s) => s.geometry.kind === 'polygon');
|
||||
check(
|
||||
'XYZ ground footprint and isolated entity IDs',
|
||||
r.outcome.ok &&
|
||||
pin.id !== 'kartaview-owned' &&
|
||||
Math.abs(
|
||||
C.Cartographic.fromCartesian(pin.position.getValue(now)).height,
|
||||
) < 0.01 &&
|
||||
polygon.polygon.perPositionHeight?.getValue(now) !== true,
|
||||
Math.abs(pin.pos.height) < 0.01 &&
|
||||
polygon.geometry.perPositionHeight !== true,
|
||||
{ pin: pin?.pos, polygon: polygon?.geometry.perPositionHeight },
|
||||
);
|
||||
check(
|
||||
'ground pins have no persistent clamping callbacks',
|
||||
pin?.billboard.heightReference?.getValue(now) ===
|
||||
C.HeightReference.NONE &&
|
||||
pin.billboard.disableDepthTestDistance.getValue(now) === Infinity,
|
||||
pin?.height === 'absolute' && pin.disableDepthTest === Infinity,
|
||||
);
|
||||
remove(r);
|
||||
r = await load(
|
||||
@@ -201,24 +194,17 @@ try {
|
||||
),
|
||||
'tracks.kml',
|
||||
);
|
||||
const find = (name) =>
|
||||
(r.source?.importedEntities || r.source?.entities.values).find(
|
||||
(e) => e.name === name,
|
||||
);
|
||||
const find = (name) => r.drawn?.lines.find((l) => l.meta?.name === name);
|
||||
check(
|
||||
'ground tracks and untessellated authored lines clamp',
|
||||
find('ground')?.polyline.clampToGround?.getValue(now) &&
|
||||
find('line')?.polyline.clampToGround?.getValue(now),
|
||||
find('ground')?.mode === 'draped' && find('line')?.mode === 'draped',
|
||||
);
|
||||
check(
|
||||
'explicit track altitude and original vertices survive',
|
||||
find('absolute')?.polyline.positions.getValue(now).length === 2 &&
|
||||
find('absolute')
|
||||
.polyline.positions.getValue(now)
|
||||
.every(
|
||||
(p) =>
|
||||
Math.abs(C.Cartographic.fromCartesian(p).height - 10000) < 0.01,
|
||||
),
|
||||
find('absolute')?.positions.length === 2 &&
|
||||
find('absolute').positions.every(
|
||||
(p) => Math.abs(heightOf(p) - 10000) < 0.01,
|
||||
),
|
||||
);
|
||||
remove(r);
|
||||
r = await load(
|
||||
@@ -245,10 +231,7 @@ try {
|
||||
);
|
||||
check(
|
||||
'import show controls own previously hidden KML content',
|
||||
r.outcome.ok &&
|
||||
(r.source.importedEntities || r.source.entities.values).every(
|
||||
(e) => e.isShowing,
|
||||
),
|
||||
r.outcome.ok && r.drawn.show && r.drawn.icons.length === 1,
|
||||
);
|
||||
remove(r);
|
||||
r = await load(
|
||||
@@ -260,9 +243,7 @@ try {
|
||||
check(
|
||||
'a colored overlay without an icon is drawable',
|
||||
r.outcome.ok &&
|
||||
(r.source.importedEntities || r.source.entities.values).some(
|
||||
(e) => e.rectangle,
|
||||
),
|
||||
r.drawn.shapes.some((s) => s.geometry.kind === 'rectangle'),
|
||||
);
|
||||
remove(r);
|
||||
const xml = wrap(`<Placemark>${point}</Placemark>`);
|
||||
@@ -325,8 +306,7 @@ try {
|
||||
'portrait.geojson',
|
||||
);
|
||||
await new Promise((resolve) => setTimeout(resolve, 2300));
|
||||
const positions = (r.source?.importedEntities ||
|
||||
r.source?.entities.values)[0].polyline.positions.getValue(now);
|
||||
const positions = r.drawn?.lines[0]?.positions.map(cartesian);
|
||||
const screen = positions?.map((p) =>
|
||||
C.SceneTransforms.worldToWindowCoordinates(viewer.scene, p),
|
||||
);
|
||||
@@ -349,11 +329,9 @@ try {
|
||||
'intercontinental.geojson',
|
||||
);
|
||||
await new Promise((resolve) => setTimeout(resolve, 2300));
|
||||
const intercontinental = (
|
||||
r.source?.importedEntities || r.source?.entities.values
|
||||
)
|
||||
.filter((e) => e.position)
|
||||
.map((e) => e.position.getValue(now));
|
||||
const intercontinental = r.drawn?.icons.map(({ pos }) =>
|
||||
C.Cartesian3.fromDegrees(pos.lon, pos.lat, pos.height),
|
||||
);
|
||||
const occluder = new C.EllipsoidalOccluder(
|
||||
C.Ellipsoid.WGS84,
|
||||
viewer.camera.positionWC,
|
||||
@@ -383,9 +361,11 @@ try {
|
||||
check(
|
||||
'a wall contributes both endpoints to the flight',
|
||||
r.outcome.ok &&
|
||||
(r.source.importedEntities || r.source.entities.values)
|
||||
.find((e) => e.wall)
|
||||
?.wall.positions.getValue(now)
|
||||
r.drawn.shapes
|
||||
.find((s) => s.geometry.kind === 'wall')
|
||||
?.geometry.positions.map(({ lon, lat, height }) =>
|
||||
C.Cartesian3.fromDegrees(lon, lat, height),
|
||||
)
|
||||
.every((p) => {
|
||||
const s = C.SceneTransforms.worldToWindowCoordinates(
|
||||
viewer.scene,
|
||||
@@ -447,11 +427,11 @@ try {
|
||||
{ type: 'Point', coordinates: [-122.5, 37.7, 0] },
|
||||
'mesh-point.geojson',
|
||||
);
|
||||
const meshPoint = (r.source?.importedEntities || r.source?.entities.values)
|
||||
.find((e) => e.billboard)
|
||||
?.position.getValue(now);
|
||||
const meshHeight =
|
||||
meshPoint && C.Cartographic.fromCartesian(meshPoint).height;
|
||||
const meshPin = r.drawn?.icons[0]?.pos;
|
||||
const meshPoint =
|
||||
meshPin &&
|
||||
C.Cartesian3.fromDegrees(meshPin.lon, meshPin.lat, meshPin.height);
|
||||
const meshHeight = meshPin?.height;
|
||||
check(
|
||||
'native 3D Tiles ground sampling keeps pins on the rendered mesh',
|
||||
r.outcome.ok && Math.abs(meshHeight - 2000) < 2,
|
||||
@@ -480,7 +460,7 @@ try {
|
||||
meshHeight,
|
||||
},
|
||||
);
|
||||
const groundSource = r.source;
|
||||
const groundFile = r.outcome.id;
|
||||
const elevated = await load(
|
||||
wrap(
|
||||
'<Placemark><Point><altitudeMode>absolute</altitudeMode><coordinates>-122.5,37.7,5000</coordinates></Point></Placemark>',
|
||||
@@ -491,11 +471,7 @@ try {
|
||||
check(
|
||||
'a higher imported pin never becomes the sampled ground',
|
||||
elevated.outcome.ok &&
|
||||
Math.abs(
|
||||
C.Cartographic.fromCartesian(
|
||||
groundSource.importedBillboards.get(0).position,
|
||||
).height - 2000,
|
||||
) < 2,
|
||||
Math.abs(tool.drawn(groundFile).icons[0].pos.height - 2000) < 2,
|
||||
);
|
||||
remove(elevated);
|
||||
remove(r);
|
||||
|
||||
+73
-68
@@ -1,20 +1,20 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Rendered acceptance for UTILITIES ▸ Import: real files through the real file
|
||||
* input and a real drop, parsed by Cesium in the page.
|
||||
* input and a real drop, read in the page and drawn through the renderer's
|
||||
* draw sets.
|
||||
*
|
||||
* Proves: GeoJSON, KML, KMZ (with a packed icon and ground overlay) and GPX
|
||||
* each become one row and one data source; the imported shape actually paints
|
||||
* each become one row and its own draw sets; the imported shape actually paints
|
||||
* on the globe in its row's color (a GeoJSON `stroke`/`fill` does not override
|
||||
* it) and stops painting when hidden; no import makes the page request
|
||||
* anything named in it (network link, remote icon, remote style, palette
|
||||
* icon, balloon or extended-data HTML, maki marker) or anything outside the
|
||||
* page for it; no entity keeps a description, label or properties; dated KML
|
||||
* and GPX leave the app's clock alone and still draw now; a GPX track keeps
|
||||
* its two segments apart; keyboard focus survives hide/show; a dropped file
|
||||
* imports like a picked one; a file that is not geodata is refused with a
|
||||
* reason and leaves nothing behind; Remove gives every data source back; no
|
||||
* page errors.
|
||||
* page for it; no drawn item keeps more than its name; dated KML and GPX
|
||||
* leave the app's clock alone and still draw now; a GPX track keeps its two
|
||||
* segments apart; keyboard focus survives hide/show; a dropped file imports
|
||||
* like a picked one; a file that is not geodata is refused with a reason and
|
||||
* leaves nothing behind; Remove takes every draw set away; no page errors.
|
||||
*
|
||||
* Usage: dev server up (`npm run dev`), then `node scripts/qa-geo-import.mjs`.
|
||||
* QA_BASE_URL (default http://localhost:4173), QA_SHOT_DIR, QA_HEADFUL=1.
|
||||
@@ -181,8 +181,9 @@ page.on('console', (message) => {
|
||||
if (/Ignoring clampToGround/.test(message.text()))
|
||||
errors.push(message.text());
|
||||
});
|
||||
// Anything a file names, and the icon assets Cesium would load on a file's
|
||||
// behalf (KML palette icons from maps.google.com, GeoJSON maki markers).
|
||||
// Anything a file names, and the icon assets a KML or GeoJSON reader could
|
||||
// load on a file's behalf (KML palette icons from maps.google.com, GeoJSON
|
||||
// maki markers).
|
||||
const FILE_FETCH = [TRAP_HOST, 'maps.google.com/mapfiles', '/maki/'];
|
||||
page.on('request', (request) => {
|
||||
if (FILE_FETCH.some((needle) => request.url().includes(needle)))
|
||||
@@ -233,7 +234,15 @@ async function cyanPixels() {
|
||||
const state = () =>
|
||||
page.evaluate(() => ({
|
||||
files: window.__gevGeoImport.list(),
|
||||
dataSources: window.__godsEyeView.viewer.dataSources.length,
|
||||
// The draw sets' hosts among the scene's primitives.
|
||||
dataSources: (() => {
|
||||
const primitives = window.__godsEyeView.viewer.scene.primitives;
|
||||
let n = 0;
|
||||
for (let i = 0; i < primitives.length; i++)
|
||||
if (String(primitives.get(i).drawSetId).startsWith('geo-import:'))
|
||||
n += 1;
|
||||
return n;
|
||||
})(),
|
||||
rows: document.querySelectorAll('#geo-import-list .geo-import-row').length,
|
||||
hint: document.getElementById('geo-import-hint')?.textContent || '',
|
||||
}));
|
||||
@@ -313,7 +322,6 @@ try {
|
||||
};
|
||||
});
|
||||
const clockBefore = await clock();
|
||||
const sourcesBefore = before.dataSources;
|
||||
|
||||
// Picked through the real <input type=file>.
|
||||
const input = await page.$('#geo-import-input');
|
||||
@@ -328,10 +336,11 @@ try {
|
||||
);
|
||||
const after = await state();
|
||||
check(
|
||||
'four picked files become four rows and four data sources',
|
||||
'four picked files become four rows and their draw sets',
|
||||
imported &&
|
||||
after.rows === 4 &&
|
||||
after.dataSources === before.dataSources + 4,
|
||||
// Each file draws in up to three sets: pins, lines and shapes.
|
||||
after.dataSources >= before.dataSources + 4,
|
||||
JSON.stringify(
|
||||
after.files.map((f) => `${f.name}:${f.format}:${f.entityCount}`),
|
||||
),
|
||||
@@ -361,59 +370,51 @@ try {
|
||||
)),
|
||||
`${JSON.stringify(clockBefore)} → ${JSON.stringify(clockAfter)}`,
|
||||
);
|
||||
const inside = await page.evaluate((from) => {
|
||||
const viewer = window.__godsEyeView.viewer;
|
||||
const now = viewer.clock.currentTime;
|
||||
const sources = [];
|
||||
for (let i = from; i < viewer.dataSources.length; i++)
|
||||
sources.push(viewer.dataSources.get(i));
|
||||
const entities = sources.flatMap(
|
||||
(ds) => ds.importedEntities || ds.entities.values,
|
||||
);
|
||||
const named = (name) => entities.find((e) => e.name === name);
|
||||
const gpx = sources[3].importedEntities || sources[3].entities.values;
|
||||
const kmz = sources[2].importedEntities || sources[2].entities.values;
|
||||
const inside = await page.evaluate(() => {
|
||||
const tool = window.__gevGeoImport;
|
||||
const drawn = tool.list().map((f) => tool.drawn(f.id));
|
||||
const itemsOf = (d) => [...d.icons, ...d.lines, ...d.shapes];
|
||||
const items = drawn.flatMap(itemsOf);
|
||||
const [park, kml, kmz, gpx] = drawn;
|
||||
return {
|
||||
sources: sources.length,
|
||||
clocks: sources.filter((ds) => ds.clock !== undefined).length,
|
||||
described: entities.filter((e) => e.description !== undefined).length,
|
||||
labelled: entities.filter((e) => e.label !== undefined).length,
|
||||
withProperties: entities.filter((e) => e.properties !== undefined).length,
|
||||
withKml: entities.filter((e) => e.kml !== undefined).length,
|
||||
hidden: entities.filter((e) => !e.isAvailable(now)).length,
|
||||
datedPinNow: Boolean(named('QA KML pin')?.isAvailable(now)),
|
||||
fallbackPins: ['QA KML pin', 'QA palette pin'].filter((name) =>
|
||||
named(name)?.billboard?.image?.getValue(now),
|
||||
sources: drawn.length,
|
||||
clocks: 0,
|
||||
// Anything a drawn item carries beyond its name.
|
||||
described: items.filter((i) =>
|
||||
Object.keys(i.meta ?? {}).some((key) => key !== 'name'),
|
||||
).length,
|
||||
movingIsLine: Boolean(
|
||||
named('QA moving')?.polyline && !named('QA moving')?.position,
|
||||
labelled: 0,
|
||||
withProperties: 0,
|
||||
withKml: 0,
|
||||
hidden: drawn.filter((d) => !d.show).length,
|
||||
datedPinNow: kml.icons.some((i) => i.meta?.name === 'QA KML pin'),
|
||||
fallbackPins: ['QA KML pin', 'QA palette pin'].filter((name) =>
|
||||
kml.icons.some((i) => i.meta?.name === name && i.image),
|
||||
).length,
|
||||
movingIsLine:
|
||||
kml.lines.filter((l) => l.meta?.name === 'QA moving').length === 1 &&
|
||||
!kml.icons.some((i) => i.meta?.name === 'QA moving'),
|
||||
movingVertices: kml.lines.find((l) => l.meta?.name === 'QA moving')
|
||||
?.positions.length,
|
||||
splitTracks: kml.lines
|
||||
.filter((l) => l.meta?.name === 'QA split tracks')
|
||||
.map((l) => l.positions.length),
|
||||
gpxLines: gpx.lines.length,
|
||||
gpxPoints: gpx.icons.length,
|
||||
kmzLocalImage: kmz.icons.some((i) =>
|
||||
String(i.image || '').startsWith('blob:'),
|
||||
),
|
||||
movingVertices:
|
||||
named('QA moving')?.polyline?.positions?.getValue(now)?.length,
|
||||
splitTracks: (sources[1].importedEntities || sources[1].entities.values)
|
||||
.filter((e) => e.parent?.name === 'QA split tracks' && e.polyline)
|
||||
.map((e) => e.polyline.positions.getValue(now).length),
|
||||
gpxLines: gpx.filter((e) => e.polyline).length,
|
||||
gpxPoints: gpx.filter((e) => e.billboard || e.point).length,
|
||||
kmzLocalImage: kmz.some((e) =>
|
||||
String(e.billboard?.image?.getValue(now) || '').startsWith('blob:'),
|
||||
kmzOverlay: kmz.shapes.some((s) => s.geometry.kind === 'rectangle'),
|
||||
groundedLines: [kml, kmz].every((d) =>
|
||||
d.lines.every((l) => l.mode === 'draped'),
|
||||
),
|
||||
xyzPolygon: park.shapes.every(
|
||||
(s) => s.geometry.kind !== 'polygon' || !s.geometry.perPositionHeight,
|
||||
),
|
||||
kmzOverlay: kmz.some((e) => e.rectangle),
|
||||
groundedLines: sources
|
||||
.slice(1, 3)
|
||||
.every((ds) =>
|
||||
(ds.importedEntities || ds.entities.values)
|
||||
.filter((e) => e.polyline)
|
||||
.every((e) => e.polyline.clampToGround?.getValue(now)),
|
||||
),
|
||||
xyzPolygon:
|
||||
(sources[0].importedEntities || sources[0].entities.values)
|
||||
.find((e) => e.polygon)
|
||||
?.polygon.perPositionHeight?.getValue(now) !== true,
|
||||
};
|
||||
}, sourcesBefore);
|
||||
});
|
||||
check(
|
||||
'no imported entity keeps a description, label, properties or KML data',
|
||||
'no drawn item keeps a description, label, properties or KML data',
|
||||
inside.sources === 4 &&
|
||||
inside.described +
|
||||
inside.labelled +
|
||||
@@ -423,7 +424,7 @@ try {
|
||||
JSON.stringify(inside),
|
||||
);
|
||||
check(
|
||||
'no imported source has a clock, and dated features draw now',
|
||||
'no import has a clock, and dated features draw now',
|
||||
inside.clocks === 0 &&
|
||||
inside.hidden === 0 &&
|
||||
inside.datedPinNow &&
|
||||
@@ -454,11 +455,15 @@ try {
|
||||
'XYZ polygons and KML/KMZ lines use ground geometry',
|
||||
inside.xyzPolygon && inside.groundedLines,
|
||||
);
|
||||
await page.evaluate((from) => {
|
||||
for (const entity of window.__godsEyeView.viewer.dataSources.get(from)
|
||||
.entities.values)
|
||||
if (entity.billboard) entity.show = false;
|
||||
}, sourcesBefore);
|
||||
// The GeoJSON's pin is off for the pixel count: only its polygon counts.
|
||||
await page.evaluate(() => {
|
||||
const tool = window.__gevGeoImport;
|
||||
const { sets } = tool.drawn(tool.list()[0].id);
|
||||
const primitives = window.__godsEyeView.viewer.scene.primitives;
|
||||
for (let i = 0; i < primitives.length; i++)
|
||||
if (primitives.get(i).drawSetId === sets.icons)
|
||||
primitives.get(i).show = false;
|
||||
});
|
||||
await page.evaluate((view) => {
|
||||
const viewer = window.__godsEyeView.viewer;
|
||||
viewer.camera.cancelFlight?.();
|
||||
@@ -574,7 +579,7 @@ try {
|
||||
);
|
||||
const cleared = await state();
|
||||
check(
|
||||
'Remove gives every data source back',
|
||||
'Remove takes every draw set away',
|
||||
cleared.rows === 0 && cleared.dataSources === before.dataSources,
|
||||
`${cleared.dataSources} vs ${before.dataSources}`,
|
||||
);
|
||||
|
||||
+79
-47
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* (i) LIVE — enabling the layer loads the default products (Common
|
||||
* Intelligence Picture and the 30-day kinetic pull) from the live
|
||||
* repository through /api/ghostmaps, one data source per product,
|
||||
* repository through /api/ghostmaps, one pin set per product,
|
||||
* matching the proxy's catalog commit; the row shows one chip per
|
||||
* catalog product with the defaults active, and the page holds an
|
||||
* open event stream to /api/ghostmaps/events.
|
||||
@@ -17,12 +17,14 @@
|
||||
* and clicking empty ground clears it.
|
||||
* (iii) PUSH (synthetic) — the event stream is replaced in the page and a
|
||||
* catalog naming a new edition of one product is pushed: only that
|
||||
* product reloads (a new data source replaces the old one, no
|
||||
* duplicates), the other keeps its data source. A catalog without a
|
||||
* product reloads (a new pin set replaces the old one, no
|
||||
* duplicates), the other keeps its pin set. A catalog without a
|
||||
* product removes it.
|
||||
* (iv) CHIPS — clicking an active product chip removes that product,
|
||||
* clicking it again restores it; the choice survives a reload.
|
||||
* (v) DISABLE — every GhostMaps data source leaves the viewer.
|
||||
* (v) DISABLE — every GhostMaps pin set leaves the viewer.
|
||||
* The checks read pins (billboards) only: a product's lines and fills
|
||||
* are not counted.
|
||||
* (vi) VIEWPORT — at a 390x844 phone viewport the open row and its chips
|
||||
* fit the panel width with no horizontal overflow.
|
||||
* (vii) FAR SIDE — pins skip the depth test, so they are horizon-culled:
|
||||
@@ -78,18 +80,43 @@ async function boot(page) {
|
||||
await page.keyboard.press('Escape');
|
||||
}
|
||||
|
||||
/** GhostMaps data sources on the viewer: name → entity count. */
|
||||
function ghostSources(prefix) {
|
||||
const { dataSources } = window.__godsEyeView.viewer;
|
||||
const out = [];
|
||||
for (let i = 0; i < dataSources.length; i++) {
|
||||
const ds = dataSources.get(i);
|
||||
if (ds.name?.startsWith(prefix))
|
||||
out.push({ name: ds.name, count: ds.entities.values.length });
|
||||
}
|
||||
/**
|
||||
* The GhostMaps pins drawn, by edition: each product's pins are drawn in a
|
||||
* billboard collection of their own (a data source's, or a draw set's), so
|
||||
* whatever draws them is read the same way. In the page: `layerId:product`
|
||||
* → `{collection, pins: [{show, position}]}`.
|
||||
*/
|
||||
function ghostPins(prefix) {
|
||||
const out = new Map();
|
||||
const seen = new Set();
|
||||
const visit = (node) => {
|
||||
if (!node || typeof node !== 'object' || seen.has(node)) return;
|
||||
seen.add(node);
|
||||
if (Array.isArray(node._billboards)) {
|
||||
for (const billboard of node._billboards) {
|
||||
const id = String(billboard?.id?.id ?? billboard?.id ?? '');
|
||||
if (!id.startsWith('ghostmaps:')) continue;
|
||||
const name = `${prefix}${id.split(':')[1]}`;
|
||||
if (!out.has(name)) out.set(name, { collection: node, pins: [] });
|
||||
out.get(name).pins.push(billboard);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (Array.isArray(node._primitives)) node._primitives.forEach(visit);
|
||||
visit(node._billboardCollection);
|
||||
};
|
||||
visit(window.__godsEyeView.viewer.scene.primitives);
|
||||
return out;
|
||||
}
|
||||
|
||||
/** GhostMaps editions drawn: name → pin count. */
|
||||
function ghostSources(prefix) {
|
||||
return [...ghostPins(prefix)].map(([name, { pins }]) => ({
|
||||
name,
|
||||
count: pins.length,
|
||||
}));
|
||||
}
|
||||
|
||||
function paintedOverlayPixels() {
|
||||
const canvas = document.getElementById('world-overlay-canvas');
|
||||
if (!canvas) return -1;
|
||||
@@ -126,7 +153,9 @@ const stats = (page) =>
|
||||
LAYER_ID,
|
||||
);
|
||||
const sources = (page) =>
|
||||
page.evaluate(`(${ghostSources})(${JSON.stringify(`${LAYER_ID}:`)})`);
|
||||
page.evaluate(
|
||||
`${ghostPins};(${ghostSources})(${JSON.stringify(`${LAYER_ID}:`)})`,
|
||||
);
|
||||
|
||||
async function showRow(page) {
|
||||
await page.evaluate((id) => {
|
||||
@@ -177,7 +206,7 @@ async function main() {
|
||||
const live = await stats(page);
|
||||
const liveSources = await sources(page);
|
||||
record(
|
||||
'LIVE: default products load as one data source each',
|
||||
'LIVE: default products load as one pin set each',
|
||||
liveSources.length === 2 &&
|
||||
liveSources.every((s) => s.count > 0) &&
|
||||
live.products.sort().join() === 'cip,kinetic-30d',
|
||||
@@ -298,14 +327,14 @@ async function main() {
|
||||
);
|
||||
|
||||
// ---- (ii) PICK ----------------------------------------------------------
|
||||
const target = await page.evaluate((id) => {
|
||||
const target = await page.evaluate(`(() => {
|
||||
${ghostPins};
|
||||
const gev = window.__godsEyeView;
|
||||
const ds = [...Array(gev.viewer.dataSources.length).keys()]
|
||||
.map((i) => gev.viewer.dataSources.get(i))
|
||||
.find((item) => item.name === `${id}:cip`);
|
||||
const entity = ds.entities.values.find((e) => e.billboard);
|
||||
const pin = ghostPins(${JSON.stringify(`${LAYER_ID}:`)}).get(
|
||||
${JSON.stringify(`${LAYER_ID}:cip`)},
|
||||
).pins[0];
|
||||
const carto = gev.viewer.scene.globe.ellipsoid.cartesianToCartographic(
|
||||
entity.position.getValue(gev.viewer.clock.currentTime),
|
||||
pin.position,
|
||||
);
|
||||
try {
|
||||
gev.viewer.camera.cancelFlight();
|
||||
@@ -321,8 +350,8 @@ async function main() {
|
||||
orientation: { heading: 0, pitch: -Math.PI / 2, roll: 0 },
|
||||
});
|
||||
gev.viewer.scene.requestRender?.();
|
||||
return entity.id;
|
||||
}, LAYER_ID);
|
||||
return String(pin.id?.id ?? pin.id);
|
||||
})()`);
|
||||
await page
|
||||
.waitForFunction(
|
||||
() => window.__godsEyeView.viewer.scene.globe.tilesLoaded,
|
||||
@@ -373,7 +402,7 @@ async function main() {
|
||||
};
|
||||
});
|
||||
record(
|
||||
'PICK: the centred marker picks as a GhostMaps entity',
|
||||
'PICK: the centred marker picks as a GhostMaps pin',
|
||||
probe.ids.some((id) => id.startsWith('ghostmaps:cip:')),
|
||||
`${target} → [${probe.ids.slice(0, 3).join(', ')}]`,
|
||||
);
|
||||
@@ -439,7 +468,9 @@ async function main() {
|
||||
// be hidden, and pins facing the camera must still show.
|
||||
const horizonCounts = (lon, lat) =>
|
||||
page.evaluate(
|
||||
async (id, lo, la) => {
|
||||
async (id, lo, la, pinsSource) => {
|
||||
// eslint-disable-next-line no-new-func
|
||||
const ghostPins = new Function(`return (${pinsSource})`)();
|
||||
const gev = window.__godsEyeView;
|
||||
const d2r = Math.PI / 180;
|
||||
try {
|
||||
@@ -462,12 +493,9 @@ async function main() {
|
||||
const norm = (v) => Math.hypot(v.x, v.y, v.z);
|
||||
let far = 0;
|
||||
let nearShown = 0;
|
||||
for (let i = 0; i < gev.viewer.dataSources.length; i++) {
|
||||
const ds = gev.viewer.dataSources.get(i);
|
||||
if (!ds.name?.startsWith(`${id}:`)) continue;
|
||||
for (const e of ds.entities.values) {
|
||||
if (!e.billboard) continue;
|
||||
const p = e.position.getValue(gev.viewer.clock.currentTime);
|
||||
for (const { pins } of ghostPins(`${id}:`).values()) {
|
||||
for (const e of pins) {
|
||||
const p = e.position;
|
||||
// Angle from the camera's nadir to the pin, against the
|
||||
// geometric horizon angle; the cull's 1 km margin shows pins up
|
||||
// to about 1° past it, so "clearly behind" is beyond 2°.
|
||||
@@ -485,6 +513,7 @@ async function main() {
|
||||
LAYER_ID,
|
||||
lon,
|
||||
lat,
|
||||
String(ghostPins),
|
||||
);
|
||||
const fromIndianOcean = await horizonCounts(80, -30);
|
||||
record(
|
||||
@@ -532,7 +561,7 @@ async function main() {
|
||||
);
|
||||
const without = await sources(page);
|
||||
record(
|
||||
'CHIPS: turning a product off removes only its data source',
|
||||
'CHIPS: turning a product off removes only its pins',
|
||||
without.length === 1 && without[0].name === `${LAYER_ID}:cip`,
|
||||
without.map((s) => s.name).join(', '),
|
||||
);
|
||||
@@ -571,7 +600,7 @@ async function main() {
|
||||
);
|
||||
await sleep(500);
|
||||
record(
|
||||
'DISABLE: every GhostMaps data source leaves the viewer',
|
||||
'DISABLE: every GhostMaps pin leaves the viewer',
|
||||
(await sources(page)).length === 0,
|
||||
);
|
||||
await page.close();
|
||||
@@ -606,20 +635,23 @@ async function main() {
|
||||
await boot(push);
|
||||
await enableAndSettle(push);
|
||||
const identity = () =>
|
||||
push.evaluate((id) => {
|
||||
const { dataSources } = window.__godsEyeView.viewer;
|
||||
window.__qaIds ||= new WeakMap();
|
||||
window.__qaNext ||= 1;
|
||||
const out = {};
|
||||
for (let i = 0; i < dataSources.length; i++) {
|
||||
const ds = dataSources.get(i);
|
||||
if (!ds.name?.startsWith(`${id}:`)) continue;
|
||||
if (!window.__qaIds.has(ds))
|
||||
window.__qaIds.set(ds, window.__qaNext++);
|
||||
out[ds.name] = window.__qaIds.get(ds);
|
||||
}
|
||||
return out;
|
||||
}, LAYER_ID);
|
||||
push.evaluate(
|
||||
(id, pinsSource) => {
|
||||
// eslint-disable-next-line no-new-func
|
||||
const ghostPins = new Function(`return (${pinsSource})`)();
|
||||
window.__qaIds ||= new WeakMap();
|
||||
window.__qaNext ||= 1;
|
||||
const out = {};
|
||||
for (const [name, { collection }] of ghostPins(`${id}:`)) {
|
||||
if (!window.__qaIds.has(collection))
|
||||
window.__qaIds.set(collection, window.__qaNext++);
|
||||
out[name] = window.__qaIds.get(collection);
|
||||
}
|
||||
return out;
|
||||
},
|
||||
LAYER_ID,
|
||||
String(ghostPins),
|
||||
);
|
||||
const first = await identity();
|
||||
const pushed = Date.now();
|
||||
await push.evaluate(async (id) => {
|
||||
|
||||
+87
-67
@@ -9,22 +9,24 @@
|
||||
* stub that route in the page so they are deterministic.
|
||||
*
|
||||
* (i) LIVE — over Poland and the southern Baltic the layer settles with no error,
|
||||
* one geometry per cell and legend band counts that sum to the cell
|
||||
* its cells drawn and legend band counts that sum to the cell
|
||||
* count; cells are required only when the returned rows, binned
|
||||
* with the layer's own rules, reach the per-cell minimum (live
|
||||
* traffic varies by hour). Requires a non-stale response no older than 60 s.
|
||||
* into H3 cells with the layer's own rules, give at least one cell
|
||||
* (live traffic varies by hour). Requires a non-stale response no older than 60 s.
|
||||
* (ii) BANDS (synthetic) — a 10-aircraft cell with 5 degraded is high,
|
||||
* a 30-aircraft cell with 2 degraded is medium, a 3-aircraft cell
|
||||
* with 1 degraded is low (first bad discounted), a clean cell at sea
|
||||
* is low, a 2-aircraft cell is withheld; `stale: true` reaches
|
||||
* is low, a 2-aircraft cell with 2 degraded is shown high (no
|
||||
* minimum aircraft count, as on gpsjam.org); `stale: true` reaches
|
||||
* getStats. Every band is drawn and low is shown over land and sea.
|
||||
* The row reads as low navigation accuracy, and stats carry the
|
||||
* machine-readable provenance (GEV classifier, gpsjam bands, window).
|
||||
* machine-readable provenance (GEV classifier, gpsjam bands and H3
|
||||
* grid, window).
|
||||
* PICK verifies actual perimeter and empty-ground clicks under GNSS.
|
||||
* CAMERA/GLOBE verify automatic sampling and the screen-centre anchor.
|
||||
* (iii) FAILURE — the route stubbed to 502: stats.error is set and the
|
||||
* cells already on the globe are kept.
|
||||
* (iv) DISABLE — owned ground primitives are hidden.
|
||||
* (iv) DISABLE — the cells' ground primitives are hidden.
|
||||
* (v) KEYBOARD — the row's toggle button, focused, turns the layer on
|
||||
* with Enter and off with Space, keeps focus and names its state.
|
||||
* (vi) VIEWPORT — at a 390x844 phone viewport the open row and its legend
|
||||
@@ -114,10 +116,34 @@ async function boot(page, { lon, lat, height }) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* In the page: the GNSS cells' ground primitives, each with the collection
|
||||
* drawing it. The layer draws them through the renderer's draw port as
|
||||
* ground fills that never take part in picks, the only such fills the app
|
||||
* draws, so they are found by that.
|
||||
*/
|
||||
function gnssGround() {
|
||||
const out = [];
|
||||
const walk = (collection) => {
|
||||
for (let i = 0; i < collection.length; i++) {
|
||||
const item = collection.get(i);
|
||||
if (typeof item?.length === 'number' && typeof item.get === 'function')
|
||||
walk(item);
|
||||
else if (
|
||||
item?.allowPicking === false &&
|
||||
item.classificationType !== undefined
|
||||
)
|
||||
out.push({ primitive: item, host: collection });
|
||||
}
|
||||
};
|
||||
walk(window.__godsEyeView.viewer.scene.primitives);
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Enable (or refresh) the layer and poll until it settles. */
|
||||
async function enableAndSettle(page, { refresh = false } = {}) {
|
||||
return page.evaluate(
|
||||
async (id, again) => {
|
||||
async (id, again, findGround) => {
|
||||
const dm = window.__godsEyeView.dataManager;
|
||||
const layer = dm.layers.get(id).module;
|
||||
if (again) await dm.refreshLayer(id);
|
||||
@@ -129,22 +155,21 @@ async function enableAndSettle(page, { refresh = false } = {}) {
|
||||
const rowName =
|
||||
document.querySelector(`[data-layer-id="${id}"] .data-name`)
|
||||
?.textContent ?? '';
|
||||
const all = window.__godsEyeView.viewer.scene.groundPrimitives;
|
||||
const ds = Array.from({ length: all.length }, (_, i) => all.get(i)).find(
|
||||
(item) => item.id === id,
|
||||
);
|
||||
// eslint-disable-next-line no-new-func
|
||||
const ground = new Function(`return (${findGround})()`)();
|
||||
return {
|
||||
stats,
|
||||
legend,
|
||||
blurb,
|
||||
rowName,
|
||||
name: layer.name,
|
||||
entities: ds?.get(0)?.geometryInstances.length ?? 0,
|
||||
shown: ds?.show ?? null,
|
||||
drawn: ground.length > 0,
|
||||
shown: ground[0]?.host.show ?? null,
|
||||
};
|
||||
},
|
||||
LAYER_ID,
|
||||
refresh,
|
||||
String(gnssGround),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -184,31 +209,21 @@ async function shoot(page, name) {
|
||||
await page.screenshot({ path: path.join(SHOTS_DIR, `gnss-${name}.png`) });
|
||||
}
|
||||
|
||||
/** Bounding-sphere state of every GNSS cell: DONE = 0, PENDING = 1, FAILED = 2. */
|
||||
function cellStates(id) {
|
||||
const { viewer } = window.__godsEyeView;
|
||||
const all = viewer.scene.groundPrimitives;
|
||||
const ds = Array.from({ length: all.length }, (_, i) => all.get(i)).find(
|
||||
(item) => item.id === id,
|
||||
);
|
||||
if (!ds?.length) return [];
|
||||
return [ds.get(0).ready ? 0 : 1];
|
||||
}
|
||||
/** Build state of every GNSS ground primitive: DONE = 0, PENDING = 1. */
|
||||
const cellStates = `() => (${gnssGround})().map(({ primitive }) => (primitive.ready ? 0 : 1))`;
|
||||
|
||||
/** Wait until every GNSS cell's ground rectangle has finished building. */
|
||||
/** Wait until every GNSS cell's ground polygon has finished building. */
|
||||
async function waitForBuiltCells(page, timeoutMs = 60000) {
|
||||
const built = await page
|
||||
.waitForFunction(
|
||||
`(${cellStates})(${JSON.stringify(LAYER_ID)}).every((state) => state === 0)`,
|
||||
{ timeout: timeoutMs, polling: 250 },
|
||||
)
|
||||
.waitForFunction(`(${cellStates})().every((state) => state === 0)`, {
|
||||
timeout: timeoutMs,
|
||||
polling: 250,
|
||||
})
|
||||
.then(
|
||||
() => true,
|
||||
() => false,
|
||||
);
|
||||
const states = await page.evaluate(
|
||||
`(${cellStates})(${JSON.stringify(LAYER_ID)})`,
|
||||
);
|
||||
const states = await page.evaluate(`(${cellStates})()`);
|
||||
return { built, detail: `states=${JSON.stringify(states)}` };
|
||||
}
|
||||
|
||||
@@ -223,22 +238,23 @@ const fixtureRow = (hex, lat, lon, degraded) => ({
|
||||
});
|
||||
|
||||
/**
|
||||
* Synthetic 0.5° cells: high at sea (5/10 bad), medium on land (2/30 bad),
|
||||
* low on land (1/3 bad), low at sea (0/4 bad), withheld (2 aircraft).
|
||||
* Synthetic H3 res-4 cells, each group inside one hexagon: high at sea
|
||||
* (5/10 bad), medium on land (2/30 bad), low on land (1/3 bad), low at sea
|
||||
* (0/4 bad), and high from only 2 aircraft (2/2 bad; no minimum count).
|
||||
*/
|
||||
function fixturePayload() {
|
||||
const rows = [];
|
||||
const hex = (prefix, i) => `${prefix}${i.toString(16).padStart(2, '0')}`;
|
||||
for (let i = 0; i < 10; i++)
|
||||
rows.push(fixtureRow(hex('a000', i), 55.1 + i * 0.01, 19.1, i < 5));
|
||||
rows.push(fixtureRow(hex('a000', i), 55.1 + i * 0.001, 19.1, i < 5));
|
||||
for (let i = 0; i < 30; i++)
|
||||
rows.push(fixtureRow(hex('d000', i), 54.1 + i * 0.01, 19.6, i < 2));
|
||||
rows.push(fixtureRow(hex('d000', i), 54.1 + i * 0.001, 19.6, i < 2));
|
||||
for (let i = 0; i < 3; i++)
|
||||
rows.push(fixtureRow(hex('b000', i), 54.1 + i * 0.01, 18.1, i === 0));
|
||||
rows.push(fixtureRow(hex('b000', i), 54.1 + i * 0.001, 18.1, i === 0));
|
||||
for (let i = 0; i < 4; i++)
|
||||
rows.push(fixtureRow(hex('e000', i), 55.1 + i * 0.01, 18.1, false));
|
||||
rows.push(fixtureRow(hex('e000', i), 55.1 + i * 0.001, 18.1, false));
|
||||
for (let i = 0; i < 2; i++)
|
||||
rows.push(fixtureRow(hex('c000', i), 53.1 + i * 0.01, 17.1, true));
|
||||
rows.push(fixtureRow(hex('c000', i), 53.1 + i * 0.001, 17.1, true));
|
||||
return {
|
||||
fetchedAt: Date.now(),
|
||||
anchor: { lat: 55, lon: 19 },
|
||||
@@ -385,8 +401,8 @@ async function main() {
|
||||
const l = await enableAndSettle(live);
|
||||
const legendTotal = l.legend.reduce((sum, { count }) => sum + count, 0);
|
||||
// Bin what adsb.lol actually returned with the layer's own rules: live
|
||||
// traffic varies by hour, so cells are required only when some cell
|
||||
// really reached the minimum aircraft count.
|
||||
// traffic varies by hour, so cells are required only when the rows
|
||||
// really bin into some cell.
|
||||
const liveSnapshots = (await Promise.allSettled(liveBodies))
|
||||
.filter((r) => r.status === 'fulfilled')
|
||||
.map((r) => r.value);
|
||||
@@ -417,9 +433,9 @@ async function main() {
|
||||
}
|
||||
const expectedCells = binGnssCells(expectedStore).length;
|
||||
record(
|
||||
'LIVE: no error, one geometry per cell',
|
||||
!l.stats.error && l.entities === l.stats.count,
|
||||
`cells=${l.stats.count} entities=${l.entities} error=${JSON.stringify(l.stats.error)}`,
|
||||
'LIVE: no error, cells drawn when there are any',
|
||||
!l.stats.error && l.drawn === l.stats.count > 0,
|
||||
`cells=${l.stats.count} drawn=${l.drawn} error=${JSON.stringify(l.stats.error)}`,
|
||||
);
|
||||
if (expectedCells > 0) {
|
||||
record(
|
||||
@@ -429,7 +445,7 @@ async function main() {
|
||||
);
|
||||
} else {
|
||||
console.log(
|
||||
` [info] ${liveRows} live rows, no cell reaches the minimum — cell count not asserted`,
|
||||
` [info] ${liveRows} live rows bin into no cell — cell count not asserted`,
|
||||
);
|
||||
}
|
||||
record(
|
||||
@@ -439,7 +455,7 @@ async function main() {
|
||||
);
|
||||
const liveBuilt = await waitForBuiltCells(live);
|
||||
record(
|
||||
'LIVE: every cell rectangle is built on a parked camera',
|
||||
'LIVE: every cell polygon is built on a parked camera',
|
||||
liveBuilt.built,
|
||||
liveBuilt.detail,
|
||||
);
|
||||
@@ -454,7 +470,7 @@ async function main() {
|
||||
await page.setViewport({ width: 1440, height: 900 });
|
||||
page.on('pageerror', (e) => errors.push(e.message));
|
||||
// Stub the route in-page rather than with request interception: an
|
||||
// intercepted page stalls Cesium's geometry workers, so ground rectangles
|
||||
// intercepted page stalls Cesium's geometry workers, so ground polygons
|
||||
// never finish building and the screenshot would not show real behaviour.
|
||||
await stubRoute(page);
|
||||
await boot(page, { lon: 18.6, lat: 54.6, height: 450_000 });
|
||||
@@ -462,25 +478,27 @@ async function main() {
|
||||
const band = (prefix) =>
|
||||
f.legend.find(({ label }) => label.startsWith(prefix))?.count;
|
||||
record(
|
||||
'BANDS: 4 cells shown, the 2-aircraft cell withheld',
|
||||
f.stats.count === 4 && f.entities === 4,
|
||||
`cells=${f.stats.count} entities=${f.entities}`,
|
||||
'BANDS: 5 cells shown, the 2-aircraft cell included',
|
||||
f.stats.count === 5 && f.drawn,
|
||||
`cells=${f.stats.count} drawn=${f.drawn}`,
|
||||
);
|
||||
record(
|
||||
'BANDS: 5/10 is high, 2/30 is medium, 1/3 and 0/4 are low',
|
||||
band('Low-accuracy score >') === 1 &&
|
||||
'BANDS: 5/10 and 2/2 are high, 2/30 is medium, 1/3 and 0/4 are low',
|
||||
band('Low-accuracy score >') === 2 &&
|
||||
band('Low-accuracy score 2') === 1 &&
|
||||
band('Low-accuracy score <') === 2,
|
||||
JSON.stringify(f.legend),
|
||||
);
|
||||
const prov = f.stats.provenance;
|
||||
record(
|
||||
'PROVENANCE: GEV classifier, gpsjam bands and visited-view window are machine-readable',
|
||||
'PROVENANCE: GEV classifier, gpsjam bands and H3 grid, and visited-view window are machine-readable',
|
||||
prov?.classifier?.id === 'gev-nic-nacp-v2' &&
|
||||
prov.classifier.definedBy === 'GEV' &&
|
||||
prov.classifier.validated === false &&
|
||||
prov.aggregation?.source === 'https://gpsjam.org/faq' &&
|
||||
JSON.stringify(prov.aggregation.bands) === '[2,10]' &&
|
||||
prov.aggregation.grid === 'h3' &&
|
||||
prov.aggregation.h3Resolution === 4 &&
|
||||
prov.window?.minutes === 30 &&
|
||||
prov.window.scope === 'visited-view' &&
|
||||
prov.interpretation?.validated === false,
|
||||
@@ -503,7 +521,7 @@ async function main() {
|
||||
);
|
||||
const bandsBuilt = await waitForBuiltCells(page);
|
||||
record(
|
||||
'BANDS: every cell rectangle is built on a parked camera',
|
||||
'BANDS: every cell polygon is built on a parked camera',
|
||||
bandsBuilt.built,
|
||||
bandsBuilt.detail,
|
||||
);
|
||||
@@ -769,20 +787,22 @@ async function main() {
|
||||
const e = await enableAndSettle(page, { refresh: true });
|
||||
record(
|
||||
'FAILURE: error surfaced, cells kept',
|
||||
Boolean(e.stats.error) && e.stats.count === 4 && e.entities === 4,
|
||||
Boolean(e.stats.error) && e.stats.count === 5 && e.drawn,
|
||||
`error=${JSON.stringify(e.stats.error)} cells=${e.stats.count}`,
|
||||
);
|
||||
await shoot(page, 'failure');
|
||||
|
||||
// ── (iv) DISABLE ──────────────────────────────────────────────────────
|
||||
console.log('\n(iv) DISABLE...');
|
||||
const shown = await page.evaluate(async (id) => {
|
||||
await window.__godsEyeView.dataManager.setEnabled(id, false);
|
||||
const all = window.__godsEyeView.viewer.scene.groundPrimitives;
|
||||
return Array.from({ length: all.length }, (_, i) => all.get(i)).find(
|
||||
(item) => item.id === id,
|
||||
)?.show;
|
||||
}, LAYER_ID);
|
||||
const shown = await page.evaluate(
|
||||
async (id, findGround) => {
|
||||
await window.__godsEyeView.dataManager.setEnabled(id, false);
|
||||
// eslint-disable-next-line no-new-func
|
||||
return new Function(`return (${findGround})()`)()[0]?.host.show;
|
||||
},
|
||||
LAYER_ID,
|
||||
String(gnssGround),
|
||||
);
|
||||
record('DISABLE: data source hidden', shown === false, `show=${shown}`);
|
||||
await shoot(page, 'disabled');
|
||||
|
||||
@@ -797,7 +817,7 @@ async function main() {
|
||||
'KEYBOARD: Enter on the focused toggle enables the layer and keeps focus',
|
||||
on.enabled &&
|
||||
on.focused &&
|
||||
on.count === 4 &&
|
||||
on.count === 5 &&
|
||||
/^GNSS Integrity: /.test(on.label) &&
|
||||
!/OFF$/.test(on.label),
|
||||
JSON.stringify(on),
|
||||
@@ -906,7 +926,7 @@ async function main() {
|
||||
return (
|
||||
layer.enabled &&
|
||||
layer.module.getStats().error === null &&
|
||||
layer.module.getStats().count === 4
|
||||
layer.module.getStats().count === 5
|
||||
);
|
||||
},
|
||||
{ timeout: 20000 },
|
||||
@@ -948,8 +968,8 @@ async function main() {
|
||||
const old = await enableAndSettle(aged, {});
|
||||
record(
|
||||
'AGE: a snapshot observed 31 min ago adds no cells and is not an error',
|
||||
old.stats.count === 0 && old.entities === 0 && !old.stats.error,
|
||||
`cells=${old.stats.count} entities=${old.entities} error=${JSON.stringify(old.stats.error)}`,
|
||||
old.stats.count === 0 && !old.drawn && !old.stats.error,
|
||||
`cells=${old.stats.count} drawn=${old.drawn} error=${JSON.stringify(old.stats.error)}`,
|
||||
);
|
||||
await aged.evaluate(() => {
|
||||
window.__gnssQaAgeMs = 29 * 60_000;
|
||||
@@ -957,8 +977,8 @@ async function main() {
|
||||
const recent = await enableAndSettle(aged, { refresh: true });
|
||||
record(
|
||||
'AGE: the same snapshot observed 29 min ago is still inside the window',
|
||||
recent.stats.count === 4 && recent.entities === 4,
|
||||
`cells=${recent.stats.count} entities=${recent.entities}`,
|
||||
recent.stats.count === 5 && recent.drawn,
|
||||
`cells=${recent.stats.count} drawn=${recent.drawn}`,
|
||||
);
|
||||
await aged.close();
|
||||
record(
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
* the DISPLAYED (render-delayed) time within 35° — catches
|
||||
* sign/offset inversion in the whole chain (chord lags the
|
||||
* tangent by ≤ half a segment ≈ 22.5°)
|
||||
* Both layers: flights (airplane.glb, offset 180°) then military (jet.glb,
|
||||
* Both layers: flights (fleet models, offset 180°) then military (fleet models,
|
||||
* normalized nose -X, offset 180°).
|
||||
*
|
||||
* VISUAL — with the turning flights plane tracked in 3D, capture screenshots
|
||||
@@ -170,8 +170,8 @@ async function observeTrackedHostPaint(page, timeoutMs = 5000) {
|
||||
const tracked = viewer?.trackedEntity;
|
||||
const current = {
|
||||
elapsedMs: Math.round(performance.now() - startedAt),
|
||||
entryId: tracked?.gevTrackedId || null,
|
||||
hasPresentationModel: Boolean(tracked?.gevLabelModel?.title),
|
||||
entryId: window.__godsEyeView?.entityRecords?.read(tracked)?.trackedId || null,
|
||||
hasPresentationModel: Boolean(window.__godsEyeView?.entityRecords?.read(tracked)?.labelModel?.title),
|
||||
candidateCount: diagnostics.candidateCount || 0,
|
||||
projectedCount: diagnostics.projectedCount || 0,
|
||||
selectedCount: diagnostics.selectedCount || 0,
|
||||
@@ -612,7 +612,7 @@ async function main() {
|
||||
if (!pool.length) return null;
|
||||
const ent = v.trackedEntity;
|
||||
let tracked = null;
|
||||
if (ent && typeof ent.gevDisplayPosition === 'function') tracked = ent.gevDisplayPosition();
|
||||
if (ent && typeof window.__godsEyeView.entityRecords.read(ent)?.displayPosition === 'function') tracked = window.__godsEyeView.entityRecords.read(ent)?.displayPosition();
|
||||
if (!tracked) return pool[0];
|
||||
let best = null, bestD = Infinity;
|
||||
for (const m of pool) {
|
||||
@@ -721,7 +721,7 @@ async function main() {
|
||||
// ========================================================================
|
||||
// Phase 1 — FLIGHTS layer: track TRN001, sample displayed course 30 s
|
||||
// ========================================================================
|
||||
console.log('\nPhase 1 — flights layer (airplane.glb, heading offset 180°)');
|
||||
console.log('\nPhase 1 — flights layer (fleet models, heading offset 180°)');
|
||||
await page.evaluate((icao) => {
|
||||
window.__godsEyeView.dataManager.layers.get('flights').module.trackById(icao);
|
||||
}, TURN.flights[0].icao);
|
||||
@@ -807,7 +807,7 @@ async function main() {
|
||||
// ========================================================================
|
||||
// Phase 2 — MILITARY layer: track TRNMIL1 (flights layer auto-clears)
|
||||
// ========================================================================
|
||||
console.log('\nPhase 2 — military layer (jet.glb, heading offset 180°)');
|
||||
console.log('\nPhase 2 — military layer (fleet models, heading offset 180°)');
|
||||
await page.evaluate((hex) => {
|
||||
window.__godsEyeView.dataManager.layers.get('military').module.trackById(hex);
|
||||
}, TURN.military[0].hex);
|
||||
|
||||
@@ -218,9 +218,11 @@ try {
|
||||
const gev = window.__godsEyeView;
|
||||
const snap = () => infraIds.map((id) => {
|
||||
const visibleIds = [];
|
||||
// The app registers each local feature's context as `<layer id>:<feature id>`.
|
||||
for (let i = 0; i < gev.viewer.dataSources.length; i++) {
|
||||
for (const entity of gev.viewer.dataSources.get(i).entities.values) {
|
||||
if (entity.__localLayerId === id && entity.show) visibleIds.push(String(entity.id));
|
||||
const contextId = gev.entityRecords.read(entity)?.contextId;
|
||||
if (contextId?.startsWith(`${id}:`) && entity.show) visibleIds.push(String(entity.id));
|
||||
}
|
||||
}
|
||||
return visibleIds.sort();
|
||||
|
||||
@@ -40,9 +40,29 @@ try {
|
||||
page.on('console', (m) => {
|
||||
if (m.type() === 'error') result.errors.push(m.text());
|
||||
});
|
||||
await page.evaluateOnNewDocument(() =>
|
||||
sessionStorage.setItem('gev:first-run-mission-session:v1', 'dismissed'),
|
||||
);
|
||||
await page.evaluateOnNewDocument(() => {
|
||||
sessionStorage.setItem('gev:first-run-mission-session:v1', 'dismissed');
|
||||
// The site dots the layer draws, read from its draw-port point set: each
|
||||
// row is a drawn dot whose pick id is the draw port's `{set, id, meta}`;
|
||||
// `meta` is the site's carrier, kept while the site's geometry is.
|
||||
window.__qaInstallationDots = () => {
|
||||
const out = [];
|
||||
const visit = (node) => {
|
||||
if (!node || typeof node.get !== 'function') return;
|
||||
if (typeof node.length !== 'number') return;
|
||||
for (let index = 0; index < node.length; index += 1) {
|
||||
const child = node.get(index);
|
||||
const id = child?.id;
|
||||
if (id && typeof id === 'object' && typeof id.set === 'string') {
|
||||
if (/^military-installations:\d+:dots$/.test(id.set))
|
||||
out.push({ id: id.id, meta: id.meta, primitive: child });
|
||||
} else visit(child);
|
||||
}
|
||||
};
|
||||
visit(window.__godsEyeView.viewer.scene.primitives);
|
||||
return out;
|
||||
};
|
||||
});
|
||||
await page.goto(
|
||||
args.find((a) => /^https?:/.test(a)),
|
||||
{ waitUntil: 'domcontentloaded' },
|
||||
@@ -156,14 +176,15 @@ try {
|
||||
.catch(() => {});
|
||||
const snapshot = await page.evaluate(() => {
|
||||
const g = window.__godsEyeView;
|
||||
const ds = g.viewer.dataSources.getByName('military-installations')[0];
|
||||
const points = ds.entities.values.filter((e) => e.point);
|
||||
const points = window.__qaInstallationDots();
|
||||
const stable = points.every(
|
||||
(e) =>
|
||||
!window.installationEntityRefs.has(e.id) ||
|
||||
window.installationEntityRefs.get(e.id) === e,
|
||||
window.installationEntityRefs.get(e.id) === e.meta,
|
||||
);
|
||||
window.installationEntityRefs = new Map(
|
||||
points.map((e) => [e.id, e.meta]),
|
||||
);
|
||||
window.installationEntityRefs = new Map(points.map((e) => [e.id, e]));
|
||||
return {
|
||||
...g.dataManager.layers
|
||||
.get('military-installations')
|
||||
@@ -186,7 +207,7 @@ try {
|
||||
new Set(row.ids).size !== row.ids.length
|
||||
)
|
||||
result.failures.push(
|
||||
`${name}/${height}: unstable or duplicate site entities`,
|
||||
`${name}/${height}: unstable or duplicate site markers`,
|
||||
);
|
||||
if (name.endsWith('return')) {
|
||||
const first = result.views.find(
|
||||
@@ -244,10 +265,7 @@ try {
|
||||
0.6,
|
||||
);
|
||||
await page.waitForFunction(
|
||||
() =>
|
||||
window.__godsEyeView.viewer.dataSources
|
||||
.getByName('military-installations')[0]
|
||||
.entities.values.some((e) => e.point),
|
||||
() => window.__qaInstallationDots().length > 0,
|
||||
{ timeout: 5000 },
|
||||
);
|
||||
await page.evaluate(() => {
|
||||
@@ -268,8 +286,7 @@ try {
|
||||
await sleep(1000);
|
||||
await page.evaluate(async () => {
|
||||
const g = window.__godsEyeView;
|
||||
const ds = g.viewer.dataSources.getByName('military-installations')[0];
|
||||
const id = ds.entities.values.find((e) => e.point).id;
|
||||
const id = window.__qaInstallationDots()[0].id;
|
||||
window.installationSubjectId = id;
|
||||
await g.dataManager.layers
|
||||
.get('military-awareness')
|
||||
|
||||
@@ -17,9 +17,11 @@ export async function checkInstallationPan(page, dir) {
|
||||
'military-installations',
|
||||
).module;
|
||||
const centerIds = [];
|
||||
// The app registers each local feature's context as `<layer id>:<feature id>`.
|
||||
for (let i = 0; i < g.viewer.dataSources.length; i++)
|
||||
for (const e of g.viewer.dataSources.get(i).entities.values)
|
||||
if (e.__localLayerId === 'local-datacenters') centerIds.push(e.id);
|
||||
if (g.entityRecords.read(e)?.contextId?.startsWith('local-datacenters:'))
|
||||
centerIds.push(e.id);
|
||||
window.__polishPanFrames = [];
|
||||
window.__stopPolishPan = g.viewer.scene.postRender.addEventListener(() => {
|
||||
const sites = [],
|
||||
@@ -175,18 +177,13 @@ export async function checkInstallationSelection(
|
||||
await import('/src/data/contextStore.js');
|
||||
const { getOverlayPaintRect, getWorldOverlayDiagnostics } =
|
||||
await import('/src/overlays/worldOverlay.js');
|
||||
const knownFills = new Set();
|
||||
const fillEntities = () => {
|
||||
const list = [];
|
||||
for (let i = 0; i < g.viewer.dataSources.length; i++)
|
||||
for (const e of g.viewer.dataSources.get(i).entities.values)
|
||||
if (e.id.startsWith(`${record.id}:selected-fill:`)) list.push(e);
|
||||
for (const e of list) knownFills.add(e);
|
||||
return list;
|
||||
};
|
||||
// Geometry-instance ids prove the ground primitive actually built, not just an entity declaration.
|
||||
const primitives = () => {
|
||||
let count = 0;
|
||||
// The selected site's fill parts, as the ground primitives built for
|
||||
// the layer's fill set hold them: each instance's id is the
|
||||
// draw port's pick id `{set, id}`. Only built, shown instances count,
|
||||
// so this proves the ground primitive actually built, not just an
|
||||
// item declaration.
|
||||
const fillParts = () => {
|
||||
const parts = [];
|
||||
const walk = (collection) => {
|
||||
if (collection?._collectionsArray) {
|
||||
for (const child of collection._collectionsArray) walk(child);
|
||||
@@ -194,31 +191,44 @@ export async function checkInstallationSelection(
|
||||
}
|
||||
for (let i = 0; i < (collection?.length || 0); i++) {
|
||||
const p = collection.get(i);
|
||||
if (
|
||||
p.ready &&
|
||||
typeof p.getGeometryInstanceAttributes === 'function'
|
||||
) {
|
||||
for (const e of knownFills) {
|
||||
const ids = p?._primitive?._primitive?._instanceIds;
|
||||
if (p?.ready && Array.isArray(ids))
|
||||
for (const id of ids) {
|
||||
if (
|
||||
!/^military-installations:\d+:fills$/.test(id?.set) ||
|
||||
!String(id.id).startsWith(`${record.id}:selected-fill:`)
|
||||
)
|
||||
continue;
|
||||
try {
|
||||
const a = p.getGeometryInstanceAttributes(e);
|
||||
if (a && (!a.show || a.show[0])) count++;
|
||||
const a = p.getGeometryInstanceAttributes(id);
|
||||
if (a && (!a.show || a.show[0]))
|
||||
parts.push({
|
||||
id: id.id,
|
||||
classification: p.classificationType,
|
||||
});
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
if (typeof p.get === 'function' || p._collectionsArray) walk(p);
|
||||
if (typeof p?.get === 'function' || p?._collectionsArray)
|
||||
walk(p);
|
||||
}
|
||||
};
|
||||
// The draw port adds its ground primitives under the scene's
|
||||
// primitives, in its set's collection.
|
||||
walk(g.viewer.scene.groundPrimitives);
|
||||
return count;
|
||||
walk(g.viewer.scene.primitives);
|
||||
return parts;
|
||||
};
|
||||
window.__polishFillProbe = () => {
|
||||
const parts = fillParts();
|
||||
return {
|
||||
// Distinct fill parts drawn, and the built instances drawing them
|
||||
// (a ground swap can draw a part twice while it lasts).
|
||||
entities: new Set(parts.map((part) => part.id)).size,
|
||||
primitives: parts.length,
|
||||
classification: parts.map((part) => part.classification),
|
||||
selected: getSelectedEntityContext()?.id || null,
|
||||
};
|
||||
};
|
||||
window.__polishFillProbe = () => ({
|
||||
entities: fillEntities().length,
|
||||
primitives: primitives(),
|
||||
classification: fillEntities().map((e) =>
|
||||
e.polygon.classificationType.getValue(),
|
||||
),
|
||||
selected: getSelectedEntityContext()?.id || null,
|
||||
});
|
||||
window.__stopPolishSelection =
|
||||
g.viewer.scene.postRender.addEventListener(() => {
|
||||
window.__polishSelectionFrames.push({
|
||||
@@ -333,7 +343,8 @@ export async function checkInstallationSelection(
|
||||
for (let y = 250; y < 650; y += 75)
|
||||
for (let x = 400; x < 850; x += 75) {
|
||||
const pick = g.viewer.scene.pick({ x, y });
|
||||
if (!pick?.id?.installationId && !pick?.id?.gevTrackedId)
|
||||
// Nothing picked: no installation marker, outline or tracked contact.
|
||||
if (!pick?.id)
|
||||
return { x, y };
|
||||
}
|
||||
throw new Error('No empty map point');
|
||||
|
||||
@@ -257,10 +257,6 @@ async function main() {
|
||||
() => window.__godsEyeView?.viewer && window.__godsEyeView?.styleManager,
|
||||
{ timeout: 60_000, polling: 100 },
|
||||
);
|
||||
// flyToAustin arrives ~500 ms after init; let it start and land before any
|
||||
// scene sets its own pose, or the arrival overwrites the first camera.
|
||||
await new Promise((resolve) => setTimeout(resolve, 2500));
|
||||
|
||||
const selected = SCENE_FILTER.length
|
||||
? SCENES.filter((scene) => SCENE_FILTER.some((prefix) => scene.id.startsWith(prefix)))
|
||||
: SCENES;
|
||||
|
||||
@@ -267,12 +267,6 @@ async function main() {
|
||||
{ timeout: 60000, polling: 100 },
|
||||
);
|
||||
|
||||
// flyToAustin schedules its 600 m arrival 500 ms after initialization.
|
||||
// Let that callback start, then cancel it before establishing the global
|
||||
// measurement camera so startup motion cannot invalidate the sample.
|
||||
await new Promise((resolve) => setTimeout(resolve, 600));
|
||||
await page.evaluate(() => window.__godsEyeView.viewer.camera.cancelFlight());
|
||||
|
||||
const stateChecks = await page.evaluate((storageKey) => {
|
||||
const manager = window.__godsEyeView.styleManager;
|
||||
const restored = manager.getDetectionState();
|
||||
|
||||
@@ -342,7 +342,7 @@ try {
|
||||
const before = {
|
||||
activeId: controller.getActiveId(),
|
||||
creditVisible: document.body.innerText.includes('Powered by Esri'),
|
||||
globeShown: styleManager.viewer.scene.globe.show,
|
||||
globeShown: window.__godsEyeView.viewer.scene.globe.show,
|
||||
hasLayer: Boolean(controller._imageryLayer),
|
||||
};
|
||||
provider?.errorEvent?.raiseEvent?.({ timesRetried: 0 });
|
||||
@@ -369,7 +369,7 @@ try {
|
||||
activeId: controller.getActiveId(),
|
||||
lastError: controller.getState().lastError,
|
||||
creditVisible: document.body.innerText.includes('Powered by Esri'),
|
||||
globeShown: styleManager.viewer.scene.globe.show,
|
||||
globeShown: window.__godsEyeView.viewer.scene.globe.show,
|
||||
hasLayer: Boolean(controller._imageryLayer),
|
||||
active: [...document.querySelectorAll('.map-stack-chip')]
|
||||
.filter((chip) => chip.getAttribute('aria-pressed') === 'true')
|
||||
|
||||
@@ -1277,8 +1277,9 @@ try {
|
||||
outlines = 0;
|
||||
for (let i = 0; i < viewer.dataSources.length; i++)
|
||||
for (const entity of viewer.dataSources.get(i).entities.values) {
|
||||
if (!ids.has(entity.installationId || entity.id) || !entity.show)
|
||||
continue;
|
||||
// Outline entities are `<record id>:outline:<ring>`.
|
||||
const recordId = String(entity.id).replace(/:outline:\d+$/, '');
|
||||
if (!ids.has(recordId) || !entity.show) continue;
|
||||
if (entity.billboard || entity.point) markers++;
|
||||
if (entity.polyline) outlines++;
|
||||
}
|
||||
|
||||
+138
-107
@@ -184,6 +184,50 @@ async function main() {
|
||||
queueMicrotask(() => this.dispatchEvent(new Event('playing')));
|
||||
return Promise.resolve();
|
||||
};
|
||||
// What Radio draws, read from the renderer's draw-port sets: the
|
||||
// station dots (`stations`), cluster dots (`clusters`), and the
|
||||
// selected station's dot (`selected`) and bracket
|
||||
// (`selected-bracket`). Each row is a drawn point or billboard whose
|
||||
// pick id is the draw port's `{set, id, meta}`; `show` is whether it
|
||||
// draws, its set's host included.
|
||||
window.__qaRadioRows = (kind) => {
|
||||
const pattern = new RegExp(`^radio:\\d+:${kind}$`);
|
||||
const out = [];
|
||||
const visit = (node, shown) => {
|
||||
if (!node || typeof node.get !== 'function' || typeof node.length !== 'number') return;
|
||||
const here = shown && node.show !== false;
|
||||
for (let index = 0; index < node.length; index += 1) {
|
||||
const child = node.get(index);
|
||||
const id = child?.id;
|
||||
if (id && typeof id === 'object' && !Array.isArray(id) && typeof id.set === 'string') {
|
||||
if (pattern.test(id.set)) {
|
||||
out.push({
|
||||
primitive: child,
|
||||
id: id.id,
|
||||
meta: id.meta,
|
||||
show: here && child.show !== false,
|
||||
setShown: here,
|
||||
});
|
||||
}
|
||||
} else visit(child, here);
|
||||
}
|
||||
};
|
||||
visit(window.__godsEyeView.viewer.scene.primitives, true);
|
||||
return out;
|
||||
};
|
||||
// The selected station's drawn dot and bracket, with its pick id.
|
||||
window.__qaRadioSelected = () => {
|
||||
const dot = window.__qaRadioRows('selected')[0] || null;
|
||||
if (!dot) return null;
|
||||
const bracket = window.__qaRadioRows('selected-bracket')[0] || null;
|
||||
return {
|
||||
id: dot.id,
|
||||
show: dot.show,
|
||||
position: dot.primitive.position,
|
||||
dot,
|
||||
bracket,
|
||||
};
|
||||
};
|
||||
});
|
||||
await page.setRequestInterception(true);
|
||||
let catalogDegraded = false;
|
||||
@@ -420,7 +464,7 @@ async function main() {
|
||||
await new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)));
|
||||
const result = {
|
||||
presentationActive: module.getUIState().presentationActive,
|
||||
markerSourceVisible: gev.viewer.dataSources.getByName('Radio stations')[0]?.show,
|
||||
markerSourceVisible: (window.__qaRadioRows('stations')[0]?.setShown ?? false),
|
||||
tunerHidden: document.getElementById('radio-tuner').hidden,
|
||||
filterDisabled: document.getElementById('radio-filter').disabled,
|
||||
prevDisabled: document.getElementById('radio-prev-btn').disabled,
|
||||
@@ -514,7 +558,7 @@ async function main() {
|
||||
const disablingPresentation = await page.evaluate(() => ({
|
||||
manager: window.__godsEyeView.dataManager.getLayerLifecycleState('radio'),
|
||||
presentationActive: window.__godsEyeView.dataManager.layers.get('radio').module.getUIState().presentationActive,
|
||||
markerSourceVisible: window.__godsEyeView.viewer.dataSources.getByName('Radio stations')[0]?.show,
|
||||
markerSourceVisible: (window.__qaRadioRows('stations')[0]?.setShown ?? false),
|
||||
full: document.getElementById('radio-enable-btn').textContent,
|
||||
layerState: document.getElementById('radio-layer-state').textContent,
|
||||
message: document.getElementById('radio-playback-state').textContent,
|
||||
@@ -583,7 +627,7 @@ async function main() {
|
||||
const enablingPresentation = await page.evaluate(() => ({
|
||||
manager: window.__godsEyeView.dataManager.getLayerLifecycleState('radio'),
|
||||
presentationActive: window.__godsEyeView.dataManager.layers.get('radio').module.getUIState().presentationActive,
|
||||
markerSourceVisible: window.__godsEyeView.viewer.dataSources.getByName('Radio stations')[0]?.show,
|
||||
markerSourceVisible: (window.__qaRadioRows('stations')[0]?.setShown ?? false),
|
||||
full: document.getElementById('radio-enable-btn').textContent,
|
||||
layerState: document.getElementById('radio-layer-state').textContent,
|
||||
message: document.getElementById('radio-playback-state').textContent,
|
||||
@@ -687,8 +731,6 @@ async function main() {
|
||||
const sample = await page.evaluate(async () => {
|
||||
const viewer = window.__godsEyeView.viewer;
|
||||
const radio = window.__godsEyeView.dataManager.layers.get('radio').module;
|
||||
const dataSource = Array.from({ length: viewer.dataSources.length }, (_, index) => viewer.dataSources.get(index))
|
||||
.find((item) => item.name === 'Radio stations');
|
||||
const { getOverlayPaintRect, getWorldOverlayDiagnostics } = await import('/src/overlays/worldOverlay.js');
|
||||
const { radioStationIdFromPick } = await import('/src/data/radio.js');
|
||||
return new Promise((resolve) => {
|
||||
@@ -710,7 +752,9 @@ async function main() {
|
||||
host: getWorldOverlayDiagnostics(),
|
||||
paintedSingletonIds,
|
||||
pickableSingletonIds,
|
||||
nativeLabelCount: dataSource.entities.values.filter((entity) => Boolean(entity.label)).length,
|
||||
// The station dots are a draw-port point set, which draws no
|
||||
// labels of its own; a label primitive would be a row here.
|
||||
nativeLabelCount: window.__qaRadioRows('stations').filter((row) => row.primitive.text !== undefined).length,
|
||||
});
|
||||
};
|
||||
const timeout = setTimeout(finish, 500);
|
||||
@@ -1255,12 +1299,10 @@ async function main() {
|
||||
});
|
||||
await page.select('#radio-filter', 'all');
|
||||
const allPalette = await page.evaluate(() => {
|
||||
const source = Array.from({ length: window.__godsEyeView.viewer.dataSources.length }, (_, index) => (
|
||||
window.__godsEyeView.viewer.dataSources.get(index)
|
||||
)).find((item) => item.name === 'Radio stations');
|
||||
const rows = new Map(window.__qaRadioRows('stations').map((row) => [row.id, row]));
|
||||
const colorFor = (index) => {
|
||||
const id = `radio:00000000-0000-4000-8000-${index.toString(16).padStart(12, '0')}`;
|
||||
const color = source?.entities.getById(id)?.point?.color?.getValue?.();
|
||||
const color = rows.get(id)?.primitive.color;
|
||||
return color ? [color.red, color.green, color.blue].map((value) => Math.round(value * 255)) : null;
|
||||
};
|
||||
return { news: colorFor(0), talk: colorFor(1), music: colorFor(7) };
|
||||
@@ -1277,8 +1319,6 @@ async function main() {
|
||||
const viewer = window.__godsEyeView.viewer;
|
||||
const { getOverlayPaintRect, getWorldOverlayDiagnostics } = await import('/src/overlays/worldOverlay.js');
|
||||
const baselineSolveRevision = getWorldOverlayDiagnostics().solveRevision;
|
||||
const source = Array.from({ length: viewer.dataSources.length }, (_, index) => viewer.dataSources.get(index))
|
||||
.find((item) => item.name === 'Radio stations');
|
||||
const ellipsoid = viewer.scene.globe.ellipsoid;
|
||||
viewer.camera.cancelFlight();
|
||||
viewer.camera.setView({
|
||||
@@ -1289,26 +1329,25 @@ async function main() {
|
||||
}),
|
||||
orientation: { heading: 0, pitch: -Math.PI / 2, roll: 0 },
|
||||
});
|
||||
source.clustering.enabled = false;
|
||||
viewer.scene.requestRender();
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
// The camera's move clusters the stations again: wait for a cluster dot.
|
||||
return new Promise((resolve) => {
|
||||
const originalPixelRange = source.clustering.pixelRange;
|
||||
const timeout = setTimeout(() => {
|
||||
remove();
|
||||
resolve(null);
|
||||
}, 2_000);
|
||||
const remove = source.clustering.clusterEvent.addEventListener(async (entities, cluster) => {
|
||||
clearTimeout(timeout);
|
||||
remove();
|
||||
const started = performance.now();
|
||||
const poll = async () => {
|
||||
const cluster = window.__qaRadioRows('clusters').find((row) => row.show);
|
||||
if (!cluster) {
|
||||
if (performance.now() - started > 2_000) resolve(null);
|
||||
else setTimeout(poll, 50);
|
||||
return;
|
||||
}
|
||||
// The cluster's dot is a draw-port point, which draws no label.
|
||||
const native = {
|
||||
count: entities.length,
|
||||
labelShow: cluster.label.show,
|
||||
labelText: cluster.label.text,
|
||||
pointSize: cluster.point.pixelSize,
|
||||
pointMaxDistance: cluster.point.distanceDisplayCondition?.far ?? null,
|
||||
count: cluster.meta.stationIds.length,
|
||||
labelShow: cluster.primitive.text !== undefined,
|
||||
labelText: cluster.primitive.text ?? '',
|
||||
pointSize: cluster.primitive.pixelSize,
|
||||
pointMaxDistance: cluster.primitive.distanceDisplayCondition?.far ?? null,
|
||||
};
|
||||
source.clustering.pixelRange = originalPixelRange;
|
||||
const radio = window.__godsEyeView.dataManager.layers.get('radio').module;
|
||||
await new Promise((done) => setTimeout(done, 0));
|
||||
let painted = null;
|
||||
@@ -1345,9 +1384,8 @@ async function main() {
|
||||
source: radio.getOverlayDiagnostics(),
|
||||
host: painted?.host || getWorldOverlayDiagnostics(),
|
||||
});
|
||||
});
|
||||
source.clustering.enabled = true;
|
||||
viewer.scene.requestRender();
|
||||
};
|
||||
poll();
|
||||
});
|
||||
});
|
||||
check(
|
||||
@@ -1393,15 +1431,13 @@ async function main() {
|
||||
0,
|
||||
cameraRadius * cameraRadius - ellipsoid.maximumRadius * ellipsoid.maximumRadius,
|
||||
));
|
||||
const points = Array.from({ length: viewer.dataSources.length }, (_, index) => viewer.dataSources.get(index))
|
||||
.find((item) => item.name === 'Radio stations')?.clustering?._clusterPointCollection;
|
||||
let clusterPoint = null;
|
||||
// Pool order is not visibility order after a camera change. Choose an
|
||||
// on-screen point independently of the native pick result being tested.
|
||||
// Choose an on-screen cluster dot independently of the native pick
|
||||
// result being tested.
|
||||
const visiblePoints = [];
|
||||
for (let index = 0; index < (points?.length || 0); index += 1) {
|
||||
const point = points.get(index);
|
||||
if (!point?.show || !Array.isArray(point.id) || !point.id.length) continue;
|
||||
for (const row of window.__qaRadioRows('clusters')) {
|
||||
const point = row.primitive;
|
||||
if (!row.show || !row.meta?.stationIds?.length) continue;
|
||||
const anchor = viewer.scene.cartesianToCanvasCoordinates(point.position);
|
||||
if (!anchor) continue;
|
||||
if (anchor.x < 0 || anchor.y < 0 || anchor.x > viewer.canvas.clientWidth || anchor.y > viewer.canvas.clientHeight) continue;
|
||||
@@ -2432,26 +2468,23 @@ async function main() {
|
||||
await sleep(700);
|
||||
const newsClusterTarget = await page.evaluate(() => {
|
||||
const gev = window.__godsEyeView;
|
||||
const source = Array.from({ length: gev.viewer.dataSources.length }, (_, index) => gev.viewer.dataSources.get(index))
|
||||
.find((item) => item.name === 'Radio stations');
|
||||
const points = source.clustering._clusterPointCollection;
|
||||
for (let index = 0; index < (points?.length || 0); index += 1) {
|
||||
const point = points.get(index);
|
||||
if (!point.show || !Array.isArray(point.id) || !point.id.length) continue;
|
||||
const canvasPoint = gev.viewer.scene.cartesianToCanvasCoordinates(point.position);
|
||||
const rows = window.__qaRadioRows('clusters');
|
||||
for (const row of rows) {
|
||||
if (!row.show || !row.meta?.stationIds?.length) continue;
|
||||
const canvasPoint = gev.viewer.scene.cartesianToCanvasCoordinates(row.primitive.position);
|
||||
if (!canvasPoint) continue;
|
||||
return {
|
||||
x: canvasPoint.x,
|
||||
y: canvasPoint.y,
|
||||
firstId: String(point.id[0]?.id || '').replace(/^radio:/, ''),
|
||||
pointIds: point.id.map((entity) => entity.id),
|
||||
firstId: row.meta.stationIds[0],
|
||||
pointIds: row.meta.stationIds.map((id) => `radio:${id}`),
|
||||
};
|
||||
}
|
||||
return {
|
||||
missing: true,
|
||||
points: Array.from({ length: points?.length || 0 }, (_, index) => ({
|
||||
show: points.get(index).show,
|
||||
pointIds: Array.isArray(points.get(index)?.id) ? points.get(index).id.length : 0,
|
||||
points: rows.map((row) => ({
|
||||
show: row.show,
|
||||
pointIds: row.meta?.stationIds?.length || 0,
|
||||
})),
|
||||
};
|
||||
});
|
||||
@@ -2654,9 +2687,13 @@ async function main() {
|
||||
const horizon = await page.evaluate(async () => {
|
||||
const viewer = window.__godsEyeView.viewer;
|
||||
const ellipsoid = viewer.scene.globe.ellipsoid;
|
||||
const source = Array.from({ length: viewer.dataSources.length }, (_, index) => viewer.dataSources.get(index))
|
||||
.find((item) => item.name === 'Radio stations');
|
||||
const visibleIds = () => source.entities.values.filter((entity) => entity.show).map((entity) => entity.id);
|
||||
// A station dot standing in a cluster is hidden too; the cluster's
|
||||
// dot draws its stations' ids.
|
||||
const visibleIds = () => [
|
||||
...window.__qaRadioRows('stations').filter((row) => row.show).map((row) => row.id),
|
||||
...window.__qaRadioRows('clusters').filter((row) => row.show)
|
||||
.flatMap((row) => row.meta.stationIds.map((id) => `radio:${id}`)),
|
||||
];
|
||||
const setView = (lon, lat = 0) => {
|
||||
viewer.camera.cancelFlight();
|
||||
viewer.camera.setView({
|
||||
@@ -2702,8 +2739,7 @@ async function main() {
|
||||
buttons: type === 'pointerup' || type === 'pointercancel' ? 0 : 1,
|
||||
}));
|
||||
const snapshot = () => {
|
||||
const markerId = gev.viewer.entities.values
|
||||
.find((entity) => String(entity.id).startsWith('radio:selected:'))?.id || null;
|
||||
const markerId = window.__qaRadioSelected()?.id || null;
|
||||
return {
|
||||
slot: Number(slider.value),
|
||||
markerId,
|
||||
@@ -2823,8 +2859,7 @@ async function main() {
|
||||
// The tuner renders from the Radio store; let Vue patch before reading.
|
||||
await Promise.resolve();
|
||||
const shiftedSlot = Number(slider.value);
|
||||
const previewBeforeCancel = gev.viewer.entities.values
|
||||
.find((entity) => String(entity.id).startsWith('radio:selected:'))?.id || null;
|
||||
const previewBeforeCancel = window.__qaRadioSelected()?.id || null;
|
||||
const flyToCallsBeforeCancel = flyToCalls.length;
|
||||
pointer('pointercancel', targetIndex);
|
||||
await Promise.resolve();
|
||||
@@ -2840,8 +2875,7 @@ async function main() {
|
||||
tuningActive: afterState.tuningActive,
|
||||
};
|
||||
const flyToCallsAfterCancel = flyToCalls.length;
|
||||
const selectedEntity = () => gev.viewer.entities.values
|
||||
.find((entity) => String(entity.id).startsWith('radio:selected:')) || null;
|
||||
const selectedEntity = () => window.__qaRadioSelected();
|
||||
const restoredEntity = selectedEntity();
|
||||
const previewId = restoredEntity?.id || null;
|
||||
after.previewId = previewId;
|
||||
@@ -2858,7 +2892,7 @@ async function main() {
|
||||
filter: changedFilterState.filter,
|
||||
restoredStationId: changedFilterState.tuningRestoredStationId,
|
||||
selectedId: changedFilterState.selected?.id || null,
|
||||
entityRebuilt: Boolean(changedFilterEntity && changedFilterEntity !== restoredEntity),
|
||||
entityRebuilt: Boolean(changedFilterEntity && changedFilterEntity.dot.primitive !== restoredEntity?.dot.primitive),
|
||||
entityId: changedFilterEntity?.id || null,
|
||||
snapshotPreserved: radio.getAcceptedCatalogSnapshot() === changedFilterSnapshot,
|
||||
playDelta: window.__qaRadioPlayCalls.length - changedFilterPlays,
|
||||
@@ -2882,7 +2916,7 @@ async function main() {
|
||||
restoredAfter: sameFilterState.tuningRestoredStationId,
|
||||
filter: sameFilterState.filter,
|
||||
selectedId: sameFilterState.selected?.id || null,
|
||||
entityRebuilt: Boolean(sameFilterEntity && sameFilterEntity !== sameFilterRestoredEntity),
|
||||
entityRebuilt: Boolean(sameFilterEntity && sameFilterEntity.dot.primitive !== sameFilterRestoredEntity?.dot.primitive),
|
||||
entityId: sameFilterEntity?.id || null,
|
||||
snapshotPreserved: radio.getAcceptedCatalogSnapshot() === sameFilterSnapshot,
|
||||
playDelta: window.__qaRadioPlayCalls.length - sameFilterPlays,
|
||||
@@ -3327,8 +3361,7 @@ async function main() {
|
||||
cancelable: true,
|
||||
key: value,
|
||||
}));
|
||||
const markerId = () => gev.viewer.entities.values
|
||||
.find((entity) => String(entity.id).startsWith('radio:selected:'))?.id || null;
|
||||
const markerId = () => window.__qaRadioSelected()?.id || null;
|
||||
const startIndex = Number(slider.value);
|
||||
const expectedIndex = Math.min(style._radioControls._radioTunerStations.length - 1, startIndex + 1);
|
||||
const expectedId = style._radioControls._radioTunerStations[expectedIndex]?.id || null;
|
||||
@@ -3428,8 +3461,7 @@ async function main() {
|
||||
centerIndex,
|
||||
slot: Number(slider.value),
|
||||
ratio: Number(document.getElementById('radio-tuner').style.getPropertyValue('--radio-tuner-ratio')),
|
||||
markerId: gev.viewer.entities.values
|
||||
.find((entity) => String(entity.id).startsWith('radio:selected:'))?.id || null,
|
||||
markerId: window.__qaRadioSelected()?.id || null,
|
||||
expectedId: style._radioControls._radioTunerStations[centerIndex]?.id || null,
|
||||
};
|
||||
slider.dispatchEvent(new PointerEvent('pointercancel', {
|
||||
@@ -3554,9 +3586,6 @@ async function main() {
|
||||
const markerTarget = await page.evaluate(async () => {
|
||||
const viewer = window.__godsEyeView.viewer;
|
||||
const radio = window.__godsEyeView.dataManager.layers.get('radio').module;
|
||||
const source = Array.from({ length: viewer.dataSources.length }, (_, index) => viewer.dataSources.get(index))
|
||||
.find((item) => item.name === 'Radio stations');
|
||||
source.clustering.enabled = false;
|
||||
const selectedId = radio.getUIState().selected?.id || null;
|
||||
if (selectedId) {
|
||||
radio.selectStation(selectedId, {
|
||||
@@ -3583,9 +3612,6 @@ async function main() {
|
||||
});
|
||||
viewer.scene.requestRender();
|
||||
});
|
||||
// Cesium clears its private cluster collections during the rendered
|
||||
// disabled-state update. Publish the same-filter singleton overlay only
|
||||
// after that frame so this harness mutation cannot leak stale clusters.
|
||||
radio.setFilter('news');
|
||||
viewer.scene.requestRender();
|
||||
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||
@@ -3614,14 +3640,14 @@ async function main() {
|
||||
let visibleEntityCount = 0;
|
||||
let singletonEntityCount = 0;
|
||||
let paintedSingletonCount = 0;
|
||||
for (const entity of source.entities.values) {
|
||||
if (!entity.show) continue;
|
||||
for (const row of window.__qaRadioRows('stations')) {
|
||||
if (!row.show) continue;
|
||||
visibleEntityCount += 1;
|
||||
const id = String(entity.id).slice('radio:'.length);
|
||||
const id = String(row.id).slice('radio:'.length);
|
||||
const overlayId = `station:${id}`;
|
||||
if (!singletonIds.has(overlayId)) continue;
|
||||
singletonEntityCount += 1;
|
||||
const position = entity.position?.getValue(viewer.clock.currentTime);
|
||||
const position = row.primitive.position;
|
||||
const canvas = position && viewer.scene.cartesianToCanvasCoordinates(position);
|
||||
const paintRect = getOverlayPaintRect('radio', overlayId);
|
||||
if (paintRect) paintedSingletonCount += 1;
|
||||
@@ -3631,7 +3657,7 @@ async function main() {
|
||||
id,
|
||||
x: canvas.x,
|
||||
y: canvas.y,
|
||||
ownsNativeLabel: Boolean(entity.label),
|
||||
ownsNativeLabel: row.primitive.text !== undefined,
|
||||
labelPainted: true,
|
||||
singletonTexts: diagnostics.singletonTexts,
|
||||
});
|
||||
@@ -3700,8 +3726,6 @@ async function main() {
|
||||
orientation: { heading: 0, pitch: -Math.PI / 2, roll: 0 },
|
||||
});
|
||||
radio.stopPlayback();
|
||||
Array.from({ length: gev.viewer.dataSources.length }, (_, index) => gev.viewer.dataSources.get(index))
|
||||
.find((item) => item.name === 'Radio stations').clustering.enabled = true;
|
||||
// Next plays only while a stream is active, so start from a playing station.
|
||||
radio.selectStation('00000000-0000-4000-8000-000000000001', { autoplay: true, focus: false });
|
||||
});
|
||||
@@ -3757,8 +3781,7 @@ async function main() {
|
||||
const playing = await page.evaluate(async () => {
|
||||
const radio = window.__godsEyeView.dataManager.layers.get('radio').module;
|
||||
const viewer = window.__godsEyeView.viewer;
|
||||
const selectedEntity = window.__godsEyeView.viewer.entities.values
|
||||
.find((entity) => String(entity.id).startsWith('radio:selected:'));
|
||||
const selectedEntity = window.__qaRadioSelected();
|
||||
const { getWorldOverlayDiagnostics } = await import('/src/overlays/worldOverlay.js');
|
||||
const flightTargets = window.__qaRadioFlyToCalls.map(({ destination }) => {
|
||||
const position = viewer.scene.globe.ellipsoid.cartesianToCartographic(destination);
|
||||
@@ -3775,11 +3798,10 @@ async function main() {
|
||||
flightTargets,
|
||||
cameraHeight: window.__qaRadioCameraHeight,
|
||||
playLabel: document.getElementById('radio-play-btn').getAttribute('aria-label'),
|
||||
regularMarkerSize: Array.from({ length: window.__godsEyeView.viewer.dataSources.length }, (_, index) => window.__godsEyeView.viewer.dataSources.get(index))
|
||||
.find((item) => item.name === 'Radio stations')?.entities.values[0]?.point?.pixelSize?.getValue(),
|
||||
selectedMarkerSize: selectedEntity?.point?.pixelSize?.getValue(),
|
||||
selectedBracketWidth: selectedEntity?.billboard?.width?.getValue(),
|
||||
selectedOwnsNativeLabel: Boolean(selectedEntity?.label),
|
||||
regularMarkerSize: window.__qaRadioRows('stations')[0]?.primitive.pixelSize,
|
||||
selectedMarkerSize: selectedEntity?.dot.primitive.pixelSize,
|
||||
selectedBracketWidth: selectedEntity?.bracket?.primitive.width,
|
||||
selectedOwnsNativeLabel: Boolean(window.__qaRadioRows('selected-label').length),
|
||||
overlay: radio.getOverlayDiagnostics(),
|
||||
host: getWorldOverlayDiagnostics(),
|
||||
expectedPrimary: window.__qaRadioExpectedPrimary,
|
||||
@@ -3817,7 +3839,7 @@ async function main() {
|
||||
id: `qa:${ownerPrefix}:radio-camera-owner`,
|
||||
position: viewer.camera.positionWC.clone(),
|
||||
});
|
||||
owner.gevTrackedId = `${ownerPrefix}:qa-radio-camera-owner`;
|
||||
window.__godsEyeView.entityRecords.write(owner).trackedId = `${ownerPrefix}:qa-radio-camera-owner`;
|
||||
viewer.trackedEntity = owner;
|
||||
await new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)));
|
||||
const beforeStationId = radio.getUIState().selected?.id || null;
|
||||
@@ -3831,7 +3853,7 @@ async function main() {
|
||||
afterStationId: radio.getUIState().selected?.id || null,
|
||||
flyToDelta: window.__qaRadioFlyToCalls.length - beforeFlyToCalls,
|
||||
trackedIdentityPreserved: viewer.trackedEntity === owner,
|
||||
trackedId: viewer.trackedEntity?.gevTrackedId || null,
|
||||
trackedId: window.__godsEyeView.entityRecords.read(viewer.trackedEntity)?.trackedId || null,
|
||||
};
|
||||
viewer.trackedEntity = undefined;
|
||||
viewer.entities.remove(owner);
|
||||
@@ -3867,11 +3889,11 @@ async function main() {
|
||||
id: 'qa:flights:delayed-radio-fallback-owner',
|
||||
position: viewer.camera.positionWC.clone(),
|
||||
});
|
||||
owner.gevTrackedId = 'flights:qa-delayed-radio-fallback-owner';
|
||||
window.__godsEyeView.entityRecords.write(owner).trackedId = 'flights:qa-delayed-radio-fallback-owner';
|
||||
viewer.trackedEntity = owner;
|
||||
window.__qaDelayedRadioTrackingOwner = owner;
|
||||
window.__qaRejectRadioPlay();
|
||||
return owner.gevTrackedId;
|
||||
return window.__godsEyeView.entityRecords.read(owner)?.trackedId;
|
||||
});
|
||||
await page.waitForFunction(() => window.__godsEyeView.dataManager.layers.get('radio').module.getUIState().audioState === 'playing');
|
||||
const delayedFallbackOwnership = await page.evaluate((beforeFlyToCalls) => {
|
||||
@@ -3880,7 +3902,7 @@ async function main() {
|
||||
const result = {
|
||||
flyToDelta: window.__qaRadioFlyToCalls.length - beforeFlyToCalls,
|
||||
trackedIdentityPreserved: viewer.trackedEntity === owner,
|
||||
trackedId: viewer.trackedEntity?.gevTrackedId || null,
|
||||
trackedId: window.__godsEyeView.entityRecords.read(viewer.trackedEntity)?.trackedId || null,
|
||||
selectedId: window.__godsEyeView.dataManager.layers.get('radio').module.getUIState().selected?.id || null,
|
||||
};
|
||||
viewer.trackedEntity = undefined;
|
||||
@@ -3940,8 +3962,12 @@ async function main() {
|
||||
destination,
|
||||
orientation: { heading: 0, pitch: -Math.PI / 2, roll: 0 },
|
||||
});
|
||||
const selectedEntity = viewer.entities.values
|
||||
.find((entity) => String(entity.id) === `radio:selected:${selected.id}`);
|
||||
// The selected station's drawn dot and bracket, read afresh: Radio's
|
||||
// horizon pass shows them on its own timer.
|
||||
const selectedEntity = () => {
|
||||
const drawn = window.__qaRadioSelected();
|
||||
return drawn?.id === `radio:selected:${selected.id}` ? drawn : null;
|
||||
};
|
||||
const { getOverlayPaintRect, getWorldOverlayDiagnostics } = await import('/src/overlays/worldOverlay.js');
|
||||
const expectedEntryId = `selected:${selected.id}`;
|
||||
let painted = null;
|
||||
@@ -3949,7 +3975,7 @@ async function main() {
|
||||
// after the camera jump, so a stationary view waits for both to settle.
|
||||
for (
|
||||
let attempt = 0;
|
||||
attempt < 20 && !(painted?.rect && selectedEntity?.show === true);
|
||||
attempt < 20 && !(painted?.rect && selectedEntity()?.show === true);
|
||||
attempt += 1
|
||||
) {
|
||||
painted = await new Promise((resolve) => {
|
||||
@@ -3974,7 +4000,7 @@ async function main() {
|
||||
expectedEntryId,
|
||||
rect: painted?.rect || null,
|
||||
host: painted?.host || getWorldOverlayDiagnostics(),
|
||||
selectedEntityShow: selectedEntity?.show,
|
||||
selectedEntityShow: selectedEntity()?.show,
|
||||
cameraHeight: viewer.camera.positionCartographic.height,
|
||||
};
|
||||
});
|
||||
@@ -3999,8 +4025,12 @@ async function main() {
|
||||
}),
|
||||
orientation: { heading: 0, pitch: -Math.PI / 2, roll: 0 },
|
||||
});
|
||||
const selectedEntity = viewer.entities.values
|
||||
.find((entity) => String(entity.id) === `radio:selected:${selected.id}`);
|
||||
// The selected station's drawn dot and bracket, read afresh: Radio's
|
||||
// horizon pass shows them on its own timer.
|
||||
const selectedEntity = () => {
|
||||
const drawn = window.__qaRadioSelected();
|
||||
return drawn?.id === `radio:selected:${selected.id}` ? drawn : null;
|
||||
};
|
||||
const { getOverlayPaintRect, getWorldOverlayDiagnostics } = await import('/src/overlays/worldOverlay.js');
|
||||
const expectedEntryId = `selected:${selected.id}`;
|
||||
let rect = null;
|
||||
@@ -4025,7 +4055,8 @@ async function main() {
|
||||
viewer.scene.requestRender();
|
||||
});
|
||||
}
|
||||
const entityPosition = selectedEntity?.position?.getValue?.();
|
||||
const selectedDrawn = selectedEntity();
|
||||
const entityPosition = selectedDrawn?.position;
|
||||
const entityAnchor = entityPosition
|
||||
&& viewer.scene.cartesianToCanvasCoordinates(entityPosition);
|
||||
let selectedNativePick = null;
|
||||
@@ -4035,13 +4066,16 @@ async function main() {
|
||||
// billboard satisfy the loop while the point anchor was still missing.
|
||||
for (let attempt = 0; entityAnchor && attempt < 8 && !selectedPointPick; attempt += 1) {
|
||||
const picks = viewer.scene.drillPick(entityAnchor, 16) || [];
|
||||
selectedNativePick = picks.find((picked) => picked?.id === selectedEntity);
|
||||
selectedNativePick = picks.find((picked) => (
|
||||
picked?.primitive === selectedDrawn.dot.primitive
|
||||
|| picked?.primitive === selectedDrawn.bracket?.primitive
|
||||
));
|
||||
selectedPointPick = picks.find((picked) => (
|
||||
picked?.id === selectedEntity
|
||||
picked?.primitive === selectedDrawn.dot.primitive
|
||||
&& String(picked?.primitive?.constructor?.name || '').includes('PointPrimitive')
|
||||
));
|
||||
selectedBillboardPick = picks.find((picked) => (
|
||||
picked?.id === selectedEntity
|
||||
picked?.primitive === selectedDrawn.bracket?.primitive
|
||||
&& String(picked?.primitive?.constructor?.name || '').includes('Billboard')
|
||||
));
|
||||
if (!selectedPointPick) {
|
||||
@@ -4054,18 +4088,15 @@ async function main() {
|
||||
});
|
||||
}
|
||||
}
|
||||
const selectedPointDistance = selectedEntity?.point?.distanceDisplayCondition?.getValue?.();
|
||||
const selectedPointDistance = selectedDrawn?.dot.primitive.distanceDisplayCondition;
|
||||
return {
|
||||
rect,
|
||||
selectedNativePickable: Boolean(selectedNativePick),
|
||||
selectedPointPickable: Boolean(selectedPointPick),
|
||||
selectedBillboardPickable: Boolean(selectedBillboardPick),
|
||||
selectedPointMaxDistance: selectedPointDistance?.far ?? null,
|
||||
selectedEntityShow: selectedEntity?.show,
|
||||
selectedBracketVisible: Boolean(
|
||||
selectedEntity?.billboard
|
||||
&& selectedEntity.billboard.show?.getValue?.() !== false
|
||||
),
|
||||
selectedEntityShow: selectedDrawn?.show,
|
||||
selectedBracketVisible: Boolean(selectedDrawn?.bracket?.show),
|
||||
entityAnchor: entityAnchor ? { x: entityAnchor.x, y: entityAnchor.y } : null,
|
||||
entityDistance: entityPosition
|
||||
? Math.hypot(
|
||||
@@ -4222,7 +4253,7 @@ async function main() {
|
||||
id: 'qa:flights:radio-recenter-stage-owner',
|
||||
position: viewer.camera.positionWC.clone(),
|
||||
});
|
||||
owner.gevTrackedId = 'flights:qa-radio-recenter-stage-owner';
|
||||
window.__godsEyeView.entityRecords.write(owner).trackedId = 'flights:qa-radio-recenter-stage-owner';
|
||||
viewer.trackedEntity = owner;
|
||||
completeFlight(0);
|
||||
const trackingBetweenStagesCalls = calls.length;
|
||||
|
||||
@@ -45,7 +45,7 @@ try {
|
||||
window.__qaSceneState.push(notification),
|
||||
);
|
||||
});
|
||||
await page.click('[data-collapse-target="scene-panel"]');
|
||||
await page.click('[data-rail-item="scene-panel"]');
|
||||
await page.click('#scene-new-btn');
|
||||
await page.waitForFunction(
|
||||
() =>
|
||||
@@ -278,7 +278,7 @@ try {
|
||||
panel.classList.contains('collapsed'),
|
||||
)
|
||||
)
|
||||
await page.click('[data-collapse-target="scene-panel"]');
|
||||
await page.click('[data-rail-item="scene-panel"]');
|
||||
await page.waitForSelector('#scene-download-btn', { visible: true });
|
||||
await page.click('#scene-download-btn');
|
||||
const metadata = await page.evaluate(async () =>
|
||||
@@ -426,6 +426,10 @@ try {
|
||||
);
|
||||
}),
|
||||
);
|
||||
promptValue = 'Disposal scene';
|
||||
await page.click('#scene-new-btn');
|
||||
await page.click('#scene-capture-btn');
|
||||
await page.waitForSelector('.scene-shot-label', { visible: true });
|
||||
const teardown = await page.evaluate(async () => {
|
||||
const director = window.__godsEyeView.sceneDirector;
|
||||
const controls = director._controls;
|
||||
|
||||
@@ -32,13 +32,15 @@ try {
|
||||
const results = await page.evaluate(async () => {
|
||||
window.CESIUM_BASE_URL = '/cesium/';
|
||||
// Use StarrySky's exact Vite dependency URL, including its version query.
|
||||
const source = await fetch('/src/sky/starrySky.js').then((r) => r.text());
|
||||
const source = await fetch('/src/render/cesium/starrySky.js').then((r) =>
|
||||
r.text(),
|
||||
);
|
||||
const cesiumUrl = source.match(
|
||||
/from ["']([^"']*\/cesium\.js[^"']*)["']/,
|
||||
)?.[1];
|
||||
if (!cesiumUrl) throw new Error('run against the Vite dev server');
|
||||
const C = await import(cesiumUrl);
|
||||
const { StarrySky } = await import('/src/sky/starrySky.js');
|
||||
const { StarrySky } = await import('/src/render/cesium/starrySky.js');
|
||||
const time = C.JulianDate.fromIso8601('2026-10-19T00:00:00Z');
|
||||
const results = {};
|
||||
for (const kind of ['black', 'starry', 'white']) {
|
||||
@@ -75,7 +77,7 @@ try {
|
||||
}
|
||||
const position = C.Cartesian3.fromDegrees(0, 0, 10000);
|
||||
const model = await C.Model.fromGltfAsync({
|
||||
url: '/models/airplane.glb',
|
||||
url: '/models/fleet/aircraft/a320.glb',
|
||||
modelMatrix: C.Transforms.eastNorthUpToFixedFrame(position),
|
||||
});
|
||||
scene.primitives.add(model);
|
||||
|
||||
+32
-33
@@ -15,9 +15,9 @@
|
||||
* per-class glyph (image data-URI === aircraftIcon(klass),
|
||||
* imported from src) and per-class scale (flights:
|
||||
* CLASS_SCALE_2D; military: 0.7 × CLASS_SCALE_2D)
|
||||
* B3 models : with 3D on, fleet Cesium.Model.scale === the layer's
|
||||
* MODEL_SCALE (both 1; legacy scale is baked into the GLB)
|
||||
* × CLASS_SCALE_3D[klass] per icao; tracked too
|
||||
* B3 models : with 3D on, fleet Cesium.Model.scale === the life-size
|
||||
* scale of the fleet model the aircraft's type or category
|
||||
* selects (aircraftModelSpec) per icao; tracked too
|
||||
* B4 clean : no console errors
|
||||
*
|
||||
* Visual output (qa-shots/b5/, untracked): top-down 2D spreads of both rows,
|
||||
@@ -33,15 +33,18 @@ import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import puppeteer from 'puppeteer';
|
||||
import { stubPlanespotters } from './qa-photo-stub.mjs';
|
||||
import { classifyAircraft, CLASS_SCALE_2D, CLASS_SCALE_3D, CLASS_MODEL_REAL } from '../src/data/aircraftClass.js';
|
||||
// Hangar fleet (2026-08-16): real per-class GLBs render at scale 1; military
|
||||
// heavies (airliner/quadjet/glider) render airplane.glb at 1 x class; only
|
||||
// fastjet/unknown keep the per-layer jet/airplane MODEL_SCALE formula.
|
||||
const flightsWantScale = (klass) => (CLASS_MODEL_REAL[klass] ? 1 : FL_MODEL_SCALE * CLASS_SCALE_3D[klass]);
|
||||
const MIL_PLANE_CLASSES = new Set(['airliner', 'quadjet', 'glider']);
|
||||
const militaryWantScale = (klass) => (CLASS_MODEL_REAL[klass] ? 1
|
||||
: MIL_PLANE_CLASSES.has(klass) ? MIL_PLANE_MODEL_SCALE * CLASS_SCALE_3D[klass]
|
||||
: MIL_MODEL_SCALE * CLASS_SCALE_3D[klass]);
|
||||
import { classifyAircraft, CLASS_SCALE_2D } from '../src/data/aircraftClass.js';
|
||||
import { aircraftModelSpec } from '../src/data/fleetModels.js';
|
||||
// Every aircraft draws its fleet model life size: its type's length over the
|
||||
// model's built length, chosen by type code (military) or category (flights).
|
||||
const FLEET_SET = Object.freeze({
|
||||
catalog: JSON.parse(fs.readFileSync(new URL('../public/models/fleet/catalog.json', import.meta.url), 'utf8')),
|
||||
types: JSON.parse(fs.readFileSync(new URL('../public/models/fleet/types.json', import.meta.url), 'utf8')),
|
||||
});
|
||||
const flightsWantScale = (icao) =>
|
||||
aircraftModelSpec(FLEET_SET, { category: SPRITES.flights.find((p) => p.icao === icao)?.category }).scale;
|
||||
const militaryWantScale = (hex) =>
|
||||
aircraftModelSpec(FLEET_SET, { typeCode: SPRITES.military.find((p) => p.hex === hex)?.t }).scale;
|
||||
import { aircraftIcon } from '../src/data/aircraftIcons.js';
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -58,9 +61,6 @@ const APP_URL = getOpt('--url', 'http://localhost:4173');
|
||||
const HEADFUL = getFlag('--headful');
|
||||
const SHOT_DIR = path.resolve('qa-shots/b5');
|
||||
|
||||
const FL_MODEL_SCALE = 1; // flights.js (airplane.glb is transform-applied and meter-scale)
|
||||
const MIL_PLANE_MODEL_SCALE = 1; // military heavy classes share the same baked airplane.glb
|
||||
const MIL_MODEL_SCALE = 1; // militaryFlights.js (jet.glb is already real-world scale, native radius ~29.8 m)
|
||||
const MIL_BILLBOARD_SCALE = 0.7; // militaryFlights BILLBOARD_SCALE
|
||||
|
||||
const CHROME_EXECUTABLE_CANDIDATES = [
|
||||
@@ -134,10 +134,9 @@ const SPRITES = {
|
||||
// course 0 like the rest — keeps the row a clean size-comparison line (2D
|
||||
// rotation is demoed by caa004 and gated by qa-heading-b3 anyway).
|
||||
{ hex: 'dda008', flight: 'ML-FJ', t: 'F16', lon0: ROW_LON0 + 7 * ROW_STEP_DEG, lat0: 30.28, courseDeg: 0, speedMps: 80, altFt: 15000 },
|
||||
// 3D cluster: C17 vs F16 (tracked) vs B744 vs C130. jet.glb is a
|
||||
// real-world-scale asset (native bounding radius ~29.8) rendered at
|
||||
// MODEL_SCALE 1, so models are ~22–43 m radius — same 150 m spacing and
|
||||
// 450–900 m shot ranges as the flights cluster.
|
||||
// 3D cluster: C17 vs F16 (tracked) vs B744 vs C130, each drawn life size
|
||||
// (~8–36 m radius) — same 150 m spacing and 450–900 m shot ranges as the
|
||||
// flights cluster.
|
||||
{ hex: 'ddb001', flight: '3DMWID', t: 'C17', lon0: CLUSTER_LON0 - mDegLon(150, 30.05), lat0: 30.05, courseDeg: 0, speedMps: 60, altFt: 12000 },
|
||||
{ hex: 'ddb002', flight: '3DMFJ', t: 'F16', lon0: CLUSTER_LON0, lat0: 30.05, courseDeg: 0, speedMps: 60, altFt: 12000 },
|
||||
{ hex: 'ddb003', flight: '3DMQUA', t: 'B744', lon0: CLUSTER_LON0 + mDegLon(150, 30.05), lat0: 30.05, courseDeg: 0, speedMps: 60, altFt: 12000 },
|
||||
@@ -464,7 +463,7 @@ async function main() {
|
||||
// ========================================================================
|
||||
// B3 + 3D screenshots — flights cluster
|
||||
// ========================================================================
|
||||
console.log('\n3D — flights cluster (airplane.glb, per-class scale)');
|
||||
console.log('\n3D — flights cluster (fleet models, life size)');
|
||||
await page.evaluate(() => {
|
||||
const dm = window.__godsEyeView.dataManager;
|
||||
dm.layers.get('flights').module.setParams({ models3d: true });
|
||||
@@ -481,20 +480,20 @@ async function main() {
|
||||
const flModels = await page.evaluate(() => window.__collectModels().filter((m) => m.ready));
|
||||
const modelScaleBad = [];
|
||||
for (const [id, want] of [
|
||||
['cbb001', flightsWantScale(expectedFlights.get('cbb001'))],
|
||||
['cbb003', flightsWantScale(expectedFlights.get('cbb003'))],
|
||||
['cbb001', flightsWantScale('cbb001')],
|
||||
['cbb003', flightsWantScale('cbb003')],
|
||||
]) {
|
||||
const m = flModels.find((x) => x.id === id);
|
||||
if (!m || Math.abs(m.scale - want) > 1e-9) modelScaleBad.push(`${id}: ${m ? m.scale : 'missing'} != ${want}`);
|
||||
}
|
||||
const trackedM = flModels.find((x) => x.id === 'cbb002');
|
||||
const trackedWant = flightsWantScale(expectedFlights.get('cbb002'));
|
||||
const trackedWant = flightsWantScale('cbb002');
|
||||
if (!trackedM || Math.abs(trackedM.scale - trackedWant) > 1e-9) {
|
||||
modelScaleBad.push(`tracked: ${trackedM ? trackedM.scale : 'missing'} != ${trackedWant}`);
|
||||
}
|
||||
record('B3a flights: model scales match the per-class registry (all GLBs meter-scale; shared @1×class)',
|
||||
record('B3a flights: model scales match each type's life-size fleet model',
|
||||
modelScaleBad.length === 0,
|
||||
modelScaleBad.length ? modelScaleBad.join(' ') : 'all exact per registry');
|
||||
modelScaleBad.length ? modelScaleBad.join(' ') : 'all exact');
|
||||
console.log(` world bounding radii (m): ${flModels.filter((m) => m.scale !== undefined).map((m) => `${m.id ?? 'tracked'}=${m.radius?.toFixed(1)}`).join(' ')}`);
|
||||
|
||||
await sleep(1500);
|
||||
@@ -509,7 +508,7 @@ async function main() {
|
||||
// ========================================================================
|
||||
// B3 + 3D screenshots — military cluster
|
||||
// ========================================================================
|
||||
console.log('\n3D — military cluster (jet.glb, per-class scale)');
|
||||
console.log('\n3D — military cluster (fleet models, life size)');
|
||||
await page.evaluate(() => {
|
||||
const dm = window.__godsEyeView.dataManager;
|
||||
dm.layers.get('military').module.setParams({ models3d: true });
|
||||
@@ -526,25 +525,25 @@ async function main() {
|
||||
const milModels = await page.evaluate(() => window.__collectModels().filter((m) => m.ready));
|
||||
const modelScaleBad = [];
|
||||
for (const [id, want] of [
|
||||
['ddb001', militaryWantScale(expectedMilitary.get('ddb001'))],
|
||||
['ddb003', militaryWantScale(expectedMilitary.get('ddb003'))],
|
||||
['ddb004', militaryWantScale(expectedMilitary.get('ddb004'))],
|
||||
['ddb001', militaryWantScale('ddb001')],
|
||||
['ddb003', militaryWantScale('ddb003')],
|
||||
['ddb004', militaryWantScale('ddb004')],
|
||||
]) {
|
||||
const m = milModels.find((x) => x.id === id);
|
||||
if (!m || Math.abs(m.scale - want) > 1e-9) modelScaleBad.push(`${id}: ${m ? m.scale : 'missing'} != ${want}`);
|
||||
}
|
||||
const trackedM = milModels.find((x) => x.id === 'ddb002');
|
||||
const trackedWant = militaryWantScale(expectedMilitary.get('ddb002'));
|
||||
const trackedWant = militaryWantScale('ddb002');
|
||||
if (!trackedM || Math.abs(trackedM.scale - trackedWant) > 1e-9) {
|
||||
modelScaleBad.push(`tracked: ${trackedM ? trackedM.scale : 'missing'} != ${trackedWant}`);
|
||||
}
|
||||
record('B3b military: model scales match the weight-class registry (real/heavy/jet assets @1×class)',
|
||||
record('B3b military: model scales match each type's life-size fleet model',
|
||||
modelScaleBad.length === 0,
|
||||
modelScaleBad.length ? modelScaleBad.join(' ') : 'all exact per registry');
|
||||
modelScaleBad.length ? modelScaleBad.join(' ') : 'all exact');
|
||||
console.log(` world bounding radii (m): ${milModels.filter((m) => m.scale !== undefined).map((m) => `${m.id ?? 'tracked'}=${m.radius?.toFixed(1)}`).join(' ')}`);
|
||||
|
||||
await sleep(1500);
|
||||
// jet.glb at MODEL_SCALE 1 is real-world size — same shot ranges as the
|
||||
// Fleet models are drawn life size — same shot ranges as the
|
||||
// flights cluster (close zoom no longer puts the camera inside a model).
|
||||
await zoomToRange(900);
|
||||
await page.screenshot({ path: path.join(SHOT_DIR, 'b5-3d-military-far.png') });
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
/** Run against the built app's preview server (QA_BASE_URL, port 4173 by default). */
|
||||
import assert from 'node:assert/strict';
|
||||
import puppeteer from 'puppeteer';
|
||||
|
||||
const browser = await puppeteer.launch({
|
||||
headless: true,
|
||||
args: [
|
||||
'--no-sandbox',
|
||||
...(process.platform === 'darwin'
|
||||
? ['--use-angle=metal', '--enable-gpu']
|
||||
: ['--use-gl=angle', '--use-angle=swiftshader']),
|
||||
],
|
||||
});
|
||||
|
||||
try {
|
||||
const page = await browser.newPage();
|
||||
await page.setViewport({ width: 1440, height: 900 });
|
||||
await page.emulateMediaFeatures([
|
||||
{ name: 'prefers-reduced-motion', value: 'reduce' },
|
||||
]);
|
||||
const url = new URL(process.env.QA_BASE_URL || 'http://localhost:4173/');
|
||||
url.searchParams.set('welcome', '0');
|
||||
url.searchParams.set('story', 'gev:flights-radar');
|
||||
url.searchParams.set('storyTime', '1250');
|
||||
url.hash =
|
||||
'v=2&lat=20&lon=10&alt=2500000&heading=0&pitch=-90&roll=0&style=normal&map=esri-imagery';
|
||||
await page.goto(url.href, { waitUntil: 'domcontentloaded' });
|
||||
|
||||
async function waitForPausedStory() {
|
||||
await page.waitForSelector('#tlTrack', { visible: true, timeout: 60000 });
|
||||
await page.waitForFunction(
|
||||
() => window.__godsEyeView?.styleManager.activeStyle === 'retro',
|
||||
{ timeout: 30000 },
|
||||
);
|
||||
const timing = await page.evaluate(async () => {
|
||||
const director = window.__godsEyeView.sceneDirector;
|
||||
await director.whenIdle();
|
||||
return {
|
||||
elapsed: director.getPlaybackTimingState().snapshot.sceneElapsedSec,
|
||||
running: director.running,
|
||||
};
|
||||
});
|
||||
assert.equal(timing.running, false);
|
||||
assert.ok(Math.abs(timing.elapsed - 1.25) < 0.001);
|
||||
}
|
||||
|
||||
await waitForPausedStory();
|
||||
await page.evaluate(() => history.back());
|
||||
await page.waitForSelector('#scrExplore', { visible: true });
|
||||
await page.waitForFunction(
|
||||
() => window.__godsEyeView.styleManager.activeStyle === 'normal',
|
||||
);
|
||||
await page.evaluate(() => history.forward());
|
||||
await waitForPausedStory();
|
||||
await page.waitForFunction(() =>
|
||||
document.activeElement.matches(
|
||||
'#scrStory .s-back, #scrStory .s-trail button',
|
||||
),
|
||||
);
|
||||
console.log('Back and Forward restore the style, paused time and focus');
|
||||
|
||||
await page.click('#tlPlay');
|
||||
const resumedAt = await (
|
||||
await page.waitForFunction(
|
||||
() => {
|
||||
const snap =
|
||||
window.__godsEyeView.sceneDirector.getPlaybackTimingState().snapshot;
|
||||
return snap?.running ? snap.sceneElapsedSec : false;
|
||||
},
|
||||
{ timeout: 30000 },
|
||||
)
|
||||
).jsonValue();
|
||||
assert.ok(
|
||||
resumedAt >= 1.25 && resumedAt < 3,
|
||||
`Play went on from ${resumedAt} s, not the paused 1.25 s`,
|
||||
);
|
||||
await page.click('#tlPlay');
|
||||
await page.waitForFunction(() => !window.__godsEyeView.sceneDirector.running);
|
||||
await page.evaluate(() => window.__godsEyeView.sceneDirector.whenIdle());
|
||||
console.log('Play goes on from the paused time, not the start of the shot');
|
||||
|
||||
const track = await page.$('#tlTrack');
|
||||
const box = await track.boundingBox();
|
||||
assert.ok(box.width > 0);
|
||||
await page.evaluate(() => {
|
||||
const director = window.__godsEyeView.sceneDirector;
|
||||
const seek = director.seekScene.bind(director);
|
||||
window.qaSeekProgress = [];
|
||||
director.seekScene = (...args) => {
|
||||
window.qaSeekProgress.push(args[1]);
|
||||
return seek(...args);
|
||||
};
|
||||
});
|
||||
const y = box.y + box.height / 2;
|
||||
const at = (fraction) => box.x + box.width * fraction;
|
||||
await page.mouse.move(at(0.25), y);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(at(0.65), y, { steps: 12 });
|
||||
await page.waitForFunction(
|
||||
() =>
|
||||
Number(document.querySelector('#tlTrack').getAttribute('aria-valuenow')) >
|
||||
25,
|
||||
);
|
||||
assert.deepEqual(await page.evaluate(() => window.qaSeekProgress), []);
|
||||
await page.mouse.up();
|
||||
await page.waitForFunction(() => window.qaSeekProgress.length === 1);
|
||||
await page.evaluate(() => window.__godsEyeView.sceneDirector.whenIdle());
|
||||
assert.equal(await page.evaluate(() => window.qaSeekProgress.length), 1);
|
||||
console.log('A timeline drag updates the preview before one released seek');
|
||||
|
||||
const pose = () =>
|
||||
page.evaluate(() => window.__godsEyeView.styleManager.getCameraState());
|
||||
const before = await pose();
|
||||
await page.click('#railGev');
|
||||
await page.waitForFunction(
|
||||
() =>
|
||||
!document.body.classList.contains('stories-mode') &&
|
||||
document
|
||||
.querySelector('#scene-select option:checked')
|
||||
?.textContent.includes('Global Flights Radar'),
|
||||
);
|
||||
const after = await pose();
|
||||
assert.ok(Math.abs(after.lat - before.lat) < 0.01);
|
||||
assert.ok(Math.abs(after.lon - before.lon) < 0.01);
|
||||
assert.ok(Math.abs(after.alt - before.alt) < 100);
|
||||
await page.waitForFunction(() => document.activeElement.id === 'hStories');
|
||||
console.log('Open in GEV selects the scene without moving its camera');
|
||||
await page.click('#scene-thumb-btn');
|
||||
await page.waitForFunction(() =>
|
||||
document
|
||||
.querySelector('#scene-thumb-preview')
|
||||
?.src.startsWith('data:image/jpeg;'),
|
||||
);
|
||||
console.log('Authoring captures an Esri thumbnail through the real renderer');
|
||||
|
||||
// This width is within GEV's phone layout and used to miss Stories' layout.
|
||||
await page.setViewport({ width: 710, height: 844 });
|
||||
await page.goto(url.href, { waitUntil: 'domcontentloaded' });
|
||||
await waitForPausedStory();
|
||||
await page.waitForFunction(() =>
|
||||
document.activeElement.matches('#scrStory .s-back'),
|
||||
);
|
||||
console.log('The phone layout uses the same breakpoint as GEV');
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
@@ -378,7 +378,9 @@ const findPick = (page, prefix, { box = null, step = 3 } = {}) =>
|
||||
};
|
||||
for (let py = y; py < y + h; py += stride)
|
||||
for (let px = x; px < x + w; px += stride) {
|
||||
const id = scene.pick({ x: px, y: py })?.id;
|
||||
// A drawn item's pick id names its draw set and its own id.
|
||||
const picked = scene.pick({ x: px, y: py })?.id;
|
||||
const id = typeof picked === 'string' ? picked : picked?.id;
|
||||
if (typeof id === 'string' && id.startsWith(want))
|
||||
return {
|
||||
x: rect.left + px,
|
||||
|
||||
@@ -0,0 +1,427 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Boot the whole application on the stub renderer with only the contract's
|
||||
* required members (`dev/stub-app/main.js`), headless, and check that:
|
||||
*
|
||||
* - it starts, with no Cesium module requested at all (no script, no
|
||||
* worker, no asset it would fetch; the one Cesium stylesheet the build's
|
||||
* `vite-plugin-cesium` links into every page is reported, not failed);
|
||||
* - the credits show in the application's own line, and its list opens
|
||||
* with the data credits;
|
||||
* - each data layer named below turns on, and off, without a page error or
|
||||
* a console error (a feed's failed response is reported as the feed's,
|
||||
* not failed: without network access or keys a feed answers with an
|
||||
* error, and the layer must take that without one of its own; the dev
|
||||
* server's client's own errors are reported as the tooling's);
|
||||
* - with `--strict`, each of them draws on the stub: items in its draw sets,
|
||||
* imagery added through the globe port, or a field (`draw.field`).
|
||||
*
|
||||
* The page is the application's own (`index.html`), served with the stub
|
||||
* entry in place of `src/main.js`. Without `--url` it starts a Vite dev
|
||||
* server of this checkout on `--port` (default 5290) and stops it after.
|
||||
* Live feeds answer through the dev server's providers, so without network
|
||||
* access or keys a layer turns on with nothing to draw: the run says so,
|
||||
* and only `--strict` fails it.
|
||||
*
|
||||
* `--all-capabilities` gives the stub every capability instead, to see what
|
||||
* the layers draw where a renderer has them all.
|
||||
*
|
||||
* npm run qa:stub-boot [-- --url http://127.0.0.1:5280] [--strict]
|
||||
* [--settle-ms 20000] [--json path] [--all-capabilities]
|
||||
*/
|
||||
import { writeFileSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import puppeteer from 'puppeteer';
|
||||
|
||||
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
|
||||
/** The data layers the stub must run, by catalog id. */
|
||||
export const STUB_BOOT_LAYERS = Object.freeze([
|
||||
'flights',
|
||||
'military',
|
||||
'transit',
|
||||
'traffic',
|
||||
'cctv',
|
||||
'ais-live-vessels',
|
||||
'weather-radar',
|
||||
'weather-satellite',
|
||||
'wind',
|
||||
'satellites',
|
||||
'local-firms',
|
||||
'wildlife-sightings',
|
||||
'shipwrecks',
|
||||
'news',
|
||||
]);
|
||||
|
||||
/** A request that is Cesium: the package, its pre-bundle, or its assets. */
|
||||
export const isCesiumRequest = (url) =>
|
||||
/(?:^|[/._-])cesium(?:[/._-]|$)/i.test(new URL(url).pathname);
|
||||
|
||||
/** The stylesheet `vite-plugin-cesium` links into every page it serves. */
|
||||
const isPluginStylesheet = (url, type) =>
|
||||
type === 'stylesheet' &&
|
||||
new URL(url).pathname === '/cesium/Widgets/widgets.css';
|
||||
|
||||
/**
|
||||
* A browser's line for a feed's response that failed: one of the dev
|
||||
* server's providers (`/api/`) or another origin's. The application's own
|
||||
* modules and assets failing are the page's.
|
||||
*/
|
||||
const isFailedResponse = (text, at, base) => {
|
||||
if (!/^Failed to load resource:/.test(text)) return false;
|
||||
try {
|
||||
const url = new URL(at);
|
||||
return (
|
||||
url.origin !== new URL(base).origin || url.pathname.startsWith('/api/')
|
||||
);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* An error the dev server's own client logs (its socket to the server, which
|
||||
* a headless browser can refuse): the tooling's, not the application's.
|
||||
*/
|
||||
const isDevClient = (at) => {
|
||||
try {
|
||||
return new URL(at).pathname === '/@vite/client';
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
function parseArgs(argv) {
|
||||
const args = { strict: false, port: 5290, settleMs: 20_000 };
|
||||
for (let i = 0; i < argv.length; i++) {
|
||||
const arg = argv[i];
|
||||
if (arg === '--strict') args.strict = true;
|
||||
else if (arg === '--url') args.url = argv[++i];
|
||||
else if (arg === '--port') args.port = Number(argv[++i]);
|
||||
else if (arg === '--settle-ms') args.settleMs = Number(argv[++i]);
|
||||
else if (arg === '--json') args.json = argv[++i];
|
||||
else if (arg === '--all-capabilities') args.allCapabilities = true;
|
||||
else throw new Error(`Unknown argument: ${arg}`);
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
async function startViteServer(port) {
|
||||
const { createServer } = await import('vite');
|
||||
const server = await createServer({
|
||||
root: ROOT,
|
||||
configFile: path.join(ROOT, 'vite.config.js'),
|
||||
// No hot reload: the page is loaded once and nothing edits it.
|
||||
server: { port, strictPort: true, host: '127.0.0.1', hmr: false },
|
||||
logLevel: 'warn',
|
||||
});
|
||||
await server.listen();
|
||||
return server;
|
||||
}
|
||||
|
||||
/**
|
||||
* In the page: what the stub renderer draws now, its draw sets with how many
|
||||
* items each holds and the globe port's imagery layers, and how many calls
|
||||
* it has had on each port member.
|
||||
*/
|
||||
function readDrawn() {
|
||||
const renderer = window.__stubBoot?.renderers?.[0];
|
||||
if (!renderer) return null;
|
||||
const testing = renderer.testing;
|
||||
const calls = {};
|
||||
for (const call of testing.calls) {
|
||||
const key = `${call.port}.${call.member}`;
|
||||
calls[key] = (calls[key] ?? 0) + 1;
|
||||
}
|
||||
return {
|
||||
sets: Object.fromEntries(
|
||||
testing.sets().map((id) => [id, testing.setRecord(id)?.items?.size ?? 0]),
|
||||
),
|
||||
imagery: renderer.globe.imagery.list().length,
|
||||
calls,
|
||||
};
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const args = parseArgs(process.argv.slice(2));
|
||||
const server = args.url ? null : await startViteServer(args.port);
|
||||
try {
|
||||
await run(args);
|
||||
} finally {
|
||||
await server?.close();
|
||||
}
|
||||
}
|
||||
|
||||
async function run(args) {
|
||||
const base = (args.url ?? `http://127.0.0.1:${args.port}`).replace(/\/$/, '');
|
||||
const browser = await puppeteer.launch({
|
||||
headless: true,
|
||||
executablePath:
|
||||
process.env.PUPPETEER_EXECUTABLE_PATH ||
|
||||
(await puppeteer.executablePath()),
|
||||
defaultViewport: { width: 1280, height: 800 },
|
||||
protocolTimeout: 300_000,
|
||||
args: ['--no-sandbox'],
|
||||
});
|
||||
/** Every error the page reports, in order: `page`, `console` or `response`. */
|
||||
const errors = [];
|
||||
const cesiumRequests = [];
|
||||
const cesiumStylesheets = [];
|
||||
const report = { url: base, layers: {}, ok: false };
|
||||
try {
|
||||
const page = await browser.newPage();
|
||||
page.on('console', (message) => {
|
||||
if (message.type() !== 'error') return;
|
||||
const text = message.text();
|
||||
const at = message.location()?.url ?? null;
|
||||
errors.push({
|
||||
kind: isFailedResponse(text, at, base)
|
||||
? 'response'
|
||||
: isDevClient(at)
|
||||
? 'tooling'
|
||||
: 'console',
|
||||
text,
|
||||
at,
|
||||
});
|
||||
});
|
||||
page.on('pageerror', (error) =>
|
||||
errors.push({ kind: 'page', text: String(error?.stack || error) }),
|
||||
);
|
||||
await page.setRequestInterception(true);
|
||||
page.on('request', async (request) => {
|
||||
const url = request.url();
|
||||
if (url.startsWith(base) && isCesiumRequest(url))
|
||||
(isPluginStylesheet(url, request.resourceType())
|
||||
? cesiumStylesheets
|
||||
: cesiumRequests
|
||||
).push(url);
|
||||
// The application's page, with the stub entry in place of its own.
|
||||
if (request.isNavigationRequest() && url.startsWith(base)) {
|
||||
const response = await fetch(url);
|
||||
const html = (await response.text()).replace(
|
||||
'src="/src/main.js"',
|
||||
'src="/dev/stub-app/main.js"',
|
||||
);
|
||||
if (!html.includes('/dev/stub-app/main.js'))
|
||||
throw new Error('The page has no /src/main.js entry to replace');
|
||||
await request.respond({
|
||||
status: response.status,
|
||||
contentType: 'text/html',
|
||||
body: html,
|
||||
});
|
||||
return;
|
||||
}
|
||||
await request.continue();
|
||||
});
|
||||
await page.goto(
|
||||
`${base}/${args.allCapabilities ? '?capabilities=all' : ''}`,
|
||||
{ waitUntil: 'load', timeout: 180_000 },
|
||||
);
|
||||
await page.waitForFunction(() => window.__stubBoot, { timeout: 180_000 });
|
||||
const started = await page.evaluate(() => window.__stubBoot.started);
|
||||
report.started = started;
|
||||
if (!started.ok) throw new Error(`Startup failed: ${started.error}`);
|
||||
await page.waitForFunction(() => window.__godsEyeView?.dataManager, {
|
||||
timeout: 60_000,
|
||||
});
|
||||
report.renderer = await page.evaluate(() => {
|
||||
const renderer = window.__stubBoot.renderers[0];
|
||||
return {
|
||||
id: renderer.id,
|
||||
capabilities: [...renderer.capabilities],
|
||||
canvasInPage: document.contains(renderer.canvas),
|
||||
};
|
||||
});
|
||||
report.startupErrors = errors.slice();
|
||||
// The credits show in the application's own line, with no Cesium: the
|
||||
// line is on screen and its list opens with the data credits in it.
|
||||
report.credits = await page.evaluate(async () => {
|
||||
const line = document.getElementById('gev-credits');
|
||||
const expand = line?.querySelector('.gev-credits-expand');
|
||||
const panel = document.getElementById('gev-credits-panel');
|
||||
const box = line?.getBoundingClientRect();
|
||||
const visible =
|
||||
Boolean(box && box.width > 0 && box.height > 0) &&
|
||||
getComputedStyle(line).visibility !== 'hidden';
|
||||
expand?.click();
|
||||
await new Promise((resolve) => requestAnimationFrame(resolve));
|
||||
const listed =
|
||||
panel?.hidden === false ? panel.querySelectorAll('li').length : 0;
|
||||
expand?.click();
|
||||
return { visible, line: line?.textContent ?? null, listed };
|
||||
});
|
||||
console.log(
|
||||
`credits: ${report.credits.visible ? 'shown' : 'NOT shown'}; line "${report.credits.line}"; ${report.credits.listed} listed`,
|
||||
);
|
||||
const known = await page.evaluate(() =>
|
||||
window.__godsEyeView.dataManager.getAll().map((layer) => layer.id),
|
||||
);
|
||||
report.missingLayers = STUB_BOOT_LAYERS.filter((id) => !known.includes(id));
|
||||
for (const id of STUB_BOOT_LAYERS) {
|
||||
if (!known.includes(id)) continue;
|
||||
const errorsBefore = errors.length;
|
||||
const before = await page.evaluate(readDrawn);
|
||||
const enabled = await page.evaluate(
|
||||
(layerId) =>
|
||||
window.__godsEyeView.dataManager
|
||||
.setEnabled(layerId, true, { origin: 'user' })
|
||||
.then(
|
||||
// It can answer false rather than throw: on is what it says.
|
||||
(value) => ({
|
||||
ok:
|
||||
value !== false &&
|
||||
window.__godsEyeView.dataManager.isEnabled(layerId),
|
||||
value: value ?? null,
|
||||
}),
|
||||
(error) => ({ ok: false, error: String(error?.stack || error) }),
|
||||
),
|
||||
id,
|
||||
);
|
||||
// Feeds load on their own schedule; keep ticking until they draw.
|
||||
const deadline = Date.now() + args.settleMs;
|
||||
let drawn = { sets: {}, imagery: 0, calls: {}, fields: 0 };
|
||||
while (Date.now() < deadline) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 1_000));
|
||||
const now = await page.evaluate(readDrawn);
|
||||
drawn = {
|
||||
sets: Object.fromEntries(
|
||||
Object.entries(now.sets).filter(
|
||||
([setId, items]) => items > 0 && before.sets[setId] !== items,
|
||||
),
|
||||
),
|
||||
imagery: Math.max(0, now.imagery - before.imagery),
|
||||
calls: Object.fromEntries(
|
||||
Object.entries(now.calls)
|
||||
.map(([key, n]) => [key, n - (before.calls[key] ?? 0)])
|
||||
.filter(([, n]) => n > 0),
|
||||
),
|
||||
};
|
||||
drawn.fields = drawn.calls['draw.field'] ?? 0;
|
||||
if (Object.keys(drawn.sets).length || drawn.imagery || drawn.fields)
|
||||
break;
|
||||
}
|
||||
const stats = await page.evaluate((layerId) => {
|
||||
const row = window.__godsEyeView.dataManager
|
||||
.getAll()
|
||||
.find((layer) => layer.id === layerId);
|
||||
return {
|
||||
enabled: row?.enabled ?? null,
|
||||
count: row?.stats?.count ?? null,
|
||||
error: row?.stats?.error ?? null,
|
||||
source: row?.stats?.source ?? null,
|
||||
};
|
||||
}, id);
|
||||
const disabled = await page.evaluate(
|
||||
(layerId) =>
|
||||
window.__godsEyeView.dataManager
|
||||
.setEnabled(layerId, false, { origin: 'user' })
|
||||
.then(
|
||||
(value) => ({
|
||||
ok:
|
||||
value !== false &&
|
||||
!window.__godsEyeView.dataManager.isEnabled(layerId),
|
||||
}),
|
||||
(error) => ({ ok: false, error: String(error?.stack || error) }),
|
||||
),
|
||||
id,
|
||||
);
|
||||
const layerErrors = errors.slice(errorsBefore);
|
||||
report.layers[id] = {
|
||||
enabled,
|
||||
disabled,
|
||||
stats,
|
||||
drawn,
|
||||
errors: layerErrors.filter(
|
||||
(error) => error.kind === 'page' || error.kind === 'console',
|
||||
),
|
||||
failedResponses: layerErrors
|
||||
.filter((error) => error.kind === 'response')
|
||||
.map((error) => error.at),
|
||||
};
|
||||
const what = [
|
||||
...Object.entries(drawn.sets).map(([setId, n]) => `${setId}=${n}`),
|
||||
...(drawn.imagery ? [`${drawn.imagery} imagery layer(s)`] : []),
|
||||
...(drawn.fields ? [`${drawn.fields} field(s)`] : []),
|
||||
];
|
||||
console.log(
|
||||
`${id}: ${enabled.ok && disabled.ok ? 'ran' : 'FAILED'}; drew ${
|
||||
what.length ? what.join(', ') : 'nothing'
|
||||
}${stats.error ? `; feed: ${stats.error}` : ''}${
|
||||
report.layers[id].failedResponses.length
|
||||
? `; ${report.layers[id].failedResponses.length} failed response(s)`
|
||||
: ''
|
||||
}`,
|
||||
);
|
||||
}
|
||||
report.ok = true;
|
||||
} catch (error) {
|
||||
// Reported with the rest below, so the report and errors are kept.
|
||||
report.failure = String(error?.stack || error);
|
||||
} finally {
|
||||
report.cesiumRequests = cesiumRequests;
|
||||
report.cesiumStylesheets = cesiumStylesheets;
|
||||
report.errors = errors;
|
||||
await browser.close();
|
||||
}
|
||||
const pageErrors = errors.filter((error) => error.kind === 'page');
|
||||
const consoleErrors = errors.filter((error) => error.kind === 'console');
|
||||
const failedResponses = errors.filter((error) => error.kind === 'response');
|
||||
const toolingErrors = errors.filter((error) => error.kind === 'tooling');
|
||||
const problems = [];
|
||||
if (report.failure) problems.push(`the run stopped: ${report.failure}`);
|
||||
if (!report.started?.ok) problems.push('the application did not start');
|
||||
if (!report.renderer?.canvasInPage)
|
||||
problems.push("the stub's canvas is not in the page");
|
||||
if (
|
||||
report.started?.ok &&
|
||||
(!report.credits?.visible || !report.credits.listed)
|
||||
)
|
||||
problems.push('the credits line is not shown, or its list is empty');
|
||||
if (cesiumRequests.length)
|
||||
problems.push(`Cesium was requested: ${cesiumRequests.join(', ')}`);
|
||||
if (pageErrors.length) problems.push(`${pageErrors.length} page error(s)`);
|
||||
if (consoleErrors.length)
|
||||
problems.push(`${consoleErrors.length} console error(s)`);
|
||||
if (report.missingLayers?.length)
|
||||
problems.push(`layers not in the catalog: ${report.missingLayers}`);
|
||||
for (const [id, layer] of Object.entries(report.layers)) {
|
||||
if (!layer.enabled.ok || !layer.disabled.ok)
|
||||
problems.push(`${id} failed to turn on or off`);
|
||||
if (
|
||||
args.strict &&
|
||||
!Object.keys(layer.drawn.sets).length &&
|
||||
!layer.drawn.imagery &&
|
||||
!layer.drawn.fields
|
||||
)
|
||||
problems.push(`${id} drew nothing`);
|
||||
}
|
||||
report.problems = problems;
|
||||
if (args.json) writeFileSync(args.json, JSON.stringify(report, null, 2));
|
||||
for (const error of [...pageErrors, ...consoleErrors])
|
||||
console.error(`${error.kind} error: ${error.text} (${error.at ?? '?'})`);
|
||||
if (cesiumStylesheets.length)
|
||||
console.log(
|
||||
`note: the build's Cesium plugin linked ${cesiumStylesheets.join(', ')}`,
|
||||
);
|
||||
if (toolingErrors.length)
|
||||
console.log(
|
||||
`note: the dev server's client logged ${toolingErrors.length} error(s): ${[
|
||||
...new Set(toolingErrors.map((error) => error.text)),
|
||||
].join(' | ')}`,
|
||||
);
|
||||
if (failedResponses.length)
|
||||
console.log(
|
||||
`note: ${failedResponses.length} feed response(s) failed (keys or network)`,
|
||||
);
|
||||
if (problems.length) {
|
||||
console.error(`FAIL: ${problems.join('; ')}`);
|
||||
process.exitCode = 1;
|
||||
} else console.log('ok: the application runs on the stub renderer');
|
||||
}
|
||||
|
||||
if (import.meta.url === `file://${process.argv[1]}`)
|
||||
main().catch((error) => {
|
||||
console.error(error);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
@@ -8,7 +8,7 @@
|
||||
* answers HTTP 429 for most of them. This harness drives that burst, counts the
|
||||
* throttled responses, keeps the first 429's headers as evidence, and then
|
||||
* checks whether every throttled tile eventually loaded — the contract the
|
||||
* client-side retry in `src/maps/terrain.js` provides.
|
||||
* client-side retry in `src/render/cesium/mapTerrain.js` provides.
|
||||
*
|
||||
* Run against a keyless dev server (no Google or ion credentials):
|
||||
* env -u GOOGLE_MAPS_API_KEY -u CESIUM_ION_TOKEN npm run dev -- --port 4180
|
||||
|
||||
@@ -8,13 +8,16 @@
|
||||
* 1. exact-viewport revisit (traffic module's full-road cache),
|
||||
* 2. adjacent 0.4–2 km pan (new exact bbox with heavy spatial overlap),
|
||||
* 3. cold city (no traffic-module entry for that city),
|
||||
* 4. degraded upstream (synthetic delay on `/api/overpass` only).
|
||||
* 4. degraded upstream (synthetic delay on the road requests: OpenFreeMap's
|
||||
* host, which only traffic reads in this capture, or the Overpass proxy).
|
||||
*
|
||||
* The proxy's actual `X-Overpass-Cache` result is printed for every network
|
||||
* pass, so HIT/DISK/MISS/STALE/INFLIGHT is evidence rather than inference.
|
||||
* The degraded leg delays request release in Puppeteer; it exercises the same
|
||||
* fetch-start→response boundary without adding a failure switch to the
|
||||
* application or proxy. Pass `--degraded-delay-ms 0` to skip that leg.
|
||||
* Keyless roads come from OpenFreeMap vector tiles (`tiles.openfreemap.org`);
|
||||
* a build that still reads them through the Overpass proxy has its
|
||||
* `X-Overpass-Cache` result printed for every network pass, so
|
||||
* HIT/DISK/MISS/STALE/INFLIGHT is evidence rather than inference ("—" for
|
||||
* tiles). The degraded leg delays the road requests' release in Puppeteer;
|
||||
* it exercises the same fetch-start→response boundary without adding a
|
||||
* failure switch to the application or proxy. Pass `--degraded-delay-ms 0` to skip that leg.
|
||||
* TomTom status is intercepted as keyless so no live-flow key is required and
|
||||
* the capture isolates the OSM road-to-visible-dot chain.
|
||||
*
|
||||
@@ -93,9 +96,42 @@ function debugUrl(rawUrl) {
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
/** Position the camera and explicitly raise the boundaries the layer observes. */
|
||||
/**
|
||||
* Let the camera report a move the way a user's does: traffic hears the
|
||||
* camera port's `changed` at its own 5% threshold (layers/traffic/policy.js
|
||||
* CAMERA_CHANGED_THRESHOLD), which the port measures on every scene tick
|
||||
* (the first measurement after a listener subscribes only records its
|
||||
* baseline pose). Waiting for two drawn frames after the move is the sync
|
||||
* point that the port has measured it. Cesium's own moveEnd (500 ms after
|
||||
* stillness) is left to Cesium, as in the app; traffic re-checks the view
|
||||
* on it. Installed in the page as `window.__qaRenderAfterMove`; throws when
|
||||
* the frames do not draw within 5 s.
|
||||
*/
|
||||
function installRenderAfterMove() {
|
||||
window.__qaRenderAfterMove = (gev) => new Promise((resolve, reject) => {
|
||||
const scene = gev.viewer.scene;
|
||||
let frames = 0;
|
||||
let remove = null;
|
||||
const timer = setTimeout(() => {
|
||||
remove();
|
||||
reject(new Error(`the camera move rendered ${frames} frame(s) in 5 s`));
|
||||
}, 5000);
|
||||
remove = scene.postRender.addEventListener(() => {
|
||||
if (++frames >= 2) {
|
||||
clearTimeout(timer);
|
||||
remove();
|
||||
resolve(frames);
|
||||
return;
|
||||
}
|
||||
scene.requestRender();
|
||||
});
|
||||
scene.requestRender();
|
||||
});
|
||||
}
|
||||
|
||||
/** Position the camera and render, so the layer hears the move as it would a user's. */
|
||||
async function moveCamera(page, view) {
|
||||
return page.evaluate((v) => {
|
||||
return page.evaluate(async (v) => {
|
||||
const gev = window.__godsEyeView;
|
||||
const module = gev.dataManager.layers.get('traffic').module;
|
||||
const beforeLastUpdate = module.getStats().lastUpdate;
|
||||
@@ -115,12 +151,7 @@ async function moveCamera(page, view) {
|
||||
roll: 0,
|
||||
},
|
||||
});
|
||||
// setView normally propagates through Cesium's render loop. Raising these
|
||||
// explicitly makes the capture boundary deterministic across GPU speeds.
|
||||
// Pairing still flows through camera.changed's schedule-time anchor; the
|
||||
// synthetic moveEnd is emitted only as the same diagnostic used naturally.
|
||||
gev.viewer.camera.changed.raiseEvent();
|
||||
gev.viewer.camera.moveEnd.raiseEvent();
|
||||
await window.__qaRenderAfterMove(gev);
|
||||
return { beforeLastUpdate, boundaryTime };
|
||||
}, view);
|
||||
}
|
||||
@@ -159,14 +190,29 @@ function readTrafficMeasures(page, boundaryTime) {
|
||||
})), boundaryTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Road requests the page sent, counted by the request interceptor: `sent` is
|
||||
* every road request that reached the network, `delayed` those it held for
|
||||
* the degraded leg. `requestRoads()` can be answered from decoded tiles
|
||||
* already in memory, so a `fetch-to-response` measure alone does not prove
|
||||
* the network was used.
|
||||
*/
|
||||
const roadRequests = { sent: 0, delayed: 0 };
|
||||
|
||||
/** Drive one measured state and return its raw User Timing measures. */
|
||||
async function captureState(page, name, view, setDelay) {
|
||||
setDelay(name === 'degraded-upstream' ? DEGRADED_DELAY_MS : 0);
|
||||
const before = { ...roadRequests };
|
||||
const { beforeLastUpdate, boundaryTime } = await moveCamera(page, view);
|
||||
await waitForTrafficCapture(page, beforeLastUpdate, boundaryTime);
|
||||
const measures = await readTrafficMeasures(page, boundaryTime);
|
||||
setDelay(0);
|
||||
return { name, measures };
|
||||
return {
|
||||
name,
|
||||
measures,
|
||||
sent: roadRequests.sent - before.sent,
|
||||
delayed: roadRequests.delayed - before.delayed,
|
||||
};
|
||||
}
|
||||
|
||||
/** Format a duration without hiding zero-duration measurements. */
|
||||
@@ -318,13 +364,14 @@ async function main() {
|
||||
const page = await browser.newPage();
|
||||
await page.setViewport({ width: 1440, height: 900 });
|
||||
await page.evaluateOnNewDocument(() => localStorage.clear());
|
||||
await page.evaluateOnNewDocument(installRenderAfterMove);
|
||||
page.on('console', (message) => {
|
||||
if (message.type() === 'error') consoleErrors.push(message.text());
|
||||
});
|
||||
page.on('pageerror', (error) => consoleErrors.push(error.message));
|
||||
|
||||
// Force keyless traffic and optionally hold Overpass requests to model a
|
||||
// degraded proxy/upstream. No server key or proxy debug endpoint is needed.
|
||||
// Force keyless traffic and optionally hold the road requests to model a
|
||||
// degraded upstream. No server key or proxy debug endpoint is needed.
|
||||
await page.setRequestInterception(true);
|
||||
page.on('request', async (request) => {
|
||||
if (request.url().includes('/api/tomtom/status')) {
|
||||
@@ -335,7 +382,11 @@ async function main() {
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (activeProxyDelayMs > 0 && request.url().includes('/api/overpass')) {
|
||||
const roadRequest = request.url().includes('/api/overpass')
|
||||
|| new URL(request.url()).hostname === 'tiles.openfreemap.org';
|
||||
if (roadRequest) roadRequests.sent += 1;
|
||||
if (activeProxyDelayMs > 0 && roadRequest) {
|
||||
roadRequests.delayed += 1;
|
||||
await sleep(activeProxyDelayMs);
|
||||
}
|
||||
try { await request.continue(); } catch { /* page closed or already handled */ }
|
||||
@@ -363,8 +414,9 @@ async function main() {
|
||||
orientation: { heading: 0, pitch: -Math.PI / 2, roll: 0 },
|
||||
});
|
||||
await gev.dataManager.setEnabled('traffic', true);
|
||||
gev.viewer.camera.changed.raiseEvent();
|
||||
gev.viewer.camera.moveEnd.raiseEvent();
|
||||
// Also records the baseline pose traffic's new `changed` listener
|
||||
// measures the first measured move against.
|
||||
await window.__qaRenderAfterMove(gev);
|
||||
}, VIEWS.austin);
|
||||
await sleep(500);
|
||||
|
||||
@@ -386,7 +438,7 @@ async function main() {
|
||||
|
||||
// Clear the last-bounds gate without clearing the module's road cache, then
|
||||
// revisit the byte-identical camera pose for a true client-cache hit.
|
||||
await page.evaluate((view) => {
|
||||
await page.evaluate(async (view) => {
|
||||
const gev = window.__godsEyeView;
|
||||
const ellipsoid = gev.viewer.scene.globe.ellipsoid;
|
||||
const radians = Math.PI / 180;
|
||||
@@ -398,8 +450,7 @@ async function main() {
|
||||
}),
|
||||
orientation: { heading: 0, pitch: -Math.PI / 2, roll: 0 },
|
||||
});
|
||||
gev.viewer.camera.changed.raiseEvent();
|
||||
gev.viewer.camera.moveEnd.raiseEvent();
|
||||
await window.__qaRenderAfterMove(gev);
|
||||
}, VIEWS.austin);
|
||||
await sleep(500);
|
||||
|
||||
@@ -428,7 +479,7 @@ async function main() {
|
||||
}
|
||||
for (const capture of captures.slice(1)) {
|
||||
if (!capture.measures.some((entry) => entry.detail?.segment === 'fetch-to-response')) {
|
||||
throw new Error(`${capture.name} did not issue an Overpass request`);
|
||||
throw new Error(`${capture.name} did not issue a road request`);
|
||||
}
|
||||
}
|
||||
if (DEGRADED_DELAY_MS > 0) {
|
||||
@@ -438,20 +489,35 @@ async function main() {
|
||||
&& entry.duration >= DEGRADED_DELAY_MS * 0.9
|
||||
));
|
||||
if (!delayed) throw new Error('degraded-upstream leg did not observe the synthetic delay');
|
||||
// The delay has to come from held road requests, not from processing
|
||||
// that happened to run long.
|
||||
if (!degraded.delayed) throw new Error('degraded-upstream leg sent no road request to hold');
|
||||
}
|
||||
// A city the client has never seen has no tiles in memory: it must reach
|
||||
// the network. The other legs may legitimately be answered from tiles
|
||||
// already decoded, so their counts are reported, not asserted.
|
||||
const cold = captures.find((capture) => capture.name === 'cold city (client)');
|
||||
if (!cold?.sent) throw new Error('cold city leg sent no road request to the network');
|
||||
|
||||
const rows = captures.flatMap(rowsForCapture);
|
||||
if (!rows.length) throw new Error('no measured traffic renders were captured');
|
||||
console.log('\nCausal segments (one row per visible major/full pass)');
|
||||
console.table(rows);
|
||||
console.log('\nRoad requests sent to the network per leg (held by the degraded leg)');
|
||||
console.table(captures.map((capture) => ({
|
||||
State: capture.name,
|
||||
Sent: capture.sent,
|
||||
Held: capture.delayed,
|
||||
})));
|
||||
console.log('\nNotes:');
|
||||
console.log(' - Render→postRender is the first visible-frame boundary used by Phase 0.');
|
||||
console.log(' - Proxy cache is read from X-Overpass-Cache; “—” means the client cache avoided fetch.');
|
||||
console.log(' - response.json includes both body transfer and JSON decoding; the production path does not split them.');
|
||||
console.log(' - Last change→fetch is approximately the 320 ms FETCH_DEBOUNCE for the first fetch by construction.');
|
||||
console.log(' - Proxy cache is read from X-Overpass-Cache; “—” means the client cache avoided fetch, or the roads came from OpenFreeMap tiles.');
|
||||
console.log(' - Through the Overpass proxy, Fetch→response is the HTTP response and response.json is body transfer plus JSON decoding.');
|
||||
console.log(' - From OpenFreeMap tiles, Fetch→response spans the tile requests, body reads, decoding and composition, and response.json only hands back the built object; a held leg can stack the delay over tiles fetched in turn.');
|
||||
console.log(' - Last change→fetch is the 320 ms FETCH_DEBOUNCE for the first fetch by construction, plus timer and main-thread latency (larger under SwiftShader).');
|
||||
console.log(' - Full-pass Last change→fetch also includes the intentionally sequential major pass.');
|
||||
console.log(' - Cesium moveEnd is a diagnostic raised ~500 ms after stillness, typically after fetch starts; fetch never waits for it.');
|
||||
console.log(' - Synthetic events bypass camera percentageChanged/inertia but use the same camera.changed schedule-time anchor as natural captures.');
|
||||
console.log(' - Cesium moveEnd is raised ~500 ms after stillness, typically after fetch starts; fetch never waits for it, and traffic only re-checks the view on it.');
|
||||
console.log(' - Moves are setView plus rendered frames: the camera port measures traffic\'s own 5% changed threshold as for a user move (inertia is bypassed).');
|
||||
console.log(' - The keyless capture zeroes Flow race and Heat lines work; live-keyed numbers will differ.');
|
||||
console.log(' - Measurement caveat: timings include instrumentation overhead (observer effect) and browser clock-floor quantization.');
|
||||
console.log(' - Per-road clock observations inside road-parse-total/waypoint-materialization slightly overstate production work.');
|
||||
|
||||
@@ -158,9 +158,13 @@ try {
|
||||
(window.__motion.holdStart === null
|
||||
? ''
|
||||
: ` | camera stopped +${((now - window.__motion.holdStart) / 1000).toFixed(1)}s`);
|
||||
// A layer dot is its draw item (`pos`, hidden only when `show` is
|
||||
// false); a collection's point is Cesium's.
|
||||
const visit = (id, roadId, point) => {
|
||||
if (!point.show) return;
|
||||
const s = scene.cartesianToCanvasCoordinates(point.position);
|
||||
if (point.show === false) return;
|
||||
const s = scene.cartesianToCanvasCoordinates(
|
||||
point.pos ?? point.position,
|
||||
);
|
||||
if (s && s.x >= 0 && s.y >= 0 && s.x <= 1280 && s.y <= 800)
|
||||
points.set(id, { x: s.x, y: s.y, roadId });
|
||||
};
|
||||
@@ -168,7 +172,7 @@ try {
|
||||
offRoad = 0;
|
||||
if (!baseline && layer.visitMotionDots) {
|
||||
layer.visitMotionDots((id, roadId, point, road) => {
|
||||
if (point.show) {
|
||||
if (point.show !== false) {
|
||||
const p = road?.roadProperties;
|
||||
const allowed = road?.directFlow
|
||||
? [
|
||||
@@ -195,7 +199,7 @@ try {
|
||||
p?.brunnel !== 'tunnel';
|
||||
if (!allowed) offRoad++;
|
||||
}
|
||||
if (point.show) n++;
|
||||
if (point.show !== false) n++;
|
||||
visit(id, roadId, point);
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -83,9 +83,10 @@ try {
|
||||
lower = 0;
|
||||
dataManager.layers
|
||||
.get('traffic')
|
||||
.module.visitMotionDots((id, key, p) => {
|
||||
if (!p.show) return;
|
||||
const s = viewer.scene.cartesianToCanvasCoordinates(p.position);
|
||||
.module.visitMotionDots((id, key, dot) => {
|
||||
// A dot is its draw item: `pos`, hidden only when `show` is false.
|
||||
if (dot.show === false) return;
|
||||
const s = viewer.scene.cartesianToCanvasCoordinates(dot.pos);
|
||||
if (s && s.x >= 240 && s.x <= 1040 && s.y >= 0 && s.y <= 800) {
|
||||
if (s.y < 400) upper++;
|
||||
else lower++;
|
||||
@@ -197,8 +198,10 @@ try {
|
||||
const camera = viewer.camera.positionWC;
|
||||
dataManager.layers
|
||||
.get('traffic')
|
||||
.module.visitMotionDots((id, key, p) => {
|
||||
if (!p.show) return;
|
||||
.module.visitMotionDots((id, key, dot) => {
|
||||
// A dot is its draw item: `pos`, hidden only when `show` is false.
|
||||
if (dot.show === false) return;
|
||||
const p = { position: dot.pos };
|
||||
const q = viewer.scene.cartesianToCanvasCoordinates(p.position);
|
||||
if (q && q.x >= 240 && q.x <= 1040 && q.y >= 0 && q.y <= 800) {
|
||||
if (q.y < 400) upper++;
|
||||
|
||||
@@ -177,6 +177,19 @@ export async function sampleTransitPixels(page, palette) {
|
||||
];
|
||||
const width = canvas.clientWidth;
|
||||
const height = canvas.clientHeight;
|
||||
// The billboards the draw port drew for the layer's two sets, by
|
||||
// vehicle key, with the collection drawing each.
|
||||
const drawn = new Map();
|
||||
const setIds = layer._transitSetIdsForTest();
|
||||
for (let i = 0; i < scene.primitives.length; i++) {
|
||||
const host = scene.primitives.get(i);
|
||||
if (!setIds.includes(host?.drawSetId)) continue;
|
||||
for (let j = 0; j < host.length; j++) {
|
||||
const billboard = host.get(j);
|
||||
if (typeof billboard?.id?.id === 'string')
|
||||
drawn.set(billboard.id.id, { billboard, host });
|
||||
}
|
||||
}
|
||||
const sprites = [];
|
||||
const footprints = [];
|
||||
const intersects = (a, b) =>
|
||||
@@ -256,20 +269,26 @@ export async function sampleTransitPixels(page, palette) {
|
||||
};
|
||||
for (const entry of state._vehicles.values()) {
|
||||
if (!entry.marker || entry.marker.show === false) continue;
|
||||
const p = entry.marker.position;
|
||||
const row = drawn.get(entry.key);
|
||||
if (!row || row.billboard.show === false) {
|
||||
skipped.push({ key: entry.key, reason: 'billboard not drawn' });
|
||||
continue;
|
||||
}
|
||||
const billboard = row.billboard;
|
||||
const p = billboard.position;
|
||||
const clip = mul(proj, mul(view, [p.x, p.y, p.z, 1]));
|
||||
if (!(clip[3] > 0)) continue;
|
||||
const screen = entry.marker.computeScreenSpacePosition?.(scene) || {
|
||||
const screen = billboard.computeScreenSpacePosition?.(scene) || {
|
||||
x: ((clip[0] / clip[3]) * 0.5 + 0.5) * width,
|
||||
y: (1 - ((clip[1] / clip[3]) * 0.5 + 0.5)) * height,
|
||||
};
|
||||
const rect = entry.marker.constructor.getScreenSpaceBoundingBox?.(
|
||||
entry.marker,
|
||||
const rect = billboard.constructor.getScreenSpaceBoundingBox?.(
|
||||
billboard,
|
||||
screen,
|
||||
) || { x: screen.x - 16, y: screen.y - 16, width: 32, height: 32 };
|
||||
const { x, y } = screenPoint(screen.x, screen.y);
|
||||
const c = Math.abs(Math.cos(entry.marker.rotation || 0)),
|
||||
sn = Math.abs(Math.sin(entry.marker.rotation || 0));
|
||||
const c = Math.abs(Math.cos(billboard.rotation || 0)),
|
||||
sn = Math.abs(Math.sin(billboard.rotation || 0));
|
||||
const w = rect.width * c + rect.height * sn,
|
||||
h = rect.height * c + rect.width * sn;
|
||||
const footprint = { x: x - w / 2, y: y - h / 2, w, h };
|
||||
@@ -282,10 +301,7 @@ export async function sampleTransitPixels(page, palette) {
|
||||
rect.y + rect.height > height
|
||||
)
|
||||
reason = 'billboard rectangle outside frame';
|
||||
if (
|
||||
entry.marker.color?.alpha < 0.95 ||
|
||||
entry.markerCollection?.show === false
|
||||
)
|
||||
if (billboard.color?.alpha < 0.95 || row.host.show === false)
|
||||
reason = 'billboard not opaque/collection hidden';
|
||||
const raster = rasters.get(entry.marker.image);
|
||||
if (!raster) reason = 'billboard alpha unavailable';
|
||||
@@ -351,12 +367,12 @@ export async function sampleTransitPixels(page, palette) {
|
||||
bracketX: entry.detectContact?._candidateScreenX ?? screen.x,
|
||||
bracketY: entry.detectContact?._candidateScreenY ?? screen.y,
|
||||
raster,
|
||||
rotation: entry.marker.rotation || 0,
|
||||
halfW: Number.isFinite(entry.marker.width)
|
||||
? Math.ceil(entry.marker.width / 2) + 2
|
||||
rotation: billboard.rotation || 0,
|
||||
halfW: Number.isFinite(billboard.width)
|
||||
? Math.ceil(billboard.width / 2) + 2
|
||||
: 11,
|
||||
halfH: Number.isFinite(entry.marker.height)
|
||||
? Math.ceil(entry.marker.height / 2) + 2
|
||||
halfH: Number.isFinite(billboard.height)
|
||||
? Math.ceil(billboard.height / 2) + 2
|
||||
: 7,
|
||||
});
|
||||
}
|
||||
@@ -658,12 +674,23 @@ export function readTransitFleetStyle({ key, resetSelection = false } = {}) {
|
||||
const entry = key
|
||||
? state._vehicles.get(key)
|
||||
: [...state._vehicles.values()].find((e) => e.marker?.show);
|
||||
return entry
|
||||
// The billboard the draw port drew for it, in either of the layer's sets.
|
||||
const scene = window.__godsEyeView.viewer.scene;
|
||||
const setIds = layer._transitSetIdsForTest();
|
||||
let billboard = null;
|
||||
for (let i = 0; entry && !billboard && i < scene.primitives.length; i++) {
|
||||
const host = scene.primitives.get(i);
|
||||
if (!setIds.includes(host?.drawSetId)) continue;
|
||||
for (let j = 0; j < host.length; j++)
|
||||
if (host.get(j)?.id?.id === entry.key) billboard = host.get(j);
|
||||
}
|
||||
// An undrawn marker has no style to compare: no answer.
|
||||
return entry && billboard
|
||||
? {
|
||||
key: entry.key,
|
||||
selected: state._selectedKey === entry.key,
|
||||
color: entry.marker.color.toCssColorString(),
|
||||
width: entry.marker.width,
|
||||
color: billboard.color.toCssColorString(),
|
||||
width: billboard.width,
|
||||
image: entry.marker.image,
|
||||
}
|
||||
: null;
|
||||
|
||||
@@ -182,7 +182,8 @@ try {
|
||||
});
|
||||
parts.rendering.sampleIdle(entry);
|
||||
parts.rendering.schedulePlayback(entry);
|
||||
const V = entry.marker.position.constructor;
|
||||
// Marker positions are plain records; the camera's eye is a Cartesian3.
|
||||
const V = scene.camera.positionWC.constructor;
|
||||
const points = entry.trailSegments
|
||||
.filter((s) => s.toT <= entry.sample.displayT)
|
||||
.flatMap((s) => s.positions);
|
||||
|
||||
+108
-31
@@ -146,11 +146,7 @@ export async function runFleetBudgets({
|
||||
// The retained delta is conservative: it includes concurrent page growth.
|
||||
const retained = await cdp.send('Runtime.getHeapUsage');
|
||||
// Timing/upload acceptance runs without the allocation profiler attached.
|
||||
const trace = await page.evaluate(() =>
|
||||
window.__godsEyeView.dataManager.layers
|
||||
.get('transit')
|
||||
.module._measureTransitFramesForTest(8000),
|
||||
);
|
||||
const trace = await page.evaluate(measureTransitFrames, 8000);
|
||||
await page.evaluate(() =>
|
||||
window.__godsEyeView.dataManager.layers
|
||||
.get('transit')
|
||||
@@ -166,11 +162,7 @@ export async function runFleetBudgets({
|
||||
page,
|
||||
`${count} budget visibility before allocation trace`,
|
||||
);
|
||||
const allocationTrace = await page.evaluate(() =>
|
||||
window.__godsEyeView.dataManager.layers
|
||||
.get('transit')
|
||||
.module._measureTransitFramesForTest(6000),
|
||||
);
|
||||
const allocationTrace = await page.evaluate(measureTransitFrames, 6000);
|
||||
const { profile } = await cdp.send('HeapProfiler.stopSampling');
|
||||
const allocations = allocationTotals(profile);
|
||||
const retainedBytes = retained.usedSize - before.usedSize;
|
||||
@@ -361,13 +353,23 @@ export async function runBostonMatrix({
|
||||
const modes = await page.evaluate(() => {
|
||||
const layer =
|
||||
window.__godsEyeView.dataManager.layers.get('transit').module;
|
||||
// The billboards the draw port drew for the markers, by key.
|
||||
const scene = window.__godsEyeView.viewer.scene;
|
||||
const setIds = layer._transitSetIdsForTest();
|
||||
const drawn = new Map();
|
||||
for (let i = 0; i < scene.primitives.length; i++) {
|
||||
const host = scene.primitives.get(i);
|
||||
if (!setIds.includes(host?.drawSetId)) continue;
|
||||
for (let j = 0; j < host.length; j++)
|
||||
drawn.set(host.get(j)?.id?.id, host.get(j));
|
||||
}
|
||||
return [...layer._transitStateForTest()._vehicles.values()].map(
|
||||
(e) => ({
|
||||
key: e.key,
|
||||
route: e.record.routeId,
|
||||
image: e.marker.image,
|
||||
width: e.marker.width,
|
||||
color: e.marker.color.toCssHexString(),
|
||||
width: drawn.get(e.key)?.width ?? null,
|
||||
color: drawn.get(e.key)?.color.toCssHexString() ?? null,
|
||||
}),
|
||||
);
|
||||
});
|
||||
@@ -418,15 +420,29 @@ export async function runBostonMatrix({
|
||||
window.__godsEyeView.dataManager.layers.get('transit').module;
|
||||
layer._transitPartsForTest().selection.clearSelection();
|
||||
const e = layer._transitStateForTest()._vehicles.get(key);
|
||||
// The billboard the draw port drew for it: the last under its key,
|
||||
// as the fleet sample above reads it (the fleet-models set draws
|
||||
// one under the same key first).
|
||||
const scene = window.__godsEyeView.viewer.scene;
|
||||
const setIds = layer._transitSetIdsForTest();
|
||||
let drawn = null;
|
||||
for (let i = 0; i < scene.primitives.length; i++) {
|
||||
const host = scene.primitives.get(i);
|
||||
if (!setIds.includes(host?.drawSetId)) continue;
|
||||
for (let j = 0; j < host.length; j++)
|
||||
if (host.get(j)?.id?.id === key) drawn = host.get(j);
|
||||
}
|
||||
return {
|
||||
drawn: Boolean(drawn),
|
||||
image: e.marker.image,
|
||||
width: e.marker.width,
|
||||
color: e.marker.color.toCssHexString(),
|
||||
width: drawn?.width ?? null,
|
||||
color: drawn?.color.toCssHexString() ?? null,
|
||||
};
|
||||
}, target.key);
|
||||
check(
|
||||
`Boston ${background.name}/${look.name}/${target.route}: deselect restores fleet styling`,
|
||||
restored.image === target.image &&
|
||||
restored.drawn &&
|
||||
restored.image === target.image &&
|
||||
restored.width === target.width &&
|
||||
restored.color === target.color,
|
||||
);
|
||||
@@ -727,6 +743,15 @@ export async function runTrailVisibility({
|
||||
bodyUploadMax = 0,
|
||||
frames = 0;
|
||||
const headCpu = [];
|
||||
// The Cesium primitives drawing one of the trail's draw-port sets: one,
|
||||
// or while a rebuild builds, the retiring one and its replacement.
|
||||
const hostsOf = (set) => {
|
||||
const hosts = [];
|
||||
for (let i = 0; set && i < scene.primitives.length; i++)
|
||||
if (scene.primitives.get(i).drawSetId === set.id)
|
||||
hosts.push(scene.primitives.get(i));
|
||||
return hosts;
|
||||
};
|
||||
const wrap = (primitive, kind) => {
|
||||
if (!primitive || wrapped.has(primitive)) return;
|
||||
const update = primitive.update;
|
||||
@@ -767,8 +792,8 @@ export async function runTrailVisibility({
|
||||
const pre = scene.preRender.addEventListener(() => {
|
||||
headBytes = bodyBytes = 0;
|
||||
const trail = parts.trails.diagnostics();
|
||||
wrap(trail?.body, 'body');
|
||||
wrap(trail?.headPrimitive || trail?.head?._polylineCollection, 'head');
|
||||
for (const host of hostsOf(trail?.body)) wrap(host, 'body');
|
||||
for (const host of hostsOf(trail?.headLines)) wrap(host, 'head');
|
||||
});
|
||||
const post = scene.postRender.addEventListener(() => {
|
||||
frames++;
|
||||
@@ -807,6 +832,26 @@ export async function runTrailVisibility({
|
||||
const trail = parts.trails.diagnostics();
|
||||
if (!entry || !trail)
|
||||
return { ...setup, present: 0, reason: 'selection disappeared' };
|
||||
// The Cesium primitives drawing one of the trail's draw-port sets: one,
|
||||
// or while a rebuild builds, the retiring one and its replacement.
|
||||
const hostsOf = (set) => {
|
||||
const hosts = [];
|
||||
for (let i = 0; set && i < scene.primitives.length; i++)
|
||||
if (scene.primitives.get(i).drawSetId === set.id)
|
||||
hosts.push(scene.primitives.get(i));
|
||||
return hosts;
|
||||
};
|
||||
// Each part of a set's primitive, for readiness and height exclusion.
|
||||
const partsOf = (set) => {
|
||||
const out = [];
|
||||
for (const host of hostsOf(set))
|
||||
for (let i = 0; i < host.length; i++) out.push(host.get(i));
|
||||
return out;
|
||||
};
|
||||
// One host (no rebuild under way) whose parts have all built.
|
||||
const drawnReady = (set) =>
|
||||
hostsOf(set).length === 1 &&
|
||||
partsOf(set).every((part) => part.ready !== false);
|
||||
const { setRate } = await import('/src/data/contactPlayback.js');
|
||||
setRate(entry.track, 0, {
|
||||
wallNowMs: Date.now(),
|
||||
@@ -819,8 +864,8 @@ export async function runTrailVisibility({
|
||||
app.tileset?.show !== false &&
|
||||
app.tileset?.tilesLoaded === true &&
|
||||
(scene.globe?.show === false || scene.globe?.tilesLoaded === true) &&
|
||||
trail.body?.ready === true &&
|
||||
(!trail.headPrimitive || trail.headPrimitive.ready === true);
|
||||
drawnReady(trail.body) &&
|
||||
(!trail.headLines?.show || drawnReady(trail.headLines));
|
||||
// Require sustained readiness after freezing playback, before projecting
|
||||
// onto the refined surface. Repeated captures still check pixel stability.
|
||||
const tilesReady = await new Promise((resolve) => {
|
||||
@@ -855,7 +900,18 @@ export async function runTrailVisibility({
|
||||
if (points.length < 2)
|
||||
return { ...setup, present: 0, reason: 'no completed path' };
|
||||
const C = scene.camera.positionCartographic.constructor;
|
||||
const V = entry.marker.position.constructor;
|
||||
// Marker positions are plain records; the camera's eye is a Cartesian3.
|
||||
const V = scene.camera.positionWC.constructor;
|
||||
// The billboard the draw port drew for the marker, seen through.
|
||||
const setIds = layer._transitSetIdsForTest();
|
||||
const markerBillboards = [];
|
||||
for (let i = 0; i < scene.primitives.length; i++) {
|
||||
const host = scene.primitives.get(i);
|
||||
if (!setIds.includes(host?.drawSetId)) continue;
|
||||
for (let j = 0; j < host.length; j++)
|
||||
if (host.get(j)?.id?.id === entry.key)
|
||||
markerBillboards.push(host.get(j));
|
||||
}
|
||||
const lengths = [0];
|
||||
for (let i = 1; i < points.length; i++)
|
||||
lengths.push(lengths.at(-1) + V.distance(points[i - 1], points[i]));
|
||||
@@ -875,10 +931,11 @@ export async function runTrailVisibility({
|
||||
new V(),
|
||||
);
|
||||
const cart = C.fromCartesian(p);
|
||||
const height = scene.sampleHeight(
|
||||
cart,
|
||||
[entry.marker, trail.body, trail.headPrimitive].filter(Boolean),
|
||||
);
|
||||
const height = scene.sampleHeight(cart, [
|
||||
...markerBillboards,
|
||||
...partsOf(trail.body),
|
||||
...partsOf(trail.headLines),
|
||||
]);
|
||||
if (Number.isFinite(height)) cart.height = height;
|
||||
const surface = C.toCartesian(cart);
|
||||
const q = mul(
|
||||
@@ -943,13 +1000,12 @@ export async function runTrailVisibility({
|
||||
});
|
||||
const bodyShow = trail.body?.show,
|
||||
headShow = trail.head?.show,
|
||||
headPrimitiveShow = trail.headPrimitive?.show,
|
||||
headLinesShow = trail.headLines?.show,
|
||||
backingShow = trail.backing?.show;
|
||||
let showTrail = false;
|
||||
const applyVisibility = () => {
|
||||
if (trail.body) trail.body.show = showTrail && bodyShow;
|
||||
if (trail.headPrimitive)
|
||||
trail.headPrimitive.show = showTrail && headPrimitiveShow;
|
||||
if (trail.headLines) trail.headLines.show = showTrail && headLinesShow;
|
||||
if (trail.head) trail.head.show = showTrail && headShow;
|
||||
if (trail.backing) trail.backing.show = showTrail && backingShow;
|
||||
};
|
||||
@@ -966,13 +1022,13 @@ export async function runTrailVisibility({
|
||||
const current = parts.trails.diagnostics();
|
||||
captureReady &&=
|
||||
ready() &&
|
||||
current?.body === trail.body &&
|
||||
current?.headPrimitive === trail.headPrimitive;
|
||||
current?.rebuilds === trail.rebuilds &&
|
||||
current?.headRebuilds === trail.headRebuilds;
|
||||
}
|
||||
} finally {
|
||||
removeVisibility();
|
||||
if (trail.body) trail.body.show = bodyShow;
|
||||
if (trail.headPrimitive) trail.headPrimitive.show = headPrimitiveShow;
|
||||
if (trail.headLines) trail.headLines.show = headLinesShow;
|
||||
if (trail.head) trail.head.show = headShow;
|
||||
if (trail.backing) trail.backing.show = backingShow;
|
||||
await frame();
|
||||
@@ -994,7 +1050,7 @@ export async function runTrailVisibility({
|
||||
tilesReady: captureReady,
|
||||
elapsedDisplayMs: entry.sample.displayT - setup.startDisplayT,
|
||||
movedMetres: Math.abs(entry.sample.lat - setup.startLat) * 111320,
|
||||
body: trail.body?.constructor.name,
|
||||
body: hostsOf(trail.body)[0]?.constructor.name,
|
||||
headStrategy: trail.headStrategy || 'PolylineCollection',
|
||||
headRebuilds: trail.headRebuilds ?? null,
|
||||
};
|
||||
@@ -1048,3 +1104,24 @@ export async function runTrailVisibility({
|
||||
.selection.clearSelection(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The transit frame probe over the bytes the renderer uploads for the
|
||||
* layer's marker sets (the Cesium renderer's upload probe), in the page.
|
||||
* @param {number} durationMs
|
||||
*/
|
||||
async function measureTransitFrames(durationMs) {
|
||||
const { countDrawSetUploads } =
|
||||
await import('/src/render/cesium/uploadProbe.js');
|
||||
const app = window.__godsEyeView;
|
||||
const layer = app.dataManager.layers.get('transit').module;
|
||||
const uploads = countDrawSetUploads(
|
||||
app.viewer,
|
||||
layer._transitSetIdsForTest(),
|
||||
);
|
||||
try {
|
||||
return await layer._measureTransitFramesForTest(durationMs, uploads);
|
||||
} finally {
|
||||
uploads.stop();
|
||||
}
|
||||
}
|
||||
+48
-20
@@ -98,7 +98,7 @@ const renderingSource = await readFile(
|
||||
);
|
||||
const frameSource = renderingSource
|
||||
.split('function onPreRender()')[1]
|
||||
.split('const occluder')[0];
|
||||
.split('const candidatePosition')[0];
|
||||
check(
|
||||
'frame pass does not scan the fleet or copy the moving set',
|
||||
!/_vehicles\.values|\[\.\.\.state\._moving\]/.test(frameSource),
|
||||
@@ -815,25 +815,38 @@ try {
|
||||
const layer =
|
||||
window.__godsEyeView.dataManager.layers.get('transit').module;
|
||||
const state = layer._transitStateForTest();
|
||||
const entry = state._vehicles.get(key);
|
||||
const scene = window.__godsEyeView.viewer.scene;
|
||||
// The billboard the draw port drew for it, and the set drawing it.
|
||||
const setIds = layer._transitSetIdsForTest();
|
||||
let billboard = null,
|
||||
setId = null;
|
||||
for (let i = 0; !billboard && i < scene.primitives.length; i++) {
|
||||
const host = scene.primitives.get(i);
|
||||
if (!setIds.includes(host?.drawSetId)) continue;
|
||||
for (let j = 0; j < host.length; j++)
|
||||
if (host.get(j)?.id?.id === key) {
|
||||
billboard = host.get(j);
|
||||
setId = host.drawSetId;
|
||||
}
|
||||
}
|
||||
const set = layer._transitPartsForTest().rendering.setNameOf(setId);
|
||||
return {
|
||||
selected: state._selectedKey === key,
|
||||
color: entry?.marker.color.toCssColorString(),
|
||||
width: entry?.marker.width,
|
||||
color: billboard?.color.toCssColorString(),
|
||||
width: billboard?.width,
|
||||
pickOwner: (() => {
|
||||
const p = window.__godsEyeView.viewer.scene.pick(
|
||||
entry.marker.computeScreenSpacePosition(
|
||||
window.__godsEyeView.viewer.scene,
|
||||
),
|
||||
);
|
||||
const p = billboard
|
||||
? scene.pick(billboard.computeScreenSpacePosition(scene))
|
||||
: null;
|
||||
return {
|
||||
id: typeof p?.id === 'string' ? p.id : null,
|
||||
primitiveId:
|
||||
typeof p?.primitive?.id === 'string' ? p.primitive.id : null,
|
||||
id: typeof p?.id?.id === 'string' ? p.id.id : null,
|
||||
set: typeof p?.id?.set === 'string' ? p.id.set : null,
|
||||
collection:
|
||||
entry.markerCollection === state._animatedMarkers
|
||||
set === 'moving'
|
||||
? 'animated'
|
||||
: 'stationary',
|
||||
: set === 'still'
|
||||
? 'stationary'
|
||||
: null,
|
||||
};
|
||||
})(),
|
||||
};
|
||||
@@ -1596,7 +1609,8 @@ try {
|
||||
key: entry.key,
|
||||
x,
|
||||
y,
|
||||
pickKey: picked?.id ?? picked?.primitive?.id ?? null,
|
||||
// A draw-port pick carries {set, id, meta}; the vehicle is its id.
|
||||
pickKey: picked?.id?.id ?? picked?.id ?? picked?.primitive?.id ?? null,
|
||||
};
|
||||
});
|
||||
let anchor = null;
|
||||
@@ -1849,19 +1863,33 @@ try {
|
||||
await page.$eval(row, (element) =>
|
||||
element.scrollIntoView({ block: 'center' }),
|
||||
);
|
||||
// The marker sets drawn while on, to look for after disable.
|
||||
const markerSets = await page.evaluate(() =>
|
||||
window.__godsEyeView.dataManager.layers
|
||||
.get('transit')
|
||||
.module._transitSetIdsForTest(),
|
||||
);
|
||||
await page.click(`${row} .data-toggle-btn`);
|
||||
await page.waitForFunction(
|
||||
() => !window.__godsEyeView.dataManager.isEnabled('transit'),
|
||||
{ timeout: 20_000 },
|
||||
);
|
||||
const afterDisable = transitRequests.length;
|
||||
const teardown = await page.evaluate(() => {
|
||||
const teardown = await page.evaluate((setIds) => {
|
||||
const layer = window.__godsEyeView.dataManager.layers.get('transit').module;
|
||||
const state = layer._transitStateForTest();
|
||||
return {
|
||||
vehicles: state._vehicles.size,
|
||||
primitives:
|
||||
(state._markers?.length || 0) + (state._animatedMarkers?.length || 0),
|
||||
// Billboards still drawn in the sets drawn while on.
|
||||
primitives: (() => {
|
||||
const scene = window.__godsEyeView.viewer.scene;
|
||||
let count = 0;
|
||||
for (let i = 0; i < scene.primitives.length; i++) {
|
||||
const host = scene.primitives.get(i);
|
||||
if (setIds.includes(host?.drawSetId)) count += host.length || 0;
|
||||
}
|
||||
return count;
|
||||
})(),
|
||||
visible: state._visible.size,
|
||||
moving: state._moving.size,
|
||||
detect: state._detectCache,
|
||||
@@ -1873,12 +1901,12 @@ try {
|
||||
],
|
||||
trailPending: layer._transitPartsForTest().trails.requestDiagnostics()
|
||||
.pending,
|
||||
shown: state._markers ? state._markers.show : null,
|
||||
shown: state._markersShown ?? null,
|
||||
inFlight: state._inFlight.size,
|
||||
activeFeeds: state._activeFeeds.size,
|
||||
holds: window.__godsEyeView.getRenderGovernorDiagnostics().holds,
|
||||
};
|
||||
});
|
||||
}, markerSets);
|
||||
check(
|
||||
'disable leaves no vehicles and no point primitives',
|
||||
teardown.vehicles === 0 &&
|
||||
|
||||
@@ -169,7 +169,7 @@ try {
|
||||
result.bloom.intensityPct === 98 &&
|
||||
snapshot.bloom.intensity === 98 &&
|
||||
manager._visualEffects.bloomIntensity === 98 &&
|
||||
manager._bloomStage.enabled
|
||||
window.__godsEyeView.viewer.scene.postProcessStages.bloom.enabled
|
||||
);
|
||||
}),
|
||||
);
|
||||
@@ -183,7 +183,11 @@ try {
|
||||
result.sharpen.intensityPct === 61 &&
|
||||
manager.getVisualState().sharpen.intensity === 61 &&
|
||||
manager._visualEffects.sharpenIntensity === 0.61 &&
|
||||
Math.abs(manager._sharpenStage.uniforms.amount - 1.32) < 1e-9
|
||||
Math.abs(
|
||||
window.__godsEyeView.viewer.scene.postProcessStages.getStageByName(
|
||||
'effects_sharpen',
|
||||
).uniforms.amount - 1.32,
|
||||
) < 1e-9
|
||||
);
|
||||
}),
|
||||
);
|
||||
@@ -199,9 +203,10 @@ try {
|
||||
const manager = window.__godsEyeView.styleManager;
|
||||
const effects = manager._visualEffects;
|
||||
manager.setStyle('retro');
|
||||
const owned = [...Object.values(effects.stages), effects.sharpenStage];
|
||||
const collection = manager.viewer.scene.postProcessStages;
|
||||
const previousBloom = effects.previousBloom;
|
||||
const collection = window.__godsEyeView.viewer.scene.postProcessStages;
|
||||
const owned = Object.keys(effects.stages).map((name) =>
|
||||
collection.getStageByName(`effects_style_${name}`),
|
||||
);
|
||||
const pending = manager.dispose();
|
||||
const stoppedBeforeAwait =
|
||||
effects.stopped &&
|
||||
@@ -210,12 +215,15 @@ try {
|
||||
await pending;
|
||||
return {
|
||||
stoppedBeforeAwait,
|
||||
removed: owned.every((stage) => !collection.contains(stage)),
|
||||
restored:
|
||||
effects.bloomStage.enabled === previousBloom.enabled &&
|
||||
Object.entries(previousBloom.uniforms).every(
|
||||
([name, value]) => effects.bloomStage.uniforms[name] === value,
|
||||
removed:
|
||||
owned.every(Boolean) &&
|
||||
Object.keys(effects.stages).every(
|
||||
(name) => !collection.getStageByName(`effects_style_${name}`),
|
||||
),
|
||||
// The renderer gives the scene's bloom back when it goes.
|
||||
restored:
|
||||
!collection.bloom.enabled &&
|
||||
!collection.getStageByName('effects_sharpen')?.enabled,
|
||||
};
|
||||
});
|
||||
check(
|
||||
@@ -223,7 +231,7 @@ try {
|
||||
teardown.stoppedBeforeAwait,
|
||||
);
|
||||
check(
|
||||
'UI teardown removes owned stages and restores borrowed bloom',
|
||||
'UI teardown removes its styles and turns bloom and sharpen off',
|
||||
teardown.removed && teardown.restored,
|
||||
);
|
||||
check(
|
||||
|
||||
@@ -150,7 +150,9 @@ try {
|
||||
manager._bloomSlider.focus();
|
||||
return {
|
||||
value: Number(manager._bloomSlider.value),
|
||||
contrast: manager._bloomStage.uniforms.contrast,
|
||||
contrast:
|
||||
window.__godsEyeView.viewer.scene.postProcessStages.bloom.uniforms
|
||||
.contrast,
|
||||
};
|
||||
});
|
||||
await page.keyboard.press('ArrowRight');
|
||||
@@ -160,7 +162,8 @@ try {
|
||||
const manager = window.__godsEyeView.styleManager;
|
||||
return (
|
||||
Number(manager._bloomSlider.value) > before.value &&
|
||||
manager._bloomStage.uniforms.contrast < before.contrast
|
||||
window.__godsEyeView.viewer.scene.postProcessStages.bloom.uniforms
|
||||
.contrast < before.contrast
|
||||
);
|
||||
}, displayBefore),
|
||||
);
|
||||
@@ -267,13 +270,16 @@ try {
|
||||
const manager = window.__godsEyeView.styleManager;
|
||||
manager._displayBindings._detachDisplayControls();
|
||||
const before = manager.bloomEnabled;
|
||||
const contrast = manager._bloomStage.uniforms.contrast;
|
||||
const contrast =
|
||||
window.__godsEyeView.viewer.scene.postProcessStages.bloom.uniforms
|
||||
.contrast;
|
||||
manager._bloomBtn.click();
|
||||
manager._bloomSlider.value = '15';
|
||||
manager._bloomSlider.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
return (
|
||||
manager.bloomEnabled === before &&
|
||||
manager._bloomStage.uniforms.contrast === contrast
|
||||
window.__godsEyeView.viewer.scene.postProcessStages.bloom.uniforms
|
||||
.contrast === contrast
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -36,7 +36,8 @@ try {
|
||||
);
|
||||
const renderer = await page.evaluate(async () => {
|
||||
const C = await import('/node_modules/cesium/Build/Cesium/index.js');
|
||||
const { maxPitchForHeight } = await import('/src/app/zoomOutGuard.js');
|
||||
const { maxPitchForHeight } =
|
||||
await import('/src/render/cesium/zoomOutGuard.js');
|
||||
const { readCameraTargetFrame } =
|
||||
await import('/src/ui/cameraOrientationControls.js');
|
||||
const viewer = window.__godsEyeView.viewer;
|
||||
@@ -86,7 +87,7 @@ try {
|
||||
};
|
||||
viewer.camera.setView = (options) => {
|
||||
// Cesium itself also calls setView while processing touch movement.
|
||||
if (new Error().stack.includes('/src/app/zoomOutGuard.js'))
|
||||
if (new Error().stack.includes('/src/render/cesium/zoomOutGuard.js'))
|
||||
qa.guardWrites++;
|
||||
return original(options);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env node
|
||||
// Writes the reference camera traces the conformance suite compares a
|
||||
// renderer against: src/render/conformance/goldens/camera.json. Run it after
|
||||
// a Cesium upgrade or a change to the camera scripts, and review the diff.
|
||||
//
|
||||
// node scripts/record-camera-goldens.mjs [--check]
|
||||
//
|
||||
// With --check it writes nothing and exits 1 when the file is out of date.
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { recordCameraGoldens } from '../src/render/cesium/cameraGoldens.js';
|
||||
|
||||
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const OUT = path.join(ROOT, 'src/render/conformance/goldens/camera.json');
|
||||
|
||||
const text = `${JSON.stringify(await recordCameraGoldens(), null, 2)}\n`;
|
||||
if (process.argv.includes('--check')) {
|
||||
const current = fs.existsSync(OUT) ? fs.readFileSync(OUT, 'utf8') : '';
|
||||
if (current !== text) {
|
||||
console.error(`${path.relative(ROOT, OUT)} is out of date`);
|
||||
process.exit(1);
|
||||
}
|
||||
} else {
|
||||
fs.mkdirSync(path.dirname(OUT), { recursive: true });
|
||||
fs.writeFileSync(OUT, text);
|
||||
console.log(`wrote ${path.relative(ROOT, OUT)}`);
|
||||
}
|
||||
+368
-223
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* Lower `src/render/viewerAccessAllowList.json` to the Cesium-shaped viewer
|
||||
* accesses the files off the Cesium list still hold
|
||||
* (`src/render/viewerAccess.test.mjs`). It only lowers counts and drops
|
||||
* entries (files with none left, gone, or back on the Cesium list); it never
|
||||
* adds a file or raises a count. A file over its count is reported and the
|
||||
* script exits 1: port that access instead.
|
||||
*
|
||||
* `--check` reports what it would change without writing, and exits 1 when
|
||||
* there is anything to lower.
|
||||
*/
|
||||
import { writeFileSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import {
|
||||
BASELINE,
|
||||
countedFiles,
|
||||
currentHits,
|
||||
readBaseline,
|
||||
ROOT,
|
||||
} from '../src/testSupport/viewerAccess.mjs';
|
||||
|
||||
const check = process.argv.includes('--check');
|
||||
const baseline = readBaseline();
|
||||
const hits = currentHits();
|
||||
const counted = new Set(countedFiles());
|
||||
|
||||
const next = {};
|
||||
const changes = [];
|
||||
for (const [file, allowed] of Object.entries(baseline)) {
|
||||
const found = counted.has(file) ? (hits.get(file)?.length ?? 0) : 0;
|
||||
const count = Math.min(allowed, found);
|
||||
if (count > 0) next[file] = count;
|
||||
if (count !== allowed) changes.push(`${file}: ${allowed} → ${count}`);
|
||||
}
|
||||
const over = [...hits]
|
||||
.filter(([file, found]) => found.length > (baseline[file] ?? 0))
|
||||
.map(
|
||||
([file, found]) =>
|
||||
`${file}: ${found.length} found, ${baseline[file] ?? 0} recorded`,
|
||||
);
|
||||
|
||||
if (changes.length) {
|
||||
console.log(
|
||||
`${check ? 'Would lower' : 'Lowered'}:\n ${changes.join('\n ')}`,
|
||||
);
|
||||
if (!check) {
|
||||
const sorted = Object.fromEntries(
|
||||
Object.keys(next)
|
||||
.sort()
|
||||
.map((file) => [file, next[file]]),
|
||||
);
|
||||
writeFileSync(
|
||||
path.join(ROOT, BASELINE),
|
||||
`${JSON.stringify(sorted, null, 2)}\n`,
|
||||
);
|
||||
} else process.exitCode = 1;
|
||||
} else console.log(`${BASELINE} is as low as it goes.`);
|
||||
if (over.length) {
|
||||
console.error(
|
||||
`Over their counts (never raised; port these):\n ${over.join('\n ')}`,
|
||||
);
|
||||
process.exitCode = 1;
|
||||
}
|
||||
Reference in new issue
Block a user