gpt4 book ai didi

android - 从 latlng 返回的图 block 坐标?

转载 作者:搜寻专家 更新时间:2023-11-01 08:03:05 30 4
gpt4 key购买 nike

我正在使用这两个函数将 latlng 转换为图 block 坐标。我无法理解的是在缩放级别 1 时是否有 4 个图 block 。那么这些坐标属于哪些瓦片?或者这些属于左上?

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;
}

此示例中使用了相同类型的公式:

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

最佳答案

很可能是它的左上角图 block 。当您想分割 map 时,使用四叉树会很有用,因此缩放级别 1 有 4 个图 block 。寻找 bing map 四键解决方案:http://msdn.microsoft.com/en-us/library/bb259689.aspx .但是谷歌地图对图 block 使用 x,y 对:How can I get Tile Count, Tile X, Tile Y details without specifying zoom Level (or LevelOfDetails)? .在缩放级别 0 中,在缩放级别 1 中有 1 个图 block ,您可以在两侧看到 4 个图 block 和一些图 block ,等等。链接: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: TileProvider method getTile - need to translate x and y to lat/long .但您也可以在 Bing 和 Google map 之间进行转换。替换四键值如下:0=q, 1=r, 2=t, 3=s (?), maybe also 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 .

更新 2:网址 http://kh.google.com已死,但您仍然可以使用代码段:

    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

在 map 中,曲线从右上角开始到右下角到左下角到左上角。因此它看起来像一个倒U形?也许我错了,它是左上角、右上角、左下角、右下角?然后是Z字形。那么 lat,lng 对在左上角的图 block 中?

为了获得边界框,我假设 long 和 lat 以秒为单位给出。

首先,您需要以秒为单位计算矩形的宽度。一秒在赤道上是 30.9 米,对于其他纬度,乘以 cos(lat),因此要将其转换为秒,请执行以下操作:

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

其次,知道了盒子的中心,就很容易计算出角的坐标:

enter image description here

1 BoundingBox around a geo coordinate

关于android - 从 latlng 返回的图 block 坐标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18252120/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com