Ë
    Ï.fj&  ã                   óz   — d dl Zd dlmZ d dlmZ d dl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)é    N)Úpartial)Ú	urlencode)ÚGeocoderQueryErrorÚGeocoderServiceErrorÚGeocoderUnavailable)ÚDEFAULT_SENTINELÚGeocoder)ÚLocation)Úlogger)ÚWoosmapc                   óx   ‡ — e Zd ZdZdZddeededdœˆ fd„
Zd„ Zddeddddd	œd
„Zddedddœd„Z	dd„Z
d„ Zˆ xZS )r   z£Geocoder using the Woosmap Address API.

    Documentation at:
        https://developers.woosmap.com/products/address-api/geocode/

    .. versionadded:: 2.4
    z/address/geocode/jsonzapi.woosmap.comN)ÚdomainÚschemeÚtimeoutÚproxiesÚ
user_agentÚssl_contextÚadapter_factoryc                óÂ   •— t         ‰	| �  ||||||¬«       || _        |j                  d«      | _        | j
                  ›d| j                  ›| j                  ›�| _        y)a/  

        :param str api_key: The Private API key required by Woosmap to perform
            geocoding requests.
            API keys are managed through
            the Woosmap Console (https://console.woosmap.com/).
            Make sure to have ``Address API`` service enabled
            for your project Private API key.

        :param str domain: Domain where the target Woosmap 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   Úapi_pathÚapi)
Úselfr   r   r   r   r   r   r   r   Ú	__class__s
            €úVC:\Users\user\Documents\project_loop\venv\Lib\site-packages\geopy/geocoders/woosmap.pyr   zWoosmap.__init__   s]   ø€ ôX 	‰ÑØØØØ!Ø#Ø+ð 	ô 	
ð ˆŒØ—l‘l 3Ó'ˆŒØ"&§+£+¨t¯{ª{¸D¿MºMÐJˆ�ó    c                 ó0  — g }t        |t        j                  j                  «      r|j	                  «       }nHt        |t        j                  j
                  «      rt        |t        t        f«      s|}nt        d«      ‚dj                  d„ |D «       «      S )Nz7`components` parameter must be of type `dict` or `list`ú|c              3   ó>   K  — | ]  }d j                  |«      –— Œ y­w)ú:N)Újoin)Ú.0Úitems     r   ú	<genexpr>z3Woosmap._format_components_param.<locals>.<genexpr>^   s   è ø€ ò 
Ø#ˆC�H‰H�T�Nñ
ùs   ‚)
Ú
isinstanceÚcollectionsÚabcÚMappingÚitemsÚSequenceÚstrÚbytesÚ
ValueErrorr%   )r   Ú
componentsÚcomponent_itemss      r   Ú_format_components_paramz Woosmap._format_components_paramP   s‚   € Øˆä�j¤+§/¡/×"9Ñ"9Ô:Ø(×.Ñ.Ó0‰Oä�z¤;§?¡?×#;Ñ#;Ô<Ü˜z¬C´¨<Ô8à(‰OäØIóKð Kð �x‰xñ 
Ø'6ô
ó 
ð 	
r    T)ÚlimitÚexactly_oner   Úlocationr2   ÚlanguageÚcountry_code_formatc                ó°  — || j                   dœ}	|r| j                  |d¬«      }
|
|	d<   |r| j                  |«      |	d<   |r||	d<   |r||	d<   |r||	d<   |rd	|	d<   d
j                  | j                  t        |	«      f«      }t        j                  d| j                  j                  |«       t        | j                  |¬«      }| j                  |||¬«      S )ay  
        Return a location point by address.

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

        :param int limit: Maximum number of results to be returned.
            This will be reset to one if ``exactly_one`` is True.

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

        :type location: :class:`geopy.point.Point`, list or tuple of ``(latitude,
            longitude)``, or string as ``"%(latitude)s, %(longitude)s"``.
        :param location: The center latlng to bias the search context.

        :type components: dict or list
        :param components: Geographic places to which you would like to restrict
            your results. Currently, you can use components to filter over countries.
            Countries are identified by a two character, ISO 3166-1 Alpha-2
            or a three character, ISO 3166-1 Alpha-3 compatible country code.

            Pass a list of tuples if you want to specify multiple components of
            the same type, e.g.:

                >>> [('country', 'FRA'), ('country', 'DE')]

        :param str language: The language in which to return results.
            Must be a ISO 639-1 language code.

        :param str country_code_format: Default country code format
            in responses is Alpha3.
            However, format in responses can be changed
            by specifying components in alpha2.
            Available formats: ``alpha2``, ``alpha3``.

        :rtype: ``None``, :class:`geopy.location.Location` or a list of them, if
            ``exactly_one=False``.
        )ÚaddressÚprivate_keyú%(lat)s,%(lon)s©Úoutput_formatr7   r2   r8   Ú	cc_formatr5   é   ú?z%s.geocode: %s©r6   ©r   )r   Ú_coerce_point_to_stringr4   r%   r   r   r   Údebugr   Ú__name__r   Ú_parse_jsonÚ_call_geocoder)r   Úqueryr5   r6   r   r7   r2   r8   r9   ÚparamsÚpointÚurlÚcallbacks                r   ÚgeocodezWoosmap.geocodeb   së   € ðp ØŸ<™<ñ
