Changeset 33503 in osm for applications/editors/josm/plugins/pt_assistant/src
- Timestamp:
- 2017-08-17T11:56:02+02:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/PTAssistantValidatorTest.java
r33502 r33503 458 458 || testError.getCode() == ERROR_CODE_SORTING 459 459 || testError.getCode() == ERROR_CODE_PARTIAL_SORTING 460 || testError.getCode() == ERROR_CODE_TRIVIAL_FIX 460 461 || testError.getCode() == ERROR_CODE_END_STOP 461 462 || testError.getCode() == ERROR_CODE_PLATFORM_PART_OF_HIGHWAY) { … … 492 493 || testError.getCode() == ERROR_CODE_END_STOP) { 493 494 commands.add(WayChecker.fixErrorByZooming(testError)); 495 } 496 497 if (testError.getCode() == ERROR_CODE_TRIVIAL_FIX) { 498 commands.add(RouteChecker.fixTrivialError(testError)); 494 499 } 495 500 -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/RouteChecker.java
r33502 r33503 110 110 Builder builder = TestError.builder(this.test, Severity.WARNING, PTAssistantValidatorTest.ERROR_CODE_TRIVIAL_FIX); 111 111 builder.message(tr("PT: Route gap can be closed by adding a single way")); 112 builder.primitives(relation, before, after, fix);112 builder.primitives(relation, before, fix, after); 113 113 TestError e = builder.build(); 114 114 this.errors.add(e); … … 372 372 } 373 373 374 //the trivial fix simply adds the right way (the one found during the 375 //detection phase) in the gap in order to close it 376 protected static Command fixTrivialError(TestError testError) { 377 378 if (testError.getCode() != PTAssistantValidatorTest.ERROR_CODE_TRIVIAL_FIX) { 379 return null; 380 } 381 382 List<OsmPrimitive> primitives = new ArrayList<>(testError.getPrimitives()); 383 Relation originalRelation = (Relation) primitives.get(0); 384 Way before = (Way) primitives.get(1); 385 Way fix = (Way) primitives.get(2); 386 387 int index = 0; 388 List<RelationMember> members = originalRelation.getMembers(); 389 for (index = 0; index < members.size(); index++) { 390 if (members.get(index).getMember().equals(before)) { 391 break; 392 } 393 } 394 395 Relation fixedRelation = new Relation(originalRelation); 396 fixedRelation.addMember(index + 1, new RelationMember(null, fix)); 397 398 return new ChangeCommand(originalRelation, fixedRelation); 399 } 400 374 401 public PTRouteDataManager getManager() { 375 402 return manager;
Note:
See TracChangeset
for help on using the changeset viewer.