Verified Commit efc6ae93 authored by Martin Raifer's avatar Martin Raifer
Browse files

Merge branch 'master' into 1.1

parents d463dab3 42b26392
1.1.1
-----
* Improve documentation by adding some examples to readme.
* Fix spelling of keywords in error messages.
1.1.0
-----
......
......@@ -59,8 +59,8 @@ Filters are defined in textual form. A filter expression can be composed out of
|---|-------------|---------|
| `key=value` | matches all entites which have this exact tag | `natural=tree` |
| `key=*` | matches all entites which have any tag with the given key | `addr:housenumber=*` |
| `key!=value` | matches all entites which do not have this exact tag | `oneway!=yes` |
| `key!=*` | matches all entites which no not have any tag with the given key | `name!=*` |
| `key!=value` | matches all entites which do not have this exact tag – the same as `not key=value` | `oneway!=yes` |
| `key!=*` | matches all entites which do not have any tag with the given key – the same as `not key=*` | `name!=*` |
| `type:osm-type` | matches all entites of the given osm type | `type:node` |
| `geometry:geom-type` | matches anything which has a geometry of the given type (_point_, _line_, _polygon_, or _other_) | `geometry:polygon` |
......@@ -82,6 +82,19 @@ When filtering by tags with any other characters in their key or value, these st
Whitespace such as spaces, tabs or newlines can be put freely between operators or parts of selectors (`name = *` is equivalent to `name=*`) to make a filter more readable.
Examples
--------
Here's some useful examples for querying some OSM features:
| OSM Feature | filter | comment |
|-------------|--------|---------|
| forests/woods | `landuse=forest or natural=wood and geometry:polygon` | Using `geometry:polygon` will select closed ways as well as multipolygons (e.g. a forest with clearings). |
| parks and park benches | `leisure=park and geometry:polygon or amenity=bench and (geometry:point or geometry:line)` | A query can also fetch features of different geometry types: this returns parks (polygons) as well as park benches (points or lines). |
| buildings | `building=* and building!=no and geometry:polygon` | This query also excludes the (rare) objects marked with `building=no`, which is a tag used to indicate that a feature might be expected to be a building (e.g. from an outdated aerial imagery source), but is in reality not one. |
| highways | `type:way and (highway=motorway or highway=motorway_link or highway=trunk or highway=trunk_link or highway=primary or highway=primary_link or highway=secondary or highway=secondary_link or highway=tertiary or highway=tertiary_link or highway=unclassified or highway=residential or highway=living_street or highway=pedestrian or (highway=service and service=alley))` | The list of used tags depends on the exact definition of a "highway". In a different context, it may also incude less or even more tags (`highway=footway`, `highway=cycleway`, `highway=track`, `highway=path`, all `highway=service`, etc.). |
| residential roads missing a name (for quality assurance) | `type:way and highway=residential and name!=* and noname!=yes` | Note that some roads might be actually unnamed in reality. Such features can be marked as unnamed with the [`noname`](https://wiki.openstreetmap.org/wiki/Key:noname) tag in OSM. |
Documentation
-------------
......
......@@ -6,7 +6,7 @@
<groupId>org.heigit.ohsome</groupId>
<artifactId>ohsome-filter</artifactId>
<version>1.1.0</version>
<version>1.1.1</version>
<description>A flexible filtering library for OSM entities.</description>
<packaging>jar</packaging>
......
......@@ -35,35 +35,35 @@ public class FilterParser {
final Parser<Void> whitespace = Scanners.WHITESPACES.skipMany();
final Parser<String> keystr = Patterns.regex("[a-zA-Z_0-9:-]+")
.toScanner("KEY_STRING")
.toScanner("KEY_STRING (a-z, 0-9, : or -)")
.source();
final Parser<String> string = keystr.or(StringLiteral.DOUBLE_QUOTE_TOKENIZER);
final Parser<String> equals = Patterns.string("=").toScanner("EQUALS")
final Parser<String> equals = Patterns.string("=").toScanner("EQUALS (=)")
.map(ignored -> "=");
final Parser<String> notEquals = Patterns.string("!=").toScanner("NOT_EQUALS")
final Parser<String> notEquals = Patterns.string("!=").toScanner("NOT_EQUALS (!=)")
.map(ignored -> "!=");
final Parser<String> colon = Patterns.string(":").toScanner("COLON")
final Parser<String> colon = Patterns.string(":").toScanner("COLON (:)")
.map(ignored -> ":");
final Parser<String> type = Patterns.string("type").toScanner("TYPE")
final Parser<String> type = Patterns.string("type").toScanner("type")
.map(ignored -> "type");
final Parser<OSMType> node = Patterns.string("node").toScanner("NODE")
final Parser<OSMType> node = Patterns.string("node").toScanner("node")
.map(ignored -> OSMType.NODE);
final Parser<OSMType> way = Patterns.string("way").toScanner("WAY")
final Parser<OSMType> way = Patterns.string("way").toScanner("way")
.map(ignored -> OSMType.WAY);
final Parser<OSMType> relation = Patterns.string("relation").toScanner("RELATION")
final Parser<OSMType> relation = Patterns.string("relation").toScanner("relation")
.map(ignored -> OSMType.RELATION);
final Parser<String> geometry = Patterns.string("geometry").toScanner("GEOMETRY")
final Parser<String> geometry = Patterns.string("geometry").toScanner("geometry")
.map(ignored -> "geometry");
final Parser<GeometryType> point = Patterns.string("point").toScanner("POINT")
final Parser<GeometryType> point = Patterns.string("point").toScanner("point")
.map(ignored -> GeometryType.POINT);
final Parser<GeometryType> line = Patterns.string("line").toScanner("LINE")
final Parser<GeometryType> line = Patterns.string("line").toScanner("line")
.map(ignored -> GeometryType.LINE);
final Parser<GeometryType> polygon = Patterns.string("polygon").toScanner("POLYGON")
final Parser<GeometryType> polygon = Patterns.string("polygon").toScanner("polygon")
.map(ignored -> GeometryType.POLYGON);
final Parser<GeometryType> other = Patterns.string("other").toScanner("OTHER")
final Parser<GeometryType> other = Patterns.string("other").toScanner("other")
.map(ignored -> GeometryType.OTHER);
final Parser<String> star = Patterns.string("*").toScanner("STAR")
final Parser<String> star = Patterns.string("*").toScanner("STAR (*)")
.map(ignored -> "*");
final Parser<FilterExpression> tagFilter = Parsers.sequence(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment