mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Knip, configured with the application, package exports, scripts, QA harnesses, workers, tools and tests as entry points, reports exports that no module imports. Each was checked by hand against string-based and namespace imports. - Symbols that are still used inside their own module lose only the `export` keyword (176 constants and helpers). - Unused re-exports are removed from barrel modules (flight, military, vessel, CCTV, directions, transit history, local ADS-B and street-level policy modules). - Declarations that nothing uses at all are deleted, among them AIS_WATCHDOG_STATUSES, applyFilter, isRadioCountryCode, compactText, DENSITY_STOPS, the unused CCTV endpoint constants, and the SDR band constants. - Default exports that nothing imports are removed. The ones in src/data/earthquakes.js, src/data/telegeographySubmarineCables.js, src/data/wind.js and src/data/bhoteKoshiLocator.js each constructed a layer instance at import time that nothing used; those instances are no longer created. Every export of a package.json entry stays, as does TOMTOM_CREDIT, which the traffic layer reads from the credits namespace it is given.
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. */
|
|
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;
|
|
}
|