alaCarte Maps
Renderer for OpenStreetMap tiles
tagmatches_selector.cpp
Go to the documentation of this file.
1 
24 #include <boost/regex.hpp>
25 #include "general/geodata.hpp"
26 #include "general/node.hpp"
27 #include "general/way.hpp"
28 #include "general/relation.hpp"
29 #include "server/rule.hpp"
31 
32 
33 TagMatchesSelector::TagMatchesSelector(const shared_ptr<Rule>& rule, const shared_ptr<Selector>& next, const string& tag, const string& value)
34  : Selector(rule, next)
35  , tag(tag)
36  , expression(value)
37 {
38 }
39 
40 void TagMatchesSelector::matchNode(NodeId nodeID, const shared_ptr<TileIdentifier>& ti, RenderAttributes* attributes) const {
41  Node* node = geodata->getNode(nodeID);
42  auto entry = node->getTags().find(tag);
43  if (entry != node->getTags().end()) {
44  if (boost::regex_match(entry->second.str(), expression)) {
45  next->matchNode(nodeID, ti, attributes);
46  }
47  }
48 }
49 
50 void TagMatchesSelector::matchWay(WayId wayID, const shared_ptr<TileIdentifier>& ti, RenderAttributes* attributes) const {
51  Way* way = geodata->getWay(wayID);
52  auto entry = way->getTags().find(tag);
53  if (entry != way->getTags().end()) {
54  if (boost::regex_match(entry->second.str(), expression)) {
55  next->matchWay(wayID, ti, attributes);
56  }
57  }
58 }
59 
60 void TagMatchesSelector::matchRelation(RelId relID, const shared_ptr<TileIdentifier>& ti, RenderAttributes* attributes) const {
61  Relation* relation = geodata->getRelation(relID);
62  auto entry = relation->getTags().find(tag);
63  if (entry != relation->getTags().end()) {
64  if (boost::regex_match(entry->second.str(), expression)) {
65  next->matchRelation(relID, ti, attributes);
66  }
67  }
68 }
Definition: node.hpp:28
A RenderAttributes object contains mappings from NodeIDs and WayIDs to Style objects which define how...
const CachedString tag
TESTABLE const DataMap< CachedString, CachedString > & getTags() const
Returns a map with key-to-tag-mapping for osm-tags.
Definition: geo_object.cpp:30
virtual void matchWay(WayId wayID, const shared_ptr< TileIdentifier > &ti, RenderAttributes *attributes) const
const boost::regex expression
const shared_ptr< Selector > next
Definition: selector.hpp:54
virtual void matchNode(NodeId nodeID, const shared_ptr< TileIdentifier > &ti, RenderAttributes *attributes) const
const shared_ptr< Geodata > geodata
Definition: selector.hpp:55
TagMatchesSelector(const shared_ptr< Rule > &rule, const shared_ptr< Selector > &next, const string &tag, const string &value)
This file is part of alaCarte.
Definition: way.hpp:31
virtual void matchRelation(RelId relID, const shared_ptr< TileIdentifier > &ti, RenderAttributes *attributes) const