您的位置:GIS门户网 GIS开发 正文
GIS网内容搜索
GIS网热门内容
GIS网推荐内容
GIS网最新内容
提出意见和建议

How Google Map Works

GIS门户网提示:本文章共3161字,分2页,当前第1页,快速翻页:
 

版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://gisblog.cn.blogbus.com/logs/4647946.html

 

introduction

This is my analyse about how google map works, et specially how the tiles are encoded. Google map uses pre-rendered tiles that can be obtained with a simple url. This article explains how to build the url for a tile from its geo coordinates (latitude/longitude)

Map Tile Encoding

Google map uses two differents algorithms to encode the location of the tiles.

For Google map, the url of a tile looks like : http://mt1.google.com/mt?n=404&v=w2.12&x=130&y=93&zoom=9 using x and Y for the tile coordinates, and a zoom factor. The zoom factor goes from 17 (fully zoomed out) to 0 (maximum definition). At a factor 17, the whole earth is in one tile where x=0 and y=0. At a factor 16, the earth is divided in 2x2 parts, where 0<=x<=1 and 0<=y<=1. and at each zoom step, each tile is divided into 4 parts. So at a zoom factor Z, the number of horizontal and vertical tiles is 2^(17-z)

Algorithm : to find a tile from a latitude, a longitude and a zoom factor :

//correct the latitude to go from 0 (north) to 180 (south),
// instead of 90(north) to -90(south)
latitude=90-latitude;

//correct the longitude to go from 0 to 360
longitude=180+longitude;

//find tile size from zoom level
double latTileSize=180/(pow(2,(17-zoom)));
double longTileSize=360/(pow(2,(17-zoom)));

//find the tile coordinates
int tilex=(int)(longitude/longTileSize);
int tiley=(int)(latitude/latTileSize);

In fact this algorithm is theorical as the covered zone doesn't match the whole globe.

Servers :

google uses 4 servers to balance the load. these are mt0, mt1, mt2 and mt3.

Tile size :

each tile is a 256x256 png picture.

For satellite Images, the encoding is a bit different.

the url looks like : http://kh0.google.com/kh?n=404&v=8&t=trtqtt the 't' parametres encodes the image location. The length of the parametre indicates a zoom level.

To see the whole globe, just use 't=t'. This gives a single tile representing the earth. For the next zoom level, this tile is divided into 4 quadrants, called, clockwise from top left : 'q' 'r' 's' and 't'. To see a quadrant, just append the letter of that quadrant to the image you are viewing. For example :'t=tq' will give the upper left quadrant of the 't' image. And so on at each zoom level...

algorithm : to find a tile from a latitude, a longitude and a zoom factor :

Collapse
//initialise the variables;
double xmin=-180;
double xmax=180;
double ymin=-90;
double ymax=90;
double xmid=0;
double ymid=0;

string location="t";

//google use a latitude divided by 2;
double halflat = latitude / 2;
for (int i = 0; i < zoom; i++)
{
xmoy = (xmax + xmin) / 2;
ymoy = (ymax + ymin) / 2;
if (halflat > ymoy) //upper part (q or r)
{
ymin = ymoy;
if (longitude < xmoy)
{ /*q*/
location+= "q";
xmax = xmoy;
}
else
{/*r*/
location+=
 

收藏本页:

点这里复制本页地址发送给您QQ/MSN上的好友
相关文章

VC++中的Win32 Application和Win32 Console
在VC中怎样实现软件的注册机制
(转)如何使应用程序只运行一个实例
如何实现API钩子
ArcView GIS 应用与开发技术(3)-地理要素
ArcView GIS 应用与开发技术(2)-Tables
ArcView GIS 应用与开发技术(1)-View&Th
win2003_iis6服务器设置排错解答
C++ class中的静态(static)成员
你应当如何学习C++(以及编程)(长,精)
实验:居心叵测的Chrome?
GoogleEarth二次开发难点和技巧
程序人生
SAAS,GIS软件的未来?
地图坐标与屏幕坐标的转换
google map api中的事件名称和描述
MapXtreme产品介绍
asp读取和写入xml简单教程+实例

相关评论


GIS门户网提示:本文章所属分类:首页 GIS开发
GIS

GIS