Revert geometry drag to live updates and fix rotation handle map insertion
Deploy Standortplaner / deploy (push) Successful in 16s Details

This commit is contained in:
Johannes Baumeister 2026-07-06 13:54:41 +02:00
parent dcd72a1268
commit ce91cddb94
1 changed files with 18 additions and 17 deletions

33
app.js
View File

@ -524,11 +524,22 @@ document.addEventListener('DOMContentLoaded', async () => {
if (state.isEditMode) openEditPanel(turbine); if (state.isEditMode) openEditPanel(turbine);
}); });
// Drag Update (Nur Marker und Panel bewegen, Geometrien erst bei dragend) // Drag Update (Geometrien ziehen jetzt wieder live mit)
turbine.layers.marker.on('drag', (e) => { turbine.layers.marker.on('drag', (e) => {
const newPos = e.target.getLatLng(); const newPos = e.target.getLatLng();
turbine.latlng = newPos; turbine.latlng = newPos;
// Recalculate all geometries live during drag
const newGeoms = calculateGeometries(newPos, turbine.rd, turbine.hh, turbine.fr, turbine.ksfAngle, turbine.ksfMirrored, turbine.hersteller);
turbine.layers.sweptArea.clearLayers().addData(newGeoms.sweptArea);
turbine.layers.techDist.clearLayers().addData(newGeoms.techDist);
turbine.layers.techDistSmall.clearLayers().addData(newGeoms.techDistSmall);
turbine.layers.loadRadius.clearLayers().addData(newGeoms.loadRadius);
turbine.layers.foundation.clearLayers().addData(newGeoms.foundation);
turbine.layers.ksf.clearLayers().addData(newGeoms.ksf);
turbine.layers.blf.clearLayers().addData(newGeoms.blf);
turbine.layers.mf.clearLayers().addData(newGeoms.mf);
// Move rotation handle along with it during drag // Move rotation handle along with it during drag
updateRotationHandlePos(turbine); updateRotationHandlePos(turbine);
@ -542,19 +553,7 @@ document.addEventListener('DOMContentLoaded', async () => {
turbine.layers.marker.on('dragend', (e) => { turbine.layers.marker.on('dragend', (e) => {
const newPos = e.target.getLatLng(); const newPos = e.target.getLatLng();
turbine.latlng = newPos; turbine.latlng = newPos;
// Recalculate all geometries ONCE after dragging is finished to avoid lagging
const newGeoms = calculateGeometries(newPos, turbine.rd, turbine.hh, turbine.fr, turbine.ksfAngle, turbine.ksfMirrored, turbine.hersteller); const newGeoms = calculateGeometries(newPos, turbine.rd, turbine.hh, turbine.fr, turbine.ksfAngle, turbine.ksfMirrored, turbine.hersteller);
turbine.layers.sweptArea.clearLayers().addData(newGeoms.sweptArea);
turbine.layers.techDist.clearLayers().addData(newGeoms.techDist);
turbine.layers.techDistSmall.clearLayers().addData(newGeoms.techDistSmall);
turbine.layers.loadRadius.clearLayers().addData(newGeoms.loadRadius);
turbine.layers.foundation.clearLayers().addData(newGeoms.foundation);
turbine.layers.ksf.clearLayers().addData(newGeoms.ksf);
turbine.layers.blf.clearLayers().addData(newGeoms.blf);
turbine.layers.mf.clearLayers().addData(newGeoms.mf);
updateRotationHandlePos(turbine);
updateLabel(turbine, newGeoms); updateLabel(turbine, newGeoms);
updateProximityLines(); updateProximityLines();
triggerAutoSave(); triggerAutoSave();
@ -577,24 +576,26 @@ document.addEventListener('DOMContentLoaded', async () => {
if (activeTurbine?.id === turbine.id) { if (activeTurbine?.id === turbine.id) {
editKsfAngle.value = angle.toFixed(1); editKsfAngle.value = angle.toFixed(1);
} }
});
turbine.layers.rotationHandle.on('dragend', (e) => { // Live Rotation Update
// Nach dem Drehen alle Geometrien aktualisieren und Handle auf Kreisbahn einrasten lassen
const newGeoms = calculateGeometries(turbine.latlng, turbine.rd, turbine.hh, turbine.fr, turbine.ksfAngle, turbine.ksfMirrored, turbine.hersteller); const newGeoms = calculateGeometries(turbine.latlng, turbine.rd, turbine.hh, turbine.fr, turbine.ksfAngle, turbine.ksfMirrored, turbine.hersteller);
turbine.layers.ksf.clearLayers().addData(newGeoms.ksf); turbine.layers.ksf.clearLayers().addData(newGeoms.ksf);
turbine.layers.blf.clearLayers().addData(newGeoms.blf); turbine.layers.blf.clearLayers().addData(newGeoms.blf);
turbine.layers.mf.clearLayers().addData(newGeoms.mf); turbine.layers.mf.clearLayers().addData(newGeoms.mf);
});
turbine.layers.rotationHandle.on('dragend', (e) => {
updateRotationHandlePos(turbine); updateRotationHandlePos(turbine);
triggerAutoSave(); triggerAutoSave();
}); });
turbine.layers.marker.on('add', function() { turbine.layers.marker.on('add', function() {
if (!state.isEditMode && this.dragging) this.dragging.disable(); if (!state.isEditMode && this.dragging) this.dragging.disable();
else if (state.isEditMode && this.dragging) this.dragging.enable();
}); });
turbine.layers.rotationHandle.on('add', function() { turbine.layers.rotationHandle.on('add', function() {
if (!state.isEditMode && this.dragging) this.dragging.disable(); if (!state.isEditMode && this.dragging) this.dragging.disable();
else if (state.isEditMode && this.dragging) this.dragging.enable();
}); });
state.turbines.push(turbine); state.turbines.push(turbine);