- Timestamp:
- 2024-02-29T07:51:49+01:00 (9 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/MultipolygonTest.java
r18871 r19001 46 46 */ 47 47 public class MultipolygonTest extends Test { 48 49 private static final String OUTER = "outer"; 50 private static final String INNER = "inner"; 48 51 49 52 /** Non-Way in multipolygon */ … … 445 448 } 446 449 if (r == createdRelation) { 450 // see #23517: sort rings so that outer come first 451 list.sort((r1, r2) -> { 452 // outer first 453 int d = Integer.compare(r1.level % 2, r2.level % 2); 454 if (d != 0) 455 return d; 456 // ring with more members first 457 return Integer.compare(r2.outerWay.getWayIds().size(), r1.outerWay.getWayIds().size()); 458 }); 447 459 List<RelationMember> modMembers = new ArrayList<>(); 448 460 for (PolygonLevel pol : list) { 449 final String calculatedRole = (pol.level % 2 == 0) ? "outer" : "inner";461 final String calculatedRole = (pol.level % 2 == 0) ? OUTER : INNER; 450 462 for (long wayId : pol.outerWay.getWayIds()) { 451 463 RelationMember member = wayMap.get(wayId); … … 457 469 } 458 470 for (PolygonLevel pol : list) { 459 final String calculatedRole = (pol.level % 2 == 0) ? "outer" : "inner";471 final String calculatedRole = (pol.level % 2 == 0) ? OUTER : INNER; 460 472 for (long wayId : pol.outerWay.getWayIds()) { 461 473 RelationMember member = wayMap.get(wayId); … … 469 481 .highlight(member.getMember()) 470 482 .build()); 471 if (pol.level == 0 && "inner".equals(member.getRole())) {483 if (pol.level == 0 && INNER.equals(member.getRole())) { 472 484 // maybe only add this error if we found an outer ring with correct role(s) ? 473 485 errors.add(TestError.builder(this, Severity.ERROR, INNER_WAY_OUTSIDE) … … 570 582 private void findIntersectingWaysIncomplete(Relation r) { 571 583 Set<OsmPrimitive> outerWays = r.getMembers().stream() 572 .filter(m -> m.getRole().isEmpty() || "outer".equals(m.getRole()))584 .filter(m -> m.getRole().isEmpty() || OUTER.equals(m.getRole())) 573 585 .map(RelationMember::getMember) 574 586 .collect(Collectors.toSet()); … … 644 656 for (RelationMember rm : r.getMembers()) { 645 657 if (rm.isWay()) { 646 if (rm.hasRole() && !rm.hasRole( "inner", "outer"))658 if (rm.hasRole() && !rm.hasRole(INNER, OUTER)) 647 659 hasUnexpectedWayRole = true; 648 if (!rm.hasRole( "inner", "outer") || !rm.hasRole()) {660 if (!rm.hasRole(INNER, OUTER) || !rm.hasRole()) { 649 661 tmpErrors.add(TestError.builder(this, Severity.ERROR, WRONG_MEMBER_ROLE) 650 662 .message(tr("Role for multipolygon way member should be inner or outer")) … … 906 918 createdRelation = null; // makes sure that repeatCheck is only set once 907 919 } while (repeatCheck); 908 errors.removeIf(e ->e.getSeverity() == Severity.OTHER);920 errors.removeIf(e -> e.getSeverity() == Severity.OTHER); 909 921 return r; 910 922 }
Note:
See TracChangeset
for help on using the changeset viewer.