How can I get Tile Count, Tile X, Tile Y details without specifying zoom Level (or LevelOfDetails)?

前端 未结 3 2130
孤独总比滥情好
孤独总比滥情好 2021-01-01 03:20

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 k

3条回答
  •  庸人自扰
    2021-01-01 04:15

    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.

提交回复
热议问题