none
BBoxToQuadKeys ? RRS feed

  • Question

  • I've used some good tools and functions from here and on msdn on translating coordinates and quadkeys. Most notably there is a QuadKeytoBBox that is used when pulling from a WMS on the fly.

    I want to modify this process a bit. Rather than pull WMS tiles on the fly by taking the requested quadkey and figuring out the BBox, I want to download and create WMS tiles for a certain region ahead of time via a background process. Since the request for QuadKeys will not be coming from the bing map+browser, I need to artificially request (or figure out) the quadkeys that exist for my desired area.

    Any suggestions for doing this? I've thought of a few crude "Get the upper left and lower right quadkeys from the coordinate corners, and then recursively loop and create my quadkey". but surely a more elegant solution exists.

     

    • Moved by Ricky_Brundritt Saturday, March 10, 2012 10:18 AM (From:Bing Maps: Map Control and Web services Development)
    Friday, July 29, 2011 3:12 PM

Answers

  • @Hemant - if I understand @Lan-Lord's description correctly, he's not accessing the Bing Maps tiles directly. Rather, he's just trying to simulate and derive the quadkeys of the tiles that would be requested for a given area, so that they can be used to construct web requests to a WMS service and store the results from that.

    @Lan-Lord - I'm not aware of a 'clever' way to do this other than by iteration or recursion as you already suggested you're using. The way I do it is that I have a set of functions that work out, given any supplied quadkey, the quadkey of the next tile one tile left/right/up/down from the current one. I then choose a starting quadkey and say that I want to retrieve the box 60 tiles across and 80 tiles down from that starting tile. This iterates through the functions, creating the quadkeys for each tile which I then use to make a WMS request. I repeat this process at each zoom level that I want tiles for.
    twitter: @alastaira blog: http://alastaira.wordpress.com/
    Saturday, July 30, 2011 7:29 PM
    Moderator
  • The solution consists of taking the top left and bottom right coordinates, converting them to tile X, and Y indices and then you can convert these to quadkey fairly easily. All the math you need can be found here: http://msdn.microsoft.com/en-us/library/bb259689.aspx
    Windows Live Developer MVP - http://rbrundritt.wordpress.com | http://inknowledge.co.uk
    Sunday, July 31, 2011 9:59 AM

All replies

  • Accessing the tiles directly is not recommended & supported feature. You can use tilebuffer property to get tiles ahead of time.

     


    MSFT
    Hemant Goyal
    Saturday, July 30, 2011 6:34 PM
  • @Hemant - if I understand @Lan-Lord's description correctly, he's not accessing the Bing Maps tiles directly. Rather, he's just trying to simulate and derive the quadkeys of the tiles that would be requested for a given area, so that they can be used to construct web requests to a WMS service and store the results from that.

    @Lan-Lord - I'm not aware of a 'clever' way to do this other than by iteration or recursion as you already suggested you're using. The way I do it is that I have a set of functions that work out, given any supplied quadkey, the quadkey of the next tile one tile left/right/up/down from the current one. I then choose a starting quadkey and say that I want to retrieve the box 60 tiles across and 80 tiles down from that starting tile. This iterates through the functions, creating the quadkeys for each tile which I then use to make a WMS request. I repeat this process at each zoom level that I want tiles for.
    twitter: @alastaira blog: http://alastaira.wordpress.com/
    Saturday, July 30, 2011 7:29 PM
    Moderator
  • The solution consists of taking the top left and bottom right coordinates, converting them to tile X, and Y indices and then you can convert these to quadkey fairly easily. All the math you need can be found here: http://msdn.microsoft.com/en-us/library/bb259689.aspx
    Windows Live Developer MVP - http://rbrundritt.wordpress.com | http://inknowledge.co.uk
    Sunday, July 31, 2011 9:59 AM