diff --git a/DATA_SOURCES.md b/DATA_SOURCES.md index f8da1e26c7..cb9da66e43 100644 --- a/DATA_SOURCES.md +++ b/DATA_SOURCES.md @@ -432,7 +432,7 @@ The [Bhote Koshi event pack](public/events/bhote-koshi-2026/README.md), under `p | **Yale Bright Star Catalogue** (9,096 stars, sky background) | `sky/` | **Public domain** | ✅ (no restrictions) | "Yale Bright Star Catalogue (Hoffleit & Warren, via CDS)" (courtesy credit) | | **ESO Milky Way panorama** (eso0932a, blurred cube map, sky background) | `sky/` | **CC BY 4.0** | ✅ (attribution; changes stated) | "ESO/S. Brunier" | | **CCTV ground heights** (3,445 cameras) | `cctv_ground_heights/` | Precomputed camera placement heights, aligned to work with Google Photorealistic 3D Tiles (folder README) | — | — | -| **CCTV Camera Database** model-enrichment extract v2.26.0 + v2.29.0 (20 camera-model records) | `src/layers/cctv/modelSpecs.js` | **CC0-1.0** (public domain dedication) | ✅ (no restrictions) | "Specs: cctv-database.com" (courtesy — not legally required) | +| **CCTV Camera Database** model-enrichment extract v2.26.0 + v2.29.0 (20 CCTV and 15 ALPR camera-model records) | `src/layers/cctv/modelSpecs.js`, `src/layers/alpr/modelSpecs.js` | **CC0-1.0** (public domain dedication) | ✅ (no restrictions) | "Specs: cctv-database.com" (courtesy — not legally required) | ### ⚠️ TeleGeography is bundled but NonCommercial @@ -458,6 +458,17 @@ commercial use with attribution and applicable database share-alike/access obligations; it does not license the application code. Trimmed test-only tile fixtures retain their provenance in `src/data/fixtures/README.md`. +A mapped `model` tag that names datasheet hardware adds a spec line to the +selected card. The specs are 16 CC0-1.0 records from the CCTV Camera Database +model-enrichment extract (v2.29.0): 15 compiled into +`src/layers/alpr/modelSpecs.js`, with the bare product codes mappers tag added +as aliases and the SharpV G3 and SharpX XGA titles naming their variant, plus +the CCTV layer's Bosch MIC-7522-Z30 record. Nothing is fetched at runtime, and +an unrecognised tag is never displayed. The default hourly extract does not +carry `model` yet, so the line appears only with a source that supplies it: an +Overpass-backed source or a custom adapter whose records include the optional +`model` field. + ### CCTV Camera Database (`src/layers/cctv/modelSpecs.js`) The CCTV layer's hardware-model specs are a small extract (v2.26.0, plus the Bosch MIC diff --git a/changelog.d/1360-alpr-model-specs.md b/changelog.d/1360-alpr-model-specs.md new file mode 100644 index 0000000000..a7db9817c5 --- /dev/null +++ b/changelog.d/1360-alpr-model-specs.md @@ -0,0 +1,7 @@ +- Mapped ALPR cameras whose OpenStreetMap `model` tag names known hardware + (Motorola Solutions Vigilant, Genetec AutoVu, Axis, Verkada, Bosch MIC) show + a datasheet spec line on their card, from 16 vendored CCTV Camera Database + records, when their source supplies `model` (an Overpass-backed source or an + integration adapter; the default hourly extract does not yet); unknown, + generation-ambiguous or mis-attributed models show nothing + (bassem chagra, @ch-bas, #1360). diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 8b01b335ad..06c3093d7d 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -1939,6 +1939,16 @@ The row count explicitly says **nearby**: loaded records can be outside the screen. Cyan camera badges use Manjunath's camera artwork; selection switches to a larger coral badge with corner brackets and an animated tactical card. Numeric mapped bearings draw illustrative 90 m direction wedges (not measured coverage). +A camera whose OSM `model` tag names known hardware (Motorola Solutions Vigilant, +Genetec AutoVu, Axis, Verkada, Bosch MIC; 408 of the 1,567 tagged cameras +in October 2026) gets a `SPEC` line on its card from vendored datasheet records +(`src/layers/alpr/modelSpecs.js`, matched with the CCTV layer's +`createModelSpecLookup`). A `manufacturer` naming another maker rejects the +match, and the raw tag text is never shown. +Unversioned `AutoVu SharpV` and `AutoVu SharpX` tags show no specs; G1/G2 +tags show the G2 (1280x960) record and G3 tags the G3 record. The default +hourly extract has no `model` field yet; an Overpass-backed source or a custom +adapter record's optional `model` fills it. The shared overlay paints gradients for at most 64 nearby cameras, promoting the selected camera; farther cameras keep native Cesium badges without wedges. Native ground-clamped wedges (a ground polyline plus a classification polygon per diff --git a/scripts/format-scope.json b/scripts/format-scope.json index 39232144dc..54bbfddb3d 100644 --- a/scripts/format-scope.json +++ b/scripts/format-scope.json @@ -671,6 +671,7 @@ "src/data/dataCredits.test.mjs", "src/layers/alpr/index.js", "src/layers/alpr/model.js", + "src/layers/alpr/modelSpecs.test.mjs", "src/layers/alpr/policy.js", "src/layers/alpr/presentation.js", "src/layers/alpr/presentation.test.mjs", diff --git a/scripts/package-boundaries.json b/scripts/package-boundaries.json index cea396ce3a..07557b3c71 100644 --- a/scripts/package-boundaries.json +++ b/scripts/package-boundaries.json @@ -3648,6 +3648,8 @@ "src/render/cesium/common.js", "src/render/cesium/internals.js", "src/layers/alpr/visuals.js", + "src/layers/alpr/modelSpecs.js", + "src/layers/cctv/modelSpecs.js", "src/layers/alpr/overlay.js", "src/layers/alpr/markerState.js", "src/layers/alpr/source.js", @@ -4449,6 +4451,7 @@ "src/layers/alpr/policy.js", "src/layers/alpr/presentation.js", "src/layers/alpr/visuals.js", + "src/layers/alpr/modelSpecs.js", "src/layers/alpr/overlay.js", "src/layers/alpr/markerState.js", "src/layers/alpr/source.js", @@ -5743,6 +5746,7 @@ "src/layers/alpr/policy.js", "src/layers/alpr/presentation.js", "src/layers/alpr/visuals.js", + "src/layers/alpr/modelSpecs.js", "src/layers/alpr/overlay.js", "src/layers/alpr/markerState.js", "src/layers/alpr/source.js", diff --git a/src/data/alprCameras.test.mjs b/src/data/alprCameras.test.mjs index d29780d554..da55e70e65 100644 --- a/src/data/alprCameras.test.mjs +++ b/src/data/alprCameras.test.mjs @@ -50,6 +50,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', @@ -63,6 +64,7 @@ test('normalizeAlprNode: maps a full OSM node to a plain record', () => { longitude: -97.7431, operator: 'Flock Safety', manufacturer: null, + model: 'L6Q', cameraType: 'fixed', zone: 'traffic', directionDeg: 270, diff --git a/src/layers/alpr/index.js b/src/layers/alpr/index.js index 2e30154240..e7d8b5206b 100644 --- a/src/layers/alpr/index.js +++ b/src/layers/alpr/index.js @@ -27,7 +27,9 @@ let instances = 0; * 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 diff --git a/src/layers/alpr/modelSpecs.js b/src/layers/alpr/modelSpecs.js new file mode 100644 index 0000000000..1e71789f28 --- /dev/null +++ b/src/layers/alpr/modelSpecs.js @@ -0,0 +1,250 @@ +/** + * @module alprModelSpecs + * + * 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. + * + * Scope guardrail: records describe camera PRODUCTS (optics, resolution, + * night vision) — never endpoints, operators or what a camera records. + */ + +import { createModelSpecLookup, lookupModelSpec } from '../cctv/modelSpecs.js'; + +/** + * 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 = [ + { + id: 'motorola-solutions-l5f', + brand: 'Motorola Solutions', + model: 'Vigilant L5F', + type: 'box', + url: 'https://www.cctv-database.com/camera/motorola-solutions-l5f/', + aliases: ['L5F', 'L5F Fixed LPR Camera System'], + resolution: { mp: 1.6, w: 1440, h: 1080 }, + lens_count: 2, + night_vision: { type: 'ir' }, + environment: ['outdoor'], + }, + { + id: 'motorola-solutions-l5m', + brand: 'Motorola Solutions', + model: 'Vigilant L5M', + type: 'box', + url: 'https://www.cctv-database.com/camera/motorola-solutions-l5m/', + aliases: [ + 'L5M', + 'L5M Mobile LPR Camera System', + 'L5M Mobile ANPR Camera System', + ], + resolution: { mp: 1.6, w: 1440, h: 1080 }, + lens_count: 2, + night_vision: { type: 'ir' }, + environment: ['outdoor'], + }, + { + id: 'motorola-solutions-l5q', + brand: 'Motorola Solutions', + model: 'Vigilant L5Q', + type: 'box', + url: 'https://www.cctv-database.com/camera/motorola-solutions-l5q/', + aliases: ['L5Q', 'L5Q Quick Deploy LPR Camera System'], + resolution: { mp: 3 }, + environment: ['outdoor'], + }, + { + id: 'motorola-solutions-l6d', + brand: 'Motorola Solutions', + model: 'Vigilant L6D', + type: 'bullet', + url: 'https://www.cctv-database.com/camera/motorola-solutions-l6d/', + aliases: [ + 'L6D', + 'L6D Dual-Purpose LPR Camera', + 'VSM-L6D-8IR', + 'VSM-L6D-7IR', + ], + fov_deg: '52-3 horizontal', + resolution: { mp: 1.6, w: 1440, h: 1080 }, + lens_count: 2, + varifocal: true, + night_vision: { type: 'ir' }, + environment: ['outdoor'], + }, + { + id: 'motorola-solutions-l6q', + brand: 'Motorola Solutions', + model: 'Vigilant L6Q', + type: 'box', + url: 'https://www.cctv-database.com/camera/motorola-solutions-l6q/', + aliases: ['L6Q', 'L6Q Quick-Deploy LPR Camera System'], + resolution: { mp: 2.1, w: 1920, h: 1080, label: '1080p' }, + night_vision: { type: 'ir' }, + environment: ['outdoor'], + }, + { + id: 'genetec-autovu-sharpv', + brand: 'Genetec', + model: 'AutoVu SharpV G3', + type: 'box', + url: 'https://www.cctv-database.com/camera/genetec-autovu-sharpv/', + aliases: [ + 'AU-V-WS850-LC-G3-000', + 'AU-V-BS850-LC-G3-0M0', + 'AU-V-BS850-LC-G3-0M1', + ], + resolution: { mp: 2.3, w: 1920, h: 1200, label: '1920x1200' }, + lens_count: 2, + night_vision: { type: 'ir' }, + environment: ['outdoor'], + }, + { + id: 'genetec-autovu-sharpv-g2', + brand: 'Genetec', + model: 'AutoVu SharpV G2', + type: 'box', + url: 'https://www.cctv-database.com/camera/genetec-autovu-sharpv-g2/', + aliases: ['AutoVu SharpV G1', 'AU-V-WS850-LC-G2', 'AU-V-WS850-LC'], + resolution: { mp: 1.2, w: 1280, h: 960, label: '1280x960' }, + lens_count: 2, + night_vision: { type: 'ir' }, + environment: ['outdoor'], + }, + { + id: 'genetec-autovu-sharpx', + brand: 'Genetec', + model: 'AutoVu SharpX XGA', + type: 'box', + url: 'https://www.cctv-database.com/camera/genetec-autovu-sharpx/', + // i18n-ignore: datasheet label + resolution: { mp: 1, w: 1024, h: 946, label: 'XGA (1024x946)' }, + lens_count: 2, + night_vision: { type: 'ir' }, + environment: ['outdoor'], + }, + { + id: 'genetec-autovu-sharpz3', + brand: 'Genetec', + model: 'AutoVu SharpZ3', + type: 'box', + url: 'https://www.cctv-database.com/camera/genetec-autovu-sharpz3/', + resolution: { mp: 1.6, w: 1456, h: 1088, label: '1456x1088' }, + lens_count: 3, + night_vision: { type: 'ir' }, + environment: ['outdoor'], + }, + { + id: 'axis-q1700-le', + brand: 'Axis', + model: 'Q1700-LE', + type: 'box', + url: 'https://www.cctv-database.com/camera/axis-q1700-le/', + fov_deg: '16-2.3 horizontal / 9.6-1.3 vertical', + resolution: { mp: 2, w: 1920, h: 1080, label: '1080p' }, + varifocal: true, + night_vision: { type: 'ir', range_m: 50 }, + environment: ['outdoor'], + ndaa_compliant: true, + }, + { + id: 'axis-q1800-le', + brand: 'Axis', + model: 'Q1800-LE', + type: 'bullet', + url: 'https://www.cctv-database.com/camera/axis-q1800-le/', + aliases: ['03107-001', 'Q1800-LE-3 (License Plate Verifier kit)'], + fov_deg: '38-2.3 horizontal', + resolution: { mp: 2, w: 1920, h: 1080, label: '1080p' }, + varifocal: true, + night_vision: { type: 'ir', range_m: 40 }, + environment: ['indoor', 'outdoor'], + ndaa_compliant: true, + }, + { + id: 'verkada-cb62-te-f', + brand: 'Verkada', + model: 'CB62-TE-F', + type: 'bullet', + url: 'https://www.cctv-database.com/camera/verkada-cb62-te-f/', + fov_deg: '42 to 17 H', + resolution: { mp: 8.3, w: 3840, h: 2160, label: '4K' }, + varifocal: true, + night_vision: { type: 'ir', range_m: 50 }, + environment: ['outdoor'], + ndaa_compliant: true, + }, + { + id: 'verkada-ch52-e-f', + brand: 'Verkada', + model: 'CH52-E-F', + type: 'panoramic', + url: 'https://www.cctv-database.com/camera/verkada-ch52-e-f/', + fov_deg: '89 to 37 H (per sensor); up to 328 combined', + // i18n-ignore: datasheet label + resolution: { mp: 5, w: 2688, h: 1944, label: '4 x 5MP (20MP)' }, + lens_count: 4, + varifocal: true, + night_vision: { type: 'ir', range_m: 30 }, + environment: ['outdoor'], + ndaa_compliant: true, + }, + { + id: 'verkada-cp63-e', + brand: 'Verkada', + model: 'CP63-E', + type: 'ptz', + url: 'https://www.cctv-database.com/camera/verkada-cp63-e/', + fov_deg: '64 to 2 H', + resolution: { mp: 8.3, w: 3840, h: 2160, label: '4K' }, + ptz: true, + varifocal: true, + night_vision: { type: 'ir', range_m: 100 }, + environment: ['outdoor'], + ndaa_compliant: true, + }, + { + id: 'verkada-cr63-e', + brand: 'Verkada', + model: 'CR63-E', + type: 'bullet', + url: 'https://www.cctv-database.com/camera/verkada-cr63-e/', + fov_deg: '109 to 49 H', + resolution: { mp: 8.3, w: 3840, h: 2160, label: '4K' }, + varifocal: true, + night_vision: { type: 'ir', range_m: 20 }, + environment: ['indoor', 'outdoor'], + }, + // 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 spec record, or null when unknown. + */ +export function lookupAlprModelSpec(model, manufacturer) { + // 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 ( + manufacturer != null && + (typeof manufacturer !== 'string' || manufacturer.length > 180) + ) + return null; + return lookupDatasheetSpec(model, manufacturer); +} diff --git a/src/layers/alpr/modelSpecs.test.mjs b/src/layers/alpr/modelSpecs.test.mjs new file mode 100644 index 0000000000..dd2c8c20c6 --- /dev/null +++ b/src/layers/alpr/modelSpecs.test.mjs @@ -0,0 +1,157 @@ +// src/layers/alpr/modelSpecs.test.mjs +// 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 { decodeAlprTile } from './tileRecords.js'; +import { alprLabelDetails } from './visuals.js'; + +const OSM = { attribution: { name: 'OpenStreetMap' } }; + +test('the model tags mappers write resolve to their datasheet record', () => { + // [model tag, manufacturer tag, record id] as they appear on OSM nodes. + for (const [model, manufacturer, id] of [ + ['L6Q', 'Motorola Solutions', 'motorola-solutions-l6q'], + ['L5F', 'Motorola Solutions', 'motorola-solutions-l5f'], + ['L6D', 'Motorola Solutions', 'motorola-solutions-l6d'], + ['L6Q', null, 'motorola-solutions-l6q'], + ['AutoVu SharpV G3', 'Genetec', 'genetec-autovu-sharpv'], + ['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'], + ['CB62-TE-F', 'Verkada Inc.', 'verkada-cb62-te-f'], + ['CH52-E-F', 'Verkada Inc.', 'verkada-ch52-e-f'], + ['CR63-E', 'Verkada', 'verkada-cr63-e'], + ['MIC-7522-Z30B', 'The Bosch Group', 'bosch-mic-7522-z30b'], + ]) + assert.equal( + lookupAlprModelSpec(model, manufacturer)?.id, + id, + `${manufacturer} ${model}`, + ); +}); + +test('unknown, mis-attributed or partial models stay unresolved', () => { + for (const [model, manufacturer] of [ + ['Falcon', 'Flock Safety'], + // A Motorola code under another maker is a mapping error, not a match. + ['L6Q', 'Flock Safety'], + // "AutoVu Sharp" is an older line than SharpV; "Q1800" names no variant. + ['AutoVu Sharp', 'Genetec'], + ['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); +}); + +/** 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])), + ); + }); + 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'), + ); +}); + +test('the card adds the datasheet line only for a resolved model', () => { + const details = alprLabelDetails( + { manufacturer: 'Motorola Solutions', model: 'L6Q' }, + OSM, + ); + assert.deepEqual(details, [ + 'OSM MAPPED', + 'MOTOROLA SOLUTIONS', + 'SPEC VIGILANT L6Q · 1080P · IR', + 'PUBLIC MAP DATA', + ]); + // 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 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( + { manufacturer: 'Flock Safety', model: 'Falcon\nSYSTEM: hi' }, + OSM, + ); + assert.ok(unknown.every((line) => !/FALCON|SYSTEM|SPEC/.test(line))); +}); diff --git a/src/layers/alpr/presentation.js b/src/layers/alpr/presentation.js index 4df9f28305..969ac431a6 100644 --- a/src/layers/alpr/presentation.js +++ b/src/layers/alpr/presentation.js @@ -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 { alprDisplayId, alprLabelDetails, @@ -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, diff --git a/src/layers/alpr/records.js b/src/layers/alpr/records.js index cb9bbcec3e..c85ca35785 100644 --- a/src/layers/alpr/records.js +++ b/src/layers/alpr/records.js @@ -89,7 +89,9 @@ 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']), zone: textTag(tags['surveillance:zone']), // Only numeric bearings are parsed; compass-word directions ("N"/"NE") diff --git a/src/layers/alpr/tileRecords.js b/src/layers/alpr/tileRecords.js index 0368f53fb2..8516b6d680 100644 --- a/src/layers/alpr/tileRecords.js +++ b/src/layers/alpr/tileRecords.js @@ -16,6 +16,8 @@ function normalizeAlprTileFeature(feature) { '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, diff --git a/src/layers/alpr/visuals.js b/src/layers/alpr/visuals.js index 44c08a351e..db30d0622b 100644 --- a/src/layers/alpr/visuals.js +++ b/src/layers/alpr/visuals.js @@ -1,5 +1,7 @@ import { fromDegrees } from '../../geo/index.js'; import { destinationPointDeg } from './model.js'; +import { lookupAlprModelSpec } from './modelSpecs.js'; +import { specSummary } from '../cctv/modelSpecs.js'; import { DIRECTION_CONE_M, DIRECTION_CONE_HALF_ANGLE_DEG, @@ -64,6 +66,15 @@ 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) { + // 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; } diff --git a/src/layers/cctv/modelSpecs.js b/src/layers/cctv/modelSpecs.js index adc35f10bf..4be78de085 100644 --- a/src/layers/cctv/modelSpecs.js +++ b/src/layers/cctv/modelSpecs.js @@ -456,33 +456,60 @@ const BRAND_ALIASES = { Hikvision: ['hiwatch'], }; -function brandWords(record) { - return new Set([ - ...words(record.brand), - ...(BRAND_ALIASES[record.brand] || []), - ]); -} - -/** - * One entry per record name (model + aliases). `required` is every - * non-generic word of the name — all must appear in a query, so a generation - * or suffix ("Mk II", "7000i" vs "7000") is never dropped. `hasCode` marks - * names carrying a letter+digit model code; names without one ("3950", - * "01959-004", "AUTODOME 800 Series") match only when the brand does. - */ -const NAME_INDEX = RECORDS.flatMap((record) => { - const brand = brandWords(record); - return [record.model, ...(record.aliases || [])].map((name) => { - const nameWords = words(name); - return { - record, - brand, - allowed: new Set(nameWords), - required: nameWords.filter((word) => !isGeneric(word)), - hasCode: nameWords.some(isModelCode), - }; +/** 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 + * generation or suffix ("Mk II", "7000i" vs "7000") is never dropped. + * `hasCode` marks names carrying a letter+digit model code; names without + * one ("3950", "01959-004", "AUTODOME 800 Series") match only when the + * brand does. + */ + const nameIndex = records.flatMap((record) => { + const brand = new Set([ + ...words(record.brand), + ...(BRAND_ALIASES[record.brand] || []), + ]); + return [record.model, ...(record.aliases || [])].map((name) => { + const nameWords = words(name); + return { + record, + brand, + allowed: new Set(nameWords), + required: nameWords.filter((word) => !isGeneric(word)), + hasCode: nameWords.some(isModelCode), + }; + }); }); -}); + return (model, manufacturer) => { + const query = words(model).map(stripVariantSuffix); + if (!query.length) return null; + const maker = words(manufacturer); + const found = new Set(); + for (const entry of nameIndex) { + const makerMatches = maker.some((word) => entry.brand.has(word)); + if (maker.length && !makerMatches) continue; + if ( + !entry.hasCode && + !makerMatches && + !query.some((word) => entry.brand.has(word)) + ) + continue; + if (!entry.required.length) continue; + if (!entry.required.every((word) => query.includes(word))) continue; + if ( + !query.every( + (word) => + entry.allowed.has(word) || entry.brand.has(word) || isGeneric(word), + ) + ) + continue; + found.add(entry.record); + } + return found.size === 1 ? [...found][0] : null; + }; +} /** * Looks up a spec record for a hardware-model string. @@ -502,33 +529,7 @@ const NAME_INDEX = RECORDS.flatMap((record) => { * @param {string} [manufacturer] - The source's manufacturer, when published. * @returns {Object|null} The matched spec record, or null when unknown. */ -export function lookupModelSpec(model, manufacturer) { - const query = words(model).map(stripVariantSuffix); - if (!query.length) return null; - const maker = words(manufacturer); - const found = new Set(); - for (const entry of NAME_INDEX) { - const makerMatches = maker.some((word) => entry.brand.has(word)); - if (maker.length && !makerMatches) continue; - if ( - !entry.hasCode && - !makerMatches && - !query.some((word) => entry.brand.has(word)) - ) - continue; - if (!entry.required.length) continue; - if (!entry.required.every((word) => query.includes(word))) continue; - if ( - !query.every( - (word) => - entry.allowed.has(word) || entry.brand.has(word) || isGeneric(word), - ) - ) - continue; - found.add(entry.record); - } - return found.size === 1 ? [...found][0] : null; -} +export const lookupModelSpec = createModelSpecLookup(RECORDS); /** * Datasheet horizontal FOV as the range the hardware can cover. Only @@ -602,13 +603,19 @@ 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}`]; - if (spec.resolution?.label) parts.push(spec.resolution.label); + 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}`); + else if (mp) parts.push(`${mp}MP`); if (spec.night_vision) { parts.push( `${spec.night_vision.type.toUpperCase()}${spec.night_vision.range_m ? ` ${spec.night_vision.range_m}m` : ''}`,