Changeset 17375 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/command/SplitWayCommand.java
r17367 r17375 467 467 if (rValue.warnme) warnings.add(WarningType.GENERIC); 468 468 insert = rValue.insert; 469 c = rValue.relation; 469 c = rValue.relation; // Value.relation is null or contains a modified copy 470 470 } else if (!isOrderedRelation) { 471 471 // Warn the user when relations that are not a route or multipolygon are modified as a result … … 473 473 warnings.add(WarningType.GENERIC); 474 474 } 475 if (c == null) {476 c = new Relation(r);477 }478 475 479 476 if (insert) { 477 if (c == null) { 478 c = new Relation(r); 479 } 480 480 if (rm.hasRole() && !nowarnroles.contains(rm.getRole())) { 481 481 warnings.add(WarningType.ROLE); … … 818 818 c.addMember(new RelationMember(role, res)); 819 819 c.removeMembersFor(way); 820 relationInformation.insert = false;821 820 } 822 } else {823 relationInformation.insert = false;824 821 } 825 822 } else if (!"via".equals(role)) { 826 823 relationInformation.warnme = true; 824 } else { 825 relationInformation.insert = true; 827 826 } 828 827 relationInformation.relation = c; -
trunk/test/unit/org/openstreetmap/josm/command/SplitWayCommandTest.java
r17275 r17375 396 396 } 397 397 } 398 399 /** 400 * Non-regression test for issue #20163 (Split way corrupts relation when splitting via way) 401 * 402 * @throws IOException if any I/O error occurs 403 * @throws IllegalDataException if OSM parsing fails 404 */ 405 @Test 406 void testTicket20163() throws IOException, IllegalDataException { 407 try (InputStream is = TestUtils.getRegressionDataStream(20163, "data-20163.osm")) { 408 DataSet ds = OsmReader.parseDataSet(is, null); 409 410 Way splitWay = (Way) ds.getPrimitiveById(757606841L, OsmPrimitiveType.WAY); 411 Node splitNode = splitWay.getNode(1); 412 Relation r = (Relation) ds.getPrimitiveById(10452821L, OsmPrimitiveType.RELATION); 413 assertEquals(3, r.getMembersCount()); 414 assertFalse(r.getMembersFor(Collections.singleton(splitWay)).isEmpty()); 415 assertEquals(1, r.getMembers().stream().filter(rm -> "via".equals(rm.getRole())).count()); 416 assertEquals("via", r.getMembersFor(Collections.singleton(splitWay)).iterator().next().getRole()); 417 final Optional<SplitWayCommand> result = SplitWayCommand.splitWay( 418 splitWay, 419 SplitWayCommand.buildSplitChunks(splitWay, Collections.singletonList(splitNode)), 420 new ArrayList<>(), 421 Strategy.keepLongestChunk(), 422 // This split requires additional downloads but problem occured before the download 423 SplitWayCommand.WhenRelationOrderUncertain.SPLIT_ANYWAY 424 ); 425 426 // Should not result in aborting the split. 427 assertTrue(result.isPresent()); 428 result.get().executeCommand(); 429 430 assertTrue(r.isModified()); 431 assertEquals(4, r.getMembersCount()); 432 assertEquals(2, r.getMembers().stream().filter(rm -> "via".equals(rm.getRole())).count()); 433 } 434 } 435 398 436 }
Note:
See TracChangeset
for help on using the changeset viewer.