Ë
    Ï.f™7  ã                   óŒ   — 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
mZmZ d dlmZ d dlmZ dZd	Zd
ddde
fZ G d„ de«      Zy)é    N)Úpartial)Ú	urlencode)ÚConfigurationErrorÚGeocoderQueryError)Ú_DEFAULT_USER_AGENTÚDEFAULT_SENTINELÚGeocoder)ÚLocation)Úlogger)Ú	Nominatimznominatim.openstreetmap.orgzmy-applicationzmy_app/1zmy_user_agent/1.0Úspecify_your_app_name_herec                   óŽ   ‡ — e Zd ZdZh d£ZdZdZeeeddeddœˆ fd„
Z	d„ Z
d	edd
d
dd
ddd
dd
dœd„Zd	ed
d	dd
dœd„Zd„ Zd„ Zˆ xZS )r   aÉ  Nominatim geocoder for OpenStreetMap data.

    Documentation at:
        https://nominatim.org/release-docs/develop/api/Overview/

    .. attention::
       Using Nominatim with the default `user_agent` is strongly discouraged,
       as it violates Nominatim's Usage Policy
       https://operations.osmfoundation.org/policies/nominatim/
       and may possibly cause 403 and 429 HTTP errors. Please make sure
       to specify a custom `user_agent` with
       ``Nominatim(user_agent="my-application")`` or by
       overriding the default `user_agent`:
       ``geopy.geocoders.options.default_user_agent = "my-application"``.
       An exception will be thrown if a custom `user_agent` is not specified.
    >   ÚcityÚstateÚcountyÚstreetÚcountryÚ
postalcodez/searchz/reverseN)ÚtimeoutÚproxiesÚdomainÚschemeÚ
user_agentÚssl_contextÚadapter_factoryc                ó’  •— t         ‰| �  ||||||¬«       |j                  d«      | _        | j                  t        k(  r0| j
                  d   t        v rt        d| j
                  d   z  «      ‚| j                  ›d| j                  ›| j                  ›�| _
        | j                  ›d| j                  ›| j                  ›�| _        y)a  

        :param int timeout:
            See :attr:`geopy.geocoders.options.default_timeout`.

        :param dict proxies:
            See :attr:`geopy.geocoders.options.default_proxies`.

        :param str domain: Domain where the target Nominatim service
            is hosted.

        :param str scheme:
            See :attr:`geopy.geocoders.options.default_scheme`.

        :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
User-Agenta˜  Using Nominatim with default or sample `user_agent` "%s" is strongly discouraged, as it violates Nominatim's ToS https://operations.osmfoundation.org/policies/nominatim/ and may possibly cause 403 and 429 HTTP errors. Please specify a custom `user_agent` with `Nominatim(user_agent="my-application")` or by overriding the default `user_agent`: `geopy.geocoders.options.default_user_agent = "my-application"`.z://N)ÚsuperÚ__init__Ústripr   Ú_DEFAULT_NOMINATIM_DOMAINÚheadersÚ_REJECTED_USER_AGENTSr   r   Úgeocode_pathÚapiÚreverse_pathÚreverse_api)	Úselfr   r   r   r   r   r   r   Ú	__class__s	           €úXC:\Users\user\Documents\project_loop\venv\Lib\site-packages\geopy/geocoders/nominatim.pyr   zNominatim.__init__5   s¼   ø€ ôN 	‰ÑØØØØ!Ø#Ø+ð 	ô 	
ð —l‘l 3Ó'ˆŒà�K‰KÔ4Ò4Ø—L‘L Ñ.Ô2GÑGÜ$ðSð —,‘,˜|Ñ,ñ-ó
ð 
ð #'§+£+¨t¯{ª{¸D×<MÒ<MÐNˆŒØ*.¯+«+°t·{²{ÀD×DUÒDUÐVˆÕó    c                 ó:   — dj                  |t        |«      f«      S )aV  
        Construct geocoding request url.
        The method can be overridden in Nominatim-based geocoders in order
        to extend URL parameters.

        :param str base_api: Geocoding function base address - self.api
            or self.reverse_api.

        :param dict params: Geocoding params.

        :return: string URL.
        ú?)Újoinr   )r(   Úbase_apiÚparamss      r*   Ú_construct_urlzNominatim._construct_urlx   s   € ð �x‰x˜¤9¨VÓ#4Ð5Ó6Ð6r+   TF)Úexactly_oner   ÚlimitÚaddressdetailsÚlanguageÚgeometryÚ	extratagsÚcountry_codesÚviewboxÚboundedÚfeaturetypeÚnamedetailsc                óŽ  — t        |t        j                  j                  «      r2|j	                  «       D ��ci c]  \  }}|| j
                  v r||“Œ }}}nd|i}|j                  ddi«       |rd|d<   n"|� t        |«      }|dk  rt        d«      ‚||d<   |
