diff --git a/app.js b/app.js index b9287ea..a1e434b 100644 --- a/app.js +++ b/app.js @@ -2714,29 +2714,52 @@ document.addEventListener('DOMContentLoaded', async () => { return; } + // Sort by WEA Nr (numerically if possible) + activeTurbines.sort((a, b) => { + const numA = parseInt(a.nr) || 0; + const numB = parseInt(b.nr) || 0; + return numA - numB; + }); + // Initialisiere jsPDF const { jsPDF } = window.jspdf; const doc = new jsPDF(); // Titel und Projektname - const projName = document.getElementById('projectSelector')?.options[document.getElementById('projectSelector')?.selectedIndex]?.text || 'Projekt unbekannt'; + const projNameForFile = document.getElementById('projectSelector')?.options[document.getElementById('projectSelector')?.selectedIndex]?.text || 'Projekt unbekannt'; doc.setFontSize(16); - doc.text(`Koordinatenliste - ${projName}`, 14, 20); + doc.text(`Koordinatenliste`, 14, 20); // Untertitel (Variante) doc.setFontSize(12); let variantName = activeVariant === 'variant1' ? 'Variante 1' : activeVariant === 'variant2' ? 'Variante 2' : 'Variante 3'; doc.text(`Variante: ${variantName}`, 14, 30); - // Daten vorbereiten (Rechtswert/Hochwert aus UTM32) + // Daten vorbereiten const tableData = activeTurbines.map(t => { const latlng = t.layers.marker.getLatLng(); const utmCoords = proj4(wgs84, utm32, [latlng.lng, latlng.lat]); + + // Nennleistung aus loaded types finden + let nennleistung = '-'; + if (window.availableWeaTypes) { + const matchedType = window.availableWeaTypes.find(w => w.hersteller === t.hersteller && w.anlagentyp === t.type); + if (matchedType && matchedType.nennleistung) { + nennleistung = matchedType.nennleistung; + } + } + + const anlagentyp = t.type === 'Standard Typ' ? '-' : (t.type || '-'); + return [ t.nr, t.hersteller || '-', - t.type || '-', + anlagentyp, + nennleistung, + t.hh ? t.hh.toString() : '-', + t.rd ? t.rd.toString() : '-', + t.totalHeight ? t.totalHeight.toFixed(1) : '-', utmCoords[0].toFixed(2), utmCoords[1].toFixed(2) ]; @@ -2745,13 +2768,13 @@ document.addEventListener('DOMContentLoaded', async () => { // Tabelle einfügen doc.autoTable({ startY: 40, - head: [['WEA Nr.', 'Hersteller', 'Anlagentyp', 'Rechtswert (E)', 'Hochwert (N)']], + head: [['WEA Nr.', 'Hersteller', 'Anlagentyp', 'MW', 'NH (m)', 'RD (m)', 'GH (m)', 'Rechtswert (E)', 'Hochwert (N)']], body: tableData, theme: 'striped', headStyles: { fillColor: [0, 200, 255], textColor: [255, 255, 255] } }); - doc.save(`Koordinatenliste_${projName.replace(/\s+/g, '_')}_${activeVariant}.pdf`); + doc.save(`Koordinatenliste_${projNameForFile.replace(/\s+/g, '_')}_${activeVariant}.pdf`); } catch (err) { console.error('Fehler beim Koordinaten-PDF Export:', err);