
    .%i'                     h    d Z d Zd Zd Zd Zd Zd Zd Zd Zd	 Z	d
 Z
d Zd Zd Zd Zd Zd Zy)zConverts Python types to string representations suitable for Maps API server.

    For example:

    sydney = {
        "lat" : -33.8674869,
        "lng" : 151.2069902
    }

    convert.latlng(sydney)
    # '-33.8674869,151.2069902'
c                 Z    dt        |       z  j                  d      j                  d      S )a[  Formats a float value to be as short as possible.

    Truncates float to 8 decimal places and trims extraneous
    trailing zeros and period to give API args the best
    possible chance of fitting within 2000 char URL length
    restrictions.

    For example:

    format_float(40) -> "40"
    format_float(40.0) -> "40"
    format_float(40.1) -> "40.1"
    format_float(40.001) -> "40.001"
    format_float(40.0010) -> "40.001"
    format_float(40.000000001) -> "40"
    format_float(40.000000009) -> "40.00000001"

    :param arg: The lat or lng float.
    :type arg: float

    :rtype: string
    z%.8f0.)floatrstripargs    l/var/www/html/navyabakers_fullstack/navyabakers_prod/venv/lib/python3.12/site-packages/googlemaps/convert.pyformat_floatr
       s)    . U3Z'',33C88    c                 p    t        |       r| S t        |       }t        |d         dt        |d         S )a  Converts a lat/lon pair to a comma-separated string.

    For example:

    sydney = {
        "lat" : -33.8674869,
        "lng" : 151.2069902
    }

    convert.latlng(sydney)
    # '-33.8674869,151.2069902'

    For convenience, also accepts lat/lon pair as a string, in
    which case it's returned unchanged.

    :param arg: The lat/lon pair.
    :type arg: string or dict or list or tuple
        ,   )	is_stringnormalize_lat_lngr
   )r   
normalizeds     r	   latlngr   :   s7    & ~
"3'J":a=1<
13NOOr   c                     t        | t              r$d| v rd| v r
| d   | d   fS d| v rd| v r
| d   | d   fS t        |       r
| d   | d   fS t        dt	        |       j
                  z        )a1  Take the various lat/lng representations and return a tuple.

    Accepts various representations:
    1) dict with two entries - "lat" and "lng"
    2) list or tuple - e.g. (-33, 151) or [-33, 151]

    :param arg: The lat/lng pair.
    :type arg: dict or list or tuple

    :rtype: tuple (lat, lng)
    latlnglatitude	longituder   r   z,Expected a lat/lng dict or tuple, but got %s)
isinstancedict_is_list	TypeErrortype__name__r   s    r	   r   r   T   s     #tC<ESLu:s5z))!3z?C$444 }1vs1v~
	Cy))	*+ +r   c                     t        | t              rt        |       S dj                  t	        |       D cg c]  }t        |       c}      S c c}w )aR  Joins a list of locations into a pipe separated string, handling
    the various formats supported for lat/lng values.

    For example:
    p = [{"lat" : -33.867486, "lng" : 151.206990}, "Sydney"]
    convert.waypoint(p)
    # '-33.867486,151.206990|Sydney'

    :param arg: The lat/lng list.
    :type arg: list

    :rtype: string
    |)r   tupler   joinas_list)r   locations     r	   location_listr%   o   s>     #uc{xx'#,Gh)GHHGs   Ac                 6    | j                  t        |            S )zIf arg is list-like, then joins it with sep.

    :param sep: Separator string.
    :type sep: string

    :param arg: Value to coerce into a list.
    :type arg: string or list of strings

    :rtype: string
    )r"   r#   )sepr   s     r	   	join_listr(      s     88GCL!!r   c                 "    t        |       r| S | gS )zCoerces arg into a list. If arg is already list-like, returns arg.
    Otherwise, returns a one-element list containing arg.

    :rtype: list
    )r   r   s    r	   r#   r#      s     }
5Lr   c                     t        | t              ryt        | t              ryt        | d      st        | d      S t        | d      S )z<Checks if arg is list-like. This excludes strings and dicts.Fstrip__getitem____iter__)r   r   str_has_methodr   s    r	   r   r      sA    #t#s2=c72K;sM*mQ\]`blQmmr   c                 n    	 t          t        | t               S # t        $ r t        | t              cY S w xY w)z>Determines whether the passed value is a string, safe for 2/3.)
basestring	NameErrorr   r.   )vals    r	   r   r      s7    $ c:&&  $#s##$s    44c                     t        | d      r| j                         } t        | t              rt	        |       } t        |       S )zConverts the value into a unix time (seconds since unix epoch).

    For example:
        convert.time(datetime.now())
        # '1409810596'

    :param arg: The time.
    :type arg: datetime.datetime or int
    	timestamp)r/   r5   r   r   intr.   r   s    r	   timer7      s5     3$mmo#u#hs8Or   c                 H    t        | |      xr t        t        | |            S )zReturns true if the given object has a method with the given name.

    :param arg: the object

    :param method: the method name
    :type method: string

    :rtype: bool
    )hasattrcallablegetattr)r   methods     r	   r/   r/      s"     3BHWS&-A$BBr   c                     d }t        | t              r dj                  t         ||                   S t	        dt        |       j                  z        )a.  Converts a dict of components to the format expected by the Google Maps
    server.

    For example:
    c = {"country": "US", "postal_code": "94043"}
    convert.components(c)
    # 'country:US|postal_code:94043'

    :param arg: The component filter.
    :type arg: dict

    :rtype: basestring
    c              3   n   K   | j                         D ]  \  }}t        |      D ]  }|d|    y w)N:)itemsr#   )r   kvitems       r	   expandzcomponents.<locals>.expand   s=     IIK 	*DAq
 *!"D))*	*s   35r    z*Expected a dict for components, but got %s)r   r   r"   sortedr   r   r   )r   rD   s     r	   
