-
Notifications
You must be signed in to change notification settings - Fork 241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for bing map url quadkey in ros1 branch #126
base: ros1
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,11 @@ std::string tileURL(TileId const& tile_id) | |
boost::replace_all(url, "{x}", std::to_string(tile_id.coord.x)); | ||
boost::replace_all(url, "{y}", std::to_string(tile_id.coord.y)); | ||
boost::replace_all(url, "{z}", std::to_string(tile_id.zoom)); | ||
|
||
/* Added by Peixuan Shu to handle bing map */ | ||
boost::replace_all(url, "{q}", TilesToQuadkey(tile_id.coord.x, | ||
tile_id.coord.y, | ||
tile_id.zoom)); | ||
|
||
return url; | ||
} | ||
|
@@ -58,3 +63,23 @@ size_t std::hash<TileId>::operator()(TileId const& tile_id) const | |
boost::hash_combine(seed, tile_id.zoom); | ||
return seed; | ||
} | ||
|
||
std::string TilesToQuadkey(int x, int y, int z) | ||
{ | ||
std::stringstream quadkey; | ||
for (int i = z; i > 0; i--) { | ||
char b = '0'; | ||
int mask = 1 << (i - 1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a very magical function. Do you have a source for this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is how quadkey converted to tile xyz defined by Microsoft bing map team. Please refer to https://learn.microsoft.com/en-us/bingmaps/articles/bing-maps-tile-system There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, would you mind adding that link in the function description for future reference? |
||
if ((x & mask) != 0) | ||
{ | ||
b++; | ||
} | ||
if ((y & mask) != 0) | ||
{ | ||
b++; | ||
b++; | ||
} | ||
quadkey << b; | ||
} | ||
return quadkey.str(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This removes
{q}
from the url. Doesn't this break all other providers except bing?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No influence on other map providers as there is no '{q}' in their urls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, good point.
Would you mind naming it
{quadkey}
in the url? Because{q}
is often used for quaternion in the context of coordinate systems and ROS.