diff --git a/static/js/layers/disasters.js b/static/js/layers/disasters.js
index 7286ffa..84ae17f 100644
--- a/static/js/layers/disasters.js
+++ b/static/js/layers/disasters.js
@@ -35,31 +35,72 @@ const DisastersLayer = {
.catch(function() {});
},
- _findMonitorSummary(lat, lon) {
- if (!this._monitorData || !this._monitorData.incidents) return null;
- // Nur die aktuell ausgewaehlte Lage verwenden
+ _findMonitorInfo(lat, lon) {
+ if (!this._monitorData) return null;
var selectedId = (typeof Globe !== 'undefined') ? Globe._currentLageId : 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 incident = null;
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) {
- if (!incident || !incident.summary) return '';
- var summary = incident.summary
- .replace(/##?\s*/g, '').replace(/\*\*/g, '').replace(/\[(\d+)\]/g, '')
- .substring(0, 600);
- return '
' +
- '
MONITOR: ' +
- (incident.title || 'LAGE').toUpperCase() + '
' +
- '
' + summary +
- (incident.summary.length > 600 ? '...' : '') + '
' +
- '
Stand: ' +
- new Date(incident.updated_at).toLocaleString('de-DE') + '
';
+ _buildMonitorHtml(lat, lon) {
+ var info = this._findMonitorInfo(lat, lon);
+ if (!info || !info.incident) return '';
+
+ var html = '';
+ html += '
MONITOR: ' +
+ (info.incident.title || 'LAGE').toUpperCase() + '
';
+
+ // Ortsspezifische Headlines wenn passender Standort gefunden
+ if (info.feature) {
+ var p = info.feature.properties;
+ var headlines = p.headlines || [];
+ if (headlines.length && headlines[0]) {
+ html += '
' + (p.name || '') +
+ ' (' + (p.article_count || 0) + ' Artikel)
';
+ html += '
';
+ for (var h = 0; h < Math.min(headlines.length, 3); h++) {
+ if (headlines[h] && headlines[h].trim()) {
+ html += '
• ' +
+ headlines[h].trim().substring(0, 120) + '
';
+ }
+ }
+ html += '
';
+ }
+ } 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, '')
+ .substring(0, 400);
+ html += '
' + summary + '
';
+ }
+ }
+
+ if (info.incident.updated_at) {
+ html += '
Stand: ' +
+ new Date(info.incident.updated_at).toLocaleString('de-DE') + '
';
+ }
+ html += '
';
+ return html;
},
_fetch() {
@@ -106,7 +147,7 @@ const DisastersLayer = {
var coords = latest.coordinates;
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({
position: Cesium.Cartesian3.fromDegrees(coords[0], coords[1], 0),
@@ -146,7 +187,7 @@ const DisastersLayer = {
var ageH = (now - p.time) / 3600000;
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({
position: Cesium.Cartesian3.fromDegrees(c[0], c[1], 0),