Changeset 10141 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/PublicTransportRouteTest.java
r9937 r10141 5 5 6 6 import java.util.ArrayList; 7 import java.util.Arrays; 8 import java.util.HashSet; 7 9 import java.util.List; 10 import java.util.Set; 8 11 12 import org.openstreetmap.josm.data.osm.Node; 13 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 9 14 import org.openstreetmap.josm.data.osm.Relation; 10 15 import org.openstreetmap.josm.data.osm.RelationMember; … … 40 45 41 46 final List<RelationMember> membersToCheck = new ArrayList<>(); 47 final Set<Node> routeNodes = new HashSet<>(); 42 48 for (RelationMember member : r.getMembers()) { 43 49 if (member.hasRole("forward", "backward")) { 44 50 errors.add(new TestError(this, Severity.WARNING, tr("Route relation contains a ''{0}'' role", "forward/backward"), 3601, r)); 45 51 return; 46 } else if (member.hasRole("")) { 52 } else if (member.hasRole("") && OsmPrimitiveType.WAY.equals(member.getType())) { 47 53 membersToCheck.add(member); 54 routeNodes.addAll(member.getWay().getNodes()); 48 55 } 49 56 } … … 65 72 } 66 73 74 for (RelationMember member : r.getMembers()) { 75 if (member.hasRole("stop", "stop_exit_only", "stop_entry_only") 76 && OsmPrimitiveType.NODE.equals(member.getType()) 77 && !routeNodes.contains(member.getNode())) { 78 errors.add(new TestError(this, Severity.WARNING, tr("Stop position not part of route"), 3603, Arrays.asList(member.getMember(), r))); 79 } 80 } 81 67 82 } 68 83 } -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/PublicTransportRouteTestTest.java
r9933 r10141 67 67 assertEquals("Route relation contains a gap", test.getErrors().get(0).getMessage()); 68 68 69 final Relation r5 = TestUtils.newRelation("type=route route=tram public_transport:version=2", 70 new RelationMember("", w1), new RelationMember("", w2), new RelationMember("", w3), 71 new RelationMember("stop", w1.firstNode()), new RelationMember("stop", w4.lastNode())); 72 test.startTest(null); 73 test.visit(r5); 74 assertEquals(1, test.getErrors().size()); 75 assertEquals("Stop position not part of route", test.getErrors().get(0).getMessage()); 76 assertEquals(w4.lastNode(), test.getErrors().get(0).getPrimitives().iterator().next()); 77 69 78 } 70 79 }
Note:
See TracChangeset
for help on using the changeset viewer.