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) => {
|
||||
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
|
||||
if (layerName.toLowerCase().includes('eigentümer') && state.ownerMapping) {
|
||||
const props = feature.properties;
|
||||
|
|
@ -1200,6 +1214,11 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
}
|
||||
|
||||
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')) {
|
||||
await loadLocalLayer(`data/${l.file}`, l.name, l.color);
|
||||
} else {
|
||||
|
|
@ -1207,18 +1226,15 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
}
|
||||
}
|
||||
|
||||
// NEU: ALKIS aus Datenbank laden, falls kein Eigentümer-Layer da ist
|
||||
const hasOwnerLayer = Object.keys(overlays).some(k => k.toLowerCase().includes('eigentümer'));
|
||||
if (!hasOwnerLayer) {
|
||||
console.log("Kein lokaler Eigentümer-Layer. Lade ALKIS aus Datenbank...");
|
||||
const resp = await fetch('/api/layers/alkis').catch(() => null);
|
||||
if (resp && resp.ok) {
|
||||
const data = await resp.json();
|
||||
await processALKISData(data, "Eigentümer (ALKIS DB)");
|
||||
}
|
||||
// ALKIS aus Datenbank IMMER laden
|
||||
console.log("Lade ALKIS-Layer aus Datenbank...");
|
||||
const resp = await fetch('/api/layers/alkis').catch(() => null);
|
||||
if (resp && resp.ok) {
|
||||
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) {
|
||||
if (!isLocalFile) console.error("Layer-Init fehlgeschlagen:", e);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue