U
    Ò­Òc_  ã                   @   s   d Z ddlmZ ddd„ZdS )z4Performs requests to the Google Maps Directions API.é    )ÚconvertNFc                 C   s  t  |¡t  |¡dœ}|r2|dkr*tdƒ‚||d< |rTt  |¡}|rLd| }||d< |r`d|d< |rtt  d	|¡|d
< |r€||d< |rŒ||d< |	r˜|	|d< |
rªt  |
¡|d< |r¼t  |¡|d< |
rÌ|rÌtdƒ‚|ràt  d	|¡|d< |rì||d< |rø||d< |  d|¡ dg ¡S )a  Get directions between an origin point and a destination point.

    :param origin: The address or latitude/longitude value from which you wish
        to calculate directions.
    :type origin: string, dict, list, or tuple

    :param destination: The address or latitude/longitude value from which
        you wish to calculate directions. You can use a place_id as destination
        by putting 'place_id:' as a prefix in the passing parameter.
    :type destination: string, dict, list, or tuple

    :param mode: Specifies the mode of transport to use when calculating
        directions. One of "driving", "walking", "bicycling" or "transit"
    :type mode: string

    :param waypoints: Specifies an array of waypoints. Waypoints alter a
        route by routing it through the specified location(s). To influence
        route without adding stop prefix the waypoint with `via`, similar to
        `waypoints = ["via:San Francisco", "via:Mountain View"]`.
    :type waypoints: a single location, or a list of locations, where a
        location is a string, dict, list, or tuple

    :param alternatives: If True, more than one route may be returned in the
        response.
    :type alternatives: bool

    :param avoid: Indicates that the calculated route(s) should avoid the
        indicated features.
    :type avoid: list or string

    :param language: The language in which to return results.
    :type language: string

    :param units: Specifies the unit system to use when displaying results.
        "metric" or "imperial"
    :type units: string

    :param region: The region code, specified as a ccTLD ("top-level domain"
        two-character value.
    :type region: string

    :param departure_time: Specifies the desired time of departure.
    :type departure_time: int or datetime.datetime

    :param arrival_time: Specifies the desired time of arrival for transit
        directions. Note: you can't specify both departure_time and
        arrival_time.
    :type arrival_time: int or datetime.datetime

    :param optimize_waypoints: Optimize the provided route by rearranging the
        waypoints in a more efficient order.
    :type optimize_waypoints: bool

    :param transit_mode: Specifies one or more preferred modes of transit.
        This parameter may only be specified for requests where the mode is
        transit. Valid values are "bus", "subway", "train", "tram", "rail".
        "rail" is equivalent to ["train", "tram", "subway"].
    :type transit_mode: string or list of strings

    :param transit_routing_preference: Specifies preferences for transit
        requests. Valid values are "less_walking" or "fewer_transfers"
    :type transit_routing_preference: string

    :param traffic_model: Specifies the predictive travel time model to use.
        Valid values are "best_guess" or "optimistic" or "pessimistic".
        The traffic_model parameter may only be specified for requests where
        the travel mode is driving, and where the request includes a
        departure_time.
    :type units: string

    :rtype: list of routes
    )ÚoriginÚdestination)ZdrivingZwalkingZ	bicyclingZtransitzInvalid travel mode.Úmodezoptimize:true|Ú	waypointsÚtrueÚalternativesú|ÚavoidÚlanguageÚunitsÚregionÚdeparture_timeÚarrival_timez7Should not specify both departure_time andarrival_time.Útransit_modeÚtransit_routing_preferenceÚtraffic_modelz/maps/api/directions/jsonZroutes)r   ZlatlngÚ
ValueErrorZlocation_listZ	join_listÚtimeZ_requestÚget)Zclientr   r   r   r   r   r
   r   r   r   r   r   Zoptimize_waypointsr   r   r   Úparams© r   úR/home/ubuntu/graampay/app_env/lib/python3.8/site-packages/googlemaps/directions.pyÚ
directions   sF    Oþ
r   )NNFNNNNNNFNNN)Ú__doc__Ú
googlemapsr   r   r   r   r   r   Ú<module>   s                         ü