Ë
    Ï.f™  ã                   ón   — d dl mZ d dlmZmZ d dlmZmZ d dlm	Z	 d dl
mZ d dlmZ dZ G d„ d	e«      Zy
)é    )Úpartial)ÚquoteÚ	urlencode)ÚDEFAULT_SENTINELÚGeocoder©ÚLocation)ÚPoint)Úlogger)ÚMapTilerc                   ód   ‡ — e Zd ZdZdZdeededddœˆ fd„
Zdd„Zdedddd	œd
„Zdeddœd„Z	ˆ xZ
S )r   z}Geocoder using the MapTiler API.

    Documentation at:
        https://cloud.maptiler.com/geocoding/ (requires sign-up)
    z/geocoding/%(query)s.jsonNzapi.maptiler.com)ÚschemeÚtimeoutÚproxiesÚ
user_agentÚssl_contextÚadapter_factoryÚdomainc                óÂ   •— t         ‰	| �  ||||||¬«       || _        |j                  d«      | _        | j
                  ›d| j                  ›| j                  ›�| _        y)a¾  
        :param str api_key: The API key required by Maptiler to perform
            geocoding requests. API keys are managed through Maptiler's account
            page (https://cloud.maptiler.com/account/keys).

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

            .. versionadded:: 2.0

        :param str domain: base api domain for Maptiler
        )r   r   r   r   r   r   ú/z://N)ÚsuperÚ__init__Úapi_keyÚstripr   r   Úapi_pathÚapi)
Úselfr   r   r   r   r   r   r   r   Ú	__class__s
            €úWC:\Users\user\Documents\project_loop\venv\Lib\site-packages\geopy/geocoders/maptiler.pyr   zMapTiler.__init__   s]   ø€ ôP 	‰ÑØØØØ!Ø#Ø+ð 	ô 	
ð ˆŒØ—l‘l 3Ó'ˆŒØ"&§+£+¨t¯{ª{¸D¿MºMÐJˆ�ó    Tc                 óh   — |d   }|sy d„ }|r ||d   «      S |D �cg c]
  } ||«      ‘Œ c}S c c}w )NÚfeaturesc                 óJ   — | d   }| d   d   }| d   d   }t        |||f| «      S )NÚ
place_nameÚcenterr   é   r   )ÚfeatureÚlocationÚ	longitudeÚlatitudes       r   Úparse_featurez+MapTiler._parse_json.<locals>.parse_featureO   s>   € Ø˜|Ñ,ˆHØ Ñ)¨!Ñ,ˆIØ˜xÑ(¨Ñ+ˆHä˜H x°Ð&;¸WÓEÐEr    r   © )r   ÚjsonÚexactly_oner"   r+   r'   s         r   Ú_parse_jsonzMapTiler._parse_jsonI   sE   € à˜
Ñ#ˆÙØò	Fñ Ù  ¨!¡Ó-Ð-à:BÖC¨w‘M 'Õ*ÒCÐCùÒCs   �/)r.   r   Ú	proximityÚlanguageÚbboxc                ó>  — d| j                   i}|}|r| j                  |d«      |d<   t        |t        «      r|g}|rdj	                  |«      |d<   |r)t        |«      }|j                  ›d|j                  ›�|d<   t        |j                  d«      «      }	dj	                  | j                  t        |	¬	«      z  t        |«      f«      }
t        j                  d
| j                  j                   |
«       t#        | j$                  |¬«      }| j'                  |
||¬«      S )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 proximity: A coordinate to bias local results based on a provided
            location.
        :type proximity: :class:`geopy.point.Point`, list or tuple of ``(latitude,
            longitude)``, or string as ``"%(latitude)s, %(longitude)s"``.

        :param language: Prefer results in specific languages. Accepts
            a single string like ``"en"`` or a list like ``["de", "en"]``.
        :type language: str or list

        :param bbox: The bounding box of the viewport within which
            to bias geocode results more prominently.
            Example: ``[Point(22, 180), Point(-22, -180)]``.
        :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``.
        Úkeyz#%(lon1)s,%(lat1)s,%(lon2)s,%(lat2)sr2   ú,r1   r0   úutf-8ú?©Úqueryz%s.geocode: %s©r.   ©r   )r   Ú_format_bounding_boxÚ
isinstanceÚstrÚjoinr
   r)   r*   r   Úencoder   Údictr   r   Údebugr   Ú__name__r   r/   Ú_call_geocoder)r   r9   r.   r   r0   r1   r2   ÚparamsÚpÚquoted_queryÚurlÚcallbacks               r   ÚgeocodezMapTiler.geocodeZ   s  € ðR ˜Ÿ™Ð&ˆàˆÙØ!×6Ñ6ØÐ;ó=ˆF�6‰Nô �h¤Ô$Ø �zˆHÙØ!$§¡¨(Ó!3ˆF�:ÑáÜ�iÓ ˆAØ-.¯[«[¸!¿*º*Ð"EˆF�;Ñä˜UŸ\™\¨'Ó2Ó3ˆØ�h‰h˜Ÿ™¤4¨lÔ#;Ñ;Ü! &Ó)ð+ó ,ˆä�‰Ð% t§~¡~×'>Ñ'>ÀÔDÜ˜4×+Ñ+¸ÔEˆØ×"Ñ" 3¨¸'Ð"ÓBÐBr    )r.   r   r1   c                óÚ  — d| j                   i}t        |t        «      r|g}|rdj                  |«      |d<   | j	                  |d«      }t        |j                  d«      «      }dj                  | j                  t        |¬«      z  t        |«      f«      }t        j                  d| j                  j                  |«       t        | j                  |¬	«      }	| j!                  ||	|¬
«      S )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 language: Prefer results in specific languages. Accepts
            a single string like ``"en"`` or a list like ``["de", "en"]``.
        :type language: str or list

        :rtype: ``None``, :class:`geopy.location.Location` or a list of them, if
            ``exactly_one=False``.
        r4   r5   r1   z%(lon)s,%(lat)sr6   r7   r8   z%s.reverse: %sr:   r;   )r   r=   r>   r?   Ú_coerce_point_to_stringr   r@   r   rA   r   r   rB   r   rC   r   r/   rD   )
r   r9   r.   r   r1   rE   ÚpointrG   rH   rI   s
             r   ÚreversezMapTiler.reverseš   sÏ   € ð> ˜Ÿ™Ð&ˆä�h¤Ô$Ø �zˆHÙØ!$§¡¨(Ó!3ˆF�:Ñà×,Ñ,¨UÐ4EÓFˆÜ˜UŸ\™\¨'Ó2Ó3ˆØ�h‰h˜Ÿ™¤4¨lÔ#;Ñ;Ü! &Ó)ð+ó ,ˆä�‰Ð% t§~¡~×'>Ñ'>ÀÔDÜ˜4×+Ñ+¸ÔEˆØ×"Ñ" 3¨¸'Ð"ÓBÐBr    )T)rC   Ú
__module__Ú__qualname__Ú__doc__r   r   r   r/   rJ   rN   Ú__classcell__)r   s   @r   r   r      sb   ø„ ñð +€Hð Ø$Ø$ØØ(Ø Ø%ö2KóhDð* Ø$ØØØô>CðH Ø$Ø÷,Cð ,Cr    r   N)Ú	functoolsr   Úurllib.parser   r   Úgeopy.geocoders.baser   r   Úgeopy.locationr	   Úgeopy.pointr
   Ú
geopy.utilr   Ú__all__r   r,   r    r   ú<module>rZ      s,   ðÝ ß )ç ;Ý #Ý Ý à
€ôzCˆxõ zCr    