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:
@@ -24,4 +24,4 @@ NEXT_PUBLIC_USE_MOCKS=true
|
||||
# z.B. http://10.10.0.13/xyz/index.aspx -> basePath in config.json auf /xyz setzen
|
||||
# basePath wird jetzt in public/config.json gepflegt
|
||||
# App-Versionsnummer
|
||||
NEXT_PUBLIC_APP_VERSION=1.1.325
|
||||
NEXT_PUBLIC_APP_VERSION=1.1.326
|
||||
|
||||
@@ -25,4 +25,4 @@ NEXT_PUBLIC_USE_MOCKS=false
|
||||
# basePath wird jetzt in public/config.json gepflegt
|
||||
|
||||
# App-Versionsnummer
|
||||
NEXT_PUBLIC_APP_VERSION=1.1.325
|
||||
NEXT_PUBLIC_APP_VERSION=1.1.326
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "nodemap",
|
||||
"version": "1.1.325",
|
||||
"version": "1.1.326",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "nodemap",
|
||||
"version": "1.1.325",
|
||||
"version": "1.1.326",
|
||||
"dependencies": {
|
||||
"@emotion/react": "^11.13.3",
|
||||
"@emotion/styled": "^11.13.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nodemap",
|
||||
"version": "1.1.325",
|
||||
"version": "1.1.326",
|
||||
"dependencies": {
|
||||
"@emotion/react": "^11.13.3",
|
||||
"@emotion/styled": "^11.13.0",
|
||||
|
||||
@@ -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