mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 19:04:02 +00:00
fix(outlines): harden shared cache and provider lifecycle
This commit is contained in:
1 parent
9559e7a282
commit
177b5951a0
27 files changed
+3363
-248
No files matched your search
@@ -21,8 +21,13 @@ import { createReferenceSources } from '../sources/reference.js';
|
||||
export { createReferenceSources as createStandaloneReferenceSources } from '../sources/reference.js';
|
||||
|
||||
/** Select standalone providers without starting their acquisition. */
|
||||
export function createStandaloneLayerSources() {
|
||||
const mapTiles = createOpenFreeMapSource();
|
||||
export function createStandaloneLayerSources({
|
||||
createMapTiles = createOpenFreeMapSource,
|
||||
} = {}) {
|
||||
// Each subsystem owns its own request lifetime and local result cache. The
|
||||
// sources still share the bounded decoded-tile owner inside OpenFreeMap.
|
||||
const trafficTiles = createMapTiles();
|
||||
const installationTiles = createMapTiles();
|
||||
return {
|
||||
...createReferenceSources(),
|
||||
flights: createOpenSkySource(),
|
||||
@@ -32,10 +37,10 @@ export function createStandaloneLayerSources() {
|
||||
}),
|
||||
cctv: createCctvSource(),
|
||||
radio: createRadioSource(),
|
||||
traffic: createTrafficSource({ mapTiles }),
|
||||
traffic: createTrafficSource({ mapTiles: trafficTiles }),
|
||||
transit: createTransitSource(),
|
||||
bikeshare: createBikeshareSource(),
|
||||
installations: createInstallationSource({ mapTiles }),
|
||||
installations: createInstallationSource({ mapTiles: installationTiles }),
|
||||
satellites: createSatelliteSource(),
|
||||
launches: createLaunchSource(),
|
||||
alpr: createAlprTileSource(),
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createStandaloneLayerSources } from './layerSources.js';
|
||||
|
||||
test('traffic and installations own separate local OpenFreeMap lifetimes', () => {
|
||||
const mapTiles = [];
|
||||
const sources = createStandaloneLayerSources({
|
||||
createMapTiles() {
|
||||
const source = {
|
||||
clears: 0,
|
||||
clear() {
|
||||
this.clears++;
|
||||
},
|
||||
getMetadata: async () => ({
|
||||
template: 'https://tiles.openfreemap.org/planet/test/{z}/{x}/{y}.pbf',
|
||||
}),
|
||||
fetchBounds: async () => ({ tiles: [], loadedTiles: [] }),
|
||||
};
|
||||
mapTiles.push(source);
|
||||
return source;
|
||||
},
|
||||
});
|
||||
|
||||
assert.equal(mapTiles.length, 2);
|
||||
assert.notEqual(mapTiles[0], mapTiles[1]);
|
||||
sources.traffic.resetFlowTileCache();
|
||||
assert.deepEqual(
|
||||
mapTiles.map((source) => source.clears),
|
||||
[1, 0],
|
||||
'traffic reset cannot clear installation work',
|
||||
);
|
||||
sources.installations.destroy();
|
||||
assert.deepEqual(
|
||||
mapTiles.map((source) => source.clears),
|
||||
[1, 1],
|
||||
'installation destroy cannot clear traffic work',
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user