fix: store and retrieve nennleistung (MW) properly in DB and frontend
Deploy Standortplaner / deploy (push) Successful in 17s Details

This commit is contained in:
Johannes Baumeister 2026-07-04 21:58:56 +02:00
parent f8313c8fee
commit 3ce303a00f
2 changed files with 28 additions and 4 deletions

24
db_add_nennleistung.js Normal file
View File

@ -0,0 +1,24 @@
require('dotenv').config({ override: true });
const { Pool } = require('pg');
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
});
async function run() {
try {
console.log('Adding nennleistung to wea_standorte...');
await pool.query('ALTER TABLE geodaten.wea_standorte ADD COLUMN IF NOT EXISTS nennleistung numeric;');
console.log('Column added successfully.');
} catch (err) {
console.error('Error adding column:', err);
} finally {
await pool.end();
}
}
run();

View File

@ -263,9 +263,9 @@ app.post('/api/wea', async (req, res) => {
log(`Füge WEA ein: Nr=${t.nr}, Typ=${t.type}, Pos=${t.latlng?.lat},${t.latlng?.lng}`); log(`Füge WEA ein: Nr=${t.nr}, Typ=${t.type}, Pos=${t.latlng?.lat},${t.latlng?.lng}`);
await client.query( await client.query(
`INSERT INTO ${schema}.wea_standorte `INSERT INTO ${schema}.wea_standorte
(projekt_id, wea_nummer, hersteller, anlagentyp, nabenhoehe, rotordurchmesser, ksf_drehung, variante, geom) (projekt_id, wea_nummer, hersteller, anlagentyp, nabenhoehe, rotordurchmesser, ksf_drehung, variante, nennleistung, geom)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, ST_Transform(ST_SetSRID(ST_MakePoint($9, $10), 4326), 25832))`, VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, ST_Transform(ST_SetSRID(ST_MakePoint($10, $11), 4326), 25832))`,
[targetProject, t.nr, t.hersteller, t.type, t.hh, t.rd, t.ksfAngle, t.variant, t.latlng.lng, t.latlng.lat] [targetProject, t.nr, t.hersteller, t.type, t.hh, t.rd, t.ksfAngle, t.variant, t.mw, t.latlng.lng, t.latlng.lat]
); );
} }
} }
@ -298,7 +298,7 @@ app.get('/api/wea/:projekt_id', async (req, res) => {
const resolvedPid = await resolveProjectId(client, projekt_id); const resolvedPid = await resolveProjectId(client, projekt_id);
const result = await client.query( const result = await client.query(
`SELECT wea_nummer as nr, hersteller as hersteller, anlagentyp as type, nabenhoehe as hh, rotordurchmesser as rd, ksf_drehung as ksfAngle, variante as variant, `SELECT wea_nummer as nr, hersteller as hersteller, anlagentyp as type, nabenhoehe as hh, rotordurchmesser as rd, ksf_drehung as ksfAngle, variante as variant, nennleistung as mw,
ST_X(ST_Transform(geom, 4326)) as lng, ST_Y(ST_Transform(geom, 4326)) as lat ST_X(ST_Transform(geom, 4326)) as lng, ST_Y(ST_Transform(geom, 4326)) as lat
FROM geodaten.wea_standorte WHERE projekt_id = $1 OR projekt_id = $2 OR projekt_id = $3`, FROM geodaten.wea_standorte WHERE projekt_id = $1 OR projekt_id = $2 OR projekt_id = $3`,
[projekt_id, resolvedPid, projectName] [projekt_id, resolvedPid, projectName]