- Timestamp:
- 2015-10-18T13:31:21+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/actions/search
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java
r8884 r8896 420 420 .addKeyword("parent <i>expr</i>", "parent ", tr("all parents of objects matching the expression"), "parent bus_stop") 421 421 .addKeyword("hasRole:<i>stop</i>", "hasRole:", tr("relation containing a member of role <i>stop</i>")) 422 .addKeyword(" isRole:<i>stop</i>", "isRole:", tr("objects being part of a relation as role <i>stop</i>"))422 .addKeyword("role:<i>stop</i>", "role:", tr("objects being part of a relation as role <i>stop</i>")) 423 423 .addKeyword("nth:<i>7</i>", "nth:", 424 424 tr("n-th member of relation and/or n-th node of way"), "nth:5 (child type:relation)", "nth:-1") -
trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java
r8884 r8896 159 159 case "hasRole": 160 160 return new HasRole(tokenizer); 161 case "isRole":162 return new IsRole(tokenizer);163 161 case "timestamp": 164 162 // add leading/trailing space in order to get expected split (e.g. "a--" => {"a", ""}) … … 1144 1142 public boolean match(OsmPrimitive osm) { 1145 1143 return osm instanceof Relation && ((Relation) osm).getMemberRoles().contains(role); 1146 }1147 }1148 1149 /**1150 * Matches object which are part of a relation with the given role1151 */1152 private static class IsRole extends Match {1153 private final String role;1154 1155 IsRole(PushbackTokenizer tokenizer) {1156 role = tokenizer.readTextOrNumber();1157 }1158 1159 @Override1160 public boolean match(final OsmPrimitive osm) {1161 for (final OsmPrimitive ref : osm.getReferrers()) {1162 if (ref instanceof Relation && Utils.exists(((Relation) ref).getMembers(), new Predicate<RelationMember>() {1163 @Override1164 public boolean evaluate(RelationMember object) {1165 return osm.equals(object.getMember()) && role.equals(object.getRole());1166 }1167 })) {1168 return true;1169 }1170 }1171 return false;1172 1144 } 1173 1145 }
Note:
See TracChangeset
for help on using the changeset viewer.