Ë
    t™ãj
8  ã                   óÈ   — d dl Z d dlmZ d dlmZ d dlmZ d dlmZm	Z	 d dl
mZ d dlmZ dZ e j                  d	e j                   «      Zd
„ Z G d„ de	«      Z G d„ de	«      Zy)é    N)Úpartial)Ú	urlencode)Úexc)ÚDEFAULT_SENTINELÚGeocoder)ÚLocation)Úlogger)Ú
What3WordsÚWhat3WordsV3z-[^\W\d\_]+\.{1,1}[^\W\d\_]+\.{1,1}[^\W\d\_]+$c                 ó>   — t        t        j                  | «      «      S )z)
    Check query validity with regex
    )ÚboolÚ_MULTIPLE_WORD_REÚmatch)Úquerys    úe/var/www/html/python-recuperauto-other/env/lib/python3.12/site-packages/geopy/geocoders/what3words.pyÚ_check_queryr      s   € ô Ô!×'Ñ'¨Ó.Ó/Ð/ó    c                   ój   ‡ — e Zd ZdZdZdZeededddœˆ fd„
Zdd	ed
œd„Zdd„Z	dd	ed
œd„Z
dd„Zˆ xZS )r
   z¿What3Words geocoder using the legacy V2 API.

    Documentation at:
        https://docs.what3words.com/api/v2/

    .. attention::
        Consider using :class:`.What3WordsV3` instead.
    z/v2/forwardz/v2/reverseNúapi.what3words.com©ÚtimeoutÚproxiesÚ
user_agentÚssl_contextÚadapter_factoryÚdomainc                óÆ   •— t         ‰| �  d|||||¬«       || _        | j                  ›d|›| j                  ›�| _        | j                  ›d|›| j                  ›�| _        y)a  

        :param str api_key: Key provided by What3Words
            (https://accounts.what3words.com/register).

        :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

            .. versionadded:: 2.4
        Úhttps©Úschemer   r   r   r   r   ú://N©ÚsuperÚ__init__Úapi_keyr    Úgeocode_pathÚgeocode_apiÚreverse_pathÚreverse_api©	Úselfr%   r   r   r   r   r   r   Ú	__class__s	           €r   r$   zWhat3Words.__init__%   se   ø€ ôL 	‰ÑØØØØ!Ø#Ø+ð 	ô 	
ð ˆŒØ*.¯+«+±v¸t×?PÒ?PÐQˆÔØ*.¯+«+±v¸t×?PÒ?PÐQˆÕr   ÚenT©ÚlangÚexactly_oner   c                óv  — t        |«      st        j                  d«      ‚||j                  «       | j                  dœ}dj                  | j                  t        |«      f«      }t        j                  d| j                  j                  |«       t        | j                  |¬«      }| j                  |||¬«      S )a(  
        Return a location point for a `3 words` query. If the `3 words` address
        doesn't exist, a :class:`geopy.exc.GeocoderQueryError` exception will be
        thrown.

        :param str query: The 3-word address you wish to geocode.

        :param str lang: two character language code as supported by
            the API (https://docs.what3words.com/api/v2/#lang).

        :param bool exactly_one: Return one result or a list of results, if
            available. Due to the address scheme there is always exactly one
            result for each `3 words` address, so this parameter is rather
            useless for this geocoder.

        :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.location.Location` or a list of them, if
            ``exactly_one=False``.
        ú&Search string must be 'word.word.word')Úaddrr/   Úkeyú?ú%s.geocode: %s©r0   ©r   )r   r   ÚGeocoderQueryErrorÚlowerr%   Újoinr'   r   r	   Údebugr,   Ú__name__r   Ú_parse_jsonÚ_call_geocoder©r+   r   r/   r0   r   ÚparamsÚurlÚcallbacks           r   ÚgeocodezWhat3Words.geocodeX   s¤   € ôB ˜EÔ"Ü×(Ñ(Ø8óð ð
 Ø—J‘J“LØ—<‘<ñ
ˆð �h‰h˜×(Ñ(¬)°FÓ*;Ð<Ó=ˆÜ�‰Ð% t§~¡~×'>Ñ'>ÀÔDÜ˜4×+Ñ+¸ÔEˆØ×"Ñ" 3¨¸'Ð"ÓBÐBr   c                 óÆ   — |d   j                  d«      }|r:d|d   d   z  }|dk(  rt        j                  |«      ‚t        j                  |«      ‚d„ } ||«      }|r|S |gS )úg
        Parse type, words, latitude, and longitude and language from a
        JSON response.
        ÚstatusÚcodeú Error returned by What3Words: %sÚmessagei‘  c                 ó®   — d| v r=| d   }| d   }|d   |d   }}|r|rt        |«      }t        |«      }t        |||f| «      S t        j                  d«      ‚)ú'
            Parse record.
            ÚgeometryÚwordsÚlatÚlngúError parsing result.©Úfloatr   r   ÚGeocoderParseError©ÚresourcerN   ÚpositionÚlatitudeÚ	longitudes        r   Úparse_resourcez.What3Words._parse_json.<locals>.parse_resource™   so   € ð
 ˜XÑ%Ø  Ñ)�Ø# JÑ/�Ø&.¨u¡o°xÀ±˜)�Ù¡	Ü$ X›�HÜ % iÓ 0�Iä ¨°)Ð'<¸hÓGÐGä×,Ñ,Ð-DÓEÐEr   ©Úgetr   ÚGeocoderAuthenticationFailurer9   )r+   Ú	resourcesr0   rH   Úexc_msgrZ   Úlocations          r   r>   zWhat3Words._parse_json‰   s{   € ð ˜Ñ"×&Ñ& vÓ.ˆáà8¸9ÀXÑ;NÈyÑ;YÑYˆGØ�sŠ{Ü×7Ñ7¸Ó@Ð@ä×(Ñ(¨Ó1Ð1ò	Fñ" " )Ó,ˆÙØˆOà�:Ðr   c                ót  — |j                  «       }| j                  |«      |j                  «       | j                  dœ}dj                  | j                  t        |«      f«      }t        j                  d| j                  j                  |«       t        | j                  |¬«      }| j                  |||¬«      S )aË  
        Return a `3 words` address by location point. Each point on the surface has
        a `3 words` address, so there's always a non-empty response.

        :param query: The coordinates for which you wish to obtain the 3 word
            address.
        :type query: :class:`geopy.point.Point`, list or tuple of ``(latitude,
            longitude)``, or string as ``"%(latitude)s, %(longitude)s"``.

        :param str lang: two character language code as supported by the
            API (https://docs.what3words.com/api/v2/#lang).

        :param bool exactly_one: Return one result or a list of results, if
            available. Due to the address scheme there is always exactly one
            result for each `3 words` address, so this parameter is rather
            useless for this geocoder.

        :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.location.Location` or a list of them, if
            ``exactly_one=False``.

        )Úcoordsr/   r4   r5   ú%s.reverse: %sr7   r8   ©r:   Ú_coerce_point_to_stringr%   r;   r)   r   r	   r<   r,   r=   r   Ú_parse_reverse_jsonr?   r@   s           r   ÚreversezWhat3Words.reverse°   sœ   € ðD �z‰z‹|ˆð ×2Ñ2°5Ó9Ø—J‘J“LØ—<‘<ñ
