Strassenverwaltung plus: Teilen von Strassenzügen

This commit is contained in:
concierge committed 2026-11-05 12:24:26 +01:00
1 parent d54a986c14
commit 3eb3b746ab
22 files changed
+17391 -158

No files matched your search

+309 -31
View File
@@ -3,6 +3,7 @@ const tenant = window.CMBNET_TENANT || '';
const apiBase = appUrl(`${tenant}/admin/api`);
let currentStreetId = null;
let editMode = false;
let splitStreetId = null;
function updateStrasse(streetId, data) {
fetch(`${apiBase}/strassen/${streetId}`, {
@@ -17,7 +18,7 @@ function updateStrasse(streetId, data) {
}
function deleteStrasse(streetId) {
if (!confirm('Straße wirklich löschen?')) return;
if (!confirm('Straße wirklich löschen?\n\nDabei werden auch die zugehörigen Einträge in der Hausnummern-Tabelle gelöscht, sofern keine weiteren Abschnitte derselben Straße mehr existieren.')) return;
fetch(`${apiBase}/strassen/${streetId}`, {
method: 'DELETE'
}).then(r => r.json()).then(data => {
@@ -25,11 +26,133 @@ function deleteStrasse(streetId) {
});
}
// === Mehrfachauswahl ===
function getStreetCheckboxes() {
return Array.from(document.querySelectorAll('#strassenTable .street-select'));
}
function getVisibleStreetCheckboxes() {
return getStreetCheckboxes().filter(checkbox => {
const row = checkbox.closest('tr');
return row && row.style.display !== 'none';
});
}
function getSelectedStreetCheckboxes() {
return getStreetCheckboxes().filter(checkbox => checkbox.checked);
}
function updateStreetSelectionState() {
const count = getSelectedStreetCheckboxes().length;
const visible = getVisibleStreetCheckboxes();
const allVisibleSelected = visible.length > 0
&& visible.every(checkbox => checkbox.checked);
const deleteButton = document.getElementById('deleteSelectedStreets');
if (deleteButton) {
deleteButton.disabled = count === 0;
deleteButton.textContent = `Ausgewählte löschen (${count})`;
}
const selectButton = document.getElementById('selectVisibleStreets');
if (selectButton) {
selectButton.textContent = allVisibleSelected
? 'Auswahl aufheben'
: 'Alle sichtbaren auswählen';
}
const info = document.getElementById('streetSelectionInfo');
if (info) {
info.textContent = count === 0
? ''
: `${count} Straße(n) ausgewählt`;
}
}
function selectVisibleStreets() {
const visible = getVisibleStreetCheckboxes();
if (!visible.length) return;
// Sind bereits alle sichtbaren Straßen ausgewählt, hebt der Button die
// Auswahl wieder auf. Andernfalls werden alle sichtbaren ausgewählt.
const allSelected = visible.every(checkbox => checkbox.checked);
visible.forEach(checkbox => {
checkbox.checked = !allSelected;
});
updateStreetSelectionState();
}
function invertStreetSelection() {
getVisibleStreetCheckboxes().forEach(checkbox => {
checkbox.checked = !checkbox.checked;
});
updateStreetSelectionState();
}
function selectedStreetNames(selected) {
const names = selected.map(checkbox => {
const row = checkbox.closest('tr');
if (!row || !row.cells[2]) return `#${checkbox.value}`;
const name = row.cells[2].innerText.trim();
const zusatz = row.cells[8] ? row.cells[8].innerText.trim() : '';
return zusatz ? `${name} ${zusatz}` : name;
});
const limit = 10;
if (names.length <= limit) return names.join('\n');
return `${names.slice(0, limit).join('\n')}\n… und ${names.length - limit} weitere`;
}
function deleteSelectedStreets() {
const selected = getSelectedStreetCheckboxes();
if (!selected.length) return;
const ids = selected
.map(checkbox => Number(checkbox.value))
.filter(streetId => Number.isInteger(streetId) && streetId > 0);
if (!ids.length) return;
const message = (
`Achtung: ${ids.length} Straße(n) werden endgültig gelöscht.\n\n` +
'Dabei werden auch die zugehörigen Einträge in der ' +
'Hausnummern-Tabelle gelöscht, sofern keine weiteren Abschnitte ' +
'derselben Straße mehr existieren.\n\n' +
`Ausgewählte Straßen:\n${selectedStreetNames(selected)}\n\n` +
'Fortfahren?'
);
if (!confirm(message)) return;
const deleteButton = document.getElementById('deleteSelectedStreets');
if (deleteButton) deleteButton.disabled = true;
fetch(`${apiBase}/strassen/bulk-delete`, {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ids})
}).then(async response => {
const data = await response.json().catch(() => ({}));
if (!response.ok || !data.success) {
throw new Error(data.error || `HTTP ${response.status}`);
}
return data;
}).then(data => {
alert(
`${data.deleted} Straße(n) gelöscht, ` +
`${data.house_numbers_deleted || 0} Hausnummern-Einträge entfernt.`
);
location.reload();
}).catch(error => {
alert(error.message || 'Straßen konnten nicht gelöscht werden');
updateStreetSelectionState();
});
}
function openCreateStrasseModal() {
editMode = false;
document.getElementById('strasseModalTitle').innerText = 'Neue Straße';
document.getElementById('strasseId').value = '';
document.getElementById('strasseName').value = '';
document.getElementById('strasseZusatz').value = '';
document.getElementById('strasseHnMin').value = '';
document.getElementById('strasseHnMax').value = '';
document.getElementById('strasseBbox').value = '';
@@ -45,13 +168,14 @@ function editStrasse(streetId) {
const row = document.querySelector(`tr[data-id="${streetId}"]`);
document.getElementById('strasseModalTitle').innerText = 'Straße bearbeiten';
document.getElementById('strasseId').value = streetId;
document.getElementById('strasseName').value = row.cells[1].innerText;
document.getElementById('strasseHnMin').value = row.cells[4].innerText === '-' ? '' : row.cells[4].innerText;
document.getElementById('strasseHnMax').value = row.cells[5].innerText === '-' ? '' : row.cells[5].innerText;
document.getElementById('strasseName').value = row.cells[2].innerText.trim();
document.getElementById('strasseZusatz').value = row.cells[8].innerText.trim();
document.getElementById('strasseHnMin').value = row.cells[5].innerText === '-' ? '' : row.cells[5].innerText;
document.getElementById('strasseHnMax').value = row.cells[6].innerText === '-' ? '' : row.cells[6].innerText;
document.getElementById('strasseBbox').value = row.dataset.bbox || '';
document.getElementById('strasseState').value = row.cells[2].querySelector('select').value;
document.getElementById('strasseState').value = row.cells[3].querySelector('select').value;
document.getElementById('strasseState').disabled = false;
document.getElementById('strasseGroup').value = row.cells[3].querySelector('select').value;
document.getElementById('strasseGroup').value = row.cells[4].querySelector('select').value;
document.getElementById('strasseGroup').disabled = false;
document.getElementById('strasseModal').showModal();
}
@@ -64,6 +188,7 @@ function saveStrasse() {
const id = document.getElementById('strasseId').value;
const data = {
name: document.getElementById('strasseName').value,
zusatz: document.getElementById('strasseZusatz').value,
hn_min: document.getElementById('strasseHnMin').value || null,
hn_max: document.getElementById('strasseHnMax').value || null,
bbox: document.getElementById('strasseBbox').value || null,
@@ -100,38 +225,167 @@ function saveStrasse() {
function importCSV(input) {
const file = input.files[0];
if (!file) return;
if (!confirm(
'Der Import ersetzt alle Straßen- und Hausnummerndaten dieses ' +
'Mandanten, einschließlich früherer Teilungen, Status- und ' +
'Gruppenzuordnungen.\n\nFortfahren?'
)) {
input.value = '';
return;
}
const formData = new FormData();
formData.append('file', file);
fetch(`${apiBase}/strassen/import`, {
method: 'POST',
body: formData
}).then(r => r.json()).then(data => {
if (data.success) {
alert(`${data.count} Straßen importiert`);
location.reload();
} else {
alert(data.error);
}).then(async response => {
const data = await response.json().catch(() => ({}));
if (!response.ok || !data.success) {
throw new Error(data.error || `HTTP ${response.status}`);
}
return data;
}).then(data => {
alert(
`${data.streets ?? data.count ?? 0} Straßen und ` +
`${data.house_numbers ?? 0} Hausnummern importiert.`
);
location.reload();
}).catch(error => {
alert(error.message || 'Import fehlgeschlagen');
}).finally(() => {
input.value = '';
});
}
function importHouseNumbers(input) {
const file = input.files[0];
if (!file) return;
const formData = new FormData();
formData.append('file', file);
fetch(`${apiBase}/hausnummern/import`, {
function generateStr2plFile() {
const confirmed = confirm(
'Die mandantenspezifische Polyline-Datei wird aus allen Straßen der ' +
'Datenbank neu erzeugt.\n\n' +
'Eine bereits vorhandene Datei wird überschrieben. Die aktuelle ' +
'Auswahl in der Tabelle spielt keine Rolle.\n\n' +
'Fortfahren?'
);
if (!confirmed) return;
const button = document.getElementById('generateStr2pl');
if (button) button.disabled = true;
fetch(`${apiBase}/strassen/str2pl`, {method: 'POST'})
.then(async response => {
const data = await response.json().catch(() => ({}));
if (!response.ok || !data.success) {
throw new Error(data.error || `HTTP ${response.status}`);
}
return data;
})
.then(data => {
alert(
'Polyline-Datei erzeugt.\n\n' +
`Straßen in der Datenbank: ${data.streets_total}\n` +
`Mit Geometrie übernommen: ${data.streets_with_geometry}\n` +
`Ohne Geometrie: ${data.streets_without_geometry}\n` +
`Segmente geschrieben: ${data.segments_written}\n` +
`Segmente außerhalb der Bounding Box verworfen: ${data.segments_outside_bbox}\n` +
`Segmente zusammengeführt: ${data.segments_merged}`
);
})
.catch(error => {
alert(error.message || 'Polyline-Datei konnte nicht erzeugt werden');
})
.finally(() => {
if (button) button.disabled = false;
});
}
function openSplitStrasse(streetId) {
splitStreetId = streetId;
const dialog = document.getElementById('splitStrasseModal');
const info = document.getElementById('splitStrasseInfo');
const select = document.getElementById('splitHouseNumber');
const error = document.getElementById('splitStrasseError');
info.textContent = 'Lade Hausnummern …';
select.innerHTML = '';
error.textContent = '';
fetch(`${apiBase}/strassen/${streetId}/split-options`)
.then(async response => {
const data = await response.json().catch(() => ({}));
if (!response.ok) {
throw new Error(data.error || `HTTP ${response.status}`);
}
return data;
})
.then(data => {
if (!Array.isArray(data.house_numbers) || !data.house_numbers.length) {
throw new Error('Für diese Straße sind keine teilbaren Hausnummern hinterlegt.');
}
const displayName = `${data.name} ${data.zusatz || ''}`.trim();
info.textContent = (
`Straße „${displayName}“, gültiger Hausnummernbereich ` +
`${data.hn_min}–${data.hn_max}. Beide Abschnitte enthalten ` +
'die gewählte Trennnummer.'
);
data.house_numbers.forEach(number => {
const option = document.createElement('option');
option.value = String(number);
option.textContent = String(number);
select.appendChild(option);
});
if (typeof dialog.showModal === 'function') dialog.showModal();
else dialog.show();
})
.catch(err => {
splitStreetId = null;
alert(err.message || 'Teilungsoptionen konnten nicht geladen werden');
});
}
function closeSplitStrasseModal() {
splitStreetId = null;
const dialog = document.getElementById('splitStrasseModal');
if (dialog && dialog.open) dialog.close();
}
function confirmSplitStrasse() {
if (!splitStreetId) return;
const select = document.getElementById('splitHouseNumber');
const error = document.getElementById('splitStrasseError');
const houseNumber = select ? select.value : '';
if (!houseNumber) {
if (error) error.textContent = 'Bitte eine Hausnummer auswählen.';
return;
}
if (!confirm(`Straße an Hausnummer ${houseNumber} in zwei Abschnitte teilen?`)) {
return;
}
fetch(`${apiBase}/strassen/${splitStreetId}/split`, {
method: 'POST',
body: formData
}).then(r => r.json()).then(data => {
if (data.success) {
alert(`${data.count} Hausnummern importiert`);
location.reload();
} else {
alert(data.error);
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({house_number: Number(houseNumber)})
}).then(async response => {
const data = await response.json().catch(() => ({}));
if (!response.ok || !data.success) {
throw new Error(data.error || `HTTP ${response.status}`);
}
}).finally(() => {
input.value = '';
return data;
}).then(data => {
alert(
'Straße geteilt.\n\n' +
`Unten: HN ${data.lower.hn_min}–${data.lower.hn_max}, ` +
`Zusatz „${data.lower.zusatz}“\n` +
`Oben: HN ${data.upper.hn_min}–${data.upper.hn_max}, ` +
`Zusatz „${data.upper.zusatz}“`
);
location.reload();
}).catch(err => {
if (error) error.textContent = err.message || 'Straße konnte nicht geteilt werden';
});
}
@@ -193,10 +447,10 @@ function applyStreetFilters() {
document.querySelectorAll('#strassenTable tbody tr').forEach(row => {
if (!row.dataset.id) return;
const nameCell = row.cells[1];
const nameCell = row.cells[2];
const nameText = normalizeForFilter(nameCell ? nameCell.innerText : '');
const stateSelect = row.cells[2] ? row.cells[2].querySelector('select') : null;
const groupSelect = row.cells[3] ? row.cells[3].querySelector('select') : null;
const stateSelect = row.cells[3] ? row.cells[3].querySelector('select') : null;
const groupSelect = row.cells[4] ? row.cells[4].querySelector('select') : null;
const stateVal = stateSelect ? stateSelect.value : '';
const groupVal = groupSelect ? groupSelect.value : '';
@@ -212,9 +466,33 @@ function applyStreetFilters() {
}
row.style.display = visible ? '' : 'none';
});
updateStreetSelectionState();
}
document.addEventListener('DOMContentLoaded', applyStreetFilters);
document.addEventListener('DOMContentLoaded', () => {
applyStreetFilters();
getStreetCheckboxes().forEach(checkbox => {
checkbox.addEventListener('change', updateStreetSelectionState);
});
const selectButton = document.getElementById('selectVisibleStreets');
if (selectButton) {
selectButton.addEventListener('click', selectVisibleStreets);
}
const invertButton = document.getElementById('invertStreetSelection');
if (invertButton) {
invertButton.addEventListener('click', invertStreetSelection);
}
const deleteButton = document.getElementById('deleteSelectedStreets');
if (deleteButton) {
deleteButton.addEventListener('click', deleteSelectedStreets);
}
updateStreetSelectionState();
});
function closeStreetHistoryModal() {
document.getElementById('streetHistoryModal').close();
+90 -17
View File
@@ -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();
+64 -12
View File
@@ -164,12 +164,34 @@ function registerServiceWorker() {
const swUrl = window.CMBNET_SW_URL || '/sw.js';
window.addEventListener('load', () => {
navigator.serviceWorker.register(swUrl).catch(error => {
console.warn('Service Worker konnte nicht registriert werden.', error);
});
navigator.serviceWorker.register(swUrl)
.then(cachePolylineScript)
.catch(error => {
console.warn('Service Worker konnte nicht registriert werden.', error);
});
});
}
function cachePolylineScript() {
// Das Polyline-Skript ist mandantenabhängig (str2pl-<tenant>.js oder
// str2pl.js) und kann deshalb nicht statisch im Service Worker
// vorabgespeichert werden. Der Client meldet die tatsächlich geladene
// Datei nach der Registrierung zum Caching an.
const script = document.querySelector('script[src*="str2pl"]');
if (!script || !script.src) return;
navigator.serviceWorker.ready
.then(registration => {
const worker = registration.active
|| registration.waiting
|| registration.installing;
if (worker) {
worker.postMessage({type: 'CACHE_URLS', urls: [script.src]});
}
})
.catch(() => {});
}
function initPwaInstall() {
const button = document.getElementById('mobileInstallBtn');
if (!button) return;
@@ -740,7 +762,7 @@ async function loadGroupData(groupId) {
if (state.streets.length) {
const first = state.streets[0];
state.currentStreetId = first.id;
loadStreetPolyline(first.name);
loadStreetPolyline(first);
fitToPositionAndPolyline();
updateWorkButton();
} else {
@@ -774,7 +796,7 @@ function buildStreetList() {
btn.type = 'button';
btn.className = 'mobile-street-item';
if (state.currentStreetId == street.id) btn.classList.add('active');
btn.textContent = `${street.name} (${street.state || 'unbearbeitet'})`;
btn.textContent = `${mobileStreetDisplayName(street)} (${street.state || 'unbearbeitet'})`;
btn.addEventListener('click', () => {
selectStreet(street);
closeMobileStreetSelect();
@@ -790,24 +812,54 @@ function selectStreet(street) {
map.removeLayer(state.currentPolyline);
state.currentPolyline = null;
}
loadStreetPolyline(street.name);
loadStreetPolyline(street);
fitToPositionAndPolyline();
updateWorkButton();
buildStreetList();
}
function mobileStreetDisplayName(street) {
if (!street) return '';
const zusatz = String(street.zusatz || '').trim();
return zusatz ? `${street.name} ${zusatz}` : String(street.name || '');
}
function getStreetFragments() {
if (typeof STRASSE2POLYLINES !== 'undefined') return STRASSE2POLYLINES;
if (typeof Strasse2Polylines !== 'undefined') return Strasse2Polylines;
return window.STRASSE2POLYLINES || window.Strasse2Polylines || {};
}
function loadStreetPolyline(name) {
function findStreetSegments(fragments, street) {
if (!street || !street.name) return 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 loadStreetPolyline(street) {
const currentStreet = street
|| state.streetById.get(Number(state.currentStreetId));
if (!currentStreet) return;
const fragments = getStreetFragments();
const segments = fragments[name];
const segments = findStreetSegments(fragments, currentStreet);
if (!Array.isArray(segments)) return;
const street = state.streetById.get(Number(state.currentStreetId));
const color = STREET_COLORS[street?.state] || STREET_COLORS.unbearbeitet;
const color = STREET_COLORS[currentStreet.state] || STREET_COLORS.unbearbeitet;
const style = {
color,
opacity: state.settings.opacity,
@@ -894,7 +946,7 @@ function openStreetStateDialog() {
alert('Bitte erst eine Straße auswählen.');
return;
}
document.getElementById('mobileStreetStateTitle').textContent = `Straße: ${street.name}`;
document.getElementById('mobileStreetStateTitle').textContent = `Straße: ${mobileStreetDisplayName(street)}`;
document.getElementById('mobileStreetStateSelect').value = street.state || 'unbearbeitet';
fillMobileStreetGroupSelect(street.group_id);
updateMobileStreetGroupVisibility();
@@ -1502,7 +1554,7 @@ function applyMobileStreetUpdate(payload) {
const dialog = document.getElementById('mobileStreetStateDialog');
if (dialog && dialog.open) {
document.getElementById('mobileStreetStateTitle').textContent =
`Straße: ${street.name}`;
`Straße: ${mobileStreetDisplayName(street)}`;
document.getElementById('mobileStreetStateSelect').value =
street.state || 'unbearbeitet';
fillMobileStreetGroupSelect(street.group_id);