mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 02:02:21 +00:00
Read the OSM `model` tag on ALPR records and resolve it, with the `manufacturer` tag, against 16 vendored CCTV Camera Database records (v2.29.0): Motorola Solutions Vigilant, Genetec AutoVu, Axis, Verkada and Bosch MIC. A resolved camera's card gains a SPEC line; an unknown or mis-attributed model shows nothing, and the raw tag text never reaches the card or the voice tools. The CCTV matcher becomes createModelSpecLookup(records) so both layers share one set of matching rules, and specSummary falls back to pixel size or megapixels when a record has no resolution label. 459 of the 1,567 OSM ALPR nodes with a model tag resolve. The hourly extract the layer reads by default has no model field yet, so tile records carry it only once the extract publishes it.
46 lines
1.5 KiB
JavaScript
46 lines
1.5 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,
|
|
// Not in the hourly extract yet; read when it ships the OSM tag.
|
|
model: p.model,
|
|
'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;
|
|
}
|