
    .hj&                     z    S SK rS SKJr  S SKJr  S SKJrJrJ	r	  S SK
JrJr  S SKJr  S SKJr  Sr " S	 S
\5      rg)    N)partial)	urlencode)GeocoderQueryErrorGeocoderServiceErrorGeocoderUnavailable)DEFAULT_SENTINELGeocoder)Location)logger)Woosmapc                      ^  \ rS rSrSrSrSS\\S\SS.U 4S jjrS rSS	\SSSSS
.S jr	SS	\SSS.S jr
SS jrS rSrU =r$ )r      zGeocoder 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	U ]  UUUUUUS9  Xl        UR                  S5      U l        U R
                  < SU R                  < U R                  < 3U l        g)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
            jC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\geopy/geocoders/woosmap.pyr   Woosmap.__init__   s[    X 	!#+ 	 	
 ll3'"&++t{{DMMJ    c                 N   / n[        U[        R                  R                  5      (       a  UR	                  5       nOR[        U[        R                  R
                  5      (       a  [        U[        [        45      (       d  UnO[        S5      eSR                  S U 5       5      $ )Nz7`components` parameter must be of type `dict` or `list`|c              3   D   #    U  H  nS R                  U5      v   M     g7f):N)join).0items     r    	<genexpr>3Woosmap._format_components_param.<locals>.<genexpr>^   s      
'6tCHHTNNs    )

isinstancecollectionsabcMappingitemsSequencestrbytes
ValueErrorr'   )r   
componentscomponent_itemss      r    _format_components_param Woosmap._format_components_paramP   s    j+//"9"9::(..0Oz;??#;#;<<zC<88(OIK K xx 
'6
 
 	
r"   T)limitexactly_oner   locationr5   languagecountry_code_formatc                   UU R                   S.n	U(       a  U R                  USS9n
XS'   U(       a  U R                  U5      U	S'   U(       a  XyS'   U(       a  XS'   U(       a  X)S'   U(       a  S	U	S'   S
R                  U R                  [        U	5      45      n[        R                  " SU R                  R                  U5        [        U R                  US9nU R                  XUS9$ )a  
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_formatr;   r5   r<   	cc_formatr9      ?z%s.geocode: %sr:   r   )r   _coerce_point_to_stringr7   r'   r   r   r   debugr   __name__r   _parse_json_call_geocoder)r   queryr9   r:   r   r;   r5   r<   r=   paramspointurlcallbacks                r    geocodeWoosmap.geocodeb   s    p <<

 00?P 1 RE!&:#'#@#@#LF< !):"5;#7OF7Ohh)F"345%t~~'>'>D4++E""3'"BBr"   )r9   r:   r   r<   r=   c                   U R                  USS9nUU R                  S.nU(       a  XXS'   U(       a  XhS'   U(       a  X(S'   U(       a  SUS'   SR                  U R                  [	        U5      45      n	[
        R                  " S	U R                  R                  U	5        [        U R                  US
9n
U R                  XUS9$ )ar  
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``.
rA   rB   )latlngr@   r<   rD   r9   rE   rF   z%s.reverse: %srG   rH   )rI   r   r'   r   r   r   rJ   r   rK   r   rL   rM   )r   rN   r9   r:   r   r<   r=   rV   rO   rQ   rR   s              r    reverseWoosmap.reverse   s    R --eCT-U<<
 !):"5;#7OF7Ohh)F"345%t~~'>'>D4++E""3'"BBr"   c                     UR                  S/ 5      nU R                  U5        U(       d  g S nU(       a  U" US   5      $ U Vs/ s H
  oT" U5      PM     sn$ s  snf )Nresultsc                 l    U R                  S5      nU S   S   S   nU S   S   S   n[        XU4U 5      $ )z6Get the location, lat, lng from a single json address.formatted_addressgeometryr;   latlng)getr
   )r?   r;   latitude	longitudes       r    parse_address*Woosmap._parse_json.<locals>.parse_address   sK    {{#67Hz*:6u=H
+J7>IH&;WEEr"   r   )r`   _check_status)r   responser:   	addressesrc   r?   s         r    rL   Woosmap._parse_json   s]    LLB/	8$	F  1..:CD)wM'*)DDDs   Ac                 &   UR                  S5      nUS:X  a  g US:X  a  g UR                  S5      nUS:X  a  [        U=(       d    S5      eUS:X  a  [        U=(       d    S5      eUS	:X  a  [        U=(       d    S
5      e[        U=(       d    S5      e)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)r`   r   r   r   )r   rf   rj   rm   s       r    re   Woosmap._check_status  s    h'T>^# _5&&$O!OQ Q''$U!UW W&%m&E~FF '}'GHHr"   )r   r   r   )T)rK   
__module____qualname____firstlineno____doc__r   r   r   r7   rS   rW   rL   re   __static_attributes____classcell__)r   s   @r    r   r      s     'H !  $6K 6Kp
,   NCh   :CxE&I 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>r      s2      " S S ; # 
GIh GIr"   