
    g                     j    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y
)    )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    t         |   ||||||       | j                  d|| j                  | _        y)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	           V/var/www/api/v1/venv_getwork_v1/lib/python3.12/site-packages/geopy/geocoders/databc.pyr   zDataBC.__init__   sD    L 	!#+ 	 	
 #'++vt7H7HI       r   anyT)max_resultsset_backlocation_descriptorexactly_oner   c                P   d|i}|dk7  r||d<   |dvrt        d      ||d<   |rd}||d<   d	j                  | j                  t        |      f      }t	        j
                  d
| j                  j                  |       t        | j                  |      }	| 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 %M 
 (;#$K*|hh)F"345%t~~'>'>D4++E""3'"BBr   c                     t        |d         sy g }|d   D ]"  }|j                  | j                  |             $ |r|d   S |S )Nfeaturesr   )lenappend_parse_feature)r   responser"   geocodedfeatures        r   r2   zDataBC._parse_json   sO    8J'(
+GOOD//89 ,A;r   c                 L    |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   sB    \*
j)-8}%AA'G
 	
r   )r1   
__module____qualname____doc__r   r   r   r8   r2   r=   __classcell__)r   s   @r   r   r      sO     (L
 $$( +.Jh  %$;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
X G
r   