From f4230785e16b51a765803df9cbc10b25ce71b9e2 Mon Sep 17 00:00:00 2001 From: Martin Raifer Date: Tue, 18 Mar 2025 12:00:35 +0100 Subject: [PATCH] fix squaring operation on vertices, closes #10401 * only calculate `motion` for the selected vertex * don't treat vertex as "closed way" when checking disabled/enabled state of operation --- CHANGELOG.md | 2 ++ modules/actions/orthogonalize.js | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 879bc0e5d..f472edb7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ _Breaking developer changes, which may affect downstream projects or sites that #### :sparkles: Usability & Accessibility * Allow searching for coordinates in localized number format in search box ([#10805]) #### :scissors: Operations +* Fix unexpected behavior of squaring operation on individual vertices ([#10401]) #### :camera: Street-Level * Add prev/next button to viewer for local georeferenced photos ([#10852], thanks [@0xatulpatil]) #### :white_check_mark: Validation @@ -58,6 +59,7 @@ _Breaking developer changes, which may affect downstream projects or sites that [#10805]: https://github.com/openstreetmap/iD/pull/10805 [#10299]: https://github.com/openstreetmap/iD/issues/10299 +[#10401]: https://github.com/openstreetmap/iD/issues/10401 [#10843]: https://github.com/openstreetmap/iD/pull/10843 [#10852]: https://github.com/openstreetmap/iD/issues/10852 [#10885]: https://github.com/openstreetmap/iD/issues/10885 diff --git a/modules/actions/orthogonalize.js b/modules/actions/orthogonalize.js index 3eb0f13ca..960eca444 100644 --- a/modules/actions/orthogonalize.js +++ b/modules/actions/orthogonalize.js @@ -56,9 +56,9 @@ export function actionOrthogonalize(wayID, projection, vertexID, degThresh, ep) if (points.length === 3) { // move only one vertex for right triangle for (i = 0; i < 1000; i++) { - motions = points.map(calcMotion); + const motion = calcMotion(points[1], 1, points); - points[corner.i].coord = geoVecAdd(points[corner.i].coord, motions[corner.i]); + points[corner.i].coord = geoVecAdd(points[corner.i].coord, motion); score = corner.dotp; if (score < epsilon) { break; @@ -217,7 +217,7 @@ export function actionOrthogonalize(wayID, projection, vertexID, degThresh, ep) way = way.removeNode(''); // sanity check - remove any consecutive duplicates graph = graph.replace(way); - var isClosed = way.isClosed(); + const isClosed = way.isClosed() && vertexID === undefined; var nodes = graph.childNodes(way).slice(); // shallow copy if (isClosed) nodes.pop();