mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 02:44:02 +00:00
refactor: separate map feature queries and source records
This commit is contained in:
1 parent
a8125ad917
commit
bf1d50f29b
28 files changed
+1128
-675
No files matched your search
@@ -1,3 +1,13 @@
|
||||
import { normalizeMilitaryInstallations } from '../../data/militaryInstallationData.js';
|
||||
|
||||
/** Preserve legacy cache admission even when the explicit saturation flag is absent. */
|
||||
export function installationResponseSaturated(payload) {
|
||||
if (typeof payload?.saturated === 'boolean') return payload.saturated;
|
||||
const cap = Number(payload?.elementCap);
|
||||
if (!Number.isFinite(cap) || cap <= 0) return false;
|
||||
return Array.isArray(payload?.elements) && payload.elements.length >= cap;
|
||||
}
|
||||
|
||||
/** Read mapped installations and explicit nearby-place searches through fixed endpoints. */
|
||||
export function createInstallationSource({
|
||||
fetchImpl = (...args) => globalThis.fetch(...args),
|
||||
@@ -43,7 +53,14 @@ export function createInstallationSource({
|
||||
);
|
||||
if (!Array.isArray(body?.elements))
|
||||
throw new Error('Malformed installation snapshot');
|
||||
return body;
|
||||
return {
|
||||
...normalizeMilitaryInstallations(
|
||||
body,
|
||||
body.retrievedAt || new Date().toISOString(),
|
||||
),
|
||||
status: body.status,
|
||||
saturated: installationResponseSaturated(body),
|
||||
};
|
||||
},
|
||||
async searchNearby({ latitude, longitude, radiusM }, { signal } = {}) {
|
||||
if (
|
||||
|
||||
Reference in new issue
Block a user