a
    î}c--  ã                    @   sÀ  d Z dZddlmZ 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d
lmZ ddlmZ ddlmZ ddlmZ 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dl&m'Z' ddl(m)Z) ddl*m+Z+ ddl,m-Z- ddl.m/Z/ ddl0m1Z1 ddl2m3Z3 ddl4m5Z5 ddl6m7Z7 ddl8m9Z9 ddl:m;Z;m<Z< ddl=m>Z> eee	eeeeeeeeeeee e!e#e%e'e)e+e-e/e5e1e3e7e9e;e<e>d œZ?d!d"„ Z@d#S )$u¯  
Each geolocation service you might use, such as Google Maps, Bing Maps, or
Nominatim, has its own class in ``geopy.geocoders`` abstracting the service's
API. Geocoders each define at least a ``geocode`` method, for resolving a
location from a string, and may define a ``reverse`` method, which resolves a
pair of coordinates to an address. Each Geocoder accepts any credentials
or settings needed to interact with its service, e.g., an API key or
locale, during its initialization.

To geolocate a query to an address and coordinates:

    >>> from geopy.geocoders import Nominatim
    >>> geolocator = Nominatim(user_agent="specify_your_app_name_here")
    >>> location = geolocator.geocode("175 5th Avenue NYC")
    >>> print(location.address)
    Flatiron Building, 175, 5th Avenue, Flatiron, New York, NYC, New York, ...
    >>> print((location.latitude, location.longitude))
    (40.7410861, -73.9896297241625)
    >>> print(location.raw)
    {'place_id': '9167009604', 'type': 'attraction', ...}


To find the address corresponding to a set of coordinates:

    >>> from geopy.geocoders import Nominatim
    >>> geolocator = Nominatim(user_agent="specify_your_app_name_here")
    >>> location = geolocator.reverse("52.509669, 13.376294")
    >>> print(location.address)
    Potsdamer Platz, Mitte, Berlin, 10117, Deutschland, European Union
    >>> print((location.latitude, location.longitude))
    (52.5094982, 13.3765983)
    >>> print(location.raw)
    {'place_id': '654513', 'osm_type': 'node', ...}

Locators' ``geocode`` and ``reverse`` methods require the argument ``query``,
and also accept at least the argument ``exactly_one``, which is ``True`` by
default.
Geocoders may have additional attributes, e.g., Bing accepts ``user_location``,
the effect of which is to bias results near that location. ``geocode``
and ``reverse`` methods  may return three types of values:

- When there are no results found, returns ``None``.

- When the method's ``exactly_one`` argument is ``True`` and at least one
  result is found, returns a :class:`geopy.location.Location` object, which
  can be iterated over as:

    ``(address<String>, (latitude<Float>, longitude<Float>))``

  Or can be accessed as ``location.address``, ``location.latitude``,
  ``location.longitude``, ``location.altitude``, and ``location.raw``. The
  last contains the full geocoder's response for this result.

- When ``exactly_one`` is ``False``, and there is at least one result, returns a
  list of :class:`geopy.location.Location` objects, as above:

    ``[location, [...]]``

If a service is unavailable or otherwise returns a non-OK response, or doesn't
receive a response in the allotted timeout, you will receive one of the
`Exceptions`_ detailed below.

.. _specifying_parameters_once:

Specifying Parameters Once
~~~~~~~~~~~~~~~~~~~~~~~~~~

Geocoding methods accept a lot of different parameters, and you would
probably want to specify some of them just once and not care about them
later.

This is easy to achieve with Python's :func:`functools.partial`::

    >>> from functools import partial
    >>> from geopy.geocoders import Nominatim

    >>> geolocator = Nominatim(user_agent="specify_your_app_name_here")

    >>> geocode = partial(geolocator.geocode, language="es")
    >>> print(geocode("london"))
    Londres, Greater London, Inglaterra, SW1A 2DX, Gran BretaÃ±a
    >>> print(geocode("paris"))
    ParÃ­s, Isla de Francia, Francia metropolitana, Francia
    >>> print(geocode("paris", language="en"))
    Paris, Ile-de-France, Metropolitan France, France

    >>> reverse = partial(geolocator.reverse, language="es")
    >>> print(reverse("52.509669, 13.376294"))
    Steinecke, Potsdamer Platz, Tiergarten, Mitte, 10785, Alemania

