Ticket #20159: 20159-count-changes.patch
File 20159-count-changes.patch, 2.1 KB (added by , 3 years ago) |
---|
-
src/org/openstreetmap/josm/actions/SplitWayAction.java
142 142 sel.addAll(selectedWays); 143 143 144 144 final List<Way> newWays = SplitWayCommand.createNewWaysFromChunks(selectedWay, wayChunks); 145 final Way wayToKeep = SplitWayCommand. Strategy.keepLongestChunk().determineWayToKeep(newWays);145 final Way wayToKeep = SplitWayCommand.smallestChangeset(selectedWay, newWays); 146 146 147 147 if (ExpertToggleAction.isExpert() && !selectedWay.isNew()) { 148 148 final ExtendedDialog dialog = new SegmentToKeepSelectionDialog(selectedWay, newWays, wayToKeep, sel); -
src/org/openstreetmap/josm/command/SplitWayCommand.java
427 427 } 428 428 } 429 429 430 /** 431 * Calculate the best way 432 * @param way the way to split 433 * @param newWays potential new ways 434 * @return the way to keep to reduce the number of changed relations 435 * @since xxx 436 */ 437 public static Way smallestChangeset(Way way, List<Way> newWays) { 438 if (way.isNew()) 439 return Strategy.keepLongestChunk().determineWayToKeep(newWays); 440 int bestCount = Integer.MAX_VALUE; 441 Way wayToKeep = newWays.iterator().next(); 442 for (Way w : newWays) { 443 Analysis res = analyseSplit(way, w, newWays); 444 if (res.numberOfRelations < bestCount) { 445 bestCount = res.numberOfRelations; 446 wayToKeep = w; 447 } 448 res.cleanup(); 449 } 450 return wayToKeep; 451 } 452 430 453 static Analysis analyseSplit(Way way, 431 454 Way wayToKeep, 432 455 List<Way> newWays) {