Changeset 11241 in josm
- Timestamp:
- 2016-11-12T15:36:05+01:00 (8 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/MultipolygonTest.java
r11227 r11241 81 81 public static final int RINGS_SHARE_NODES = 1617; 82 82 83 private static final int FOUND_INSIDE = 1; 84 private static final int FOUND_OUTSIDE = 2; 85 83 86 private final Set<String> keysCheckedByAnotherTest = new HashSet<>(); 84 87 … … 89 92 super(tr("Multipolygon"), 90 93 tr("This test checks if multipolygons are valid.")); 91 }92 93 @Override94 public void initialize() {95 94 } 96 95 … … 137 136 checkOuterWay(r); 138 137 boolean hasRepeatedMembers = checkRepeatedWayMembers(r); 139 if (!hasRepeatedMembers) { 140 // Rest of checks is only for complete multipolygon 141 if (!r.hasIncompleteMembers()) { 142 Multipolygon polygon = new Multipolygon(r); 143 checkStyleConsistency(r, polygon); 144 checkGeometryAndRoles(r, polygon); 145 } 138 // Rest of checks is only for complete multipolygon 139 if (!hasRepeatedMembers && !r.hasIncompleteMembers()) { 140 Multipolygon polygon = new Multipolygon(r); 141 checkStyleConsistency(r, polygon); 142 checkGeometryAndRoles(r, polygon); 146 143 } 147 144 } … … 285 282 PolyData pd2 = allPolygons.get(j); 286 283 if (!checkProblemMap(crossingPolyMap, pd1, pd2)) { 287 checkPolygonsForSharedNodes(r, pd1, pd2, sharedNodes , wayMap);284 checkPolygonsForSharedNodes(r, pd1, pd2, sharedNodes); 288 285 } 289 286 } … … 310 307 * @return List of nodes were ways intersect 311 308 */ 312 private Set<Node> findIntersectionNodes(Relation r) {309 private static Set<Node> findIntersectionNodes(Relation r) { 313 310 Set<Node> intersectionNodes = new HashSet<>(); 314 311 Map<Node, List<Way>> nodeMap = new HashMap<>(); … … 344 341 } 345 342 346 private void checkPolygonsForSharedNodes(Relation r, PolyData pd1, PolyData pd2, Set<Node> allSharedNodes, 347 Map<Long, RelationMember> wayMap) { 343 private void checkPolygonsForSharedNodes(Relation r, PolyData pd1, PolyData pd2, Set<Node> allSharedNodes) { 348 344 Set<Node> sharedByPolygons = new HashSet<>(allSharedNodes); 349 345 sharedByPolygons.retainAll(pd1.getNodes()); … … 391 387 } 392 388 393 private ExtPolygonIntersection checkOverlapAtSharedNodes(Set<Node> shared, PolyData pd1, PolyData pd2) {389 private static ExtPolygonIntersection checkOverlapAtSharedNodes(Set<Node> shared, PolyData pd1, PolyData pd2) { 394 390 // Idea: if two polygons share one or more nodes they can either just touch or share segments or intersect. 395 391 // The insideness test is complex, so we try to reduce the number of these tests. 396 392 // There is no need to check all nodes, we only have to check the node following a shared node. 397 393 398 final int FOUND_INSIDE = 1;399 final int FOUND_OUTSIDE = 2;400 394 int[] flags = new int[2]; 401 395 for (int loop = 0; loop < flags.length; loop++) { … … 447 441 */ 448 442 private static class PolygonLevel { 449 publicfinal int level; // nesting level, even for outer, odd for inner polygons.450 publicfinal PolyData outerWay;443 final int level; // nesting level, even for outer, odd for inner polygons. 444 final PolyData outerWay; 451 445 452 446 PolygonLevel(PolyData pd, int level) { … … 504 498 private static boolean checkIfNodeIsInsidePolygon(Node n, PolyData p) { 505 499 EastNorth en = n.getEastNorth(); 506 return (en != null && p.get().contains(en.getX(), en.getY()));500 return en != null && p.get().contains(en.getX(), en.getY()); 507 501 } 508 502 … … 530 524 531 525 for (Way w : r.getMemberPrimitives(Way.class)) { 532 findIntersectingWay(w, r,cellSegments, problemWays, loop == 1);526 findIntersectingWay(w, cellSegments, problemWays, loop == 1); 533 527 } 534 528 … … 587 581 * Find ways which are crossing without sharing a node. 588 582 * @param w way that is member of the relation 589 * @param r the relation (used for error messages)590 583 * @param cellSegments map with already collected way segments 591 584 * @param crossingWays list to collect crossing ways 592 585 * @param findSharedWaySegments true: find shared way segments instead of crossings 593 586 */ 594 private void findIntersectingWay(Way w, Relation r, Map<Point2D, List<WaySegment>> cellSegments,587 private static void findIntersectingWay(Way w, Map<Point2D, List<WaySegment>> cellSegments, 595 588 Map<List<Way>, List<WaySegment>> crossingWays, boolean findSharedWaySegments) { 596 589 int nodesSize = w.getNodesCount(); … … 637 630 * @return true if the combination of polygons is found in the map 638 631 */ 639 private boolean checkProblemMap(Map<PolyData, List<PolyData>> problemPolyMap, PolyData pd1, PolyData pd2) {632 private static boolean checkProblemMap(Map<PolyData, List<PolyData>> problemPolyMap, PolyData pd1, PolyData pd2) { 640 633 List<PolyData> crossingWithFirst = problemPolyMap.get(pd1); 641 if (crossingWithFirst != null) { 642 if (crossingWithFirst.contains(pd2)) 643 return true; 634 if (crossingWithFirst != null && crossingWithFirst.contains(pd2)) { 635 return true; 644 636 } 645 637 List<PolyData> crossingWith2nd = problemPolyMap.get(pd2); 646 return (crossingWith2nd != null && crossingWith2nd.contains(pd1));638 return crossingWith2nd != null && crossingWith2nd.contains(pd1); 647 639 } 648 640 … … 795 787 } 796 788 797 publicList<PolygonLevel> findOuterWays(List<PolyData> allPolygons) {789 List<PolygonLevel> findOuterWays(List<PolyData> allPolygons) { 798 790 return findOuterWaysRecursive(0, allPolygons); 799 791 } -
trunk/src/org/openstreetmap/josm/tools/Shortcut.java
r11218 r11241 284 284 } 285 285 286 publicvoid replace(Shortcut newShortcut) {286 void replace(Shortcut newShortcut) { 287 287 final Optional<Shortcut> existing = findShortcutByKeyOrShortText(-1, NONE, newShortcut.shortText); 288 288 if (existing.isPresent()) { -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MultipolygonTestTest.java
r11227 r11241 49 49 /** 50 50 * Non-regression test for bug #10469. 51 * @throws Exception if an exception occurs 51 52 */ 52 53 @Test 53 public void testTicket10469() {54 public void testTicket10469() throws Exception { 54 55 MULTIPOLYGON_TEST.initialize(); 55 56 MULTIPOLYGON_TEST.startTest(null); -
trunk/test/unit/org/openstreetmap/josm/tools/UtilsTest.java
r10758 r11241 10 10 11 11 import org.junit.Assert; 12 import org.junit.Rule; 12 13 import org.junit.Test; 13 14 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 20 21 * Use default, basic test rules. 21 22 */ 23 @Rule 22 24 public JOSMTestRules rules = new JOSMTestRules(); 23 25
Note:
See TracChangeset
for help on using the changeset viewer.