Guest User

Untitled

a guest
Sep 10th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 0.63 KB | None | 0 0
  1.  def getAgentsDistanceFromUser(double userLat, double userLon) {
  2.         //List agents = Agent.findAllByLatitiudeBetweenAndLongitudeBetween(userLat-1,userLat+1,userLon-1,userLon+1)
  3.         List agents = Agent.findAll()
  4.         List listOfDistances =[]
  5.         Map agentsAndDistances = [:]
  6.        
  7.         agentsAndDistances['listOfagents']=agents
  8.        
  9.         agents.each { agent ->
  10.             def distance = calculateDistance(userLat, userLon, agent)
  11.             if(distance == -1){
  12.                 agentsAndDistances['status']="Cannot find a way from user to any agent"
  13.             }
  14.             listOfDistances.add(distance)
  15.         }
  16.         agentsAndDistances['distances']=listOfDistances
  17.         return agentsAndDistances
  18.     }
Add Comment
Please, Sign In to add comment