alaCarte Maps
Renderer for OpenStreetMap tiles
apply_selector.cpp
Go to the documentation of this file.
1 
25 #include "server/style.hpp"
26 #include "server/rule.hpp"
28 #include "general/geodata.hpp"
29 #include "general/node.hpp"
30 #include "general/way.hpp"
31 #include "general/relation.hpp"
33 
34 ApplySelector::ApplySelector(const shared_ptr<Rule>& rule)
35  : Selector(rule, shared_ptr<Selector>())
36 {
37 }
38 
39 void ApplySelector::matchNode(NodeId nodeID, const shared_ptr<TileIdentifier>& ti, RenderAttributes* attributes) const {
40  auto entry = attributes->getNodeMap().find(nodeID);
41  Style* style;
42  if (entry == attributes->getNodeMap().end()) {
43  // add a new Style entry
44  style = attributes->getNewStyle(nodeID);
45  }else{
46  style = entry->second;
47  }
48 
49  // overmerge with the currently existing style
50  style->overmerge(geodata->getNode(nodeID), rule.lock()->getStyleTemplate());
51 }
52 
53 void ApplySelector::matchWay(WayId wayID, const shared_ptr<TileIdentifier>& ti, RenderAttributes* attributes) const {
54  auto entry = attributes->getWayMap().find(wayID);
55  Style* style;
56  if (entry == attributes->getWayMap().end()) {
57  // add a new Style entry
58  style = attributes->getNewStyle(wayID);
59  }else{
60  style = entry->second;
61  }
62 
63  style->overmerge(geodata->getWay(wayID), rule.lock()->getStyleTemplate());
64 }
65 
66 // this should only be reached for relations of type multipolygon
67 void ApplySelector::matchRelation(RelId relID, const shared_ptr<TileIdentifier>& ti, RenderAttributes* attributes) const {
68  auto entry = attributes->getRelationMap().find(relID);
69  Style* style;
70  if (entry == attributes->getRelationMap().end()) {
71  // add a new Style entry
72  style = attributes->getNewStyle(relID);
73  }else{
74  style = entry->second;
75  }
76 
77  style->overmerge(geodata->getRelation(relID), rule.lock()->getStyleTemplate());
78 }
virtual void matchRelation(RelId relID, const shared_ptr< TileIdentifier > &ti, RenderAttributes *attributes) const
TESTABLE void overmerge(GeoObject *obj, const shared_ptr< StyleTemplate > &style)
Takes all non-"null" (meaning only properties that were explicitely set) properties from the given St...
Definition: style.cpp:38
TESTABLE const boost::unordered_map< WayId, Style * > & getWayMap() const
A RenderAttributes object contains mappings from NodeIDs and WayIDs to Style objects which define how...
TESTABLE Style * getNewStyle(NodeId id)
TESTABLE const boost::unordered_map< RelId, Style * > & getRelationMap() const
virtual void matchWay(WayId wayID, const shared_ptr< TileIdentifier > &ti, RenderAttributes *attributes) const
TESTABLE const boost::unordered_map< NodeId, Style * > & getNodeMap() const
const weak_ptr< Rule > rule
Definition: selector.hpp:53
virtual void matchNode(NodeId nodeID, const shared_ptr< TileIdentifier > &ti, RenderAttributes *attributes) const
ApplySelector(const shared_ptr< Rule > &rule)
This file is part of alaCarte.
A Style stores the MapCSS properties for a single Node or Way, or a Relation of type multipolygon...
Definition: style.hpp:35
const shared_ptr< Geodata > geodata
Definition: selector.hpp:55