Ultra-robust data mapping for GIS imports
Deploy TrassenPlaner / deploy (push) Waiting to run
Details
Deploy TrassenPlaner / deploy (push) Waiting to run
Details
This commit is contained in:
parent
805794756f
commit
945b01b8f4
19
index.html
19
index.html
|
|
@ -2817,11 +2817,24 @@
|
||||||
|
|
||||||
features.forEach(f => {
|
features.forEach(f => {
|
||||||
const p = f.properties || {};
|
const p = f.properties || {};
|
||||||
const varName = p.Variante ? `Variante ${p.Variante}` : (p.name || "Variante A");
|
// Robustly find 'Variante' (case-insensitive)
|
||||||
|
const rawVariante = p.Variante || p.variante || p.VARIANTE || '';
|
||||||
|
const rawName = p.name || p.Name || p.NAME || '';
|
||||||
|
|
||||||
|
const varName = rawVariante ? `Variante ${rawVariante}` : (rawName || "Variante A");
|
||||||
const slot = state.variants.find(lv => lv.name === varName);
|
const slot = state.variants.find(lv => lv.name === varName);
|
||||||
|
|
||||||
if (slot && f.geometry && f.geometry.coordinates) {
|
if (slot && f.geometry && f.geometry.coordinates) {
|
||||||
slot.id = f.id || p.id || slot.id;
|
slot.id = f.id || p.fid || p.id || p._id || slot.id;
|
||||||
slot.routes = f.geometry.coordinates.map(c => ({ lat: c[1], lng: c[0] }));
|
|
||||||
|
// Handle potential nested coordinate arrays from different GIS exports
|
||||||
|
let coords = f.geometry.coordinates;
|
||||||
|
if (f.geometry.type === "LineString") {
|
||||||
|
slot.routes = coords.map(c => ({ lat: c[1], lng: c[0] }));
|
||||||
|
} else if (f.geometry.type === "MultiLineString") {
|
||||||
|
// Take the first segment of a MultiLineString if it's imported that way
|
||||||
|
slot.routes = coords[0].map(c => ({ lat: c[1], lng: c[0] }));
|
||||||
|
}
|
||||||
|
|
||||||
// Re-sync the polyline layer if it exists
|
// Re-sync the polyline layer if it exists
|
||||||
if (routeLayers[slot.id]) {
|
if (routeLayers[slot.id]) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue