Changeset 6305 in josm


Ignore:
Timestamp:
2013-10-06T22:07:36+02:00 (10 years ago)
Author:
Don-vip
Message:

fix #9093 - teach validator about "subarea" and "land_area" roles of administrative boundary relations

Location:
trunk/src/org/openstreetmap/josm/data
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/RelationMember.java

    r6084 r6305  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.data.osm;
     3
     4import java.util.Arrays;
    35
    46/**
     
    2123
    2224    /**
    23      *
     25     * Returns the role of this relation member.
    2426     * @return Role name or "". Never returns null
    2527     * @since 1930
     
    3032
    3133    /**
    32      *
     34     * Determines if this relation member has a role.
    3335     * @return True if role is set
    3436     * @since 1930
     
    3941
    4042    /**
    41      *
     43     * Determines if this relation member's role is in the given list.
     44     * @param roles The roles to look after
     45     * @return True if role is in the given list
     46     * @since 6305
     47     */
     48    public boolean hasRole(String ... roles) {
     49        return Arrays.asList(roles).contains(role);
     50    }
     51
     52    /**
     53     * Determines if this relation member is a relation.
    4254     * @return True if member is relation
    4355     * @since 1937
     
    4860
    4961    /**
    50      *
     62     * Determines if this relation member is a way.
    5163     * @return True if member is way
    5264     * @since 1937
     
    6678
    6779    /**
    68      *
     80     * Determines if this relation member is a node.
    6981     * @return True if member is node
    7082     * @since 1937
     
    7587
    7688    /**
    77      *
     89     * Returns the relation member as a relation.
    7890     * @return Member as relation
    7991     * @since 1937
     
    8496
    8597    /**
    86      *
     98     * Returns the relation member as a way.
    8799     * @return Member as way
    88100     * @since 1937
     
    93105
    94106    /**
    95      *
     107     * Returns the relation member as a node.
    96108     * @return Member as node
    97109     * @since 1937
     
    102114
    103115    /**
    104      *
     116     * Returns the relation member.
    105117     * @return Member. Returned value is never null.
    106118     * @since 1937
     
    111123
    112124    /**
    113      *
     125     * Constructs a new {@code RelationMember}.
    114126     * @param role Can be null, in this case it's save as ""
    115127     * @param member Cannot be null
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MultipolygonTest.java

    r6240 r6305  
    248248        for (RelationMember rm : r.getMembers()) {
    249249            if (rm.isWay()) {
    250                 if (!("inner".equals(rm.getRole()) || "outer".equals(rm.getRole()) || !rm.hasRole())) {
     250                if (!(rm.hasRole("inner", "outer") || !rm.hasRole())) {
    251251                    addError(r, new TestError(this, Severity.WARNING, tr("No useful role for multipolygon member"), WRONG_MEMBER_ROLE, rm.getMember()));
    252252                }
    253253            } else {
    254                 if(!"admin_centre".equals(rm.getRole()) && !"label".equals(rm.getRole()))
     254                if (!rm.hasRole("admin_centre", "label", "subarea", "land_area")) {
    255255                    addError(r, new TestError(this, Severity.WARNING, tr("Non-Way in multipolygon"), WRONG_MEMBER_TYPE, rm.getMember()));
     256                }
    256257            }
    257258        }
Note: See TracChangeset for help on using the changeset viewer.