alaCarte Maps
Renderer for OpenStreetMap tiles
meta_identifier.cpp
Go to the documentation of this file.
1 
25 
31 shared_ptr<MetaIdentifier> MetaIdentifier::Create(const shared_ptr<TileIdentifier>& origin)
32 {
33  return boost::make_shared<MetaIdentifier>(*origin);
34 }
35 
37  : TileIdentifier(origin)
38 {
39  // round to neared multiple of META_TILE_SIZE
40  int x0 = origin.getX() / META_TILE_SIZE * META_TILE_SIZE;
41  int y0 = origin.getY() / META_TILE_SIZE * META_TILE_SIZE;
42  int x1 = x0 + META_TILE_SIZE;
43  int y1 = y0 + META_TILE_SIZE;
44  x1 = std::min(x1, (1 << origin.getZoom()));
45  y1 = std::min(y1, (1 << origin.getZoom()));
46  this->width = x1 - x0;
47  this->height = y1 - y0;
48  this->x = x0;
49  this->y = y0;
50 
51  for (int tx = x; tx < x1; tx++)
52  for (int ty = y; ty < y1; ty++)
53  {
54  tids.push_back(
55  boost::make_shared<TileIdentifier>(tx, ty, origin.getZoom(),
56  origin.getStylesheetPath(),
57  origin.getImageFormat())
58  );
59  }
60 }
61 
62 const std::vector<shared_ptr<TileIdentifier>>& MetaIdentifier::getIdentifiers() const
63 {
64  return tids;
65 }
66 
68 {
69  return width;
70 }
71 
73 {
74  return height;
75 }
76 
77 bool MetaIdentifier::contains(const shared_ptr<TileIdentifier> tid) const
78 {
79  int tx = tid->getX();
80  int ty = tid->getY();
81  return (x <= tx && tx < x+width
82  && y <= ty && ty < y+height
83  && tid->getZoom() == zoom
84  && tid->getStylesheetPath() == styleSheetpath);
85 }
86 
91 void MetaIdentifier::getSubIdentifiers(std::vector<shared_ptr<MetaIdentifier>>& tiles) const
92 {
93  int z = this->zoom + 1;
94  int x = this->x*2;
95  int y = this->y*2;
96  int n = META_TILE_SIZE;
97 
98  tiles.push_back(boost::make_shared<MetaIdentifier>(TileIdentifier(x, y, z, styleSheetpath, imageFormat)));
99  if (x+n < (1 << z))
100  tiles.push_back(boost::make_shared<MetaIdentifier>(TileIdentifier(x+n, y, z, styleSheetpath, imageFormat)));
101  if (y+n < (1 << z))
102  tiles.push_back(boost::make_shared<MetaIdentifier>(TileIdentifier(x, y+n, z, styleSheetpath, imageFormat)));
103  if (x+n < (1 << z) && y+n < (1 << z))
104  tiles.push_back(boost::make_shared<MetaIdentifier>(TileIdentifier(x+n, y+n, z, styleSheetpath, imageFormat)));
105 }
string styleSheetpath
path to the Stylesheet which should be used for rendering.
TileIdentifier(int x, int y, int zoom, string styleSheetpath, Format imageFormat)
Constructs a new TileIdentifier with the given parameters.
TESTABLE const std::vector< shared_ptr< TileIdentifier > > & getIdentifiers() const
std::vector< shared_ptr< TileIdentifier > > tids
list of all contained tiles
TESTABLE int getHeight() const
static shared_ptr< MetaIdentifier > Create(const shared_ptr< TileIdentifier > &origin)
This file is part of alaCarte.
MetaIdentifier(const TileIdentifier &origin)
bool contains(const shared_ptr< TileIdentifier > tid) const
A TileIdentifier identifies a Tile.
TESTABLE void getSubIdentifiers(std::vector< shared_ptr< MetaIdentifier >> &tiles) const
get all tiles that are below this tile on the next zoom level.
TESTABLE int getY() const
Returns the y coordinate of the Tile.
int x
x coordinate of the Tile.
TESTABLE int getZoom() const
Returns the zoom level of the Tile.
TESTABLE const string & getStylesheetPath() const
Returns the path to the Stylesheet which should be used for rendering.
TESTABLE Format getImageFormat() const
Returns the image Format of the Tile.
int y
y coordinate of the Tile.
#define META_TILE_SIZE
Definition: settings.hpp:131
TESTABLE int getX() const
Returns the x coordinate of the Tile.
int width
with of the meta tile in tiles
Format imageFormat
Format of the image.
TESTABLE int getWidth() const
int zoom
zoom level of the Tile.
int height
height of the meta tile in tiles