
    .h(                     r    S SK rS SKJr  S SKJr  S SKJrJr  S SK	J
r
  S SKJr  S SKJr  Sr " S	 S
\5      rg)    N)partial)	urlencode)DEFAULT_SENTINELGeocoder)Location)Point)logger)AlgoliaPlacesc                      ^  \ rS rSrSrSrSrSSSS\\S\SS.	U 4S jjrS	\SSSSSSSSSS
.S jr	S	\SSS.S jr
S rS rSrU =r$ )r
      zvGeocoder using the Algolia Places API.

Documentation at:
    https://community.algolia.com/places/documentation.html
z/1/places/queryz/1/places/reverseNzplaces-dsn.algolia.net)	app_idapi_keydomainschemetimeoutproxies
user_agentssl_contextadapter_factoryc       	   	      *  > [         T
U ]  UUUUUU	S9  UR                  S5      U l        Xl        X l        U R                  < SU R                  < U R                  < 3U l        U R                  < SU R                  < U R                  < 3U l
        g)af  
:param str app_id: Unique application identifier. It's used to
    identify you when using Algolia's API.
    See https://www.algolia.com/dashboard.

:param str api_key: Algolia's user API key.

:param str domain: Currently it is ``'places-dsn.algolia.net'``,
    can be changed for testing purposes.

:param str scheme:
    See :attr:`geopy.geocoders.options.default_scheme`.

:param int timeout:
    See :attr:`geopy.geocoders.options.default_timeout`.

:param dict proxies:
    See :attr:`geopy.geocoders.options.default_proxies`.

:param str user_agent:
    See :attr:`geopy.geocoders.options.default_user_agent`.

:type ssl_context: :class:`ssl.SSLContext`
:param ssl_context:
    See :attr:`geopy.geocoders.options.default_ssl_context`.

:param callable adapter_factory:
    See :attr:`geopy.geocoders.options.default_adapter_factory`.

    .. versionadded:: 2.0
)r   r   r   r   r   r   /z://N)super__init__stripr   r   r   r   geocode_pathgeocode_apireverse_pathreverse_api)selfr   r   r   r   r   r   r   r   r   	__class__s             jC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\geopy/geocoders/algolia.pyr   AlgoliaPlaces.__init__   s    X 	!#+ 	 	
 ll3'  ;;T5F5FG 	  ;;T5F5FG 	    T)exactly_oner   typerestrict_searchable_attributeslimitlanguage	countriesaroundaround_via_iparound_radiusx_forwarded_forc                   SU0nUb  XMS'   Ub  X]S'   Ub  XmS'   U(       a  SUS'   Ub  UR                  5       US'   Ub2  SR                  U Vs/ s H  oR                  5       PM     sn5      US'   U	b+  [        U	5      nUR                  < SUR                  < 3US	'   U
b  U
(       a  S
OSUS'   Ub  XS'   SR                  U R
                  [        U5      45      n0 nUb  UUS'   U R                  b+  U R                  b  U R                  US'   U R                  US'   [        R                  " SU R                  R                  U5        [        U R                  X'S9nU R                  UUUUS9$ s  snf )a  
Return a location point by address.

:param str query: The address or query you wish to geocode.

:param bool exactly_one: Return one result or a list of results, if
    available.

:param int timeout: Time, in seconds, to wait for the geocoding service
    to respond before raising a :class:`geopy.exc.GeocoderTimedOut`
    exception. Set this only if you wish to override, on this call
    only, the value set during the geocoder's initialization.

:param str type: Restrict the search results to a specific type.
    Available types are defined in documentation:
    https://community.algolia.com/places/api-clients.html#api-options-type

:param str restrict_searchable_attributes: Restrict the fields in which
    the search is done.

:param int limit: Limit the maximum number of items in the
    response. If not provided and there are multiple results
    Algolia API will return 20 results by default. This will be
    reset to one if ``exactly_one`` is True.

:param str language: If specified, restrict the search results
    to a single language. You can pass two letters country
    codes (ISO 639-1).

:param list countries: If specified, restrict the search results
    to a specific list of countries. You can pass two letters
    country codes (ISO 3166-1).

:param around: Force to first search around a specific
    latitude longitude.
:type around: :class:`geopy.point.Point`, list or tuple of
    ``(latitude, longitude)``, or string as ``"%(latitude)s,
    %(longitude)s"``.

:param bool around_via_ip: Whether or not to first search
    around the geolocation of the user found via his IP address.
    This is true by default.

:param int around_radius: Radius in meters to search around the
    latitude/longitude. Otherwise a default radius is
    automatically computed given the area density.

:param str x_forwarded_for: Override the HTTP header X-Forwarded-For.
    With this you can control the source IP address used to resolve
    the geo-location of the user. This is particularly useful when
    you want to use the API from your backend as if it was from your
    end-users' locations.

:rtype: ``None``, :class:`geopy.location.Location` or a list of them, if
    ``exactly_one=False``.

queryr%   restrictSearchableAttributeshitsPerPage   r(   ,r)   aroundLatLngtruefalsearoundLatLngViaIParoundRadius?zX-Forwarded-ForX-Algolia-Application-IdX-Algolia-API-Keyz%s.geocode: %sr$   r(   headersr   )lowerjoinr   latitude	longituder   r   r   r   r	   debugr    __name__r   _parse_json_call_geocoder)r   r/   r$   r   r%   r&   r'   r(   r)   r*   r+   r,   r-   paramscpurlr>   callbacks                      r!   geocodeAlgoliaPlaces.geocodeW   s   V U
 !6N)55S12$)=!$%F=!!)!1F: "%((y+Iy!GGIy+I"JF;fA01

