
    .hc1                         S SK Jr  S SKJr  S SKJrJrJrJrJ	r	  S SK
JrJr  S SKJr  S SKJrJrJr  S SKJr  Sr " S	 S
\5      rg)    )partial)	urlencode)GeocoderAuthenticationFailureGeocoderInsufficientPrivilegesGeocoderQueryErrorGeocoderQuotaExceededGeocoderServiceError)DEFAULT_SENTINELGeocoder)Location)ensure_pytz_is_installedfrom_fixed_gmt_offsetfrom_timezone_name)logger)GeoNamesc                      ^  \ rS rS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 jrS\	SSSS.S jrS rS r\	S.S jrS rS rS rSrU =r$ )r      zGeoNames geocoder.

Documentation at:
    http://www.geonames.org/export/geonames-search.html

Reverse geocoding documentation at:
    http://www.geonames.org/export/web-services.html#findNearbyPlaceName
z/searchJSONz/findNearbyPlaceNameJSONz/findNearbyJSONz/timezoneJSONNhttpzapi.geonames.org)timeoutproxies
user_agentssl_contextadapter_factoryschemedomainc          	      ^  > [         T	U ]  UUUUUUS9  Xl        U R                  < SU< U R                  < 3U l        U R                  < SU< U R                  < 3U l        U R                  < SU< U R                  < 3U l	        U R                  < SU< U R                  < 3U l        g)a  

:param str username: GeoNames username, required. Sign up here:
    http://www.geonames.org/login

: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

:param str scheme:
    See :attr:`geopy.geocoders.options.default_scheme`. Note that
    at the time of writing GeoNames doesn't support `https`, so
    the default scheme is `http`. The value of
    :attr:`geopy.geocoders.options.default_scheme` is not respected.
    This parameter is present to make it possible to switch to
    `https` once GeoNames adds support for it.

