From 1dade4c5664d091dfe892a1cc010d5b79c284ed9 Mon Sep 17 00:00:00 2001 From: Johannes Baumeister Date: Wed, 15 Jul 2026 14:36:52 +0200 Subject: [PATCH] feat: Update Koordinaten-Export und Ergaenzung Nordex N175 --- app.js | 50 ++++++++++++++++++++++++++++++++++++++++--- check_db.js | 24 +++++++++++++++++++++ enwelo_db.session.sql | 5 +++++ query_db_temp6.js | 6 ++++++ 4 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 check_db.js create mode 100644 query_db_temp6.js diff --git a/app.js b/app.js index 6513d09..1fa9153 100644 --- a/app.js +++ b/app.js @@ -2840,7 +2840,7 @@ document.addEventListener('DOMContentLoaded', async () => { // Initialisiere jsPDF const { jsPDF } = window.jspdf; - const doc = new jsPDF(); + const doc = new jsPDF('landscape'); // Titel und Projektname const projNameForFile = document.getElementById('projectSelector')?.options[document.getElementById('projectSelector')?.selectedIndex]?.text || 'Projekt unbekannt'; @@ -2853,6 +2853,10 @@ document.addEventListener('DOMContentLoaded', async () => { let variantName = activeVariant === 'variant1' ? 'Variante 1' : activeVariant === 'variant2' ? 'Variante 2' : 'Variante 3'; doc.text(`Variante: ${variantName}`, 14, 30); + // Finde Eigentümer Layer, falls vorhanden + const ownerLayerKey = Object.keys(overlays).find(k => k.toLowerCase().includes('eigentümer')); + const ownerLayer = ownerLayerKey ? overlays[ownerLayerKey] : null; + // Daten vorbereiten const tableData = activeTurbines.map(t => { const latlng = t.layers.marker.getLatLng(); @@ -2861,6 +2865,43 @@ document.addEventListener('DOMContentLoaded', async () => { const anlagentyp = t.type === 'Standard Typ' ? '-' : (t.type || '-'); let nennleistung = t.mw ? t.mw.toString() : '-'; + let gemarkung = '-'; + let flur = '-'; + let flurstueck = '-'; + + if (ownerLayer) { + const tPoint = turf.point([latlng.lng, latlng.lat]); + let found = false; + ownerLayer.eachLayer(l => { + if (found) return; + if (l.feature && l.feature.geometry) { + try { + if (turf.booleanPointInPolygon(tPoint, l.feature)) { + const p = l.feature.properties || {}; + + const gmkKeys = ['GMK', 'Gemarkung', 'GEMARKUNG', 'gemarkung', 'GMK_NAME', 'gmk_name']; + for (let k of gmkKeys) { if (p[k]) { gemarkung = p[k]; break; } } + + const flurKeys = ['FLR', 'Flur', 'FLUR', 'flur']; + for (let k of flurKeys) { if (p[k]) { flur = p[k]; break; } } + + const fsKeys = ['FSZ', 'Flurstueck', 'FLURSTUECK', 'flurstueck', 'Flurstück', 'FLURSTÜCK', 'flurstück', 'FST_NR', 'FST']; + for (let k of fsKeys) { if (p[k]) { flurstueck = p[k]; break; } } + + if (flurstueck === '-' && p['ZAE']) { + flurstueck = p['ZAE']; + if (p['NEN']) { flurstueck += '/' + p['NEN']; } + } + + found = true; + } + } catch (e) { + // ignore turf errors + } + } + }); + } + return [ t.nr, t.hersteller || '-', @@ -2870,14 +2911,17 @@ document.addEventListener('DOMContentLoaded', async () => { t.rd ? t.rd.toString() : '-', t.totalHeight ? t.totalHeight.toFixed(1) : '-', utmCoords[0].toFixed(2), - utmCoords[1].toFixed(2) + utmCoords[1].toFixed(2), + gemarkung, + flur, + flurstueck ]; }); // Tabelle einfügen doc.autoTable({ startY: 40, - head: [['WEA Nr.', 'Hersteller', 'Anlagentyp', 'MW', 'NH (m)', 'RD (m)', 'GH (m)', 'Rechtswert (E)', 'Hochwert (N)']], + head: [['WEA Nr.', 'Hersteller', 'Anlagentyp', 'MW', 'NH (m)', 'RD (m)', 'GH (m)', 'Rechtswert (E)', 'Hochwert (N)', 'Gemarkung', 'Flur', 'Flurstück']], body: tableData, theme: 'striped', headStyles: { fillColor: [0, 200, 255], textColor: [255, 255, 255] } diff --git a/check_db.js b/check_db.js new file mode 100644 index 0000000..c68923e --- /dev/null +++ b/check_db.js @@ -0,0 +1,24 @@ +const { Pool } = require('pg'); +const pool = new Pool({ + host: '87.106.21.21', + port: 5432, + database: 'enwelo', + user: 'enwelo_admin', + password: 'WX1t1cgP1qK09' +}); + +async function checkTable() { + try { + const resCount = await pool.query("SELECT COUNT(*) FROM geodaten.wohngebaeude_umrisse;"); + console.log("Count:", resCount.rows[0].count); + + const resIdx = await pool.query("SELECT indexname, indexdef FROM pg_indexes WHERE tablename = 'wohngebaeude_umrisse';"); + console.log("Indexes:", resIdx.rows); + + } catch (err) { + console.error(err); + } finally { + pool.end(); + } +} +checkTable(); diff --git a/enwelo_db.session.sql b/enwelo_db.session.sql index e9267cb..8bf1b22 100644 --- a/enwelo_db.session.sql +++ b/enwelo_db.session.sql @@ -9,3 +9,8 @@ UPDATE geodaten.wea_standorte SET projekt_id = 'trasse_bw_scheddebrock' WHERE pr UPDATE geodaten.wea_standorte SET projekt_id = 'projekt_bw_samern-ohne' WHERE projekt_id = 'bw_samern-ohne'; UPDATE geodaten.wea_standorte SET projekt_id = 'projekt_bw_test' WHERE projekt_id = 'test'; UPDATE geodaten.wea_standorte SET projekt_id = 'projekt_bw_an_der_landwehr' WHERE projekt_id ILIKE '%landwehr%'; + +-- 3. Nordex N175 Anlage mit Gesamthöhe 250m hinzufügen +INSERT INTO geodaten.anlagendaten_wea (hersteller, anlagentyp, nabenhoehe, rotordurchmesser, nennleistung) +VALUES ('Nordex', 'N175/6.X', 162.5, 175, 6.8) +ON CONFLICT DO NOTHING; diff --git a/query_db_temp6.js b/query_db_temp6.js new file mode 100644 index 0000000..db3f5ee --- /dev/null +++ b/query_db_temp6.js @@ -0,0 +1,6 @@ +const { Pool } = require('pg'); +require('dotenv').config({ path: '.env' }); +const pool = new Pool({ + host: process.env.DB_HOST, port: process.env.DB_PORT, database: process.env.DB_NAME, user: process.env.DB_USER, password: process.env.DB_PASSWORD +}); +pool.query('SELECT id, name FROM geodaten.projekte').then(res => { console.log(res.rows); pool.end(); }).catch(console.error);