Fix: Ortsspezifische Monitor-Infos statt globale Summary

Klick auf Waldbrand in USA zeigt jetzt US-Waldbrand-Headlines.
Klick auf Ueberschwemmung in Kenia zeigt Kenia-Headlines.
Nicht mehr die globale Lage-Summary fuer alle Standorte.

Logik: Naechsten Monitor-Standort zur Klickposition suchen (5-Grad-Radius).
Wenn gefunden: dessen ortsspezifische Headlines anzeigen.
Wenn nicht gefunden: globale Lage-Summary als Fallback.
Dieser Commit ist enthalten in:
Claude Dev
2026-03-24 13:38:43 +01:00
Ursprung a3b4890f1e
Commit 91fdd806bd

Datei anzeigen

@@ -35,31 +35,72 @@ const DisastersLayer = {
.catch(function() {}); .catch(function() {});
}, },
_findMonitorSummary(lat, lon) { _findMonitorInfo(lat, lon) {
if (!this._monitorData || !this._monitorData.incidents) return null; if (!this._monitorData) return null;
// Nur die aktuell ausgewaehlte Lage verwenden
var selectedId = (typeof Globe !== 'undefined') ? Globe._currentLageId : null; var selectedId = (typeof Globe !== 'undefined') ? Globe._currentLageId : null;
if (!selectedId) return null; if (!selectedId) return null;
// Naechsten Monitor-Standort zur Klickposition finden
var features = this._monitorData.features || [];
var best = null, bestDist = 999;
for (var i = 0; i < features.length; i++) {
var f = features[i];
var c = f.geometry.coordinates;
var d = Math.abs(c[1] - lat) + Math.abs(c[0] - lon);
if (d < bestDist) { bestDist = d; best = f; }
}
// Lage-Infos
var incidents = this._monitorData.incidents || []; var incidents = this._monitorData.incidents || [];
var incident = null; var incident = null;
for (var j = 0; j < incidents.length; j++) { for (var j = 0; j < incidents.length; j++) {
if (incidents[j].id === selectedId && incidents[j].summary) { incident = incidents[j]; break; } if (incidents[j].id === selectedId) { incident = incidents[j]; break; }
} }
return incident;
if (!best || bestDist > 5) return { incident: incident, feature: null };
return { incident: incident, feature: best };
}, },
_buildMonitorHtml(incident) { _buildMonitorHtml(lat, lon) {
if (!incident || !incident.summary) return ''; var info = this._findMonitorInfo(lat, lon);
var summary = incident.summary if (!info || !info.incident) return '';
var html = '<div style="border-top:1px solid #333;padding-top:8px;margin-top:8px">';
html += '<div style="color:#00ff88;font-size:10px;letter-spacing:1px;margin-bottom:6px">MONITOR: ' +
(info.incident.title || 'LAGE').toUpperCase() + '</div>';
// Ortsspezifische Headlines wenn passender Standort gefunden
if (info.feature) {
var p = info.feature.properties;
var headlines = p.headlines || [];
if (headlines.length && headlines[0]) {
html += '<div style="color:#00ff88;font-size:11px;margin-bottom:4px">' + (p.name || '') +
' (' + (p.article_count || 0) + ' Artikel)</div>';
html += '<div style="border-left:2px solid #00ff88;padding-left:8px;margin-bottom:8px">';
for (var h = 0; h < Math.min(headlines.length, 3); h++) {
if (headlines[h] && headlines[h].trim()) {
html += '<div style="color:#e0e0e0;font-size:11px;margin-bottom:3px">&bull; ' +
headlines[h].trim().substring(0, 120) + '</div>';
}
}
html += '</div>';
}
} else {
// Kein passender Standort in der Naehe — globale Summary
if (info.incident.summary) {
var summary = info.incident.summary
.replace(/##?\s*/g, '').replace(/\*\*/g, '').replace(/\[(\d+)\]/g, '') .replace(/##?\s*/g, '').replace(/\*\*/g, '').replace(/\[(\d+)\]/g, '')
.substring(0, 600); .substring(0, 400);
return '<div style="border-top:1px solid #333;padding-top:8px;margin-top:8px">' + html += '<div style="color:#ccc;font-size:11px;line-height:1.5">' + summary + '</div>';
'<div style="color:#00ff88;font-size:10px;letter-spacing:1px;margin-bottom:4px">MONITOR: ' + }
(incident.title || 'LAGE').toUpperCase() + '</div>' + }
'<div style="color:#ccc;font-size:11px;line-height:1.5">' + summary +
(incident.summary.length > 600 ? '...' : '') + '</div>' + if (info.incident.updated_at) {
'<div style="color:#666;font-size:9px;margin-top:4px">Stand: ' + html += '<div style="color:#666;font-size:9px;margin-top:4px">Stand: ' +
new Date(incident.updated_at).toLocaleString('de-DE') + '</div></div>'; new Date(info.incident.updated_at).toLocaleString('de-DE') + '</div>';
}
html += '</div>';
return html;
}, },
_fetch() { _fetch() {
@@ -106,7 +147,7 @@ const DisastersLayer = {
var coords = latest.coordinates; var coords = latest.coordinates;
if (!coords || coords.length < 2) return; if (!coords || coords.length < 2) return;
var monitorHtml = self._buildMonitorHtml(self._findMonitorSummary(coords[1], coords[0])); var monitorHtml = self._buildMonitorHtml(coords[1], coords[0]);
self._dataSource.entities.add({ self._dataSource.entities.add({
position: Cesium.Cartesian3.fromDegrees(coords[0], coords[1], 0), position: Cesium.Cartesian3.fromDegrees(coords[0], coords[1], 0),
@@ -146,7 +187,7 @@ const DisastersLayer = {
var ageH = (now - p.time) / 3600000; var ageH = (now - p.time) / 3600000;
var color = ageH < 1 ? '#ff0000' : ageH < 6 ? '#ff6600' : ageH < 12 ? '#ffaa00' : '#ffdd00'; var color = ageH < 1 ? '#ff0000' : ageH < 6 ? '#ff6600' : ageH < 12 ? '#ffaa00' : '#ffdd00';
var monitorHtml = self._buildMonitorHtml(self._findMonitorSummary(c[1], c[0])); var monitorHtml = self._buildMonitorHtml(c[1], c[0]);
self._dataSource.entities.add({ self._dataSource.entities.add({
position: Cesium.Cartesian3.fromDegrees(c[0], c[1], 0), position: Cesium.Cartesian3.fromDegrees(c[0], c[1], 0),