Bing map image system II

Source: Internet
Author: User

 

Coordinate System and map image encoding]

To optimize the map system performance and increase the speed of map download and display, all maps are divided into small square blocks of 256x256 pixels. Because the number of pixels varies at each zoom level, the number of Map Images (tile) is also different:

map width = map height = 2^Leveltiles

Each tile has an XY coordinate value from (0, 0) in the upper left corner to (2 ^ level-1, 2 ^ level-1) in the lower right corner ). For example, at the three-level amplification level, the coordinates of all tile ranges from (0, 0) to (7, 7), for example:

When the XY coordinate value of a pixel is known, we can easily obtain the XY coordinate value of the tile where the pixel is located:

tileX = floor(pixelX / 256)

tileY = floor(pixelY / 256)

To simplify indexing and store map images, the Two-Dimensional XY value of each tile is converted into a one-dimensional string, that is, the quardtree key (quadkey ). Each quadkey corresponds to a single tile at a specific amplification level, and can be used as a B-tree index value in the database. To convert a coordinate value to a quadkey, You need to combine the binary values of Y and X coordinates and convert them to a 4-digit value and the corresponding string. For example, if tile's XY coordinate value is (3, 5) when the amplification level is 3, The quadkey is calculated as follows:

Tilex = 3 = 011 (Binary)

Tiley = 5 = 101 (Binary)

Quadkey = 100111 (Binary) = 213 (four-digit) = “213”

Quadkey has other interesting features. First, the length of the quadkey is equal to the amplification level corresponding to the tile. Second, the first digit of each quadkey is the same as that of its parent tile (the tile corresponding to the previous amplification level; in, tile 2 is the parent Tile of tile 20 to 23, and tile 13 is the parent Tile of tile 130 to 133:

Finally, the one-dimensional Index value provided by quadkey usually shows the similarity between two tile in the XY coordinate system. In other words, the quadkey corresponding to two adjacent tile is very close. This is very important to optimize the database performance, because adjacent tile is usually displayed at the same time, so these tile can be stored in the same disk area, in order to reduce the number of disk reads.

For practical application, if you have used httpwatch, you can find that the URL for obtaining the Bing map tile is as follows:

http://r3.tiles.ditu.live.com/tiles/r13023.png?g=47

The detailed explanation of this URL is explained in detail in my blog. Here we see r13023.png. r indicates the road image and 13023 indicates the quadkey corresponding to tile. Apparently, the tile is located on a 5-level map, and its grandfather tile is 130 in the black box.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.