[英]How do I convert the (x,y) coordinates of a point on the road in its image coordinates, to its (x,y) coordinates in the world coordinates?
[英]How do I convert the x, y, and zoom coordinates of a map tile to the corresponding coordinates in a quadtree map system?
我正在尝试从Web服务访问地图图块。
磁贴以这样的四叉树形式组织。 在文件系统中,将它们组织起来,例如3/0/0/1/1/2.png
指的是从基点开始,在第三个象限下,然后是第0个象限,然后是第0个象限以及所以第四。
在我的应用程序中,要求我提供地图图块的x,y和zoom值,并且我必须返回一个URL。 如何将这些值转换为上述文件路径格式?
我找到了这个python脚本,该脚本声称可以将x,y和zoom值转换为可以以某种方式用于访问给定图块的google maps图块标识符,但是我不知道如何修改它以所需的格式输出:
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)
这是一个示例执行:
>>> quadtree(20,49,10)
'tqtsqrqt'
我想发生的事情:
>>> quadtree(5,3,3)
'2/1/3'
显然这不是我想要的输出,但是这似乎是一个起点(我想)。
我将采用任何编码语言(或伪代码)提出解决方案或建议。
您可以分别用0、1、2和3替换'q','t','r'和's'。
有一个小的PyPi软件包可以帮助转换。 https://pypi.python.org/pypi/pyGeoTile
它来自Github上的pyGeoTile存储库。 https://github.com/geometalab/pyGeoTile
这是一个用法示例:
from pygeotile.tile import Tile
tms_x, tms_y, zoom = 134494, 329369, 19
tile = Tile.from_tms(tms_x=tms_x, tms_y=tms_y, zoom=19) # Tile Map Service (TMS) X Y and zoom
print('QuadTree: ', tile.quad_tree) # QuadTree: 0302222310303211330
print('Google: ', tile.google) # Google: (134494, 194918)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.