- Timestamp:
- 2024-01-15T17:20:18+01:00 (10 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/SimplifyWayAction.java
r18883 r18935 341 341 */ 342 342 private static SequenceCommand buildSimplifyWaysCommand(List<Way> ways, double threshold) { 343 Collection<Command> allCommands = ways.stream()344 .map(way -> createSimplifyCommand(way, threshold ))343 List<Command> allCommands = ways.stream() 344 .map(way -> createSimplifyCommand(way, threshold, false)) 345 345 .filter(Objects::nonNull) 346 346 .collect(StreamUtils.toUnmodifiableList()); 347 347 if (allCommands.isEmpty()) 348 348 return null; 349 final List<OsmPrimitive> deletedPrimitives = allCommands.stream() 350 .map(Command::getChildren) 351 .flatMap(Collection::stream) 352 .filter(DeleteCommand.class::isInstance) 353 .map(DeleteCommand.class::cast) 354 .map(DeleteCommand::getParticipatingPrimitives) 355 .flatMap(Collection::stream) 356 .collect(Collectors.toList()); 357 allCommands.get(0).getAffectedDataSet().clearSelection(deletedPrimitives); 349 358 return new SequenceCommand( 350 359 trn("Simplify {0} way", "Simplify {0} ways", allCommands.size(), allCommands.size()), … … 372 381 */ 373 382 public static SequenceCommand createSimplifyCommand(Way w, double threshold) { 383 return createSimplifyCommand(w, threshold, true); 384 } 385 386 /** 387 * Creates the SequenceCommand to simplify a way with a given threshold. 388 * 389 * @param w the way to simplify 390 * @param threshold the max error threshold 391 * @param deselect {@code true} if we want to deselect the deleted nodes 392 * @return The sequence of commands to run 393 */ 394 private static SequenceCommand createSimplifyCommand(Way w, double threshold, boolean deselect) { 374 395 int lower = 0; 375 396 int i = 0; … … 418 439 cmds.add(new ChangeNodesCommand(w, newNodes)); 419 440 cmds.add(new DeleteCommand(w.getDataSet(), delNodes)); 420 w.getDataSet().clearSelection(delNodes); 441 if (deselect) { 442 w.getDataSet().clearSelection(delNodes); 443 } 421 444 return new SequenceCommand( 422 445 trn("Simplify Way (remove {0} node)", "Simplify Way (remove {0} nodes)", delNodes.size(), delNodes.size()), cmds);
Note:
See TracChangeset
for help on using the changeset viewer.