error en haversine()

This commit is contained in:
binlaab
2025-12-09 11:43:35 +01:00
parent 77fef039e0
commit f5ce288871

View File

@@ -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: