
    N}bg"                     n    d dl 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 G d d	e          ZdS )
    N)partial)	urlencode)DEFAULT_SENTINELGeocoder)Location)logger)Photonc                   t     e Zd ZdZdZdZdeeddedd fd
Zdedd	dddd
dZded	dddZ	ddZ
d Z xZS )r	   a  Geocoder using Photon geocoding service (data based on OpenStreetMap
    and service provided by Komoot on https://photon.komoot.io).

    Documentation at:
        https://github.com/komoot/photon

    Photon/Komoot geocoder aims to let you `search as you type with
    OpenStreetMap`. No API Key is needed by this platform.

    .. versionchanged:: 2.2
        Changed default domain from ``photon.komoot.de``
        to ``photon.komoot.io``.
    z/apiz/reverseNzphoton.komoot.io)schemetimeoutproxiesdomain
user_agentssl_contextadapter_factoryc                    t                                          ||||||           |                    d          | _        | j        d| j        | j        | _        | j        d| j        | j        | _        dS )ap  

        :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 domain: Should be the localized Photon domain to
            connect to. The default is ``'photon.komoot.io'``, but you
            can change it to a domain of your own.

        :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
        )r   r   r   r   r   r   /z://N)	super__init__stripr   r   geocode_pathapireverse_pathreverse_api)	selfr   r   r   r   r   r   r   	__class__s	           i/home/e360mart.nyusoft.in/public_html/e360mart_env/lib/python3.11/site-packages/geopy/geocoders/photon.pyr   zPhoton.__init__   s    L 	!#+ 	 	
 	
 	
 ll3''"&+++t{{D<M<MN*.+++t{{DDUDUV    TF)exactly_oner   location_biaslanguagelimitosm_tagbboxc                   d|i}	|rt          |          |	d<   |rd|	d<   |r||	d<   |rT	 |                     |                              d          \  }
}||	d<   |
|	d<   n# t          $ r t          d          w xY w|r|                     |d	          |	d
<   |r\t          |t                    r|g|	d<   n@t          |t          j        j	                  st          d          t          |          |	d<   d                    | j        t          |	d          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 location_bias: The coordinates to use as location bias.
        :type location_bias: :class:`geopy.point.Point`, list or tuple of
            ``(latitude, longitude)``, or string
            as ``"%(latitude)s, %(longitude)s"``.

        :param str language: Preferred language in which to return results.

        :param int limit: Limit the number of returned results, defaults to no
            limit.

        :param osm_tag: The expression to filter (include/exclude) by key and/
            or value, str as ``'key:value'`` or list/set of str if multiple
            filters are required as ``['key:!val', '!key', ':!value']``.
        :type osm_tag: str or list or set

        :param bbox: The bounding box of the viewport within which
            to bias geocode results more prominently.
            Example: ``[Point(22, 180), Point(-22, -180)]``.

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

        qr"      lang,lonlatz0Location bias must be a coordinate pair or Pointz#%(lon1)s,%(lat1)s,%(lon2)s,%(lat2)sr$   r#   z2osm_tag must be a string or an iterable of strings?T)doseqz%s.geocode: %sr   r   )int_coerce_point_to_stringsplit
ValueError_format_bounding_box
isinstancestrcollectionsabcIterablelistjoinr   r   r   debugr   __name__r   _parse_json_call_geocoder)r   queryr   r   r    r!   r"   r#   r$   paramsr+   r*   urlcallbacks                 r   geocodezPhoton.geocodeP   s   j 
  	)!%jjF7O 	 F7O 	&%F6N 	UU77FFLLSQQS #u #u U U U !STTTU  	=!66;= =F6N  		2'3'' 2%,Iy!!!';?+CDD $1   %)MMy!hh)F$"?"?"?@AA%t~'>DDD4+EEE""3'"BBBs   5A   A:)r   r   r!   r"   c                   	 |                      |                              d          \  }}n# t          $ r t          d          w xY w||d}|rt          |          |d<   |rd|d<   |r||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 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: Preferred language in which to return results.

        :param int limit: Limit the number of returned results, defaults to no
            limit.

        :rtype: ``None``, :class:`geopy.location.Location` or a list of them, if
            ``exactly_one=False``.
        r)   z"Must be a coordinate pair or Point)r+   r*   r"   r'   r(   r,   z%s.reverse: %sr.   r/   )r1   r2   r3   r0   r;   r   r   r   r<   r   r=   r   r>   r?   )r   r@   r   r   r!   r"   r+   r*   rA   rB   rC   s              r   reversezPhoton.reverse   s   B	C33E::@@EEHC 	C 	C 	CABBB	C 
 
  	)!%jjF7O 	 F7O 	&%F6Nhh()F*;*;<==%t~'>DDD4+EEE""3'"BBBs	   +. Ac                      t          |d                   sdS |r!                     |d         d                   S  fd|d         D             S )zS
        Parse display name, latitude, and longitude from a JSON response.
        featuresNr   c                 :    g | ]}                     |          S  )_parse_resource).0resourcer   s     r   
<listcomp>z&Photon._parse_json.<locals>.<listcomp>   s3     . . .xD((22 . . .r   )lenrK   )r   	resourcesr   s   `  r   r>   zPhoton._parse_json   su     9Z()) 	4 	.''	*(=a(@AAA. . . . ,. . . .r   c                    g d}fd|D             }d                     |          }d         d         d         }d         d         d         }|r |rt          |          }t          |          }t          |||f          S )N)namehousenumberstreetpostcoderT   citystatecountryc                 |    g | ]8}d                               |          d                               |          9S )
properties)get)rL   krM   s     r   rN   z*Photon._parse_resource.<locals>.<listcomp>   sZ     C C C!$,\$:$>$>q$A$AC&**1-- C C Cr   z, geometrycoordinatesr'   r   )r;   floatr   )r   rM   name_elementsrR   locationlatitude	longitudes    `     r   rK   zPhoton._parse_resource   s    - - -C C C C C C C99T??J'6q9Z(7:	 	)	 	)XHi((I8Y"7BBBr   )T)r=   
__module____qualname____doc__r   r   r   r   rD   rF   r>   rK   __classcell__)r   s   @r   r	   r	      s	         LL
 $$%( 0W 0W 0W 0W 0W 0W 0Wl $VC VC VC VC VCx $2C 2C 2C 2C 2Ch
. 
. 
. 
.C C C C C C Cr   r	   )collections.abcr7   	functoolsr   urllib.parser   geopy.geocoders.baser   r   geopy.locationr   
geopy.utilr   __all__r	   rJ   r   r   <module>ro      s              " " " " " " ; ; ; ; ; ; ; ; # # # # # #      
kC kC kC kC kCX kC kC kC kC kCr   