mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Traffic roads come from OpenFreeMap vector tiles, or TomTom flow tiles with a key (Hybrid by default). Military areas use OpenFreeMap polygons with a bundled worldwide name index; wide views show named points. ALPR reads an hourly OpenStreetMap extract. Cockpit place context and country, state and US county outlines use bundled Natural Earth and US Census data. Overpass is used only when an operator configures their own endpoint. Also: camera arrivals no longer land below ground, keyless terrain retries on 429, bounded relation geometry for configured Overpass, one shared OpenStreetMap credit, and separate tile and API transports for embedders. Co-authored-by: theGaryLarson <[email protected]> Co-authored-by: Milan Khanal <[email protected]>
44 lines
1.4 KiB
JavaScript
44 lines
1.4 KiB
JavaScript
import { PbfReader } from 'pbf';
|
|
import { VectorTile } from '@mapbox/vector-tile';
|
|
import { normalizeAlprNode } from './records.js';
|
|
|
|
/** Map extract attributes without treating an OSM edit date as a field verification. */
|
|
export function normalizeAlprTileFeature(feature) {
|
|
const p = feature?.properties || {};
|
|
if (feature?.geometry?.type !== 'Point' || p.osmType !== 'node') return null;
|
|
const [lon, lat] = feature.geometry.coordinates;
|
|
const record = normalizeAlprNode({
|
|
type: 'node',
|
|
id: Number(p.osmId),
|
|
lat,
|
|
lon,
|
|
tags: {
|
|
'surveillance:type': 'ALPR',
|
|
operator: p.operator,
|
|
manufacturer: p.brand,
|
|
'camera:type': p.cameraType,
|
|
'camera:direction': p.direction,
|
|
'surveillance:zone': p.surveillanceZone,
|
|
ref: p.ref,
|
|
check_date: p.check_date,
|
|
},
|
|
});
|
|
return record ? { ...record, osmTimestamp: p.osmTimestamp || null } : null;
|
|
}
|
|
|
|
/** Decode detail-level camera points; geometry-only heatmap tiles are not records. */
|
|
export function decodeAlprTile(bytes, z, x, y) {
|
|
const layer = new VectorTile(new PbfReader(bytes)).layers.cameras;
|
|
if (!layer) return [];
|
|
if (layer.length > 40_000)
|
|
throw new Error('Camera tile feature limit exceeded');
|
|
const records = [];
|
|
for (let i = 0; i < layer.length; i++) {
|
|
const record = normalizeAlprTileFeature(
|
|
layer.feature(i).toGeoJSON(x, y, z),
|
|
);
|
|
if (record) records.push(record);
|
|
}
|
|
return records;
|
|
}
|