[转]由经纬度计算Google卫星地图中瓦片Tile的地址
2011-02-24 01:38
295 查看
在网上转悠了转悠,看到了一篇文章,记得以前从哪里看过,贴一下,将来理理这类信息包。
转自:http://www.cnblogs.com/powermap/archive/2009/07/07/1518588.html
Google卫星地图是由256x256大小的jpg图片拼接而成,每块图片的URL格式为“http://kh.google.com/kh?v=3&t=trstrq”样。参数v与图片关系不大,主要是参数t起作用,它是“qrst”4个字符排列而成的字符串。为获取某经纬度的URL,就需要把经纬度转化为“qrst”字符串。 Google卫星地图在zoom=1时,全球就为一个256x256的图片,它的中心经纬度为(0,0),URL为“http://kh.google.com/kh?v=3&t=t”。zoom=2时裂化为4块,每块的编号为:左上”t=tq”,右上”t=tr”,右下“t=ts”,左下”t=tt”。依此类推,每放大一倍,每一小块都裂分为四,从左上到右下顺时针按qrst编号,裂分后的编码为裂分前的编号上小块的编号。
计算代码如下:
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
y = 0.5 * Math.log((1+Math.sin(y)) / (1 - Math.sin(y)));
y *= 1.0/(2 * PI); // scale factor from radians to normalized
y += 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
x -= Math.floor(x);
y -= Math.floor(y);
quad = quad + lookup.substr((x >= 0.5 ? 1 : 0) + (y >= 0.5 ? 2 : 0), 1);
// now descend into that square
x *= 2;
y *= 2;
}
return quad;
}
转自:http://www.cnblogs.com/powermap/archive/2009/07/07/1518588.html
Google卫星地图是由256x256大小的jpg图片拼接而成,每块图片的URL格式为“http://kh.google.com/kh?v=3&t=trstrq”样。参数v与图片关系不大,主要是参数t起作用,它是“qrst”4个字符排列而成的字符串。为获取某经纬度的URL,就需要把经纬度转化为“qrst”字符串。 Google卫星地图在zoom=1时,全球就为一个256x256的图片,它的中心经纬度为(0,0),URL为“http://kh.google.com/kh?v=3&t=t”。zoom=2时裂化为4块,每块的编号为:左上”t=tq”,右上”t=tr”,右下“t=ts”,左下”t=tt”。依此类推,每放大一倍,每一小块都裂分为四,从左上到右下顺时针按qrst编号,裂分后的编码为裂分前的编号上小块的编号。
计算代码如下:
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
y = 0.5 * Math.log((1+Math.sin(y)) / (1 - Math.sin(y)));
y *= 1.0/(2 * PI); // scale factor from radians to normalized
y += 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
x -= Math.floor(x);
y -= Math.floor(y);
quad = quad + lookup.substr((x >= 0.5 ? 1 : 0) + (y >= 0.5 ? 2 : 0), 1);
// now descend into that square
x *= 2;
y *= 2;
}
return quad;
}
相关文章推荐
- 由经纬度计算Google卫星地图中瓦片Tile的地址
- 由经纬度计算Google卫星地图中瓦片Tile的地址
- Google卫星地图的URL计算
- Google卫星地图的URL计算
- 一个可以地址和各种格式的经纬度查询互换的网址,支持百度、高德、Google等地图对比查询。
- google V3实例化地图,标点,画线(卫星模式地址不匹配是因为引入google的js时少了®ion=cn)
- 如何用JAVA获取GOOGLE 地图经纬度,地址信息
- 也说Google卫星地图的URL地址的qrts编码算法
- C# 根据经纬度得到GOOGLE瓦片地址
- google离线地图实例,加载本地地图瓦片, 支持点线面及图文标注,坐标定位,卫星、电子地图切换
- 百度地图API接口 地图标注 地址经纬度解析
- google,百度,yahoo,msn,ASK网址登录和网站地图提交地址
- iOS 地图根据经纬度计算距离的方法
- Python计算地图上两点经纬度间的距离
- 根据经纬度调用Google地图显示对应位置
- CLLocationManager定位经纬度,MKReverseGeocoder地址解析, MKMapView 地图显示 iphone
- Android Map Api 使用和开发(2) 定位我的位置、地图弹出泡泡、通过经纬度获取地址
- google经纬度转地址
- [转]Google的卫星地图将让你"偷窥"到世界的每个角落
- google根据地址获取经纬度