AKK%HF>"$'W &' $%2>"hh(()F*;<=&)8G%&;;"t||'?26++G./+/<<G'(%t~~'>'>D4++X""3'7"SS3 ,Js   E1)r$   r   r'   r(   c                   U R                  U5      nSU0nUb  XGS'   Ub  XWS'   SR                  U R                  [        U5      45      n0 n	U R                  b+  U R
                  b  U R                  U	S'   U R
                  U	S'   [        R                  " SU R                  R                  U5        [        U R                  X%S9n
U R                  XXS	9$ )
aT  
Return an address by location point.

:param query: The coordinates for which you wish to obtain the
    closest human-readable addresses.
:type query: :class:`geopy.point.Point`, list or tuple of ``(latitude,
    longitude)``, or string as ``"%(latitude)s, %(longitude)s"``.

:param bool exactly_one: Return one result or a list of results, if
    available.

:param int timeout: Time, in seconds, to wait for the geocoding service
    to respond before raising a :class:`geopy.exc.GeocoderTimedOut`
    exception. Set this only if you wish to override, on this call
    only, the value set during the geocoder's initialization.

:param int limit: Limit the maximum number of items in the
    response. If not provided and there are multiple results
    Algolia API will return 20 results by default. This will be
    reset to one if ``exactly_one`` is True.

:param str language: If specified, restrict the search results
    to a single language. You can pass two letters country
    codes (ISO 639-1).

:rtype: ``None``, :class:`geopy.location.Location` or a list of them, if
    ``exactly_one=False``.
r4   r1   r(   r9   r:   r;   z%s.reverse: %sr<   r=   )_coerce_point_to_stringr@   r   r   r   r   r	   rC   r    rD   r   rE   rF   )r   r/   r$   r   r'   r(   locationrG   rJ   r>   rK   s              r!   reverseAlgoliaPlaces.reverse   s    J //6 H
 $)=!!):hh(()F*;<=;;"t||'?26++G./+/<<G'(%t~~'>'>D4++X""3'"SSr#   c                 J   UR                  S0 5      R                  S5      nUR                  S0 5      R                  S5      n[        US   [        R                  R                  5      (       a   X!S   ;   a  US   U   S   nOUS   S   S   nOUS   S   n[        XSU4U5      $ )N_geoloclatlnglocale_namesr   default)get
isinstancecollectionsabcMappingr   )r   featurer(   rA   rB   	placenames         r!   _parse_featureAlgoliaPlaces._parse_feature  s    ;;y"-11%8KK	2.2259	gn-{/F/FGG>22#N3H=a@	#N3I>qA	/2I	i#8'BBr#   c                     Ub  SU;  a  g US   n[        U5      (       d  g U(       a  U R                  US   US9$ U Vs/ s H  oPR                  XSS9PM     sn$ s  snf )Nhitsr   )r(   )lenr`   )r   responser$   r(   featuresr^   s         r!   rE   AlgoliaPlaces._parse_json  sv    vX5F#8}}&&x{X&FF PXOWG##G#?x  s   A)r   r   r   r   r   )rD   
__module____qualname____firstlineno____doc__r   r   r   r   rL   rQ   r`   rE   __static_attributes____classcell__)r    s   @r!   r
   r
      s     %L&L
 +$$( >
 >
H $+/ wTz $:TxC r#   r
   )collections.abcr[   	functoolsr   urllib.parser   geopy.geocoders.baser   r   geopy.locationr   geopy.pointr   
geopy.utilr	   __all__r
    r#   r!   <module>rw      s-      " ; #  
YH Yr#   