Changeset 33467 in osm for applications/editors/josm/plugins/pt_assistant/src
- Timestamp:
- 2017-07-24T23:24:26+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
r33465 r33467 45 45 46 46 public static final int ERROR_CODE_FROM_TO_ROUTE_TAG = 3701; 47 public static final int ERROR_CODE_FIRST_LAST_STOP_WAY_TAG = 3702; 47 48 public static final int ERROR_CODE_SORTING = 3711; 48 49 public static final int ERROR_CODE_PARTIAL_SORTING = 3712; … … 355 356 routeChecker.setManager(manager); 356 357 routeChecker.setAssigner(assigner); 357 routeChecker.performFromToTagsTest(); 358 if (!routeChecker.performFromToTagsTest()) { 359 routeChecker.performFirstLastWayStopTest(); 360 } 358 361 routeChecker.performSortingTest(); 359 362 List<TestError> routeCheckerErrors = routeChecker.getErrors(); -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/RouteChecker.java
r33465 r33467 5 5 6 6 import java.util.ArrayList; 7 import java.util.Arrays; 7 8 import java.util.Collection; 8 9 import java.util.List; … … 14 15 import org.openstreetmap.josm.data.osm.Relation; 15 16 import org.openstreetmap.josm.data.osm.RelationMember; 17 import org.openstreetmap.josm.data.osm.Way; 16 18 import org.openstreetmap.josm.data.validation.Severity; 17 19 import org.openstreetmap.josm.data.validation.Test; … … 52 54 } 53 55 56 //checks if sorting the members of the current relation could make it 57 //continuous or it could reduce the number of gaps. if one of the previous 58 //is true raises a warning 54 59 protected void performSortingTest() { 55 60 … … 93 98 } 94 99 95 protected void performFromToTagsTest() { 100 //checks if the from and to tags of the route match the names of the first 101 //and last stops 102 protected boolean performFromToTagsTest() { 96 103 97 104 String from = relation.get("from"); 98 105 String to = relation.get("to"); 99 106 if (from == null || to == null || manager.getPTStopCount() == 0) { 100 return; 101 } 102 107 return false; 108 } 109 110 boolean foundError = false; 103 111 PTStop stop = manager.getFirstStop(); 104 112 OsmPrimitive primitive = checkPTStopName(stop, from); … … 108 116 PTAssistantValidatorTest.ERROR_CODE_FROM_TO_ROUTE_TAG); 109 117 builder.message(tr("PT: The name of the first stop does not match the \"from\" tag of the route relation")); 110 builder.primitives(primitive); 118 builder.primitives(primitive, relation); 111 119 TestError e = builder.build(); 112 120 this.errors.add(e); 121 foundError = true; 113 122 } 114 123 … … 120 129 PTAssistantValidatorTest.ERROR_CODE_FROM_TO_ROUTE_TAG); 121 130 builder.message(tr("PT: The name of the last stop does not match the \"to\" tag of the route relation")); 122 builder.primitives(primitive); 131 builder.primitives(primitive, relation); 132 TestError e = builder.build(); 133 this.errors.add(e); 134 foundError = true; 135 } 136 137 return foundError; 138 } 139 140 //checks if the first and last stop are assigned to the first and last way 141 protected void performFirstLastWayStopTest() { 142 143 if (manager.getPTStopCount() == 0 || manager.getPTWayCount() == 0) { 144 return; 145 } 146 147 PTStop stop = manager.getFirstStop(); 148 Way way = manager.getFirstWay(); 149 if (!way.equals(assigner.get(stop))) { 150 Builder builder = TestError.builder(this.test, Severity.WARNING, 151 PTAssistantValidatorTest.ERROR_CODE_FIRST_LAST_STOP_WAY_TAG); 152 builder.message(tr("PT: The first stop of the route does not match the first way")); 153 List<OsmPrimitive> prims = new ArrayList<>(Arrays.asList(way, relation)); 154 if (stop.getPlatform() != null) 155 prims.add(stop.getPlatform()); 156 if (stop.getStopPosition() != null) 157 prims.add(stop.getStopPosition()); 158 builder.primitives(prims); 159 TestError e = builder.build(); 160 this.errors.add(e); 161 } 162 163 stop = manager.getLastStop(); 164 way = manager.getLastWay(); 165 if (!way.equals(assigner.get(stop))) { 166 Builder builder = TestError.builder(this.test, Severity.WARNING, 167 PTAssistantValidatorTest.ERROR_CODE_FIRST_LAST_STOP_WAY_TAG); 168 builder.message(tr("PT: The last stop of the route does not match the last way")); 169 List<OsmPrimitive> prims = new ArrayList<>(Arrays.asList(way, relation)); 170 if (stop.getPlatform() != null) 171 prims.add(stop.getPlatform()); 172 if (stop.getStopPosition() != null) 173 prims.add(stop.getStopPosition()); 174 builder.primitives(prims); 123 175 TestError e = builder.build(); 124 176 this.errors.add(e); … … 147 199 } 148 200 201 /** 202 * Checks whether there is at least one gap in the given list of ways. 203 * 204 * @param waysToCheck ways to check 205 * @return true if has gap (in the sense of continuity of ways in the 206 * Relation Editor), false otherwise 207 */ 149 208 public boolean hasGaps(List<RelationMember> waysToCheck) { 150 209 return countGaps(waysToCheck) > 0; … … 157 216 * 158 217 * @param waysToCheck ways to check 159 * @return true if has gap (in the sense of continuity of ways in the 160 * Relation Editor), false otherwise 218 * @return number of gaps 161 219 */ 162 220 private int countGaps(List<RelationMember> waysToCheck) {
Note:
See TracChangeset
for help on using the changeset viewer.