Changeset 4346 in josm for trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java
- Timestamp:
- 2011-08-26T22:35:14+02:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java
r4089 r4346 509 509 } 510 510 511 private static class NodeCountRange extends Match { 511 private abstract static class CountRange extends Match { 512 512 513 private int minCount; 513 514 private int maxCount; 515 516 public CountRange(int minCount, int maxCount) { 517 this.minCount = Math.min(minCount, maxCount); 518 this.maxCount = Math.max(minCount, maxCount); 519 } 520 521 protected abstract Integer getCount(OsmPrimitive osm); 522 523 protected abstract String getCountString(); 524 525 @Override 526 public boolean match(OsmPrimitive osm) { 527 Integer count = getCount(osm); 528 if (count == null) { 529 return false; 530 } else { 531 return (count >= minCount) && (count <= maxCount); 532 } 533 } 534 535 @Override 536 public String toString() { 537 return getCountString() + "=" + minCount + "-" + maxCount; 538 } 539 } 540 541 542 543 private static class NodeCountRange extends CountRange { 544 514 545 public NodeCountRange(int minCount, int maxCount) { 515 if(maxCount < minCount) { 516 this.minCount = maxCount; 517 this.maxCount = minCount; 518 } else { 519 this.minCount = minCount; 520 this.maxCount = maxCount; 521 } 522 } 523 @Override public boolean match(OsmPrimitive osm) { 524 if(!(osm instanceof Way)) return false; 525 int size = ((Way)osm).getNodesCount(); 526 return (size >= minCount) && (size <= maxCount); 527 } 528 @Override public String toString() {return "nodes="+minCount+"-"+maxCount;} 529 } 530 531 private static class TagCountRange extends Match { 532 private int minCount; 533 private int maxCount; 546 super(minCount, maxCount); 547 } 548 549 @Override 550 protected Integer getCount(OsmPrimitive osm) { 551 if (!(osm instanceof Way)) { 552 return null; 553 } else { 554 return ((Way) osm).getNodesCount(); 555 } 556 } 557 558 @Override 559 protected String getCountString() { 560 return "nodes"; 561 } 562 } 563 564 private static class TagCountRange extends CountRange { 565 534 566 public TagCountRange(int minCount, int maxCount) { 535 if(maxCount < minCount) { 536 this.minCount = maxCount; 537 this.maxCount = minCount; 538 } else { 539 this.minCount = minCount; 540 this.maxCount = maxCount; 541 } 542 } 543 @Override public boolean match(OsmPrimitive osm) { 544 int size = osm.getKeys().size(); 545 return (size >= minCount) && (size <= maxCount); 546 } 547 @Override public String toString() {return "tags="+minCount+"-"+maxCount;} 567 super(minCount, maxCount); 568 } 569 570 @Override 571 protected Integer getCount(OsmPrimitive osm) { 572 return osm.getKeys().size(); 573 } 574 575 @Override 576 protected String getCountString() { 577 return "tags"; 578 } 548 579 } 549 580 … … 637 668 * @author Ole Jørgen Brønner 638 669 */ 639 private static class Area extends Match{640 private int min, max; 641 642 public Area(int min, int max) {643 this.min = min;644 this.max = max; 645 if (min == max) {646 this.min = 0;647 }648 }649 650 @Override651 public boolean match(OsmPrimitive osm) {652 if(!(osm instanceof Way && ((Way) osm).isClosed()))653 return false; 654 Way way = (Way)osm;655 double area = Geometry.closedWayArea(way);656 return (min <= area && area <= max);670 private static class Area extends CountRange { 671 672 public Area(int minCount, int maxCount) { 673 super(minCount, maxCount); 674 } 675 676 @Override 677 protected Integer getCount(OsmPrimitive osm) { 678 if (!(osm instanceof Way && ((Way) osm).isClosed())) { 679 return null; 680 } 681 Way way = (Way) osm; 682 return (int) Geometry.closedWayArea(way); 683 } 684 685 @Override 686 protected String getCountString() { 687 return "area"; 657 688 } 658 689 }
Note:
See TracChangeset
for help on using the changeset viewer.