:param str domain: base api domain

    .. versionadded:: 2.4
)r   r   r   r   r   r   z://N)super__init__usernamer   geocode_pathapireverse_pathapi_reversereverse_nearby_pathapi_reverse_nearbytimezone_pathapi_timezone)
selfr   r   r   r   r   r   r   r   	__class__s
            kC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\geopy/geocoders/geonames.pyr   GeoNames.__init__&   s    ^ 	!#+ 	 	
 !  ;;0A0AB 	  ;;0A0AB 	  ;;0H0HI 	  ;;0B0BC 	    T)exactly_oner   countrycountry_biasc                   SU4SU R                   4/nU(       a  UR                  SU45        U(       d  / n[        U[        5      (       a  U/nU H  nUR                  SU45        M     U(       a  UR                  S5        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$ )
aV  
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 country: Limit records to the specified countries.
    Two letter country code ISO-3166 (e.g. ``FR``). Might be
    a single string or a list of strings.
:type country: str or list

:param str country_bias: Records from the country_bias are listed first.
    Two letter country code ISO-3166.

:rtype: ``None``, :class:`geopy.location.Location` or a list of them, if
    ``exactly_one=False``.
qr   countryBiasr.   )maxRows   ?z%s.geocode: %sr-   r   )r   append
isinstancestrjoinr!   r   r   debugr)   __name__r   _parse_json_call_geocoder)
r(   queryr-   r   r.   r/   paramscountry_itemurlcallbacks
             r*   geocodeGeoNames.geocodel   s    D %L'

 MM=,78Ggs##iG#LMM9l34 $ MM.)hh)F"345%t~~'>'>D4++E""3'"BBr,   findNearbyPlaceName)r-   r   feature_codelangfind_nearby_typec                v    U R                  U5      R                  S5      u  pxUS:X  aJ  U(       a  [        S5      eU R                  UUUS9n	SR	                  U R
                  [        U	5      45      n
O^US:X  aJ  U(       a  [        S5      eU R                  UUUS	9n	SR	                  U R                  [        U	5      45      n
O[        S
U-  5      e[        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 feature_code: A GeoNames feature code

:param str lang: language of the returned ``name`` element (the pseudo
    language code 'local' will return it in local language)
    Full list of supported languages can be found here:
    https://www.geonames.org/countries/

:param str find_nearby_type: A flag to switch between different
    GeoNames API endpoints. The default value is ``findNearbyPlaceName``
    which returns the closest populated place. Another currently
    implemented option is ``findNearby`` which returns
    the closest toponym for the lat/lng query.

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

,"Must be a coordinate pair or PointrG   zMfind_nearby_type=findNearbyPlaceName doesn't support the `feature_code` param)latlngrI   r5   
findNearbyz<find_nearby_type=findNearby doesn't support the `lang` param)rN   rO   rH   z/`%s` find_nearby_type is not supported by geopyz%s.reverse: %sr6   r7   )_coerce_point_to_stringsplit
ValueError&_reverse_find_nearby_place_name_paramsr;   r#   r   _reverse_find_nearby_paramsr%   r   r   r<   r)   r=   r   r>   r?   )r(   r@   r-   r   rH   rI   rJ   rN   rO   rA   rC   rD   s               r*   reverseGeoNames.reverse   s]   X	C33E:@@EHC 44 /  @@ A F
 ((D,,i.?@AC- R  55) 6 F
 ((D33Yv5FGHC$ADTT  	%t~~'>'>D4++E""3'"BBC  	CABB	Cs   "D" "D8c                 <    UUU R                   S.nU(       a  X4S'   U$ )NrN   rO   r   featureCoder   )r(   rN   rO   rH   rA   s        r*   rU   $GeoNames._reverse_find_nearby_params   s(    

 $0=!r,   c                 <    UUU R                   S.nU(       a  X4S'   U$ )NrY   rI   r[   )r(   rN   rO   rI   rA   s        r*   rT   /GeoNames._reverse_find_nearby_place_name_params   s'    

 !6Nr,   r7   c                   [        5          U R                  U5      R                  S5      u  p4UUU R                  S.nSR                  U R                  [        U5      45      n[        R                  " SU R                  R                  U5        U R                  X`R                  US9$ ! [         a    [        S5      ef = f)a  
Find the timezone for a point in `query`.

GeoNames always returns a timezone: if the point being queried
doesn't have an assigned Olson timezone id, a ``pytz.FixedOffset``
timezone is used to produce the :class:`geopy.timezone.Timezone`.

:param query: The coordinates for which you want a timezone.
:type query: :class:`geopy.point.Point`, list or tuple of (latitude,
    longitude), or string as "%(latitude)s, %(longitude)s"

: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.

:rtype: :class:`geopy.timezone.Timezone`.
rL   rM   rY   r5   z%s.reverse_timezone: %sr7   )r   rQ   rR   rS   r   r;   r'   r   r   r<   r)   r=   r?   _parse_json_timezone)r(   r@   r   rN   rO   rA   rC   s          r*   reverse_timezoneGeoNames.reverse_timezone  s    & 	!"	C33E:@@EHC
 
 hh))9V+<=>.0G0GM""3(A(A7"SS  	CABB	Cs   "B* *C c                     UR                  S5      nU(       aX  US   nUS   nUR                  S5      (       a  [        U5      eUS:X  a  [        U5      eUS;   a  [	        U5      e[        U5      eg )Nstatusvaluemessagezuser account not enabled to use
   )         )get
startswithr   r   r   r	   )r(   bodyerrcoderf   s        r*   _raise_for_errorGeoNames._raise_for_error-  sw    hhx w<D)nG!!"CDD4W==rz3G<<|#+G44&w// r,   c                 z    U R                  U5        UR                  S5      nUc  US   n[        X1S9$ [        X!S9$ )N
timezoneId	rawOffset)raw)rp   rk   r   r   )r(   responsetimezone_id
raw_offsets       r*   r`   GeoNames._parse_json_timezone;  sF    h'll<0
 "+.J(BB%k@@r,   c                     UR                  S/ 5      nU R                  U5        [        U5      (       d  gS nU(       a  U" US   5      $ U Vs/ s H
  oT" U5      PM     sn$ s  snf )z
Parse JSON response body.
geonamesNc                 ~   U R                  SS5      nU R                  SS5      nU(       a  U(       a  [        U5      n[        U5      nOgU R                  S5      nU R                  SS5      nU R                  SS5      nSR                  X4U4 Vs/ s H  of(       d  M  UPM     sn5      n[        XqU4U 5      $ s  snf )z
Parse each record.
rN   NrO   name
adminName1countryNamez, )rk   floatr;   r   )placelatitude	longitude	placenamestater.   xlocations           r*   
parse_code(GeoNames._parse_json.<locals>.parse_codeR  s     yy-H		%.II ?!),			&)IIIlD1Eiit4Gyy&w7=7q17=H H&;UCC >s   
B:B:r   )rk   rp   len)r(   docr-   placesr   r   s         r*   r>   GeoNames._parse_jsonI  se     R(c"6{{	D, fQi((39:6%Ju%6:::s   A")r!   r#   r%   r'   r   )r=   
__module____qualname____firstlineno____doc__r    r"   r$   r&   r
   r   rE   rV   rU   rT   ra   rp   r`   r>   __static_attributes____classcell__)r)   s   @r*   r   r      s     !L-L+#M %$( %D
 D
T $5Cv $2OCb 2B #TJ0A"; ";r,   r   N)	functoolsr   urllib.parser   	geopy.excr   r   r   r   r	   geopy.geocoders.baser
   r   geopy.locationr   geopy.timezoner   r   r   
geopy.utilr   __all__r    r,   r*   <module>r      s?     "  < # 
 
T;x T;r,   