
    N}bg                     v    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d
S )    )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                                          ||||||           || _        |                    d          | _        | j        d| j        | j        | _        dS )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
            k/home/e360mart.nyusoft.in/public_html/e360mart_env/lib/python3.11/site-packages/geopy/geocoders/maptiler.pyr   zMapTiler.__init__   su    P 	!#+ 	 	
 	
 	
 ll3''"&+++t{{DMMJ    Tc                 d    |d         }|sd S d |r |d                   S fd|D             S )Nfeaturesc                 p    | 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   sA    |,H)!,Ix(+HHx&;WEEEr    r   c                 &    g | ]} |          S  r-   ).0r'   r+   s     r   
<listcomp>z(MapTiler._parse_json.<locals>.<listcomp>X   s#    CCCwMM'**CCCr    r-   )r   jsonexactly_oner"   r+   s       @r   _parse_jsonzMapTiler._parse_jsonI   se    
# 	4	F 	F 	F  	D =!---CCCC(CCCCr    )r1   r   	proximitylanguagebboxc                P   d| j         i}|}|r|                     |d          |d<   t          |t                    r|g}|rd                    |          |d<   |r#t          |          }|j        d|j        |d<   t          |	                    d                    }	d                    | j
        t          |		          z  t          |          f          }
t          j        d
| j        j        |
           t#          | 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)sr5   ,r4   r3   utf-8?queryz%s.geocode: %sr1   r   )r   _format_bounding_box
isinstancestrjoinr
   r)   r*   r   encoder   dictr   r   debugr   __name__r   r2   _call_geocoder)r   r<   r1   r   r3   r4   r5   paramspquoted_queryurlcallbacks               r   geocodezMapTiler.geocodeZ   s?   R & 	=!66;= =F6N h$$ 	" zH 	4!$(!3!3F: 	Fi  A-.[[[!**"EF;U\\'2233hh4l#;#;#;;!&))+ , ,%t~'>DDD4+EEE""3'"BBBr    )r1   r   r4   c                   d| j         i}t          |t                    r|g}|rd                    |          |d<   |                     |d          }t          |                    d                    }d                    | j        t          |          z  t          |          f          }t          j        d| j        j        |           t          | 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``.
        r7   r8   r4   z%(lon)s,%(lat)sr9   r:   r;   z%s.reverse: %sr=   r>   )r   r@   rA   rB   _coerce_point_to_stringr   rC   r   rD   r   r   rE   r   rF   r   r2   rG   )
r   r<   r1   r   r4   rH   pointrJ   rK   rL   s
             r   reversezMapTiler.reverse   s    > &h$$ 	" zH 	4!$(!3!3F:,,U4EFFU\\'2233hh4l#;#;#;;!&))+ , ,%t~'>DDD4+EEE""3'"BBBr    )T)rF   
__module____qualname____doc__r   r   r   r2   rM   rQ   __classcell__)r   s   @r   r   r      s          +H $$( %2K 2K 2K 2K 2K 2K 2KhD D D D* $>C >C >C >C >CH $,C ,C ,C ,C ,C ,C ,C ,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>r]      s          ) ) ) ) ) ) ) ) ; ; ; ; ; ; ; ; # # # # # #            
zC zC zC zC zCx zC zC zC zC zCr    