Changeset 33405 in osm for applications/editors/josm/plugins
- Timestamp:
- 2017-06-21T22:23:11+02:00 (8 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
r33349 r33405 45 45 46 46 public static final int ERROR_CODE_SORTING = 3711; 47 public static final int ERROR_CODE_PARTIAL_SORTING = 3712; 47 48 public static final int ERROR_CODE_ROAD_TYPE = 3721; 48 49 public static final int ERROR_CODE_CONSTRUCTION = 3722; … … 390 391 boolean sortingErrorFound = false; 391 392 for (TestError error : this.errors) { 392 if (error.getCode() == ERROR_CODE_SORTING) { 393 if (error.getCode() == ERROR_CODE_SORTING 394 || error.getCode() == ERROR_CODE_PARTIAL_SORTING) { 393 395 sortingErrorFound = true; 394 396 break; … … 469 471 || testError.getCode() == ERROR_CODE_CONSTRUCTION 470 472 || testError.getCode() == ERROR_CODE_SORTING 473 || testError.getCode() == ERROR_CODE_PARTIAL_SORTING 471 474 || testError.getCode() == ERROR_CODE_END_STOP 472 475 || testError.getCode() == ERROR_CODE_PLATFORM_PART_OF_HIGHWAY) { … … 505 508 } 506 509 507 if (testError.getCode() == ERROR_CODE_SORTING) { 510 if (testError.getCode() == ERROR_CODE_SORTING 511 || testError.getCode() == ERROR_CODE_PARTIAL_SORTING) { 508 512 commands.add(RouteChecker.fixSortingError(testError)); 509 513 } -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/RouteChecker.java
r33082 r33405 43 43 } 44 44 45 45 protected void performSortingTest() { 46 46 47 47 final List<RelationMember> waysToCheck = new ArrayList<>(); … … 57 57 } 58 58 59 if (hasGap(waysToCheck)) { 59 int numOfGaps = countGaps(waysToCheck); 60 61 if (numOfGaps > 0) { 60 62 61 63 this.hasGap = true; … … 64 66 sortedMembers = sorter.sortMembers(waysToCheck); 65 67 66 if (!hasGap(sortedMembers)) { 68 int numOfGapsAfterSort = countGaps(sortedMembers); 69 70 if (numOfGapsAfterSort == 0) { 67 71 Builder builder = TestError.builder(this.test, Severity.WARNING, PTAssistantValidatorTest.ERROR_CODE_SORTING); 68 72 builder.message(tr("PT: Route contains a gap that can be fixed by sorting")); … … 70 74 TestError e = builder.build(); 71 75 this.errors.add(e); 72 76 } else if(numOfGapsAfterSort < numOfGaps) { 77 Builder builder = TestError.builder(this.test, Severity.WARNING, PTAssistantValidatorTest.ERROR_CODE_PARTIAL_SORTING); 78 builder.message(tr("PT: Route gaps can decrease by sorting members. Further validations will be required")); 79 builder.primitives(relation); 80 TestError e = builder.build(); 81 this.errors.add(e); 73 82 } 74 75 83 } 76 77 84 } 78 85 79 86 /** 80 * C hecks ifthereis a gapfor a given list of ways. It does not check if87 * Counts how many gaps there are for a given list of ways. It does not check if 81 88 * the way actually stands for a public transport platform - that should be 82 89 * checked beforehand. … … 86 93 * Relation Editor), false otherwise 87 94 */ 88 private boolean hasGap(List<RelationMember> waysToCheck) { 89 WayConnectionTypeCalculator connectionTypeCalculator = new WayConnectionTypeCalculator(); 95 private int countGaps(List<RelationMember> waysToCheck) { 96 int numberOfGaps = 0; 97 98 WayConnectionTypeCalculator connectionTypeCalculator = new WayConnectionTypeCalculator(); 90 99 final List<WayConnectionType> links = connectionTypeCalculator.updateLinks(waysToCheck); 91 100 for (int i = 0; i < links.size(); i++) { 92 101 final WayConnectionType link = links.get(i); 93 final boolean hasError = !(i == 0 || link.linkPrev) || !(i == links.size() - 1 || link.linkNext) 94 || link.direction == null || WayConnectionType.Direction.NONE.equals(link.direction); 95 if (hasError) { 96 return true; 97 102 if(!(i == 0 || link.linkPrev) || !(i == links.size() - 1 || link.linkNext) 103 || link.direction == null || WayConnectionType.Direction.NONE.equals(link.direction)) { 104 numberOfGaps++; 105 i++; 98 106 } 99 107 } 100 108 101 return false;109 return numberOfGaps; 102 110 } 103 111 … … 115 123 116 124 protected static Command fixSortingError(TestError testError) { 117 if (testError.getCode() != PTAssistantValidatorTest.ERROR_CODE_SORTING) { 125 if (testError.getCode() != PTAssistantValidatorTest.ERROR_CODE_SORTING 126 && testError.getCode() != PTAssistantValidatorTest.ERROR_CODE_PARTIAL_SORTING) { 118 127 return null; 119 128 } … … 129 138 for (RelationMember member : members) { 130 139 if (RouteUtils.isPTWay(member)) { 131 if (member.getRole() .equals("")) {140 if ("".equals(member.getRole())) { 132 141 ways.add(member); 133 142 } else { … … 135 144 ways.add(modifiedMember); 136 145 } 137 138 146 } else { // stops: 139 if (member.getRole() .equals("stop_positon")) {147 if ("stop_positon".equals(member.getRole())) { 140 148 // it is not expected that stop_positions could 141 149 // be relations … … 150 158 stops.add(member); 151 159 } 152 153 160 } 154 161 } … … 169 176 sortedRelation.setMembers(sortedRelationMembers); 170 177 171 ChangeCommand changeCommand = new ChangeCommand(originalRelation, sortedRelation); 172 173 return changeCommand; 174 178 return new ChangeCommand(originalRelation, sortedRelation); 175 179 } 176 177 180 }
Note:
See TracChangeset
for help on using the changeset viewer.