error en haversine()
This commit is contained in:
@@ -52,15 +52,15 @@ def convertirMes(mes):
|
||||
|
||||
def haversine(coord1, coord2):
|
||||
r = 6367.45 * 1000 # conversión a metros
|
||||
for i in coord1.keys():
|
||||
coord1[i] = math.radians(coord1[i])
|
||||
coord2[i] = math.radians(coord2[i])
|
||||
|
||||
dlat = coord2['latitud'] - coord1['latitud']
|
||||
dlong = coord2['latitud'] - coord1['longitud']
|
||||
|
||||
dlat = math.radians(dlat)
|
||||
dlong = math.radians(dlong)
|
||||
|
||||
h = math.sin(dlat)**2 + math.cos(dlat) * math.cos(dlong) * math.sin(dlong)**2
|
||||
d = 2 * r * math.asin(math.sqrt(h))
|
||||
return d
|
||||
dlong = coord2['longitud'] - coord1['longitud']
|
||||
h = math.sin(dlat / 2)**2 + math.cos(coord1['latitud']) * math.cos(coord2['latitud']) * math.sin(dlong / 2)**2
|
||||
d = 2 * math.atan2(math.sqrt(h), math.sqrt(1 - h))
|
||||
return d * r
|
||||
|
||||
def convertirSegundos(instante):
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user