Changeset 10141 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2016-04-11T22:06:50+02:00 (9 years ago)
Author:
simon04
Message:

Validate that stop position lies on public transport route

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/PublicTransportRouteTest.java

    r9937 r10141  
    55
    66import java.util.ArrayList;
     7import java.util.Arrays;
     8import java.util.HashSet;
    79import java.util.List;
     10import java.util.Set;
    811
     12import org.openstreetmap.josm.data.osm.Node;
     13import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    914import org.openstreetmap.josm.data.osm.Relation;
    1015import org.openstreetmap.josm.data.osm.RelationMember;
     
    4045
    4146        final List<RelationMember> membersToCheck = new ArrayList<>();
     47        final Set<Node> routeNodes = new HashSet<>();
    4248        for (RelationMember member : r.getMembers()) {
    4349            if (member.hasRole("forward", "backward")) {
    4450                errors.add(new TestError(this, Severity.WARNING, tr("Route relation contains a ''{0}'' role", "forward/backward"), 3601, r));
    4551                return;
    46             } else if (member.hasRole("")) {
     52            } else if (member.hasRole("") && OsmPrimitiveType.WAY.equals(member.getType())) {
    4753                membersToCheck.add(member);
     54                routeNodes.addAll(member.getWay().getNodes());
    4855            }
    4956        }
     
    6572        }
    6673
     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
    6782    }
    6883}
Note: See TracChangeset for help on using the changeset viewer.