Changeset 30783 in osm for applications/editors/josm
- Timestamp:
- 2014-10-29T22:12:34+01:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/merge-overlap/src/mergeoverlap/MergeOverlapAction.java
r30782 r30783 186 186 combine.add(way); 187 187 for (Way opositWay : ways) { 188 if (way != opositWay 189 && way.getNodesCount() == opositWay.getNodesCount()) { 188 if (way != opositWay && way.getNodesCount() == opositWay.getNodesCount()) { 190 189 boolean equals1 = true; 191 190 for (int i = 0; i < way.getNodesCount(); i++) { … … 197 196 boolean equals2 = true; 198 197 for (int i = 0; i < way.getNodesCount(); i++) { 199 if (way.getNode(i) != opositWay.getNode(way 200 .getNodesCount() 201 - i - 1)) { 198 if (way.getNode(i) != opositWay.getNode(way.getNodesCount() - i - 1)) { 202 199 equals2 = false; 203 200 break; … … 283 280 private boolean follows(Way way1, Way way2, NodePos np1, NodePos np2, 284 281 int incr) { 285 if (way2.isClosed() && incr == 1 286 && np1.opositPos == way2.getNodesCount() - 2) { 282 if (way2.isClosed() && incr == 1 && np1.opositPos == way2.getNodesCount() - 2) { 287 283 return np2.pos == np1.pos + 1 && np2.opositPos == 0; 288 284 } else if (way2.isClosed() && incr == 1 && np1.opositPos == 0) { … … 290 286 || np2.pos == np1.pos + 1 && np2.opositPos == 1; 291 287 } else if (way2.isClosed() && incr == -1 && np1.opositPos == 0) { 292 return np2.pos == np1.pos && np2.opositPos == 0 293 || np2.pos == np1.pos + 1 288 return np2.pos == np1.pos && np2.opositPos == 0 || np2.pos == np1.pos + 1 294 289 && np2.opositPos == way2.getNodesCount() - 2; 295 290 } else { 296 return np2.pos == np1.pos + 1 297 && np2.opositPos == np1.opositPos + incr; 291 return np2.pos == np1.pos + 1 && np2.opositPos == np1.opositPos + incr; 298 292 } 299 293 } … … 307 301 * @return 308 302 */ 309 private SplitWayResult splitWay(OsmDataLayer layer, Way way, 310 List<List<Node>> wayChunks) { 303 private SplitWayResult splitWay(OsmDataLayer layer, Way way, List<List<Node>> wayChunks) { 311 304 // build a list of commands, and also a new selection list 312 Collection<Command> commandList = new ArrayList<>(wayChunks 313 .size()); 305 Collection<Command> commandList = new ArrayList<>(wayChunks.size()); 314 306 315 307 Iterator<List<Node>> chunkIt = wayChunks.iterator(); 316 Collection<String> nowarnroles = Main.pref.getCollection( 317 "way.split.roles.nowarn", Arrays.asList(new String[] { "outer", 318 "inner", "forward", "backward" })); 308 Collection<String> nowarnroles = Main.pref.getCollection("way.split.roles.nowarn", 309 Arrays.asList(new String[] { "outer", "inner", "forward", "backward" })); 319 310 320 311 // First, change the original way … … 402 393 warnme = true; 403 394 } 404 } else if (!("route".equals(type)) 405 && !("multipolygon".equals(type))) { 395 } else if (!("route".equals(type)) && !("multipolygon".equals(type))) { 406 396 warnme = true; 407 397 } … … 418 408 int k = 1; 419 409 while (ir - k >= 0 || ir + k < relationMembers.size()) { 420 if ((ir - k >= 0) 421 && relationMembers.get(ir - k).isWay()) { 410 if ((ir - k >= 0) && relationMembers.get(ir - k).isWay()) { 422 411 Way w = relationMembers.get(ir - k).getWay(); 423 if ((w.lastNode() == way.firstNode()) 424 || w.firstNode() == way.firstNode()) { 412 if ((w.lastNode() == way.firstNode()) || w.firstNode() == way.firstNode()) { 425 413 backwards = false; 426 } else if ((w.firstNode() == way.lastNode()) 427 || w.lastNode() == way.lastNode()) { 414 } else if ((w.firstNode() == way.lastNode()) || w.lastNode() == way.lastNode()) { 428 415 backwards = true; 429 416 } 430 417 break; 431 418 } 432 if ((ir + k < relationMembers.size()) 433 && relationMembers.get(ir + k).isWay()) { 419 if ((ir + k < relationMembers.size()) && relationMembers.get(ir + k).isWay()) { 434 420 Way w = relationMembers.get(ir + k).getWay(); 435 if ((w.lastNode() == way.firstNode()) 436 || w.firstNode() == way.firstNode()) { 421 if ((w.lastNode() == way.firstNode()) || w.firstNode() == way.firstNode()) { 437 422 backwards = true; 438 } else if ((w.firstNode() == way.lastNode()) 439 || w.lastNode() == way.lastNode()) { 423 } else if ((w.firstNode() == way.lastNode()) || w.lastNode() == way.lastNode()) { 440 424 backwards = false; 441 425 } … … 447 431 int j = ic; 448 432 for (Way wayToAdd : newWays) { 449 RelationMember em = new RelationMember( 450 rm.getRole(), wayToAdd); 433 RelationMember em = new RelationMember(rm.getRole(), wayToAdd); 451 434 j++; 452 435 if ((backwards != null) && backwards) { … … 469 452 } 470 453 if (warnmerole) { 471 JOptionPane.showMessageDialog( 472 Main.parent, 454 JOptionPane.showMessageDialog(Main.parent, 473 455 tr("<html>A role based relation membership was copied to all new ways.<br>You should verify this and correct it when necessary.</html>"), 474 456 tr("Warning"), JOptionPane.WARNING_MESSAGE); 475 457 } else if (warnme) { 476 JOptionPane.showMessageDialog( 477 Main.parent, 458 JOptionPane.showMessageDialog(Main.parent, 478 459 tr("<html>A relation membership was copied to all new ways.<br>You should verify this and correct it when necessary.</html>"), 479 460 tr("Warning"), JOptionPane.WARNING_MESSAGE); 480 461 } 481 462 482 return new SplitWayResult( 483 new SequenceCommand(tr("Split way"), commandList), null, 484 changedWay, newWays); 463 return new SplitWayResult(new SequenceCommand(tr("Split way"), commandList), null, changedWay, newWays); 485 464 } 486 465 … … 491 470 * @throws UserCancelException 492 471 */ 493 private Pair<Way, List<Command>> combineWaysWorker(Collection<Way> ways) 494 throws UserCancelException { 472 private Pair<Way, List<Command>> combineWaysWorker(Collection<Way> ways) throws UserCancelException { 495 473 496 474 // prepare and clean the list of ways to combine 497 475 if (ways == null || ways.isEmpty()) 498 476 return null; 499 ways.remove(null); // just in case - remove all null ways from the 500 // collection 477 ways.remove(null); // just in case - remove all null ways from the collection 501 478 502 479 // remove duplicates, preserving order … … 514 491 List<Way> unreversedWays = new LinkedList<>(); 515 492 for (Way w : ways) { 516 if ((path.indexOf(w.getNode(0)) + 1) == path.lastIndexOf(w 517 .getNode(1))) { 493 if ((path.indexOf(w.getNode(0)) + 1) == path.lastIndexOf(w.getNode(1))) { 518 494 unreversedWays.add(w); 519 495 } else { … … 529 505 if ((reversedWays != null) && !reversedWays.isEmpty()) { 530 506 // filter out ways that have no direction-dependent tags 531 unreversedWays = ReverseWayTagCorrector 532 .irreversibleWays(unreversedWays); 533 reversedWays = ReverseWayTagCorrector 534 .irreversibleWays(reversedWays); 507 unreversedWays = ReverseWayTagCorrector.irreversibleWays(unreversedWays); 508 reversedWays = ReverseWayTagCorrector.irreversibleWays(reversedWays); 535 509 // reverse path if there are more reversed than unreversed ways with 536 510 // direction-dependent tags … … 552 526 Way wnew = new Way(w); 553 527 reversedTagWays.add(wnew); 554 changePropertyCommands = reverseWayTagCorrector.execute(w, 555 wnew); 556 } 557 if ((changePropertyCommands != null) 558 && !changePropertyCommands.isEmpty()) { 528 changePropertyCommands = reverseWayTagCorrector.execute(w, wnew); 529 } 530 if ((changePropertyCommands != null) && !changePropertyCommands.isEmpty()) { 559 531 for (Command c : changePropertyCommands) { 560 532 c.executeCommand();
Note:
See TracChangeset
for help on using the changeset viewer.