ˆð �h‰h˜×(Ñ(¬)°FÓ*;Ð<Ó=ˆä�‰Ð% t§~¡~×'>Ñ'>ÀÔDÜ˜4×3Ñ3ÀÔMˆØ×"Ñ" 3¨¸'Ð"ÓBÐBr   c                 ó&   — | j                  ||«      S ©zJ
        Parses a location from a single-result reverse API call.
        ©r>   ©r+   r^   r0   s      r   rf   zWhat3Words._parse_reverse_jsonà   ó   € ð ×Ñ 	¨;Ó7Ð7r   ©T©r=   Ú
__module__Ú__qualname__Ú__doc__r&   r(   r   r$   rD   r>   rg   rf   Ú__classcell__©r,   s   @r   r
   r
      s^   ø„ ñð !€LØ €Lð %Ø$ØØ(Ø Ø'ö1Rðn ØØ$ô/Cób%ðV ØØ$ô.C÷`8r   r
   c                   óh   ‡ — e Zd ZdZdZdZeededddœˆ fd„
Zded	œd
„Zdd„Z	ddedœd„Z
dd„Zˆ xZS )r   z•What3Words geocoder using the V3 API.

    Documentation at:
        https://developer.what3words.com/public-api/docs

    .. versionadded:: 2.2
    z/v3/convert-to-coordinatesz/v3/convert-to-3waNr   r   c                óÆ   •— t         ‰| �  d|||||¬«       || _        | j                  ›d|›| j                  ›�| _        | j                  ›d|›| j                  ›�| _        y)añ  

        :param str api_key: Key provided by What3Words
            (https://accounts.what3words.com/register).

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

        :param str domain: base api domain

            .. versionadded:: 2.4
        r   r   r!   Nr"   r*   s	           €r   r$   zWhat3WordsV3.__init__ó   se   ø€ ôH 	‰ÑØØØØ!Ø#Ø+ð 	ô 	
ð ˆŒØ*.¯+«+±v¸t×?PÒ?PÐQˆÔØ*.¯+«+±v¸t×?PÒ?PÐQˆÕr   T)r0   r   c                óX  — t        |«      st        j                  d«      ‚|| j                  dœ}dj	                  | j
                  t        |«      f«      }t        j                  d| j                  j                  |«       t        | j                  |¬«      }| j                  |||¬«      S )a¢  
        Return a location point for a `3 words` query. If the `3 words` address
        doesn't exist, a :class:`geopy.exc.GeocoderQueryError` exception will be
        thrown.

        :param str query: The 3-word address you wish to geocode.

        :param bool exactly_one: Return one result or a list of results, if
            available. Due to the address scheme there is always exactly one
            result for each `3 words` address, so this parameter is rather
            useless for this geocoder.

        :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.location.Location` or a list of them, if
            ``exactly_one=False``.
        r2   )rN   r4   r5   r6   r7   r8   )r   r   r9   r%   r;   r'   r   r	   r<   r,   r=   r   r>   r?   )r+   r   r0   r   rA   rB   rC   s          r   rD   zWhat3WordsV3.geocode$  sš   € ô: ˜EÔ"Ü×(Ñ(Ø8óð ð
 Ø—<‘<ñ
ˆð
 �h‰h˜×(Ñ(¬)°FÓ*;Ð<Ó=ˆÜ�‰Ð% t§~¡~×'>Ñ'>ÀÔDÜ˜4×+Ñ+¸ÔEˆØ×"Ñ" 3¨¸'Ð"ÓBÐBr   c                 óà   — |j                  d«      }|�Jd|d   d   z  }|j                  d«      }|dv rt        j                  |«      ‚t        j                  |«      ‚d„ } ||«      }|r|S |gS )rF   ÚerrorrI   rJ   rH   )Ú
MissingKeyÚ
InvalidKeyc                 ó®   — d| v r=| d   }| d   }|d   |d   }}|r|rt        |«      }t        |«      }t        |||f| «      S t        j                  d«      ‚)rL   ÚcoordinatesrN   rO   rP   rQ   rR   rU   s        r   rZ   z0What3WordsV3._parse_json.<locals>.parse_resourcea  so   € ð
  Ñ(Ø  Ñ)�Ø# MÑ2�Ø&.¨u¡o°xÀ±˜)�Ù¡	Ü$ X›�HÜ % iÓ 0�Iä ¨°)Ð'<¸hÓGÐGä×,Ñ,Ð-DÓEÐEr   r[   )r+   r^   r0   rx   r_   Úexc_coderZ   r`   s           r   r>   zWhat3WordsV3._parse_jsonP  s‡   € ð —‘˜gÓ&ˆàÐà8¸9ÀWÑ;MÈiÑ;XÑXˆGØ—y‘y Ó(ˆHØÐ7Ñ7Ü×7Ñ7¸Ó@Ð@ä×(Ñ(¨Ó1Ð1ò	Fñ" " )Ó,ˆÙØˆOà�:Ðr   r-   r.   c                ót  — |j                  «       }| j                  |«      |j                  «       | j                  dœ}dj                  | j                  t        |«      f«      }t        j                  d| j                  j                  |«       t        | j                  |¬«      }| j                  |||¬«      S )aç  
        Return a `3 words` address by location point. Each point on the surface has
        a `3 words` address, so there's always a non-empty response.

        :param query: The coordinates for which you wish to obtain the 3 word
            address.
        :type query: :class:`geopy.point.Point`, list or tuple of ``(latitude,
            longitude)``, or string as ``"%(latitude)s, %(longitude)s"``.

        :param str lang: two character language code as supported by the
            API (https://developer.what3words.com/public-api/docs#available-languages).

        :param bool exactly_one: Return one result or a list of results, if
            available. Due to the address scheme there is always exactly one
            result for each `3 words` address, so this parameter is rather
            useless for this geocoder.

        :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.location.Location` or a list of them, if
            ``exactly_one=False``.

        )r|   Úlanguager4   r5   rc   r7   r8   rd   r@   s           r   rg   zWhat3WordsV3.reversex  sœ   € ðD �z‰z‹|ˆð  ×7Ñ7¸Ó>ØŸ
™
›Ø—<‘<ñ
ˆð �h‰h˜×(Ñ(¬)°FÓ*;Ð<Ó=ˆä�‰Ð% t§~¡~×'>Ñ'>ÀÔDÜ˜4×3Ñ3ÀÔMˆØ×"Ñ" 3¨¸'Ð"ÓBÐBr   c                 ó&   — | j                  ||«      S ri   rj   rk   s      r   rf   z What3WordsV3._parse_reverse_json¨  rl   r   rm   rn   rs   s   @r   r   r   ç   s[   ø„ ñð 0€LØ'€Lð %Ø$ØØ(Ø Ø'ö/Rðj Ø$ô*CóX&ðX ØØ$ô.C÷`8r   r   )ÚreÚ	functoolsr   Úurllib.parser   Úgeopyr   Úgeopy.geocoders.baser   r   Úgeopy.locationr   Ú
geopy.utilr	   Ú__all__ÚcompileÚUr   r   r
   r   © r   r   ú<module>rŒ      s[   ðÛ 	Ý Ý "å ß ;Ý #Ý à
(€à�B—J‘JØ4°b·d±dóÐ ò
0ôL8�ô L8ô^E8�8õ E8r   