Changeset 16581 in josm for trunk/src/org


Ignore:
Timestamp:
2020-06-08T22:54:33+02:00 (4 years ago)
Author:
simon04
Message:

fix #13082 - SearchCompiler: add members: keyword to search for relations with the specified number of members (patch by naoliv, modified)

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

Legend:

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

    r16553 r16581  
    127127    public static class CoreSimpleMatchFactory implements SimpleMatchFactory {
    128128        private final Collection<String> keywords = Arrays.asList("id", "version", "type", "user", "role",
    129                 "changeset", "nodes", "ways", "tags", "areasize", "waylength", "modified", "deleted", "selected",
     129                "changeset", "nodes", "ways", "members", "tags", "areasize", "waylength", "modified", "deleted", "selected",
    130130                "incomplete", "untagged", "closed", "new", "indownloadedarea",
    131131                "allindownloadedarea", "timestamp", "nth", "nth%", "hasRole", "preset");
     
    173173                    case "ways":
    174174                        return new WayCountRange(tokenizer);
     175                    case "members":
     176                        return new MemberCountRange(tokenizer);
    175177                    case "tags":
    176178                        return new TagCountRange(tokenizer);
     
    14351437    }
    14361438
     1439    /*
     1440     * Matches relations with a certain number of members
     1441     */
     1442    private static class MemberCountRange extends RangeMatch {
     1443        MemberCountRange(Range range) {
     1444            super(range);
     1445        }
     1446
     1447        MemberCountRange(PushbackTokenizer tokenizer) throws SearchParseError {
     1448            this(tokenizer.readRange(tr("Range of numbers expected")));
     1449        }
     1450
     1451        @Override
     1452        protected Long getNumber(OsmPrimitive osm) {
     1453            if (osm instanceof Relation) {
     1454                Relation r = (Relation) osm;
     1455                return (long) r.getMembersCount();
     1456            } else {
     1457                return null;
     1458            }
     1459        }
     1460
     1461        @Override
     1462        protected String getString() {
     1463            return "members";
     1464        }
     1465    }
     1466
    14371467    /**
    14381468     * Matches objects with a number of tags in given range
  • trunk/src/org/openstreetmap/josm/gui/dialogs/SearchDialog.java

    r16354 r16581  
    383383                .addKeyword("ways:<i>3-</i>", "ways:", tr("nodes with at least 3 referring ways, or relations containing at least 3 ways"))
    384384                .addKeyword("tags:<i>5-10</i>", "tags:", tr("objects having 5 to 10 tags"))
    385                 .addKeyword("role:", "role:", tr("objects with given role in a relation"))
     385                .addKeyword("members:<i>2</i>", "members:", tr("relations with 2 members"))
    386386                .addKeyword("areasize:<i>-100</i>", "areasize:", tr("closed ways with an area of 100 m\u00b2"))
    387387                .addKeyword("waylength:<i>200-</i>", "waylength:", tr("ways with a length of 200 m or more")),
     
    399399                .addKeyword("child <i>expr</i>", "child ", tr("all children of objects matching the expression"), "child building")
    400400                .addKeyword("parent <i>expr</i>", "parent ", tr("all parents of objects matching the expression"), "parent bus_stop")
     401                .addKeyword("role:", "role:", tr("objects with given role in a relation"))
    401402                .addKeyword("hasRole:<i>stop</i>", "hasRole:", tr("relation containing a member of role <i>stop</i>"))
    402403                .addKeyword("role:<i>stop</i>", "role:", tr("objects being part of a relation as role <i>stop</i>"))
Note: See TracChangeset for help on using the changeset viewer.