Changeset 15196 in josm for trunk/src


Ignore:
Timestamp:
2019-06-29T23:07:03+02:00 (6 years ago)
Author:
Don-vip
Message:

fix #17845 - Add a MapCSS method to check for roles in relations (patch by taylor.smock)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java

    r14802 r15196  
    2929import org.openstreetmap.josm.data.osm.Node;
    3030import org.openstreetmap.josm.data.osm.OsmPrimitive;
     31import org.openstreetmap.josm.data.osm.Relation;
     32import org.openstreetmap.josm.data.osm.RelationMember;
    3133import org.openstreetmap.josm.data.osm.Way;
    3234import org.openstreetmap.josm.data.osm.search.SearchCompiler;
     
    571573
    572574        /**
     575         * Returns true if role is in relation. Returns false if not a relation or it does not have the role.
     576         * @param env the environment
     577         * @param roles The roles to count in the relation
     578         * @return The number of relation members with the specified role
     579         * @since 15196
     580         */
     581        public static int count_roles(final Environment env, String... roles) { // NO_UCD (unused code)
     582            int rValue = 0;
     583            if (env.osm instanceof Relation) {
     584                List<String> roleList = Arrays.asList(roles);
     585                Relation rel = (Relation) env.osm;
     586                for (RelationMember member : rel.getMembers()) {
     587                    if (roleList.contains(member.getRole())) rValue++;
     588                }
     589            }
     590            return rValue;
     591        }
     592
     593        /**
    573594         * Returns the area of a closed way or multipolygon in square meters or {@code null}.
    574595         * @param env the environment
Note: See TracChangeset for help on using the changeset viewer.