Safeguard: prevent errors when GisStationsMeasurements is empty or missing
- Ensure createAndSetDevices.js always uses an array for measurements - Prevents crashes if measurement data is empty
This commit is contained in:
@@ -49,13 +49,15 @@ export const createAndSetDevices = async (
|
||||
const staticDistrictData = selectGisStationsStaticDistrict(state);
|
||||
const statusDistrictData = selectGisStationsStatusDistrict(state);
|
||||
const measurementData = selectGisStationsMeasurements(state);
|
||||
// Sicherstellen, dass measurementData immer ein Array ist
|
||||
const safeMeasurementData = Array.isArray(measurementData) ? measurementData : [];
|
||||
|
||||
if (!staticDistrictData?.Points?.length) return;
|
||||
const hasStatus = Array.isArray(statusDistrictData) && statusDistrictData.length > 0;
|
||||
|
||||
const statisMap = new Map(statusDistrictData.map(s => [s.IdLD, s]));
|
||||
const measurementsMap = new Map();
|
||||
measurementData?.forEach(m => {
|
||||
safeMeasurementData.forEach(m => {
|
||||
if (!measurementsMap.has(m.IdLD)) {
|
||||
measurementsMap.set(m.IdLD, m);
|
||||
}
|
||||
@@ -118,10 +120,10 @@ export const createAndSetDevices = async (
|
||||
marker.bindPopup(popupContent);
|
||||
|
||||
// ✅ Tooltip (nur für System 11)
|
||||
|
||||
if (station.System === 11 && messung) {
|
||||
const gmaMap = new Map();
|
||||
|
||||
measurementData?.forEach(m => {
|
||||
safeMeasurementData.forEach(m => {
|
||||
if (!gmaMap.has(m.IdLD)) {
|
||||
gmaMap.set(m.IdLD, {});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user