Changeset 8250 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2015-04-23T18:59:15+02:00 (10 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
r8220 r8250 397 397 .addKeyword("child <i>expr</i>", "child ", tr("all children of objects matching the expression"), "child building") 398 398 .addKeyword("parent <i>expr</i>", "parent ", tr("all parents of objects matching the expression"), "parent bus_stop") 399 .addKeyword("nth:<i>7</i>", "nth: ", tr("n-th member of relation and/or n-th node of way"), "nth:5 (child type:relation)" )399 .addKeyword("nth:<i>7</i>", "nth: ", tr("n-th member of relation and/or n-th node of way"), "nth:5 (child type:relation)", "nth:-1") 400 400 .addKeyword("nth%:<i>7</i>", "nth%: ", tr("every n-th member of relation and/or every n-th node of way"), "nth%:100 (child waterway)") 401 401 , GBC.eol()); -
trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java
r8231 r8250 846 846 847 847 private Nth(int nth, boolean modulo) throws ParseError { 848 if (nth <= 0) {849 throw new ParseError(tr("Positive integer expected"));850 }851 848 this.nth = nth; 852 849 this.modulo = modulo; … … 856 853 public boolean match(OsmPrimitive osm) { 857 854 for (OsmPrimitive p : osm.getReferrers()) { 858 Integer idx = null; 855 final int idx; 856 final int maxIndex; 859 857 if (p instanceof Way) { 860 858 Way w = (Way) p; 861 859 idx = w.getNodes().indexOf(osm); 860 maxIndex = w.getNodesCount(); 862 861 } else if (p instanceof Relation) { 863 862 Relation r = (Relation) p; 864 863 idx = r.getMemberPrimitivesList().indexOf(osm); 865 } 866 if (idx != null) { 867 if (idx.intValue() == nth || (modulo && idx.intValue() % nth == 0)) { 868 return true; 869 } 870 } 864 maxIndex = r.getMembersCount(); 865 } else { 866 continue; 867 } 868 if (nth < 0 && idx - maxIndex == nth) { 869 return true; 870 } else if (idx == nth || (modulo && idx % nth == 0)) 871 return true; 871 872 } 872 873 return false; 874 } 875 876 @Override 877 public String toString() { 878 return "Nth{nth=" + nth + ", modulo=" + modulo + '}'; 873 879 } 874 880 }
Note:
See TracChangeset
for help on using the changeset viewer.