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
评论列表
文章目录