| 1 | 'use client'; |
| 2 | |
| 3 | import { useEffect, useRef, useState, useCallback, memo } from 'react'; |
| 4 | import maplibregl from 'maplibre-gl'; |
| 5 | import 'maplibre-gl/dist/maplibre-gl.css'; |
| 6 | |
| 7 | interface OsirisMapProps { |
| 8 | data: any; |
| 9 | activeLayers: Record<string, boolean>; |
| 10 | onEntityClick?: (entity: any) => void; |
| 11 | onMouseCoords?: (coords: { lat: number; lng: number }) => void; |
| 12 | onRightClick?: (coords: { lat: number; lng: number }) => void; |
| 13 | onViewStateChange?: (vs: { zoom: number; latitude: number }) => void; |
| 14 | flyToLocation?: { lat: number; lng: number; ts: number } | null; |
| 15 | projection?: 'mercator' | 'globe'; |
| 16 | mapStyle?: string; |
| 17 | sweepData?: any; |
| 18 | scanTargets?: any[]; |
| 19 | } |
| 20 | |
| 21 | function computeSolarTerminator(): [number, number][] { |
| 22 | const now = new Date(); |
| 23 | const dayOfYear = Math.floor((now.getTime() - new Date(now.getFullYear(), 0, 0).getTime()) / 86400000); |
| 24 | const declination = -23.44 * Math.cos((2 * Math.PI / 365) * (dayOfYear + 10)); |
| 25 | const decRad = declination * Math.PI / 180; |
| 26 | const utcHours = now.getUTCHours() + now.getUTCMinutes() / 60; |
| 27 | const subsolarLng = (12 - utcHours) * 15; |
| 28 | const points: [number, number][] = []; |
| 29 | for (let lng = -180; lng <= 180; lng += 2) { |
| 30 | const lngRad = (lng - subsolarLng) * Math.PI / 180; |
| 31 | const lat = Math.atan(-Math.cos(lngRad) / Math.tan(decRad)) * 180 / Math.PI; |
| 32 | points.push([lng, lat]); |
| 33 | } |
| 34 | const darkSide = declination >= 0 ? -90 : 90; |
| 35 | points.push([180, darkSide]); |
| 36 | points.push([-180, darkSide]); |
| 37 | points.push(points[0]); |
| 38 | return points; |
| 39 | } |
| 40 | |
| 41 | const EMPTY_FC = { type: 'FeatureCollection' as const, features: [] }; |
| 42 | |
| 43 | function OsirisMap({ data, activeLayers, onEntityClick, onMouseCoords, onRightClick, onViewStateChange, flyToLocation, projection = 'globe', mapStyle = 'dark', sweepData, scanTargets = [] }: OsirisMapProps) { |
| 44 | const containerRef = useRef<HTMLDivElement>(null); |
| 45 | const mapRef = useRef<maplibregl.Map | null>(null); |
| 46 | const popupRef = useRef<maplibregl.Popup | null>(null); |
| 47 | const [mapReady, setMapReady] = useState(false); |
| 48 | const prevStyleRef = useRef(mapStyle); |
| 49 | |
| 50 | // Create aircraft icon on canvas (for WebGL symbol layer) |
| 51 | const createIcon = useCallback((map: maplibregl.Map, id: string, color: string, size: number) => { |
| 52 | if (map.hasImage(id)) return; |
| 53 | const canvas = document.createElement('canvas'); |
| 54 | canvas.width = size; canvas.height = size; |
| 55 | const ctx = canvas.getContext('2d')!; |
| 56 | const cx = size / 2, cy = size / 2; |
| 57 | ctx.fillStyle = color; |
| 58 | ctx.beginPath(); |
| 59 | ctx.moveTo(cx, cy - size * 0.4); |
| 60 | ctx.lineTo(cx - size * 0.12, cy + size * 0.1); |
| 61 | ctx.lineTo(cx - size * 0.4, cy + size * 0.2); |
| 62 | ctx.lineTo(cx - size * 0.4, cy + size * 0.3); |
| 63 | ctx.lineTo(cx - size * 0.12, cy + size * 0.15); |
| 64 | ctx.lineTo(cx, cy + size * 0.35); |
| 65 | ctx.lineTo(cx + size * 0.12, cy + size * 0.15); |
| 66 | ctx.lineTo(cx + size * 0.4, cy + size * 0.3); |
| 67 | ctx.lineTo(cx + size * 0.4, cy + size * 0.2); |
| 68 | ctx.lineTo(cx + size * 0.12, cy + size * 0.1); |
| 69 | ctx.closePath(); |
| 70 | ctx.fill(); |
| 71 | map.addImage(id, { width: size, height: size, data: new Uint8Array(ctx.getImageData(0, 0, size, size).data) }); |
| 72 | }, []); |
| 73 | |
| 74 | const createDot = useCallback((map: maplibregl.Map, id: string, color: string, size: number) => { |
| 75 | if (map.hasImage(id)) return; |
| 76 | const canvas = document.createElement('canvas'); |
| 77 | canvas.width = size; canvas.height = size; |
| 78 | const ctx = canvas.getContext('2d')!; |
| 79 | ctx.fillStyle = color; |
| 80 | ctx.beginPath(); |
| 81 | ctx.arc(size/2, size/2, size/2 - 1, 0, Math.PI * 2); |
| 82 | ctx.fill(); |
| 83 | map.addImage(id, { width: size, height: size, data: new Uint8Array(ctx.getImageData(0, 0, size, size).data) }); |
| 84 | }, []); |
| 85 | |
| 86 | useEffect(() => { |
| 87 | if (!containerRef.current || mapRef.current) return; |
| 88 | const map = new maplibregl.Map({ |
| 89 | container: containerRef.current, |
| 90 | style: 'https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json', |
| 91 | center: [25.48, 42.70], zoom: 6.5, minZoom: 1.5, maxZoom: 18, |
| 92 | attributionControl: false, |
| 93 | maxPitch: 85, |
| 94 | }); |
| 95 | |
| 96 | map.on('load', () => { |
| 97 | mapRef.current = map; |
| 98 | // Create icons |
| 99 | createIcon(map, 'plane-cyan', '#00E5FF', 24); |
| 100 | createIcon(map, 'plane-green', '#00E676', 24); |
| 101 | createIcon(map, 'plane-pink', '#FF69B4', 24); |
| 102 | createIcon(map, 'plane-red', '#FF3D3D', 24); |
| 103 | createIcon(map, 'plane-grey', '#555555', 24); |
| 104 | createDot(map, 'dot-gold', '#D4AF37', 8); |
| 105 | createDot(map, 'dot-red', '#FF3D3D', 10); |
| 106 | createDot(map, 'dot-orange', '#FF9500', 10); |
| 107 | createDot(map, 'dot-green', '#00E676', 10); |
| 108 | createDot(map, 'dot-fire', '#FF6B00', 10); |
| 109 | createDot(map, 'dot-cctv', '#39FF14', 10); |
| 110 | |
| 111 | // Sources |
| 112 | const sources = ['flights','military','jets','private-fl','satellites','earthquakes','gdelt','gps-jamming','day-night','cctv','fires','weather','infrastructure','maritime','maritime-choke','maritime-ships','live-news','sigint-news','conflict-zones', 'war-alerts-targets', 'war-alerts-lines', 'balloons', 'radiation', 'ip-sweep-devices', 'ip-sweep-pulse', 'ip-sweep-connections', 'scan-targets', 'sdk-entities', 'sdk-links']; |
| 113 | sources.forEach(s => map.addSource(s, { type: 'geojson', data: EMPTY_FC })); |
| 114 | |
| 115 | // Warning icon generator (parameterized — eliminates 3x copy-paste) |
| 116 | const createWarningIcon = (id: string, color: string) => { |
| 117 | const s = 20; |
| 118 | const c = document.createElement('canvas'); |
| 119 | c.width = s; c.height = s; |
| 120 | const ctx = c.getContext('2d')!; |
| 121 | ctx.fillStyle = color; |
| 122 | ctx.beginPath(); |
| 123 | ctx.moveTo(s/2, 1); |
| 124 | ctx.lineTo(s - 1, s - 1); |
| 125 | ctx.lineTo(1, s - 1); |
| 126 | ctx.closePath(); |
| 127 | ctx.fill(); |
| 128 | ctx.fillStyle = '#000'; |
| 129 | ctx.font = 'bold 11px sans-serif'; |
| 130 | ctx.textAlign = 'center'; |
| 131 | ctx.fillText('!', s/2, s - 4); |
| 132 | map.addImage(id, { width: s, height: s, data: new Uint8Array(ctx.getImageData(0, 0, s, s).data) }); |
| 133 | }; |
| 134 | createWarningIcon('warn-icon', '#FF1744'); |
| 135 | createWarningIcon('warn-orange', '#FF9500'); |
| 136 | createWarningIcon('warn-yellow', '#FFD500'); |
| 137 | |
| 138 | map.addLayer({ id: 'conflict-icons', type: 'symbol', source: 'conflict-zones', layout: { |
| 139 | 'icon-image': ['match', ['get','severity'], 'war','warn-icon', 'high','warn-orange', 'warn-yellow'], |
| 140 | 'icon-size': ['interpolate',['linear'],['zoom'], 1,0.6, 4,0.8, 8,1], |
| 141 | 'icon-allow-overlap': true, |
| 142 | 'text-field': ['get','label'], |
| 143 | 'text-size': ['interpolate',['linear'],['zoom'], 1,7, 4,9, 8,11], |
| 144 | 'text-font': ['Open Sans Bold'], |
| 145 | 'text-offset': [0, 1.4], |
| 146 | 'text-allow-overlap': false, |
| 147 | }, paint: { |
| 148 | 'text-color': ['match', ['get','severity'], 'war','#FF1744', 'high','#FF9500', '#FFD500'], |
| 149 | 'text-halo-color': '#000', 'text-halo-width': 1.5, 'text-opacity': 0.9, |
| 150 | }}); |
| 151 | |
| 152 | |
| 153 | // Day/Night |
| 154 | map.addLayer({ id: 'day-night-fill', type: 'fill', source: 'day-night', paint: { 'fill-color': '#000022', 'fill-opacity': 0.35 }}); |
| 155 | |
| 156 | // Earthquakes |
| 157 | map.addLayer({ id: 'eq-circles', type: 'circle', source: 'earthquakes', paint: { |
| 158 | 'circle-radius': ['interpolate',['linear'],['get','magnitude'], 2.5,4, 5,12, 7,24], |
| 159 | 'circle-color': ['interpolate',['linear'],['get','magnitude'], 2.5,'#FFD700', 4,'#FF9500', 6,'#FF1744'], |
| 160 | 'circle-opacity': 0.6, 'circle-blur': 0.3, 'circle-stroke-width': 1, 'circle-stroke-color': '#FFD700', 'circle-stroke-opacity': 0.3, |
| 161 | }}); |
| 162 | map.addLayer({ id: 'eq-label', type: 'symbol', source: 'earthquakes', filter: ['>=',['get','magnitude'],4.5], layout: { |
| 163 | 'text-field': ['concat','M',['to-string',['get','magnitude']]], 'text-size': 9, 'text-font': ['Open Sans Regular'], 'text-offset': [0,1.5], |
| 164 | }, paint: { 'text-color': '#FFD700', 'text-halo-color': '#000', 'text-halo-width': 1 }}); |
| 165 | |
| 166 | // Fires |
| 167 | map.addLayer({ id: 'fires-heat', type: 'circle', source: 'fires', paint: { |
| 168 | 'circle-radius': ['interpolate',['linear'],['zoom'], 1,2, 5,4, 10,8], |
| 169 | 'circle-color': '#FF6B00', 'circle-opacity': 0.5, 'circle-blur': 0.5, |
| 170 | }}); |
| 171 | |
| 172 | // CCTV — outer glow ring |
| 173 | map.addLayer({ id: 'cctv-glow', type: 'circle', source: 'cctv', paint: { |
| 174 | 'circle-radius': ['interpolate',['linear'],['zoom'], 1,5, 5,8, 10,14, 14,20], |
| 175 | 'circle-color': '#39FF14', 'circle-opacity': 0.08, 'circle-blur': 1, |
| 176 | }}); |
| 177 | // CCTV — main dot |
| 178 | map.addLayer({ id: 'cctv-dots', type: 'circle', source: 'cctv', paint: { |
| 179 | 'circle-radius': ['interpolate',['linear'],['zoom'], 1,3, 5,5, 10,8, 14,12], |
| 180 | 'circle-color': '#39FF14', 'circle-opacity': 0.8, |
| 181 | 'circle-stroke-width': 2, 'circle-stroke-color': '#39FF14', 'circle-stroke-opacity': 0.5, |
| 182 | }}); |
| 183 | // CCTV — labels at zoom 10+ |
| 184 | map.addLayer({ id: 'cctv-label', type: 'symbol', source: 'cctv', minzoom: 10, layout: { |
| 185 | 'text-field': ['get','name'], 'text-size': 9, 'text-font': ['Open Sans Regular'], |
| 186 | 'text-offset': [0, 1.8], 'text-max-width': 12, 'text-allow-overlap': false, |
| 187 | }, paint: { 'text-color': '#39FF14', 'text-halo-color': '#000', 'text-halo-width': 1, 'text-opacity': 0.7 }}); |
| 188 | |
| 189 | // GDELT |
| 190 | map.addLayer({ id: 'gdelt-dots', type: 'circle', source: 'gdelt', paint: { |
| 191 | 'circle-radius': 4, 'circle-color': '#FF3D3D', 'circle-opacity': 0.5, 'circle-stroke-width': 1, 'circle-stroke-color': '#FF3D3D', 'circle-stroke-opacity': 0.3, |
| 192 | }}); |
| 193 | |
| 194 | // GPS Jamming |
| 195 | map.addLayer({ id: 'jam-fill', type: 'circle', source: 'gps-jamming', paint: { 'circle-radius': 30, 'circle-color': '#FF0000', 'circle-opacity': 0.15, 'circle-blur': 1 }}); |
| 196 | map.addLayer({ id: 'jam-label', type: 'symbol', source: 'gps-jamming', layout: { |
| 197 | 'text-field': ['concat','GPS JAM ',['to-string',['get','severity']],'%'], 'text-size': 10, 'text-font': ['Open Sans Bold'], 'text-allow-overlap': true, |
| 198 | }, paint: { 'text-color': '#FF4444', 'text-halo-color': '#000', 'text-halo-width': 1 }}); |
| 199 | |
| 200 | // Weather Events (NASA EONET — storms, volcanoes) |
| 201 | map.addLayer({ id: 'weather-glow', type: 'circle', source: 'weather', paint: { |
| 202 | 'circle-radius': ['interpolate',['linear'],['zoom'], 1,12, 5,20, 10,30], |
| 203 | 'circle-color': '#E040FB', 'circle-opacity': 0.1, 'circle-blur': 1, |
| 204 | }}); |
| 205 | map.addLayer({ id: 'weather-dots', type: 'circle', source: 'weather', paint: { |
| 206 | 'circle-radius': ['interpolate',['linear'],['zoom'], 1,5, 5,8, 10,14], |
| 207 | 'circle-color': ['match', ['get','icon'], 'cyclone','#E040FB', 'volcano','#FF1744', '#E040FB'], |
| 208 | 'circle-opacity': 0.8, |
| 209 | 'circle-stroke-width': 2, 'circle-stroke-color': '#E040FB', 'circle-stroke-opacity': 0.4, |
| 210 | }}); |
| 211 | map.addLayer({ id: 'weather-label', type: 'symbol', source: 'weather', layout: { |
| 212 | 'text-field': ['get','title'], 'text-size': 9, 'text-font': ['Open Sans Regular'], |
| 213 | 'text-offset': [0, 2], 'text-max-width': 14, 'text-allow-overlap': false, |
| 214 | }, paint: { 'text-color': '#E040FB', 'text-halo-color': '#000', 'text-halo-width': 1, 'text-opacity': 0.8 }}); |
| 215 | |
| 216 | // Nuclear Infrastructure |
| 217 | map.addLayer({ id: 'infra-glow', type: 'circle', source: 'infrastructure', paint: { |
| 218 | 'circle-radius': ['interpolate',['linear'],['zoom'], 1,8, 5,14, 10,22], |
| 219 | 'circle-color': ['case', ['in', 'SEISMIC RISK', ['get', 'status']], '#FF9500', '#76FF03'], |
| 220 | 'circle-opacity': 0.08, 'circle-blur': 1, |
| 221 | }}); |
| 222 | map.addLayer({ id: 'infra-dots', type: 'circle', source: 'infrastructure', paint: { |
| 223 | 'circle-radius': ['interpolate',['linear'],['zoom'], 1,4, 5,6, 10,10], |
| 224 | 'circle-color': ['case', |
| 225 | ['in', 'SEISMIC RISK', ['get', 'status']], '#FF9500', |
| 226 | ['==', ['get','status'], 'Active Conflict Zone'], '#FF1744', |
| 227 | ['==', ['get','status'], 'Destroyed / Decommissioning'], '#757575', |
| 228 | '#76FF03' |
| 229 | ], |
| 230 | 'circle-opacity': 0.8, |
| 231 | 'circle-stroke-width': 2, 'circle-stroke-color': ['case', ['in', 'SEISMIC RISK', ['get', 'status']], '#FF9500', '#76FF03'], 'circle-stroke-opacity': 0.4, |
| 232 | }}); |
| 233 | map.addLayer({ id: 'infra-label', type: 'symbol', source: 'infrastructure', minzoom: 5, layout: { |
| 234 | 'text-field': ['get','name'], 'text-size': 9, 'text-font': ['Open Sans Regular'], |
| 235 | 'text-offset': [0, 2], 'text-max-width': 14, 'text-allow-overlap': false, |
| 236 | }, paint: { 'text-color': ['case', ['in', 'SEISMIC RISK', ['get', 'status']], '#FF9500', '#76FF03'], 'text-halo-color': '#000', 'text-halo-width': 1, 'text-opacity': 0.7 }}); |
| 237 | |
| 238 | // Satellites |
| 239 | map.addLayer({ id: 'sat-glow', type: 'circle', source: 'satellites', paint: { |
| 240 | 'circle-radius': ['interpolate',['linear'],['zoom'], 1,3, 5,6], 'circle-color': ['get','color'], 'circle-opacity': 0.3, 'circle-blur': 1, |
| 241 | }}); |
| 242 | map.addLayer({ id: 'sat-dots', type: 'circle', source: 'satellites', paint: { |
| 243 | 'circle-radius': ['interpolate',['linear'],['zoom'], 1,1.5, 5,3], 'circle-color': ['get','color'], 'circle-opacity': 1.0, |
| 244 | }}); |
| 245 | |
| 246 | // Maritime — ports & naval bases |
| 247 | map.addLayer({ id: 'maritime-glow', type: 'circle', source: 'maritime', paint: { |
| 248 | 'circle-radius': ['interpolate',['linear'],['zoom'], 1,6, 5,12, 10,20], |
| 249 | 'circle-color': ['match', ['get','type'], 'naval','#FF3D3D', 'energy','#FF9500', '#00BCD4'], |
| 250 | 'circle-opacity': 0.1, 'circle-blur': 1, |
| 251 | }}); |
| 252 | map.addLayer({ id: 'maritime-dots', type: 'circle', source: 'maritime', paint: { |
| 253 | 'circle-radius': ['interpolate',['linear'],['zoom'], 1,3, 5,5, 10,9], |
| 254 | 'circle-color': ['match', ['get','type'], 'naval','#FF3D3D', 'energy','#FF9500', '#00BCD4'], |
| 255 | 'circle-opacity': 0.85, |
| 256 | 'circle-stroke-width': 2, 'circle-stroke-color': ['match', ['get','type'], 'naval','#FF3D3D', 'energy','#FF9500', '#00BCD4'], 'circle-stroke-opacity': 0.4, |
| 257 | }}); |
| 258 | map.addLayer({ id: 'maritime-label', type: 'symbol', source: 'maritime', minzoom: 4, layout: { |
| 259 | 'text-field': ['get','name'], 'text-size': 9, 'text-font': ['Open Sans Regular'], |
| 260 | 'text-offset': [0, 1.8], 'text-max-width': 12, 'text-allow-overlap': false, |
| 261 | }, paint: { 'text-color': '#00BCD4', 'text-halo-color': '#000', 'text-halo-width': 1, 'text-opacity': 0.7 }}); |
| 262 | |
| 263 | // Maritime chokepoints — pulsing warning diamonds |
| 264 | map.addLayer({ id: 'choke-glow', type: 'circle', source: 'maritime-choke', paint: { |
| 265 | 'circle-radius': ['interpolate',['linear'],['zoom'], 1,10, 5,18, 10,28], |
| 266 | 'circle-color': '#FF9500', 'circle-opacity': 0.12, 'circle-blur': 1, |
| 267 | }}); |
| 268 | map.addLayer({ id: 'choke-dots', type: 'circle', source: 'maritime-choke', paint: { |
| 269 | 'circle-radius': ['interpolate',['linear'],['zoom'], 1,4, 5,7, 10,12], |
| 270 | 'circle-color': ['match', ['get','risk'], 'CRITICAL','#FF1744', 'HIGH','#FF9500', 'ELEVATED','#FFD700', '#00E676'], |
| 271 | 'circle-opacity': 0.9, |
| 272 | 'circle-stroke-width': 2, 'circle-stroke-color': '#FF9500', 'circle-stroke-opacity': 0.5, |
| 273 | }}); |
| 274 | map.addLayer({ id: 'choke-label', type: 'symbol', source: 'maritime-choke', minzoom: 3, layout: { |
| 275 | 'text-field': ['get','name'], 'text-size': 10, 'text-font': ['Open Sans Bold'], |
| 276 | 'text-offset': [0, 2], 'text-max-width': 14, 'text-allow-overlap': false, |
| 277 | }, paint: { 'text-color': '#FF9500', 'text-halo-color': '#000', 'text-halo-width': 1, 'text-opacity': 0.9 }}); |
| 278 | |
| 279 | // Live News — broadcast dots |
| 280 | map.addLayer({ id: 'news-glow', type: 'circle', source: 'live-news', paint: { |
| 281 | 'circle-radius': ['interpolate',['linear'],['zoom'], 1,8, 5,14, 10,22], |
| 282 | 'circle-color': '#FF4081', 'circle-opacity': 0.1, 'circle-blur': 1, |
| 283 | }}); |
| 284 | map.addLayer({ id: 'news-dots', type: 'circle', source: 'live-news', paint: { |
| 285 | 'circle-radius': ['interpolate',['linear'],['zoom'], 1,4, 5,6, 10,10], |
| 286 | 'circle-color': '#FF4081', 'circle-opacity': 0.85, |
| 287 | 'circle-stroke-width': 2, 'circle-stroke-color': '#FF4081', 'circle-stroke-opacity': 0.5, |
| 288 | }}); |
| 289 | map.addLayer({ id: 'news-label', type: 'symbol', source: 'live-news', minzoom: 4, layout: { |
| 290 | 'text-field': ['get','name'], 'text-size': 9, 'text-font': ['Open Sans Regular'], |
| 291 | 'text-offset': [0, 1.8], 'text-max-width': 12, 'text-allow-overlap': false, |
| 292 | }, paint: { 'text-color': '#FF4081', 'text-halo-color': '#000', 'text-halo-width': 1, 'text-opacity': 0.8 }}); |
| 293 | |
| 294 | // SIGINT RSS news - gold markers |
| 295 | map.addLayer({ id: 'sigint-news-glow', type: 'circle', source: 'sigint-news', paint: { |
| 296 | 'circle-radius': ['interpolate',['linear'],['zoom'], 1,6, 5,10, 10,18], |
| 297 | 'circle-color': '#D4AF37', 'circle-opacity': 0.12, 'circle-blur': 1, |
| 298 | }}); |
| 299 | map.addLayer({ id: 'sigint-news-dots', type: 'circle', source: 'sigint-news', paint: { |
| 300 | 'circle-radius': ['interpolate',['linear'],['zoom'], 1,3, 5,5, 10,8], |
| 301 | 'circle-color': '#D4AF37', 'circle-opacity': 0.9, |
| 302 | 'circle-stroke-width': 1.5, 'circle-stroke-color': '#FFF8DC', 'circle-stroke-opacity': 0.6, |
| 303 | }}); |
| 304 | map.addLayer({ id: 'sigint-news-label', type: 'symbol', source: 'sigint-news', minzoom: 5, layout: { |
| 305 | 'text-field': ['get','source'], 'text-size': 9, 'text-font': ['Open Sans Regular'], |
| 306 | 'text-offset': [0, 1.6], 'text-max-width': 10, 'text-allow-overlap': false, |
| 307 | }, paint: { 'text-color': '#D4AF37', 'text-halo-color': '#000', 'text-halo-width': 1, 'text-opacity': 0.85 }}); |
| 308 | |
| 309 | // ══ IP SWEEP — Neighborhood device visualization ══ |
| 310 | map.addLayer({ id: 'sweep-connections', type: 'line', source: 'ip-sweep-connections', paint: { |
| 311 | 'line-color': ['get', 'color'], 'line-width': 1, 'line-opacity': 0.3, 'line-dasharray': [2, 4], |
| 312 | }}); |
| 313 | map.addLayer({ id: 'sweep-pulse-ring', type: 'circle', source: 'ip-sweep-pulse', paint: { |
| 314 | 'circle-radius': ['interpolate',['linear'],['zoom'], 8,40, 12,80, 16,160], |
| 315 | 'circle-color': 'transparent', 'circle-opacity': 0.6, |
| 316 | 'circle-stroke-width': 2, 'circle-stroke-color': '#FF3D3D', 'circle-stroke-opacity': 0.4, |
| 317 | }}); |
| 318 | map.addLayer({ id: 'sweep-device-glow', type: 'circle', source: 'ip-sweep-devices', paint: { |
| 319 | 'circle-radius': ['interpolate',['linear'],['zoom'], 8,8, 12,16, 16,30], |
| 320 | 'circle-color': ['get', 'color'], 'circle-opacity': 0.15, 'circle-blur': 1, |
| 321 | }}); |
| 322 | map.addLayer({ id: 'sweep-device-dots', type: 'circle', source: 'ip-sweep-devices', paint: { |
| 323 | 'circle-radius': ['interpolate',['linear'],['zoom'], 8,3, 12,6, 16,10], |
| 324 | 'circle-color': ['get', 'color'], 'circle-opacity': 0.95, |
| 325 | 'circle-stroke-width': 1.5, 'circle-stroke-color': '#FFFFFF', 'circle-stroke-opacity': 0.6, |
| 326 | }}); |
| 327 | map.addLayer({ id: 'sweep-device-labels', type: 'symbol', source: 'ip-sweep-devices', minzoom: 13, layout: { |
| 328 | 'text-field': ['concat', ['get', 'device_type'], '\n', ['get', 'ip']], |
| 329 | 'text-size': 9, 'text-font': ['Open Sans Regular'], |
| 330 | 'text-offset': [0, 2.2], 'text-max-width': 12, 'text-allow-overlap': false, |
| 331 | }, paint: { |
| 332 | 'text-color': ['get', 'color'], 'text-halo-color': '#000', 'text-halo-width': 1.5, 'text-opacity': 0.9, |
| 333 | }}); |
| 334 | |
| 335 | // ══ SCAN TARGETS — Geolocated individual scans ══ |
| 336 | map.addLayer({ id: 'scan-targets-glow', type: 'circle', source: 'scan-targets', paint: { |
| 337 | 'circle-radius': ['interpolate',['linear'],['zoom'], 1,12, 5,25, 10,40], |
| 338 | 'circle-color': '#FF3D3D', 'circle-opacity': 0.2, 'circle-blur': 1, |
| 339 | }}); |
| 340 | map.addLayer({ id: 'scan-targets-dots', type: 'circle', source: 'scan-targets', paint: { |
| 341 | 'circle-radius': ['interpolate',['linear'],['zoom'], 1,5, 5,8, 10,12], |
| 342 | 'circle-color': '#FF3D3D', 'circle-opacity': 0.95, |
| 343 | 'circle-stroke-width': 2, 'circle-stroke-color': '#FFFFFF', 'circle-stroke-opacity': 0.8, |
| 344 | }}); |
| 345 | map.addLayer({ id: 'scan-targets-label', type: 'symbol', source: 'scan-targets', layout: { |
| 346 | 'text-field': ['get', 'id'], 'text-size': 11, 'text-font': ['Open Sans Bold'], |
| 347 | 'text-offset': [0, 2], 'text-max-width': 14, 'text-allow-overlap': false, |
| 348 | }, paint: { 'text-color': '#FF3D3D', 'text-halo-color': '#000', 'text-halo-width': 1.5, 'text-opacity': 0.9 }}); |
| 349 | |
| 350 | // Flight layers (WebGL symbol — GPU rendered, handles 50K+ smooth) |
| 351 | const flightLayers = [ |
| 352 | { id: 'fl-commercial', src: 'flights', icon: 'plane-cyan' }, |
| 353 | { id: 'fl-private', src: 'private-fl', icon: 'plane-green' }, |
| 354 | { id: 'fl-jets', src: 'jets', icon: 'plane-pink' }, |
| 355 | { id: 'fl-military', src: 'military', icon: 'plane-red' }, |
| 356 | ]; |
| 357 | flightLayers.forEach(l => { |
| 358 | map.addLayer({ id: l.id, type: 'symbol', source: l.src, layout: { |
| 359 | 'icon-image': l.icon, 'icon-size': ['interpolate',['linear'],['zoom'], 1,0.4, 5,0.7, 10,1], |
| 360 | 'icon-rotate': ['get','heading'], 'icon-rotation-alignment': 'map', 'icon-allow-overlap': true, 'icon-ignore-placement': true, |
| 361 | }, paint: { 'icon-opacity': 0.85 }}); |
| 362 | }); |
| 363 | |
| 364 | // Balloons (moving entities) |
| 365 | map.addLayer({ id: 'balloon-dots', type: 'circle', source: 'balloons', paint: { |
| 366 | 'circle-radius': ['interpolate',['linear'],['zoom'], 1,3, 5,5, 10,7], |
| 367 | 'circle-color': ['get', 'color'], |
| 368 | 'circle-opacity': 0.8, |
| 369 | 'circle-stroke-width': 1, 'circle-stroke-color': '#fff', 'circle-stroke-opacity': 0.5, |
| 370 | }}); |
| 371 | map.addLayer({ id: 'balloon-label', type: 'symbol', source: 'balloons', minzoom: 4, layout: { |
| 372 | 'text-field': ['get','callsign'], 'text-size': 9, 'text-font': ['Open Sans Regular'], |
| 373 | 'text-offset': [0, 1.2], 'text-max-width': 12, 'text-allow-overlap': false, |
| 374 | }, paint: { 'text-color': ['get', 'color'], 'text-halo-color': '#000', 'text-halo-width': 1 }}); |
| 375 | |
| 376 | // Radiation (glow based on reading level) |
| 377 | map.addLayer({ id: 'rad-glow', type: 'circle', source: 'radiation', paint: { |
| 378 | 'circle-radius': ['interpolate',['linear'],['zoom'], 1,10, 5,20, 10,40], |
| 379 | 'circle-color': ['match', ['get','status'], 'DANGER','#FF1744', 'WARNING','#FF9500', '#AB47BC'], |
| 380 | 'circle-opacity': 0.15, 'circle-blur': 1, |
| 381 | }}); |
| 382 | map.addLayer({ id: 'rad-dots', type: 'circle', source: 'radiation', paint: { |
| 383 | 'circle-radius': ['interpolate',['linear'],['zoom'], 1,4, 5,6, 10,8], |
| 384 | 'circle-color': ['match', ['get','status'], 'DANGER','#FF1744', 'WARNING','#FF9500', '#AB47BC'], |
| 385 | 'circle-opacity': 0.9, |
| 386 | 'circle-stroke-width': 2, 'circle-stroke-color': ['match', ['get','status'], 'DANGER','#FF1744', 'WARNING','#FF9500', '#AB47BC'], 'circle-stroke-opacity': 0.4, |
| 387 | }}); |
| 388 | map.addLayer({ id: 'rad-label', type: 'symbol', source: 'radiation', minzoom: 5, layout: { |
| 389 | 'text-field': ['concat', ['to-string', ['get','reading']], ' nSv/h'], 'text-size': 9, 'text-font': ['Open Sans Bold'], |
| 390 | 'text-offset': [0, 1.5], 'text-allow-overlap': false, |
| 391 | }, paint: { 'text-color': ['match', ['get','status'], 'DANGER','#FF1744', 'WARNING','#FF9500', '#AB47BC'], 'text-halo-color': '#000', 'text-halo-width': 1 }}); |
| 392 | |
| 393 | // ══ OSIRIS SDK — Lattice Intelligence Mesh ══ |
| 394 | |
| 395 | // -- GLOW LAYERS -- |
| 396 | map.addLayer({ id: 'sdk-sea-glow', type: 'line', source: 'sdk-links', filter: ['==',['get','domain'],'SEA'], paint: { |
| 397 | 'line-color': '#4FC3F7', |
| 398 | 'line-width': ['interpolate',['linear'],['zoom'], 1, 3, 5, 6, 10, 10], |
| 399 | 'line-opacity': ['interpolate',['linear'],['zoom'], 1, 0.15, 5, 0.25, 10, 0.35], |
| 400 | 'line-blur': 4, |
| 401 | }}); |
| 402 | map.addLayer({ id: 'sdk-air-glow', type: 'line', source: 'sdk-links', filter: ['==',['get','domain'],'AIR'], paint: { |
| 403 | 'line-color': '#B3E5FC', |
| 404 | 'line-width': ['interpolate',['linear'],['zoom'], 1, 2, 5, 4, 10, 8], |
| 405 | 'line-opacity': ['interpolate',['linear'],['zoom'], 1, 0.1, 5, 0.15, 10, 0.2], |
| 406 | 'line-blur': 3, |
| 407 | }}); |
| 408 | map.addLayer({ id: 'sdk-intel-glow', type: 'line', source: 'sdk-links', filter: ['==',['get','domain'],'INTEL'], paint: { |
| 409 | 'line-color': '#81D4FA', |
| 410 | 'line-width': ['interpolate',['linear'],['zoom'], 1, 2, 5, 4, 10, 6], |
| 411 | 'line-opacity': ['interpolate',['linear'],['zoom'], 1, 0.08, 5, 0.12, 10, 0.18], |
| 412 | 'line-blur': 2, |
| 413 | }}); |
| 414 | |
| 415 | // -- CORE LINES -- |
| 416 | // Maritime routes — solid, brightest |
| 417 | map.addLayer({ id: 'sdk-sea', type: 'line', source: 'sdk-links', filter: ['==',['get','domain'],'SEA'], paint: { |
| 418 | 'line-color': '#4FC3F7', |
| 419 | 'line-width': ['interpolate',['linear'],['zoom'], 1, 0.6, 5, 1.2, 10, 2], |
| 420 | 'line-opacity': ['interpolate',['linear'],['zoom'], 1, 0.4, 5, 0.6, 10, 0.9], |
| 421 | }}); |
| 422 | // Air corridors — dashed, medium |
| 423 | map.addLayer({ id: 'sdk-air', type: 'line', source: 'sdk-links', filter: ['==',['get','domain'],'AIR'], paint: { |
| 424 | 'line-color': '#B3E5FC', |
| 425 | 'line-width': ['interpolate',['linear'],['zoom'], 1, 0.4, 5, 0.9, 10, 1.6], |
| 426 | 'line-opacity': ['interpolate',['linear'],['zoom'], 1, 0.25, 5, 0.4, 10, 0.6], |
| 427 | 'line-dasharray': [6, 3], |
| 428 | }}); |
| 429 | // Naval/Intel — dotted, subtle |
| 430 | map.addLayer({ id: 'sdk-intel', type: 'line', source: 'sdk-links', filter: ['==',['get','domain'],'INTEL'], paint: { |
| 431 | 'line-color': '#81D4FA', |
| 432 | 'line-width': ['interpolate',['linear'],['zoom'], 1, 0.3, 5, 0.7, 10, 1.2], |
| 433 | 'line-opacity': ['interpolate',['linear'],['zoom'], 1, 0.2, 5, 0.35, 10, 0.5], |
| 434 | 'line-dasharray': [2, 4], |
| 435 | }}); |
| 436 | |
| 437 | // Maritime Ships (moving entities) |
| 438 | map.addLayer({ id: 'ship-dots', type: 'circle', source: 'maritime-ships', paint: { |
| 439 | 'circle-radius': ['interpolate',['linear'],['zoom'], 1,2, 5,4, 10,6], |
| 440 | 'circle-color': ['match', ['get','type'], 'military','#FF1744', 'tanker','#FF9500', 'cargo','#00BCD4', '#fff'], |
| 441 | 'circle-opacity': 0.8, |
| 442 | }}); |
| 443 | map.addLayer({ id: 'ship-label', type: 'symbol', source: 'maritime-ships', minzoom: 5, layout: { |
| 444 | 'text-field': ['get','name'], 'text-size': 9, 'text-font': ['Open Sans Regular'], |
| 445 | 'text-offset': [0, 1.2], 'text-allow-overlap': false, |
| 446 | }, paint: { 'text-color': ['match', ['get','type'], 'military','#FF1744', 'tanker','#FF9500', 'cargo','#00BCD4', '#fff'], 'text-halo-color': '#000', 'text-halo-width': 1 }}); |
| 447 | |
| 448 | setMapReady(true); |
| 449 | }); |
| 450 | |
| 451 | // Events |
| 452 | let lastMove = 0; |
| 453 | map.on('mousemove', e => { |
| 454 | const now = Date.now(); |
| 455 | if (now - lastMove > 100) { |
| 456 | lastMove = now; |
| 457 | onMouseCoords?.({ lat: e.lngLat.lat, lng: e.lngLat.lng }); |
| 458 | } |
| 459 | }); |
| 460 | map.on('contextmenu', e => { e.preventDefault(); onRightClick?.({ lat: e.lngLat.lat, lng: e.lngLat.lng }); }); |
| 461 | map.on('moveend', () => { const c = map.getCenter(); onViewStateChange?.({ zoom: map.getZoom(), latitude: c.lat }); }); |
| 462 | |
| 463 | // ── POPUP HELPER ── |
| 464 | const popup = (coords: any, html: string) => { |
| 465 | popupRef.current?.remove(); |
| 466 | popupRef.current = new maplibregl.Popup({ closeButton: true, maxWidth: '420px', offset: 14 }).setLngLat(coords).setHTML(html).addTo(map); |
| 467 | }; |
| 468 | const pStyle = `background:rgba(12,14,26,0.95);backdrop-filter:blur(16px);border-radius:10px;padding:16px;font-family:'JetBrains Mono',monospace;`; |
| 469 | const linkStyle = `display:inline-block;margin-top:8px;padding:5px 12px;font-size:10px;letter-spacing:0.12em;text-decoration:none;border-radius:5px;font-family:'JetBrains Mono',monospace;`; |
| 470 | |
| 471 | // ── Flights (with FlightAware + ADS-B Exchange links) ── |
| 472 | ['fl-commercial','fl-private','fl-jets','fl-military'].forEach(layer => { |
| 473 | map.on('click', layer, e => { |
| 474 | if (!e.features?.length) return; |
| 475 | const p = e.features[0].properties as any; |
| 476 | const coords = (e.features[0].geometry as any).coordinates; |
| 477 | const cs = (p.callsign||'').trim(); |
| 478 | popup(coords, `<div style="${pStyle}border:1px solid rgba(212,175,55,0.3);"> |
| 479 | <div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:10px;"> |
| 480 | <span style="color:#D4AF37;font-size:16px;font-weight:700;letter-spacing:0.1em;">${cs}</span> |
| 481 | <span style="color:#5C5A54;font-size:10px;">${p.icao24||''}</span> |
| 482 | </div> |
| 483 | <div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:8px;font-size:11px;"> |
| 484 | <div><span style="color:#5C5A54;font-size:9px;">MODEL</span><br/><span style="color:#E8E6E0;">${p.model||'—'}</span></div> |
| 485 | <div><span style="color:#5C5A54;font-size:9px;">ALT</span><br/><span style="color:#00E5FF;">${p.alt?Math.round(p.alt)+'m':'—'}</span></div> |
| 486 | <div><span style="color:#5C5A54;font-size:9px;">SPEED</span><br/><span style="color:#E8E6E0;">${p.speed_knots||'—'}kt</span></div> |
| 487 | <div><span style="color:#5C5A54;font-size:9px;">HDG</span><br/><span style="color:#E8E6E0;">${Math.round(p.heading||0)}°</span></div> |
| 488 | <div><span style="color:#5C5A54;font-size:9px;">REG</span><br/><span style="color:#E8E6E0;">${p.registration||'—'}</span></div> |
| 489 | <div><span style="color:#5C5A54;font-size:9px;">POS</span><br/><span style="color:#E8E6E0;">${coords[1].toFixed(2)},${coords[0].toFixed(2)}</span></div> |
| 490 | </div> |
| 491 | <div style="margin-top:12px;display:flex;gap:6px;flex-wrap:wrap;"> |
| 492 | <a href="https://www.flightaware.com/live/flight/${cs}" target="_blank" style="${linkStyle}color:#D4AF37;border:1px solid rgba(212,175,55,0.4);background:rgba(212,175,55,0.1);">⚡ FLIGHTAWARE</a> |
| 493 | <a href="https://globe.adsbexchange.com/?icao=${p.icao24||''}" target="_blank" style="${linkStyle}color:#00E5FF;border:1px solid rgba(0,229,255,0.4);background:rgba(0,229,255,0.1);">📡 ADS-B</a> |
| 494 | <a href="https://www.radarbox.com/data/flights/${cs}" target="_blank" style="${linkStyle}color:#FF69B4;border:1px solid rgba(255,105,180,0.4);background:rgba(255,105,180,0.1);">📍 RADARBOX</a> |
| 495 | </div> |
| 496 | </div>`); |
| 497 | onEntityClick?.(p); |
| 498 | }); |
| 499 | map.on('mouseenter', layer, () => { map.getCanvas().style.cursor = 'pointer'; }); |
| 500 | map.on('mouseleave', layer, () => { map.getCanvas().style.cursor = ''; }); |
| 501 | }); |
| 502 | |
| 503 | // ── CCTV (opens CameraViewer panel) ── |
| 504 | map.on('click', 'cctv-dots', e => { |
| 505 | if (!e.features?.length) return; |
| 506 | const p = e.features[0].properties as any; |
| 507 | const coords = (e.features[0].geometry as any).coordinates; |
| 508 | // Emit the camera data so the CameraViewer opens |
| 509 | onEntityClick?.({ |
| 510 | type: 'cctv', |
| 511 | id: p.id, |
| 512 | name: p.name, |
| 513 | city: p.city, |
| 514 | country: p.country, |
| 515 | source: p.source, |
| 516 | feed_url: p.feed_url, |
| 517 | stream_url: p.stream_url, |
| 518 | stream_type: p.stream_type, |
| 519 | external_url: p.external_url, |
| 520 | lat: coords[1], |
| 521 | lng: coords[0], |
| 522 | }); |
| 523 | // Also fly to the camera |
| 524 | map.flyTo({ center: coords, zoom: Math.max(map.getZoom(), 13), duration: 1000 }); |
| 525 | }); |
| 526 | |
| 527 | // ── Earthquakes (with USGS link) ── |
| 528 | map.on('click', 'eq-circles', e => { |
| 529 | if (!e.features?.length) return; |
| 530 | const p = e.features[0].properties as any; |
| 531 | const coords = (e.features[0].geometry as any).coordinates; |
| 532 | popup(coords, `<div style="${pStyle}border:1px solid rgba(255,149,0,0.3);"> |
| 533 | <div style="color:#FF9500;font-size:14px;font-weight:700;margin-bottom:4px;">M${p.magnitude} EARTHQUAKE</div> |
| 534 | <div style="font-size:9px;color:#E8E6E0;margin-bottom:8px;">${p.place||'Unknown location'}</div> |
| 535 | <div style="display:grid;grid-template-columns:1fr 1fr;gap:4px;font-size:9px;"> |
| 536 | <div><span style="color:#5C5A54;">DEPTH</span><br/><span style="color:#E8E6E0;">${p.depth||'—'}km</span></div> |
| 537 | <div><span style="color:#5C5A54;">COORDS</span><br/><span style="color:#E8E6E0;">${coords[1].toFixed(3)}, ${coords[0].toFixed(3)}</span></div> |
| 538 | </div> |
| 539 | <a href="${p.source === 'NIGGG-BAS' ? 'https://ndc.niggg.bas.bg/' : `https://earthquake.usgs.gov/earthquakes/eventpage/${p.id||''}`}" target="_blank" style="${linkStyle}color:#FF9500;border:1px solid rgba(255,149,0,0.4);background:rgba(255,149,0,0.1);">📊 ${p.source === 'NIGGG-BAS' ? 'NIGGG-BAS' : 'USGS DETAILS'}</a> |
| 540 | </div>`); |
| 541 | }); |
| 542 | |
| 543 | // ── Satellites (SatNOGS powered) ── |
| 544 | map.on('click', 'sat-dots', e => { |
| 545 | if (!e.features?.length) return; |
| 546 | const p = e.features[0].properties as any; |
| 547 | const coords = (e.features[0].geometry as any).coordinates; |
| 548 | popup(coords, `<div style="${pStyle}border:1px solid rgba(212,175,55,0.3);"> |
| 549 | <div style="color:#D4AF37;font-size:12px;font-weight:700;letter-spacing:0.1em;margin-bottom:4px;">🛰️ ${p.name}</div> |
| 550 | <div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:4px;font-size:9px;margin-bottom:8px;"> |
| 551 | <div><span style="color:#5C5A54;">MISSION</span><br/><span style="color:${p.color||'#aaa'};">${p.mission||'Unknown'}</span></div> |
| 552 | <div><span style="color:#5C5A54;">ALT</span><br/><span style="color:#00E5FF;">${p.alt ? p.alt+' km' : '—'}</span></div> |
| 553 | <div><span style="color:#5C5A54;">POS</span><br/><span style="color:#E8E6E0;">${coords[1].toFixed(2)}°, ${coords[0].toFixed(2)}°</span></div> |
| 554 | </div> |
| 555 | ${p.noradId ? `<a href="https://db.satnogs.org/satellite/${p.noradId}/" target="_blank" style="display:block;text-align:center;padding:4px;margin-top:6px;font-size:8px;font-family:monospace;letter-spacing:0.1em;text-decoration:none;color:#00E5FF;border:1px solid rgba(0,229,255,0.4);background:rgba(0,229,255,0.1);border-radius:2px;cursor:pointer;">🔭 SOURCE: SATNOGS</a>` : ''} |
| 556 | </div>`); |
| 557 | }); |
| 558 | |
| 559 | // ── Fires (with NASA FIRMS link) ── |
| 560 | map.on('click', 'fires-heat', e => { |
| 561 | if (!e.features?.length) return; |
| 562 | const p = e.features[0].properties as any; |
| 563 | const coords = (e.features[0].geometry as any).coordinates; |
| 564 | popup(coords, `<div style="${pStyle}border:1px solid rgba(255,107,0,0.3);"> |
| 565 | <div style="color:#FF6B00;font-size:12px;font-weight:700;margin-bottom:6px;">🔥 ACTIVE FIRE DETECTED</div> |
| 566 | <div style="display:grid;grid-template-columns:1fr 1fr;gap:4px;font-size:9px;margin-bottom:8px;"> |
| 567 | <div><span style="color:#5C5A54;">BRIGHTNESS</span><br/><span style="color:#FF6B00;">${p.brightness||'—'}K</span></div> |
| 568 | <div><span style="color:#5C5A54;">COORDS</span><br/><span style="color:#E8E6E0;">${coords[1].toFixed(3)}°, ${coords[0].toFixed(3)}°</span></div> |
| 569 | </div> |
| 570 | <a href="https://firms.modaps.eosdis.nasa.gov/map/#d:24hrs;l:noaa20-viirs,viirs,modis_a,modis_t;@${coords[0]},${coords[1]},10z" target="_blank" style="${linkStyle}color:#FF6B00;border:1px solid rgba(255,107,0,0.4);background:rgba(255,107,0,0.1);">🛰️ NASA FIRMS MAP</a> |
| 571 | </div>`); |
| 572 | }); |
| 573 | |
| 574 | // ── GDELT Conflicts (with source article) ── |
| 575 | map.on('click', 'gdelt-dots', e => { |
| 576 | if (!e.features?.length) return; |
| 577 | const p = e.features[0].properties as any; |
| 578 | const coords = (e.features[0].geometry as any).coordinates; |
| 579 | popup(coords, `<div style="${pStyle}border:1px solid rgba(255,61,61,0.3);"> |
| 580 | <div style="color:#FF3D3D;font-size:12px;font-weight:700;margin-bottom:6px;">⚠️ CONFLICT EVENT</div> |
| 581 | <div style="font-size:9px;color:#E8E6E0;margin-bottom:8px;line-height:1.4;">${p.name||'Unclassified incident'}</div> |
| 582 | <div style="display:flex;gap:6px;"> |
| 583 | ${p.url ? `<a href="${p.url}" target="_blank" style="${linkStyle}color:#FF3D3D;border:1px solid rgba(255,61,61,0.4);background:rgba(255,61,61,0.1);">SOURCE</a>` : ''} |
| 584 | <a href="https://www.google.com/maps/@${coords[1]},${coords[0]},12z" target="_blank" style="${linkStyle}color:#448AFF;border:1px solid rgba(68,138,255,0.4);background:rgba(68,138,255,0.1);">MAP</a> |
| 585 | </div> |
| 586 | </div>`); |
| 587 | }); |
| 588 | |
| 589 | // ── Global Event / Conflict Markers ── |
| 590 | map.on('click', 'conflict-icons', e => { |
| 591 | if (!e.features?.length) return; |
| 592 | const p = e.features[0].properties as any; |
| 593 | const coords = (e.features[0].geometry as any).coordinates; |
| 594 | const color = p.severity === 'war' ? '#FF1744' : p.severity === 'high' ? '#FF9500' : '#FFD500'; |
| 595 | popup(coords, `<div style="${pStyle}border:1px solid ${color}40;"> |
| 596 | <div style="color:${color};font-size:12px;font-weight:700;margin-bottom:6px;">⚠️ ${p.label || 'WARNING EVENT'}</div> |
| 597 | <div style="font-size:10px;color:#E8E6E0;margin-bottom:8px;line-height:1.4;">${p.description || 'Global event detected at this location.'}</div> |
| 598 | <div style="display:grid;grid-template-columns:1fr 1fr;gap:4px;font-size:9px;margin-bottom:8px;"> |
| 599 | <div><span style="color:#5C5A54;">SEVERITY</span><br/><span style="color:${color};">${(p.severity||'unknown').toUpperCase()}</span></div> |
| 600 | <div><span style="color:#5C5A54;">COORDS</span><br/><span style="color:#E8E6E0;">${coords[1].toFixed(3)}°, ${coords[0].toFixed(3)}°</span></div> |
| 601 | </div> |
| 602 | </div>`); |
| 603 | }); |
| 604 | |
| 605 | |
| 606 | // ── OSIRIS SDK link click ── |
| 607 | const SDK_SOURCE_URLS: Record<string, string> = { |
| 608 | 'AIS Maritime': 'https://www.marinetraffic.com', |
| 609 | 'AIS Stream': 'https://aisstream.io', |
| 610 | 'AIS → Lattice': 'https://aisstream.io', |
| 611 | 'ADS-B / OpenSky': 'https://opensky-network.org', |
| 612 | 'ADS-B → Lattice': 'https://opensky-network.org', |
| 613 | 'Naval Intelligence': 'https://www.odni.gov', |
| 614 | }; |
| 615 | ['sdk-sea','sdk-sea-glow','sdk-air','sdk-air-glow','sdk-intel','sdk-intel-glow'].forEach(layer => { |
| 616 | map.on('click', layer, e => { |
| 617 | if (!e.features?.length) return; |
| 618 | const p = e.features[0].properties as any; |
| 619 | const coords = e.lngLat; |
| 620 | const srcUrl = p.url || SDK_SOURCE_URLS[p.source] || 'https://osirisai.live'; |
| 621 | const domainLabel = p.domain === 'SEA' ? '⚓ MARITIME' : p.domain === 'AIR' ? '✈ AIR CORRIDOR' : '🛡 NAVAL INTEL'; |
| 622 | const domainColor = p.domain === 'SEA' ? '#4FC3F7' : p.domain === 'AIR' ? '#B3E5FC' : '#81D4FA'; |
| 623 | const linkStyle = 'text-decoration:none;padding:3px 8px;border-radius:4px;font-size:9px;font-weight:700;letter-spacing:0.05em;'; |
| 624 | popup([coords.lng, coords.lat], `<div style="${pStyle}border:1px solid ${domainColor}40;"> |
| 625 | <div style="display:flex;align-items:center;gap:6px;margin-bottom:8px;"> |
| 626 | <div style="width:8px;height:8px;border-radius:50%;background:${domainColor};box-shadow:0 0 8px ${domainColor};"></div> |
| 627 | <span style="color:${domainColor};font-size:11px;font-weight:700;letter-spacing:0.1em;">${domainLabel}</span> |
| 628 | </div> |
| 629 | <div style="display:grid;grid-template-columns:1fr 1fr;gap:6px;font-size:9px;margin-bottom:8px;"> |
| 630 | <div><span style="color:#5C5A54;">FROM</span><br/><span style="color:#E8E6E0;">${p.fromName || 'Origin'}</span></div> |
| 631 | <div><span style="color:#5C5A54;">TO</span><br/><span style="color:#E8E6E0;">${p.toName || 'Destination'}</span></div> |
| 632 | <div><span style="color:#5C5A54;">DOMAIN</span><br/><span style="color:${domainColor};">${p.domain}</span></div> |
| 633 | <div><span style="color:#5C5A54;">SOURCE</span><br/><a href="${srcUrl}" target="_blank" style="color:${domainColor};text-decoration:underline;cursor:pointer;">${p.source || 'OSIRIS'}</a></div> |
| 634 | </div> |
| 635 | <a href="${srcUrl}" target="_blank" style="${linkStyle}color:${domainColor};border:1px solid ${domainColor}40;background:${domainColor}18;display:inline-block;margin-top:4px;">OPEN SOURCE ↗</a> |
| 636 | </div>`); |
| 637 | }); |
| 638 | }); |
| 639 | |
| 640 | // ── Generic hover for clickables ── |
| 641 | ['conflict-icons','cctv-dots','eq-circles','sat-dots','fires-heat','gdelt-dots','weather-dots','infra-dots','maritime-dots','choke-dots','news-dots','sigint-news-dots','balloon-dots','rad-dots','ship-dots','sweep-device-dots','scan-targets-dots','sdk-sea','sdk-sea-glow','sdk-air','sdk-air-glow','sdk-intel','sdk-intel-glow'].forEach(layer => { |
| 642 | map.on('mouseenter', layer, () => { map.getCanvas().style.cursor = 'pointer'; }); |
| 643 | map.on('mouseleave', layer, () => { map.getCanvas().style.cursor = ''; }); |
| 644 | }); |
| 645 | |
| 646 | // ── Scan Targets click ── |
| 647 | map.on('click', 'scan-targets-dots', (e: any) => { |
| 648 | const p = e.features?.[0]?.properties; |
| 649 | if (!p) return; |
| 650 | const coords = e.features[0].geometry.coordinates.slice(); |
| 651 | popup(coords, `<div style="${pStyle}border:1px solid rgba(255,61,61,0.5);"> |
| 652 | <div style="color:#FF3D3D;font-size:12px;font-weight:700;margin-bottom:6px;">🎯 TARGET: ${p.id}</div> |
| 653 | <div style="font-size:9px;color:#E8E6E0;margin-bottom:8px;">${p.city || 'Unknown'}, ${p.country || 'Unknown'} — ${p.isp || 'Unknown ISP'}</div> |
| 654 | <div style="display:grid;grid-template-columns:1fr 1fr;gap:4px;font-size:9px;"> |
| 655 | <div><span style="color:#5C5A54;">TYPE</span><br/><span style="color:#00E5FF;">${(p.type || 'UNKNOWN').toUpperCase()}</span></div> |
| 656 | <div><span style="color:#5C5A54;">COORDS</span><br/><span style="color:#E8E6E0;">${coords[1].toFixed(3)}°, ${coords[0].toFixed(3)}°</span></div> |
| 657 | </div> |
| 658 | </div>`); |
| 659 | }); |
| 660 | |
| 661 | // ── SCM Suppliers ── |
| 662 | map.on('click', 'scm-dots', e => { |
| 663 | if (!e.features?.length) return; |
| 664 | const p = e.features[0].properties as any; |
| 665 | const coords = (e.features[0].geometry as any).coordinates; |
| 666 | const color = p.risk_level === 'CRITICAL' ? '#FF1744' : p.risk_level === 'HIGH' ? '#FF9500' : '#00BCD4'; |
| 667 | const activeThreats = p.active_threats ? JSON.parse(p.active_threats) : []; |
| 668 | |
| 669 | let threatsHtml = ''; |
| 670 | if (activeThreats.length > 0) { |
| 671 | threatsHtml = `<div style="margin-top:8px;padding-top:6px;border-top:1px solid ${color}40;color:${color};font-size:9px;font-weight:bold;"> |
| 672 | ACTIVE THREATS:<br/>${activeThreats.map((t: string) => `⚠ ${t}`).join('<br/>')} |
| 673 | </div>`; |
| 674 | } |
| 675 | |
| 676 | popup(coords, `<div style="${pStyle}border:1px solid ${color}40;"> |
| 677 | <div style="color:${color};font-size:12px;font-weight:700;margin-bottom:4px;">🏢 ${p.name}</div> |
| 678 | <div style="font-size:9px;color:#aaa;margin-bottom:8px;">${p.category} | ${p.city}, ${p.country}</div> |
| 679 | <div style="display:grid;grid-template-columns:1fr;gap:4px;font-size:11px;"> |
| 680 | <div><span style="color:#5C5A54;font-size:9px;">SCM RISK LEVEL</span><br/><span style="color:${color};font-weight:bold;">${p.risk_level}</span></div> |
| 681 | </div> |
| 682 | ${threatsHtml} |
| 683 | </div>`); |
| 684 | }); |
| 685 | |
| 686 | // ── IP Sweep device click ── |
| 687 | map.on('click', 'sweep-device-dots', (e: any) => { |
| 688 | const p = e.features?.[0]?.properties; |
| 689 | if (!p) return; |
| 690 | const coords = e.features[0].geometry.coordinates.slice(); |
| 691 | const ports = JSON.parse(p.ports || '[]'); |
| 692 | const vulns = JSON.parse(p.vulns || '[]'); |
| 693 | const hostnames = JSON.parse(p.hostnames || '[]'); |
| 694 | const riskColors: Record<string, string> = { CRITICAL: '#FF3D3D', HIGH: '#FF6B00', MEDIUM: '#FFD700', LOW: '#76FF03', INFO: '#5C5A54' }; |
| 695 | popup(coords, `<div style="font-family:monospace;font-size:11px;color:#E8E6E0;"> |
| 696 | <div style="font-size:13px;font-weight:bold;margin-bottom:6px;color:${p.color};">${p.device_type}</div> |
| 697 | <div style="font-size:12px;margin-bottom:8px;color:#fff;">${p.ip}</div> |
| 698 | ${hostnames.length > 0 ? `<div style="font-size:9px;color:#8A8880;margin-bottom:6px;">${hostnames.join(', ')}</div>` : ''} |
| 699 | <div style="display:grid;grid-template-columns:1fr 1fr;gap:6px;margin-bottom:8px;"> |
| 700 | <div><span style="color:#5C5A54;">PORTS</span><br/><span style="color:#E8E6E0;">${ports.length}</span></div> |
| 701 | <div><span style="color:#5C5A54;">RISK</span><br/><span style="color:${riskColors[p.risk_level] || '#666'};">${p.risk_level}</span></div> |
| 702 | </div> |
| 703 | <div style="font-size:9px;color:#8A8880;margin-bottom:6px;">Open: ${ports.slice(0, 12).join(', ')}${ports.length > 12 ? ' ...' : ''}</div> |
| 704 | ${vulns.length > 0 ? `<div style="font-size:9px;color:#FF3D3D;margin-bottom:6px;">⚠ CVEs: ${vulns.slice(0, 5).join(', ')}${vulns.length > 5 ? ` +${vulns.length - 5} more` : ''}</div>` : ''} |
| 705 | </div>`); |
| 706 | }); |
| 707 | |
| 708 | // ── Balloons / Sondes ── |
| 709 | map.on('click', 'balloon-dots', e => { |
| 710 | if (!e.features?.length) return; |
| 711 | const p = e.features[0].properties as any; |
| 712 | const coords = (e.features[0].geometry as any).coordinates; |
| 713 | popup(coords, `<div style="${pStyle}border:1px solid ${p.color}40;"> |
| 714 | <div style="color:${p.color};font-size:12px;font-weight:700;letter-spacing:0.1em;margin-bottom:4px;">🎈 ${p.callsign}</div> |
| 715 | <div style="font-size:9px;color:#aaa;margin-bottom:8px;">${p.type.toUpperCase()} / STATUS: ${p.status.toUpperCase()}</div> |
| 716 | <div style="display:grid;grid-template-columns:1fr 1fr;gap:4px;font-size:9px;"> |
| 717 | <div><span style="color:#5C5A54;">ALTITUDE</span><br/><span style="color:#E8E6E0;">${p.altitude} m</span></div> |
| 718 | <div><span style="color:#5C5A54;">SPEED</span><br/><span style="color:#E8E6E0;">${Math.round(p.speed)} km/h</span></div> |
| 719 | <div><span style="color:#5C5A54;">VERT RATE</span><br/><span style="color:${p.verticalRate > 0 ? '#00E676' : '#FF3D3D'};">${p.verticalRate.toFixed(1)} m/s</span></div> |
| 720 | <div><span style="color:#5C5A54;">TEMP</span><br/><span style="color:#E8E6E0;">${p.temperature}°C</span></div> |
| 721 | </div> |
| 722 | </div>`); |
| 723 | }); |
| 724 | |
| 725 | // ── Radiation ── |
| 726 | map.on('click', 'rad-dots', e => { |
| 727 | if (!e.features?.length) return; |
| 728 | const p = e.features[0].properties as any; |
| 729 | const coords = (e.features[0].geometry as any).coordinates; |
| 730 | const color = p.status === 'DANGER' ? '#FF1744' : p.status === 'WARNING' ? '#FF9500' : '#AB47BC'; |
| 731 | popup(coords, `<div style="${pStyle}border:1px solid ${color}40;"> |
| 732 | <div style="color:${color};font-size:12px;font-weight:700;margin-bottom:4px;">☢️ ${p.name}</div> |
| 733 | <div style="font-size:9px;color:#aaa;margin-bottom:8px;">${p.city}, ${p.country}</div> |
| 734 | <div style="display:grid;grid-template-columns:1fr;gap:4px;font-size:11px;"> |
| 735 | <div><span style="color:#5C5A54;font-size:9px;">READING</span><br/><span style="color:${color};font-weight:bold;">${p.reading} nSv/h</span></div> |
| 736 | <div><span style="color:#5C5A54;font-size:9px;">STATUS</span><br/><span style="color:${color};">${p.status}</span></div> |
| 737 | <div><span style="color:#5C5A54;font-size:9px;">NETWORK</span><br/><span style="color:#E8E6E0;">${p.network}</span></div> |
| 738 | </div> |
| 739 | </div>`); |
| 740 | }); |
| 741 | |
| 742 | // ── Maritime Ships ── |
| 743 | map.on('click', 'ship-dots', e => { |
| 744 | if (!e.features?.length) return; |
| 745 | const p = e.features[0].properties as any; |
| 746 | const coords = (e.features[0].geometry as any).coordinates; |
| 747 | const color = p.type === 'military' ? '#FF1744' : p.type === 'tanker' ? '#FF9500' : '#00BCD4'; |
| 748 | popup(coords, `<div style="${pStyle}border:1px solid ${color}40;"> |
| 749 | <div style="display:flex;justify-content:space-between;margin-bottom:4px;"> |
| 750 | <span style="color:${color};font-size:12px;font-weight:700;letter-spacing:0.1em;">🚢 ${p.name}</span> |
| 751 | <span style="color:#aaa;font-size:9px;">${p.flag}</span> |
| 752 | </div> |
| 753 | <div style="display:grid;grid-template-columns:1fr 1fr;gap:4px;font-size:9px;"> |
| 754 | <div><span style="color:#5C5A54;">TYPE</span><br/><span style="color:${color};">${p.type.toUpperCase()}</span></div> |
| 755 | <div><span style="color:#5C5A54;">SPEED</span><br/><span style="color:#E8E6E0;">${p.speed} knots</span></div> |
| 756 | <div><span style="color:#5C5A54;">HEADING</span><br/><span style="color:#E8E6E0;">${p.heading}°</span></div> |
| 757 | <div><span style="color:#5C5A54;">DEST</span><br/><span style="color:#E8E6E0;">${p.destination || 'UNKNOWN'}</span></div> |
| 758 | </div> |
| 759 | </div>`); |
| 760 | }); |
| 761 | |
| 762 | // ── Weather Events (NASA EONET) ── |
| 763 | map.on('click', 'weather-dots', e => { |
| 764 | if (!e.features?.length) return; |
| 765 | const p = e.features[0].properties as any; |
| 766 | const coords = (e.features[0].geometry as any).coordinates; |
| 767 | const iconEmoji = p.icon === 'cyclone' ? '🌀' : p.icon === 'volcano' ? '🌋' : '⚡'; |
| 768 | popup(coords, `<div style="${pStyle}border:1px solid rgba(224,64,251,0.3);"> |
| 769 | <div style="color:#E040FB;font-size:14px;font-weight:700;margin-bottom:6px;">${iconEmoji} ${p.type || 'Weather Event'}</div> |
| 770 | <div style="font-size:10px;color:#E8E6E0;margin-bottom:8px;line-height:1.4;">${p.title || 'Unknown event'}</div> |
| 771 | <div style="display:grid;grid-template-columns:1fr 1fr;gap:4px;font-size:9px;margin-bottom:8px;"> |
| 772 | <div><span style="color:#5C5A54;">SEVERITY</span><br/><span style="color:${p.severity === 'high' ? '#FF1744' : '#FFD700'};">${(p.severity||'low').toUpperCase()}</span></div> |
| 773 | <div><span style="color:#5C5A54;">COORDS</span><br/><span style="color:#E8E6E0;">${coords[1].toFixed(3)}°, ${coords[0].toFixed(3)}°</span></div> |
| 774 | </div> |
| 775 | <div style="display:flex;gap:6px;"> |
| 776 | ${p.source ? `<a href="${p.source}" target="_blank" style="${linkStyle}color:#E040FB;border:1px solid rgba(224,64,251,0.4);background:rgba(224,64,251,0.1);">📡 SOURCE</a>` : ''} |
| 777 | <a href="https://eonet.gsfc.nasa.gov/api/v3/events/${p.id || ''}" target="_blank" style="${linkStyle}color:#D4AF37;border:1px solid rgba(212,175,55,0.4);background:rgba(212,175,55,0.1);">🛰️ NASA EONET</a> |
| 778 | </div> |
| 779 | </div>`); |
| 780 | }); |
| 781 | |
| 782 | // ── Nuclear Infrastructure ── |
| 783 | map.on('click', 'infra-dots', e => { |
| 784 | if (!e.features?.length) return; |
| 785 | const p = e.features[0].properties as any; |
| 786 | const coords = (e.features[0].geometry as any).coordinates; |
| 787 | const statusColor = p.status.includes('SEISMIC RISK') ? '#FF9500' : p.status === 'Active Conflict Zone' ? '#FF1744' : p.status === 'Operational' ? '#76FF03' : '#757575'; |
| 788 | popup(coords, `<div style="${pStyle}border:1px solid rgba(118,255,3,0.3);"> |
| 789 | <div style="color:#76FF03;font-size:14px;font-weight:700;margin-bottom:4px;">☢️ ${p.name || 'Nuclear Facility'}</div> |
| 790 | <div style="display:grid;grid-template-columns:1fr 1fr;gap:6px;font-size:9px;margin-bottom:8px;"> |
| 791 | <div><span style="color:#5C5A54;">STATUS</span><br/><span style="color:${statusColor};">${p.status || '—'}</span></div> |
| 792 | <div><span style="color:#5C5A54;">CITY</span><br/><span style="color:#E8E6E0;">${p.city || '—'}, ${p.country || ''}</span></div> |
| 793 | <div><span style="color:#5C5A54;">REACTORS</span><br/><span style="color:#76FF03;">${p.reactors || '—'}</span></div> |
| 794 | <div><span style="color:#5C5A54;">CAPACITY</span><br/><span style="color:#E8E6E0;">${p.capacityMW ? p.capacityMW.toLocaleString() + ' MW' : '—'}</span></div> |
| 795 | <div><span style="color:#5C5A54;">OWNER</span><br/><span style="color:#E8E6E0;">${p.owner || '—'}</span></div> |
| 796 | <div><span style="color:#5C5A54;">COORDS</span><br/><span style="color:#E8E6E0;">${coords[1].toFixed(3)}°, ${coords[0].toFixed(3)}°</span></div> |
| 797 | </div> |
| 798 | <a href="https://www.google.com/maps/@${coords[1]},${coords[0]},14z/data=!3m1!1e3" target="_blank" style="${linkStyle}color:#76FF03;border:1px solid rgba(118,255,3,0.4);background:rgba(118,255,3,0.1);">SATELLITE VIEW</a> |
| 799 | </div>`); |
| 800 | }); |
| 801 | |
| 802 | // ── Maritime Ports & Naval Bases ── |
| 803 | map.on('click', 'maritime-dots', e => { |
| 804 | const p = e.features?.[0]?.properties; |
| 805 | if (!p) return; |
| 806 | const coords = (e.features![0].geometry as any).coordinates; |
| 807 | const typeColor = p.type === 'naval' ? '#FF3D3D' : p.type === 'energy' ? '#FF9500' : '#00BCD4'; |
| 808 | const typeLabel = p.type === 'naval' ? 'NAVAL BASE' : p.type === 'energy' ? 'ENERGY PORT' : 'CONTAINER PORT'; |
| 809 | |
| 810 | const congestionHtml = p.congestion ? ` |
| 811 | <div style="margin-top:8px;padding-top:6px;border-top:1px solid rgba(255,255,255,0.1);"> |
| 812 | <div style="display:grid;grid-template-columns:1fr 1fr;gap:4px;"> |
| 813 | <div><span style="color:#5C5A54;font-size:9px;">CONGESTION</span><br/><span style="color:${p.congestion === 'SEVERE' ? '#FF1744' : p.congestion === 'CONGESTED' ? '#FF9500' : '#00E676'};font-weight:bold;font-size:10px;">${p.congestion}</span></div> |
| 814 | <div><span style="color:#5C5A54;font-size:9px;">EST. DWELL TIME</span><br/><span style="color:#E8E6E0;font-weight:bold;font-size:10px;">${p.dwell_time || 'Unknown'}</span></div> |
| 815 | </div> |
| 816 | </div>` : ''; |
| 817 | |
| 818 | popup(coords, `<div style="${pStyle}border:1px solid ${typeColor}40;"> |
| 819 | <div style="color:${typeColor};font-weight:bold;font-size:11px;margin-bottom:4px;">${p.name}</div> |
| 820 | <div style="color:#999;font-size:9px;margin-bottom:6px;">${typeLabel} — ${p.country}</div> |
| 821 | ${p.volume ? `<div style="font-size:9px;color:#aaa;">Volume: <span style="color:${typeColor};font-weight:bold;">${p.volume}</span></div>` : ''} |
| 822 | ${p.fleet ? `<div style="font-size:9px;color:#aaa;">Fleet: <span style="color:${typeColor};font-weight:bold;">${p.fleet}</span></div>` : ''} |
| 823 | ${p.rank ? `<div style="font-size:9px;color:#aaa;">Global Rank: <span style="color:${typeColor};font-weight:bold;">#${p.rank}</span></div>` : ''} |
| 824 | ${congestionHtml} |
| 825 | </div>`); |
| 826 | }); |
| 827 | |
| 828 | // ── Maritime Chokepoints ── |
| 829 | map.on('click', 'choke-dots', e => { |
| 830 | const p = e.features?.[0]?.properties; |
| 831 | if (!p) return; |
| 832 | const coords = (e.features![0].geometry as any).coordinates; |
| 833 | const riskCol = p.risk === 'CRITICAL' ? '#FF1744' : p.risk === 'HIGH' ? '#FF9500' : p.risk === 'ELEVATED' ? '#FFD700' : '#00E676'; |
| 834 | popup(coords, `<div style="${pStyle}border:1px solid ${riskCol}40;"> |
| 835 | <div style="color:#FF9500;font-weight:bold;font-size:11px;margin-bottom:4px;">${p.name}</div> |
| 836 | <div style="font-size:9px;color:#aaa;">Traffic: <span style="color:#fff;">${p.traffic}</span></div> |
| 837 | <div style="font-size:9px;color:#aaa;">Risk: <span style="color:${riskCol};font-weight:bold;">${p.risk}</span></div> |
| 838 | </div>`); |
| 839 | }); |
| 840 | |
| 841 | // ── Live News (opens feed viewer) ── |
| 842 | map.on('click', 'news-dots', e => { |
| 843 | const p = e.features?.[0]?.properties; |
| 844 | if (!p) return; |
| 845 | onEntityClick?.({ |
| 846 | type: 'live_news', |
| 847 | name: p.name, |
| 848 | city: p.city, |
| 849 | country: p.country, |
| 850 | url: p.url, |
| 851 | category: p.category, |
| 852 | embed_allowed: p.embed_allowed !== false && p.embed_allowed !== 'false', |
| 853 | }); |
| 854 | }); |
| 855 | |
| 856 | return () => { map.remove(); mapRef.current = null; }; |
| 857 | }, []); |
| 858 | |
| 859 | // Day/Night |
| 860 | useEffect(() => { |
| 861 | if (!mapReady || !mapRef.current) return; |
| 862 | const map = mapRef.current; |
| 863 | const update = () => { |
| 864 | const src = map.getSource('day-night') as any; |
| 865 | if (!src) return; |
| 866 | if (!activeLayers.day_night) { src.setData(EMPTY_FC); return; } |
| 867 | src.setData({ type: 'FeatureCollection', features: [{ type: 'Feature', geometry: { type: 'Polygon', coordinates: [computeSolarTerminator()] }, properties: {} }] }); |
| 868 | }; |
| 869 | update(); |
| 870 | const iv = setInterval(update, 300000); // 5 min (was 1 min — shadow barely moves) |
| 871 | return () => clearInterval(iv); |
| 872 | }, [mapReady, activeLayers.day_night]); |
| 873 | |
| 874 | // Helper to set GeoJSON |
| 875 | const setGeo = useCallback((source: string, features: any[]) => { |
| 876 | const src = mapRef.current?.getSource(source) as any; |
| 877 | if (src) src.setData({ type: 'FeatureCollection', features }); |
| 878 | }, []); |
| 879 | |
| 880 | const setVis = useCallback((ids: string[], visible: boolean) => { |
| 881 | const map = mapRef.current; |
| 882 | if (!map) return; |
| 883 | ids.forEach(id => { if (map.getLayer(id)) map.setLayoutProperty(id, 'visibility', visible ? 'visible' : 'none'); }); |
| 884 | }, []); |
| 885 | |
| 886 | // Flight data → GeoJSON (GPU rendered) |
| 887 | useEffect(() => { |
| 888 | if (!mapReady) return; |
| 889 | const toFeatures = (arr: any[]) => (arr || []).map((f: any) => ({ |
| 890 | type: 'Feature' as const, geometry: { type: 'Point' as const, coordinates: [f.lng, f.lat] }, |
| 891 | properties: { callsign: f.callsign, heading: f.heading || 0, alt: f.alt, model: f.model, speed_knots: f.speed_knots, registration: f.registration, icao24: f.icao24 }, |
| 892 | })); |
| 893 | setGeo('flights', activeLayers.flights ? toFeatures(data.commercial_flights) : []); |
| 894 | setGeo('private-fl', activeLayers.private ? toFeatures(data.private_flights) : []); |
| 895 | setGeo('jets', activeLayers.jets ? toFeatures(data.private_jets) : []); |
| 896 | setGeo('military', activeLayers.military ? toFeatures(data.military_flights) : []); |
| 897 | }, [mapReady, data.commercial_flights, data.private_flights, data.private_jets, data.military_flights, activeLayers.flights, activeLayers.private, activeLayers.jets, activeLayers.military]); |
| 898 | |
| 899 | // ── DECOUPLED LAYER RENDERERS (Performance Optimized) ── |
| 900 | |
| 901 | useEffect(() => { |
| 902 | if (!mapReady) return; |
| 903 | setGeo('earthquakes', activeLayers.earthquakes && data.earthquakes ? data.earthquakes.map((eq: any) => ({ type: 'Feature', geometry: { type: 'Point', coordinates: [eq.lng, eq.lat] }, properties: { magnitude: eq.magnitude, place: eq.place } })) : []); |
| 904 | }, [mapReady, data.earthquakes, activeLayers.earthquakes, setGeo]); |
| 905 | |
| 906 | useEffect(() => { |
| 907 | if (!mapReady) return; |
| 908 | setGeo('satellites', activeLayers.satellites && data.satellites ? data.satellites.map((s: any) => ({ type: 'Feature', geometry: { type: 'Point', coordinates: [s.lng, s.lat] }, properties: { name: s.name, color: s.color, mission: s.mission, alt: s.alt, noradId: s.noradId } })) : []); |
| 909 | }, [mapReady, data.satellites, activeLayers.satellites, setGeo]); |
| 910 | |
| 911 | useEffect(() => { |
| 912 | if (!mapReady) return; |
| 913 | setGeo('gdelt', activeLayers.global_incidents && data.gdelt ? data.gdelt.map((e: any) => ({ type: 'Feature', geometry: { type: 'Point', coordinates: [e.lng, e.lat] }, properties: { name: e.name } })) : []); |
| 914 | }, [mapReady, data.gdelt, activeLayers.global_incidents, setGeo]); |
| 915 | |
| 916 | useEffect(() => { |
| 917 | if (!mapReady) return; |
| 918 | setGeo('gps-jamming', activeLayers.gps_jamming && data.gps_jamming ? data.gps_jamming.map((z: any) => ({ type: 'Feature', geometry: { type: 'Point', coordinates: [z.lng, z.lat] }, properties: { severity: z.severity } })) : []); |
| 919 | }, [mapReady, data.gps_jamming, activeLayers.gps_jamming, setGeo]); |
| 920 | |
| 921 | useEffect(() => { |
| 922 | if (!mapReady) return; |
| 923 | setGeo('cctv', activeLayers.cctv && data.cameras ? data.cameras.map((c: any) => ({ type: 'Feature', geometry: { type: 'Point', coordinates: [c.lng, c.lat] }, properties: { id: c.id, name: c.name, city: c.city, country: c.country, source: c.source, feed_url: c.feed_url, stream_url: c.stream_url, stream_type: c.stream_type, external_url: c.external_url } })) : []); |
| 924 | }, [mapReady, data.cameras, activeLayers.cctv, setGeo]); |
| 925 | |
| 926 | useEffect(() => { |
| 927 | if (!mapReady) return; |
| 928 | setGeo('fires', activeLayers.fires && data.fires ? data.fires.map((f: any) => ({ type: 'Feature', geometry: { type: 'Point', coordinates: [f.lng, f.lat] }, properties: { brightness: f.brightness } })) : []); |
| 929 | }, [mapReady, data.fires, activeLayers.fires, setGeo]); |
| 930 | |
| 931 | useEffect(() => { |
| 932 | if (!mapReady) return; |
| 933 | setGeo('weather', activeLayers.weather && data.weather_events ? data.weather_events.map((w: any) => ({ type: 'Feature', geometry: { type: 'Point', coordinates: [w.lng, w.lat] }, properties: { title: w.title, type: w.type, icon: w.icon, severity: w.severity, source: w.source, id: w.id } })) : []); |
| 934 | }, [mapReady, data.weather_events, activeLayers.weather, setGeo]); |
| 935 | |
| 936 | useEffect(() => { |
| 937 | if (!mapReady) return; |
| 938 | setGeo('infrastructure', activeLayers.infrastructure && data.infrastructure ? data.infrastructure.map((i: any) => ({ type: 'Feature', geometry: { type: 'Point', coordinates: [i.lng, i.lat] }, properties: { name: i.name, city: i.city, country: i.country, status: i.status, reactors: i.reactors, capacityMW: i.capacityMW, owner: i.owner } })) : []); |
| 939 | }, [mapReady, data.infrastructure, activeLayers.infrastructure, setGeo]); |
| 940 | |
| 941 | useEffect(() => { |
| 942 | if (!mapReady) return; |
| 943 | setGeo('maritime', activeLayers.maritime && data.maritime_ports ? data.maritime_ports.map((p: any) => ({ type: 'Feature', geometry: { type: 'Point', coordinates: [p.lng, p.lat] }, properties: { name: p.name, country: p.country, type: p.type, volume: p.volume, fleet: p.fleet, rank: p.rank } })) : []); |
| 944 | setGeo('maritime-choke', activeLayers.maritime && data.maritime_chokepoints ? data.maritime_chokepoints.map((c: any) => ({ type: 'Feature', geometry: { type: 'Point', coordinates: [c.lng, c.lat] }, properties: { name: c.name, traffic: c.traffic, risk: c.risk } })) : []); |
| 945 | setGeo('maritime-ships', activeLayers.maritime && data.maritime_ships ? data.maritime_ships.map((s: any) => ({ type: 'Feature', geometry: { type: 'Point', coordinates: [s.lng, s.lat] }, properties: { name: s.name || s.mmsi?.toString(), type: s.type || 'cargo', speed: s.speed, heading: s.heading, destination: s.destination, flag: s.flag } })) : []); |
| 946 | }, [mapReady, data.maritime_ports, data.maritime_chokepoints, data.maritime_ships, activeLayers.maritime, setGeo]); |
| 947 | |
| 948 | useEffect(() => { |
| 949 | if (!mapReady) return; |
| 950 | setGeo('balloons', activeLayers.balloons && data.balloons ? data.balloons.map((b: any) => ({ type: 'Feature', geometry: { type: 'Point', coordinates: [b.lng, b.lat] }, properties: { callsign: b.callsign, type: b.type, status: b.status, altitude: b.altitude, speed: b.speed, verticalRate: b.verticalRate, temperature: b.temperature, color: b.color } })) : []); |
| 951 | }, [mapReady, data.balloons, activeLayers.balloons, setGeo]); |
| 952 | |
| 953 | useEffect(() => { |
| 954 | if (!mapReady) return; |
| 955 | setGeo('radiation', activeLayers.radiation && data.radiation ? data.radiation.map((r: any) => ({ type: 'Feature', geometry: { type: 'Point', coordinates: [r.lng, r.lat] }, properties: { name: r.name, city: r.city, country: r.country, reading: r.reading, status: r.status, network: r.network } })) : []); |
| 956 | }, [mapReady, data.radiation, activeLayers.radiation, setGeo]); |
| 957 | |
| 958 | // ══ OSIRIS SDK — Lattice Sensor Mesh ══ |
| 959 | // Multi-waypoint routes tracing real-world shipping lanes, air corridors, and intel lines |
| 960 | useEffect(() => { |
| 961 | if (!mapReady) return; |
| 962 | setGeo('sdk-entities', []); |
| 963 | |
| 964 | if (!activeLayers.sdk_stream) { |
| 965 | setGeo('sdk-links', []); |
| 966 | return; |
| 967 | } |
| 968 | |
| 969 | // Spline curve generator for ultra-smooth paths |
| 970 | const splineCurve = (points: [number,number][], segments = 15): [number,number][] => { |
| 971 | if (points.length < 2) return points; |
| 972 | const res: [number,number][] = []; |
| 973 | const p = [...points]; |
| 974 | p.unshift(p[0]); // Duplicate first |
| 975 | p.push(p[p.length-1]); // Duplicate last |
| 976 | for (let i = 1; i < p.length - 2; i++) { |
| 977 | for (let t = 0; t <= 1; t += 1/segments) { |
| 978 | const t2 = t*t, t3 = t2*t; |
| 979 | const x = 0.5 * ((2*p[i][0]) + (-p[i-1][0] + p[i+1][0])*t + (2*p[i-1][0] - 5*p[i][0] + 4*p[i+1][0] - p[i+2][0])*t2 + (-p[i-1][0] + 3*p[i][0] - 3*p[i+1][0] + p[i+2][0])*t3); |
| 980 | const y = 0.5 * ((2*p[i][1]) + (-p[i-1][1] + p[i+1][1])*t + (2*p[i-1][1] - 5*p[i][1] + 4*p[i+1][1] - p[i+2][1])*t2 + (-p[i-1][1] + 3*p[i][1] - 3*p[i+1][1] + p[i+2][1])*t3); |
| 981 | res.push([x,y]); |
| 982 | } |
| 983 | } |
| 984 | return res; |
| 985 | }; |
| 986 | |
| 987 | // Route builder — applies spline smoothing |
| 988 | const route = (waypoints: [number,number][], props: any) => ({ |
| 989 | type: 'Feature' as const, |
| 990 | geometry: { type: 'LineString' as const, coordinates: splineCurve(waypoints) }, |
| 991 | properties: props, |
| 992 | }); |
| 993 | |
| 994 | const links: any[] = []; |
| 995 | |
| 996 | // ── MARITIME: Real shipping lane waypoints (strictly over water) ── |
| 997 | |
| 998 | links.push(route([ |
| 999 | [121.47,31.23], [122.5,30.5], [120.0,26.0], [119.0,24.0], [116.0,21.0], [111.0,15.0], [109.0,10.0], [105.0,4.0], [103.84,1.26] |
| 1000 | ], { fromName:'Shanghai', toName:'Singapore', domain:'SEA', source:'AIS Maritime' })); |
| 1001 | |
| 1002 | links.push(route([ |
| 1003 | [103.84,1.26], [103.0,1.8], [100.0,4.0], [96.0,6.0], [88.0,6.0], [80.0,5.5], [70.0,8.0], [60.0,12.0], [52.0,14.0], [45.0,12.0], [43.33,12.58] |
| 1004 | ], { fromName:'Singapore', toName:'Bab el-Mandeb', domain:'SEA', source:'AIS Maritime' })); |
| 1005 | |
| 1006 | links.push(route([ |
| 1007 | [43.33,12.58], [41.0,17.0], [38.0,21.0], [35.0,25.0], [32.34,30.43] |
| 1008 | ], { fromName:'Bab el-Mandeb', toName:'Suez Canal', domain:'SEA', source:'AIS Maritime' })); |
| 1009 | |
| 1010 | links.push(route([ |
| 1011 | [32.34,30.43], [32.3,31.3], [31.5,31.8], [26.0,34.0], [18.0,35.0], [15.0,36.0], [11.0,37.5], [6.0,38.0], [0.0,36.5], [-5.35,36.0] |
| 1012 | ], { fromName:'Suez Canal', toName:'Gibraltar', domain:'SEA', source:'AIS Maritime' })); |
| 1013 | |
| 1014 | links.push(route([ |
| 1015 | [-5.35,36.0], [-9.0,36.0], [-10.0,38.0], [-10.0,43.0], [-8.0,45.0], [-5.5,48.5], [-2.0,49.5], [1.5,51.0], [3.5,51.5], [4.50,51.90] |
| 1016 | ], { fromName:'Gibraltar', toName:'Rotterdam', domain:'SEA', source:'AIS Maritime' })); |
| 1017 | |
| 1018 | links.push(route([ |
| 1019 | [121.47,31.23], [123.0,30.5], [130.0,30.0], [140.0,34.0], [150.0,40.0], [165.0,43.0], [180.0,44.0], [200.0,43.0], [220.0,38.0], [235.0,34.0], [241.73,33.74] |
| 1020 | ], { fromName:'Shanghai', toName:'Los Angeles', domain:'SEA', source:'AIS Maritime' })); |
| 1021 | |
| 1022 | links.push(route([ |
| 1023 | [103.84,1.26], [105.0,4.0], [109.0,10.0], [111.0,15.0], [116.0,21.0], [119.0,24.0], [120.0,26.0], [124.0,30.0], [127.0,32.0], [129.04,35.10] |
| 1024 | ], { fromName:'Singapore', toName:'Busan', domain:'SEA', source:'AIS Maritime' })); |
| 1025 | |
| 1026 | links.push(route([ |
| 1027 | [4.50,51.90], [3.5,51.5], [1.5,51.0], [-2.0,49.5], [-5.5,48.5], [-8.0,45.0], [-10.0,43.0], [-10.0,38.0], [-18.0,25.0], [-25.0,15.0], [-20.0,0.0], [-10.0,-20.0], [5.0,-32.0], [18.47,-34.36] |
| 1028 | ], { fromName:'Rotterdam', toName:'Cape of Good Hope', domain:'SEA', source:'AIS Maritime' })); |
| 1029 | |
| 1030 | links.push(route([ |
| 1031 | [18.47,-34.36], [22.0,-35.0], [30.0,-33.0], [40.0,-20.0], [45.0,-10.0], [52.0,5.0], [56.0,14.0], [59.0,22.0], [56.25,26.57] |
| 1032 | ], { fromName:'Cape of Good Hope', toName:'Strait of Hormuz', domain:'SEA', source:'AIS Maritime' })); |
| 1033 | |
| 1034 | links.push(route([ |
| 1035 | [-79.68,9.08], [-79.0,11.0], [-75.0,15.0], [-72.0,20.0], [-65.0,30.0], [-50.0,42.0], [-30.0,48.0], [-10.0,49.0], [-5.5,48.5], [-2.0,49.5], [1.5,51.0], [4.50,51.90] |
| 1036 | ], { fromName:'Panama', toName:'Rotterdam', domain:'SEA', source:'AIS Maritime' })); |
| 1037 | |
| 1038 | links.push(route([ |
| 1039 | [-118.27,33.74], [-118.0,32.0], [-115.0,26.0], [-105.0,18.0], [-95.0,13.0], [-85.0,8.0], [-80.0,7.5], [-79.68,9.08] |
| 1040 | ], { fromName:'Los Angeles', toName:'Panama', domain:'SEA', source:'AIS Maritime' })); |
| 1041 | |
| 1042 | links.push(route([ |
| 1043 | [-46.31,-23.95], [-44.0,-25.0], [-30.0,-28.0], [-15.0,-30.0], [0.0,-32.0], [10.0,-33.0], [18.47,-34.36] |
| 1044 | ], { fromName:'Santos', toName:'Cape of Good Hope', domain:'SEA', source:'AIS Maritime' })); |
| 1045 | |
| 1046 | links.push(route([ |
| 1047 | [55.06,25.01], [54.5,25.5], [53.0,25.8], [51.0,26.0], [50.16,26.64] |
| 1048 | ], { fromName:'Dubai', toName:'Ras Tanura', domain:'SEA', source:'AIS Maritime' })); |
| 1049 | |
| 1050 | links.push(route([ |
| 1051 | [79.84,6.94], [80.0,5.5], [88.0,6.0], [96.0,6.0], [100.0,4.0], [103.0,1.8], [103.84,1.26] |
| 1052 | ], { fromName:'Colombo', toName:'Singapore', domain:'SEA', source:'AIS Maritime' })); |
| 1053 | |
| 1054 | // ── AIR CORRIDORS: High altitude splined curves ── |
| 1055 | |
| 1056 | links.push(route([ |
| 1057 | [-73.78,40.64], [-65.0,44.0], [-50.0,50.0], [-35.0,53.0], [-20.0,53.5], [-10.0,52.5], [-0.46,51.47] |
| 1058 | ], { fromName:'JFK New York', toName:'London Heathrow', domain:'AIR', source:'ADS-B / OpenSky' })); |
| 1059 | |
| 1060 | links.push(route([ |
| 1061 | [-0.46,51.47], [8.0,48.0], [18.0,44.0], [28.81,41.27], [35.0,37.0], [42.0,32.0], [50.0,28.0], [55.36,25.25] |
| 1062 | ], { fromName:'London', toName:'Dubai', domain:'AIR', source:'ADS-B / OpenSky' })); |
| 1063 | |
| 1064 | links.push(route([ |
| 1065 | [55.36,25.25], [65.0,20.0], [75.0,15.0], [85.0,10.0], [95.0,5.0], [103.99,1.36], [110.0,8.0], [118.0,16.0], [125.0,25.0], [132.0,30.0], [139.79,35.61] |
| 1066 | ], { fromName:'Dubai', toName:'Tokyo', domain:'AIR', source:'ADS-B / OpenSky' })); |
| 1067 | |
| 1068 | links.push(route([ |
| 1069 | [139.79,35.61], [148.0,38.0], [158.0,41.0], [170.0,43.0], [180.0,44.0], [195.0,43.0], [210.0,41.0], [225.0,38.0], [235.0,36.0], [241.59,33.94] |
| 1070 | ], { fromName:'Tokyo', toName:'LAX', domain:'AIR', source:'ADS-B / OpenSky' })); |
| 1071 | |
| 1072 | links.push(route([ |
| 1073 | [-118.41,33.94], [-110.0,35.0], [-100.0,37.0], [-90.0,39.0], [-80.0,40.0], [-73.78,40.64] |
| 1074 | ], { fromName:'LAX', toName:'JFK', domain:'AIR', source:'ADS-B / OpenSky' })); |
| 1075 | |
| 1076 | links.push(route([ |
| 1077 | [28.81,41.27], [40.0,42.0], [52.0,42.5], [65.0,43.0], [78.0,43.0], [90.0,42.5], [103.0,41.5], [116.60,40.08] |
| 1078 | ], { fromName:'Istanbul', toName:'Beijing', domain:'AIR', source:'ADS-B / OpenSky' })); |
| 1079 | |
| 1080 | // ── NAVAL/INTEL: Fleet deployment corridors (smooth curves) ── |
| 1081 | |
| 1082 | links.push(route([ |
| 1083 | [-76.33,36.95], [-68.0,38.0], [-55.0,42.0], [-40.0,46.0], [-25.0,49.0], [-10.0,50.5], [-1.11,50.80] |
| 1084 | ], { fromName:'Norfolk NAS', toName:'Portsmouth (Royal Navy)', domain:'INTEL', source:'Naval Intelligence' })); |
| 1085 | |
| 1086 | links.push(route([ |
| 1087 | [-76.33,36.95], [-65.0,37.0], [-45.0,36.5], [-25.0,36.0], [-10.0,36.0], [-5.35,36.0], [2.0,37.0], [10.0,38.0], [20.0,37.0], [28.0,36.0], [35.89,34.89] |
| 1088 | ], { fromName:'Norfolk NAS', toName:'Tartus (Russian Base)', domain:'INTEL', source:'Naval Intelligence' })); |
| 1089 | |
| 1090 | links.push(route([ |
| 1091 | [-117.15,32.69], [-130.0,29.0], [-145.0,25.0], [-157.97,21.35], [-170.0,25.0], [-180.0,29.0], [-192.0,31.0], [-205.0,33.0], [-215.0,34.0], [-220.33,35.28] |
| 1092 | ], { fromName:'San Diego NB', toName:'Yokosuka (7th Fleet)', domain:'INTEL', source:'Naval Intelligence' })); |
| 1093 | |
| 1094 | links.push(route([ |
| 1095 | [139.67,35.28], [130.0,30.0], [120.0,22.0], [110.0,12.0], [104.01,1.33], [95.0,5.0], [85.0,10.0], [78.0,15.0], [72.84,18.93] |
| 1096 | ], { fromName:'Yokosuka', toName:'Mumbai (Indian Navy)', domain:'INTEL', source:'Naval Intelligence' })); |
| 1097 | |
| 1098 | links.push(route([ |
| 1099 | [33.42,69.07], [35.0,65.0], [30.0,58.0], [28.0,52.0], [30.0,46.0], [33.0,42.0], [30.0,38.0], [35.89,34.89] |
| 1100 | ], { fromName:'Severomorsk (Northern Fleet)', toName:'Tartus', domain:'INTEL', source:'Naval Intelligence' })); |
| 1101 | |
| 1102 | links.push(route([ |
| 1103 | [110.39,21.20], [112.0,24.0], [115.0,28.0], [118.0,32.0], [120.43,36.09] |
| 1104 | ], { fromName:'Zhanjiang (PLA Southern Theater)', toName:'Qingdao (PLA Northern Theater)', domain:'INTEL', source:'Naval Intelligence' })); |
| 1105 | |
| 1106 | links.push(route([ |
| 1107 | [5.93,43.12], [8.0,41.0], [12.0,39.0], [18.0,37.5], [25.0,36.0], [30.0,35.0], [35.89,34.89] |
| 1108 | ], { fromName:'Toulon (Marine Nationale)', toName:'Tartus', domain:'INTEL', source:'Naval Intelligence' })); |
| 1109 | |
| 1110 | links.push(route([ |
| 1111 | [72.84,18.93], [68.0,21.0], [63.0,23.5], [58.0,25.0], [56.25,26.57] |
| 1112 | ], { fromName:'Mumbai (Western Naval Command)', toName:'Strait of Hormuz', domain:'INTEL', source:'Naval Intelligence', url:'https://www.indiannavy.nic.in/content/western-naval-command' })); |
| 1113 | |
| 1114 | // ── ADDITIONAL HIGH-FIDELITY ROUTES ── |
| 1115 | |
| 1116 | // Maritime: US West Coast → Hawaii → Guam → Taiwan |
| 1117 | links.push(route([ |
| 1118 | [-122.42,37.77], [-130.0,34.0], [-140.0,29.0], [-150.0,24.0], [-157.86,21.31] |
| 1119 | ], { fromName:'San Francisco', toName:'Honolulu', domain:'SEA', source:'AIS Maritime', url:'https://www.marinetraffic.com/en/ais/home/centerx:-140/centery:29/zoom:4' })); |
| 1120 | |
| 1121 | links.push(route([ |
| 1122 | [-157.86,21.31], [-170.0,18.0], [-180.0,16.5], [-200.0,14.0], [-215.25,13.44] |
| 1123 | ], { fromName:'Honolulu', toName:'Guam', domain:'SEA', source:'AIS Maritime', url:'https://www.marinetraffic.com/en/ais/home/centerx:-170/centery:18/zoom:4' })); |
| 1124 | |
| 1125 | links.push(route([ |
| 1126 | [144.75,13.44], [135.0,18.0], [125.0,23.0], [121.5,25.04] |
| 1127 | ], { fromName:'Guam', toName:'Taipei', domain:'SEA', source:'AIS Maritime', url:'https://www.marinetraffic.com/en/ais/home/centerx:135/centery:18/zoom:5' })); |
| 1128 | |
| 1129 | // Maritime: US East Coast → Gulf of Mexico |
| 1130 | links.push(route([ |
| 1131 | [-76.3,36.8], [-75.0,34.0], [-79.0,30.0], [-80.0,26.0], [-82.0,24.0], [-86.0,25.0], [-90.0,27.0], [-94.8,29.3] |
| 1132 | ], { fromName:'Norfolk', toName:'Galveston', domain:'SEA', source:'AIS Maritime', url:'https://www.marinetraffic.com/en/ais/home/centerx:-85/centery:26/zoom:5' })); |
| 1133 | |
| 1134 | // Maritime: Europe → West Africa |
| 1135 | links.push(route([ |
| 1136 | [-9.14,38.72], [-12.0,34.0], [-15.0,28.0], [-17.0,22.0], [-17.53,14.71] |
| 1137 | ], { fromName:'Lisbon', toName:'Dakar', domain:'SEA', source:'AIS Maritime', url:'https://www.marinetraffic.com/en/ais/home/centerx:-15/centery:25/zoom:4' })); |
| 1138 | |
| 1139 | links.push(route([ |
| 1140 | [-17.53,14.71], [-15.0,9.0], [-10.0,5.0], [-5.0,4.0], [0.0,4.5], [3.4,6.4] |
| 1141 | ], { fromName:'Dakar', toName:'Lagos', domain:'SEA', source:'AIS Maritime', url:'https://www.marinetraffic.com/en/ais/home/centerx:-5/centery:4/zoom:5' })); |
| 1142 | |
| 1143 | // Maritime: Australia → Japan |
| 1144 | links.push(route([ |
| 1145 | [151.2,-33.8], [153.0,-25.0], [155.0,-15.0], [154.0,-5.0], [150.0,5.0], [145.0,15.0], [140.0,25.0], [139.7,35.6] |
| 1146 | ], { fromName:'Sydney', toName:'Tokyo', domain:'SEA', source:'AIS Maritime', url:'https://www.marinetraffic.com/en/ais/home/centerx:145/centery:0/zoom:3' })); |
| 1147 | |
| 1148 | // Maritime: Australia → Singapore |
| 1149 | links.push(route([ |
| 1150 | [115.8,-31.9], [113.0,-25.0], [110.0,-15.0], [107.0,-5.0], [105.0,0.0], [103.8,1.2] |
| 1151 | ], { fromName:'Perth', toName:'Singapore', domain:'SEA', source:'AIS Maritime', url:'https://www.marinetraffic.com/en/ais/home/centerx:110/centery:-15/zoom:4' })); |
| 1152 | |
| 1153 | // Air: Trans-polar NY to Beijing |
| 1154 | links.push(route([ |
| 1155 | [-73.78,40.64], [-75.0,55.0], [-78.0,70.0], [-80.0,85.0], [110.0,80.0], [115.0,60.0], [116.60,40.08] |
| 1156 | ], { fromName:'JFK', toName:'Beijing', domain:'AIR', source:'ADS-B / OpenSky', url:'https://www.flightradar24.com/65.0,-75.0/4' })); |
| 1157 | |
| 1158 | // Air: South America to Europe |
| 1159 | links.push(route([ |
| 1160 | [-46.63,-23.55], [-40.0,-15.0], [-35.0,-5.0], [-30.0,5.0], [-20.0,15.0], [-15.0,25.0], [-10.0,35.0], [-0.46,51.47] |
| 1161 | ], { fromName:'Sao Paulo', toName:'London', domain:'AIR', source:'ADS-B / OpenSky', url:'https://www.flightradar24.com/15.0,-20.0/4' })); |
| 1162 | |
| 1163 | // Air: Middle East to Australia |
| 1164 | links.push(route([ |
| 1165 | [55.36,25.25], [65.0,15.0], [75.0,5.0], [85.0,-5.0], [100.0,-15.0], [115.0,-25.0], [130.0,-30.0], [151.2,-33.8] |
| 1166 | ], { fromName:'Dubai', toName:'Sydney', domain:'AIR', source:'ADS-B / OpenSky', url:'https://www.flightradar24.com/-5.0,90.0/4' })); |
| 1167 | |
| 1168 | // Intel: Trans-Atlantic Subsea Data Cable (TAT-14 equivalent) |
| 1169 | links.push(route([ |
| 1170 | [-74.01,40.12], [-65.0,42.0], [-50.0,46.0], [-35.0,48.0], [-20.0,49.0], [-5.0,50.0], [4.5,52.0] |
| 1171 | ], { fromName:'New Jersey Landing', toName:'Europe Landing', domain:'INTEL', source:'Global Subsea Cable Network', url:'https://www.submarinecablemap.com/' })); |
| 1172 | |
| 1173 | // Intel: Trans-Pacific Subsea Data Cable (FASTER equivalent) |
| 1174 | links.push(route([ |
| 1175 | [-124.0,43.0], [-135.0,45.0], [-150.0,47.0], [-165.0,48.0], [-185.0,47.0], [-205.0,42.0], [-220.0,35.0] |
| 1176 | ], { fromName:'Oregon Landing', toName:'Japan Landing', domain:'INTEL', source:'Global Subsea Cable Network', url:'https://www.submarinecablemap.com/' })); |
| 1177 | |
| 1178 | // Intel: Mediterranean Subsea Cable (SEA-ME-WE) |
| 1179 | links.push(route([ |
| 1180 | [5.3,43.3], [10.0,38.0], [18.0,35.0], [25.0,33.0], [31.2,31.2] |
| 1181 | ], { fromName:'Marseille', toName:'Alexandria', domain:'INTEL', source:'Global Subsea Cable Network', url:'https://www.submarinecablemap.com/' })); |
| 1182 | |
| 1183 | // Maritime: Suez to Mumbai (Arabian Sea) |
| 1184 | links.push(route([ |
| 1185 | [32.34,30.43], [35.0,25.0], [38.0,21.0], [41.0,17.0], [43.33,12.58], [45.0,12.0], [52.0,14.0], [60.0,15.0], [68.0,17.0], [72.84,18.93] |
| 1186 | ], { fromName:'Suez Canal', toName:'Mumbai', domain:'SEA', source:'AIS Maritime', url:'https://www.marinetraffic.com/en/ais/home/centerx:60/centery:15/zoom:5' })); |
| 1187 | |
| 1188 | // Maritime: Cape of Good Hope to Australia (Southern Ocean) |
| 1189 | links.push(route([ |
| 1190 | [18.47,-34.36], [40.0,-40.0], [60.0,-42.0], [80.0,-43.0], [100.0,-40.0], [115.8,-31.9] |
| 1191 | ], { fromName:'Cape of Good Hope', toName:'Perth', domain:'SEA', source:'AIS Maritime', url:'https://www.marinetraffic.com/en/ais/home/centerx:70/centery:-40/zoom:3' })); |
| 1192 | |
| 1193 | // Maritime: Panama Canal to Valparaiso (South America West Coast) |
| 1194 | links.push(route([ |
| 1195 | [-79.68,9.08], [-80.0,2.0], [-81.5,-5.0], [-78.0,-15.0], [-74.0,-25.0], [-71.6,-33.0] |
| 1196 | ], { fromName:'Panama Canal', toName:'Valparaiso', domain:'SEA', source:'AIS Maritime', url:'https://www.marinetraffic.com/en/ais/home/centerx:-78/centery:-15/zoom:4' })); |
| 1197 | |
| 1198 | // Air: London to Singapore |
| 1199 | links.push(route([ |
| 1200 | [-0.46,51.47], [15.0,48.0], [35.0,42.0], [55.0,35.0], [70.0,25.0], [85.0,15.0], [95.0,8.0], [103.8,1.2] |
| 1201 | ], { fromName:'London', toName:'Singapore', domain:'AIR', source:'ADS-B / OpenSky', url:'https://www.flightradar24.com/55.0,35.0/4' })); |
| 1202 | |
| 1203 | // Air: New York to Buenos Aires |
| 1204 | links.push(route([ |
| 1205 | [-73.78,40.64], [-70.0,20.0], [-65.0,0.0], [-55.0,-15.0], [-58.4,-34.6] |
| 1206 | ], { fromName:'JFK New York', toName:'Buenos Aires', domain:'AIR', source:'ADS-B / OpenSky', url:'https://www.flightradar24.com/-65.0,0.0/4' })); |
| 1207 | |
| 1208 | // Air: Tokyo to Sydney |
| 1209 | links.push(route([ |
| 1210 | [139.7,35.6], [142.0,20.0], [145.0,0.0], [148.0,-15.0], [151.2,-33.8] |
| 1211 | ], { fromName:'Tokyo', toName:'Sydney', domain:'AIR', source:'ADS-B / OpenSky', url:'https://www.flightradar24.com/145.0,0.0/4' })); |
| 1212 | |
| 1213 | // Intel: Arctic Patrol Route (Northern Fleet) |
| 1214 | links.push(route([ |
| 1215 | [33.42,69.07], [20.0,72.0], [0.0,75.0], [-20.0,72.0], [-30.0,65.0] |
| 1216 | ], { fromName:'Severomorsk', toName:'Greenland Sea', domain:'INTEL', source:'Naval Intelligence', url:'https://www.odni.gov' })); |
| 1217 | |
| 1218 | // Intel: South China Sea Carrier Patrol |
| 1219 | links.push(route([ |
| 1220 | [127.6,26.2], [123.0,24.0], [118.0,20.0], [114.0,15.0], [112.0,10.0] |
| 1221 | ], { fromName:'Okinawa', toName:'South China Sea', domain:'INTEL', source:'Naval Intelligence', url:'https://www.odni.gov' })); |
| 1222 | |
| 1223 | setGeo('sdk-links', links); |
| 1224 | }, [mapReady, activeLayers.sdk_stream, setGeo]); |
| 1225 | |
| 1226 | useEffect(() => { |
| 1227 | if (!mapReady) return; |
| 1228 | setGeo('live-news', activeLayers.live_news && data.live_feeds ? data.live_feeds.map((f: any) => ({ type: 'Feature', geometry: { type: 'Point', coordinates: [f.lng, f.lat] }, properties: { name: f.name, city: f.city, country: f.country, url: f.url, category: f.category, embed_allowed: f.embed_allowed !== false } })) : []); |
| 1229 | }, [mapReady, data.live_feeds, activeLayers.live_news, setGeo]); |
| 1230 | |
| 1231 | useEffect(() => { |
| 1232 | if (!mapReady) return; |
| 1233 | const items = data.news || []; |
| 1234 | setGeo('sigint-news', activeLayers.news_intel && items.length > 0 |
| 1235 | ? items.filter((n: any) => n.coords?.length === 2).map((n: any) => ({ |
| 1236 | type: 'Feature', |
| 1237 | geometry: { type: 'Point', coordinates: [n.coords[1], n.coords[0]] }, |
| 1238 | properties: { title: n.title, source: n.source, risk_score: n.risk_score, link: n.link } |
| 1239 | })) |
| 1240 | : []); |
| 1241 | }, [mapReady, data.news, activeLayers.news_intel, setGeo]); |
| 1242 | |
| 1243 | useEffect(() => { |
| 1244 | if (!mapReady) return; |
| 1245 | // ── CONFLICT ZONES — center-point warning markers ── |
| 1246 | const CONFLICT_ZONES = [ |
| 1247 | { label: 'UKRAINE WAR', severity: 'war', lat: 48.5, lng: 31.2 }, |
| 1248 | { label: 'GAZA CONFLICT', severity: 'war', lat: 31.35, lng: 34.35 }, |
| 1249 | { label: 'LEBANON BORDER', severity: 'high', lat: 33.4, lng: 35.8 }, |
| 1250 | { label: 'SUDAN CIVIL WAR', severity: 'war', lat: 15.0, lng: 30.0 }, |
| 1251 | { label: 'MYANMAR CONFLICT', severity: 'war', lat: 19.5, lng: 96.5 }, |
| 1252 | { label: 'DRC EASTERN CONFLICT', severity: 'war', lat: -1.0, lng: 28.5 }, |
| 1253 | { label: 'YEMEN WAR', severity: 'war', lat: 15.5, lng: 48.0 }, |
| 1254 | { label: 'SYRIA', severity: 'high', lat: 35.0, lng: 38.5 }, |
| 1255 | { label: 'TAIWAN STRAIT', severity: 'elevated', lat: 24.0, lng: 119.5 }, |
| 1256 | { label: 'KOREAN DMZ', severity: 'elevated', lat: 38.3, lng: 127.0 }, |
| 1257 | { label: 'SAHEL INSTABILITY', severity: 'high', lat: 14.0, lng: 5.0 }, |
| 1258 | { label: 'SOMALIA', severity: 'high', lat: 5.0, lng: 46.0 }, |
| 1259 | { label: 'RED SEA THREAT', severity: 'high', lat: 16.0, lng: 40.0 }, |
| 1260 | ]; |
| 1261 | const conflictFeatures = CONFLICT_ZONES.map(z => ({ |
| 1262 | type: 'Feature' as const, |
| 1263 | geometry: { type: 'Point' as const, coordinates: [z.lng, z.lat] }, |
| 1264 | properties: { label: z.label, severity: z.severity }, |
| 1265 | })); |
| 1266 | setGeo('conflict-zones', conflictFeatures); |
| 1267 | }, [mapReady, setGeo]); |
| 1268 | |
| 1269 | |
| 1270 | // Visibility |
| 1271 | useEffect(() => { |
| 1272 | if (!mapReady) return; |
| 1273 | setVis(['eq-circles','eq-label'], activeLayers.earthquakes); |
| 1274 | setVis(['sat-dots'], activeLayers.satellites); |
| 1275 | setVis(['gdelt-dots'], activeLayers.global_incidents); |
| 1276 | setVis(['jam-fill','jam-label'], activeLayers.gps_jamming); |
| 1277 | setVis(['day-night-fill'], activeLayers.day_night); |
| 1278 | setVis(['fl-commercial'], activeLayers.flights); |
| 1279 | setVis(['fl-private'], activeLayers.private); |
| 1280 | setVis(['fl-jets'], activeLayers.jets); |
| 1281 | setVis(['fl-military'], activeLayers.military); |
| 1282 | setVis(['cctv-glow','cctv-dots','cctv-label'], activeLayers.cctv); |
| 1283 | setVis(['fires-heat'], activeLayers.fires); |
| 1284 | setVis(['weather-glow','weather-dots','weather-label'], activeLayers.weather); |
| 1285 | setVis(['infra-glow','infra-dots','infra-label'], activeLayers.infrastructure); |
| 1286 | setVis(['maritime-glow','maritime-dots','maritime-label'], activeLayers.maritime); |
| 1287 | setVis(['choke-glow','choke-dots','choke-label'], activeLayers.maritime); |
| 1288 | setVis(['ship-dots','ship-label'], activeLayers.maritime); |
| 1289 | setVis(['news-glow','news-dots','news-label'], activeLayers.live_news); |
| 1290 | setVis(['sigint-news-glow','sigint-news-dots','sigint-news-label'], activeLayers.news_intel); |
| 1291 | setVis(['conflict-icons'], activeLayers.conflict_zones !== false); |
| 1292 | |
| 1293 | setVis(['balloon-dots','balloon-label'], activeLayers.balloons); |
| 1294 | setVis(['rad-glow','rad-dots','rad-label'], activeLayers.radiation); |
| 1295 | setVis(['sdk-sea','sdk-air','sdk-intel'], activeLayers.sdk_stream !== false); |
| 1296 | // Sweep layers always visible when data is present (controlled by useEffect) |
| 1297 | setVis(['sweep-connections','sweep-pulse-ring','sweep-device-glow','sweep-device-dots','sweep-device-labels'], true); |
| 1298 | }, [mapReady, activeLayers, setVis]); |
| 1299 | |
| 1300 | // IP Sweep visualization |
| 1301 | useEffect(() => { |
| 1302 | if (!mapReady) return; |
| 1303 | if (!sweepData?.devices?.length) { |
| 1304 | setGeo('ip-sweep-devices', []); |
| 1305 | setGeo('ip-sweep-pulse', []); |
| 1306 | setGeo('ip-sweep-connections', []); |
| 1307 | return; |
| 1308 | } |
| 1309 | |
| 1310 | const map = mapRef.current; |
| 1311 | if (!map) return; |
| 1312 | |
| 1313 | const { center, devices } = sweepData; |
| 1314 | const centerCoord: [number, number] = [center.lng, center.lat]; |
| 1315 | |
| 1316 | // Switch to globe and fly to the sweep location |
| 1317 | try { |
| 1318 | (map as any).setProjection({ type: 'globe' }); |
| 1319 | map.setSky({ 'sky-color': '#0A0A0F', 'sky-horizon-blend': 0.02, 'horizon-color': '#0A0A0F', 'horizon-fog-blend': 0.02 }); |
| 1320 | } catch { /* projection may not be supported */ } |
| 1321 | |
| 1322 | map.flyTo({ center: centerCoord, zoom: 14, pitch: 50, bearing: -20, duration: 3000, essential: true }); |
| 1323 | |
| 1324 | // Set center pulse |
| 1325 | setGeo('ip-sweep-pulse', [{ |
| 1326 | type: 'Feature' as const, |
| 1327 | geometry: { type: 'Point' as const, coordinates: centerCoord }, |
| 1328 | properties: { ip: sweepData.target_ip }, |
| 1329 | }]); |
| 1330 | |
| 1331 | // Build device features spread in a circle around center |
| 1332 | const allDeviceFeatures = devices.map((d: any, i: number) => { |
| 1333 | const angle = (i / devices.length) * Math.PI * 2; |
| 1334 | const radius = 0.001 + ((i % 7 + 1) * 0.0004); |
| 1335 | const dLng = centerCoord[0] + Math.cos(angle) * radius * (1 / Math.cos(center.lat * Math.PI / 180)); |
| 1336 | const dLat = centerCoord[1] + Math.sin(angle) * radius; |
| 1337 | return { |
| 1338 | type: 'Feature' as const, |
| 1339 | geometry: { type: 'Point' as const, coordinates: [dLng, dLat] }, |
| 1340 | properties: { |
| 1341 | ip: d.ip, device_type: d.device_type, device_icon: d.device_icon, |
| 1342 | color: d.device_color, risk_level: d.risk_level, |
| 1343 | ports: JSON.stringify(d.ports), hostnames: JSON.stringify(d.hostnames), |
| 1344 | vulns: JSON.stringify(d.vulns), cpes: JSON.stringify(d.cpes), tags: JSON.stringify(d.tags), |
| 1345 | }, |
| 1346 | }; |
| 1347 | }); |
| 1348 | |
| 1349 | // Connection lines from center to each device |
| 1350 | const connectionFeatures = allDeviceFeatures.map((f: any) => ({ |
| 1351 | type: 'Feature' as const, |
| 1352 | geometry: { type: 'LineString' as const, coordinates: [centerCoord, f.geometry.coordinates] }, |
| 1353 | properties: { color: f.properties.color }, |
| 1354 | })); |
| 1355 | |
| 1356 | // Stagger the appearance after 3s flyTo completes |
| 1357 | const timer = setTimeout(() => { |
| 1358 | setGeo('ip-sweep-connections', connectionFeatures); |
| 1359 | const batchSize = 5; |
| 1360 | const batches = Math.ceil(allDeviceFeatures.length / batchSize); |
| 1361 | for (let b = 0; b < batches; b++) { |
| 1362 | setTimeout(() => { |
| 1363 | setGeo('ip-sweep-devices', allDeviceFeatures.slice(0, (b + 1) * batchSize)); |
| 1364 | }, b * 100); |
| 1365 | } |
| 1366 | }, 3000); |
| 1367 | |
| 1368 | return () => clearTimeout(timer); |
| 1369 | }, [mapReady, sweepData, setGeo]); |
| 1370 | |
| 1371 | // Scan Targets visualization |
| 1372 | useEffect(() => { |
| 1373 | if (!mapReady || !mapRef.current || !scanTargets) return; |
| 1374 | const map = mapRef.current; |
| 1375 | |
| 1376 | const features = scanTargets.map(t => ({ |
| 1377 | type: 'Feature' as const, |
| 1378 | geometry: { type: 'Point' as const, coordinates: [t.lng, t.lat] }, |
| 1379 | properties: { ...t } |
| 1380 | })); |
| 1381 | |
| 1382 | const src = map.getSource('scan-targets') as maplibregl.GeoJSONSource; |
| 1383 | if (src) src.setData({ type: 'FeatureCollection', features }); |
| 1384 | }, [scanTargets, mapReady]); |
| 1385 | |
| 1386 | // Fly-to |
| 1387 | useEffect(() => { |
| 1388 | if (!mapReady || !mapRef.current || !flyToLocation) return; |
| 1389 | mapRef.current.flyTo({ center: [flyToLocation.lng, flyToLocation.lat], zoom: 8, duration: 2000 }); |
| 1390 | }, [mapReady, flyToLocation]); |
| 1391 | |
| 1392 | // Dynamic projection switching (lightweight — no terrain DEM) |
| 1393 | useEffect(() => { |
| 1394 | if (!mapReady || !mapRef.current) return; |
| 1395 | const map = mapRef.current; |
| 1396 | try { |
| 1397 | (map as any).setProjection({ type: projection }); |
| 1398 | if (projection === 'globe') { |
| 1399 | map.easeTo({ pitch: 20, duration: 1200 }); |
| 1400 | try { |
| 1401 | (map as any).setSky({ |
| 1402 | 'sky-color': '#04040A', |
| 1403 | 'sky-horizon-blend': 0.5, |
| 1404 | 'horizon-color': '#0a0a1a', |
| 1405 | 'horizon-fog-blend': 0.3, |
| 1406 | 'fog-color': '#04040A', |
| 1407 | 'fog-ground-blend': 0.9, |
| 1408 | }); |
| 1409 | } catch (e) { console.warn('[OSIRIS] Suppressed error:', e instanceof Error ? e.message : e); } |
| 1410 | } else { |
| 1411 | map.easeTo({ pitch: 0, duration: 800 }); |
| 1412 | } |
| 1413 | } catch (e) { |
| 1414 | console.warn('Projection switch failed:', e); |
| 1415 | } |
| 1416 | }, [mapReady, projection]); |
| 1417 | |
| 1418 | // Satellite / Dark style switching |
| 1419 | useEffect(() => { |
| 1420 | if (!mapReady || !mapRef.current) return; |
| 1421 | if (mapStyle === prevStyleRef.current) return; |
| 1422 | prevStyleRef.current = mapStyle; |
| 1423 | const map = mapRef.current; |
| 1424 | |
| 1425 | try { |
| 1426 | if (mapStyle !== 'dark') { |
| 1427 | // Add satellite raster tiles |
| 1428 | if (!map.getSource('satellite-tiles')) { |
| 1429 | map.addSource('satellite-tiles', { |
| 1430 | type: 'raster', |
| 1431 | tiles: ['https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}'], |
| 1432 | tileSize: 256, |
| 1433 | maxzoom: 18, |
| 1434 | }); |
| 1435 | map.addLayer({ id: 'satellite-layer', type: 'raster', source: 'satellite-tiles', paint: { 'raster-opacity': 0.85 } }, 'day-night-fill'); |
| 1436 | } else { |
| 1437 | map.setLayoutProperty('satellite-layer', 'visibility', 'visible'); |
| 1438 | } |
| 1439 | } else { |
| 1440 | if (map.getLayer('satellite-layer')) { |
| 1441 | map.setLayoutProperty('satellite-layer', 'visibility', 'none'); |
| 1442 | } |
| 1443 | } |
| 1444 | } catch (e) { |
| 1445 | console.warn('Style switch failed:', e); |
| 1446 | } |
| 1447 | }, [mapReady, mapStyle]); |
| 1448 | |
| 1449 | return <div ref={containerRef} className="absolute inset-0 w-full h-full" />; |
| 1450 | } |
| 1451 | |
| 1452 | export default memo(OsirisMap); |