const ADDITIONAL_SIDE

This commit is contained in:
Tomas Richtar 2025-07-11 14:16:47 +02:00
parent 3559fd9ecd
commit ed42327ff5

View File

@ -6,6 +6,8 @@ import { LEFT_SIDE, RIGHT_SIDE, BOTH_SIDES } from "athena-utils/shape/Frontline.
const ARROW = "arrow"; const ARROW = "arrow";
const FRONTLINE = "frontline"; const FRONTLINE = "frontline";
const ADDITIONAL_SIDE = "additionalSide"; // used for Id in BOTH_SIDES style
const DEFAULT_ARROW_PARAMS = { const DEFAULT_ARROW_PARAMS = {
splineStep: 20, splineStep: 20,
offsetDistance: 12000, offsetDistance: 12000,
@ -217,7 +219,7 @@ function DrawFrontline(coordinates, polygonId) {
}, },
params.protrusion params.protrusion
); );
let polygonToDraw = frontlineGeoJSON; let polygonToDraw = frontlineGeoJSON;
// Only one side // Only one side
@ -231,7 +233,7 @@ function DrawFrontline(coordinates, polygonId) {
let additionalPolygonToDraw = frontlineGeoJSON.rightPoly; let additionalPolygonToDraw = frontlineGeoJSON.rightPoly;
drawOnMap(additionalPolygonToDraw, FRONTLINE + "-" + (polygonId+1), params.paintOptionsRight); drawOnMap(additionalPolygonToDraw, FRONTLINE + "-" + (polygonId + ADDITIONAL_SIDE), params.paintOptionsRight);
return; return;
} }
@ -275,6 +277,7 @@ function drawOnMap(frontlineGeoJSON, id, paintOptions = {}) {
}); });
} }
function handleDelete(polygonType) function handleDelete(polygonType)
{ {
if (!currentFeature) return; if (!currentFeature) return;
@ -294,10 +297,10 @@ function handleDelete(polygonType)
const frontlineLayerId = polygonType + "-" + id; const frontlineLayerId = polygonType + "-" + id;
if (frontlineParamsMap.get(id).style == 3){ //BOTH_SIDES if (frontlineParamsMap.get(id).style == 3){ //BOTH_SIDES
const frontlineLayerIdB = polygonType + "-" + (id+1); const frontlineLayerIdB = polygonType + "-" + (id + ADDITIONAL_SIDE);
DeleteFromMap(frontlineLayerId, id); DeleteFromMap(frontlineLayerId, id);
DeleteFromMap(frontlineLayerIdB, id+1); DeleteFromMap(frontlineLayerIdB, id + ADDITIONAL_SIDE);
hideArrowEditor(); hideArrowEditor();
hideFrontlineEditor(); hideFrontlineEditor();
return; return;
@ -520,7 +523,7 @@ document.addEventListener('DOMContentLoaded', () => {
if (map.getLayer(frontlineLayerId)) map.removeLayer(frontlineLayerId); if (map.getLayer(frontlineLayerId)) map.removeLayer(frontlineLayerId);
if (map.getSource(frontlineLayerId)) map.removeSource(frontlineLayerId); if (map.getSource(frontlineLayerId)) map.removeSource(frontlineLayerId);
drawOnMap(polygonToDrawLeft, FRONTLINE + "-" + id+1, paintOptionsLeft); drawOnMap(polygonToDrawLeft, FRONTLINE + "-" + id + ADDITIONAL_SIDE, paintOptionsLeft);
drawOnMap(polygonToDrawRight, FRONTLINE + "-" + (id), paintOptionsRight); drawOnMap(polygonToDrawRight, FRONTLINE + "-" + (id), paintOptionsRight);
const allFeatures = draw.getAll().features; const allFeatures = draw.getAll().features;
@ -530,8 +533,8 @@ document.addEventListener('DOMContentLoaded', () => {
} }
const frontlineLayerId = FRONTLINE + "-" + id; const frontlineLayerId = FRONTLINE + "-" + id;
if (map.getLayer(frontlineLayerId+1)) map.removeLayer(frontlineLayerId+1); if (map.getLayer(frontlineLayerId + ADDITIONAL_SIDE)) map.removeLayer(frontlineLayerId + ADDITIONAL_SIDE);
if (map.getSource(frontlineLayerId+1)) map.removeSource(frontlineLayerId+1); if (map.getSource(frontlineLayerId + ADDITIONAL_SIDE)) map.removeSource(frontlineLayerId + ADDITIONAL_SIDE);
if (map.getLayer(frontlineLayerId)) map.removeLayer(frontlineLayerId); if (map.getLayer(frontlineLayerId)) map.removeLayer(frontlineLayerId);
if (map.getSource(frontlineLayerId)) map.removeSource(frontlineLayerId); if (map.getSource(frontlineLayerId)) map.removeSource(frontlineLayerId);