Fix critical error: restored accidentally removed function declaration and added DB loading safety
Deploy Bürgerwind / deploy (push) Successful in 16s Details

This commit is contained in:
Johannes Baumeister 2026-05-11 12:48:27 +02:00
parent d14eed0c7f
commit 4fe64857d9
1 changed files with 13 additions and 6 deletions

19
app.js
View File

@ -124,7 +124,7 @@ document.addEventListener('DOMContentLoaded', async () => {
// Calculation Functions // Calculation Functions
function calculateGeometries(latlng, rotorDiameter, hubHeight, foundationRadius, ksfAngle = 0, ksfMirrored = false, hersteller = 'Enercon') { function calculateGeometries(latlng, rotorDiameter, hubHeight, foundationRadius, ksfAngle = 0, ksfMirrored = false, hersteller = 'Enercon') {
// Ensure valid numbers for Turf console.log(`Berechne Geometrien für ${hersteller}, RD=${rotorDiameter}, HH=${hubHeight}`);
const rd = parseFloat(rotorDiameter) || 160; const rd = parseFloat(rotorDiameter) || 160;
const hh = parseFloat(hubHeight) || 165; const hh = parseFloat(hubHeight) || 165;
const fr = parseFloat(foundationRadius) || 15; const fr = parseFloat(foundationRadius) || 15;
@ -229,11 +229,16 @@ document.addEventListener('DOMContentLoaded', async () => {
]; ];
} }
const blf = transform(blfCoords); try {
const ksf = transform(ksfCoords); const blf = transform(blfCoords);
const mf = turf.featureCollection(mfParts.map(part => transform(part))); const ksf = transform(ksfCoords);
const mf = turf.featureCollection(mfParts.map(part => transform(part)));
return { sweptArea, techDist, techDistSmall, loadRadius, foundation, blf, ksf, mf, totalHeight, utmCoords }; return { sweptArea, techDist, techDistSmall, loadRadius, foundation, blf, ksf, mf, totalHeight, utmCoords };
} catch (err) {
console.error("Fehler in calculateGeometries:", err);
throw err;
}
} }
function updateLabel(turbine, geoms) { function updateLabel(turbine, geoms) {
@ -1925,7 +1930,9 @@ document.addEventListener('DOMContentLoaded', async () => {
if (dbTurbines.length > 0) { if (dbTurbines.length > 0) {
// Clear existing turbines // Clear existing turbines
state.turbines.forEach(t => { state.turbines.forEach(t => {
Object.values(t.layers).forEach(l => variantLayers[t.variant].removeLayer(l)); if (t.layers && t.variant && variantLayers[t.variant]) {
Object.values(t.layers).forEach(l => variantLayers[t.variant].removeLayer(l));
}
}); });
state.turbines = []; state.turbines = [];