Ë
    Ï.fª  ã                   óz   — d dl mZ d dlmZ d dlmZmZmZmZm	Z	 d dl
mZmZ d dlmZ d dlmZ dZ G d„ d	e«      Zy
)é    )Úpartial)Ú	urlencode)ÚGeocoderAuthenticationFailureÚGeocoderQueryErrorÚGeocoderQuotaExceededÚGeocoderServiceErrorÚGeocoderUnavailable)ÚDEFAULT_SENTINELÚGeocoder)ÚLocation)Úlogger)ÚGeokeoc                   óh   ‡ — e Zd ZdZdZdZddeededdœˆ fd„
Zdded	œd
„Zdedœd„Z	dd„Z
d„ Zˆ xZS )r   z‚Geocoder using the geokeo API.

    Documentation at:
        https://geokeo.com/documentation.php

    .. versionadded:: 2.4
    z/geocode/v1/search.phpz/geocode/v1/reverse.phpz
geokeo.comN)ÚdomainÚschemeÚtimeoutÚproxiesÚ
user_agentÚssl_contextÚadapter_factoryc                ó  •— t         ‰	| �  ||||||¬«       || _        |j                  d«      | _        | j
                  ›d| j                  ›| j                  ›�| _        | j
                  ›d| j                  ›| j                  ›�| _	        y)a�  

        :param str api_key: The API key required by Geokeo.com
            to perform geocoding requests. You can get your key here:
            https://geokeo.com/

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

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

        )r   r   r   r   r   r   ú/z://N)
ÚsuperÚ__init__Úapi_keyÚstripr   r   Úgeocode_pathÚapiÚreverse_pathÚreverse_api)
Úselfr   r   r   r   r   r   r   r   Ú	__class__s
            €úUC:\Users\user\Documents\project_loop\venv\Lib\site-packages\geopy/geocoders/geokeo.pyr   zGeokeo.__init__   s|   ø€ ôR 	‰ÑØØØØ!Ø#Ø+ð 	ô 	
ð ˆŒØ—l‘l 3Ó'ˆŒØ"&§+£+¨t¯{ª{¸D×<MÒ<MÐNˆŒØ*.¯+«+°t·{²{ÀD×DUÒDUÐVˆÕó    T)ÚcountryÚexactly_oner   c                ó&  — | j                   |dœ}|r||d<   dj                  | j                  t        |«      f«      }t	        j
                  d| j                  j                  |«       t        | j                  |¬«      }| j                  |||¬«      S )aJ  
        Return a location point by address.

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

        :param str country: Restricts the results to the specified
            country. The country code is a 2 character code as
            defined by the ISO 3166-1 Alpha 2 standard (e.g. ``us``).

        :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``.
        )r   Úqr%   ú?z%s.geocode: %s©r&   ©r   )r   Újoinr   r   r   Údebugr"   Ú__name__r   Ú_parse_jsonÚ_call_geocoder)r!   Úqueryr%   r&   r   ÚparamsÚurlÚcallbacks           r#   ÚgeocodezGeokeo.geocodeU   s…   € ð: —<‘<Øñ
ˆñ
 Ø 'ˆF�9Ñà�h‰h˜Ÿ™¤)¨FÓ"3Ð4Ó5ˆä�‰Ð% t§~¡~×'>Ñ'>ÀÔDÜ˜4×+Ñ+¸ÔEˆØ×"Ñ" 3¨¸'Ð"ÓBÐBr$   )r&   r   c                ó’  — 	 | j                  |«      j                  d«      \  }}| j                  ||dœ}dj	                  | j
                  t        |«      f«      }t        j                  d| j                  j                  |«       t        | j                  |¬«      }| j                  |||¬«      S # t        $ r t        d«      ‚w xY w)aL  
        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.

        :rtype: ``None``, :class:`geopy.location.Location` or a list of them, if
            ``exactly_one=False``.
        ú,z"Must be a coordinate pair or Point)r   ÚlatÚlngr)   z%s.reverse: %sr*   r+   )Ú_coerce_point_to_stringÚsplitÚ