componentsrF      sO    $*
 #txxvc{+,,
	Cy))	*+ +r   c                    t        |       r*| j                  d      dk(  r| j                  d      dk(  r| S t        | t              r'd| v r#d| v rt	        | d         dt	        | d         S t        dt        |       j                  z        )a  Converts a lat/lon bounds to a comma- and pipe-separated string.

    Accepts two representations:
    1) string: pipe-separated pair of comma-separated lat/lon pairs.
    2) dict with two entries - "southwest" and "northeast". See convert.latlng
    for information on how these can be represented.

    For example:

    sydney_bounds = {
        "northeast" : {
            "lat" : -33.4245981,
            "lng" : 151.3426361
        },
        "southwest" : {
            "lat" : -34.1692489,
            "lng" : 150.502229
        }
    }

    convert.bounds(sydney_bounds)
    # '-34.169249,150.502229|-33.424598,151.342636'

    :param arg: The bounds.
    :type arg: dict
    r    r   r      	southwest	northeastz8Expected a bounds (southwest/northeast) dict, but got %s)r   countr   r   r   r   r   r   r   s    r	   boundsrL      s    8 ~#))C.A-#))C.A2E
	C	#+"4$S%56$S%568 8 	Cy))	*+ +r   c                     t        | t              r| d| S t        |       r| d   d| d   S t        dt	        |       j
                  z        )Nxr   r   z'Expected a size int or list, but got %s)r   r6   r   r   r   r   r   s    r	   sizerO     sU    #ss##	#a&#a&))
	Cy))	*+ +r   c                    g }dx}x}}|t        |       k  rd}d}	 t        | |         dz
  dz
  }|dz  }|||z  z  }|dz  }|dk  rn-||dz  dk7  r| dz	  n|dz	  z  }d}d}	 t        | |         dz
  dz
  }|dz  }|||z  z  }|dz  }|dk  rn-||dz  dk7  r|dz	   n|dz	  z  }|j                  |dz  |dz  d       |t        |       k  r|S )aH  Decodes a Polyline string into a list of lat/lng dicts.

    See the developer docs for a detailed description of this encoding:
    https://developers.google.com/maps/documentation/utilities/polylinealgorithm

    :param polyline: An encoded polyline
    :type polyline: string

    :rtype: list of dicts with lat/lng keys
    r   r   ?         gh㈵>)r   r   )lenordappend)polylinepointsindexr   r   resultshiftbs           r	   decode_polyliner]   "  s@    FEC#
#h-
HUO$r)A-AQJEa5j FQJE4x  	&1*!211EHUO$r)A-AQJEa5j FQJE4x  	&1*!21~1EcDjt<=/ #h-
2 Mr   c                 \   dx}}d}| D ]  }t        |      }t        t        |d   dz              }t        t        |d   dz              }||z
  }||z
  }	||	fD ]J  }
|
dk  r|
dz   n|
dz  }
|
dk\  r"|t        d|
dz  z  dz         z  }|
dz  }
|
dk\  r"|t        |
dz         z  }L |}|} |S )	a9  Encodes a list of points into a polyline string.

    See the developer docs for a detailed description of this encoding:
    https://developers.google.com/maps/documentation/utilities/polylinealgorithm

    :param points: a list of lat/lng pairs
    :type points: list of dicts or tuples

    :rtype: string
    r    g     j@r       rS   rQ   rR   )r   r6   roundchr)rX   last_latlast_lngrZ   pointllr   r   d_latd_lngrB   s              r	   encode_polylineri   L  s     HxF u%%1$%%1$%hh 	$AU!q&	QAt)3D 1R789a t) s1r6{#F	$ " Mr   c                     t        | t              r| g} dt        |       z  }t        |       }t	        |      t	        |      k  r|S |S )ai  Returns the shortest representation of the given locations.

    The Elevations API limits requests to 2000 characters, and accepts
    multiple locations either as pipe-delimited lat/lng values, or
    an encoded polyline, so we determine which is shortest and use it.

    :param locations: The lat/lng list.
    :type locations: list

    :rtype: string
    zenc:%s)r   r!   ri   r%   rT   )	locationsencoded	unencodeds      r	   shortest_pathrn   n  sI     )U#K	33Gi(I
7|c)n$r   N)__doc__r
   r   r   r%   r(   r#   r   r   r7   r/   rF   rL   rO   r]   ri   rn    r   r	   <module>rq      sa   $94P4+6I*"n'(
C+>%+P+'TDr   