Changeset 11441 in josm for trunk/test/unit/org
- Timestamp:
- 2017-01-07T17:19:05+01:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/SelfIntersectingWayTest.java
r11201 r11441 25 25 @BeforeClass 26 26 public static void setUp() throws Exception { 27 JOSMFixture.createUnitTestFixture().init( true);27 JOSMFixture.createUnitTestFixture().init(false); 28 28 } 29 29 30 30 private static List<Node> createNodes() { 31 31 List<Node> nodes = new ArrayList<>(); 32 for (int i = 0; i < 5; i++) {32 for (int i = 0; i < 6; i++) { 33 33 nodes.add(new Node(i+1)); 34 34 } 35 nodes.get(0).setCoor(new LatLon(34.2680878298, 133.56336369008)); 36 nodes.get(1).setCoor(new LatLon(34.25096598132, 133.54891792012)); 37 nodes.get(2).setCoor(new LatLon(34.24466741332, 133.56693544639)); 38 nodes.get(3).setCoor(new LatLon(34.26815342405, 133.56066502976)); 39 nodes.get(4).setCoor(new LatLon(34.26567411471, 133.56132705125)); 35 nodes.get(0).setCoor(new LatLon(34.2680, 133.563)); 36 nodes.get(1).setCoor(new LatLon(34.2509, 133.548)); 37 nodes.get(2).setCoor(new LatLon(34.2446, 133.566)); 38 nodes.get(3).setCoor(new LatLon(34.2681, 133.560)); 39 nodes.get(4).setCoor(new LatLon(34.2656, 133.561)); 40 nodes.get(5).setCoor(new LatLon(34.2655, 133.562)); 40 41 return nodes; 41 42 } … … 86 87 87 88 /** 89 * First node is identical to an inner node ("P"-Shape). 90 * This is considered okay. 91 */ 92 @Test 93 public void testUnclosedWayFirstRepeated() { 94 List<Node> nodes = createNodes(); 95 96 Way w = (Way) OsmUtils.createPrimitive("way "); 97 List<Node> wayNodes = new ArrayList<>(); 98 wayNodes.add(nodes.get(0)); 99 wayNodes.add(nodes.get(1)); 100 wayNodes.add(nodes.get(2)); 101 wayNodes.add(nodes.get(0)); 102 wayNodes.add(nodes.get(3)); 103 wayNodes.add(nodes.get(4)); 104 w.setNodes(wayNodes); 105 SelfIntersectingWay test = new SelfIntersectingWay(); 106 test.visit(w); 107 Assert.assertEquals(0, test.getErrors().size()); 108 } 109 110 /** 88 111 * Last node is identical to an inner node ("b"-Shape). 89 112 * This is considered okay. … … 109 132 /** 110 133 * Both endpoints join at one inner node ("8"-shape). 111 * This is considered okay.134 * This is considered to be an error. 112 135 */ 113 136 @Test … … 127 150 SelfIntersectingWay test = new SelfIntersectingWay(); 128 151 test.visit(w); 129 Assert.assertEquals(0, test.getErrors().size()); 152 Assert.assertEquals(1, test.getErrors().size()); 153 Assert.assertTrue(test.getErrors().iterator().next().getHighlighted().contains(nodes.get(0))); 154 } 155 156 /** 157 * Closed way contains a spike. 158 * This is considered to be an error. 159 */ 160 @Test 161 public void testSpikeWithStartInClosedWay() { 162 List<Node> nodes = createNodes(); 163 164 Way w = (Way) OsmUtils.createPrimitive("way "); 165 List<Node> wayNodes = new ArrayList<>(); 166 wayNodes.add(nodes.get(0)); 167 wayNodes.add(nodes.get(1)); 168 wayNodes.add(nodes.get(0)); // problem 169 wayNodes.add(nodes.get(3)); 170 wayNodes.add(nodes.get(4)); 171 wayNodes.add(nodes.get(0)); 172 w.setNodes(wayNodes); 173 SelfIntersectingWay test = new SelfIntersectingWay(); 174 test.visit(w); 175 Assert.assertEquals(1, test.getErrors().size()); 176 Assert.assertTrue(test.getErrors().iterator().next().getHighlighted().contains(nodes.get(0))); 177 } 178 179 /** 180 * Closed way contains a spike. 181 * This is considered to be an error. 182 */ 183 @Test 184 public void testSpikeWithEndInClosedWay() { 185 List<Node> nodes = createNodes(); 186 187 Way w = (Way) OsmUtils.createPrimitive("way "); 188 List<Node> wayNodes = new ArrayList<>(); 189 wayNodes.add(nodes.get(0)); 190 wayNodes.add(nodes.get(1)); 191 wayNodes.add(nodes.get(2)); 192 wayNodes.add(nodes.get(0)); // problem 193 wayNodes.add(nodes.get(3)); 194 wayNodes.add(nodes.get(0)); 195 w.setNodes(wayNodes); 196 SelfIntersectingWay test = new SelfIntersectingWay(); 197 test.visit(w); 198 Assert.assertEquals(1, test.getErrors().size()); 199 Assert.assertTrue(test.getErrors().iterator().next().getHighlighted().contains(nodes.get(0))); 200 } 201 202 /** 203 * Closed way contains a spike. 204 * This is considered to be an error. 205 */ 206 @Test 207 public void testSpikeInClosedWay() { 208 List<Node> nodes = createNodes(); 209 210 Way w = (Way) OsmUtils.createPrimitive("way "); 211 List<Node> wayNodes = new ArrayList<>(); 212 wayNodes.add(nodes.get(0)); 213 wayNodes.add(nodes.get(1)); 214 wayNodes.add(nodes.get(2)); 215 wayNodes.add(nodes.get(3)); 216 wayNodes.add(nodes.get(2)); 217 wayNodes.add(nodes.get(0)); 218 w.setNodes(wayNodes); 219 SelfIntersectingWay test = new SelfIntersectingWay(); 220 test.visit(w); 221 Assert.assertEquals(1, test.getErrors().size()); 222 Assert.assertTrue(test.getErrors().iterator().next().getHighlighted().contains(nodes.get(2))); 223 } 224 225 /** 226 * Closed way with barbell shape (a-b-c-a-d-e-f-d). 227 * This is considered to be an error. 228 */ 229 @Test 230 public void testClosedWayBarbell() { 231 List<Node> nodes = createNodes(); 232 233 Way w = (Way) OsmUtils.createPrimitive("way "); 234 List<Node> wayNodes = new ArrayList<>(); 235 wayNodes.add(nodes.get(0)); 236 wayNodes.add(nodes.get(1)); 237 wayNodes.add(nodes.get(2)); 238 wayNodes.add(nodes.get(0)); 239 wayNodes.add(nodes.get(3)); 240 wayNodes.add(nodes.get(4)); 241 wayNodes.add(nodes.get(5)); 242 wayNodes.add(nodes.get(3)); 243 w.setNodes(wayNodes); 244 SelfIntersectingWay test = new SelfIntersectingWay(); 245 test.visit(w); 246 Assert.assertEquals(1, test.getErrors().size()); 247 Assert.assertTrue(test.getErrors().iterator().next().getHighlighted().contains(nodes.get(3))); 130 248 } 131 249
Note:
See TracChangeset
for help on using the changeset viewer.