alaCarte Maps
Renderer for OpenStreetMap tiles
rule.cpp
Go to the documentation of this file.
1 
23 #include "server/rule.hpp"
24 #include "server/style.hpp"
27 #include "general/geodata.hpp"
30 
31 #include "config.hpp"
32 
33 Rule::Rule(const shared_ptr<Geodata>& geodata)
34  : geodata(geodata)
35  , zoombottom(ALAC_ZOOM_BOTTOM)
36  , zoomtop(ALAC_ZOOM_TOP)
37  , accepableType(Accept_Any)
38 {
39 }
40 
41 void Rule::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* renderAttributes) const
46 {
47  if(zoombottom <= ti->getZoom() && ti->getZoom() <= zoomtop)
48  {
49  if( accepableType & Accept_Node) {
50  for (NodeId nodeID : *nodeIDs) {
51  first->matchNode(nodeID, ti, renderAttributes);
52  }
53  }
54 
56  for (WayId wayID : *wayIDs) {
57  first->matchWay(wayID, ti, renderAttributes);
58  }
59  }
60 
62  for (RelId relID : *relIDs) {
63  first->matchRelation(relID, ti, renderAttributes);
64  }
65  }
66  }
67 }
68 
69 const shared_ptr<Geodata>& Rule::getGeodata() const {
70  return geodata;
71 }
72 
73 const shared_ptr<StyleTemplate>& Rule::getStyleTemplate() const {
74  return styleTemplate;
75 }
76 
77 void Rule::setStyleTemplate(const shared_ptr<StyleTemplate>& styleTemplate) {
78  this->styleTemplate = styleTemplate;
79 }
80 
81 void Rule::setFirstSelector(const shared_ptr<Selector>& first) {
82  this->first = first;
83 }
84 
85 void Rule::setZoomBounds(int bottom, int top) {
86  zoombottom = bottom;
87  zoomtop = top;
88 }
89 
91  accepableType = type;
92 }
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 *renderAttributes) const
Definition: rule.cpp:41
AcceptableTypes accepableType
Definition: rule.hpp:51
int zoombottom
Definition: rule.hpp:50
A RenderAttributes object contains mappings from NodeIDs and WayIDs to Style objects which define how...
TESTABLE const shared_ptr< StyleTemplate > & getStyleTemplate() const
Definition: rule.cpp:73
shared_ptr< StyleTemplate > styleTemplate
Definition: rule.hpp:49
TESTABLE void setFirstSelector(const shared_ptr< Selector > &first)
what is the first selector in the selector chain for this rule?
Definition: rule.cpp:81
TESTABLE const shared_ptr< Geodata > & getGeodata() const
Definition: rule.cpp:69
TESTABLE void setZoomBounds(int bottom, int top)
from which to which zoom level does this rule apply?
Definition: rule.cpp:85
TESTABLE void setAcceptableType(AcceptableTypes type)
what types of GeoObjects does this rule accept in the first selector?
Definition: rule.cpp:90
shared_ptr< Selector > first
Definition: rule.hpp:48
TESTABLE void setStyleTemplate(const shared_ptr< StyleTemplate > &styleTemplate)
sets the StyleTemplate representation of the attributes specified in the MapCSS file for this rule...
Definition: rule.cpp:77
#define ALAC_ZOOM_BOTTOM
Definition: settings.hpp:132
const shared_ptr< Geodata > geodata
Definition: rule.hpp:47
#define ALAC_ZOOM_TOP
Definition: settings.hpp:133
Rule(const shared_ptr< Geodata > &geodata)
This file is part of alaCarte.
Definition: rule.cpp:33
int zoomtop
Definition: rule.hpp:50
AcceptableTypes
Definition: rule.hpp:38