/** * Katastrophen-Layer: NASA EONET + USGS Erdbeben kombiniert. */ const DisastersLayer = { _viewer: null, _dataSource: null, _interval: null, _count: 0, start(viewer) { if (this._dataSource) return; this._viewer = viewer; this._dataSource = new Cesium.CustomDataSource('disasters'); viewer.dataSources.add(this._dataSource); this._fetch(); var self = this; this._interval = setInterval(function() { self._fetch(); }, 600000); }, stop() { if (this._interval) { clearInterval(this._interval); this._interval = null; } if (this._dataSource && this._viewer) { this._viewer.dataSources.remove(this._dataSource); this._dataSource = null; } this._count = 0; }, _fetch() { var self = this; var loadEl = document.getElementById('loading-disasters'); var statusEl = document.getElementById('status-disasters'); if (loadEl) loadEl.classList.add('active'); if (statusEl) { statusEl.textContent = 'Lade Katastrophen + Erdbeben...'; statusEl.classList.add('active'); } Promise.all([ fetch('/api/disasters').then(function(r) { return r.json(); }).catch(function() { return { events: [] }; }), fetch('/api/quakes').then(function(r) { return r.json(); }).catch(function() { return { features: [] }; }) ]) .then(function(results) { if (!self._dataSource) return; self._dataSource.entities.removeAll(); var events = results[0].events || []; var quakes = results[1].features || []; self._renderEonet(events); self._renderQuakes(quakes); self._count = events.length + quakes.length; if (statusEl) statusEl.textContent = self._count + ' Ereignisse'; }) .catch(function(e) { console.warn('Disasters error:', e); if (statusEl) statusEl.textContent = 'Fehler'; }) .finally(function() { if (loadEl) loadEl.classList.remove('active'); setTimeout(function() { if (statusEl) statusEl.classList.remove('active'); }, 5000); }); }, _renderEonet(events) { var self = this; var icons = { 'wildfires': { color: '#ff4400', label: 'Waldbrand' }, 'volcanoes': { color: '#ff0000', label: 'Vulkan' }, 'severeStorms': { color: '#aa44ff', label: 'Sturm' }, 'floods': { color: '#4488ff', label: 'Flut' }, 'earthquakes': { color: '#ffaa00', label: 'Erdbeben' }, 'seaLakeIce': { color: '#88ddff', label: 'Eis' }, 'landslides': { color: '#886644', label: 'Erdrutsch' }, }; events.forEach(function(evt) { var cats = evt.categories || []; var catId = cats.length ? cats[0].id : 'unknown'; var icon = icons[catId] || { color: '#ffffff', label: catId }; var geom = evt.geometry || []; if (!geom.length) return; var latest = geom[geom.length - 1]; var coords = latest.coordinates; if (!coords || coords.length < 2) return; self._dataSource.entities.add({ position: Cesium.Cartesian3.fromDegrees(coords[0], coords[1], 0), point: { pixelSize: 8, color: Cesium.Color.fromCssColorString(icon.color), outlineColor: Cesium.Color.fromCssColorString(icon.color).withAlpha(0.4), outlineWidth: 3, heightReference: Cesium.HeightReference.NONE, }, label: { text: icon.label, font: '10px monospace', fillColor: Cesium.Color.fromCssColorString(icon.color), outlineColor: Cesium.Color.BLACK, outlineWidth: 2, style: Cesium.LabelStyle.FILL_AND_OUTLINE, pixelOffset: new Cesium.Cartesian2(0, -14), scale: 0.7, distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 5000000), }, description: '