KingOfWesteros

Monitoria

Apr 30th, 2021
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.93 KB | None | 0 0
  1. #####################################################################
  2. def menor(listaDePostos):
  3.   # print("LISTA DE POSTOS",listaDePostos)
  4.   auxiliar    = listaDePostos[:]
  5.   auxiliar.sort()               #Ordena de forma crescente
  6.   menorValor  = auxiliar[0]
  7.   #return [(n, listaDePostos[n]) for n, x in enumerate(listaDePostos) if x==menorValor]
  8.   indiceValor = listaDePostos.index(menorValor)
  9.   idByIndice  = indiceValor + 1
  10.   print("LISTA AUXILIAR", auxiliar)
  11.   return (idByIndice)
  12.           #, menorValor)
  13. #####################################################################
  14.  
  15.  
  16. #####################################################################
  17. def calcularposto(latitude_ref,longitude_ref):
  18.   distancia1 = calcularDistancia(latitude_ref, longitude_ref, -21.79143, -46.56805) #posto 1 da planiha
  19.   distancia2 = calcularDistancia(latitude_ref, longitude_ref, -21.78646, -46.57236) #posto 2 da planiha
  20.   distancia3 = calcularDistancia(latitude_ref, longitude_ref, -21.79900, -46.59849) #posto 3 da planiha
  21.   distancia4 = calcularDistancia(latitude_ref, longitude_ref, -21.83674, -46.55918) #posto 4 da planiha
  22.  
  23.   listaDistancia = [distancia1,distancia2,distancia3,distancia4]
  24.  
  25.   for indice, distancia in enumerate(listaDistancia):
  26.     print("DISTANCIA POSTO {}: {}".format(indice+1,distancia))
  27.  
  28.   return menor(listaDistancia) # Passando lista de postos como argumento
  29. #####################################################################
  30.  
  31.  
  32.  
  33. #####################################################################
  34. #####TESTE USANDO LAT E LONG NA MAO FUNCIONA E NA FUNCAO NAO########   bamboo -21.79382778698024, -46.59437556719203
  35. # latitude_ref=-21.79382
  36. # longitude_ref=-46.59437
  37. latitude_ref, longitude_ref = -21.79901, -46.59849
  38. posto = calcularposto(latitude_ref,longitude_ref)
  39. #posto = calcularposto(latitude_ref,longitude_ref)889201021, 084285116
  40. posto
  41. #####################################################################
  42.  
  43.  
Add Comment
Please, Sign In to add comment