From 7b0e9ca6ae0f6d2b24e412d5390c1cc44522c127 Mon Sep 17 00:00:00 2001 From: Alexander Borg Date: Mon, 18 Aug 2025 09:14:23 +0200 Subject: [PATCH] Fix jwt-token --- client/src/pages/MapView.jsx | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/client/src/pages/MapView.jsx b/client/src/pages/MapView.jsx index c6185dd..a6cd8dc 100644 --- a/client/src/pages/MapView.jsx +++ b/client/src/pages/MapView.jsx @@ -139,7 +139,7 @@ const MapView = () => { const newDetection = { ...latestDetection, timestamp: Date.now(), - id: `${latestDetection.device_id}-${latestDetection.drone_id}-${latestDetection.device_timestamp}` + id: `${latestDetection.device_id}-${latestDetection.drone_id || 'unknown'}-${latestDetection.device_timestamp || Date.now()}` }; console.log('MapView: Adding to history:', newDetection); @@ -393,14 +393,25 @@ const MapView = () => { const dashPattern = getDashPattern(detection.drone_type, droneIndex, totalDrones); const [latOffset, lonOffset] = getPositionOffset(droneIndex, totalDrones); + // Ensure coordinates are numbers and properly calculated + const baseLat = parseFloat(detection.geo_lat) || 0; + const baseLon = parseFloat(detection.geo_lon) || 0; + const centerLat = baseLat + latOffset; + const centerLon = baseLon + lonOffset; + + console.log('MapView: Coordinate calculation - baseLat:', baseLat, 'baseLon:', baseLon, 'latOffset:', latOffset, 'lonOffset:', lonOffset, 'centerLat:', centerLat, 'centerLon:', centerLon); + + // Validate coordinates before rendering + if (!isFinite(centerLat) || !isFinite(centerLon) || centerLat < -90 || centerLat > 90 || centerLon < -180 || centerLon > 180) { + console.error('MapView: Invalid coordinates detected, skipping ring:', centerLat, centerLon); + return null; + } + return ( {/* Detection Ring around Detector (NOT drone position) */} { {totalDrones > 1 && age < 5 && ( // Show labels for recent detections with multiple drones