从经纬度返回的图块坐标? [英] The tile coordinates returned from latlng?

查看:299
本文介绍了从经纬度返回的图块坐标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用这两个功能,经纬度转换成瓦合ordinates.what我无法理解的是,如果缩放级别为1有4瓦。因此,哪些瓷砖这些坐标是属于哪一种?或者这些属于左上?

I am using these two function to convert latlng to tile co-ordinates.what i am unable to understand is if at zoom level 1 there are 4 tiles. So of which tiles these co-ordinates are belong to? Or these belongs to left-top?

public int langtoTileX(Double lng,int zoom)
{
    double x;
    x = Math.round((256*(Math.pow(2,zoom-1)))+(lng*((256*(Math.pow(2,zoom)))/360)));
    return ((int)(x/256));
}
public int lattoTileY(Double lat,int zoom)
{
    Double exp = Math.sin(lat*Math.PI/180);
    if (exp < -.9999)
        exp = -.9999;
    if (exp > .9999)
        exp = .9999 ;
    return (int) (Math.round (256*(Math.pow(2,zoom-1)))+((.5*Math.log((1+exp)/(1-exp)))*((-256*(Math.pow(2,zoom)))/(2*Math.PI))))/256;
}

的相同类型的结构式的都在本实施例中使用

The same type of formula's are used in this example:

https://developers.google.com/maps/documentation/javascript/examples/map-coordinates

推荐答案

最有可能的左上图块。当你要细分地图也可以是使用一个四叉树,因此有缩放级别为4瓦1.查找Bing地图quadkey解决方案有用:的 http://msdn.microsoft.com/en-us/library/bb259689.aspx 。但是,谷歌地图使用x,y对的瓷砖:<一href=\"http://stackoverflow.com/questions/3238611/how-can-i-get-tile-count-tile-x-tile-y-details-without-specifying-zoom-level\">How我可以得到瓷砖计数,瓷砖X,瓷砖ÿ细节,而无需指定缩放级别(或LevelOfDetails)?。在缩放级别0有1瓦缩放级别为1,你可以看到4瓷砖和两侧有些砖等页链接: http://facstaff.unca.edu/mcmcclur/GoogleMaps/Projections/GoogleCoords.html ,的 http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection

Most likely its top-left tile. When you want to subdivide a map it can be useful to use a quadtree hence there is 4 tiles at zoom level 1. Look for the bing maps quadkey solution: http://msdn.microsoft.com/en-us/library/bb259689.aspx. But Google maps uses a x,y pair for the tiles: How can I get Tile Count, Tile X, Tile Y details without specifying zoom Level (or LevelOfDetails)?. In zoom level 0 there is 1 tile at zoom level 1 you can see 4 tiles and some tiles on both side, etc. pp. Link: http://facstaff.unca.edu/mcmcclur/GoogleMaps/Projections/GoogleCoords.html, http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection.

更新:自X获得边框,y对使用矩形这样的X,X + 1,Y,Y + 1:
<一href=\"http://stackoverflow.com/questions/16883997/tileprovider-method-gettile-need-to-translate-x-and-y-to-lat-long?rq=1\">TileProvider方法getTile - 需要x和y转换为纬度/长。但你也可以Bing和谷歌地图之间进行转换。替代quadkey值如下:0(?)= Q,1 = R 2 = T,3 = S,或许也为0 = Q,1 = R 2 = S,3 = T并将它添加到(?)网址 http://kh.google.com/kh?v=3& ; T = quadkey 。来源: http://dzone.com/snippets/converting-between-2-google

Update: To get the bounding box from x,y pair use a rectangle like this x,x+1,y,y+1: TileProvider method getTile - need to translate x and y to lat/long. But you can also convert between Bing and Google maps. Substitute the quadkey values as follows: 0=q, 1=r, 2=t, 3=s (?), maybe also 0=q, 1=r, 2=s, 3=t (?) and append it to the url http://kh.google.com/kh?v=3&;t=quadkey. Source: http://dzone.com/snippets/converting-between-2-google.

UPDATE2:本网址 http://kh.google.com 是死了,但你仍然可以使用该代码段

Update2: The url http://kh.google.com is dead but you can still use the snippet:

    def quadtree(x,y, zoom):
    out = []
    m = {(0,0):'q', (0,1):'t', (1,0):'r', (1,1):'s'}
    for i in range(17-zoom):
        x, rx = divmod(x, 2)
    y, ry = divmod(y, 2)
    out.insert(0, m[(rx,ry)])
        return 't' + ''.join(out)

     def xyzoom(quad):
         x, y, z = 0, 0, 17
     m = {'q':(0,0), 't':(0,1), 'r':(1,0), 's':(1,1)}
     for c in quad[1:]:
        x = x*2 + m[c][0]
        y = y*2 + m[c][1]
        z -= 1
     return x, y, z

在地图的右上角到右下角的曲线开始左下方移动到左上角。因此,它看起来像一个倒U字形?也许我错了,它的左上,右上,左下,右下?那么它的Z形。那么纬度,经度对是在左上角的瓷砖?

In the map the curve start at the top-right corner to bottom-right to bottom-left to top-left. Hence it looks like a reverse U-shape? Maybe I'm wrong and it's top-left, top-right, bottom-left, bottom-right? Then it's a Z-shape. Then the lat,lng pair is in the top-left tile?

要获得边框,我认为长和纬度都在几秒钟内给出。

To get the bounding box, I assume that long and lat are given in seconds.

首先,你需要计算以秒为矩形的宽度。一秒赤道30.9米,其他纬度,通过COS(LAT)大量繁殖,所以将其转换为秒你做到以下几点:

First, you need to calculate width of the rectangle in seconds. One second is 30.9 meters on the equator, for other latitudes, multiply by cos(lat), so to convert it to seconds you do the following:

double widthSeconds = meters / (30.9 * cos(lat));

二,知道了框的中心,很容易计算出角的坐标:

Second, knowing the center of the box, it's easy to calculate the coordinates of corners:

1 <一个href=\"http://stackoverflow.com/questions/17955800/boundingbox-around-a-geo-coordinate/17955995#17955995\">BoundingBox围绕一个地理坐标

这篇关于从经纬度返回的图块坐标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