route_distances/distances.py
def route(self, from_long, from_lat, to_long, to_lat, mode = "walk"):
        """ Routes the distance between two coordinates

        Args:
            orig_long: The origin longitude.
            orig_lat: The origin latitude.
            dest_long: The destination longitude.
            dest_lat: The destination latitude.
            mode: A key of the self.mode_map dictionary that will be remapped to
                a different string and passed to the API.

        Returns:
            A dictionary containing the total duration in the "duration" key and
                the total distance in the "distance" key if there are no errors;
                False if there are errors. Distance is in meters; duration is in
                seconds.
        """


        url = ("http://%s/route/v1/%s/"
               "%f,%f;%f,%f" % (
            self.entrypoint,
            self.map_mode(mode),
            from_long, from_lat, to_long, to_lat
        ))

        self.log("Sending request: %s" % url)
        response = requests.get(url, timeout = self.timeout)
        data = response.content.decode()
        self.log("Response: %s" % data)

        if (response.status_code == 200):
            content = json.loads(data)
            if (not "error" in content):
                return {
                    "distance": content["routes"][0]["distance"],
                    "duration": content["routes"][0]["duration"],
                    "response": content
                }

        return False
 Routes the distance between two coordinates

        Args:
            orig_long: The origin longitude.
            orig_lat: The origin latitude.
            dest_long: The destination longitude.
            dest_lat: The destination latitude.
            mode: A key of the self.mode_map dictionary that will be remapped to
                a different string and passed to the API.

        Returns:
            A dictionary containing the total duration in the "duration" key and
                the total distance in the "distance" key if there are no errors;
                False if there are errors. Distance is in meters; duration is in
                seconds.
        
Routes the distance between two coordinates
Routes the distance between two coordinates
def route(self, from_long, from_lat, to_long, to_lat, mode = "walk"):
        url = ("http://%s/route/v1/%s/"
               "%f,%f;%f,%f" % (
            self.entrypoint,
            self.map_mode(mode),
            from_long, from_lat, to_long, to_lat
        ))
        self.log("Sending request: %s" % url)
        response = requests.get(url, timeout = self.timeout)
        data = response.content.decode()
        self.log("Response: %s" % data)
        if (response.status_code == 200):
            content = json.loads(data)
            if (not "error" in content):
                return {
                    "distance": content["routes"][0]["distance"],
                    "duration": content["routes"][0]["duration"],
                    "response": content
                }
        return False
def route ( self , from_long , from_lat , to_long , to_lat , mode = "walk" ) : url = ( "http://%s/route/v1/%s/" "%f,%f;%f,%f" % ( self . entrypoint , self . map_mode ( mode ) , from_long , from_lat , to_long , to_lat ) ) self . log ( "Sending request: %s" % url ) response = requests . get ( url , timeout = self . timeout ) data = response . content . decode ( ) self . log ( "Response: %s" % data ) if ( response . status_code == 200 ) : content = json . loads ( data ) if ( not "error" in content ) : return { "distance" : content [ "routes" ] [ 0 ] [ "distance" ] , "duration" : content [ "routes" ] [ 0 ] [ "duration" ] , "response" : content } return False
Routes the distance between two coordinates
Routes the distance between two coordinates
""" Routes the distance between two coordinates

        Args:
            orig_long: The origin longitude.
            orig_lat: The origin latitude.
            dest_long: The destination longitude.
            dest_lat: The destination latitude.
            mode: A key of the self.mode_map dictionary that will be remapped to
                a different string and passed to the API.

        Returns:
            A dictionary containing the total duration in the "duration" key and
                the total distance in the "distance" key if there are no errors;
                False if there are errors. Distance is in meters; duration is in
                seconds.
        """
A dictionary containing the total duration in the "duration" key and
the total distance in the "distance" key if there are no errors;
False if there are errors. Distance is in meters; duration is in
seconds.
A dictionary containing the total duration in the " duration " key and the total distance in the " distance " key if there are no errors ; False if there are errors . Distance is in meters ; duration is in seconds .
self
from_long
from_lat
to_long
to_lat
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 .
orig_long
The origin longitude.
The origin longitude .
orig_lat
The origin latitude.
The origin latitude .
dest_long
The destination longitude.
The destination longitude .
dest_lat
The destination latitude.
The destination latitude .