27 #include <boost/algorithm/string.hpp> 28 #include <boost/lexical_cast.hpp> 51 while (*p >=
'0' && *p <=
'9') {
52 x = (x*10) + (*p -
'0');
72 shared_ptr<TileIdentifier>
TileIdentifier::Create(
const string& url, shared_ptr<StylesheetManager> stylesheetManager,
const shared_ptr<Configuration>&
config)
78 static int boundaries[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144};
81 std::vector<string> parts;
82 boost::split(parts, url, boost::is_any_of(
"/"));
83 int length = parts.size();
89 std::vector<string> subparts;
90 boost::split(subparts, parts.at(length-1), boost::is_any_of(
"."));
91 if (subparts.size() < 2) {
95 string& format = subparts.at(1);
96 std::transform(format.begin(), format.end(), format.begin(), ::tolower);
97 if (format ==
"png") {
105 }
else if (format ==
"svg") {
115 if (zoom < 0 || zoom > 18) {
120 if (y < 0 || y >= boundaries[zoom]) {
125 if (x < 0 || x >= boundaries[zoom]) {
130 for (
int i = 1; i < length - 3; i++) {
132 styleSheetpath +=
"/";
134 styleSheetpath += parts.at(i);
136 if (styleSheetpath ==
"" || !stylesheetManager->hasStylesheet(styleSheetpath))
140 if (!stylesheetManager->hasStylesheet(styleSheetpath))
141 styleSheetpath =
".fallback";
154 return boost::make_shared<TileIdentifier>(-2, -2, -2, stylesheetPath, format);
170 styleSheetpath(styleSheetpath),
171 imageFormat(imageFormat)
249 return x==-2 &&
y==-2 &&
zoom==-2;
262 return out <<
"TileIdentifier(x=" << ti.
getX()
263 <<
", y=" << ti.
getY()
276 std::size_t seed = 0;
277 boost::hash_combine(seed, ti.
getX());
278 boost::hash_combine(seed, ti.
getY());
279 boost::hash_combine(seed, ti.
getZoom());
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.
static const char * path_to_default_style
Path to the default stylesheet (type: string)
TESTABLE bool isDefaultIdentifier() const
Determine whether this is the Identifier for the default tile.
static const string FormatString[enumSize]
This file is part of alaCarte.
Format
Enumeration which contains all supported image formats.
TESTABLE const string & getImageFormatString() const
Returns the image Format of the Tile.
A TileIdentifier identifies a Tile.
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.
boost::error_info< struct TagWhatInfo, string > InfoWhat
Use this info to give an what msg to the exception.
TESTABLE bool isNoneDataIdentifier() const
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.
TESTABLE int getX() const
Returns the x coordinate of the Tile.
static int stringToInt(const char *c)
Converts the given char* to integer.
std::size_t hash_value(const TileIdentifier &ti)
Returns a hash for the TileIdentifier.
static const char * config
Option to get the configuration filename (type: string)
Format imageFormat
Format of the image.
static shared_ptr< TileIdentifier > CreateEmptyTID(const string &stylesheetPath, TileIdentifier::Format format)
Return the TileIdentifier used for Tiles without data.
static shared_ptr< TileIdentifier > Create(const string &url, shared_ptr< StylesheetManager > StylesheetManager, const shared_ptr< Configuration > &config)
Constructs a new TileIdentifier with the given url.
std::ostream & operator<<(std::ostream &out, const TileIdentifier &ti)
toString method for TileIdentifier (overloading << operator).
int zoom
zoom level of the Tile.
bool operator==(const TileIdentifier &a, const TileIdentifier &b)
Equals operator for two TileIdentifiers.