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