Changeset 2357 in josm
- Timestamp:
- 2009-10-31T09:20:00+01:00 (15 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
r2264 r2357 112 112 + "<li>"+tr("<b>id:</b>... - object with given ID (0 for new objects)")+"</li>" 113 113 + "<li>"+tr("<b>nodes:</b>... - object with given number of nodes")+"</li>" 114 + "<li>"+tr("<b>tags:</b>... - object with given number of tags (tags:count or tags:min-max)")+"</li>" 114 115 + "<li>"+tr("<b>modified</b> - all changed objects")+"</li>" 115 116 + "<li>"+tr("<b>selected</b> - all selected objects")+"</li>" -
trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java
r2291 r2357 415 415 } 416 416 417 private static class TagCount extends Match { 418 private int count; 419 public TagCount(int count) {this.count = count;} 420 @Override public boolean match(OsmPrimitive osm) { 421 int size = osm.getKeys().size(); 422 return size == count; 423 } 424 @Override public String toString() {return "tags="+count;} 425 } 426 427 private static class TagCountRange extends Match { 428 private int minCount; 429 private int maxCount; 430 public TagCountRange(int minCount, int maxCount) { 431 if(maxCount < minCount) { 432 this.minCount = maxCount; 433 this.maxCount = minCount; 434 } else { 435 this.minCount = minCount; 436 this.maxCount = maxCount; 437 } 438 } 439 @Override public boolean match(OsmPrimitive osm) { 440 int size = osm.getKeys().size(); 441 return (size >= minCount) && (size <= maxCount); 442 } 443 @Override public String toString() {return "tags="+minCount+"-"+maxCount;} 444 } 445 417 446 private static class Modified extends Match { 418 447 @Override public boolean match(OsmPrimitive osm) { … … 610 639 else if (key.equals("user")) 611 640 return new UserMatch(value); 641 else if (key.equals("tags")) 642 try { 643 String[] range = value.split("-"); 644 if (range.length == 1) 645 return new TagCount(Integer.parseInt(value)); 646 else if (range.length == 2) 647 return new TagCountRange(Integer.parseInt(range[0]), Integer.parseInt(range[1])); 648 else 649 throw new ParseError(tr("Wrong number of parameters for tags operator.")); 650 } catch (NumberFormatException e) { 651 throw new ParseError(tr("Incorrect value of tags operator: {0}. Tags operator expects number of tags or range, for example tags:1 or tags:2-5", value)); 652 } 612 653 else if (key.equals("nodes")) { 613 654 try {
Note:
See TracChangeset
for help on using the changeset viewer.