From 67986ed9e2f09c262c5c12d68f17e0b1e6bae4c2 Mon Sep 17 00:00:00 2001 From: Lukas Toggenburger Date: Sun, 10 Nov 2024 20:58:23 +0100 Subject: [PATCH] Add examples for TagFilter --- docs/user_manual/04-Working-with-Filters.md | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/user_manual/04-Working-with-Filters.md b/docs/user_manual/04-Working-with-Filters.md index b8d91ac..43175b8 100644 --- a/docs/user_manual/04-Working-with-Filters.md +++ b/docs/user_manual/04-Working-with-Filters.md @@ -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