Fix rotation handle drag issue and optimize performance
Deploy Standortplaner / deploy (push) Successful in 16s Details

This commit is contained in:
Johannes Baumeister 2026-07-06 13:50:31 +02:00
parent 21bd7f00be
commit dcd72a1268
1 changed files with 7 additions and 6 deletions

15
app.js
View File

@ -566,11 +566,9 @@ document.addEventListener('DOMContentLoaded', async () => {
const centerUtm = proj4(wgs84, utm32, [turbine.latlng.lng, turbine.latlng.lat]); const centerUtm = proj4(wgs84, utm32, [turbine.latlng.lng, turbine.latlng.lat]);
const handleUtm = proj4(wgs84, utm32, [handlePos.lng, handlePos.lat]); const handleUtm = proj4(wgs84, utm32, [handlePos.lng, handlePos.lat]);
// Calculate angle: Math.atan2(dx, dy). Note: y is North (up), x is East (right) // Calculate angle
// We want 0 deg to be South (down), following the KSF pattern if needed.
// Moving handle CW (to West/-X) should increase angle.
const dx = handleUtm[0] - centerUtm[0]; const dx = handleUtm[0] - centerUtm[0];
const dy = centerUtm[1] - handleUtm[1]; // Handle is South of center -> positive dy const dy = centerUtm[1] - handleUtm[1];
let angle = Math.atan2(-dx, dy) * (180 / Math.PI); let angle = Math.atan2(-dx, dy) * (180 / Math.PI);
if (angle < 0) angle += 360; if (angle < 0) angle += 360;
@ -579,15 +577,18 @@ 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) => {
// 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);
updateRotationHandlePos(turbine);
});
turbine.layers.rotationHandle.on('dragend', triggerAutoSave); updateRotationHandlePos(turbine);
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();