如何在不指定缩放级别(或 LevelOfDetails)的情况下获取图块计数、图块 X、图块 Y 详细信息?

发布于 2024-09-09 11:13:30 字数 159 浏览 0 评论 0原文

这是参考 Google Tile 地图或 Bing 地图。是否可以在不通过任何类型的内部计算指定缩放级别(或 LevelOfDetails)的情况下获取图块计数、图块 X、图块 Y 详细信息?

客户只需提供坐标 P1 和 P2,并要求提供图块地图和边界框等

。Shilpa

This is with reference to Google Tile Map or Bing Maps. Is it possible to get Tile Count, Tile X, Tile Y details without specifying zoom Level (or LevelOfDetails) with any kind of internal calculations?

Client will give just Coordinates P1 and P2 and ask for a Tile Map and Bound Box, etc.

Shilpa

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

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

发布评论

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

评论(3

故事灯 2024-09-16 11:13:30

每个图块为 256 像素 x 256 像素。

缩放级别 0 为 1 个瓦片。 (1 x 1)

缩放级别 1 为 4 个图块。 (2 x 2)

缩放级别 2 为 16 个图块。 (4 x 4)

缩放级别 3 为 64 个图块。 (8 x 8)

缩放级别 4 为 256 个图块 (16 x 16)

每个缩放级别的 x 和 y 计数加倍。根据 88ad 的评论,图块数量的公式为 (2^zoom x 2^zoom)。

我希望您可以通过缩放级别 18 完成其余的数学运算。为了节省空间,不存储海洋图块。它们是作为对请求的响应而创建的。

在缩放级别 3 下,图块在 x 方向(经度)上编号为 0 到 7,在 y 方向(纬度)上编号为 0 到 7。

这些图块从国际日期变更线附近的美国一侧(东经-180 或+180)开始。瓦片 0,0 从大约北纬 70 度开始。

有关球体如何映射到平面的更多详细信息,请参阅维基百科文章 墨卡托投影。维基百科文章中提供了将经度和纬度转换为 x 和 y 坐标的计算方法。

您可以将墨卡托投影上的任何点映射到图块集。图块集是缩放级别的图块集。您必须知道缩放级别才能知道要访问哪个图块集并计算要检索和显示图块集中的哪个图块。

这篇博文 Google 地图 给出了转换公式(纬度、经度、缩放比例) ) 到 (x, y, 缩放),其中 x 和 y 表示缩放集中的图块。

Each tile is 256 pixels by 256 pixels.

Zoom level 0 is 1 tile. (1 x 1)

Zoom level 1 is 4 tiles. (2 x 2)

Zoom level 2 is 16 tiles. (4 x 4)

Zoom level 3 is 64 tiles. (8 x 8)

Zoom level 4 is 256 tiles (16 x 16)

The x and y counts are doubled for each zoom level. Per 88ad's comment, the formula for the number of tiles is (2^zoom x 2^zoom).

I hope you can do the rest of the math through zoom level 18. To save space, ocean tiles aren't stored. They're created as a response to the request.

At zoom level 3, the tiles are numbered from 0 to 7 in the x direction (longitude) and numbered from 0 to 7 in the y direction (latitude).

The tiles start on the American side of near the International Date Line (longitude -180 or +180). The tile 0,0 starts at about latitude 70 north.

See the Wikipedia article Mercator Projection for more details about how a sphere is mapped to a plane. The calculations for converting longitude and latitude to x and y coordinates are in the Wikipedia article.

You can map any point on the Mercator Projection to a tile set. A tile set is the set of tiles at a zoom level. You have to know the zoom level to know which tile set to access and to calculate which tile in the tile set to retrieve and display.

This blog post, Google Mapping, gives the formula for converting (latitude, longitude, zoom) to (x, y, zoom), where x and y represent the tile from the zoom set.

や莫失莫忘 2024-09-16 11:13:30

您可能想查看 OSM 图块名称的 wiki。除了 y 轴方向外,它们与 googletile 几乎相同。带有大量代码示例的描述在这里: http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames

You may want to check out wiki of OSM tilenames. They are almost the same as google tiles except of y axis direction. Description with a lot of code examples is here: http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames

酒废 2024-09-16 11:13:30

如果您有边界框,您可以使用此 python 函数来查找缩放级别(或您选择的编程语言中的类似函数):

def level_dic():
    '''
    http://wiki.openstreetmap.org/wiki/Zoom_levels
    '''
    data = {0: 360.0,
        1: 180.0,
        2: 90.0,
        3: 45.0,
        4: 22.5,
        5: 11.25,
        6: 5.625,
        7: 2.813,
        8: 1.406,
        9: 0.703,
        10: 0.352,
        11: 0.176,
        12: 0.088,
        13: 0.044,
        14: 0.022,
        15: 0.011,
        16: 0.005,
        17: 0.003,
        18: 0.001,
        19: 0.0005}

    return data


def getzoom(self):
    data = level_dic()  # our presets
    a, b, c, d = bbox
    r = 3
    dne = abs(round(float(c) - float(a), r))  # ne: North East point
    mylist = [round(i, r) for i in data.values()] + [dne]
    new = sorted(mylist, reverse=True)
    return new.index(dne)

我使用 此参考。其余的很简单。您需要使用Slippy_map_tilenames

If you have a bounding box, you can use this python function for finding zoom level (or similar function in your programming language choice):

def level_dic():
    '''
    http://wiki.openstreetmap.org/wiki/Zoom_levels
    '''
    data = {0: 360.0,
        1: 180.0,
        2: 90.0,
        3: 45.0,
        4: 22.5,
        5: 11.25,
        6: 5.625,
        7: 2.813,
        8: 1.406,
        9: 0.703,
        10: 0.352,
        11: 0.176,
        12: 0.088,
        13: 0.044,
        14: 0.022,
        15: 0.011,
        16: 0.005,
        17: 0.003,
        18: 0.001,
        19: 0.0005}

    return data


def getzoom(self):
    data = level_dic()  # our presets
    a, b, c, d = bbox
    r = 3
    dne = abs(round(float(c) - float(a), r))  # ne: North East point
    mylist = [round(i, r) for i in data.values()] + [dne]
    new = sorted(mylist, reverse=True)
    return new.index(dne)

I used this reference. The rest is simple. You need to use Slippy_map_tilenames.

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