fix: Lightning updates every 30s + add earthquake debug logging

Lightning:
- Strike IDs now include rounded timestamp (10s intervals)
- This allows strikes to 'cycle' and be detected as new every 10 seconds
- Strikes stay at same location but IDs change to trigger updates
- Stats panel now updates properly every 30 seconds

Earthquakes:
- Added console logging to debug why markers don't appear
- Logs: fetch count, enabled state, marker creation count
- Will help identify if it's a data fetch or rendering issue
pull/82/head
trancen 2 days ago
parent 2ac8419fec
commit 1f5f618359

@ -38,6 +38,7 @@ export function useLayer({ enabled = false, opacity = 0.9, map = null }) {
'https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_hour.geojson'
);
const data = await response.json();
console.log('Earthquakes fetched:', data.features?.length || 0, 'quakes');
setEarthquakeData(data.features || []);
} catch (err) {
console.error('Earthquake data fetch error:', err);
@ -66,7 +67,10 @@ export function useLayer({ enabled = false, opacity = 0.9, map = null }) {
});
setMarkersRef([]);
if (!enabled || earthquakeData.length === 0) return;
if (!enabled || earthquakeData.length === 0) {
console.log('Earthquakes: enabled=', enabled, 'data count=', earthquakeData.length);
return;
}
const newMarkers = [];
const currentQuakeIds = new Set();
@ -197,6 +201,7 @@ export function useLayer({ enabled = false, opacity = 0.9, map = null }) {
isFirstLoad.current = false;
}
console.log('Earthquakes: Created', newMarkers.length, 'markers on map');
setMarkersRef(newMarkers);
return () => {

@ -66,13 +66,14 @@ function generateSimulatedStrikes(count = 50) {
const cycleMs = 30 * 60 * 1000; // 30 minute cycle
const ageMs = ((now + (i * 10000)) % cycleMs); // Stagger ages
const timestamp = now - ageMs;
const roundedTime = Math.floor(timestamp / 10000) * 10000; // Round to 10s for ID changes
// Intensity fixed for this strike
const intensity = (r2 * 200) - 50; // -50 to +150 kA
const polarity = intensity >= 0 ? 'positive' : 'negative';
strikes.push({
id: `strike_${i}_${lat}_${lon}`, // Index-based ID = always same
id: `strike_${i}_${lat}_${lon}_${roundedTime}`, // Include time for ID changes
lat, // Fixed position
lon, // Fixed position
timestamp,

Loading…
Cancel
Save

Powered by TurnKey Linux.