If you need to modify the query, you can also use a one-liner with lambda.
For example, if you only need to geocode locations in `Cleveland, Ohio`,
you could do::

    >>> geocode = lambda query: geolocator.geocode("%s, Cleveland OH" % query)
    >>> print(geocode("11111 Euclid Ave"))
    Thwing Center, Euclid Avenue, Magnolia-Wade Park Historic District,
    University Circle, Cleveland, Cuyahoga County, Ohio, 44106, United States
    of America

That lambda doesn't accept kwargs. If you need them, you could do::

    >>> _geocode = partial(geolocator.geocode, language="es")
    >>> geocode = lambda query, **kw: _geocode("%s, Cleveland OH" % query, **kw)
    >>> print(geocode("11111 Euclid Ave"))
    Thwing Center, Euclid Avenue, Magnolia-Wade Park Historic District,
    University Circle, Cleveland, Cuyahoga County, Ohio, 44106, Estados Unidos
    >>> print(geocode("11111 Euclid Ave", language="en"))
    Thwing Center, Euclid Avenue, Magnolia-Wade Park Historic District,
    University Circle, Cleveland, Cuyahoga County, Ohio, 44106, United States
    of America

Geopy Is Not a Service
~~~~~~~~~~~~~~~~~~~~~~

Geocoding is provided by a number of different services, which are not
affiliated with geopy in any way. These services provide APIs, which anyone
could implement, and geopy is just a library which provides these
implementations for many different services in a single package.

.. image:: ./_static/geopy_and_geocoding_services.svg
   :target: ./_static/geopy_and_geocoding_services.svg

Therefore:

1. Different services have different Terms of Use, quotas, pricing,
   geodatabases and so on. For example, :class:`.Nominatim`
   is free, but provides low request limits. If you need to make more queries,
   consider using another (probably paid) service, such as
   :class:`.OpenMapQuest` or :class:`.PickPoint`
   (these two are commercial providers of Nominatim, so they should
   have the same data and APIs). Or, if you are ready to wait, you can try
   :mod:`geopy.extra.rate_limiter`.

2. geopy cannot be responsible for the geocoding services' databases.
   If you have issues with some queries which the service cannot fulfill,
   it should be directed to that service's support team.

3. geopy cannot be responsible for any networking issues between your computer
   and the geocoding service.

If you face any problem with your current geocoding service provider, you can
always try a different one.

.. _async_mode:

Async Mode
~~~~~~~~~~

By default geopy geocoders are synchronous (i.e. they use an Adapter
based on :class:`.BaseSyncAdapter`).

All geocoders can be used with asyncio by simply switching to an
Adapter based on :class:`.BaseAsyncAdapter` (like :class:`.AioHTTPAdapter`).

Example::

    from geopy.adapters import AioHTTPAdapter
    from geopy.geocoders import Nominatim

    async with Nominatim(
        user_agent="specify_your_app_name_here",
        adapter_factory=AioHTTPAdapter,
    ) as geolocator:
        location = await geolocator.geocode("175 5th Avenue NYC")
        print(location.address)

