Changeset 8198 in josm for trunk/src/org


Ignore:
Timestamp:
2015-04-15T22:31:53+02:00 (10 years ago)
Author:
simon04
Message:

fix #11343 - Search: add waylength keyword to test the length of ways in meters

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

Legend:

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

    r8131 r8198  
    435435                .addKeyword("role:", "role:", tr("objects with given role in a relation"))
    436436                .addKeyword("areasize:<i>-100</i>", "areasize:", tr("closed ways with an area of 100 m\u00b2"))
     437                .addKeyword("waylength:<i>200-</i>", "waylength:", tr("ways with a length of 200 m or more"))
    437438                , GBC.eol());
    438439            right.add(new SearchKeywordRow(hcbSearchString)
  • trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java

    r7509 r8198  
    9999    public class CoreSimpleMatchFactory implements SimpleMatchFactory {
    100100        private Collection<String> keywords = Arrays.asList("id", "version",
    101                 "changeset", "nodes", "tags", "areasize", "modified", "selected",
     101                "changeset", "nodes", "tags", "areasize", "waylength", "modified", "selected",
    102102                "incomplete", "untagged", "closed", "new", "indownloadedarea",
    103103                "allindownloadedarea", "inview", "allinview", "timestamp", "nth", "nth%");
     
    141141                    case "areasize":
    142142                        return new AreaSize(tokenizer);
     143                    case "waylength":
     144                        return new WayLength(tokenizer);
    143145                    case "nth":
    144146                        return new Nth(tokenizer, false);
     
    11151117
    11161118    /**
     1119     * Matches if the length of a way is within the given range
     1120     */
     1121    private static class WayLength extends RangeMatch {
     1122
     1123        public WayLength(Range range) {
     1124            super(range);
     1125        }
     1126
     1127        public WayLength(PushbackTokenizer tokenizer) throws ParseError {
     1128            this(tokenizer.readRange(tr("Range of numbers expected")));
     1129        }
     1130
     1131        @Override
     1132        protected Long getNumber(OsmPrimitive osm) {
     1133            if (!(osm instanceof Way))
     1134                return null;
     1135            Way way = (Way) osm;
     1136            return (long) way.getLength();
     1137        }
     1138
     1139        @Override
     1140        protected String getString() {
     1141            return "waylength";
     1142        }
     1143    }
     1144
     1145    /**
    11171146     * Matches objects within the given bounds.
    11181147     */
Note: See TracChangeset for help on using the changeset viewer.