
    N}bg                     r    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 G d d	e          Zd
S )    )partial)	urlencode)GeocoderQueryError)DEFAULT_SENTINELGeocoderLocation)logger)DataBCc                   X     e Zd ZdZdZdeededdd fd
Zddd	d
eddZd Zd Z	 xZ
S )r   zGeocoder using the Physical Address Geocoder from DataBC.

    Documentation at:
        https://github.com/bcgov/ols-geocoder/blob/gh-pages/geocoder-developer-guide.md
    z/addresses.geojsonNzgeocoder.api.gov.bc.ca)schemetimeoutproxies
user_agentssl_contextadapter_factorydomainc                    t                                          ||||||           | j        d|| j        | _        dS )a   

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

            .. versionadded:: 2.0

        :param str domain: base api domain

            .. versionadded:: 2.4
        )r   r   r   r   r   r   z://N)super__init__r   geocode_path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/databc.pyr   zDataBC.__init__   s[    L 	!#+ 	 	
 	
 	
 #'+++vvt7H7HI       r   anyT)max_resultsset_backlocation_descriptorexactly_oner   c                P   d|i}|dk    r||d<   |dvrt          d          ||d<   |rd}||d<   d	                    | j        t          |          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 int max_results: The maximum number of resutls to request.

        :param float set_back: The distance to move the accessPoint away
            from the curb (in meters) and towards the interior of the parcel.
            location_descriptor must be set to accessPoint for set_back to
            take effect.

        :param str location_descriptor: The type of point requested. It
            can be any, accessPoint, frontDoorPoint, parcelPoint,
            rooftopPoint and routingPoint.

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

        :rtype: ``None``, :class:`geopy.location.Location` or a list of them, if
            ``exactly_one=False``.
        addressStringr   setBack)r   accessPointfrontDoorPointparcelPointrooftopPointroutingPointzYou did not provided a location_descriptor the webservice can consume. It should be any, accessPoint, frontDoorPoint, parcelPoint, rooftopPoint or routingPoint.locationDescriptor   
maxResults?z%s.geocode: %s)r"   )r   )r   joinr   r   r
   debugr   __name__r   _parse_json_call_geocoder)
r   queryr   r    r!   r"   r   paramsurlcallbacks
             r   geocodezDataBC.geocodeE   s    J "5)q== (F9 '7 7 7 %M  
 (;#$ 	K*|hh)F"3"3455%t~'>DDD4+EEE""3'"BBBr   c                     t          |d                   sd S g }|d         D ]*}|                    |                     |                     +|r|d         S |S )Nfeaturesr   )lenappend_parse_feature)r   responser"   geocodedfeatures        r   r2   zDataBC._parse_json   so    8J'(( 	4
+ 	: 	:GOOD//889999 	A;r   c                 x    |d         }|d         d         }t          |d         |d         |d         f|          S )N
propertiesgeometrycoordinatesfullAddressr,   r   r   )r   r@   rB   rD   s       r   r=   zDataBC._parse_feature   sG    \*
j)-8}%AA'G
 
 	
r   )r1   
__module____qualname____doc__r   r   r   r8   r2   r=   __classcell__)r   s   @r   r   r      s          (L
 $$( +.J .J .J .J .J .J .Jh  %$;C ;C ;C ;C ;Cz	 	 	
 
 
 
 
 
 
r   r   N)	functoolsr   urllib.parser   	geopy.excr   geopy.geocoders.baser   r   geopy.locationr	   
geopy.utilr
   __all__r    r   r   <module>rR      s          " " " " " " ( ( ( ( ( ( ; ; ; ; ; ; ; ; # # # # # #      
G
 G
 G
 G
 G
X G
 G
 G
 G
 G
r   