Basically the usage is the same as in synchronous mode, except that
all geocoder calls should be used with ``await``, and the geocoder
instance should be created by ``async with``. The context manager is optional,
however, it is strongly advised to use it to avoid resources leaks.

) Úget_geocoder_for_serviceÚoptionsÚAlgoliaPlacesÚArcGISÚ	AzureMapsÚBaiduÚBaiduV3Ú	BANFranceÚBingÚDataBCÚGeocodeEarthÚGeocodioÚGeoNamesÚGoogleV3ÚGeolakeÚHereÚHereV7Ú	IGNFranceÚMapBoxÚMapQuestÚMapTilerÚ	NominatimÚOpenCageÚOpenMapQuestÚ	PickPointÚPeliasÚPhotonÚLiveAddressÚTomTomÚ
What3WordsÚWhat3WordsV3ÚYandexé    )ÚGeocoderNotFound)r   )r   )r   )r   r   )r   )r   )r	   )r
   )r   )r   )r   )r   )r   )r   r   )r   )r   )r   )r   )r   )r   )r   )r   )r   )r   )r   )r   )r   r   )r    )ZalgoliaZarcgisZazureZbaiduZbaiduv3Z	banfranceZbingZdatabcZgeocodeearthZgeocodioZgeonamesÚgoogleZgooglev3ZgeolakeÚhereZherev7Z	ignfranceZmapboxZmapquestZmaptilerZ	nominatimZopencageZopenmapquestZ	pickpointZpeliasZphotonZliveaddressZtomtomZ
what3wordsZwhat3wordsv3Zyandexc                 C   s:   zt |  ¡  W S  ty4   td| t  ¡ f ƒ‚Y n0 dS )a  
    For the service provided, try to return a geocoder class.

    >>> from geopy.geocoders import get_geocoder_for_service
    >>> get_geocoder_for_service("nominatim")
    geopy.geocoders.nominatim.Nominatim

    If the string given is not recognized, a
    :class:`geopy.exc.GeocoderNotFound` exception is raised.

    Given that almost all of the geocoders provide the ``geocode``
    method it could be used to make basic queries based entirely
    on user input::

        from geopy.geocoders import get_geocoder_for_service

        def geocode(geocoder, config, query):
            cls = get_geocoder_for_service(geocoder)
            geolocator = cls(**config)
            location = geolocator.geocode(query)
            return location.address

        >>> geocode("nominatim", dict(user_agent="specify_your_app_name_here"), "london")
        'London, Greater London, England, SW1A 2DX, United Kingdom'
        >>> geocode("photon", dict(), "london")
        'London, SW1A 2DX, London, England, United Kingdom'

    z&Unknown geocoder '%s'; options are: %sN)ÚSERVICE_TO_GEOCODERÚlowerÚKeyErrorr"   Úkeys)Zservice© r)   úT/var/www/html/django/DPS/env/lib/python3.9/site-packages/geopy/geocoders/__init__.pyr     s    
ÿÿr   N)AÚ__doc__Ú__all__Z	geopy.excr"   Zgeopy.geocoders.algoliar   Zgeopy.geocoders.arcgisr   Zgeopy.geocoders.azurer   Zgeopy.geocoders.baidur   r   Zgeopy.geocoders.banfrancer   Zgeopy.geocoders.baser   Zgeopy.geocoders.bingr	   Zgeopy.geocoders.databcr
   Zgeopy.geocoders.geocodeearthr   Zgeopy.geocoders.geocodior   Zgeopy.geocoders.geolaker   Zgeopy.geocoders.geonamesr   Zgeopy.geocoders.googler   Zgeopy.geocoders.herer   r   Zgeopy.geocoders.ignfrancer   Zgeopy.geocoders.mapboxr   Zgeopy.geocoders.mapquestr   Zgeopy.geocoders.maptilerr   Zgeopy.geocoders.nominatimr   Zgeopy.geocoders.opencager   Zgeopy.geocoders.openmapquestr   Zgeopy.geocoders.peliasr   Zgeopy.geocoders.photonr   Zgeopy.geocoders.pickpointr   Zgeopy.geocoders.smartystreetsr   Zgeopy.geocoders.tomtomr   Zgeopy.geocoders.what3wordsr   r   Zgeopy.geocoders.yandexr    r%   r   r)   r)   r)   r*   Ú<module>   s€    //á#