Ensure ALKIS DB layer is always loaded and add auto-column mapping for owner layers
Deploy Bürgerwind / deploy (push) Successful in 16s
Details
Deploy Bürgerwind / deploy (push) Successful in 16s
Details
This commit is contained in:
parent
826fbb8973
commit
42237cddcf
36
app.js
36
app.js
|
|
@ -971,6 +971,20 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
style: (feature) => {
|
style: (feature) => {
|
||||||
let fillColor = style.fillColor || style.color;
|
let fillColor = style.fillColor || style.color;
|
||||||
|
|
||||||
|
// Auto-detect ALKIS columns if not set
|
||||||
|
if (layerName.toLowerCase().includes('eigentümer') && !state.ownerMapping) {
|
||||||
|
const sampleProps = feature.properties;
|
||||||
|
const hasGNA = 'GNA' in sampleProps || 'gna' in sampleProps;
|
||||||
|
const hasVNA = 'VNA' in sampleProps || 'vna' in sampleProps;
|
||||||
|
if (hasGNA && hasVNA) {
|
||||||
|
state.ownerMapping = {
|
||||||
|
firstName: 'VNA' in sampleProps ? 'VNA' : 'vna',
|
||||||
|
lastName: 'GNA' in sampleProps ? 'GNA' : 'gna'
|
||||||
|
};
|
||||||
|
console.log("ALKIS-Spalten automatisch erkannt:", state.ownerMapping);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Owner-Status-Coloring
|
// Owner-Status-Coloring
|
||||||
if (layerName.toLowerCase().includes('eigentümer') && state.ownerMapping) {
|
if (layerName.toLowerCase().includes('eigentümer') && state.ownerMapping) {
|
||||||
const props = feature.properties;
|
const props = feature.properties;
|
||||||
|
|
@ -1200,6 +1214,11 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const l of layers) {
|
for (const l of layers) {
|
||||||
|
// Lokalen Eigentümer-Layer umbenennen, um Verwechslung mit DB zu vermeiden
|
||||||
|
if (l.name.toLowerCase() === 'eigentümer') {
|
||||||
|
l.name = 'Eigentümer (Lokal)';
|
||||||
|
}
|
||||||
|
|
||||||
if (l.file.toLowerCase().endsWith('.geojson')) {
|
if (l.file.toLowerCase().endsWith('.geojson')) {
|
||||||
await loadLocalLayer(`data/${l.file}`, l.name, l.color);
|
await loadLocalLayer(`data/${l.file}`, l.name, l.color);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1207,18 +1226,15 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NEU: ALKIS aus Datenbank laden, falls kein Eigentümer-Layer da ist
|
// ALKIS aus Datenbank IMMER laden
|
||||||
const hasOwnerLayer = Object.keys(overlays).some(k => k.toLowerCase().includes('eigentümer'));
|
console.log("Lade ALKIS-Layer aus Datenbank...");
|
||||||
if (!hasOwnerLayer) {
|
const resp = await fetch('/api/layers/alkis').catch(() => null);
|
||||||
console.log("Kein lokaler Eigentümer-Layer. Lade ALKIS aus Datenbank...");
|
if (resp && resp.ok) {
|
||||||
const resp = await fetch('/api/layers/alkis').catch(() => null);
|
const data = await resp.json();
|
||||||
if (resp && resp.ok) {
|
await processALKISData(data, "Eigentümer (ALKIS DB)");
|
||||||
const data = await resp.json();
|
|
||||||
await processALKISData(data, "Eigentümer (ALKIS DB)");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
statusEl.innerText = "Alle konfigurierten Layer geladen.";
|
statusEl.innerText = "Layer geladen (ALKIS DB integriert).";
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (!isLocalFile) console.error("Layer-Init fehlgeschlagen:", e);
|
if (!isLocalFile) console.error("Layer-Init fehlgeschlagen:", e);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue