From ab44f83464bf1905528561a8443b9306ee327148 Mon Sep 17 00:00:00 2001 From: Alexander Borg Date: Sun, 7 Sep 2025 14:27:36 +0200 Subject: [PATCH] Fix jwt-token --- client/src/pages/MapView.jsx | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/client/src/pages/MapView.jsx b/client/src/pages/MapView.jsx index cba9a0b..286f4c2 100644 --- a/client/src/pages/MapView.jsx +++ b/client/src/pages/MapView.jsx @@ -394,17 +394,24 @@ const MapView = () => { return hasCoords; }); - // Group detections by detector position to handle multiple drones at same detector + // Group detections by detector device to handle multiple drones at same detector const detectionsByDetector = filteredDetections.reduce((acc, detection) => { - const key = `${detection.geo_lat}_${detection.geo_lon}`; + const key = detection.device_id; // Group by device_id instead of drone coordinates if (!acc[key]) acc[key] = []; acc[key].push(detection); return acc; }, {}); - return Object.entries(detectionsByDetector).flatMap(([detectorKey, detections]) => { + return Object.entries(detectionsByDetector).flatMap(([deviceId, detections]) => { + // Find the detector device for these detections + const detectorDevice = devices.find(d => d.id === parseInt(deviceId)); + if (!detectorDevice || !detectorDevice.geo_lat || !detectorDevice.geo_lon) { + console.warn('MapView: No device found or missing coordinates for device_id:', deviceId); + return []; + } + return detections.map((detection, droneIndex) => { - console.log('MapView: Rendering ring for detection:', detection, 'droneIndex:', droneIndex, 'totalDrones:', detections.length); + console.log('MapView: Rendering ring for detection:', detection, 'droneIndex:', droneIndex, 'totalDrones:', detections.length, 'detector device:', detectorDevice); const opacity = getDetectionOpacity(detection); const age = getDetectionAge(detection); console.log('MapView: Detection age:', age, 'opacity:', opacity); @@ -483,9 +490,9 @@ 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; + // Use detector device coordinates (NOT drone coordinates) + const baseLat = parseFloat(detectorDevice.geo_lat) || 0; + const baseLon = parseFloat(detectorDevice.geo_lon) || 0; const centerLat = baseLat + latOffset; const centerLon = baseLon + lonOffset;