Skip to content

Commit f9b9f2c

Browse files
authored
Merge pull request #272 from ltog/master
Add examples for TagFilter
2 parents 6988244 + 67986ed commit f9b9f2c

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

docs/user_manual/04-Working-with-Filters.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,21 @@ KeyFilter multiple times:
212212

213213
### TagFilter
214214

215-
This filter works exactly the same as the KeyFilter, only it looks for the
216-
presence of whole tags (key and value) in the tag list of the object.
215+
This filter works like KeyFilter, allowing both AND and OR combinations, but
216+
it requires whole tags (key and value) in the object's tag list.
217+
Tags are given as two-element tuples.
218+
219+
!!! example
220+
```python
221+
print("Objects with 'highway=primary' _or_ 'surface=asphalt' tags:",
222+
sum(1 for o in osmium.FileProcessor('../data/liechtenstein.osm.pbf')
223+
.with_filter(osmium.filter.TagFilter(('highway','primary'), ('surface','asphalt')))))
224+
225+
print("Objects with 'highway=primary' _and_ 'surface=asphalt' tags:",
226+
sum(1 for o in osmium.FileProcessor('../data/liechtenstein.osm.pbf')
227+
.with_filter(osmium.filter.TagFilter(('highway','primary')))
228+
.with_filter(osmium.filter.TagFilter(('surface','asphalt')))))
229+
```
217230

218231
### IdFilter
219232

0 commit comments

Comments
 (0)