
    .h"                     f    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r " S S	\5      rg)
    N)partial)	urlencode)DEFAULT_SENTINELGeocoder)Location)logger)Photonc                      ^  \ rS rSrSrSrSrS\\SS\SS.U 4S jjrS	\SS
SSSS.S jr	S	\S
SS.S jr
SS jrS rSrU =r$ )r	      a  Geocoder using Photon geocoding service (data based on OpenStreetMap
and service provided by Komoot on https://photon.komoot.io).

Documentation at:
    https://github.com/komoot/photon

Photon/Komoot geocoder aims to let you `search as you type with
OpenStreetMap`. No API Key is needed by this platform.

.. versionchanged:: 2.2
    Changed default domain from ``photon.komoot.de``
    to ``photon.komoot.io``.
z/apiz/reverseNzphoton.komoot.io)schemetimeoutproxiesdomain
user_agentssl_contextadapter_factoryc          	        > [         TU ]  UUUUUUS9  UR                  S5      U l        U R                  < SU R                  < U R
                  < 3U l        U R                  < SU R                  < U R                  < 3U l        g)a  

: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 domain: Should be the localized Photon domain to
    connect to. The default is ``'photon.komoot.io'``, but you
    can change it to a domain of your own.

: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   geocode_pathapireverse_pathreverse_api)	selfr   r   r   r   r   r   r   	__class__s	           iC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\geopy/geocoders/photon.pyr   Photon.__init__   su    L 	!#+ 	 	
 ll3'"&++t{{D<M<MN*.++t{{DDUDUV    TF)exactly_oner   location_biaslanguagelimitosm_tagbboxc                   SU0n	U(       a  [        U5      U	S'   U(       a  SU	S'   U(       a  XYS'   U(       a+   U R                  U5      R                  S5      u  pXS'   XS'   U(       a  U R	                  US	5      U	S
'   U(       a^  [        U[        5      (       a  U/U	S'   OB[        U[        R                  R                  5      (       d  [        S5      e[        U5      U	S'   SR                  U R                  [        U	SS945      n[        R                  " SU R                   R"                  U5        [%        U R&                  US9nU R)                  XUS9$ ! [         a    [        S5      ef = 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 location_bias: The coordinates to use as location bias.
:type location_bias: :class:`geopy.point.Point`, list or tuple of
    ``(latitude, longitude)``, or string
    as ``"%(latitude)s, %(longitude)s"``.

:param str language: Preferred language in which to return results.

:param int limit: Limit the number of returned results, defaults to no
    limit.

:param osm_tag: The expression to filter (include/exclude) by key and/
    or value, str as ``'key:value'`` or list/set of str if multiple
    filters are required as ``['key:!val', '!key', ':!value']``.
:type osm_tag: str or list or set

:param bbox: The bounding box of the viewport within which
    to bias geocode results more prominently.
    Example: ``[Point(22, 180), Point(-22, -180)]``.

    .. versionadded:: 2.2
:type bbox: list or tuple of 2 items of :class:`geopy.point.Point` or
    ``(latitude, longitude)`` or ``"%(latitude)s, %(longitude)s"``.

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

qr$      lang,lonlatz0Location bias must be a coordinate pair or Pointz#%(lon1)s,%(lat1)s,%(lon2)s,%(lat2)sr&   r%   z2osm_tag must be a string or an iterable of strings?T)doseqz%s.geocode: %sr!   r   )int_coerce_point_to_stringsplit
ValueError_format_bounding_box
isinstancestrcollectionsabcIterablelistjoinr   r   r   debugr   __name__r   _parse_json_call_geocoder)r   queryr!   r   r"   r#   r$   r%   r&   paramsr-   r,   urlcallbacks                 r   geocodePhoton.geocodeP   sc   j 
 !%jF7OF7O%6NU77FLLSQ #u #u !66;=F6N '3''%,Iy!!';??+C+CDD$1  %)My!hh)F$"?@A%t~~'>'>D4++E""3'"BB)  U !STTUs   *E E/)r!   r   r#   r$   c                    U R                  U5      R                  S5      u  pgUUS.nU(       a  [        U5      US'   U(       a  SUS'   U(       a  XHS'   SR	                  U R
                  [        U5      45      n	[        R                  " SU R                  R                  U	5        [        U R                  US	9n
U R                  XUS
9$ ! [         a    [        S5      ef = f)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 str language: Preferred language in which to return results.

:param int limit: Limit the number of returned results, defaults to no
    limit.

:rtype: ``None``, :class:`geopy.location.Location` or a list of them, if
    ``exactly_one=False``.
r+   z"Must be a coordinate pair or Point)r-   r,   r$   r)   r*   r.   z%s.reverse: %sr0   r1   )r3   r4   r5   r2   r=   r   r   r   r>   r   r?   r   r@   rA   )r   rB   r!   r   r#   r$   r-   r,   rC   rD   rE   s              r   reversePhoton.reverse   s    B	C33E:@@EHC 
 !%jF7OF7O%6Nhh(()F*;<=%t~~'>'>D4++E""3'"BB  	CABB	Cs   "C C!c                     [        US   5      (       d  gU(       a  U R                  US   S   5      $ US    Vs/ s H  o0R                  U5      PM     sn$ s  snf )zC
Parse display name, latitude, and longitude from a JSON response.
featuresNr   )len_parse_resource)r   	resourcesr!   resources       r   r@   Photon._parse_json   sk     9Z())''	*(=a(@AA !,., 8@((2,. . .s   Ac                 D   / SQnU Vs/ s H2  nUS   R                  U5      (       d  M  US   R                  U5      PM4     nnSR                  U5      nUS   S   S   nUS   S   S   nU(       a  U(       a  [        U5      n[        U5      n[        XVU4U5      $ s  snf )N)namehousenumberstreetpostcoderU   citystatecountry
propertiesz, geometrycoordinatesr)   r   )getr=   floatr   )r   rP   name_elementskrS   locationlatitude	longitudes           r   rN   Photon._parse_resource   s    - !C  34$,\$:$>$>q$A .&**1-  	 C99T?J'6q9Z(7:		XHi(IY"7BBCs
   BB)r   r   r   )T)r?   
__module____qualname____firstlineno____doc__r   r   r   r   rF   rI   r@   rN   __static_attributes____classcell__)r   s   @r   r	   r	      s}     LL
 $$%( 0W 0Wl $VCx $2Ch
.C Cr    r	   )collections.abcr9   	functoolsr   urllib.parser   geopy.geocoders.baser   r   geopy.locationr   
geopy.utilr   __all__r	    r    r   <module>rs      s,      " ; # 
kCX kCr    