本文介绍了给定纬度,经度和距离,我想找到一个边界框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
考虑到纬度,经度和距离,我想找到一个距离小于给定距离的边界框.
Given a latitude and longitude, and distance, I want to find a bounding box where the distances are less than the given distance.
在此处提出了以下问题:如何计算给定纬度/经度位置的边界框?
This questions was asked here: How to calculate the bounding box for a given lat/lng location?
我不希望它在表面上是准确的,所以我将其修改并简化为
I donot want this partcularly accurate, so I have modified and simplified it to
def boundingBox(latitudeInDegrees, longitudeInDegrees, halfSideInKm):
lat = math.radians(latitudeInDegrees)
lon = math.radians(longitudeInDegrees)
halfSide = 1000*halfSideInKm
RADIUS_OF_EARTH = 6371
# Radius of the parallel at given latitude
pradius = radius*math.cos(lat)
latMin = lat - halfSide/radius
latMax = lat + halfSide/radius
lonMin = lon - halfSide/pradius
lonMax = lon + halfSide/pradius
rad2deg = math.degrees
return (rad2deg(latMin), rad2deg(lonMin), rad2deg(latMax), rad2deg(lonMax))
但是我无法理解它是如何工作的,特别是这条线对我来说没有任何意义halfSide = 1000*halfSideInKm
But I cant understand how this is working, in particular this line makes no sense to me halfSide = 1000*halfSideInKm
推荐答案
该行将边界框单位从公里转换为米.
That line is converting the bounding box units from kilometres to metres.
这篇关于给定纬度,经度和距离,我想找到一个边界框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!