Ticket #22614: 22614_faster1.patch
File 22614_faster1.patch, 2.9 KB (added by , 2 years ago) |
---|
-
src/org/openstreetmap/josm/actions/CombineWayAction.java
232 232 } 233 233 234 234 protected static List<Node> tryJoin(Collection<Way> ways) { 235 List<Node> path = joinWithMultipolygonCode(ways);235 List<Node> path = Collections.emptyList(); 236 236 if (path.isEmpty()) { 237 NodeGraph graph = NodeGraph.createDirectedGraphFromWays(ways); 238 path = graph.buildSpanningPathNoRemove(); 239 } 240 if (path.isEmpty()) { 241 path = joinWithMultipolygonCode(ways); 242 } 243 if (path.isEmpty()) { 237 244 NodeGraph graph = NodeGraph.createNearlyUndirectedGraphFromNodeWays(ways); 238 245 path = graph.buildSpanningPathNoRemove(); 239 246 } -
src/org/openstreetmap/josm/data/osm/NodeGraph.java
271 271 dupCheck.add(cur); 272 272 if (isSpanningWay(path)) 273 273 return buildPathFromNodePairs(path); 274 nextPairs.addAll(getOutboundPairs(path.peekLast())); 274 List<NodePair> followers = getOutboundPairs(cur); 275 if (addedEdges != numUndirectedEges && followers.size() == 2) { 276 final NodePair swapped = cur.swap(); 277 followers.remove(swapped); 278 } 279 nextPairs.addAll(followers); 275 280 } 276 281 } 277 282 } … … 369 374 sortedMap.computeIfAbsent(e.getValue(), x -> new LinkedHashSet<>()).add(e.getKey()); 370 375 } 371 376 LinkedHashSet<Node> result = new LinkedHashSet<>(); 377 final int threshold = numUndirectedEges == addedEdges ? 2 : 4; 372 378 for (Entry<Integer, Set<Node>> e : sortedMap.entrySet()) { 373 if (e.getKey() > 4|| result.isEmpty()) {379 if (e.getKey() > threshold || result.isEmpty()) { 374 380 result.addAll(e.getValue()); 375 381 } 376 382 } -
src/org/openstreetmap/josm/data/osm/NodePair.java
77 77 public String toString() { 78 78 return new StringBuilder() 79 79 .append('[') 80 .append(a.get Id())80 .append(a.getUniqueId()) 81 81 .append(',') 82 .append(b.get Id())82 .append(b.getUniqueId()) 83 83 .append(']') 84 84 .toString(); 85 85 }