U
    Ò­Òcè  ã                
   @   s   d Z ddlmZ ddd„ZdS )z9Performs requests to the Google Maps Distance Matrix API.é    )ÚconvertNc                 C   sÞ   t  |¡t  |¡dœ}|r2|dkr*tdƒ‚||d< |r>||d< |rZ|dkrRtdƒ‚||d< |rf||d	< |rxt  |¡|d
< |rŠt  |¡|d< |rš|rštdƒ‚|	r®t  d|	¡|d< |
rº|
|d< |rÆ||d< |rÒ||d< |  d|¡S )ay   Gets travel distance and time for a matrix of origins and destinations.

    :param origins: One or more addresses, Place IDs, and/or latitude/longitude
        values, from which to calculate distance and time. Each Place ID string
        must be prepended with 'place_id:'. If you pass an address as a string,
        the service will geocode the string and convert it to a
        latitude/longitude coordinate to calculate directions.
    :type origins: a single location, or a list of locations, where a
        location is a string, dict, list, or tuple

    :param destinations: One or more addresses, Place IDs, and/or lat/lng values
        , to which to calculate distance and time. Each Place ID string must be
        prepended with 'place_id:'. If you pass an address as a string, the
        service will geocode the string and convert it to a latitude/longitude
        coordinate to calculate directions.
    :type destinations: a single location, or a list of locations, where a
        location is a string, dict, list, or tuple

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

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

    :param avoid: Indicates that the calculated route(s) should avoid the
        indicated features. Valid values are "tolls", "highways" or "ferries".
    :type avoid: string

    :param units: Specifies the unit system to use when displaying results.
        Valid values are "metric" or "imperial".
    :type units: 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 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.

    :param region: Specifies the prefered region the geocoder should search
        first, but it will not restrict the results to only this region. Valid
        values are a ccTLD code.
    :type region: string

    :rtype: matrix of distances. Results are returned in rows, each row
        containing one origin paired with each destination.
    )ÚoriginsÚdestinations)ZdrivingZwalkingZ	bicyclingZtransitzInvalid travel mode.ÚmodeÚlanguage)ZtollsZhighwaysZferrieszInvalid route restriction.ÚavoidÚunitsÚdeparture_timeÚarrival_timez7Should not specify both departure_time andarrival_time.ú|Útransit_modeÚtransit_routing_preferenceÚtraffic_modelÚregionz/maps/api/distancematrix/json)r   Zlocation_listÚ
ValueErrorÚtimeZ	join_listZ_request)Zclientr   r   r   r   r   r   r	   r
   r   r   r   r   Úparams© r   úW/home/ubuntu/graampay/app_env/lib/python3.8/site-packages/googlemaps/distance_matrix.pyÚdistance_matrix   s<    Hþr   )
NNNNNNNNNN)Ú__doc__Ú
googlemapsr   r   r   r   r   r   Ú<module>   s                    ý