Fixed Usage layer: broadened filtering keywords and added property name robustness
This commit is contained in:
parent
a24fbf08c1
commit
f2d9962fae
27
index.html
27
index.html
|
|
@ -1519,16 +1519,24 @@
|
||||||
|
|
||||||
const statusEl = document.getElementById('status-usage');
|
const statusEl = document.getElementById('status-usage');
|
||||||
|
|
||||||
// Filtering: Only show requested types
|
// Filtering: Expanded list and more robust matching
|
||||||
const requestedTypes = ['gehölz', 'wald', 'bahnverkehr', 'straßenverkehr', 'wohnbafläche', 'weg', 'fließgewässer', 'stehendes gewässer', 'gewässer'];
|
const requestedKeywords = [
|
||||||
|
'gehölz', 'wald', 'forst', 'bahn', 'verkehr', 'straße', 'baufläche', 'wohnbau',
|
||||||
|
'weg', 'gewässer', 'wasser', 'grünland', 'landwirtsch', 'acker'
|
||||||
|
];
|
||||||
|
|
||||||
const filteredFeatures = state.usage.features.filter(f => {
|
const filteredFeatures = state.usage.features.filter(f => {
|
||||||
const type = (f.properties.nutzart || f.properties.NUTZART || '').toLowerCase();
|
const props = f.properties;
|
||||||
return requestedTypes.some(rt => type.includes(rt));
|
const rawType = props.nutzart || props.NUTZART || props.bezeichnung || props.BEZEICHNUN || props.nutzungsart || '';
|
||||||
|
const type = rawType.toLowerCase();
|
||||||
|
return requestedKeywords.some(kw => type.includes(kw));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(`Nutzung-Layer: ${filteredFeatures.length} von ${state.usage.features.length} Objekten nach Filterung.`);
|
||||||
|
|
||||||
if (statusEl) {
|
if (statusEl) {
|
||||||
statusEl.innerText = `${filteredFeatures.length} Objekte`;
|
statusEl.innerText = `${filteredFeatures.length} Objekte`;
|
||||||
statusEl.style.color = 'var(--success)';
|
statusEl.style.color = filteredFeatures.length > 0 ? 'var(--success)' : 'var(--warning)';
|
||||||
}
|
}
|
||||||
|
|
||||||
layers.usage.clearLayers();
|
layers.usage.clearLayers();
|
||||||
|
|
@ -1537,10 +1545,11 @@
|
||||||
type: "FeatureCollection",
|
type: "FeatureCollection",
|
||||||
features: filteredFeatures
|
features: filteredFeatures
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
if (layers.usage.getBounds().isValid() && filteredFeatures.length > 0) {
|
||||||
if (layers.usage.getBounds().isValid() && state.visibleLayers.usage && filteredFeatures.length > 0) {
|
console.log("Zooming to Usage layer...");
|
||||||
map.fitBounds(layers.usage.getBounds());
|
// map.fitBounds(layers.usage.getBounds()); // Optional: Auto-zoom to usage
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue