Changeset 15558 in josm
- Timestamp:
- 2019-12-04T11:42:24+01:00 (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/NodeGraph.java
r15556 r15558 221 221 } 222 222 223 private List<NodePair> getConnectedPairs (Node node) { 224 List<NodePair> connected = new ArrayList<>(); 225 connected.addAll(Optional.ofNullable(successors.get(node)).orElseGet(Collections::emptyList)); 226 connected.addAll(Optional.ofNullable(predecessors.get(node)).orElseGet(Collections::emptyList)); 227 return connected; 228 } 229 223 230 protected List<NodePair> getOutboundPairs(NodePair pair) { 224 231 return getOutboundPairs(pair.getB()); … … 340 347 Node n = toVisit.pop(); 341 348 if (!visited.contains(n)) { 342 List<NodePair> neighbours = getOutboundPairs(n); 343 for (NodePair pair : neighbours) { 344 toVisit.addLast(pair.getA()); 345 toVisit.addLast(pair.getB()); 349 for (NodePair pair : getConnectedPairs(n)) { 350 if (n != pair.getA()) 351 toVisit.addLast(pair.getA()); 352 if (n != pair.getB()) 353 toVisit.addLast(pair.getB()); 346 354 } 347 355 visited.add(n); -
trunk/test/unit/org/openstreetmap/josm/actions/CombineWayActionTest.java
r15555 r15558 4 4 import static org.junit.Assert.assertEquals; 5 5 import static org.junit.Assert.assertNull; 6 import static org.junit.Assert.assertTrue; 6 7 7 8 import java.io.IOException; 8 9 import java.io.InputStream; 10 import java.util.ArrayList; 11 import java.util.Collections; 9 12 import java.util.HashSet; 10 13 import java.util.List; … … 18 21 import org.openstreetmap.josm.data.osm.NodeGraph; 19 22 import org.openstreetmap.josm.data.osm.NodePair; 23 import org.openstreetmap.josm.data.osm.Way; 20 24 import org.openstreetmap.josm.io.IllegalDataException; 21 25 import org.openstreetmap.josm.io.OsmReader; … … 60 64 61 65 /** 62 * Non-regression test for bug #1835 (combine way with overlapping ways) 66 * Non-regression test for bug #18385 (combine way with overlapping ways) 63 67 * @throws IOException if any I/O error occurs 64 68 * @throws IllegalDataException if OSM parsing fails … … 75 79 76 80 /** 81 * Non-regression test for bug #18387 (combine new way with oneway) 82 * @throws IOException if any I/O error occurs 83 * @throws IllegalDataException if OSM parsing fails 84 */ 85 @Test 86 public void testTicket18387() throws IOException, IllegalDataException { 87 try (InputStream is = TestUtils.getRegressionDataStream(18387, "data.osm")) { 88 DataSet ds = OsmReader.parseDataSet(is, null); 89 ArrayList<Way> selection = new ArrayList<>(ds.getWays()); 90 assertEquals(2, selection.size()); 91 if (!selection.get(0).isNew()) 92 Collections.reverse(selection); 93 NodeGraph graph = NodeGraph.createNearlyUndirectedGraphFromNodeWays(selection); 94 List<Node> path = graph.buildSpanningPathNoRemove(); 95 assertTrue(path != null); 96 } 97 } 98 99 /** 77 100 * Unit test of methods {@link NodePair#equals} and {@link NodePair#hashCode}. 78 101 */
Note:
See TracChangeset
for help on using the changeset viewer.