Skip to content

Commit

Permalink
Merge pull request #272 from ltog/master
Browse files Browse the repository at this point in the history
Add examples for TagFilter
  • Loading branch information
lonvia authored Nov 10, 2024
2 parents 6988244 + 67986ed commit f9b9f2c
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions docs/user_manual/04-Working-with-Filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,21 @@ KeyFilter multiple times:

### TagFilter

This filter works exactly the same as the KeyFilter, only it looks for the
presence of whole tags (key and value) in the tag list of the object.
This filter works like KeyFilter, allowing both AND and OR combinations, but
it requires whole tags (key and value) in the object's tag list.
Tags are given as two-element tuples.

!!! example
```python
print("Objects with 'highway=primary' _or_ 'surface=asphalt' tags:",
sum(1 for o in osmium.FileProcessor('../data/liechtenstein.osm.pbf')
.with_filter(osmium.filter.TagFilter(('highway','primary'), ('surface','asphalt')))))

print("Objects with 'highway=primary' _and_ 'surface=asphalt' tags:",
sum(1 for o in osmium.FileProcessor('../data/liechtenstein.osm.pbf')
.with_filter(osmium.filter.TagFilter(('highway','primary')))
.with_filter(osmium.filter.TagFilter(('surface','asphalt')))))
```

### IdFilter

Expand Down

0 comments on commit f9b9f2c

Please sign in to comment.