google_static_maps_api.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:mapsplotlib 作者: tcassou 项目源码 文件源码
def get_zoom(cls, latitudes, longitudes, size, scale):
        """Compute level of zoom needed to display all points in a single tile.

        :param pandas.Series latitudes: set of latitudes
        :param pandas.Series longitudes: set of longitudes
        :param int size: size of the tile
        :param int scale: 1 or 2 (free plan), see Google Static Maps API docs

        :return: zoom level
        :rtype: int
        """
        # Extreme pixels
        min_pixel = cls.to_pixel(latitudes.min(), longitudes.min())
        max_pixel = cls.to_pixel(latitudes.max(), longitudes.max())
        # Longitude spans from -180 to +180, latitudes only from -90 to +90
        amplitudes = (max_pixel - min_pixel).abs() * pd.Series([2., 1.], index=['x_pixel', 'y_pixel'])
        return int(np.log2(2 * size / amplitudes.max()))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号