alaCarte Maps
Renderer for OpenStreetMap tiles
taglarger_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 TagLargerSelector::TagLargerSelector(const shared_ptr<Rule>& rule, const shared_ptr<Selector>& next, const string& tag, const int& value)
33  : Selector(rule, next)
34  , tag(tag)
35  , value(value)
36 {
37 }
38 
39 void TagLargerSelector::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 
43  if (entry != node->getTags().end()) {
44  std::stringstream strstream(entry->second.str());
45  int tagvalue;
46  strstream >> tagvalue;
47 
48  // !strstream is true if the string value could be converted to int
49  if (!strstream.bad() && tagvalue > value) {
50  next->matchNode(nodeID, ti, attributes);
51  }
52  }
53 
54 }
55 
56 void TagLargerSelector::matchWay(WayId wayID, const shared_ptr<TileIdentifier>& ti, RenderAttributes* attributes) const {
57  Way* way = geodata->getWay(wayID);
58  auto entry = way->getTags().find(tag);
59 
60  if (entry != way->getTags().end()) {
61  std::stringstream strstream(entry->second.str());
62  int tagvalue;
63  strstream >> tagvalue;
64 
65  if (!strstream.bad() && tagvalue > value) {
66  next->matchWay(wayID, ti, attributes);
67  }
68  }
69 }
70 
71 void TagLargerSelector::matchRelation(RelId relID, const shared_ptr<TileIdentifier>& ti, RenderAttributes* attributes) const {
72  Relation* relation = geodata->getRelation(relID);
73  auto entry = relation->getTags().find(tag);
74 
75  if (entry != relation->getTags().end()) {
76  std::stringstream strstream(entry->second.str());
77  int tagvalue;
78  strstream >> tagvalue;
79 
80  if (!strstream.bad() && tagvalue > value) {
81  next->matchRelation(relID, ti, attributes);
82  }
83  }
84 }
Definition: node.hpp:28
virtual void matchNode(NodeId nodeID, const shared_ptr< TileIdentifier > &ti, RenderAttributes *attributes) const
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 shared_ptr< Selector > next
Definition: selector.hpp:54
const shared_ptr< Geodata > geodata
Definition: selector.hpp:55
virtual void matchRelation(RelId relID, const shared_ptr< TileIdentifier > &ti, RenderAttributes *attributes) const
TagLargerSelector(const shared_ptr< Rule > &rule, const shared_ptr< Selector > &next, const string &tag, const int &value)
This file is part of alaCarte.
Definition: way.hpp:31