Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract segments between nodes #2732

Merged
merged 5 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ Vespucci utilizes a number of independent, separately maintained, projects. The
* [OpeningHoursFragment](https://github.com/simonpoole/OpeningHoursFragment) opening hours user interface
* [Name Suggestion Index](https://github.com/osmlab/name-suggestion-index) name/brand-related tag suggestions database
* [iD tagging schema](https://github.com/openstreetmap/id-tagging-schema) for synonyms used for searching presets
* [geocontext](https://github.com/simonpoole/geocontext) country/region specific speed limits and similar
* [osm-area-tags](https://github.com/simonpoole/osm-area-tags) OSM tags that imply area semantics

You can update both the imagery and preset configuration from within the app, the other configuration files are updated when necessary in the APK.

## License and trademarks

Expand Down
8 changes: 8 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@ task updateGeocontext(type: Download) {
updateGeocontext.group = 'vespucci'
updateGeocontext.description = 'Update the geocontext configuration'

task updateAreaTags(type: Download) {
acceptAnyCertificate true
src 'https://raw.githubusercontent.com/simonpoole/osm-area-tags/master/area-tags.json'
dest new File(projectDir.getPath() + '/src/main/assets/area-tags.json')
}
updateAreaTags.group = 'vespucci'
updateAreaTags.description = 'Update the area tags configuration'

task updateNameSuggestionIndex(type: Download) {
acceptAnyCertificate true
src 'https://raw.githubusercontent.com/osmlab/name-suggestion-index/main/dist/nsi.min.json'
Expand Down
8 changes: 7 additions & 1 deletion documentation/docs/help/en/Multiselect.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<Node> 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<Node> wayNodes = way.getNodes();
assertEquals(2, wayNodes.size());
assertTrue(wayNodes.contains(nodes.get(0)));
assertTrue(wayNodes.contains(nodes.get(1)));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ public void rotateMultipolygon() {
TestUtils.clickAtCoordinates(device, map, 8.3881251, 47.3885077, true);
assertTrue(TestUtils.findText(device, false, context.getString(R.string.actionmode_closed_way_split_2)));
TestUtils.clickAtCoordinates(device, map, 8.3881577, 47.3886924, true);
// click away issue
assertTrue(TestUtils.findText(device, false, context.getString(R.string.tag_conflict_title)));
assertTrue(TestUtils.clickText(device, false, context.getString(R.string.Done), true, false));

assertTrue(TestUtils.findText(device, false, context.getString(R.string.actionmode_multiselect)));

assertTrue(TestUtils.clickOverflowButton(device));
Expand Down Expand Up @@ -264,6 +268,11 @@ public void createAndAddToMultiPolygon() {
TestUtils.clickAtCoordinates(device, map, 8.3881251, 47.3885077, true);
assertTrue(TestUtils.findText(device, false, context.getString(R.string.actionmode_closed_way_split_2)));
TestUtils.clickAtCoordinates(device, map, 8.3881577, 47.3886924, true);

// click away issue
assertTrue(TestUtils.findText(device, false, context.getString(R.string.tag_conflict_title)));
assertTrue(TestUtils.clickText(device, false, context.getString(R.string.Done), true, false));

assertTrue(TestUtils.findText(device, false, context.getString(R.string.actionmode_multiselect)));
TestUtils.clickUp(device);
//
Expand Down
22 changes: 12 additions & 10 deletions src/androidTest/java/de/blau/android/osm/GeometryEditsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,10 @@ public void closedWaySplit() {
final Node n5 = nList1.get(4);
assertEquals(n1, n5);
assertTrue(w1.isClosed());
Way[] ways = logic.performClosedWaySplit(main, w1, n2, n4, false);
assertEquals(2, ways.length);
assertEquals(3, ways[0].getNodes().size());
assertEquals(3, ways[1].getNodes().size());
List<Result> results = logic.performClosedWaySplit(main, w1, n2, n4, false);
assertEquals(2, results.size());
assertEquals(3, ((Way) results.get(0).getElement()).getNodes().size());
assertEquals(3, ((Way) results.get(1).getElement()).getNodes().size());
} catch (Exception igit) {
fail(igit.getMessage());
}
Expand Down Expand Up @@ -361,12 +361,14 @@ public void closedWaySplitToPolygons() {
final Node n5 = nList1.get(4);
assertEquals(n1, n5);
assertTrue(w1.isClosed());
Way[] ways = logic.performClosedWaySplit(main, w1, n1, n3, true);
assertEquals(2, ways.length);
assertEquals(4, ways[0].getNodes().size());
assertTrue(ways[0].isClosed());
assertEquals(4, ways[1].getNodes().size());
assertTrue(ways[1].isClosed());
List<Result> results = logic.performClosedWaySplit(main, w1, n1, n3, true);
assertEquals(2, results.size());
final Way way0 = (Way) results.get(0).getElement();
assertEquals(4, way0.getNodes().size());
assertTrue(way0.isClosed());
final Way way1 = (Way) results.get(1).getElement();
assertEquals(4, way1.getNodes().size());
assertTrue(way1.isClosed());
} catch (Exception igit) {
fail(igit.getMessage());
}
Expand Down
Loading
Loading