route_distances/distances.py
def route_multi(self, orig_long, orig_lat, destinations, mode = "walk"):
        """ Routes the distance between one origin and multiple destinations

        Args:
            orig_long: The origin longitude.
            orig_lat: The origin latitude.
            destinations: An iterable containing (long, lat) tuples or lists
            mode: A key of the self.mode_map dictionary that will be remapped
                to a different string and passed to the API.

        Returns:
            A list of dictionaries formatted like the output of self.distance().
        """

        self.log("Sending request to Google")
        result = self.gmaps.distance_matrix(
            origins = (orig_lat, orig_long),
            destinations = [(coord[1], coord[0]) for coord in destinations],
            units = "metric",
            mode = self.map_mode(mode)
        )
        self.log("Response: %s" % result)

        if (result["status"] == "OK"):
            results = []
            for element in result["rows"][0]["elements"]:
                results.append({
                    "duration": element["duration"]["value"],
                    "distance": element["distance"]["value"],
                    "response": element
                })
            return results

        return False
 Routes the distance between one origin and multiple destinations

        Args:
            orig_long: The origin longitude.
            orig_lat: The origin latitude.
            destinations: An iterable containing (long, lat) tuples or lists
            mode: A key of the self.mode_map dictionary that will be remapped
                to a different string and passed to the API.

        Returns:
            A list of dictionaries formatted like the output of self.distance().
        
Routes the distance between one origin and multiple destinations
Routes the distance between one origin and multiple destinations
def route_multi(self, orig_long, orig_lat, destinations, mode = "walk"):
        self.log("Sending request to Google")
        result = self.gmaps.distance_matrix(
            origins = (orig_lat, orig_long),
            destinations = [(coord[1], coord[0]) for coord in destinations],
            units = "metric",
            mode = self.map_mode(mode)
        )
        self.log("Response: %s" % result)
        if (result["status"] == "OK"):
            results = []
            for element in result["rows"][0]["elements"]:
                results.append({
                    "duration": element["duration"]["value"],
                    "distance": element["distance"]["value"],
                    "response": element
                })
            return results
        return False
def route_multi ( self , orig_long , orig_lat , destinations , mode = "walk" ) : self . log ( "Sending request to Google" ) result = self . gmaps . distance_matrix ( origins = ( orig_lat , orig_long ) , destinations = [ ( coord [ 1 ] , coord [ 0 ] ) for coord in destinations ] , units = "metric" , mode = self . map_mode ( mode ) ) self . log ( "Response: %s" % result ) if ( result [ "status" ] == "OK" ) : results = [ ] for element in result [ "rows" ] [ 0 ] [ "elements" ] : results . append ( { "duration" : element [ "duration" ] [ "value" ] , "distance" : element [ "distance" ] [ "value" ] , "response" : element } ) return results return False
Routes the distance between one origin and multiple destinations
Routes the distance between one origin and multiple destinations
""" Routes the distance between one origin and multiple destinations

        Args:
            orig_long: The origin longitude.
            orig_lat: The origin latitude.
            destinations: An iterable containing (long, lat) tuples or lists
            mode: A key of the self.mode_map dictionary that will be remapped
                to a different string and passed to the API.

        Returns:
            A list of dictionaries formatted like the output of self.distance().
        """
A list of dictionaries formatted like the output of self.distance().
A list of dictionaries formatted like the output of self . distance () .
self
orig_long
The origin longitude.
The origin longitude .
orig_lat
The origin latitude.
The origin latitude .
destinations
An iterable containing (long, lat) tuples or lists
An iterable containing ( long lat ) tuples or lists
mode
A key of the self.mode_map dictionary that will be remapped
to a different string and passed to the API.
A key of the self . mode_map dictionary that will be remapped to a different string and passed to the API .