从cloudmade下载图块时出现问题

发布于 2024-10-01 05:17:10 字数 62 浏览 8 评论 0原文

我需要下载指定区域的图块。我有一个带有纬度/经度坐标的 bbox,但是如何将它们转换为 URL 所需的 x/y

I need download tiles for specified area. I have a bbox with lat/long coordinates, but how convert them to x/y which are required by URL

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

东风软 2024-10-08 05:17:10

要计算出给定纬度和经度所需的图块,您首先需要选择您感兴趣的缩放级别。然后计算:

n = 2 ^ zoom
xtile = ((lon_deg + 180) / 360) * n
ytile = (1 - (ln(tan(lat_rad) + sec(lat_rad)) / Pi)) / 2 * n

注意:ln 代表自然对数
对 xtile 和 ytile 进行向下舍入以获得整数图块编号。
如果您需要走另一条路:

n = 2 ^ zoom
lon_deg = xtile / n * 360.0 - 180.0
lat_rad = arctan(sinh( Pi * (1 - 2 * ytile / n)))
lat_deg = lat_rad * 180.0 / Pi

这应该足以让您启动并运行。要获得任何 CloudMade API 的帮助并了解我们的最新版本,请查看开发人员邮件列表。

To work out which tile you need for a given latitude and longitude, you first need to pick a zoom level that you're interested in. Then calculate:

n = 2 ^ zoom
xtile = ((lon_deg + 180) / 360) * n
ytile = (1 - (ln(tan(lat_rad) + sec(lat_rad)) / Pi)) / 2 * n

Note: ln stands for natural logarithm
round down xtile and ytile to get the integer tile numbers.
If you need to go the other way:

n = 2 ^ zoom
lon_deg = xtile / n * 360.0 - 180.0
lat_rad = arctan(sinh( Pi * (1 - 2 * ytile / n)))
lat_deg = lat_rad * 180.0 / Pi

That should be enough to get you up and running. To get help with any of CloudMade's APIs and to keep up-to-date with our latest releases, take a look at the developers mailing list.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文