mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 10:12:18 +00:00
fix(alpr): tighten model spec matching and card text
- Name the G3 record "AutoVu SharpV G3" and the SharpX record "XGA", so a bare SharpV or SharpX tag shows no specs without a separate wrapper. - Reuse the CCTV layer's Bosch MIC-7522-Z30 record instead of a copy. - Drop the brand from the SPEC line when the equipment line already names it, so long lines fit the card; pass the summary to entity properties. - Fall back to the OSM `brand` tag when `manufacturer` is missing. - Reject non-string or overlong model/manufacturer values before matching. - Remove the unused `brandAliases` parameter; shorten JSDoc and comments. - Cover the tile `model` path and the megapixel summary in tests; fold duplicate tests into existing ones. - Docs and changelog: the default hourly extract has no `model`; any source that supplies it shows the SPEC line.
This commit is contained in:
1 parent
d325c1e62d
commit
77fe8299d7
11 files changed
+147
-114
No files matched your search
@@ -43,6 +43,7 @@ test('normalizeAlprNode: maps a full OSM node to a plain record', () => {
|
||||
'surveillance:type': 'ALPR',
|
||||
operator: 'Flock Safety',
|
||||
'camera:type': 'fixed',
|
||||
model: ' L6Q ',
|
||||
'surveillance:zone': 'traffic',
|
||||
'camera:direction': '270',
|
||||
ref: 'ATX-001',
|
||||
@@ -56,7 +57,7 @@ test('normalizeAlprNode: maps a full OSM node to a plain record', () => {
|
||||
longitude: -97.7431,
|
||||
operator: 'Flock Safety',
|
||||
manufacturer: null,
|
||||
model: null,
|
||||
model: 'L6Q',
|
||||
cameraType: 'fixed',
|
||||
zone: 'traffic',
|
||||
directionDeg: 270,
|
||||
|
||||
@@ -23,7 +23,9 @@ import { t, tn, msg } from '../../i18n/index.js';
|
||||
* records fully cover, reused for later views inside it) and `zoom` (their
|
||||
* tile precision; `source.detailZoom(box)` names the zoom a view needs). Records use stable string ids and latitude /
|
||||
* longitude in degrees; optional directionDeg is a compass bearing [0, 360).
|
||||
* Manufacturer, operator and cameraType are optional display fields.
|
||||
* Manufacturer, operator, cameraType and model are optional display fields;
|
||||
* model only selects a vendored datasheet line (modelSpecs.js), never shown
|
||||
* as text.
|
||||
* Source label and attribution { name, description, text, href } identify the
|
||||
* actual provider; href must be HTTPS. Provider payload parsing stays in source.
|
||||
* Context services remove obsolete records with
|
||||
|
||||
@@ -1,17 +1,9 @@
|
||||
/**
|
||||
* @module alprModelSpecs
|
||||
*
|
||||
* Datasheet specs for the ALPR hardware that OpenStreetMap mappers name.
|
||||
*
|
||||
* 1,567 mapped ALPR cameras carry a `model` tag (October 2026). This module
|
||||
* vendors the records for the models among them that the CCTV Camera Database
|
||||
* (https://github.com/ch-bas/cctv-camera-database, CC0-1.0) covers —
|
||||
* Motorola Solutions Vigilant, Genetec AutoVu, Axis, Verkada and Bosch MIC,
|
||||
* which resolve 408 of those cameras (excluding unversioned SharpV tags) —
|
||||
* and resolves a camera's `model` (with its `manufacturer`) through the CCTV
|
||||
* layer's matcher. The hourly extract the
|
||||
* layer reads by default does not publish `model` yet, so today only an
|
||||
* Overpass-backed source shows these specs. Flock Safety publishes no
|
||||
* Datasheet specs for the ALPR hardware that OpenStreetMap `model` tags name,
|
||||
* vendored from the CCTV Camera Database (CC0-1.0) and matched with the CCTV
|
||||
* layer's rules; DATA_SOURCES.md has the provenance. Flock Safety publishes no
|
||||
* datasheet resolution, so Flock models stay unresolved; an unknown model
|
||||
* never implies anything.
|
||||
*
|
||||
@@ -19,13 +11,15 @@
|
||||
* night vision) — never endpoints, operators or what a camera records.
|
||||
*/
|
||||
|
||||
import { createModelSpecLookup } from '../cctv/modelSpecs.js';
|
||||
import { createModelSpecLookup, lookupModelSpec } from '../cctv/modelSpecs.js';
|
||||
|
||||
/**
|
||||
* Verbatim records from the dataset's model-enrichment extract (v2.29.0).
|
||||
* Mappers tag the bare product code ("L6Q", "MIC-7522-Z30B") where the
|
||||
* datasheet names the product line too ("Vigilant L6Q"), so each record also
|
||||
* lists its bare code as an alias.
|
||||
* Records from the dataset's model-enrichment extract (v2.29.0), with the
|
||||
* bare product codes mappers tag ("L6Q") added as aliases where the title
|
||||
* names the product line ("Vigilant L6Q"). A tag without a generation or
|
||||
* variant could name any of them, so the SharpV G3 and SharpX XGA titles
|
||||
* carry theirs. Fields the card does not read (type, url, fov_deg, …) stay as
|
||||
* in the dataset, like the CCTV records.
|
||||
*/
|
||||
const RECORDS = [
|
||||
{
|
||||
@@ -99,11 +93,10 @@ const RECORDS = [
|
||||
{
|
||||
id: 'genetec-autovu-sharpv',
|
||||
brand: 'Genetec',
|
||||
model: 'AutoVu SharpV',
|
||||
model: 'AutoVu SharpV G3',
|
||||
type: 'box',
|
||||
url: 'https://www.cctv-database.com/camera/genetec-autovu-sharpv/',
|
||||
aliases: [
|
||||
'AutoVu SharpV G3',
|
||||
'AU-V-WS850-LC-G3-000',
|
||||
'AU-V-BS850-LC-G3-0M0',
|
||||
'AU-V-BS850-LC-G3-0M1',
|
||||
@@ -128,7 +121,7 @@ const RECORDS = [
|
||||
{
|
||||
id: 'genetec-autovu-sharpx',
|
||||
brand: 'Genetec',
|
||||
model: 'AutoVu SharpX',
|
||||
model: 'AutoVu SharpX XGA',
|
||||
type: 'box',
|
||||
url: 'https://www.cctv-database.com/camera/genetec-autovu-sharpx/',
|
||||
// i18n-ignore: datasheet label
|
||||
@@ -229,42 +222,29 @@ const RECORDS = [
|
||||
night_vision: { type: 'ir', range_m: 20 },
|
||||
environment: ['indoor', 'outdoor'],
|
||||
},
|
||||
{
|
||||
id: 'bosch-mic-7522-z30b',
|
||||
brand: 'Bosch',
|
||||
model: 'MIC IP starlight 7100i (MIC-7522-Z30B)',
|
||||
type: 'ptz',
|
||||
url: 'https://www.cctv-database.com/camera/bosch-mic-7522-z30b/',
|
||||
aliases: ['MIC-7522-Z30B'],
|
||||
fov_deg: '2.1-58.3',
|
||||
// i18n-ignore: datasheet label
|
||||
resolution: { mp: 2, w: 1920, h: 1080, label: '1080p HD' },
|
||||
ptz: true,
|
||||
varifocal: true,
|
||||
night_vision: { type: 'color' },
|
||||
environment: ['outdoor'],
|
||||
ndaa_compliant: true,
|
||||
},
|
||||
// The CCTV layer's record: one colour-neutral title for the B/G/W variants.
|
||||
lookupModelSpec('MIC-7522-Z30B', 'Bosch'),
|
||||
];
|
||||
|
||||
const lookupDatasheetSpec = createModelSpecLookup(RECORDS);
|
||||
|
||||
/**
|
||||
* Datasheet record for a mapped ALPR camera's `model` tag. A `manufacturer`
|
||||
* naming another maker rejects the match, so a "Flock Safety" camera tagged
|
||||
* "L6Q" stays unresolved rather than borrowing Motorola's specs.
|
||||
* @param {string|null} model - The OSM `model` tag.
|
||||
* @param {string|null} [manufacturer] - The OSM `manufacturer` tag.
|
||||
* @returns {Object|null} The verbatim spec record, or null when unknown.
|
||||
* @returns {Object|null} The spec record, or null when unknown.
|
||||
*/
|
||||
const lookupDatasheetSpec = createModelSpecLookup(RECORDS);
|
||||
|
||||
export function lookupAlprModelSpec(model, manufacturer) {
|
||||
const spec = lookupDatasheetSpec(model, manufacturer);
|
||||
// The dataset's unversioned SharpV label is tied to G3 hardware, but OSM
|
||||
// tags may name G1 or G2. Require an explicit G3 or a G3 part number.
|
||||
// Adapter records arrive unnormalized and the matcher's word trim is
|
||||
// quadratic on long punctuation runs: match only tag-sized strings (the
|
||||
// built-in sources keep 180 characters).
|
||||
if (typeof model !== 'string' || model.length > 180) return null;
|
||||
if (
|
||||
spec?.id === 'genetec-autovu-sharpv' &&
|
||||
!/\bg3\b/i.test(String(model || ''))
|
||||
manufacturer != null &&
|
||||
(typeof manufacturer !== 'string' || manufacturer.length > 180)
|
||||
)
|
||||
return null;
|
||||
return spec;
|
||||
return lookupDatasheetSpec(model, manufacturer);
|
||||
}
|
||||
@@ -2,9 +2,10 @@
|
||||
// Mapped ALPR model tags resolve to vendored datasheets, and never guess.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { PbfWriter } from 'pbf';
|
||||
|
||||
import { lookupAlprModelSpec } from './modelSpecs.js';
|
||||
import { normalizeAlprNode } from './records.js';
|
||||
import { decodeAlprTile } from './tileRecords.js';
|
||||
import { alprLabelDetails } from './visuals.js';
|
||||
|
||||
const OSM = { attribution: { name: 'OpenStreetMap' } };
|
||||
@@ -20,6 +21,7 @@ test('the model tags mappers write resolve to their datasheet record', () => {
|
||||
['AU-V-WS850-LC-G3-000', 'Genetec', 'genetec-autovu-sharpv'],
|
||||
['AutoVu SharpV G2', 'Genetec', 'genetec-autovu-sharpv-g2'],
|
||||
['AutoVu SharpV G1', 'Genetec', 'genetec-autovu-sharpv-g2'],
|
||||
['AutoVu SharpX XGA', 'Genetec', 'genetec-autovu-sharpx'],
|
||||
['Q1700-LE', 'Axis Communications', 'axis-q1700-le'],
|
||||
['Q1800-LE', 'Axis Communications', 'axis-q1800-le'],
|
||||
['CP63-E', 'Verkada Inc.', 'verkada-cp63-e'],
|
||||
@@ -45,37 +47,61 @@ test('unknown, mis-attributed or partial models stay unresolved', () => {
|
||||
['Q1800', 'Axis Communications'],
|
||||
// Without a maker, a code-less product name is never trusted.
|
||||
['AutoVu SharpV', null],
|
||||
// A SharpV without its generation could be G1, G2 or G3, and a SharpX
|
||||
// without XGA could be the VGA model.
|
||||
['AutoVu SharpV', 'Genetec'],
|
||||
['AutoVu SharpV HD', 'Genetec'],
|
||||
['Genetec AutoVu SharpV', 'Genetec'],
|
||||
['AutoVu SharpX', 'Genetec'],
|
||||
['UnicamVELOCITY3', null],
|
||||
[null, 'Motorola Solutions'],
|
||||
// Adapter text is matched only as a string of tag size.
|
||||
[['L6Q'], 'Motorola Solutions'],
|
||||
['L6Q' + ' IP'.repeat(60), 'Motorola Solutions'],
|
||||
])
|
||||
assert.equal(lookupAlprModelSpec(model, manufacturer), null);
|
||||
});
|
||||
|
||||
test('Overpass records carry the trimmed OSM model tag', () => {
|
||||
const node = normalizeAlprNode({
|
||||
type: 'node',
|
||||
id: 7,
|
||||
lat: 30,
|
||||
lon: -97,
|
||||
tags: {
|
||||
'surveillance:type': 'ALPR',
|
||||
manufacturer: 'Motorola Solutions',
|
||||
model: ' L6Q ',
|
||||
},
|
||||
/** A one-point `cameras` vector tile (z0) with string attributes. */
|
||||
function cameraTile(properties) {
|
||||
const tile = new PbfWriter();
|
||||
tile.writeMessage(3, (_, layer) => {
|
||||
layer.writeVarintField(15, 2);
|
||||
layer.writeStringField(1, 'cameras');
|
||||
layer.writeVarintField(5, 4096);
|
||||
const keys = Object.keys(properties);
|
||||
layer.writeMessage(2, (_, feature) => {
|
||||
feature.writePackedVarint(
|
||||
2,
|
||||
keys.flatMap((_, i) => [i, i]),
|
||||
);
|
||||
feature.writeVarintField(3, 1); // Point
|
||||
feature.writePackedVarint(4, [9, 4096, 4096]); // MoveTo(2048, 2048)
|
||||
});
|
||||
for (const key of keys) layer.writeStringField(3, key);
|
||||
for (const key of keys)
|
||||
layer.writeMessage(4, (_, value) =>
|
||||
value.writeStringField(1, String(properties[key])),
|
||||
);
|
||||
});
|
||||
assert.equal(node.model, 'L6Q');
|
||||
assert.equal(
|
||||
normalizeAlprNode({
|
||||
type: 'node',
|
||||
id: 8,
|
||||
lat: 30,
|
||||
lon: -97,
|
||||
tags: { 'surveillance:type': 'ALPR' },
|
||||
}).model,
|
||||
null,
|
||||
return tile.finish();
|
||||
}
|
||||
|
||||
test('extract tiles carry the model tag to the card', () => {
|
||||
const [record] = decodeAlprTile(
|
||||
cameraTile({
|
||||
osmType: 'node',
|
||||
osmId: '7',
|
||||
brand: 'Motorola Solutions',
|
||||
model: 'L6Q',
|
||||
}),
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
);
|
||||
assert.equal(record.model, 'L6Q');
|
||||
assert.ok(
|
||||
alprLabelDetails(record, OSM).includes('SPEC VIGILANT L6Q · 1080P · IR'),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -87,15 +113,40 @@ test('the card adds the datasheet line only for a resolved model', () => {
|
||||
assert.deepEqual(details, [
|
||||
'OSM MAPPED',
|
||||
'MOTOROLA SOLUTIONS',
|
||||
'SPEC MOTOROLA SOLUTIONS VIGILANT L6Q · 1080P · IR',
|
||||
'SPEC VIGILANT L6Q · 1080P · IR',
|
||||
'PUBLIC MAP DATA',
|
||||
]);
|
||||
// A record without a resolution label falls back to its pixel size.
|
||||
// Without a maker on the equipment line, the spec line names it.
|
||||
assert.ok(
|
||||
alprLabelDetails({ model: 'L6Q' }, OSM).includes(
|
||||
'SPEC MOTOROLA SOLUTIONS VIGILANT L6Q · 1080P · IR',
|
||||
),
|
||||
);
|
||||
// A record without a resolution label falls back to its pixel size, then
|
||||
// to megapixels.
|
||||
assert.ok(
|
||||
alprLabelDetails(
|
||||
{ manufacturer: 'Motorola Solutions', model: 'L5F' },
|
||||
OSM,
|
||||
).includes('SPEC MOTOROLA SOLUTIONS VIGILANT L5F · 1440X1080 · IR'),
|
||||
).includes('SPEC VIGILANT L5F · 1440X1080 · IR'),
|
||||
);
|
||||
assert.ok(
|
||||
alprLabelDetails(
|
||||
{ manufacturer: 'Motorola Solutions', model: 'L5Q' },
|
||||
OSM,
|
||||
).includes('SPEC VIGILANT L5Q · 3MP'),
|
||||
);
|
||||
assert.ok(
|
||||
alprLabelDetails(
|
||||
{ manufacturer: 'Genetec', model: 'AutoVu SharpV G3' },
|
||||
OSM,
|
||||
).includes('SPEC AUTOVU SHARPV G3 · 1920X1200 · IR'),
|
||||
);
|
||||
assert.ok(
|
||||
alprLabelDetails(
|
||||
{ manufacturer: 'The Bosch Group', model: 'MIC-7522-Z30B' },
|
||||
OSM,
|
||||
).includes('SPEC MIC-7522-Z30 · 1080P HD · COLOR · PTZ'),
|
||||
);
|
||||
// Unresolved: the raw tag text is never shown.
|
||||
const unknown = alprLabelDetails(
|
||||
@@ -104,17 +155,3 @@ test('the card adds the datasheet line only for a resolved model', () => {
|
||||
);
|
||||
assert.ok(unknown.every((line) => !/FALCON|SYSTEM|SPEC/.test(line)));
|
||||
});
|
||||
|
||||
test('unversioned SharpV does not display G3 specs on an ALPR card', () => {
|
||||
const ambiguous = alprLabelDetails(
|
||||
{ manufacturer: 'Genetec', model: 'AutoVu SharpV' },
|
||||
OSM,
|
||||
);
|
||||
assert.deepEqual(ambiguous, ['OSM MAPPED', 'GENETEC', 'PUBLIC MAP DATA']);
|
||||
|
||||
const g3 = alprLabelDetails(
|
||||
{ manufacturer: 'Genetec', model: 'AutoVu SharpV G3' },
|
||||
OSM,
|
||||
);
|
||||
assert.ok(g3.includes('SPEC GENETEC AUTOVU SHARPV · 1920X1200 · IR'));
|
||||
});
|
||||
@@ -16,6 +16,8 @@ import { boxContains } from './model.js';
|
||||
import { msg } from '../../i18n/index.js';
|
||||
import { createAlprFloorResolver } from './floors.js';
|
||||
import { createAlprOverlay } from './overlay.js';
|
||||
import { lookupAlprModelSpec } from './modelSpecs.js';
|
||||
import { specSummary } from '../cctv/modelSpecs.js';
|
||||
import {
|
||||
MARKER_IMAGE,
|
||||
SELECTED_IMAGE,
|
||||
@@ -458,6 +460,10 @@ export function createAlprPresentation({ state, services, source }) {
|
||||
properties: {
|
||||
operator: record.operator,
|
||||
manufacturer: record.manufacturer,
|
||||
spec:
|
||||
specSummary(
|
||||
lookupAlprModelSpec(record.model, record.manufacturer),
|
||||
) || null,
|
||||
cameraType: record.cameraType,
|
||||
zone: record.zone,
|
||||
directionDeg: record.directionDeg,
|
||||
|
||||
@@ -89,7 +89,7 @@ export function normalizeAlprNode(el) {
|
||||
latitude: el.lat,
|
||||
longitude: el.lon,
|
||||
operator: textTag(tags.operator),
|
||||
manufacturer: textTag(tags.manufacturer),
|
||||
manufacturer: textTag(tags.manufacturer) ?? textTag(tags.brand),
|
||||
// Display-only: resolved against vendored datasheets (see modelSpecs.js).
|
||||
model: textTag(tags.model),
|
||||
cameraType: textTag(tags['camera:type']),
|
||||
|
||||
@@ -45,10 +45,7 @@ export function alprDisplayId(record) {
|
||||
return `ALPR-${String(record.osmId).slice(-4).padStart(4, '0')}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show only supplied metadata, with the actual source named for custom
|
||||
* adapters, plus the datasheet summary when the mapped model is known.
|
||||
*/
|
||||
/** Show only supplied metadata, with the actual source named for custom adapters. */
|
||||
export function alprLabelDetails(record, source) {
|
||||
const sourceName =
|
||||
source.attribution?.name || source.label || 'Camera source';
|
||||
@@ -71,7 +68,13 @@ export function alprLabelDetails(record, source) {
|
||||
if (equipment.length) details.push(equipment.join(' · '));
|
||||
// Only a datasheet match is shown: the raw OSM `model` text never is.
|
||||
const spec = lookupAlprModelSpec(record.model, record.manufacturer);
|
||||
if (spec) details.push(`SPEC ${specSummary(spec).toUpperCase()}`);
|
||||
if (spec) {
|
||||
// The equipment line usually names the maker already; the card does not wrap.
|
||||
const withBrand = !equipment.some((line) =>
|
||||
line.includes(spec.brand.toUpperCase()),
|
||||
);
|
||||
details.push(`SPEC ${specSummary(spec, { withBrand }).toUpperCase()}`);
|
||||
}
|
||||
if (sourceName === 'OpenStreetMap') details.push('PUBLIC MAP DATA');
|
||||
return details;
|
||||
}
|
||||
|
||||
@@ -456,15 +456,8 @@ const BRAND_ALIASES = {
|
||||
Hikvision: ['hiwatch'],
|
||||
};
|
||||
|
||||
/**
|
||||
* Builds a model lookup over a record table, so another layer can resolve its
|
||||
* own vendored records with the same matching rules (see lookupModelSpec).
|
||||
* @param {Object[]} records - Spec records in this module's shape.
|
||||
* @param {Object<string, string[]>} [brandAliases] - Extra manufacturer words
|
||||
* accepted per record brand.
|
||||
* @returns {(model: string, manufacturer?: string) => (Object|null)} Lookup.
|
||||
*/
|
||||
export function createModelSpecLookup(records, brandAliases = BRAND_ALIASES) {
|
||||
/** A model lookup over `records` with this module's matching rules (see lookupModelSpec). */
|
||||
export function createModelSpecLookup(records) {
|
||||
/**
|
||||
* One entry per record name (model + aliases). `required` is every
|
||||
* non-generic word of the name — all must appear in a query, so a
|
||||
@@ -476,7 +469,7 @@ export function createModelSpecLookup(records, brandAliases = BRAND_ALIASES) {
|
||||
const nameIndex = records.flatMap((record) => {
|
||||
const brand = new Set([
|
||||
...words(record.brand),
|
||||
...(brandAliases[record.brand] || []),
|
||||
...(BRAND_ALIASES[record.brand] || []),
|
||||
]);
|
||||
return [record.model, ...(record.aliases || [])].map((name) => {
|
||||
const nameWords = words(name);
|
||||
@@ -610,12 +603,15 @@ export function specFovCapabilityToken(
|
||||
|
||||
/**
|
||||
* One-line spec summary for HUD meta text.
|
||||
* @param {Object} spec - A record from this module.
|
||||
* @param {Object} spec - A spec record (CCTV or ALPR). Resolution falls back
|
||||
* from label to WxH to NMP.
|
||||
* @param {{withBrand?: boolean}} [options] - `withBrand: false` leaves the
|
||||
* brand out.
|
||||
* @returns {string} e.g. 'Axis Q6135-LE · 1080p · IR 250m · PTZ' ('' for null).
|
||||
*/
|
||||
export function specSummary(spec) {
|
||||
export function specSummary(spec, { withBrand = true } = {}) {
|
||||
if (!spec) return '';
|
||||
const parts = [`${spec.brand} ${spec.model}`];
|
||||
const parts = [withBrand ? `${spec.brand} ${spec.model}` : spec.model];
|
||||
const { label, w, h, mp } = spec.resolution || {};
|
||||
if (label) parts.push(label);
|
||||
else if (w && h) parts.push(`${w}x${h}`);
|
||||
|
||||
Reference in new issue
Block a user