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