Ë
    Ï.fÇ  ã                   óV   — d 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	)
z<
Mapzen geocoder, contributed by Michal Migurski of Mapzen.
é    )Ú	urlencode)ÚDEFAULT_SENTINELÚGeocoder)ÚLocation)Úlogger)ÚMapzenc            
       óf   ‡ — e Zd ZdZddddeedddef
ˆ fd„	Zdefd„Zdefd„Zed„ «       Z	d	„ Z
ˆ xZS )
r   zðMapzen Search geocoder.

    Documentation at:
        https://mapzen.com/documentation/search/

    .. warning::
       Please note that Mapzen has shut down their API so this geocoder
       class might be removed in future releases.
    Nzsearch.mapzen.comc                 ó  •— t         t        | �  ||	||||
¬«       || _        || _        || _        |j                  d«      | _        | j                  ›d| j                  ›d�| _	        | j                  ›d| j                  ›d�| _
        y)a(  
        :param str api_key: Mapzen API key, optional.

        :param str format_string:
            See :attr:`geopy.geocoders.options.default_format_string`.

        :param tuple boundary_rect: Coordinates to restrict search within,
            given as (west, south, east, north) coordinate tuple.

        :param str country_bias: Bias results to this country (ISO alpha-3).

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

            .. versionadded:: 1.12.0

        :param str domain: Specify a custom domain for Mapzen API.

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

        :type ssl_context: :class:`ssl.SSLContext`
        :param ssl_context:
            See :attr:`geopy.geocoders.options.default_ssl_context`.

            .. versionadded:: 1.14.0

        )Úformat_stringÚschemeÚtimeoutÚproxiesÚ
user_agentÚssl_contextú/z://z
/v1/searchz/v1/reverseN)Úsuperr   Ú__init__Úcountry_biasÚboundary_rectÚapi_keyÚstripÚdomainr   Úgeocode_apiÚreverse_api)Úselfr   r   r   r   r   r   r   r   r   r   Ú	__class__s              €úUC:\Users\user\Documents\project_loop\venv\Lib\site-packages\geopy/geocoders/mapzen.pyr   zMapzen.__init__   s   ø€ ô^ 	Œf�dÑ$Ø'ØØØØ!Ø#ð 	%ô 	
ð )ˆÔØ*ˆÔØˆŒØ—l‘l 3Ó'ˆŒà26·+³+¸t¿{»{ÐKˆÔØ37·;³;ÀÇÃÐLˆÕó    Tc                 ó<  — d| j                   |z  i}| j                  r|j                  d| j                  i«       | j                  rH| j                  d   |d<   | j                  d   |d<   | j                  d   |d<   | j                  d	   |d
<   | j                  r| j                  |d<   dj                  | j                  t        |«      f«      }t        j                  d| j                  j                  |«       | j                  | j                  ||¬«      |«      S )aª  
        Return a location point by address.

        :param str query: The address, query or structured query to geocode
            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.

        :rtype: ``None``, :class:`geopy.location.Location` or a list of them, if
            ``exactly_one=False``.
        Útextr   r   zboundary.rect.min_loné   zboundary.rect.min_laté   zboundary.rect.max_loné   zboundary.rect.max_latzboundary.countryú?z%s.geocode_api: %s©r   )r   r   Úupdater   r   Újoinr   r   r   Údebugr   Ú__name__Ú_parse_jsonÚ_call_geocoder)r   ÚqueryÚexactly_oner   ÚparamsÚurls         r   ÚgeocodezMapzen.geocodeW   s  € ð. ˜$×,Ñ,¨uÑ4Ð5ˆà�<Š<Ø�M‰MØ˜4Ÿ<™<ðô ð ×ÒØ.2×.@Ñ.@ÀÑ.CˆFÐ*Ñ+Ø.2×.@Ñ.@ÀÑ.CˆFÐ*Ñ+Ø.2×.@Ñ.@ÀÑ.CˆFÐ*Ñ+Ø.2×.@Ñ.@ÀÑ.CˆFÐ*Ñ+à×ÒØ)-×):Ñ):ˆFÐ%Ñ&à�h‰h˜×(Ñ(¬)°FÓ*;Ð<Ó=ˆÜ�‰Ð)¨4¯>©>×+BÑ+BÀCÔHØ×ÑØ×Ñ ¨WÐÓ5°{ó
ð 	
r   c                 ó   — 	 | j                  |«      j                  d«      D �cg c]  }|j                  «       ‘Œ c}\  }}||dœ}| j                  r|j                  d| j                  i«       dj                  | j                  t        |«      f«      }t        j                  d| j                  j                  |«       | j                  | j                  ||¬«      |«      S c c}w # t        $ r t        d«      ‚w xY w)aL  
        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.

        :rtype: ``None``, :class:`geopy.location.Location` or a list of them, if
            ``exactly_one=False``.
        ú,z"Must be a coordinate pair or Point)z	point.latz	point.lonr   r$   z%s.reverse: %sr%   )Ú_coerce_point_to_stringÚsplitr   Ú
