mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 18:22:25 +00:00
test(dams): run the Acaray and Yacyretá layer check on main's test doubles
The separate layer test built a fake viewer with the old Cesium interface, which fails on current main. Move it into src/data/infrastructure.test.mjs on the fake ground renderer and input port, with one table and one parse of dams.geojsonl for both checks. Compare source_url exactly and check retrieved_at, and cover the dams attribution and both new records in the find_infrastructure tests. Also trim the dataset README section (keep both dams as polygons), drop the outdated "does not refresh or relicense" sentence, keep provenance out of the License cell, rename the changelog fragment after the change, and restore the accent in the test name.
This commit is contained in:
1 parent
17b75e8896
commit
fa4b4adeae
8 files changed
+87
-137
No files matched your search
+1
-1
@@ -411,7 +411,7 @@ The [Bhote Koshi event pack](public/events/bhote-koshi-2026/README.md), under `p
|
||||
| Dataset | Folder | License | Commercial use? | Attribution |
|
||||
| --------------------------------------------------------------------------- | --------------------------------- | --------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | --------------------------------------------------------------------------- |
|
||||
| **Datacenters** (4,352) | `datacenters/` | **ODbL 1.0** (OpenStreetMap extract) | ✅ (attribution + share-alike on data) | © OpenStreetMap contributors (shared credit) |
|
||||
| **Dams** (706) | `dams/` | **ODbL 1.0** (OpenInfraMap / OSM extract; Acaray and Yacyretá supplemented from the OSM API) | ✅ (attribution + share-alike on data) | © OpenStreetMap contributors (shared credit) + Open Infrastructure Map |
|
||||
| **Dams** (706) | `dams/` | **ODbL 1.0** (OpenInfraMap / OSM extract + OSM API) | ✅ (attribution + share-alike on data) | © OpenStreetMap contributors (shared credit) + Open Infrastructure Map |
|
||||
| **Military area names** (36,466) | `osm_military_names/` | **ODbL 1.0** (OpenStreetMap, via Overture Maps) | ✅ (attribution + share-alike on data) | © OpenStreetMap contributors (shared credit) + Overture Maps Foundation |
|
||||
| **Ukraine outline** (Rail layer no-positions rule; 1 ring, 7,801 points) | `src/data/railNoPositions.js` | **ODbL 1.0** (OpenStreetMap, via geoBoundaries gbOpen UKR ADM0, commit 9469f09; simplified to 0.0005°) | ✅ (attribution + share-alike on data) | © OpenStreetMap contributors (shared credit) + geoBoundaries |
|
||||
| **Québec CCTV source catalog** (1,120 locations) | `public/quebec-cameras.json` | Mixed: MTQ locations CC BY 4.0; Montréal camera nodes ODbL 1.0; scenic records retain per-record provenance. No video files are bundled or cached. | Location data is per-record; video remains hosted by Québec 511 and its platform terms apply; scenic source pages may have separate terms | MTQ / Données Québec CC BY 4.0; © OpenStreetMap contributors (ODbL); scenic operator and position source shown in the selected-camera panel |
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
- Add the Acaray and Yacyretá dams from OpenStreetMap to the Dams layer, and
|
||||
credit the layer to OpenStreetMap / OpenInfraMap instead of USACE (radianx,
|
||||
#1152).
|
||||
@@ -1,3 +0,0 @@
|
||||
- Add Acaray and Yacyretá dam geometries from OpenStreetMap to the existing Dams
|
||||
layer, with source provenance and a corrected OpenStreetMap source label
|
||||
(radianx, #1152).
|
||||
@@ -85,4 +85,4 @@ globals.
|
||||
Dataset files and source/license notices remain under `src/data/local_data/`.
|
||||
Their input counts are 4,352 datacenter features and 706 dam features. A multipart
|
||||
geometry draws as several parts, each with its own stem; part and stem counts are
|
||||
different measurements from feature counts. This change does not refresh or relicense the datasets.
|
||||
different measurements from feature counts.
|
||||
@@ -1,101 +0,0 @@
|
||||
// Regression: both dams added by #1152 must reach the Dams layer itself —
|
||||
// a stem/label (selection context) and a voice analyst record — not only
|
||||
// the find_infrastructure query source.
|
||||
// Place at src/data/damsParaguayLayer.test.mjs and run:
|
||||
// node --test src/data/damsParaguayLayer.test.mjs
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import * as Cesium from 'cesium';
|
||||
import { localGeoJsonServices } from '../app/localGeojsonServices.js';
|
||||
import { createLocalGeoJsonLayer } from './localGeojsonCore.js';
|
||||
|
||||
const ADDED = new Map([
|
||||
[262532166, 'Acaray'],
|
||||
[-5671745, 'Represa Yacyretá-Apipé'],
|
||||
]);
|
||||
|
||||
const features = readFileSync(
|
||||
new URL('./local_data/dams/dams.geojsonl', import.meta.url),
|
||||
'utf8',
|
||||
)
|
||||
.trim()
|
||||
.split('\n')
|
||||
.map((line) => JSON.parse(line))
|
||||
.filter((feature) => ADDED.has(feature.id));
|
||||
|
||||
const quietEvent = () => ({ addEventListener: () => () => {} });
|
||||
|
||||
test('Acaray and Yacyretá each get a layer stem, selection context and analyst record', async () => {
|
||||
assert.equal(features.length, 2, 'both added features are bundled');
|
||||
const originalFetch = globalThis.fetch;
|
||||
const originalWindow = globalThis.window;
|
||||
globalThis.window = { dispatchEvent() {} };
|
||||
globalThis.fetch = async () => ({
|
||||
ok: true,
|
||||
status: 200,
|
||||
text: async () => features.map((f) => JSON.stringify(f)).join('\n'),
|
||||
});
|
||||
const contexts = [];
|
||||
const overlayHost = { setVisible() {}, setEntries() {}, clearSource() {} };
|
||||
const viewer = {
|
||||
selectedEntity: undefined,
|
||||
dataSources: { add: (dataSource) => dataSource, remove: () => true },
|
||||
camera: {
|
||||
positionWC: Cesium.Cartesian3.fromDegrees(-55.5, -26.5, 900_000),
|
||||
frustum: { fov: Math.PI / 3 },
|
||||
moveEnd: quietEvent(),
|
||||
flyTo() {},
|
||||
},
|
||||
scene: {
|
||||
canvas: { clientWidth: 800, clientHeight: 600 },
|
||||
preRender: quietEvent(),
|
||||
sampleHeightSupported: false,
|
||||
sampleHeight: () => undefined,
|
||||
screenSpaceCameraController: { enableInputs: true },
|
||||
pick: () => null,
|
||||
requestRender() {},
|
||||
},
|
||||
};
|
||||
const layer = createLocalGeoJsonLayer(
|
||||
{
|
||||
id: 'local-dams',
|
||||
url: '/dams.geojsonl',
|
||||
name: 'Dams',
|
||||
color: '#0088ff',
|
||||
projectToWindow: () => ({ x: 400, y: 300 }),
|
||||
screenSpaceEventHandlerFactory: () => ({
|
||||
setInputAction() {},
|
||||
destroy() {},
|
||||
}),
|
||||
},
|
||||
{
|
||||
...localGeoJsonServices,
|
||||
overlayHost,
|
||||
registerEntityContext: (entity, context) => contexts.push(context),
|
||||
},
|
||||
);
|
||||
try {
|
||||
await layer.enable(viewer);
|
||||
assert.equal(layer.getStats().count, 2);
|
||||
const expected = [...ADDED.values()].sort();
|
||||
assert.deepEqual(
|
||||
contexts.map((context) => context.label).sort(),
|
||||
expected,
|
||||
'each added dam registers a selection context (stem, label, card)',
|
||||
);
|
||||
const rows = layer.getAnalystRecords();
|
||||
assert.deepEqual(
|
||||
rows.map((row) => row.name).sort(),
|
||||
expected,
|
||||
'each added dam is visible to voice analyst_query',
|
||||
);
|
||||
for (const row of rows)
|
||||
assert.ok(Number.isFinite(row.lat) && Number.isFinite(row.lon));
|
||||
} finally {
|
||||
layer.destroy(viewer);
|
||||
globalThis.fetch = originalFetch;
|
||||
if (originalWindow === undefined) delete globalThis.window;
|
||||
else globalThis.window = originalWindow;
|
||||
}
|
||||
});
|
||||
@@ -6,6 +6,7 @@ import { createInfrastructureLayers } from 'gods-eye-view/infrastructure';
|
||||
import { createLocalGeoJsonLayer } from 'gods-eye-view/infrastructure/geojson';
|
||||
import { fakeInput } from '../input/testDoubles.mjs';
|
||||
import { bindFakeGroundRenderer } from '../testSupport/fakeGroundRenderer.mjs';
|
||||
import { parseGeojsonLines } from '../sources/infrastructureData.js';
|
||||
|
||||
function services() {
|
||||
const records = new Map();
|
||||
@@ -34,6 +35,20 @@ function services() {
|
||||
};
|
||||
}
|
||||
|
||||
// Added from the OSM API, not the OpenInfraMap extract: [id, name, OSM
|
||||
// object, version]. Both must stay polygons: the Dams layer skips
|
||||
// LineStrings.
|
||||
const OSM_API_DAMS = [
|
||||
[262532166, 'Acaray', 'way/262532166', 7],
|
||||
[-5671745, 'Represa Yacyretá-Apipé', 'relation/5671745', 2],
|
||||
];
|
||||
const DAMS = parseGeojsonLines(
|
||||
readFileSync(
|
||||
new URL('./local_data/dams/dams.geojsonl', import.meta.url),
|
||||
'utf8',
|
||||
),
|
||||
);
|
||||
|
||||
test('package exports import without an application, DOM, fetch, or timers', () => {
|
||||
const result = spawnSync(
|
||||
process.execPath,
|
||||
@@ -100,29 +115,64 @@ test('dataset URLs still name the complete bundled sources', () => {
|
||||
}
|
||||
});
|
||||
|
||||
test('Acaray and Yacyreta retain unique OSM records in the current GeoJSONL bundle', () => {
|
||||
const folder = new URL('./local_data/dams/', import.meta.url);
|
||||
const lines = readFileSync(new URL('dams.geojsonl', folder), 'utf8')
|
||||
.trim()
|
||||
.split('\n')
|
||||
.map(JSON.parse);
|
||||
for (const [id, name, version] of [
|
||||
[262532166, 'Acaray', 7],
|
||||
[-5671745, 'Represa Yacyretá-Apipé', 2],
|
||||
]) {
|
||||
const matches = lines.filter((feature) => feature.id === id);
|
||||
test('Acaray and Yacyretá appear once each with OSM provenance', () => {
|
||||
for (const [id, name, object, version] of OSM_API_DAMS) {
|
||||
const matches = DAMS.filter((feature) => feature.id === id);
|
||||
assert.equal(matches.length, 1);
|
||||
assert.equal(matches[0].properties.name, name);
|
||||
assert.equal(matches[0].properties.source_version, version);
|
||||
assert.equal(matches[0].properties.osm_id, id);
|
||||
assert.match(
|
||||
matches[0].properties.source_url,
|
||||
/^https:\/\/www.openstreetmap.org\//,
|
||||
const { properties } = matches[0];
|
||||
assert.equal(properties.name, name);
|
||||
assert.equal(properties.osm_id, id);
|
||||
assert.equal(properties.source_version, version);
|
||||
assert.equal(
|
||||
properties.source_url,
|
||||
`https://www.openstreetmap.org/${object}`,
|
||||
);
|
||||
assert.ok(Array.isArray(matches[0].geometry.coordinates));
|
||||
assert.equal(properties.retrieved_at, '2026-10-15');
|
||||
}
|
||||
});
|
||||
|
||||
test('Acaray and Yacyretá each get a stem, a selection context and an analyst record', async (t) => {
|
||||
const added = DAMS.filter((feature) =>
|
||||
OSM_API_DAMS.some(([id]) => id === feature.id),
|
||||
);
|
||||
t.mock.method(globalThis, 'fetch', async () => ({
|
||||
ok: true,
|
||||
text: async () =>
|
||||
added.map((feature) => JSON.stringify(feature)).join('\n'),
|
||||
}));
|
||||
const host = services();
|
||||
const layer = createLocalGeoJsonLayer(
|
||||
{
|
||||
id: 'local-dams',
|
||||
name: 'Dams',
|
||||
osmDerived: true,
|
||||
color: '#0088ff',
|
||||
url: '/dams.geojsonl',
|
||||
},
|
||||
host,
|
||||
);
|
||||
const viewer = {
|
||||
scene: { screenSpaceCameraController: { enableInputs: true } },
|
||||
};
|
||||
const fake = bindFakeGroundRenderer(viewer);
|
||||
fakeInput(viewer);
|
||||
t.after(() => layer.destroy(viewer));
|
||||
await layer.enable(viewer);
|
||||
const names = OSM_API_DAMS.map(([, name]) => name).sort();
|
||||
assert.equal(fake.set('stems').items.size, 2, 'both dams get a stem');
|
||||
assert.deepEqual(
|
||||
[...host.records.values()].map((record) => record.label).sort(),
|
||||
names,
|
||||
);
|
||||
assert.deepEqual(
|
||||
layer
|
||||
.getAnalystRecords()
|
||||
.map((record) => record.name)
|
||||
.sort(),
|
||||
names,
|
||||
);
|
||||
});
|
||||
|
||||
test('two viewers use their supplied contexts and dispose independently', async (t) => {
|
||||
t.mock.method(globalThis, 'fetch', async () => ({
|
||||
ok: true,
|
||||
|
||||
@@ -16,20 +16,15 @@ The public-release snapshot removes contact-oriented fields and note values
|
||||
that contain email or phone identifiers. The runtime layer does not display or
|
||||
depend on those fields.
|
||||
|
||||
## OSM API additions
|
||||
|
||||
## Paraguay additions (2026-10-15)
|
||||
Two dams come from the public OpenStreetMap API rather than the extract:
|
||||
|
||||
The existing extract is supplemented with two OpenStreetMap features fetched
|
||||
through the public OSM API, under the same ODbL 1.0 license:
|
||||
- Acaray: [way 262532166](https://www.openstreetmap.org/way/262532166), its closed outline of nine nodes.
|
||||
- Represa Yacyretá-Apipé: [relation 5671745](https://www.openstreetmap.org/relation/5671745), its eight outer ways joined into one closed outline.
|
||||
|
||||
- Acaray: [way 262532166](https://www.openstreetmap.org/way/262532166), original closed dam outline, stored as a polygon from the way's nine nodes.
|
||||
- Represa Yacyretá-Apipé: [relation 5671745](https://www.openstreetmap.org/relation/5671745), original dam outline. Its eight outer ways are joined by shared node IDs into one closed polygon; no reservoir or duplicate power-plant footprint is added.
|
||||
Both are under the same ODbL 1.0; the relation keeps the extract's negative ID (-5671745).
|
||||
Keep both as polygons: the Dams layer skips LineStrings.
|
||||
|
||||
Each feature preserves the OSM name/tags and records its source URL, parent
|
||||
object version and retrieval date. Relation IDs retain the extract's negative-ID
|
||||
convention. Node metadata and contributor identifiers are not bundled. This is
|
||||
a static map inventory, not live generation, reservoir level or dam status.
|
||||
|
||||
The layer places a polygon's marker and label at the centre of its bounding
|
||||
sphere. The Yacyretá outline is L-shaped, so its marker sits about 1.6 km from
|
||||
the outline, over the reservoir.
|
||||
The layer puts a polygon's marker at the centre of its bounding sphere. The Yacyretá outline is L-shaped, so its
|
||||
marker sits about 1.6 km from the outline, over the reservoir.
|
||||
@@ -119,6 +119,10 @@ test('datacenters and dams are listed nearest first with their own fields', asyn
|
||||
lon: -114.737,
|
||||
distance_km: 3.8,
|
||||
});
|
||||
assert.equal(
|
||||
dams.data.attribution,
|
||||
'© OpenStreetMap contributors (ODbL 1.0) + Open Infrastructure Map',
|
||||
);
|
||||
});
|
||||
|
||||
test('the bundled datasets load through the local fetch', async () => {
|
||||
@@ -135,6 +139,8 @@ test('the bundled datasets load through the local fetch', async () => {
|
||||
(record) => Number.isFinite(record.lat) && Number.isFinite(record.lon),
|
||||
),
|
||||
);
|
||||
for (const name of ['Acaray', 'Represa Yacyretá-Apipé'])
|
||||
assert.equal(dams.filter((record) => record.name === name).length, 1, name);
|
||||
assert.equal(await source.getRecords('local-dams'), dams);
|
||||
await assert.rejects(
|
||||
source.getRecords('local-other'),
|
||||
|
||||
Reference in new issue
Block a user