Strassenverwaltung plus: Teilen von Strassenzügen
This commit is contained in:
1 parent
d54a986c14
commit
3eb3b746ab
22 files changed
+17391
-158
No files matched your search
@@ -404,6 +404,12 @@ function tooltipElement(text) {
|
||||
return element;
|
||||
}
|
||||
|
||||
function streetDisplayName(street) {
|
||||
if (!street) return '';
|
||||
const zusatz = String(street.zusatz || '').trim();
|
||||
return zusatz ? `${street.name} ${zusatz}` : String(street.name || '');
|
||||
}
|
||||
|
||||
function buildPolylines() {
|
||||
const fragments = getStreetFragments();
|
||||
const regionBounds = dispatcherState.streets
|
||||
@@ -416,7 +422,7 @@ function buildPolylines() {
|
||||
: map.getCenter());
|
||||
|
||||
dispatcherState.streets.forEach(street => {
|
||||
const segments = findStreetSegments(fragments, street.name);
|
||||
const segments = findStreetSegments(fragments, street);
|
||||
if (!Array.isArray(segments)) return;
|
||||
|
||||
const streetBounds = bboxToBounds(street.bbox) || regionBounds;
|
||||
@@ -430,7 +436,7 @@ function buildPolylines() {
|
||||
if (latlngs.length < 2) return;
|
||||
|
||||
const line = L.polyline(latlngs, polylineStyle(street.state));
|
||||
line.bindTooltip(tooltipElement(`${street.name} (${street.state})`), {sticky: true});
|
||||
line.bindTooltip(tooltipElement(`${streetDisplayName(street)} (${street.state})`), {sticky: true});
|
||||
line.on('click', () => {
|
||||
if (dispatcherState.crosshairGroupId) return;
|
||||
openStreetModal(street.id);
|
||||
@@ -445,13 +451,25 @@ function buildPolylines() {
|
||||
});
|
||||
}
|
||||
|
||||
function findStreetSegments(fragments, name) {
|
||||
if (!name) return null;
|
||||
if (fragments[name]) return fragments[name];
|
||||
function findStreetSegments(fragments, street) {
|
||||
if (!street || !street.name) return null;
|
||||
|
||||
const lower = String(name).toLowerCase();
|
||||
const matchingKey = Object.keys(fragments).find(key => key.toLowerCase() === lower);
|
||||
return matchingKey ? fragments[matchingKey] : null;
|
||||
const name = String(street.name).trim();
|
||||
const zusatz = String(street.zusatz || '').trim();
|
||||
const keys = zusatz ? [`${name} ${zusatz}`, name] : [name];
|
||||
|
||||
for (const key of keys) {
|
||||
if (Array.isArray(fragments[key])) return fragments[key];
|
||||
|
||||
const lower = key.toLowerCase();
|
||||
const matchingKey = Object.keys(fragments).find(
|
||||
candidate => candidate.toLowerCase() === lower
|
||||
);
|
||||
if (matchingKey && Array.isArray(fragments[matchingKey])) {
|
||||
return fragments[matchingKey];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function normalizeStreetPoint(point, bounds, fallbackCenter) {
|
||||
@@ -552,7 +570,7 @@ function recolorStreet(street) {
|
||||
opacity: dispatcherState.settings.opacity,
|
||||
weight: currentPolylineWeight()
|
||||
});
|
||||
line.setTooltipContent(tooltipElement(`${street.name} (${street.state})`));
|
||||
line.setTooltipContent(tooltipElement(`${streetDisplayName(street)} (${street.state})`));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1642,11 +1660,11 @@ function appendGroupStreetSection(container, title, streets, showEmpty) {
|
||||
const button = document.createElement('button');
|
||||
button.type = 'button';
|
||||
button.className = 'group-street-entry';
|
||||
button.title = `Auf die Bounding Box von ${street.name} zoomen`;
|
||||
button.title = `Auf die Bounding Box von ${streetDisplayName(street)} zoomen`;
|
||||
|
||||
const name = document.createElement('span');
|
||||
name.className = 'group-street-name';
|
||||
name.textContent = street.name;
|
||||
name.textContent = streetDisplayName(street);
|
||||
|
||||
const state = document.createElement('span');
|
||||
state.className = 'group-street-state';
|
||||
@@ -1681,6 +1699,35 @@ function zoomToStreet(streetId) {
|
||||
map.fitBounds(bounds, {padding: [30, 30], maxZoom: 18});
|
||||
}
|
||||
|
||||
function combinedStreetBounds(streets) {
|
||||
const bounds = L.latLngBounds([]);
|
||||
(streets || []).forEach(street => {
|
||||
const streetBounds = bboxToBounds(street.bbox);
|
||||
if (streetBounds && streetBounds.isValid()) {
|
||||
bounds.extend(streetBounds);
|
||||
return;
|
||||
}
|
||||
|
||||
const lines = dispatcherState.polylinesByStreetId.get(Number(street.id)) || [];
|
||||
lines.forEach(line => {
|
||||
line.getLatLngs().forEach(latlng => bounds.extend(latlng));
|
||||
});
|
||||
});
|
||||
return bounds;
|
||||
}
|
||||
|
||||
function zoomToStreetSearchResult(street) {
|
||||
if (!street) return;
|
||||
|
||||
const normalized = normalizeStreetSearchText(street.name);
|
||||
const sameName = dispatcherState.streets.filter(
|
||||
candidate => normalizeStreetSearchText(candidate.name) === normalized
|
||||
);
|
||||
const bounds = combinedStreetBounds(sameName.length ? sameName : [street]);
|
||||
if (!bounds.isValid()) return;
|
||||
map.fitBounds(bounds, {padding: [30, 30], maxZoom: 18});
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Straßensuche und Hausnummern */
|
||||
/* ------------------------------------------------------------------ */
|
||||
@@ -1702,8 +1749,21 @@ function findStreetBySearchName(value) {
|
||||
const normalized = normalizeStreetSearchText(value);
|
||||
if (!normalized) return null;
|
||||
|
||||
return dispatcherState.streets.find(street => (
|
||||
const exact = dispatcherState.streets.find(street => (
|
||||
normalizeStreetSearchText(street.name) === normalized
|
||||
));
|
||||
if (exact) return exact;
|
||||
|
||||
// Der Zusatz wird bei der Suche ignoriert. Endet die Eingabe auf eine
|
||||
// bekannte Richtung (auch kombiniert, z. B. "Nord-Süd"), wird sie für den
|
||||
// Namensvergleich entfernt.
|
||||
const withoutZusatz = normalized
|
||||
.replace(/(?:[\s-]+(?:nord|sud|sued|ost|west))+$/u, '')
|
||||
.trim();
|
||||
if (!withoutZusatz || withoutZusatz === normalized) return null;
|
||||
|
||||
return dispatcherState.streets.find(street => (
|
||||
normalizeStreetSearchText(street.name) === withoutZusatz
|
||||
)) || null;
|
||||
}
|
||||
|
||||
@@ -1753,10 +1813,23 @@ function getStreetSearchResults(streetText) {
|
||||
const normalized = normalizeStreetSearchText(streetText);
|
||||
if (normalized.length < STREET_SEARCH_MIN_CHARS) return [];
|
||||
|
||||
return dispatcherState.streets
|
||||
const matches = dispatcherState.streets
|
||||
.filter(street => normalizeStreetSearchText(street.name).startsWith(normalized))
|
||||
.sort((a, b) => String(a.name).localeCompare(String(b.name), 'de'))
|
||||
.slice(0, STREET_SEARCH_MAX_RESULTS);
|
||||
.sort((a, b) => String(a.name).localeCompare(String(b.name), 'de'));
|
||||
|
||||
// Gleiche Straßennamen mit unterschiedlichen Zusätzen erscheinen nur
|
||||
// einmal. Das Suchergebnis wird später über die gemeinsame Bounding Box
|
||||
// aller Abschnitte angezeigt.
|
||||
const seen = new Set();
|
||||
const results = [];
|
||||
for (const street of matches) {
|
||||
const key = normalizeStreetSearchText(street.name);
|
||||
if (seen.has(key)) continue;
|
||||
seen.add(key);
|
||||
results.push(street);
|
||||
if (results.length >= STREET_SEARCH_MAX_RESULTS) break;
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
function setStreetSearchStatus(text, isError = false) {
|
||||
@@ -1951,7 +2024,7 @@ async function performStreetSearch(value, selectedStreet = null) {
|
||||
closeStreetSearchResults();
|
||||
setStreetSearchStatus('');
|
||||
input.value = houseNumber ? `${street.name} ${houseNumber}` : street.name;
|
||||
zoomToStreet(street.id);
|
||||
zoomToStreetSearchResult(street);
|
||||
|
||||
if (!houseNumber) return;
|
||||
|
||||
@@ -2045,7 +2118,7 @@ function openStreetModal(streetId) {
|
||||
if (!street) return;
|
||||
|
||||
dispatcherState.currentStreetId = Number(streetId);
|
||||
document.getElementById('streetModalTitle').textContent = `Straße: ${street.name}`;
|
||||
document.getElementById('streetModalTitle').textContent = `Straße: ${streetDisplayName(street)}`;
|
||||
document.getElementById('streetStateSelect').value = street.state || 'unbearbeitet';
|
||||
fillStreetGroupOptions(street.group_id);
|
||||
updateStreetGroupVisibility();
|
||||
|
||||
Reference in new issue
Block a user