const InfraLayer = { _viewer: null, _points: null, _labels: null, _count: 0, start(viewer) { if (this._points) return; this._viewer = viewer; this._points = viewer.scene.primitives.add(new Cesium.PointPrimitiveCollection()); this._labels = viewer.scene.primitives.add(new Cesium.LabelCollection()); this._fetchNuclear(); this._fetchBases(); }, stop() { if (this._points && this._viewer) { this._viewer.scene.primitives.remove(this._points); this._points = null; } if (this._labels && this._viewer) { this._viewer.scene.primitives.remove(this._labels); this._labels = null; } this._count = 0; }, _fetchNuclear() { var self = this; fetch('/api/nuclear-plants') .then(function(r) { return r.json(); }) .then(function(data) { var yellow = Cesium.Color.fromCssColorString('#ffdd00'); (data.plants || []).forEach(function(p) { self._points.add({ position: Cesium.Cartesian3.fromDegrees(p.lon, p.lat, 0), pixelSize: 7, color: yellow, outlineColor: Cesium.Color.fromCssColorString('#ff8800'), outlineWidth: 2 }); self._labels.add({ position: Cesium.Cartesian3.fromDegrees(p.lon, p.lat, 0), text: p.name, font: '9px sans-serif', fillColor: yellow, outlineColor: Cesium.Color.BLACK, outlineWidth: 2, style: Cesium.LabelStyle.FILL_AND_OUTLINE, pixelOffset: new Cesium.Cartesian2(0, -10), scale: 0.6, distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 500000), }); }); self._count += (data.plants || []).length; var s = document.getElementById('status-infra'); if (s) { s.textContent = self._count + ' Standorte'; s.classList.add('active'); setTimeout(function() { s.classList.remove('active'); }, 5000); } }).catch(function() {}); }, _fetchBases() { var self = this; fetch('/api/military-bases') .then(function(r) { return r.json(); }) .then(function(data) { var red = Cesium.Color.fromCssColorString('#ff4444'); (data.bases || []).forEach(function(b) { self._points.add({ position: Cesium.Cartesian3.fromDegrees(b.lon, b.lat, 0), pixelSize: 6, color: red, outlineColor: Cesium.Color.fromCssColorString('#aa0000'), outlineWidth: 1 }); self._labels.add({ position: Cesium.Cartesian3.fromDegrees(b.lon, b.lat, 0), text: b.name, font: '9px sans-serif', fillColor: red, outlineColor: Cesium.Color.BLACK, outlineWidth: 2, style: Cesium.LabelStyle.FILL_AND_OUTLINE, pixelOffset: new Cesium.Cartesian2(0, -10), scale: 0.6, distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 500000), }); }); self._count += (data.bases || []).length; }).catch(function() {}); }, };