/JosmFilterParser

This is a parser for the JOSM filter/search grammar

Primary LanguageJavaOtherNOASSERTION

build status Quality Gate Status Coverage sonarcloud bugs sonarcould maintainability sonarcloud security sonarcloud reliability

JosmFilterParser

Usage

    try {
        JosmFilterParser parser = new JosmFilterParser(new ByteArrayInputStream(filterString.getBytes()));
        boolean matches = parser.condition(false).eval(...);
    } catch (JosmFilterParseException pex) {
        ...
    } catch (Error err) {
        ...
    }

Your OSM elements object must either implement the Meta interface or be wrapped in an object that implements it. The object can then be passed to the eval method.

Supported expressions

This is what the parser currently supports not necessarily what can be supported in a specific application.

Syntax Overpass
Baker Street
"Baker Street"
key:valuefragment
-key:valuefragment
key: undocumented in JOSM
key
key? undocumented in JOSM
key=value
key~regexp in JOSM since 16260
key=*
key=
*=value
key>value
key<value
expr expr
expr AND expr undocumented in JOSM
expr | expr
expr OR expr
expr XOR expr undocumented in JOSM
-expr
(expr)
type:node
type:way
type:relation
closed
untagged
preset:"preset item path"
preset:"preset group path/*"
user:
id:
version:
changeset:
timestamp:
nodes:range
ways:range
members:range in JOSM since 16581
tags:range
role:role
areasize:range
waylength:range
modified
new
ways:range
selected
incomplete
deleted
child expr
parent expr
hasRole:role
nth:number
nth%:number
inview
allinview
indownloadedarea
allindownloadedarea
in place only overpass queries
around place only overpass queries

Version 0.3.0 and later optionally supports regexps instead of the * wildcard.

Backslash style quoting is supported in quote strings for backslash and double quotes, it is not supported in unquoted strings.

More documentation on the grammar can be found in the documentation repository.

Including in your project

You can either download the jar from github or add the following to your build.gradle

...
    repositories {
        ...   
        mavenCentral()
        ...              
    }
...

dependencies {
    ...
    compile 'ch.poole.osm:JosmFilterParser:0.10.0'
    ...
}