Final synchronization fix: added legacy status mapping, improved name normalization for names with special characters/brackets, and increased color visibility
Deploy Bürgerwind / deploy (push) Successful in 16s
Details
Deploy Bürgerwind / deploy (push) Successful in 16s
Details
This commit is contained in:
parent
cccdce49c1
commit
f4403b055f
38
app.js
38
app.js
|
|
@ -27,6 +27,18 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
'Kooperationspartner': { color: '#ffffff', desc: 'Anderes Vorhaben mit dem kooperiert wird.' }
|
'Kooperationspartner': { color: '#ffffff', desc: 'Anderes Vorhaben mit dem kooperiert wird.' }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Mapping for old database values
|
||||||
|
const LEGACY_STATUS_MAP = {
|
||||||
|
'declined': 'Ablehnung',
|
||||||
|
'negative': 'Ablehnung',
|
||||||
|
'external': 'Fremdplanung',
|
||||||
|
'fremdplanung': 'Fremdplanung',
|
||||||
|
'positive': 'Erwartet Positiv',
|
||||||
|
'undecided': 'Unentschlossen',
|
||||||
|
'gbr': 'In der Projektgesellschaft',
|
||||||
|
'gesichert': 'Vertraglich gesichert'
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Removed fetch for config to prevent CORS errors on file:// protocol
|
// Removed fetch for config to prevent CORS errors on file:// protocol
|
||||||
console.log("Konfiguration geladen.");
|
console.log("Konfiguration geladen.");
|
||||||
|
|
@ -1250,36 +1262,38 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
const lastName = (props.GNA || '').trim();
|
const lastName = (props.GNA || '').trim();
|
||||||
|
|
||||||
// Normalisierung des Namens für den Abgleich
|
// Normalisierung des Namens für den Abgleich
|
||||||
const normalize = (s) => (s || '').toString().toLowerCase().replace(/[\s,.-]/g, '').trim();
|
const normalize = (s) => (s || '').toString().toLowerCase().replace(/[^a-z0-9]/g, '').trim();
|
||||||
const ownerKey = normalize(firstName + lastName);
|
const ownerKey = normalize(firstName + lastName);
|
||||||
|
|
||||||
// Suche in den geladenen Status-Einträgen
|
// Suche in den geladenen Status-Einträgen
|
||||||
let status = '';
|
let rawStatus = '';
|
||||||
let foundInState = false;
|
let foundInState = false;
|
||||||
|
|
||||||
// Wir suchen im state.ownerStatuses (der aus /api/sicherung geladen wurde)
|
// Wir suchen im state.ownerStatuses
|
||||||
for (let key in state.ownerStatuses) {
|
for (let key in state.ownerStatuses) {
|
||||||
if (normalize(key) === ownerKey) {
|
if (normalize(key) === ownerKey) {
|
||||||
status = state.ownerStatuses[key].status;
|
rawStatus = state.ownerStatuses[key].status;
|
||||||
foundInState = true;
|
foundInState = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback auf die Properties im GeoJSON selbst
|
if (!rawStatus) rawStatus = props.status || '';
|
||||||
if (!status) status = props.status || '';
|
|
||||||
|
// Translate legacy values
|
||||||
|
const status = LEGACY_STATUS_MAP[rawStatus.toLowerCase()] || rawStatus;
|
||||||
|
|
||||||
let fillColor = 'transparent';
|
let fillColor = 'transparent';
|
||||||
let opacity = 0.1;
|
let opacity = 0.1;
|
||||||
|
|
||||||
if (status && STATUS_MAP[status]) {
|
if (status && STATUS_MAP[status]) {
|
||||||
fillColor = STATUS_MAP[status].color;
|
fillColor = STATUS_MAP[status].color;
|
||||||
opacity = 0.7;
|
opacity = 0.8; // High visibility
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
color: '#000',
|
color: '#000',
|
||||||
weight: 1,
|
weight: 1.5, // Stronger border
|
||||||
fillOpacity: opacity,
|
fillOpacity: opacity,
|
||||||
fillColor: fillColor
|
fillColor: fillColor
|
||||||
};
|
};
|
||||||
|
|
@ -1289,20 +1303,22 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
const props = feature.properties;
|
const props = feature.properties;
|
||||||
const firstName = (props.VNA || '').trim();
|
const firstName = (props.VNA || '').trim();
|
||||||
const lastName = (props.GNA || '').trim();
|
const lastName = (props.GNA || '').trim();
|
||||||
const normalize = (s) => (s || '').toString().toLowerCase().replace(/[\s,.-]/g, '').trim();
|
const normalize = (s) => (s || '').toString().toLowerCase().replace(/[^a-z0-9]/g, '').trim();
|
||||||
const ownerKey = normalize(firstName + lastName);
|
const ownerKey = normalize(firstName + lastName);
|
||||||
|
|
||||||
let status = props.status || 'Kein Status';
|
let rawStatus = props.status || 'Kein Status';
|
||||||
let notiz = props.notiz || '';
|
let notiz = props.notiz || '';
|
||||||
|
|
||||||
for (let key in state.ownerStatuses) {
|
for (let key in state.ownerStatuses) {
|
||||||
if (normalize(key) === ownerKey) {
|
if (normalize(key) === ownerKey) {
|
||||||
status = state.ownerStatuses[key].status;
|
rawStatus = state.ownerStatuses[key].status;
|
||||||
notiz = state.ownerStatuses[key].notiz;
|
notiz = state.ownerStatuses[key].notiz;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const status = LEGACY_STATUS_MAP[rawStatus.toLowerCase()] || rawStatus;
|
||||||
|
|
||||||
let popup = `<b>${layerName}</b><br><hr style="margin: 5px 0; border: 0; border-top: 1px solid #444;">`;
|
let popup = `<b>${layerName}</b><br><hr style="margin: 5px 0; border: 0; border-top: 1px solid #444;">`;
|
||||||
popup += `<b>Eigentümer:</b> ${firstName} ${lastName}<br>`;
|
popup += `<b>Eigentümer:</b> ${firstName} ${lastName}<br>`;
|
||||||
popup += `<b>Status:</b> ${status}<br>`;
|
popup += `<b>Status:</b> ${status}<br>`;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue