Changeset 15555 in josm for trunk/src/org
- Timestamp:
- 2019-12-03T16:28:41+01:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java
r14397 r15555 124 124 // try to build a new way which includes all the combined ways 125 125 NodeGraph graph = NodeGraph.createNearlyUndirectedGraphFromNodeWays(ways); 126 List<Node> path = graph.buildSpanningPath ();126 List<Node> path = graph.buildSpanningPathNoRemove(); 127 127 if (path == null) { 128 128 warnCombiningImpossible(); -
trunk/src/org/openstreetmap/josm/data/osm/NodeGraph.java
r15554 r15555 139 139 private final Set<NodePair> edges; 140 140 private int numUndirectedEges; 141 /** counts the number of edges that were added */ 142 private int addedEdges; 141 143 private final Map<Node, List<NodePair>> successors = new LinkedHashMap<>(); 142 144 private final Map<Node, List<NodePair>> predecessors = new LinkedHashMap<>(); … … 195 197 */ 196 198 public void add(NodePair pair) { 197 if (!edges.contains(pair)) { 198 edges.add(pair); 199 } 199 addedEdges++; 200 edges.add(pair); 200 201 } 201 202 … … 290 291 public List<Node> buildSpanningPath() { 291 292 prepare(); 292 if (numUndirectedEges > 0 && isConnected()) {293 if (numUndirectedEges > 0 && isConnected()) { 293 294 // try to find a path from each "terminal node", i.e. from a 294 295 // node which is connected by exactly one undirected edges (or … … 311 312 312 313 /** 314 * Tries to find a path through the graph which visits each edge (i.e. 315 * the segment of a way) exactly once. If the graph was build from overlapping 316 * ways duplicate edges were removed already. This method will return null if 317 * any duplicated edge was removed. 318 * 319 * @return the path; null, if no path was found or duplicated edges were found 320 * @since xxx 321 */ 322 public List<Node> buildSpanningPathNoRemove() { 323 if (edges.size() != addedEdges) 324 return null; 325 return buildSpanningPath(); 326 } 327 328 /** 313 329 * Find out if the graph is connected. 314 330 * @return true if it is connected. … … 321 337 HashSet<Node> visited = new HashSet<>(); 322 338 toVisit.add(nodes.iterator().next()); 323 while (!toVisit.isEmpty()) {339 while (!toVisit.isEmpty()) { 324 340 Node n = toVisit.pop(); 325 341 if (!visited.contains(n)) {
Note:
See TracChangeset
for help on using the changeset viewer.