我试着去计算边界框的中心,这些给定的点如何计算边界框的中心?
(50.607041876988994, -1.3187316344406208, 52.40735812301099, 1.5737316344406207)
编辑解决:这是我的代码在python做
from math import cos, sin, atan2, sqrt
def center_geolocation(geolocations):
"""
Provide a relatively accurate center lat, lon returned as a list pair, given
a list of list pairs.
ex: in: geolocations = ((lat1,lon1), (lat2,lon2),)
out: (center_lat, center_lon)
"""
x = 0
y = 0
z = 0
for lat, lon in geolocations:
lat = float(lat)
lon = float(lon)
x += cos(lat) * cos(lon)
y += cos(lat) * sin(lon)
z += sin(lat)
x = float(x/len(geolocations))
y = float(y/len(geolocations))
z = float(z/len(geolocations))
return (atan2(y, x), atan2(z, sqrt(x * x + y * y)))
谢谢:)
你传递给函数的参数是什么? –
我试着通过我的计算边框(50.607041876988994,-1.3187316344406208,52.40735812301099,1.5737316344406207) –