Skip to content

Commit

Permalink
Added new TagContains and Id matching expressions.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamfranco committed May 26, 2016
1 parent b7bd29b commit e4a64f2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
19 changes: 19 additions & 0 deletions curvature/match.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions curvature/post_processors/filter_out_ways.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit e4a64f2

Please sign in to comment.