git commit -m "fix: Fehlerbehandlung für fehlende gis_lines-Tabelle und Verwendung des DB-Namens aus .env
- Verhindert Absturz der Anwendung, wenn die gis_lines-Tabelle fehlt - Gibt stattdessen eine Warnung in der Konsole aus - Stellt sicher, dass der Datenbankname dynamisch aus der .env-Datei geladen wird"
This commit is contained in:
@@ -299,7 +299,35 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
}, [dispatch, mapGisStationsStaticDistrictUrl]);
|
||||
|
||||
//--------------------------------------------------------
|
||||
useDrawLines(setLinePositions); // Linien auf die Karte zeichnen
|
||||
useEffect(() => {
|
||||
const endpoint = "/api/talas_v5_DB/gisLines/readGisLines";
|
||||
|
||||
fetch(endpoint)
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
if (data.message) {
|
||||
console.warn(data.message);
|
||||
return; // Falls die Tabelle nicht existiert, keine weitere Verarbeitung
|
||||
}
|
||||
|
||||
const newLinePositions = data.map((item) => {
|
||||
if (item.points && Array.isArray(item.points)) {
|
||||
return {
|
||||
coordinates: item.points.map((point) => [point.x, point.y]),
|
||||
idModul: item.idModul,
|
||||
idLD: item.idLD,
|
||||
};
|
||||
}
|
||||
throw new Error("Points missing or not an array");
|
||||
});
|
||||
|
||||
setLinePositions(newLinePositions);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Error fetching data:", error.message);
|
||||
});
|
||||
}, []);
|
||||
|
||||
//--------------------------------------------
|
||||
// POIs Popup Informationen anzeigen
|
||||
useEffect(() => {
|
||||
@@ -487,7 +515,12 @@ const MapComponent = ({ locations, onLocationUpdate, lineCoordinates }) => {
|
||||
|
||||
const colorsByModule = {};
|
||||
reversedData.forEach((stat) => {
|
||||
const matchingLine = data2.find((item) => item.idLD === stat.IdLD && item.idModul === stat.Modul);
|
||||
if (!Array.isArray(data2)) {
|
||||
console.warn("WARNUNG: gis_lines ist kein Array, wird ignoriert.");
|
||||
return;
|
||||
}
|
||||
const matchingLine = data2.find((item) => item.idLD === statis.IdLD && item.idModul === statis.Modul);
|
||||
|
||||
if (matchingLine) {
|
||||
colorsByModule[matchingLine.idModul] = stat.PrioColor;
|
||||
//console.log("Übereinstimmung gefunden für: ", stat);
|
||||
|
||||
Reference in New Issue
Block a user