Google卫星地图的URL计算

Google卫星地图是由256x256大小的jpeg图片拼接而成,每块图片的URL格式为“http://kh.google.com/kh?v=2&t=trstrqqstsrqttsttq”样。参数v与图片关系不大,主要是参数t起作用,它是“qrst”4个字符排列而成的字符串。为获取某经纬度的URL,就需要把经纬度转化为“qrst”字符串。 Google卫星地图在zoom=1时,全球就为一个256x256的图片,它的中心经纬度为(0,0),URL为“http://www.liuma.net/vr360map/getmap.asp?ttt=t”。zoom=2时裂化为4块,每块的编号为:左上”t=tq”,右上”t=tr”,右下“t=ts”,左下”t=tt”。依此类推,每放大一倍,每一小块都裂分为四,从左上到右下顺时针按qrst编号,裂分后的编码为裂分前的编号上小块的编号。

摘录一个网页:http://intepid.com/stuff/gmkh/,在这个网页上输入一个坐标和缩放级别就可以显示地图,并显示从世界图到详细图的逐层计算。

摘录两个代码,一个是上面这个网页中的JS代码,一个是小百合论坛上说的另一中Delphi的算法。 

function GetQuadtreeAddress(long, lat)
{
var PI = 3.1415926535897;
var digits = 18// how many digits precision
//
 now convert to normalized square coordinates
//
 use standard equations to map into mercator projection
var x = (180.0 + parseFloat(long)) / 360.0;
var y = -parseFloat(lat) * PI / 180// convert to radians
= 0.5 * Math.log((1+Math.sin(y)) / (1 - Math.sin(y)));
*= 1.0/(2 * PI); // scale factor from radians to normalized
+= 0.5// and make y range from 0 - 1
var quad = "t"// google addresses start with t
var lookup = "qrts"// tl tr bl br
while (digits–)
{
// make sure we only look at fractional part
-= Math.floor(x);
-= Math.floor(y);
quad 
= quad + lookup.substr((x >= 0.5 ? 1 : 0+ (y >= 0.5 ? 2 : 0), 1);
// now descend into that square
*= 2;
*= 2;
}

return quad;
}


function getSatURL(zoom: integer; X, Y: double): string;
var
  wx, wy, cx, cy: 
double;
  tid: 
string;
  i: integer;
begin
  cx :
= 0;
  cy :
= 0;
  wx :
= 180;
  wy :
= 180;
  tid :
= 't';

  
for i := 1 to zoom-1 do
  begin
    
if (x >= cx) and (y >= cy) then
    begin
      tid :
= tid + 'r';
      cx :
= cx + wx / 2;
      cy :
= cy + wy / 2;
    end
    
else if (x >= cx) and (y < cy) then
    begin
      tid :
= tid + 's';
      cx :
= cx + wx / 2;
      cy :
= cy - wy / 2;
    end
    
else if (x < cx) and (y < cy) then
    begin
      tid :
= tid + 't';
      cx :
= cx - wx / 2;
      cy :
= cy - wy / 2;
    end
    
else
    begin
      tid :
= tid + 'q';
      cx :
= cx - wx / 2;
      cy :
= cy + wy / 2;
    end;
    wx :
= wx / 2;
    wy :
= wy / 2;
  end;
  result :
= 'http://kh.google.com/kh?v=2&t=' + tid;
end;

 

google map的图片

Google的地图,当然我这里说的是卫星影像

可以用下面的方式浏览

http://www.liuma.net/vr360map/getmap.asp?ttt=t

这个图是整个地球的图

地图的每一块都被同样的大小的四块地图代替了,这样分解下去,大概有20层,第二十层是清晰度最高的一层了,分解顺序如下

qr
ts

于是上面的图的第二层是


http://kh1.google.com/kh?n=404&v=5&t=tq

http://kh1.google.com/kh?n=404&v=5&t=tr

http://kh1.google.com/kh?n=404&v=5&t=tt

http://kh1.google.com/kh?n=404&v=5&t=ts

这样逐步下去,就构成了多分辨率的影像金字塔结构,而且Google的Map Api中提供了完整的影像金字塔区块坐标转换的完整公式及应用

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值