Ignore:
Timestamp:
2017-04-25T19:33:21+02:00 (7 years ago)
Author:
stoecker
Message:

fix #14692 - relatation checker test broken

File:
1 edited

Legend:

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

    r11998 r12002  
    88import java.util.EnumSet;
    99import java.util.HashMap;
     10import java.util.LinkedHashMap;
    1011import java.util.LinkedList;
    1112import java.util.List;
     
    101102    @Override
    102103    public void visit(Relation n) {
    103         List<Role> allroles = buildAllRoles(n);
     104        Map<Role, String> allroles = buildAllRoles(n);
    104105        if (allroles.isEmpty() && n.hasTag("type", "route")
    105106                && n.hasTag("route", "train", "subway", "monorail", "tram", "bus", "trolleybus", "aerialway", "ferry")) {
     
    141142
    142143    // return Roles grouped by key
    143     private static List<Role> buildAllRoles(Relation n) {
    144         List<Role> allroles = new LinkedList<>();
     144    private static Map<Role, String> buildAllRoles(Relation n) {
     145        Map<Role, String> allroles = new LinkedHashMap<>();
    145146
    146147        for (TaggingPreset p : relationpresets) {
     
    148149            final Roles r = Utils.find(p.data, Roles.class);
    149150            if (matches && r != null) {
    150                 allroles.addAll(r.roles);
     151                for (Role role: r.roles) {
     152                    allroles.put(role, p.name);
     153                }
    151154            }
    152155        }
     
    185188     *
    186189     */
    187     private boolean checkMemberExpressionAndType(List<Role> allroles, RelationMember member, Relation n) {
     190    private boolean checkMemberExpressionAndType(Map<Role, String> allroles, RelationMember member, Relation n) {
    188191        String role = member.getRole();
    189192        String name = null;
     
    193196        // iterate through all of the role definition within preset
    194197        // and look for any matching definition
    195         for (Role r: allroles) {
     198        for (Map.Entry<Role, String> e : allroles.entrySet()) {
     199            Role r = e.getKey();
    196200            if (!r.isRole(role)) {
    197201                continue;
    198202            }
    199             name = r.key;
     203            name = e.getValue();
    200204            types.addAll(r.types);
    201205            if (checkMemberType(r, member)) {
     
    266270     * @param map contains statistics of occurances of specified role types in relation
    267271     */
    268     private void checkRoles(Relation n, List<Role> allroles, Map<String, RoleInfo> map) {
     272    private void checkRoles(Relation n, Map<Role, String> allroles, Map<String, RoleInfo> map) {
    269273        // go through all members of relation
    270274        for (RelationMember member: n.getMembers()) {
     
    274278
    275279        // verify role counts based on whole role sets
    276         for (Role r: allroles) {
     280        for (Role r: allroles.keySet()) {
    277281            String keyname = r.key;
    278282            if (keyname.isEmpty()) {
     
    287291        for (String key : map.keySet()) {
    288292            boolean found = false;
    289             for (Role r: allroles) {
     293            for (Role r: allroles.keySet()) {
    290294                if (r.isRole(key)) {
    291295                    found = true;
     
    295299
    296300            if (!found) {
    297                 String templates = allroles.stream().map(r -> r.key).collect(Collectors.joining("/"));
     301                String templates = allroles.keySet().stream().map(r -> r.key).collect(Collectors.joining("/"));
    298302
    299303                if (!key.isEmpty()) {
Note: See TracChangeset for help on using the changeset viewer.