Changeset 16200 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/command/SplitWayCommand.java
r15943 r16200 501 501 direction = Direction.IRRELEVANT; 502 502 } else { 503 boolean previousWayMemberMissing = true; 504 boolean nextWayMemberMissing = true; 505 503 506 // For ordered relations, looking beyond the nearest neighbour members is not required, 504 507 // and can even cause the wrong direction to be guessed (with closed loops). 505 508 if (ir - 1 >= 0 && relationMembers.get(ir - 1).isWay()) { 506 509 Way w = relationMembers.get(ir - 1).getWay(); 507 if (w.lastNode() == way.firstNode() || w.firstNode() == way.firstNode()) { 508 direction = Direction.FORWARDS; 509 } else if (w.firstNode() == way.lastNode() || w.lastNode() == way.lastNode()) { 510 direction = Direction.BACKWARDS; 510 if (!w.isIncomplete()) { 511 previousWayMemberMissing = false; 512 if (w.lastNode() == way.firstNode() || w.firstNode() == way.firstNode()) { 513 direction = Direction.FORWARDS; 514 } else if (w.firstNode() == way.lastNode() || w.lastNode() == way.lastNode()) { 515 direction = Direction.BACKWARDS; 516 } 511 517 } 518 } else { 519 previousWayMemberMissing = false; 512 520 } 513 521 if (ir + 1 < relationMembers.size() && relationMembers.get(ir + 1).isWay()) { 514 522 Way w = relationMembers.get(ir + 1).getWay(); 515 if (w.lastNode() == way.firstNode() || w.firstNode() == way.firstNode()) { 516 direction = Direction.BACKWARDS; 517 } else if (w.firstNode() == way.lastNode() || w.lastNode() == way.lastNode()) { 518 direction = Direction.FORWARDS; 523 if (!w.isIncomplete()) { 524 nextWayMemberMissing = false; 525 if (w.lastNode() == way.firstNode() || w.firstNode() == way.firstNode()) { 526 direction = Direction.BACKWARDS; 527 } else if (w.firstNode() == way.lastNode() || w.lastNode() == way.lastNode()) { 528 direction = Direction.FORWARDS; 529 } 519 530 } 531 } else { 532 nextWayMemberMissing = false; 533 } 534 535 if (direction == Direction.UNKNOWN 536 && !previousWayMemberMissing 537 && !nextWayMemberMissing) { 538 // If both the next and previous way member in the relation are already known at 539 // this point, and they are not connected to this one, then we can safely 540 // assume that the direction doesn't matter. Downloading any more members 541 // won't help in any case. 542 direction = Direction.IRRELEVANT; 520 543 } 521 544 } -
trunk/test/unit/org/openstreetmap/josm/command/SplitWayCommandTest.java
r15943 r16200 290 290 291 291 /** 292 * Non-regression test for issue #17400 ( 292 * Non-regression test for issue #17400 (Warn when splitting way in not fully downloaded region) 293 293 * 294 294 * Bus route 190 gets broken when the split occurs, because the two new way parts are inserted in the relation in … … 333 333 } 334 334 } 335 336 /** 337 * Non-regression test for issue #18863 (Asking for download of missing members when not needed) 338 * 339 * A split on node 4518025255 caused the 'download missing members?' dialog to pop up for relation 68745 (CB 2), 340 * even though the way members next to the split way were already downloaded. This happened because this relation 341 * does not have its members connected at all. 342 * 343 * This split should not trigger any download action at all. 344 * 345 * @throws IOException if any I/O error occurs 346 * @throws IllegalDataException if OSM parsing fails 347 */ 348 @Test 349 public void testTicket18863() throws IOException, IllegalDataException { 350 try (InputStream is = TestUtils.getRegressionDataStream(18863, "data.osm.bz2")) { 351 DataSet ds = OsmReader.parseDataSet(is, null); 352 353 Way splitWay = (Way) ds.getPrimitiveById(290581177L, OsmPrimitiveType.WAY); 354 Node splitNode = (Node) ds.getPrimitiveById(4518025255L, OsmPrimitiveType.NODE); 355 356 final Optional<SplitWayCommand> result = SplitWayCommand.splitWay( 357 splitWay, 358 SplitWayCommand.buildSplitChunks(splitWay, Collections.singletonList(splitNode)), 359 new ArrayList<>(), 360 Strategy.keepLongestChunk(), 361 // This split requires no additional downloads. If any are needed, this command will fail. 362 SplitWayCommand.WhenRelationOrderUncertain.ABORT 363 ); 364 365 // Should not result in aborting the split. 366 assertTrue(result.isPresent()); 367 } 368 } 335 369 }
Note:
See TracChangeset
for help on using the changeset viewer.