# xRoute.remove_too_far_away def self.remove_too_far_away(parking_places, finish_latitude, finish_longitude, standard_distance) url = URI.parse(CALCULATE_DISTANCE_URL) # ... code to setup http request # we are asking for driving distances from all parking places to finish location driving_distances = JSON.parse(response.body) parking_places_good = [] parking_places.each_with_index do |parking_place,index| if driving_distances['matrixInfo'].present? parking_places_good << parking_place if ( (parking_place.driving_distance[:distance][:value].to_i + driving_distances['matrixInfo'][index]['distance'].to_i - standard_distance.to_i ) < 6000) end end parking_places_good end def self.get_reachable_objects(route) url = URI.parse(CALCULATE_REACHABLE_OBJECTS_URL) # ... code to setup http request res = JSON.parse(response.body) detours = Hash.new if res['reachableObject'].present? res['reachableObject'].each do |ro| detours[ro['object']['id']] = {detour_time: ro['routeInfo']} end end return detours end