
    .h7                         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
JrJr  S SKJr  S SKJr  SrS	rS
SSS\
4r " S S\5      rg)    N)partial)	urlencode)ConfigurationErrorGeocoderQueryError)_DEFAULT_USER_AGENTDEFAULT_SENTINELGeocoder)Location)logger)	Nominatimznominatim.openstreetmap.orgzmy-applicationzmy_app/1zmy_user_agent/1.0specify_your_app_name_herec                      ^  \ rS rSrSr1 SkrSrSr\\\	SS\SS.U 4S jjr
S	 rS
\SSSSSSSSSSS.S jrS
\SS
SSS.S jrS rS rSrU =r$ )r      a  Nominatim geocoder for OpenStreetMap data.

Documentation at:
    https://nominatim.org/release-docs/develop/api/Overview/

.. attention::
   Using Nominatim with the default `user_agent` is strongly discouraged,
   as it violates Nominatim's Usage Policy
   https://operations.osmfoundation.org/policies/nominatim/
   and may possibly cause 403 and 429 HTTP errors. Please make sure
   to specify a custom `user_agent` with
   ``Nominatim(user_agent="my-application")`` or by
   overriding the default `user_agent`:
   ``geopy.geocoders.options.default_user_agent = "my-application"``.
   An exception will be thrown if a custom `user_agent` is not specified.
