Server robustness: handled missing WEA/Infrastruktur tables and optimized geometry ST_Transform
Deploy TrassenPlaner / deploy (push) Failing after 6s
Details
Deploy TrassenPlaner / deploy (push) Failing after 6s
Details
This commit is contained in:
parent
d5edb1e992
commit
6d152ad3c9
43
server.js
43
server.js
|
|
@ -49,7 +49,7 @@ app.get('/api/owners', async (req, res) => {
|
||||||
const query = `
|
const query = `
|
||||||
SELECT
|
SELECT
|
||||||
*,
|
*,
|
||||||
ST_AsGeoJSON(ST_Transform(ST_SetSRID(geom, 25832), 4326)) as geometry
|
ST_AsGeoJSON(ST_Transform(geom, 4326)) as geometry
|
||||||
FROM bw_scheddebrock."Eigentuemerdaten"
|
FROM bw_scheddebrock."Eigentuemerdaten"
|
||||||
`;
|
`;
|
||||||
const result = await client.query(query);
|
const result = await client.query(query);
|
||||||
|
|
@ -89,7 +89,7 @@ app.get('/api/usage', async (req, res) => {
|
||||||
const query = `
|
const query = `
|
||||||
SELECT
|
SELECT
|
||||||
*,
|
*,
|
||||||
ST_AsGeoJSON(ST_Transform(ST_SetSRID(geom, 25832), 4326)) as geometry
|
ST_AsGeoJSON(ST_Transform(geom, 4326)) as geometry
|
||||||
FROM bw_scheddebrock."Nutzung"
|
FROM bw_scheddebrock."Nutzung"
|
||||||
`;
|
`;
|
||||||
const result = await client.query(query);
|
const result = await client.query(query);
|
||||||
|
|
@ -121,13 +121,18 @@ app.get('/api/wea', async (req, res) => {
|
||||||
const client = await pool.connect();
|
const client = await pool.connect();
|
||||||
try {
|
try {
|
||||||
await setSchema(client);
|
await setSchema(client);
|
||||||
const query = `
|
let result;
|
||||||
SELECT
|
try {
|
||||||
*,
|
result = await client.query(`
|
||||||
ST_AsGeoJSON(ST_Transform(ST_SetSRID(geom, 25832), 4326)) as geometry
|
SELECT
|
||||||
FROM bw_scheddebrock."WEA"
|
*,
|
||||||
`;
|
ST_AsGeoJSON(ST_Transform(geom, 4326)) as geometry
|
||||||
const result = await client.query(query);
|
FROM bw_scheddebrock."WEA"
|
||||||
|
`);
|
||||||
|
} catch (dbErr) {
|
||||||
|
console.log("WEA Tabelle fehlt oder nicht abrufbar.");
|
||||||
|
result = { rows: [], rowCount: 0 };
|
||||||
|
}
|
||||||
|
|
||||||
const geojson = {
|
const geojson = {
|
||||||
type: "FeatureCollection",
|
type: "FeatureCollection",
|
||||||
|
|
@ -155,18 +160,24 @@ app.get('/api/infrastructure', async (req, res) => {
|
||||||
const client = await pool.connect();
|
const client = await pool.connect();
|
||||||
try {
|
try {
|
||||||
await setSchema(client);
|
await setSchema(client);
|
||||||
const result = await client.query(`
|
let result;
|
||||||
SELECT
|
try {
|
||||||
*,
|
result = await client.query(`
|
||||||
ST_AsGeoJSON(ST_Transform(ST_SetSRID(geom, 25832), 4326)) as geometry
|
SELECT
|
||||||
FROM bw_scheddebrock."Infrastruktur"
|
*,
|
||||||
`);
|
ST_AsGeoJSON(ST_Transform(geom, 4326)) as geometry
|
||||||
|
FROM bw_scheddebrock."Infrastruktur"
|
||||||
|
`);
|
||||||
|
} catch (dbErr) {
|
||||||
|
console.log("Infrastruktur Tabelle fehlt oder nicht abrufbar.");
|
||||||
|
result = { rows: [], rowCount: 0 };
|
||||||
|
}
|
||||||
|
|
||||||
const geojson = {
|
const geojson = {
|
||||||
type: "FeatureCollection",
|
type: "FeatureCollection",
|
||||||
features: result.rows.map(row => {
|
features: result.rows.map(row => {
|
||||||
const { geometry, geom, ...properties } = row;
|
const { geometry, geom, ...properties } = row;
|
||||||
const geomObj = JSON.parse(geometry);
|
const geomObj = typeof geometry === 'string' ? JSON.parse(geometry) : (geometry || null);
|
||||||
return {
|
return {
|
||||||
type: "Feature",
|
type: "Feature",
|
||||||
geometry: geomObj,
|
geometry: geomObj,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue