
    rbi                     X    d dl Z d dlmZ d dlZd dlmZ d dlZd Zd	dZ	d	dZ
d Zd ZdS )
    N)defaultdict)Pointc                 2    ddl }| |j        j        k    rdS dS )z
    Amount of time to wait between requests to a geocoding API, for providers
    that specify rate limits in their terms of service.
    r   N   )geopy.geocoders	geocoders	Nominatim)providergeopys     i/var/www/html/mdtn/previsions/meteo_cartes/venv/lib/python3.11/site-packages/geopandas/tools/geocoding.py_get_throttle_timer      s,    
  5?,,,qq    c                 H    |d}t          |          }t          | d||fi |S )ab  
    Geocode a set of strings and get a GeoDataFrame of the resulting points.

    Parameters
    ----------
    strings : list or Series of addresses to geocode
    provider : str or geopy.geocoder
        Specifies geocoding service to use. If none is provided,
        will use 'photon' (see the Photon's terms of service at:
        https://photon.komoot.io).

        Either the string name used by geopy (as specified in
        geopy.geocoders.SERVICE_TO_GEOCODER) or a geopy Geocoder instance
        (e.g., geopy.geocoders.Photon) may be used.

        Some providers require additional arguments such as access keys
        See each geocoder's specific parameters in geopy.geocoders

    Notes
    -----
    Ensure proper use of the results by consulting the Terms of Service for
    your provider.

    Geocoding requires geopy. Install it using 'pip install geopy'. See also
    https://github.com/geopy/geopy

    Examples
    --------
    >>> df = geopandas.tools.geocode(  # doctest: +SKIP
    ...         ["boston, ma", "1600 pennsylvania ave. washington, dc"]
    ...     )
    >>> df  # doctest: +SKIP
                        geometry                                            address
    0  POINT (-71.05863 42.35899)                          Boston, MA, United States
    1  POINT (-77.03651 38.89766)  1600 Pennsylvania Ave NW, Washington, DC 20006...
    NphotonTr   _query)stringsr
   kwargsthrottle_times       r   geocoder      s9    J &x00M'4=CCFCCCr   c                 H    |d}t          |          }t          | d||fi |S )a  
    Reverse geocode a set of points and get a GeoDataFrame of the resulting
    addresses.

    The points

    Parameters
    ----------
    points : list or Series of Shapely Point objects.
        x coordinate is longitude
        y coordinate is latitude
    provider : str or geopy.geocoder (opt)
        Specifies geocoding service to use. If none is provided,
        will use 'photon' (see the Photon's terms of service at:
        https://photon.komoot.io).

        Either the string name used by geopy (as specified in
        geopy.geocoders.SERVICE_TO_GEOCODER) or a geopy Geocoder instance
        (e.g., geopy.geocoders.Photon) may be used.

        Some providers require additional arguments such as access keys
        See each geocoder's specific parameters in geopy.geocoders

    Notes
    -----
    Ensure proper use of the results by consulting the Terms of Service for
    your provider.

    Reverse geocoding requires geopy. Install it using 'pip install geopy'.
    See also https://github.com/geopy/geopy

    Examples
    --------
    >>> from shapely.geometry import Point
    >>> df = geopandas.tools.reverse_geocode(  # doctest: +SKIP
    ...     [Point(-71.0594869, 42.3584697), Point(-77.0365305, 38.8977332)]
    ... )
    >>> df  # doctest: +SKIP
                         geometry                                            address
    0  POINT (-71.05941 42.35837)       29 Court Sq, Boston, MA 02108, United States
    1  POINT (-77.03641 38.89766)  1600 Pennsylvania Ave NW, Washington, DC 20006...
    Nr   Fr   )pointsr
   r   r   s       r   reverse_geocoder   E   s9    V &x00M&%=CCFCCCr   c                 ^   ddl m} ddlm} |r/t	          | t
          j                  st          j        |           } n.t	          | t          j                  st          j        |           } t	          |t                    r ||          } |di |}i }| 
                                D ]s\  }	}
	 |r|                    |
          ||	<   n&|                    |
j        |
j        fd          ||	<   n# |t          f$ r d||	<   Y nw xY wt!          j        |           tt%          |          }|S )Nr   )get_geocoder_for_service)GeocoderQueryErrorT)exactly_one)NN )r   r   geopy.geocoders.baser   
isinstancepdSeries	geopandas	GeoSeriesstritemsr   reverseyx
ValueErrortimesleep_prepare_geocode_result)dataforwardr
   r   r   r   r   coderresultsisdfs               r   r   r   w   se   888888777777 -$	** 	#9T??D$	 344 	-&t,,D(C   6++H55HvEG

 " "1	& I"]]1--

"]]AC:4]HH
"J/ 	& 	& 	&%GAJJJ	&
=!!!!	 	)	)BIs   0AC22DDc                    t          t                    }g }|                                 D ]\  }}|t                      }d}n2|\  }}|t                      }nt          |d         |d                   }|d                             |           |d                             |           |                    |           t          j        ||d          }|S )zConvert the geocode results to a GeoDataFrame.

    Takes a dict where keys are index entries, values are tuples containing:
    (address, (lat, lon))

    Nr   r   geometryaddressz	EPSG:4326)indexcrs)r   listr&   r   appendr#   GeoDataFrame)	r1   dr8   r2   r3   pr7   locr4   s	            r   r-   r-      s     	DAE  19AGG LGS {GG#a&#a&))	*Q	)G$$$Q		K	@	@	@BIr   )N)r+   collectionsr   pandasr!   shapely.geometryr   r#   r   r   r   r   r-   r   r   r   <module>rC      s     # # # # # #     " " " " " "      )D )D )D )DX/D /D /D /Dd  >    r   