r| j                  |
d«      |d<   |rd|d	<   |	sg }	t        |	t        «      r|	g}	|	rd
j                  |	«      |d<   |rd|d<   |rd|d<   |r||d<   |rd|d<   |�G|j                  «       }|dk(  rd|d<   n,|dk(  rd|d<   n!|dk(  rd|d<   n|dk(  rd|d<   nt        d«      ‚|r||d<   | j                  | j                  |«      }t!        j"                  d| j$                  j&                  |«       t)        | j*                  |¬«      }| j-                  |||¬«      S c c}}w )aõ  
        Return a location point by address.

        :param query: The address, query or a structured query
            you wish to geocode.

            For a structured query, provide a dictionary whose keys
            are one of: `street`, `city`, `county`, `state`, `country`, or
            `postalcode`. For more information, see Nominatim's
            documentation for `structured requests`:

                https://nominatim.org/release-docs/develop/api/Search

        :type query: dict or str

        :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 int limit: Maximum amount of results to return from Nominatim.
            Unless exactly_one is set to False, limit will always be 1.

        :param bool addressdetails: If you want in *Location.raw* to include
            address details such as house_number, city_district, postcode, etc
            (in a structured form) set it to True

        :param str language: Preferred language in which to return results.
            Either uses standard
            `RFC2616 <http://www.ietf.org/rfc/rfc2616.txt>`_
            accept-language string or a simple comma-separated
            list of language codes.

        :param str geometry: If present, specifies whether the geocoding
            service should return the result's geometry in `wkt`, `svg`,
            `kml`, or `geojson` formats. This is available via the
            `raw` attribute on the returned :class:`geopy.location.Location`
            object.

        :param bool extratags: Include additional information in the result if available,
            e.g. wikipedia link, opening hours.

        :param country_codes: Limit search results
            to a specific country (or a list of countries).
            A country_code should be the ISO 3166-1alpha2 code,
            e.g. ``gb`` for the United Kingdom, ``de`` for Germany, etc.

        :type country_codes: str or list

        :type viewbox: list or tuple of 2 items of :class:`geopy.point.Point` or
            ``(latitude, longitude)`` or ``"%(latitude)s, %(longitude)s"``.

        :param viewbox: Prefer this area to find search results. By default this is
            treated as a hint, if you want to restrict results to this area,
            specify ``bounded=True`` as well.
            Example: ``[Point(22, 180), Point(-22, -180)]``.

        :param bool bounded: Restrict the results to only items contained
            within the bounding ``viewbox``.

        :param str featuretype: If present, restrict results to certain type of features.
            Allowed values: `country`, `state`, `city`, `settlement`.

        :param bool namedetails: If you want in *Location.raw* to include
            namedetails, set it to True. This will be a list of alternative names,
            including language variants, etc.

        :rtype: ``None``, :class:`geopy.location.Location` or a list of them, if
            ``exactly_one=False``.

        ÚqÚformatÚjsoné   r3   zLimit cannot be less than 1z#%(lon1)s,%(lat1)s,%(lon2)s,%(lat2)sr9   r:   ú,Úcountrycodesr4   r<   úaccept-languageTr7   ÚwktÚpolygon_textÚsvgÚpolygon_svgÚkmlÚpolygon_kmlÚgeojsonÚpolygon_geojsonz@Invalid geometry format. Must be one of: wkt, svg, kml, geojson.ÚfeatureTypez%s.geocode: %s©r2   ©r   )Ú
isinstanceÚcollectionsÚabcÚMappingÚitemsÚstructured_query_paramsÚupdateÚintÚ
ValueErrorÚ_format_bounding_boxÚstrr.   Úlowerr   r1   r%   r   Údebugr)   Ú__name__r   Ú_parse_jsonÚ_call_geocoder)r(   Úqueryr2   r   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   ÚkeyÚvalr0   ÚurlÚcallbacks                      r*   ÚgeocodezNominatim.geocode‡   s  € ôx �eœ[Ÿ_™_×4Ñ4Ô5ð —;‘;“=÷á�C˜à˜$×6Ñ6Ñ6ð �S‘ðˆFò ð ˜5�\ˆFà�‰Ø�fð
ô 	ñ ØˆF�7ŠOØÐÜ˜“JˆEØ�qŠyÜ Ð!>Ó?Ð?Ø#ˆF�7‰OáØ $× 9Ñ 9ØÐ>ó!@ˆF�9Ññ Ø !ˆF�9ÑáØˆMÜ�m¤SÔ)Ø*˜OˆMÙØ%(§X¡X¨mÓ%<ˆF�>Ñ"áØ'(ˆFÐ#Ñ$áØ$%ˆF�=Ñ!áØ(0ˆFÐ$Ñ%áØ"&ˆF�;ÑàÐØ—~‘~Ó'ˆHØ˜5Ò Ø)*��~Ò&Ø˜UÒ"Ø()��}Ò%Ø˜UÒ"Ø()��}Ò%Ø˜YÒ&Ø,-�Ð(Ò)ä(ð.óð ñ
 Ø$/ˆF�=Ñ!à×!Ñ! $§(¡(¨FÓ3ˆÜ�‰Ð% t§~¡~×'>Ñ'>ÀÔDÜ˜4×+Ñ+¸ÔEˆØ×"Ñ" 3¨¸'Ð"ÓBÐBùóKs   ¸G)r2   r   r5   r4   Úzoomr<   c                ó¦  — 	 | j                  |«      j                  d«      \  }}	||	ddœ}
|r||
d<   |rdnd|
d<   |�||
d	<   |rd|
d
<   | j                  | j                  |
«      }t        j                  d| j                  j                  |«       t        | j                  |¬«      }| j                  |||¬«      S # t        $ r t        d«      ‚w xY w)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.
            Either uses standard
            `RFC2616 <http://www.ietf.org/rfc/rfc2616.txt>`_
            accept-language string or a simple comma-separated
            list of language codes.

        :param bool addressdetails: Whether or not to include address details,
            such as city, county, state, etc. in *Location.raw*

        :param int zoom: Level of detail required for the address,
            an integer in range from 0 (country level) to 18 (building level),
            default is 18.

        :param bool namedetails: If you want in *Location.raw* to include
            namedetails, set it to True. This will be a list of alternative names,
            including language variants, etc.

            .. versionadded:: 2.3

        :rtype: ``None``, :class:`geopy.location.Location` or a list of them, if
            ``exactly_one=False``.

        rB   z"Must be a coordinate pair or Pointr@   )ÚlatÚlonr?   rD   rA   r   r4   rf   r<   z%s.reverse: %srN   rO   )Ú_coerce_point_to_stringÚsplitrX   r1   r'   r   r\   r)   r]   r   r^   r_   )r(   r`   r2   r   r5   r4   rf   r<   rh   ri   r0   rc   rd   s                r*   ÚreversezNominatim.reverse+  sñ   € ðd	CØ×3Ñ3°EÓ:×@Ñ@ÀÓE‰HˆC�ð ØØñ
ˆñ
 Ø(0ˆFÐ$Ñ%á(6¡1¸AˆÐÑ àÐØ!ˆF�6‰NáØ$%ˆF�=Ñ!à×!Ñ! $×"2Ñ"2°FÓ;ˆÜ�‰Ð% t§~¡~×'>Ñ'>ÀÔDÜ˜4×+Ñ+¸ÔEˆØ×"Ñ" 3¨¸'Ð"ÓBÐBøô+ ò 	CÜÐAÓBÐBð	Cús   ‚#B; Â;Cc                 óÀ   — |j                  dd «      }|j                  dd «      }|j                  dd «      }|�|�t        |«      }t        |«      }t        |||f|«      S )Nrh   ri   Údisplay_name)ÚgetÚfloatr
   )r(   ÚplaceÚlatitudeÚ	longitudeÚ	placenames        r*   Ú_parse_codezNominatim._parse_codev  sd   € à—9‘9˜U DÓ)ˆØ—I‘I˜e TÓ*ˆ	Ø—I‘I˜n¨dÓ3ˆ	ØÐ IÐ$9Ü˜X“ˆHÜ˜iÓ(ˆIÜ˜	 H¨iÐ#8¸%Ó@Ð@r+   c                 óH  — |sy t        |t        j                  j                  «      rd|v r|d   dk(  ry t	        |d   «      ‚t        |t        j                  j
                  «      s|g}|r| j                  |d   «      S |D �cg c]  }| j                  |«      ‘Œ c}S c c}w )NÚerrorzUnable to geocoder   )rP   rQ   rR   rS   r   ÚSequenceru   )r(   Úplacesr2   rq   s       r*   r^   zNominatim._parse_json€  s”   € ÙØä�fœkŸo™o×5Ñ5Ô6¸7ÀfÑ;LØ�g‰Ð"5Ò5àä(¨°©Ó9Ð9ä˜&¤+§/¡/×":Ñ":Ô;Ø�XˆFÙØ×#Ñ# F¨1¡IÓ.Ð.à9?Ö@°�D×$Ñ$ UÕ+Ò@Ð@ùÒ@s   ÂB)r]   Ú
__module__Ú__qualname__Ú__doc__rU   r$   r&   r   r!   r   r1   re   rl   ru   r^   Ú__classcell__)r)   s   @r*   r   r      s–   ø„ ñò"Ðð €LØ€Lð
 %Ø$Ø,ØØØ(Ø öAWòF7ð& Ø$ØØ ØØØØØØØØôbCðP Ø$ØØØØôICòVAöAr+   r   )Úcollections.abcrQ   Ú	functoolsr   Úurllib.parser   Ú	geopy.excr   r   Úgeopy.geocoders.baser   r   r	   Úgeopy.locationr
   Ú
geopy.utilr   Ú__all__r!   r#   r   © r+   r*   ú<module>r‡      sQ   ðÛ Ý Ý "ç <ß PÑ PÝ #Ý à
€à9Ð ð ØØØ ØðÐ ôyA�õ yAr+   