>   citystatecountystreetcountry
postalcodez/searchz/reverseN)timeoutproxiesdomainscheme
user_agentssl_contextadapter_factoryc          	        > [         TU ]  UUUUUUS9  UR                  S5      U l        U R                  [        :X  a2  U R
                  S   [        ;   a  [        SU R
                  S   -  5      eU R                  < SU R                  < U R                  < 3U l
        U R                  < SU R                  < U R                  < 3U l        g)a  

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

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

:param str domain: Domain where the target Nominatim service
    is hosted.

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

: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
User-Agenta  Using Nominatim with default or sample `user_agent` "%s" is strongly discouraged, as it violates Nominatim's ToS https://operations.osmfoundation.org/policies/nominatim/ and may possibly cause 403 and 429 HTTP errors. Please specify a custom `user_agent` with `Nominatim(user_agent="my-application")` or by overriding the default `user_agent`: `geopy.geocoders.options.default_user_agent = "my-application"`.z://N)super__init__stripr   _DEFAULT_NOMINATIM_DOMAINheaders_REJECTED_USER_AGENTSr   r   geocode_pathapireverse_pathreverse_api)	selfr   r   r   r   r   r   r   	__class__s	           lC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\geopy/geocoders/nominatim.pyr    Nominatim.__init__5   s    N 	!#+ 	 	
 ll3'KK44LL.2GG$S ,,|,-
 
 #'++t{{D<M<MN*.++t{{DDUDUV    c                 :    SR                  U[        U5      45      $ )a  
Construct geocoding request url.
The method can be overridden in Nominatim-based geocoders in order
to extend URL parameters.

:param str base_api: Geocoding function base address - self.api
    or self.reverse_api.

:param dict params: Geocoding params.

:return: string URL.
?)joinr   )r)   base_apiparamss      r+   _construct_urlNominatim._construct_urlx   s     xx9V#4566r-   TF)exactly_oner   limitaddressdetailslanguagegeometry	extratagscountry_codesviewboxboundedfeaturetypenamedetailsc                   [        U[        R                  R                  5      (       a6  UR	                  5        VVs0 s H  u  pXR
                  ;   d  M  X_M     nnnOSU0nUR                  SS05        U(       a  SUS'   O$Ub!  [        U5      nUS:  a  [        S5      eUUS'   U
(       a  U R                  U
S5      US'   U(       a  SUS	'   U	(       d  / n	[        U	[        5      (       a  U	/n	U	(       a  S
R                  U	5      US'   U(       a  SUS'   U(       a  SUS'   U(       a  UUS'   U(       a  SUS'   UbK  UR                  5       nUS:X  a  SUS'   O/US:X  a  SUS'   O#US:X  a  SUS'   OUS:X  a  SUS'   O[        S5      eU(       a  UUS'   U R                  U R                  U5      n[         R"                  " SU R$                  R&                  U5        [)        U R*                  US9nU R-                  UUUS9$ s  snnf )aM  
Return a location point by address.

:param query: The address, query or a structured query
    you wish to geocode.

    For a structured query, provide a dictionary whose keys
    are one of: `street`, `city`, `county`, `state`, `country`, or
    `postalcode`. For more information, see Nominatim's
    documentation for `structured requests`:

        https://nominatim.org/release-docs/develop/api/Search

:type query: dict or str

: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: Maximum amount of results to return from Nominatim.
    Unless exactly_one is set to False, limit will always be 1.

:param bool addressdetails: If you want in *Location.raw* to include
    address details such as house_number, city_district, postcode, etc
    (in a structured form) set it to True

:param str language: Preferred language in which to return results.
    Either uses standard
    `RFC2616 <http://www.ietf.org/rfc/rfc2616.txt>`_
    accept-language string or a simple comma-separated
    list of language codes.

:param str geometry: If present, specifies whether the geocoding
    service should return the result's geometry in `wkt`, `svg`,
    `kml`, or `geojson` formats. This is available via the
    `raw` attribute on the returned :class:`geopy.location.Location`
    object.

:param bool extratags: Include additional information in the result if available,
    e.g. wikipedia link, opening hours.

:param country_codes: Limit search results
    to a specific country (or a list of countries).
    A country_code should be the ISO 3166-1alpha2 code,
    e.g. ``gb`` for the United Kingdom, ``de`` for Germany, etc.

:type country_codes: str or list

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

:param viewbox: Prefer this area to find search results. By default this is
    treated as a hint, if you want to restrict results to this area,
    specify ``bounded=True`` as well.
    Example: ``[Point(22, 180), Point(-22, -180)]``.

:param bool bounded: Restrict the results to only items contained
    within the bounding ``viewbox``.

:param str featuretype: If present, restrict results to certain type of features.
    Allowed values: `country`, `state`, `city`, `settlement`.

:param bool namedetails: If you want in *Location.raw* to include
    namedetails, set it to True. This will be a list of alternative names,
    including language variants, etc.

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

qformatjson   r6   zLimit cannot be less than 1z#%(lon1)s,%(lat1)s,%(lon2)s,%(lat2)sr<   r=   ,countrycodesr7   r?   accept-languageTr:   wktpolygon_textsvgpolygon_svgkmlpolygon_kmlgeojsonpolygon_geojsonz@Invalid geometry format. Must be one of: wkt, svg, kml, geojson.featureTypez%s.geocode: %sr5   r   )
isinstancecollectionsabcMappingitemsstructured_query_paramsupdateint
ValueError_format_bounding_boxstrr0   lowerr   r3   r&   r   debugr*   __name__r   _parse_json_call_geocoder)r)   queryr5   r   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   keyvalr2   urlcallbacks                      r+   geocodeNominatim.geocode   s*   x e[__4455 ;;= ! C666    F 5\Ff
 	 F7OJEqy !>??#F7O $ 9 9>!@F9  !F9MmS))*OM%(XXm%<F>"'(F#$$%F=!(0F$%"&F;~~'H5 )*~&U"()}%U"()}%Y&,-()(. 
 $/F=!!!$((F3%t~~'>'>D4++E""3'"BBKs   HH)r5   r   r8   r7   zoomr?   c                    U R                  U5      R                  S5      u  pUU	SS.n
U(       a  XJS'   U(       a  SOSU
S'   Ub  XjS	'   U(       a  SU
S
'   U R                  U R                  U
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 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.
    Either uses standard
    `RFC2616 <http://www.ietf.org/rfc/rfc2616.txt>`_
    accept-language string or a simple comma-separated
    list of language codes.

:param bool addressdetails: Whether or not to include address details,
    such as city, county, state, etc. in *Location.raw*

:param int zoom: Level of detail required for the address,
    an integer in range from 0 (country level) to 18 (building level),
    default is 18.

:param bool namedetails: If you want in *Location.raw* to include
    namedetails, set it to True. This will be a list of alternative names,
    including language variants, etc.

    .. versionadded:: 2.3

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

rE   z"Must be a coordinate pair or PointrC   )latlonrB   rG   rD   r   r7   rj   r?   z%s.reverse: %srQ   rR   )_coerce_point_to_stringsplitr[   r3   r(   r   r_   r*   r`   r   ra   rb   )r)   rc   r5   r   r8   r7   rj   r?   rl   rm   r2   rf   rg   s                r+   reverseNominatim.reverse+  s    d	C33E:@@EHC 

 (0$%(61A !6N$%F=!!!$"2"2F;%t~~'>'>D4++E""3'"BB+  	CABB	Cs   "C Cc                     UR                  SS 5      nUR                  SS 5      nUR                  SS 5      nUb  Ub  [        U5      n[        U5      n[        XBU4U5      $ )Nrl   rm   display_name)getfloatr
   )r)   placelatitude	longitude	placenames        r+   _parse_codeNominatim._parse_codev  sb    99UD)IIeT*	IInd3	I$9XHi(I	i#8%@@r-   c                 z   U(       d  g [        U[        R                  R                  5      (       a  SU;   a  US   S:X  a  g [	        US   5      e[        U[        R                  R
                  5      (       d  U/nU(       a  U R                  US   5      $ U Vs/ s H  o0R                  U5      PM     sn$ s  snf )NerrorzUnable to geocoder   )rS   rT   rU   rV   r   Sequencerz   )r)   placesr5   rv   s       r+   ra   Nominatim._parse_json  s    fkoo55667f;Lg"55(99&+//":":;;XF##F1I..9?@$$U+@@@s   B8)r&   r   r(   )r`   
__module____qualname____firstlineno____doc__rX   r%   r'   r   r"   r    r3   rh   rp   rz   ra   __static_attributes____classcell__)r*   s   @r+   r   r      s    " LL
 %$,( AW AWF7& $ bCP $ICVAA Ar-   r   )collections.abcrT   	functoolsr   urllib.parser   	geopy.excr   r   geopy.geocoders.baser   r   r	   geopy.locationr
   
geopy.utilr   __all__r"   r$   r    r-   r+   <module>r      sQ      " < P P # 
9    yA yAr-   