bounds.py 文件源码

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

项目:cyphon 作者: dunbarcyber 项目源码 文件源码
def buffer(self, buffer_m):
        """
        Takes a buffer distance in meters and extends the bounds by that
        distance. Uses the average latitude of the current bounds to calculate
        new latitude bounds. Over extremely large latitude bounds, the results
        will lose accuracy.
        """
        calculator = vincenty(meters=buffer_m)

        ave_lng = (self.w_lng + self.e_lng) / 2
        ave_lat = (self.n_lat + self.s_lat) / 2

        self.n_lat = calculator.destination((self.n_lat, ave_lng), 0).latitude
        self.s_lat = calculator.destination((self.s_lat, ave_lng), 180).latitude
        self.e_lng = calculator.destination((ave_lat, self.e_lng), 90).longitude
        self.w_lng = calculator.destination((ave_lat, self.w_lng), 270).longitude

        return self
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号