32 #include <boost/lexical_cast.hpp> 33 #include <boost/random.hpp> 38 #include <json/json.h> 50 network_manager_(this)
55 base_url_ =
"https://dev.virtualearth.net/REST/v1/Imagery/Metadata/Aerial?uriScheme=https&include=ImageryProviders&key={api_key}";
74 boost::random::uniform_int_distribution<> random(0, (
int)
subdomains_.size() - 1);
75 url.replace(QString::fromStdString(
"{subdomain}"),
subdomains_[random(
rng_)]);
77 url.replace(QString::fromStdString(
"{quadkey}"),
GenerateQuadKey(level, x, y));
97 url.replace(QString::fromStdString(
"{api_key}"),
api_key_);
109 for (int32_t i = level; i > 0; i--)
111 int32_t bitmask = 1 << (i-1);
113 if ((x & bitmask) != 0)
117 if ((y & bitmask) != 0)
121 quadkey.append(QString::number(digit));
129 QString reply_string(reply->readAll());
132 reader.parse(reply_string.toStdString(), root);
137 Q_EMIT
ErrorMessage(
"Bing authorization error: " + boost::lexical_cast<std::string>(status));
160 if (image_url.empty())
166 tile_url_ = QString::fromStdString(image_url);
173 Q_EMIT
ErrorMessage(
"No image URL subdomains; maybe that's ok sometimes?");
179 subdomains_.push_back(QString::fromStdString(subdomain.asString()));
boost::random::mt19937 rng_
QString GenerateQuadKey(int32_t level, int64_t x, int64_t y) const
static const std::string BING_IMAGE_URL_KEY
static const QString BING_TYPE
QString GetApiKey() const
boost::hash< std::string > hash_
virtual void SetMaxZoom(int32_t max_zoom)
static const std::string BING_STATUS_CODE_KEY
BingSource(const QString &name)
void InfoMessage(const std::string &info_msg) const
void ErrorMessage(const std::string &error_msg) const
static const std::string BING_IMAGE_URL_SUBDOMAIN_KEY
static const std::string BING_RESOURCE_KEY
virtual QString GetType() const
static const std::string BING_RESOURCE_SET_KEY
void SetApiKey(const QString &api_key)
std::vector< QString > subdomains_
QNetworkAccessManager network_manager_
virtual QString GenerateTileUrl(int32_t level, int64_t x, int64_t y)
virtual size_t GenerateTileHash(int32_t level, int64_t x, int64_t y)
void ReplyFinished(QNetworkReply *reply)