From fd1a722b9e54d57d23ca7458b13f25aa4b304b11 Mon Sep 17 00:00:00 2001 From: Will Freeman Date: Tue, 18 Mar 2025 20:41:17 -0600 Subject: [PATCH] support cardinal directions; style improvements --- webapp/src/components/DFMapPopup.vue | 65 ++++++++++++++++++---------- webapp/src/components/LeafletMap.vue | 16 ++++++- 2 files changed, 56 insertions(+), 25 deletions(-) diff --git a/webapp/src/components/DFMapPopup.vue b/webapp/src/components/DFMapPopup.vue index 50e49fe..803cf7b 100644 --- a/webapp/src/components/DFMapPopup.vue +++ b/webapp/src/components/DFMapPopup.vue @@ -2,39 +2,50 @@ - mdi-face-recognition Face Recognition +
+ mdi-face-recognition Face Recognition +
- mdi-cctv License Plate Reader +
+ mdi-cctv License Plate Reader +
mdi-adjust Omnidirectional - mdi-compass-outline {{ cardinalDirection }} +
+ mdi-compass-outline {{ cardinalDirection }} +
- mdi-domain - - {{ alpr.tags.manufacturer }} - - - {{ alpr.tags.brand }} - - - Unspecified Manufacturer - - +
+ mdi-domain + + {{ alpr.tags.manufacturer }} + + + {{ alpr.tags.brand }} + + + Unspecified Manufacturer + + +
- mdi-account-tie - - {{ alpr.tags.operator }} - - - Unspecified Operator - - +
+ mdi-account-tie + + + {{ alpr.tags.operator }} + + + Unspecified Operator + + +
@@ -61,12 +72,18 @@ const isFaceRecognition = computed(() => props.alpr.tags.brand === 'Avigilon'); const cardinalDirection = computed(() => { const direction = props.alpr.tags.direction || props.alpr.tags["camera:direction"]; - return direction === undefined ? 'Unspecified Direction' : degreesToCardinal(parseInt(direction)) + if (direction === undefined) { + return 'Unspecified Direction'; + } else if (direction.includes(';')) { + return 'Faces Multiple Directions'; + } else { + return /^\d+$/.test(direction) ? degreesToCardinal(parseInt(direction)) : direction; + } } ); function degreesToCardinal(degrees: number): string { - const cardinals = ['North', 'Northeast', 'East', 'Southeast', 'South', 'Southwest', 'West', 'Northwest']; + const cardinals = ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NE']; return 'Faces ' + cardinals[Math.round(degrees / 45) % 8]; } diff --git a/webapp/src/components/LeafletMap.vue b/webapp/src/components/LeafletMap.vue index 62e2c33..a52b502 100644 --- a/webapp/src/components/LeafletMap.vue +++ b/webapp/src/components/LeafletMap.vue @@ -58,7 +58,7 @@ let currentLocationLayer: FeatureGroup; function createSVGMarkers(alpr: ALPR): string { const orientationValues = (alpr.tags.direction || alpr.tags['camera:direction'] || '') .split(';') - .map(val => val.trim()); + .map(val => /^\d+$/.test(val) ? parseInt(val) : cardinalToDegrees(val.trim())); const fovPath = ` @@ -80,6 +80,20 @@ function createSVGMarkers(alpr: ALPR): string { `; } +function cardinalToDegrees(cardinal: string): number { + const cardinalMap: Record = { + N: 0, + NE: 45, + E: 90, + SE: 135, + S: 180, + SW: 225, + W: 270, + NW: 315, + }; + return cardinalMap[cardinal] ?? cardinal; +} + function createMarker(alpr: ALPR): Marker | CircleMarker { if (hasPlottableOrientation(alpr.tags.direction || alpr.tags['camera:direction'])) { const icon = L.divIcon({