Harden owner name matching with normalization and add detailed debug logging for map synchronization
Deploy Bürgerwind / deploy (push) Successful in 16s
Details
Deploy Bürgerwind / deploy (push) Successful in 16s
Details
This commit is contained in:
parent
c5469e7fa5
commit
cccdce49c1
58
app.js
58
app.js
|
|
@ -1241,25 +1241,40 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
}
|
||||
|
||||
async function processALKISData(geojson, layerName) {
|
||||
console.log(`Verarbeite ALKIS-Daten für Layer: ${layerName}. Features: ${geojson.features ? geojson.features.length : 0}`);
|
||||
|
||||
const layer = L.geoJSON(geojson, {
|
||||
style: (feature) => {
|
||||
const props = feature.properties;
|
||||
const firstName = (props.VNA || '').trim();
|
||||
const lastName = (props.GNA || '').trim();
|
||||
const ownerName = `${firstName} ${lastName}`.trim().toLowerCase();
|
||||
|
||||
const stored = state.ownerStatuses[ownerName];
|
||||
const status = typeof stored === 'object' ? (stored.status || '') : (stored || props.status || '');
|
||||
// Normalisierung des Namens für den Abgleich
|
||||
const normalize = (s) => (s || '').toString().toLowerCase().replace(/[\s,.-]/g, '').trim();
|
||||
const ownerKey = normalize(firstName + lastName);
|
||||
|
||||
// Suche in den geladenen Status-Einträgen
|
||||
let status = '';
|
||||
let foundInState = false;
|
||||
|
||||
// Wir suchen im state.ownerStatuses (der aus /api/sicherung geladen wurde)
|
||||
for (let key in state.ownerStatuses) {
|
||||
if (normalize(key) === ownerKey) {
|
||||
status = state.ownerStatuses[key].status;
|
||||
foundInState = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback auf die Properties im GeoJSON selbst
|
||||
if (!status) status = props.status || '';
|
||||
|
||||
let fillColor = 'transparent';
|
||||
let opacity = 0.1;
|
||||
|
||||
if (STATUS_MAP[status]) {
|
||||
if (status && STATUS_MAP[status]) {
|
||||
fillColor = STATUS_MAP[status].color;
|
||||
opacity = 0.7;
|
||||
} else if (status === 'none' || status === '') {
|
||||
fillColor = 'transparent';
|
||||
opacity = 0.1;
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
@ -1271,16 +1286,31 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
},
|
||||
onEachFeature: (feature, layer) => {
|
||||
if (feature.properties) {
|
||||
const status = feature.properties.status || 'Kein Status';
|
||||
const notiz = feature.properties.notiz || '';
|
||||
const props = feature.properties;
|
||||
const firstName = (props.VNA || '').trim();
|
||||
const lastName = (props.GNA || '').trim();
|
||||
const normalize = (s) => (s || '').toString().toLowerCase().replace(/[\s,.-]/g, '').trim();
|
||||
const ownerKey = normalize(firstName + lastName);
|
||||
|
||||
let status = props.status || 'Kein Status';
|
||||
let notiz = props.notiz || '';
|
||||
|
||||
for (let key in state.ownerStatuses) {
|
||||
if (normalize(key) === ownerKey) {
|
||||
status = state.ownerStatuses[key].status;
|
||||
notiz = state.ownerStatuses[key].notiz;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let popup = `<b>${layerName}</b><br><hr style="margin: 5px 0; border: 0; border-top: 1px solid #444;">`;
|
||||
popup += `<b>Eigentümer:</b> ${feature.properties.VNA} ${feature.properties.GNA}<br>`;
|
||||
popup += `<b>Eigentümer:</b> ${firstName} ${lastName}<br>`;
|
||||
popup += `<b>Status:</b> ${status}<br>`;
|
||||
if (notiz) popup += `<b>Notiz:</b> ${notiz}<br>`;
|
||||
popup += `<hr style="margin: 5px 0; border: 0; border-top: 1px solid #444;">`;
|
||||
for (let key in feature.properties) {
|
||||
for (let key in props) {
|
||||
if (['VNA', 'GNA', 'status', 'notiz', 'id'].includes(key)) continue;
|
||||
const val = feature.properties[key];
|
||||
const val = props[key];
|
||||
if (val !== null && val !== undefined) popup += `<b>${key}:</b> ${val}<br>`;
|
||||
}
|
||||
layer.bindPopup(popup);
|
||||
|
|
@ -1460,8 +1490,8 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
Object.keys(owners).sort().forEach(name => {
|
||||
const data = owners[name];
|
||||
const stored = state.ownerStatuses[name.toLowerCase()] || { status: 'none', notiz: '' };
|
||||
const status = typeof stored === 'string' ? stored : (stored.status || 'none');
|
||||
const notiz = typeof stored === 'string' ? '' : (stored.notiz || '');
|
||||
const status = typeof stored === 'object' ? (stored.status || 'none') : (stored || 'none');
|
||||
const notiz = typeof stored === 'object' ? (stored.notiz || '') : '';
|
||||
|
||||
const row = document.createElement('tr');
|
||||
row.innerHTML = `
|
||||
|
|
|
|||
Loading…
Reference in New Issue