Changeset 33465 in osm for applications/editors/josm
- Timestamp:
- 2017-07-24T22:23:18+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
r33464 r33465 44 44 public class PTAssistantValidatorTest extends Test { 45 45 46 public static final int ERROR_CODE_FROM_TO_ROUTE_TAG = 3701; 46 47 public static final int ERROR_CODE_SORTING = 3711; 47 48 public static final int ERROR_CODE_PARTIAL_SORTING = 3712; … … 352 353 // Check if the relation is correct, or only has a wrong sorting order: 353 354 RouteChecker routeChecker = new RouteChecker(r, this); 355 routeChecker.setManager(manager); 356 routeChecker.setAssigner(assigner); 357 routeChecker.performFromToTagsTest(); 354 358 routeChecker.performSortingTest(); 355 359 List<TestError> routeCheckerErrors = routeChecker.getErrors(); -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/RouteChecker.java
r33432 r33465 21 21 import org.openstreetmap.josm.gui.dialogs.relation.sort.WayConnectionType; 22 22 import org.openstreetmap.josm.gui.dialogs.relation.sort.WayConnectionTypeCalculator; 23 import org.openstreetmap.josm.plugins.pt_assistant.data.PTRouteDataManager; 24 import org.openstreetmap.josm.plugins.pt_assistant.data.PTStop; 23 25 import org.openstreetmap.josm.plugins.pt_assistant.utils.RouteUtils; 26 import org.openstreetmap.josm.plugins.pt_assistant.utils.StopToWayAssigner; 24 27 25 28 /** … … 35 38 List<RelationMember> sortedMembers; 36 39 40 /* Manager of the PTStops and PTWays of the current route */ 41 private PTRouteDataManager manager; 42 43 /* Assigns PTStops to nearest PTWays and stores that correspondence */ 44 private StopToWayAssigner assigner; 45 37 46 public RouteChecker(Relation relation, Test test) { 38 47 … … 43 52 } 44 53 45 protected void performSortingTest() {54 protected void performSortingTest() { 46 55 47 56 final List<RelationMember> waysToCheck = new ArrayList<>(); … … 82 91 } 83 92 } 93 } 94 95 protected void performFromToTagsTest() { 96 97 String from = relation.get("from"); 98 String to = relation.get("to"); 99 if (from == null || to == null || manager.getPTStopCount() == 0) { 100 return; 101 } 102 103 PTStop stop = manager.getFirstStop(); 104 OsmPrimitive primitive = checkPTStopName(stop, from); 105 106 if (primitive != null) { 107 Builder builder = TestError.builder(this.test, Severity.WARNING, 108 PTAssistantValidatorTest.ERROR_CODE_FROM_TO_ROUTE_TAG); 109 builder.message(tr("PT: The name of the first stop does not match the \"from\" tag of the route relation")); 110 builder.primitives(primitive); 111 TestError e = builder.build(); 112 this.errors.add(e); 113 } 114 115 stop = manager.getLastStop(); 116 primitive = checkPTStopName(stop, to); 117 118 if (primitive != null) { 119 Builder builder = TestError.builder(this.test, Severity.WARNING, 120 PTAssistantValidatorTest.ERROR_CODE_FROM_TO_ROUTE_TAG); 121 builder.message(tr("PT: The name of the last stop does not match the \"to\" tag of the route relation")); 122 builder.primitives(primitive); 123 TestError e = builder.build(); 124 this.errors.add(e); 125 } 126 } 127 128 //given a PTStop and a name, check whether one of its primitives have a 129 //different name from the one passed. if so, it returns the primitive. 130 //it returns null if the names match 131 private OsmPrimitive checkPTStopName(PTStop stop, String name) { 132 OsmPrimitive primitive = null; 133 String toCheck = null; 134 if (stop.getPlatform() != null) { 135 toCheck = stop.getPlatform().getName(); 136 primitive = stop.getPlatform(); 137 } 138 if (toCheck == null && stop.getStopPosition() != null) { 139 toCheck = stop.getStopPosition().getName(); 140 primitive = stop.getStopPosition(); 141 } 142 143 if (toCheck != null && !toCheck.equals(name)) 144 return primitive; 145 146 return null; 84 147 } 85 148 … … 185 248 return new ChangeCommand(originalRelation, sortedRelation); 186 249 } 250 251 public PTRouteDataManager getManager() { 252 return manager; 253 } 254 255 public void setManager(PTRouteDataManager manager) { 256 this.manager = manager; 257 } 258 259 public StopToWayAssigner getAssigner() { 260 return assigner; 261 } 262 263 public void setAssigner(StopToWayAssigner assigner) { 264 this.assigner = assigner; 265 } 187 266 }
Note:
See TracChangeset
for help on using the changeset viewer.