alaCarte Maps
Renderer for OpenStreetMap tiles
stylesheet.cpp
Go to the documentation of this file.
1 
23 #include "server/stylesheet.hpp"
24 #include "server/style.hpp"
25 #include "server/rule.hpp"
28 #include "general/geodata.hpp"
29 #include "general/node.hpp"
30 #include "general/way.hpp"
31 #include "general/relation.hpp"
32 
33 Stylesheet::Stylesheet(const shared_ptr<Geodata>& geodata, const std::vector<shared_ptr<Rule> >& rules, const shared_ptr<StyleTemplate>& canvasStyle)
34  : geodata(geodata)
35  , rules(rules)
36  , canvasStyle(canvasStyle)
37 {
38 }
39 
40 
41 void Stylesheet::match( const shared_ptr<std::vector<NodeId> >& nodeIDs,
42  const shared_ptr<std::vector<WayId> >& wayIDs,
43  const shared_ptr<std::vector<RelId> >& relIDs,
44  const shared_ptr<TileIdentifier>& ti,
45  RenderAttributes* styleMap) const
46 {
47  for(auto& rule : rules)
48  {
49  rule->match(nodeIDs, wayIDs, relIDs, ti, styleMap);
50  }
51 
52  for(auto& pair : styleMap->getNodeMap())
53  {
54  pair.second->finish(geodata->getNode(pair.first), shared_from_this());
55  }
56 
57  for(auto& pair : styleMap->getWayMap())
58  {
59  pair.second->finish(geodata->getWay(pair.first), shared_from_this());
60  }
61 
62  for(auto& pair : styleMap->getRelationMap())
63  {
64  pair.second->finish(geodata->getRelation(pair.first), shared_from_this());
65  }
66 
67  if(canvasStyle) {
68  Style* s = styleMap->getCanvasStyle();
69  s->overmerge(nullptr, canvasStyle);
70  s->finish(nullptr, shared_from_this());
71  }
72 }
73 
74 const boost::filesystem::path Stylesheet::getPath() const
75 {
76  return path;
77 }
void finish(GeoObject *associatedObject, shared_ptr< const Stylesheet > stylesheet)
Performs finishing operations on the style, like resolve tags for texts or check for icon path existe...
Definition: style.cpp:88
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
Stylesheet(const shared_ptr< Geodata > &geodata, const std::vector< shared_ptr< Rule > > &rules, const shared_ptr< StyleTemplate > &canvasStyle)
This file is part of alaCarte.
Definition: stylesheet.cpp:33
A RenderAttributes object contains mappings from NodeIDs and WayIDs to Style objects which define how...
TESTABLE Style * getCanvasStyle()
boost::filesystem::path path
Definition: stylesheet.hpp:75
TESTABLE const boost::unordered_map< RelId, Style * > & getRelationMap() const
shared_ptr< Geodata > geodata
Definition: stylesheet.hpp:72
const std::vector< shared_ptr< Rule > > rules
Definition: stylesheet.hpp:73
TESTABLE const boost::unordered_map< NodeId, Style * > & getNodeMap() const
TESTABLE const boost::filesystem::path getPath() const
Definition: stylesheet.cpp:74
shared_ptr< StyleTemplate > canvasStyle
Definition: stylesheet.hpp:74
A Style stores the MapCSS properties for a single Node or Way, or a Relation of type multipolygon...
Definition: style.hpp:35
TESTABLE void match(const shared_ptr< std::vector< NodeId > > &nodeIDs, const shared_ptr< std::vector< WayId > > &wayIDs, const shared_ptr< std::vector< RelId > > &relIDs, const shared_ptr< TileIdentifier > &ti, RenderAttributes *styleMap) const
Returns a new RenderAttributes with a Style object for each given Node and Way.
Definition: stylesheet.cpp:41