diff --git a/client/src/pages/MapView.jsx b/client/src/pages/MapView.jsx index 411e9d0..adeba89 100644 --- a/client/src/pages/MapView.jsx +++ b/client/src/pages/MapView.jsx @@ -73,8 +73,8 @@ const MapView = () => { const [devices, setDevices] = useState([]); const [selectedDevice, setSelectedDevice] = useState(null); const [loading, setLoading] = useState(true); - const [mapCenter, setMapCenter] = useState([59.3293, 18.0686]); // Stockholm default - const [mapZoom, setMapZoom] = useState(10); + const [mapCenter, setMapCenter] = useState([59.4, 18.1]); // Stockholm area center + const [mapZoom, setMapZoom] = useState(11); // Closer zoom for Stockholm area const [showDroneDetections, setShowDroneDetections] = useState(true); const [droneDetectionHistory, setDroneDetectionHistory] = useState([]); const { recentDetections, deviceStatus } = useSocket(); @@ -131,10 +131,15 @@ const MapView = () => { setDevices(deviceData); - // Set map center to first device with valid coordinates - const deviceWithCoords = deviceData.find(d => d.geo_lat && d.geo_lon); - if (deviceWithCoords && devices.length === 0) { - setMapCenter([deviceWithCoords.geo_lat, deviceWithCoords.geo_lon]); + // Set map bounds to Stockholm area with all three detectors + if (deviceData.length > 0 && devices.length === 0) { + // Stockholm area bounds that include Arlanda, Naval Base, and Royal Castle + const stockholmBounds = [ + [59.2, 17.8], // Southwest + [59.7, 18.4] // Northeast + ]; + setMapCenter([59.4, 18.1]); // Center of Stockholm area + setMapZoom(11); } } catch (error) { console.error('Error fetching devices:', error); @@ -216,12 +221,12 @@ const MapView = () => { zoom={mapZoom} className="h-full w-full" whenCreated={(map) => { - // Auto-fit to device locations if available - const validDevices = devices.filter(d => d.geo_lat && d.geo_lon); - if (validDevices.length > 1) { - const bounds = validDevices.map(d => [d.geo_lat, d.geo_lon]); - map.fitBounds(bounds, { padding: [20, 20] }); - } + // Set bounds to Stockholm area to show all three detectors + const stockholmBounds = [ + [59.2, 17.8], // Southwest + [59.7, 18.4] // Northeast + ]; + map.fitBounds(stockholmBounds, { padding: [20, 20] }); }} > { })} - {/* Map Legend */} -
-
Legend
-
+ {/* Map Legend - Fixed positioning and visibility */} +
+
Map Legend
+
-
- Device Online +
+ Device Online
-
- Device Detecting +
+ Device Detecting
-
- Device Offline +
+ Device Offline
{showDroneDetections && ( <> -
-
Drone Detections:
+
+
Drone Detections:
-
- Strong Signal (>-60dBm) +
+ Strong Signal (>-60dBm)
-
- Medium Signal (-60 to -70dBm) +
+ Medium Signal (-60 to -70dBm)
-
- Weak Signal (<-70dBm) +
+ Weak Signal (<-70dBm) +
+
+
+ Detection Range
)} diff --git a/server/seedDatabase.js b/server/seedDatabase.js index eba4ce8..7e77544 100644 --- a/server/seedDatabase.js +++ b/server/seedDatabase.js @@ -30,21 +30,46 @@ async function seedDatabase() { console.log('✅ Admin user already exists'); } - // Create a sample device if none exist + // Create sample devices if none exist const deviceCount = await Device.count(); if (deviceCount === 0) { - await Device.create({ - name: 'Drone Detector Alpha', - geo_lat: 59.3293, - geo_lon: 18.0686, - location_description: 'Stockholm Central', - is_active: true, - last_heartbeat: new Date(), - heartbeat_interval: 300, - firmware_version: '1.0.0' - }); + await Device.bulkCreate([ + { + id: 1, + name: 'Arlanda Airport Detector', + geo_lat: 59.6519, + geo_lon: 17.9186, + location_description: 'Arlanda Airport Security Zone', + is_active: true, + last_heartbeat: new Date(), + heartbeat_interval: 300, + firmware_version: '1.0.0' + }, + { + id: 2, + name: 'Musk Naval Base Detector', + geo_lat: 59.2753, + geo_lon: 18.2649, + location_description: 'Musk Naval Base Perimeter', + is_active: true, + last_heartbeat: new Date(), + heartbeat_interval: 300, + firmware_version: '1.0.0' + }, + { + id: 3, + name: 'Royal Castle Detector', + geo_lat: 59.3268, + geo_lon: 18.0717, + location_description: 'Royal Castle Security Zone', + is_active: true, + last_heartbeat: new Date(), + heartbeat_interval: 300, + firmware_version: '1.0.0' + } + ]); - console.log('✅ Sample device created'); + console.log('✅ Three detector devices created (Arlanda, Naval Base, Royal Castle)'); } else { console.log('✅ Devices already exist'); } diff --git a/test_drone_data.py b/test_drone_data.py index 6a054ea..8dd1c4d 100644 --- a/test_drone_data.py +++ b/test_drone_data.py @@ -19,24 +19,24 @@ API_BASE_URL = "http://selfservice.cqers.com/drones/api" DEVICES = [ { "id": 1, - "name": "Stockholm Central Detector", - "lat": 59.3293, - "lon": 18.0686, - "coverage_radius": 5.0 # km - }, - { - "id": 2, "name": "Arlanda Airport Detector", "lat": 59.6519, "lon": 17.9186, "coverage_radius": 8.0 # km }, { - "id": 3, - "name": "Göteborg Harbor Detector", - "lat": 57.7089, - "lon": 11.9746, + "id": 2, + "name": "Musk Naval Base Detector", + "lat": 59.2753, + "lon": 18.2649, "coverage_radius": 6.0 # km + }, + { + "id": 3, + "name": "Royal Castle Detector", + "lat": 59.3268, + "lon": 18.0717, + "coverage_radius": 4.0 # km } ]