ValueErrorr   r,   r    r   r   r-   r"   r.   r   r/   r0   )	r!   r1   r&   r   r8   r9   r2   r3   r4   s	            r#   ÚreversezGeokeo.reverse   sÁ   € ð6	CØ×3Ñ3°EÓ:×@Ñ@ÀÓE‰HˆC�ð
 —<‘<ØØñ
ˆð �h‰h˜×(Ñ(¬)°FÓ*;Ð<Ó=ˆä�‰Ð% t§~¡~×'>Ñ'>ÀÔDÜ˜4×+Ñ+¸ÔEˆØ×"Ñ" 3¨¸'Ð"ÓBÐBøô ò 	CÜÐAÓBÐBð	Cús   ‚#B1 Â1Cc                 ó¤   — |j                  dg «      }| j                  |«       |sy d„ }|r ||d   «      S |D �cg c]
  } ||«      ‘Œ c}S c c}w )NÚresultsc                 ón   — | j                  d«      }| d   d   d   }| d   d   d   }t        |||f| «      S )z4Get the location, lat, lng from a single json place.Úformatted_addressÚgeometryÚlocationr8   r9   )Úgetr   )ÚplacerC   ÚlatitudeÚ	longitudes       r#   Úparse_placez'Geokeo._parse_json.<locals>.parse_place±   sM   € à—y‘yÐ!4Ó5ˆHØ˜ZÑ(¨Ñ4°UÑ;ˆHØ˜jÑ)¨*Ñ5°eÑ<ˆIÜ˜H x°Ð&;¸UÓCÐCr$   r   )rD   Ú_check_status)r!   Úpager&   ÚplacesrH   rE   s         r#   r/   zGeokeo._parse_json«   sY   € Ø—‘˜) RÓ(ˆØ×Ñ˜4Ô ÙØò	Dñ Ù˜v a™yÓ)Ð)à4:Ö;¨5‘K Õ&Ò;Ð;ùÒ;s   »Ac                 óö   — |j                  d«      xs dj                  «       }|dk(  ry |dk(  ry |dk(  rt        d«      ‚|dk(  rt        d«      ‚|d	k(  rt	        d
«      ‚|dk(  rt        d«      ‚t        d«      ‚)NÚstatusÚ ÚOKÚZERO_RESULTSÚINVALID_REQUESTzInvalid request parametersÚACCESS_DENIEDzAccess deniedÚOVER_QUERY_LIMITzOver query limitÚINTERNAL_SERVER_ERRORzInternal server errorzUnknown error)rD   Úupperr   r   r   r	   r   )r!   rJ   rM   s      r#   rI   zGeokeo._check_status½   s”   € Ø—(‘(˜8Ó$Ò*¨×1Ñ1Ó3ˆð �TŠ>ØØ�^Ò#ØàÐ&Ò&Ü$Ð%AÓBÐBØ�Ò&Ü/°Ó@Ð@ØÐ)Ò)Ü'Ð(:Ó;Ð;ØÐ.Ò.Ü%Ð&=Ó>Ð>ô ' Ó7Ð7r$   )T)r.   Ú
__module__Ú__qualname__Ú__doc__r   r   r
   r   r5   r=   r/   rI   Ú__classcell__)r"   s   @r#   r   r      s]   ø„ ñð ,€LØ,€Lð  ØØ$Ø$ØØ(Ø ö5Wðv ØØ$ô(Cð\ Ø$ô*CóX<ö$8r$   r   N)Ú	functoolsr   Úurllib.parser   Ú	geopy.excr   r   r   r   r	   Úgeopy.geocoders.baser
   r   Úgeopy.locationr   Ú
geopy.utilr   Ú__all__r   © r$   r#   ú<module>rb      s3   ðÝ Ý "÷õ ÷ <Ý #Ý à
€ô~8ˆXõ ~8r$   