alaCarte Maps
Renderer for OpenStreetMap tiles
hastag_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 HasTagSelector::HasTagSelector(const shared_ptr<Rule>& rule, const shared_ptr<Selector>& next, const string& tag)
33  : Selector(rule, next)
34  , tag(tag)
35 {
36 }
37 
38 void HasTagSelector::matchNode(NodeId nodeID, const shared_ptr<TileIdentifier>& ti, RenderAttributes* attributes) const {
39  Node* node = geodata->getNode(nodeID);
40  auto& map = node->getTags();
41  if (map.find(tag) != map.end()) {
42  next->matchNode(nodeID, ti, attributes);
43  }
44 }
45 
46 void HasTagSelector::matchWay(WayId wayID, const shared_ptr<TileIdentifier>& ti, RenderAttributes* attributes) const {
47  Way* way = geodata->getWay(wayID);
48  auto& map = way->getTags();
49  if (map.find(tag) != map.end()) {
50  next->matchWay(wayID, ti, attributes);
51  }
52 }
53 
54 void HasTagSelector::matchRelation(RelId relID, const shared_ptr<TileIdentifier>& ti, RenderAttributes* attributes) const {
55  Relation* relation = geodata->getRelation(relID);
56 
57  auto& map = relation->getTags();
58  if (map.find(tag) != map.end()) {
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
const CachedString tag
const shared_ptr< Selector > next
Definition: selector.hpp:54
virtual void matchNode(NodeId nodeID, const shared_ptr< TileIdentifier > &ti, RenderAttributes *attributes) const
virtual void matchRelation(RelId relID, const shared_ptr< TileIdentifier > &ti, RenderAttributes *attributes) const
const shared_ptr< Geodata > geodata
Definition: selector.hpp:55
HasTagSelector(const shared_ptr< Rule > &rule, const shared_ptr< Selector > &next, const string &tag)
This file is part of alaCarte.
Definition: way.hpp:31
virtual void matchWay(WayId wayID, const shared_ptr< TileIdentifier > &ti, RenderAttributes *attributes) const