
    .h                     r    S SK Jr  S SKJr  S SKJrJr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
)    )partial)	urlencode)GeocoderAuthenticationFailureGeocoderQuotaExceededGeocoderServiceError)DEFAULT_SENTINELGeocoder)Location)logger)GeocodeFarmc                   ~   ^  \ rS rSrSrSrSr S\\S\SSS.U 4S jjjrS\S	.S
 jr	S\S	.S jr
S rS rS rSrU =r$ )r      zvGeocoder using the GeocodeFarm API.

Documentation at:
    https://www.geocode.farm/geocoding/free-api-documentation/
z/v3/json/forward/z/v3/json/reverse/N)timeoutproxies
user_agentssl_contextadapter_factoryschemec          	         > [         T	U ]  UUUUUUS9  Xl        SnU R                  < SU< U R                  < 3U l        U R                  < SU< U R                  < 3U l        g)a  

:param str api_key: (optional) The API key required by GeocodeFarm
    to perform geocoding requests.

: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`.
)r   r   r   r   r   r   zwww.geocode.farmz://N)super__init__api_keyr   geocode_pathapireverse_pathreverse_api)
selfr   r   r   r   r   r   r   domain	__class__s
            nC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\geopy/geocoders/geocodefarm.pyr   GeocodeFarm.__init__   so    J 	!#+ 	 	
 #;;0A0AB 	  ;;0A0AB 	    T)exactly_oner   c                6   SU0nU R                   (       a  U R                   US'   SR                  U R                  [        U5      45      n[        R
                  " SU R                  R                  U5        [        U R                  US9nU R                  XVUS9$ )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.

:rtype: ``None``, :class:`geopy.location.Location` or a list of them, if
    ``exactly_one=False``.
addrkey?z%s.geocode: %sr#   r   )r   joinr   r   r   debugr   __name__r   _parse_json_call_geocoder)r   queryr#   r   paramsurlcallbacks          r    geocodeGeocodeFarm.geocodeP   s    $ E
 << LLF5Mhh)F"345%t~~'>'>D4++E""3'"BBr"   c                    U R                  U5      R                  S5      u  pEUUS.nU R                  (       a  U R                  US'   SR	                  U R
                  [        U5      45      n[        R                  " SU R                  R                  U5        [        U R                  US9nU R                  XxU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. GeocodeFarm's API will always return at most one
    result.

: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: ``None``, :class:`geopy.location.Location` or a list of them, if
    ``exactly_one=False``.
,z"Must be a coordinate pair or Point)latlonr&   r'   z%s.reverse: %sr(   r)   )_coerce_point_to_stringsplit
ValueErrorr   r*   r   r   r   r+   r   r,   r   r-   r.   )	r   r/   r#   r   r7   r8   r0   r1   r2   s	            r    reverseGeocodeFarm.reversek   s    *	C33E:@@EHC 
 << LLF5Mhh(()F*;<=%t~~'>'>D4++E""3'"BB  	CABB	Cs   "B? ?Cc                    / nUR                  S5       H  nUR                  S0 5      nUR                  S0 5      nUR                  SS 5      nUR                  SS 5      nUR                  SS 5      nUc  UR                  SS 5      nUc  UR                  SS 5      nU(       a  U(       a  [        U5      n[        U5      nUR                  [        XU4U5      5        M     U$ )	NRESULTSCOORDINATESADDRESSlatitude	longitudeaddress_returnedaddressformatted_address)getfloatappendr
   )	r   resultsplacesresultcoordinatesrE   rB   rC   	placenames	            r    _parse_codeGeocodeFarm._parse_code   s    kk),F **]B7KjjB/G"z48H#T:I$6=I #KK	48	 "JJ':DA	I ?!),	MM(9.CVLM - r"   c                     Uc  g US   nU R                  U5        SUR                  S0 5      R                  SS5      ;   a  g U R                  U5      nU(       a  US   $ U$ )Ngeocoding_results
NO_RESULTSSTATUSstatus r   )_check_for_api_errorsrG   rO   )r   
api_resultr#   rR   rK   s        r    r-   GeocodeFarm._parse_json   so    &':;""#45,002>BB8RPP!!"34!9Mr"   c                    UR                  S0 5      nSUR                  SS5      ;   a  gUR                  SS5      S:H  nU(       d<  UR                  S5      n[        [        S.nUR                  U[        5      nU" U5      eg)	zK
Raise any exceptions if there were problems reported
in the api response.
rT   rS   rU   rV   NSUCCESSaccess)API_KEY_INVALIDOVER_QUERY_LIMIT)rG   r   r   r   )r   rR   status_resultapi_call_successaccess_erroraccess_error_to_exceptionexception_clss          r    rW   !GeocodeFarm._check_for_api_errors   s    
 *--h;=,,Xr::(,,Xr:iG(,,X6L#@$9)% 6992M  --  r"   )r   r   r   )N)r,   
__module____qualname____firstlineno____doc__r   r   r   r   r3   r<   rO   r-   rW   __static_attributes____classcell__)r   s   @r    r   r      sn     'L&L 4
 %$( 4
 4
l -1:J C6 -1:J "CH&. .r"   r   N)	functoolsr   urllib.parser   	geopy.excr   r   r   geopy.geocoders.baser   r	   geopy.locationr
   
geopy.utilr   __all__r    r"   r    <module>rs      s3     " 
 < # 
s.( s.r"   