From 92d2084b20c10237c778f9057e689fef081d9140 Mon Sep 17 00:00:00 2001 From: simonpoole Date: Sun, 1 Dec 2024 14:11:32 +0100 Subject: [PATCH] Add integration test and update doc --- documentation/docs/help/en/Multiselect.md | 8 ++++- .../easyedit/ExtendedSelectionTest.java | 35 ++++++++++++++++++- src/main/assets/help/en/Multiselect.html | 3 ++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/documentation/docs/help/en/Multiselect.md b/documentation/docs/help/en/Multiselect.md index 057d88c339..96952e466e 100644 --- a/documentation/docs/help/en/Multiselect.md +++ b/documentation/docs/help/en/Multiselect.md @@ -32,7 +32,13 @@ Remove the objects from the data. Merge multiple selected ways resulting in a single way. Ways will be reversed if necessary. This option will only be available if only ways with common start/end nodes are selected, or the selection is two closed ways (polygons), in the later case if the polygons do not have common nodes a multi-polygon relation will be created and the ways added as members. If post-merge tag conflicts are detected you will be alerted. -### Add node at intersection +### Extract segment + +If you have selected exactly two nodes on the same way, you can extract the segment of the way between the two nodes. If the way is closed the segment extracted will between the first and 2nd node selected in the winding direction (clockwise or counterclockwise) of the way. + +If the way has _highway_ or _waterway_ tagging a number of shortcuts will be displayed, for example to change a _footway_ in to _steps_. + +### Add node at intersectionn If two or more ways are selected and they intersect without a common node, a new node will be added at the first intersection found. diff --git a/src/androidTest/java/de/blau/android/easyedit/ExtendedSelectionTest.java b/src/androidTest/java/de/blau/android/easyedit/ExtendedSelectionTest.java index 76af84c6aa..111aad2666 100644 --- a/src/androidTest/java/de/blau/android/easyedit/ExtendedSelectionTest.java +++ b/src/androidTest/java/de/blau/android/easyedit/ExtendedSelectionTest.java @@ -2,9 +2,9 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -271,4 +271,37 @@ public void undoInsertion() { TestUtils.clickText(device, false, context.getString(R.string.okay), true); // click away tip assertTrue(TestUtils.findText(device, false, context.getResources().getQuantityString(R.plurals.actionmode_object_count, 1, 2))); } + + /** + * Select node, select 2nd node, extract segment + */ + @Test + public void extractSegment() { + TestUtils.loadTestData(main, "test2.osm"); + TestUtils.zoomToLevel(device, main, 20); // if we are zoomed in too far we might not get the selection popups + map.getDataLayer().setVisible(true); + TestUtils.unlock(device); + TestUtils.sleep(2000); + TestUtils.clickAtCoordinates(device, map, 8.3894224, 47.3891963, true); + TestUtils.clickText(device, true, context.getString(R.string.okay), true, false); // Tip + assertTrue(TestUtils.findText(device, false, context.getString(R.string.actionmode_nodeselect))); + assertTrue(TestUtils.clickOverflowButton(device)); + assertTrue(TestUtils.clickText(device, false, context.getString(R.string.menu_extend_selection), true, false)); + assertTrue(TestUtils.findText(device, false, context.getString(R.string.actionmode_multiselect))); + TestUtils.clickAtCoordinates(device, map, 8.389856, 47.3891991, true); + + assertTrue(TestUtils.findText(device, false, context.getResources().getQuantityString(R.plurals.actionmode_object_count, 2, 2), 5000)); + List nodes = new ArrayList<>(App.getLogic().getSelectedNodes()); + assertTrue(TestUtils.clickOverflowButton(device)); + assertTrue(TestUtils.clickText(device, false, context.getString(R.string.menu_extract_segment), true, false)); + + assertTrue(TestUtils.findText(device, false, context.getString(R.string.actionmode_wayselect))); + + Way way = App.getLogic().getSelectedWay(); + final List wayNodes = way.getNodes(); + assertEquals(2, wayNodes.size()); + assertTrue(wayNodes.contains(nodes.get(0))); + assertTrue(wayNodes.contains(nodes.get(1))); + } + } diff --git a/src/main/assets/help/en/Multiselect.html b/src/main/assets/help/en/Multiselect.html index c93e766a16..c631aa21dd 100644 --- a/src/main/assets/help/en/Multiselect.html +++ b/src/main/assets/help/en/Multiselect.html @@ -22,6 +22,9 @@

Delete Delete

Remove the objects from the data.

Merge Merge ways

Merge multiple selected ways resulting in a single way. Ways will be reversed if necessary. This option will only be available if only ways with common start/end nodes are selected, or the selection is two closed ways (polygons), in the later case if the polygons do not have common nodes a multi-polygon relation will be created and the ways added as members. If post-merge tag conflicts are detected you will be alerted.

+

Extract segment

+

If you have selected exactly two nodes on the same way, you can extract the segment of the way between the two nodes. If the way is closed the segment extracted will between the first and 2nd node selected in the winding direction (clockwise or counterclockwise) of the way.

+

If the way has highway or waterway tagging a number of shortcuts will be displayed, for example to change a footway in to steps.

Add node at intersection

If two or more ways are selected and they intersect without a common node, a new node will be added at the first intersection found.

Create circle