diff --git a/curvature/match.py b/curvature/match.py index 64a3096..82973db 100644 --- a/curvature/match.py +++ b/curvature/match.py @@ -106,3 +106,22 @@ def match_way(self, way): if self.tag not in way['tags']: return False return way['tags'][self.tag] == self.value + +class TagContains(TagEquals): + + def match_way(self, way): + if 'tags' not in way: + raise ValueError('Ways must be a dict with a "tags" key. Received {}'.format(way)) + if self.tag not in way['tags']: + return False + return self.value in way['tags'][self.tag] + +class Id(WayMatcher): + + def __init__(self, *arg): + if not len(arg): + raise ValueError('You must pass at least one id') + self.ids = arg + + def match_way(self, way): + return way['id'] in self.ids diff --git a/curvature/post_processors/filter_out_ways.py b/curvature/post_processors/filter_out_ways.py index af14082..14f9705 100644 --- a/curvature/post_processors/filter_out_ways.py +++ b/curvature/post_processors/filter_out_ways.py @@ -6,6 +6,8 @@ from curvature.match import Not from curvature.match import TagEmpty from curvature.match import TagEquals +from curvature.match import TagContains +from curvature.match import Id class FilterOutWays(CollectionSplitter): def __init__(self, match_expression):