Google Earth卫星地图URL的计算方法及代码实例
Google卫星地图在zoom=1时,全球就为一个256x256的图片,它的中心经纬度为(0,0),URL为“http://kh.google.com/kh?v=2&t=t”。zoom=2时裂化为4块,每块的编号为:左上”t=tq”,右上”t=tr”,右下“t=ts”,左下”t=tt”。依此类推,每放大一倍,每一小块都裂分为四,从左上到右下顺时针按qrst编号,裂分后的编码为裂分前的编号上小块的编号
Google卫星地图是由256x256大小的jpeg图片拼接而成,每块图片的URL格式为“http://kh.google.com/kh?v=2&t=trstrqqstsrqttsttq”样。参数v与图片关系不大,主要是参数t起作用,它是“qrst”4个字符排列而成的字符串。为获取某经纬度的URL,就需要把经纬度转化为“qrst”字符串。
两个代码如下
Gmap URL_JS
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;
}
Gmap URL_Delphi
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;
最新文章
- WebGIS技术剖析-主动/动态WebGIS及 [08-24]
- 图像服务和网络地图集成方案ER Map [11-25]
- Ajax机制与Ajax模型探讨及基于Ajax [11-09]
- Google Earth卫星地图URL的计算方法 [11-09]
- 基于Ajax+Servlet架构的WebGIS服务 [10-20]
- 介绍两种基于JAVA的WebGIS服务器设 [10-20]
- 深入研究:使用ArcXML扩展ArcIMS Ma [09-22]
- 如何使用ArcIMS构建Google Maps风格 [09-22]
- 经验之谈:ArcIMS中文显示乱码问题的 [09-22]
- 如何使用ArcIMS和JSP发布地图服务 [09-22]
推荐文章


热点文章
Ajax机制与Ajax模型探讨及基于Aj
基于Ajax+Servlet架构的WebGIS服
Google Earth卫星地图URL的计算方
如何使用ArcIMS构建Google Maps风
教程:基于MapServer的WebGIS开发
深入研究:使用ArcXML扩展ArcIMS
如何使用ArcIMS和JSP发布地图服务
网络GIS(WebGIS)的主要发展趋势及
介绍两种基于JAVA的WebGIS服务器
基础教程之:ArcIMS HTML Viewer的
资料:基于GeoMedia WebMap的WebG
arcims开发经验总结之arcIMS客户
Arcims开发经验总结之地图放大缩
示例如何用SVG技术实现基于网络的
辅导WebGIS客户端和服务器各自的
ArcIMS体系结构详细介绍
ArcIMS学习之 HTML Viewer定制笔
经验之谈:ArcIMS中文显示乱码问题
欲开发基于arcims的webgis需要掌
WebGIS技术剖析-主动/动态WebGIS
图像服务和网络地图集成方案ER M

