Changeset 1389 in josm for trunk/src


Ignore:
Timestamp:
2009-02-09T16:53:53+01:00 (15 years ago)
Author:
stoecker
Message:

close #2132. patch by xeen

File:
1 edited

Legend:

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

    r1375 r1389  
    270270        }
    271271        @Override public String toString() {return "nodes="+count;}
     272    }
     273   
     274    private static class NodeCountRange extends Match {
     275        private int minCount;
     276        private int maxCount;
     277        public NodeCountRange(int minCount, int maxCount) {
     278            if(maxCount < minCount) {
     279                this.minCount = maxCount;
     280                this.maxCount = minCount;
     281            } else {
     282                this.minCount = minCount;
     283                this.maxCount = maxCount;
     284            }
     285        }
     286        @Override public boolean match(OsmPrimitive osm) {
     287            if(!(osm instanceof Way)) return false;
     288            int size = ((Way)osm).nodes.size();
     289            return (size >= minCount) && (size <= maxCount);
     290        }
     291        @Override public String toString() {return "nodes="+minCount+"-"+maxCount;}
    272292    }
    273293
     
    398418            return new UserMatch(value);
    399419        } else if (key.equals("nodes")) {
    400             return new NodeCount(Integer.parseInt(value));
     420            try {
     421                return new NodeCount(Integer.parseInt(value));
     422            } catch(Exception x) {}
     423       
     424            try {
     425                String[] range = value.split("-", 2);
     426                return new NodeCountRange(Integer.parseInt(range[0]), Integer.parseInt(range[1]));
     427            } catch(Exception x) {}
     428           
     429            return new NodeCount(0);
    401430        } else if (key.equals("id")) {
    402431            try {
Note: See TracChangeset for help on using the changeset viewer.