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
|
# 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
|
# basePath wird jetzt in public/config.json gepflegt
|
||||||
# App-Versionsnummer
|
# 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
|
# basePath wird jetzt in public/config.json gepflegt
|
||||||
|
|
||||||
# App-Versionsnummer
|
# 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",
|
"name": "nodemap",
|
||||||
"version": "1.1.325",
|
"version": "1.1.326",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "nodemap",
|
"name": "nodemap",
|
||||||
"version": "1.1.325",
|
"version": "1.1.326",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emotion/react": "^11.13.3",
|
"@emotion/react": "^11.13.3",
|
||||||
"@emotion/styled": "^11.13.0",
|
"@emotion/styled": "^11.13.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nodemap",
|
"name": "nodemap",
|
||||||
"version": "1.1.325",
|
"version": "1.1.326",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emotion/react": "^11.13.3",
|
"@emotion/react": "^11.13.3",
|
||||||
"@emotion/styled": "^11.13.0",
|
"@emotion/styled": "^11.13.0",
|
||||||
|
|||||||
@@ -49,13 +49,15 @@ export const createAndSetDevices = async (
|
|||||||
const staticDistrictData = selectGisStationsStaticDistrict(state);
|
const staticDistrictData = selectGisStationsStaticDistrict(state);
|
||||||
const statusDistrictData = selectGisStationsStatusDistrict(state);
|
const statusDistrictData = selectGisStationsStatusDistrict(state);
|
||||||
const measurementData = selectGisStationsMeasurements(state);
|
const measurementData = selectGisStationsMeasurements(state);
|
||||||
|
// Sicherstellen, dass measurementData immer ein Array ist
|
||||||
|
const safeMeasurementData = Array.isArray(measurementData) ? measurementData : [];
|
||||||
|
|
||||||
if (!staticDistrictData?.Points?.length) return;
|
if (!staticDistrictData?.Points?.length) return;
|
||||||
const hasStatus = Array.isArray(statusDistrictData) && statusDistrictData.length > 0;
|
const hasStatus = Array.isArray(statusDistrictData) && statusDistrictData.length > 0;
|
||||||
|
|
||||||
const statisMap = new Map(statusDistrictData.map(s => [s.IdLD, s]));
|
const statisMap = new Map(statusDistrictData.map(s => [s.IdLD, s]));
|
||||||
const measurementsMap = new Map();
|
const measurementsMap = new Map();
|
||||||
measurementData?.forEach(m => {
|
safeMeasurementData.forEach(m => {
|
||||||
if (!measurementsMap.has(m.IdLD)) {
|
if (!measurementsMap.has(m.IdLD)) {
|
||||||
measurementsMap.set(m.IdLD, m);
|
measurementsMap.set(m.IdLD, m);
|
||||||
}
|
}
|
||||||
@@ -118,10 +120,10 @@ export const createAndSetDevices = async (
|
|||||||
marker.bindPopup(popupContent);
|
marker.bindPopup(popupContent);
|
||||||
|
|
||||||
// ✅ Tooltip (nur für System 11)
|
// ✅ Tooltip (nur für System 11)
|
||||||
|
|
||||||
if (station.System === 11 && messung) {
|
if (station.System === 11 && messung) {
|
||||||
const gmaMap = new Map();
|
const gmaMap = new Map();
|
||||||
|
safeMeasurementData.forEach(m => {
|
||||||
measurementData?.forEach(m => {
|
|
||||||
if (!gmaMap.has(m.IdLD)) {
|
if (!gmaMap.has(m.IdLD)) {
|
||||||
gmaMap.set(m.IdLD, {});
|
gmaMap.set(m.IdLD, {});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user