ValueErrorr   r&   r'   r   r   r   r(   r   r)   r*   r+   )	r   r,   r-   r   ÚxÚlatÚlonr.   r/   s	            r   ÚreversezMapzen.reverse„   sø   € ð2	Cð ×,Ñ,¨UÓ3×9Ñ9¸#Ó>öØ�—‘•	ò‰HˆC�ð Øñ
ˆð
 �<Š<Ø�M‰MØ˜4Ÿ<™<ðô ð �h‰h˜×(Ñ(¬)°FÓ*;Ð<Ó=ˆÜ�‰Ð% t§~¡~×'>Ñ'>ÀÔDØ×ÑØ×Ñ ¨WÐÓ5°{ó
ð 	
ùò%øô ò 	CÜÐAÓBÐBð	Cús   ‚"C( ¤C#»C( Ã#C( Ã(C=c                 óö   — | j                  di «      j                  dg «      d   }| j                  di «      j                  dg «      d   }| j                  di «      j                  d«      }t        |||f| «      S )NÚgeometryÚcoordinatesr!   r   Ú
propertiesÚname)Úgetr   )ÚfeatureÚlatitudeÚ	longitudeÚ	placenames       r   Ú
parse_codezMapzen.parse_code´   sw   € ð —;‘;˜z¨2Ó.×2Ñ2°=À"ÓEÀaÑHˆØ—K‘K 
¨BÓ/×3Ñ3°MÀ2ÓFÀqÑIˆ	Ø—K‘K ¨bÓ1×5Ñ5°fÓ=ˆ	Ü˜	 H¨iÐ#8¸'ÓBÐBr   c                 óž   — |€y |d   }t        |«      sy |r| j                  |d   «      S |D �cg c]  }| j                  |«      ‘Œ c}S c c}w )NÚfeaturesr   )ÚlenrD   )r   Úresponser-   rF   r@   s        r   r*   zMapzen._parse_json½   sR   € ØÐØØ˜JÑ'ˆÜ�8Œ}ØÙØ—?‘? 8¨A¡;Ó/Ð/à<DÖE°�D—O‘O GÕ,ÒEÐEùÒEs   ¯A
)r)   Ú
__module__Ú__qualname__Ú__doc__r   r   r0   r9   ÚstaticmethodrD   r*   Ú__classcell__)r   s   @r   r   r      sg   ø„ ñð ØØØØ$Ø$ØØ&ØØ(õ=MðD Ø$ó	+
ð` Ø$ó	.
ð` ñCó ðCö	Fr   r   N)rK   Úgeopy.compatr   Úgeopy.geocoders.baser   r   Úgeopy.locationr   Ú
geopy.utilr   Ú__all__r   © r   r   ú<module>rT      s-   ðñõ #ß ;Ý #Ý à
€ôyFˆXõ yFr   