hmbb
路人甲
路人甲
  • 注册日期2005-10-10
  • 发帖数12
  • QQ
  • 铜币170枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1525回复:2

由经纬度计算Google卫星地图中瓦片Tile的地址

楼主#
更多 发布于:2009-02-14 15:26
<TABLE cellSpacing=0 cellPadding=0>

<TR>
<TD>推荐一个小工具:<a href="http://www.muqingshuihua.cn/tools/GoogleSatelliticTrace.html" target="_blank" ><FONT color=#810081>http://www.muqingshuihua.cn/tools/GoogleSatelliticTrace.html</FONT></A> 在这个工具中输入经纬度数据,就可以逐级显示包含该经纬度的Google卫星图片。<BR><BR>Google卫星地图是由256x256大小的jpg图片拼接而成,每块图片的URL格式为“<a href="http://www.muqingshuihua.cn/post/2276.html" target="_blank" ><FONT color=#810081>http://kh.google.com/kh?v=3;t=trstrq</FONT></A>”样。参数v与图片关系不大,主要是参数t起作用,它是“qrst”4个字符排列而成的字符串。为获取某经纬度的URL,就需要把经纬度转化为“qrst”字符串。 Google卫星地图在zoom=1时,全球就为一个256x256的图片,它的中心经纬度为(0,0),URL为“<a href="http://www.muqingshuihua.cn/post/2276.html" target="_blank" ><FONT color=#810081>http://kh.google.com/kh?v=3;t=t</FONT></A>”。zoom=2时裂化为4块,每块的编号为:左上”t=tq”,右上”t=tr”,右下“t=ts”,左下”t=tt”。依此类推,每放大一倍,每一小块都裂分为四,从左上到右下顺时针按qrst编号,裂分后的编码为裂分前的编号上小块的编号。<BR><BR><BR>计算代码如下:<BR><BR>function GetQuadtreeAddress(long, lat)<BR>{<BR>var PI = 3.1415926535897;<BR>var digits = 18; // how many digits precision<BR>// now convert to normalized square coordinates<BR>// use standard equations to map into mercator projection<BR>var x = (180.0 + parseFloat(long)) / 360.0;<BR>var y = -parseFloat(lat) * PI / 180; // convert to radians<BR>y = 0.5 * Math.log((1+Math.sin(y)) / (1 - Math.sin(y)));<BR>y *= 1.0/(2 * PI); // scale factor from radians to normalized<BR>y += 0.5; // and make y range from 0 - 1<BR>var quad = "t"; // google addresses start with t<BR>var lookup = "qrts"; // tl tr bl br<BR>while (digits–)<BR>{<BR>// make sure we only look at fractional part<BR>x -= Math.floor(x);<BR>y -= Math.floor(y);<BR>quad = quad + lookup.substr((x >= 0.5 ? 1 : 0) + (y >= 0.5 ? 2 : 0), 1);<BR>// now descend into that square<BR>x *= 2;<BR>y *= 2;<BR>}<BR>return quad;<BR>}</TD></TR></TABLE>
喜欢0 评分0
zhouning
路人甲
路人甲
  • 注册日期2006-08-10
  • 发帖数10
  • QQ
  • 铜币90枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2009-02-14 16:06
学习了 呵呵!<img src="images/post/smile/dvbbs/em01.gif" />
举报 回复(0) 喜欢(0)     评分
zzj9189
路人甲
路人甲
  • 注册日期2003-08-30
  • 发帖数131
  • QQ
  • 铜币413枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2009-05-06 15:48
纯粹学习
举报 回复(0) 喜欢(0)     评分
游客

返回顶部