ˆñ
 Ø×0Ñ0°Ø?Pð 1ó RˆEà!&ˆF�:ÑÙØ#'×#@Ñ#@ÀÓ#LˆF�<Ñ ÙØ!)ˆF�:ÑÙØ"5ˆF�;ÑÙØ#ˆF�7‰OÙØˆF�7‰Oà�h‰h˜Ÿ™¤)¨FÓ"3Ð4Ó5ˆÜ�‰Ð% t§~¡~×'>Ñ'>ÀÔDÜ˜4×+Ñ+¸ÔEˆØ×"Ñ" 3¨¸'Ð"ÓBÐBr    )r5   r6   r   r8   r9   c                óv  — | j                  |d¬«      }|| j                  dœ}|r||d<   |r||d<   |r||d<   |rd|d<   dj                  | j                  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 int limit: Maximum number of results to be returned.
            This will be reset to one if ``exactly_one`` is True.

        :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 str language: The language in which to return results.

        :param str country_code_format: Default country code format
            in responses is Alpha3.
            However, format in responses can be changed
            by specifying components in alpha2.
            Available formats: ``alpha2``, ``alpha3``.

        :rtype: ``None``, :class:`geopy.location.Location` or a list of them, if
            ``exactly_one=False``.
        r=   r>   )Úlatlngr<   r8   r@   r5   rA   rB   z%s.reverse: %srC   rD   )rE   r   r%   r   r   r   rF   r   rG   r   rH   rI   )r   rJ   r5   r6   r   r8   r9   rQ   rK   rM   rN   s              r   ÚreversezWoosmap.reverse²   sÁ   € ðR ×-Ñ-¨eÐCTÐ-ÓUˆàØŸ<™<ñ
ˆñ Ø!)ˆF�:ÑÙØ"5ˆF�;ÑÙØ#ˆF�7‰OÙØˆF�7‰Oà�h‰h˜Ÿ™¤)¨FÓ"3Ð4Ó5ˆÜ�‰Ð% t§~¡~×'>Ñ'>ÀÔDÜ˜4×+Ñ+¸ÔEˆØ×"Ñ" 3¨¸'Ð"ÓBÐBr    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 )z6Get the location, lat, lng from a single json address.Úformatted_addressÚgeometryr7   ÚlatÚlng)Úgetr
   )r;   r7   ÚlatitudeÚ	longitudes       r   Úparse_addressz*Woosmap._parse_json.<locals>.parse_addressõ   sM   € à—{‘{Ð#6Ó7ˆHØ˜zÑ*¨:Ñ6°uÑ=ˆHØ 
Ñ+¨JÑ7¸Ñ>ˆIÜ˜H x°Ð&;¸WÓEÐEr    r   )rZ   Ú_check_status)r   Úresponser6   Ú	addressesr]   r;   s         r   rH   zWoosmap._parse_jsonî   sY   € Ø—L‘L ¨BÓ/ˆ	à×Ñ˜8Ô$ÙØò	Fñ Ù  ¨1¡Ó.Ð.à:CÖD¨w‘M 'Õ*ÒDÐDùÒDs   »Ac                 óô   — |j                  d«      }|dk(  ry |dk(  ry |j                  d«      }|dk(  rt        |xs d«      ‚|dk(  rt        |xs d«      ‚|d	k(  rt        |xs d
«      ‚t        |xs d«      ‚)NÚstatusÚOKÚZERO_RESULTSÚerror_messageÚINVALID_REQUESTz,Invalid request or missing address or latlngÚREQUEST_DENIEDz2Your request was denied. Please check your API KeyÚUNKNOWN_ERRORzServer errorzUnknown error)rZ   r   r   r   )r   r_   rb   re   s       r   r^   zWoosmap._check_status  sŸ   € à—‘˜hÓ'ˆØ�TŠ>ØØ�^Ò#Øà Ÿ™ _Ó5ˆØÐ&Ò&Ü$ØÒOÐ!OóQð QàÐ'Ò'Ü$ØÒUÐ!UóWð Wà�Ò&Ü% mÒ&E°~ÓFÐFô ' }Ò'G¸ÓHÐHr    )T)rG   Ú
__module__Ú__qualname__Ú__doc__r   r   r   r4   rO   rR   rH   r^   Ú__classcell__)r   s   @r   r   r      su   ø„ ñð '€Hð !ØØ Ø ØØ$Øö6Kòp
ð, ØØ ØØØØ ôNCðh ØØ ØØ ô:CóxEö&Ir    r   )Úcollections.abcr*   Ú	functoolsr   Úurllib.parser   Ú	geopy.excr   r   r   Úgeopy.geocoders.baser   r	   Úgeopy.locationr
   Ú
geopy.utilr   Ú__all__r   © r    r   ú<module>rv      s2   ðÛ Ý Ý "ç SÑ Sß ;Ý #Ý à
€ôGIˆhõ GIr    