Also said that the Google satellite map URL address of the qrts coding algorithm

Source: Internet
Author: User
Tags numeric sin

Today I see someone is already discussing how to get Google satellite images, see http://www.cnblogs.com/tangf/archive/2006/07/23/457902.html? Login=1&commentid=1507040#post a blog, which copied the JavaScript and Delphi code to come, I am here again to copy again lest everyone look for.

The algorithm thought as follows: Google satellite image server, by different levels of 256x256 JPEG image seamless stitching, the encoding is based on the Qrst encoding method index:

Zoom=1, the world only a 256x256 picture, its center by latitude (0,0), its URL is "http://kh.google.com/kh?v=3&t=t" (You can change the URL to copy to the browser to see), its scope is the Earth Angle longitudinal cut cylindrical projection, about 180 degrees from the west to the East 180 degrees, from the South 180 degrees to the North 180 degrees (here is not exactly according to the Earth North and South only 90 degrees), the midpoint of the equator and central Meridian intersection, its coding for T.

When the zoom=2 of the second level of coding, that is, from the midpoint began to be divided into equal parts from top to bottom, starting from the left on the clockwise direction of the upper left Q, upper right R, lower right s, lower left T, each block of code is: Tq,tr,ts,tt.

And so on, each increase in the first level of code, magnified by one times, each piece is divided into four blocks for the next level of coding, coding in the first group of code on the basis of a separate plus q,r,s,t. That is, the first level of the code consists of a letter, two-level code consists of two letters, three level by three letters, the other level, and so on, different regions to provide download the number of layers of graph, can be divided into 21 levels.

For the management of all of the world's health films, this coding method is the best, is a typical pyramid index coding method, the use of this encoding to get a certain number of blocks, seemingly to the number of string generation calculation, in fact, this encoding method for the number can be numeric plus or minus can be directly calculated, Then do a numeric and character conversion. This is very quick and convenient for finding, translating, locating and so on.

The JavaScript code is as follows:

1function Getquadtreeurl_ (lon, LAT)
2{
3 var PI = 3.1415926535897;
4 var digits = 18; How many digits precision
5//Now convert to normalized square coordinates
6//Standard equations to map into Mercator projection
7 var x = (180.0 + parsefloat (lon))/360.0;
8 var y =-parsefloat (lat) * pi/180; Convert to radians
9
y = 0.5 * Math.log ((1+math.sin (Y))/(1-math.sin (y)));
11
Y *= 1.0/(2 * PI); Scale factor from radians to normalized
y = 0.5; and make Y range from 0-1
14
var quad = "T"; Google addresses start with T
var lookup = "Qrts"; TL tr. BL BR
17
while (digits–) {
A/Make sure we only look at the fractional part
x = Math.floor (x);
Y-= Math.floor (y);
Quad = Quad + lookup.substr ((x >= 0.5? 1:0) + (y >= 0.5? 2:0), 1);
Descend/now to that square
x *= 2;
Y *= 2;
26}
return quad;
28}

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.