mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 10:12:18 +00:00
feat(alpr): show datasheet specs for mapped ALPR camera models
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.
This commit is contained in:
1 parent
9d3548c27c
commit
52ebd8ac94
10 files changed
+452
-53
No files matched your search
@@ -0,0 +1,257 @@
|
||||
/**
|
||||
* @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 459 of those cameras — 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 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 } 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.
|
||||
*/
|
||||
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',
|
||||
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',
|
||||
],
|
||||
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',
|
||||
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'],
|
||||
},
|
||||
{
|
||||
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,
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
export const lookupAlprModelSpec = createModelSpecLookup(RECORDS);
|
||||
@@ -0,0 +1,100 @@
|
||||
// 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 { lookupAlprModelSpec } from './modelSpecs.js';
|
||||
import { normalizeAlprNode } from './records.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', 'Genetec', 'genetec-autovu-sharpv'],
|
||||
['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],
|
||||
['UnicamVELOCITY3', null],
|
||||
[null, '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 ',
|
||||
},
|
||||
});
|
||||
assert.equal(node.model, 'L6Q');
|
||||
assert.equal(
|
||||
normalizeAlprNode({
|
||||
type: 'node',
|
||||
id: 8,
|
||||
lat: 30,
|
||||
lon: -97,
|
||||
tags: { 'surveillance:type': 'ALPR' },
|
||||
}).model,
|
||||
null,
|
||||
);
|
||||
});
|
||||
|
||||
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 MOTOROLA SOLUTIONS VIGILANT L6Q · 1080P · IR',
|
||||
'PUBLIC MAP DATA',
|
||||
]);
|
||||
// A record without a resolution label falls back to its pixel size.
|
||||
assert.ok(
|
||||
alprLabelDetails(
|
||||
{ manufacturer: 'Motorola Solutions', model: 'L5F' },
|
||||
OSM,
|
||||
).includes('SPEC MOTOROLA SOLUTIONS VIGILANT L5F · 1440X1080 · IR'),
|
||||
);
|
||||
// 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)));
|
||||
});
|
||||
@@ -89,6 +89,8 @@ export function normalizeAlprNode(el) {
|
||||
longitude: el.lon,
|
||||
operator: textTag(tags.operator),
|
||||
manufacturer: textTag(tags.manufacturer),
|
||||
// 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")
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import * as Cesium from 'cesium';
|
||||
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,
|
||||
@@ -42,7 +44,10 @@ 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. */
|
||||
/**
|
||||
* Show only supplied metadata, with the actual source named for custom
|
||||
* adapters, plus the datasheet summary when the mapped model is known.
|
||||
*/
|
||||
export function alprLabelDetails(record, source) {
|
||||
const sourceName =
|
||||
source.attribution?.name || source.label || 'Camera source';
|
||||
@@ -63,6 +68,9 @@ 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 (sourceName === 'OpenStreetMap') details.push('PUBLIC MAP DATA');
|
||||
return details;
|
||||
}
|
||||
|
||||
@@ -387,33 +387,67 @@ 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.
|
||||
* 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.
|
||||
*/
|
||||
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),
|
||||
};
|
||||
export function createModelSpecLookup(records, brandAliases = BRAND_ALIASES) {
|
||||
/**
|
||||
* 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),
|
||||
...(brandAliases[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.
|
||||
@@ -433,33 +467,7 @@ const NAME_INDEX = RECORDS.flatMap((record) => {
|
||||
* @param {string} [manufacturer] - The source's manufacturer, when published.
|
||||
* @returns {Object|null} The verbatim 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
|
||||
@@ -539,7 +547,10 @@ export function specFovCapabilityToken(
|
||||
export function specSummary(spec) {
|
||||
if (!spec) return '';
|
||||
const parts = [`${spec.brand} ${spec.model}`];
|
||||
if (spec.resolution?.label) parts.push(spec.resolution.label);
|
||||
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` : ''}`,
|
||||
|
||||
Reference in new issue
Block a user