
    N}bgj&                         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dS )    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   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                                          ||||||           || _        |                    d          | _        | j        d| j        | j        | _        dS )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
            j/home/e360mart.nyusoft.in/public_html/e360mart_env/lib/python3.11/site-packages/geopy/geocoders/woosmap.pyr   zWoosmap.__init__   su    X 	!#+ 	 	
 	
 	
 ll3''"&+++t{{DMMJ    c                 F   g }t          |t          j        j                  r|                                }nMt          |t          j        j                  rt          |t          t          f          s|}nt          d          d	                    d |D                       S )Nz7`components` parameter must be of type `dict` or `list`|c              3   @   K   | ]}d                      |          V  dS ):N)join).0items     r   	<genexpr>z3Woosmap._format_components_param.<locals>.<genexpr>^   s=       
 
#CHHTNN
 
 
 
 
 
r    )

isinstancecollectionsabcMappingitemsSequencestrbytes
ValueErrorr%   )r   
componentscomponent_itemss      r   _format_components_paramz Woosmap._format_components_paramP   s    j+/"9:: 		K(..00OOz;?#;<<	KzC<88	K )OOIK K K xx 
 
'6
 
 
 
 
 	
r    T)limitexactly_oner   locationr2   languagecountry_code_formatc                   || j         d}	|r|                     |d          }
|
|	d<   |r|                     |          |	d<   |r||	d<   |r||	d<   |r||	d<   |rd	|	d<   d
                    | j        t          |	          f          }t          j        d| j        j	        |           t          | 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 RE!&F: 	M#'#@#@#L#LF<  	*!)F: 	6"5F; 	$#F7O 	 F7Ohh)F"3"3455%t~'>DDD4+EEE""3'"BBBr    )r5   r6   r   r8   r9   c                j   |                      |d          }|| j        d}|r||d<   |r||d<   |r||d<   |rd|d<   d                    | j        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 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 --eCT-UU<
 
  	*!)F: 	6"5F; 	$#F7O 	 F7Ohh)F"3"3455%t~'>DDD4+EEE""3'"BBBr    c                     |                     dg           }|                     |           |sd S d |r |d                   S fd|D             S )Nresultsc                     |                      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   sS    {{#677Hz*:6u=H
+J7>IHx&;WEEEr    r   c                 &    g | ]} |          S  r_   )r&   r;   r]   s     r   
<listcomp>z'Woosmap._parse_json.<locals>.<listcomp>   s#    DDDwMM'**DDDr    )rZ   _check_status)r   responser6   	addressesr]   s       @r   rH   zWoosmap._parse_json   s    LLB//	8$$$ 	4	F 	F 	F  	E =1...DDDD)DDDDr    c                 "   |                     d          }|dk    rd S |dk    rd S |                     d          }|dk    rt          |pd          |dk    rt          |pd          |d	k    rt          |pd
          t          |p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   rb   re   rh   s       r   ra   zWoosmap._check_status  s    h''T>>F^##F _55&&&$O!OQ Q Q'''$U!UW W W&&%m&E~FFF '}'GHHHr    )T)rG   
__module____qualname____doc__r   r   r   r4   rO   rR   rH   ra   __classcell__)r   s   @r   r   r      s         'H !  $6K 6K 6K 6K 6K 6K 6Kp
 
 
,   NC NC NC NC NCh   :C :C :C :C :CxE E E E&I I I I I 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    r   <module>rx      s              " " " " " " S S S S S S S S S S ; ; ; ; ; ; ; ; # # # # # #      
GI GI GI GI GIh GI GI GI GI GIr    