
    Eh$                         S r SSKrSSKrSSKJr  SSKrSSK	J
r
JrJrJrJr  SSKJrJrJr  SSKJr  SSKJr  \R.                  R1                  S5      rS	\ 3r " S
 S\5      r SS jrg)z-Tools for generating maps from a text search.    N   )howmanybounds2raster
bounds2img_sm2ll_calculate_zoom)INTERPOLATIONZOOMadd_attribution)	providers)TileProvideri@B contextily_user_c                   x    \ rS rSrSrSSSS\R                  R                  \S94S jr	S r
S\\S4S jrS rS	rg)
Place   a.  Geocode a place by name and get its map.

This allows you to search for a name (e.g., city, street, country) and
grab map and location data from the internet.

Parameters
----------
search : string
    The location to be searched.
zoom : int or None
    [Optional. Default: None]
    The level of detail to include in the map. Higher levels mean more
    tiles and thus longer download time. If None, the zoom level will be
    automatically determined.
path : str or None
    [Optional. Default: None]
    Path to a raster file that will be created after getting the place map.
    If None, no raster file will be downloaded.
zoom_adjust : int or None
    [Optional. Default: None]
    The amount to adjust a chosen zoom level if it is chosen automatically.
source : xyzservices.providers object or str
    [Optional. Default: OpenStreetMap Humanitarian web tiles]
    The tile source: web tile provider or path to local file. The web tile
    provider can be in the form of a :class:`xyzservices.TileProvider` object or a
    URL. The placeholders for the XYZ in the URL need to be `{x}`, `{y}`,
    `{z}`, respectively. For local file paths, the file is read with
    `rasterio` and all bands are loaded into the basemap.
    IMPORTANT: tiles are assumed to be in the Spherical Mercator
    projection (EPSG:3857), unless the `crs` keyword is specified.
geocoder : geopy.geocoders
    [Optional. Default: geopy.geocoders.Nominatim()] Geocoder method to process `search`

Attributes
----------
geocode : geopy object
    The result of calling ``geopy.geocoders.Nominatim`` with ``search`` as input.
s : float
    The southern bbox edge.
n : float
    The northern bbox edge.
e : float
    The eastern bbox edge.
w : float
    The western bbox edge.
im : ndarray
    The image corresponding to the map of ``search``.
bbox : list
    The bounding box of the returned image, expressed in lon/lat, with the
    following order: [minX, minY, maxX, maxY]
bbox_map : tuple
    The bounding box of the returned image, expressed in Web Mercator, with the
    following order: [minX, minY, maxX, maxY]
N)
user_agentc           	      j   X0l         Uc  [        R                  R                  nXPl        X@l        UR                  U5      n[        R                  " UR                  S    Vs/ s H  n[        U5      PM     sn5      n	SUR                  R                  5       ;   a  UR                  S   n
O0SUR                  R                  5       ;   a  UR                  S   n
OUn
Xl        Xl        U	u  U l        U l        U l        U l        U R                   U R                  U R"                  U R                  /U l        UR&                  U l        UR(                  U l        Xpl        Uc6  [+        U R                   U R                  U R"                  U R                  5      OUU l        [/        U R,                  5      U l        U R
                  b  U =R,                  U-  sl        [1        U R                   U R                  U R"                  U R                  U R,                  SS9U l        U R5                  5         g s  snf )Nboundingboxdisplay_nameaddressF)verbose)pathr   OpenStreetMapHOTsourcezoom_adjustgeocodenparrayrawfloatkeysplacesearchsnwebboxlatitude	longituder   zoomintr   n_tiles_get_map)selfr$   r,   r   r   r   geocoderrespiir)   r#   s              cC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\contextily/place.py__init__Place.__init__I   s    	>,,00F& 'xxTXXm-DE-Drr-DEFTXX]]_,HH^,E$((--/)HHY'EE
)-&VVTVVTVVTVV4	 @D|ODFFDFFDFFDFF;QU 		 		N	'II$ItvvtvvtvvtvvtyyRWX 	5 Fs   "H0c                    SS0nU R                   b  U R                   US'    [        U R                  [        5      (       aQ  [	        U R
                  U R                  U R                  U R                  U R                  4SU R                  0UD6u  p#OE[        U R
                  U R                  U R                  U R                  U R                  40 UD6u  p# X l        X0l        X#4$ ! [         aV  n[        SR                  U R
                  U R                  U R                  U R                  U R                  X5      5      eS nAff = f)NllTr   r,   zLCould not retrieve map with parameters: {}, {}, {}, {}, zoom={}
{}
Error: {})r   
isinstancer   strr   r'   r%   r(   r&   r,   r   	Exception
ValueErrorformatimbbox_map)r0   kwargsr>   r)   errs        r4   r/   Place._get_mapv   s   ;;"#{{F8	$))S))(FFDFFDFFDFFDIIDHIIQWD &FFDFFDFFDFFDIIAGD x  	`ggFFDFFDFFDFFDIIv 	s    A/C& AC& &
E0AEEc                    U R                   nU R                  nSnSnUc$  [        R                  " SS9u  pU R                  nSnUR                  XVUS9  UR                  SSS	9  [        U R                  [        [        45      (       a  Uc  U R                  R                  S
5      nU(       a  [        X5        Ub  UR                  US9  U(       a  UR                  5         U$ )at  
Plot a `Place` object
...

Parameters
----------
ax : AxesSubplot
    Matplotlib axis with `x_lim` and `y_lim` set in Web
    Mercator (EPSG=3857). If not provided, a new
    12x12 figure will be set and the name of the place
    will be added as title
zoom : int/'auto'
    [Optional. Default='auto'] Level of detail for the
    basemap. If 'auto', if calculates it automatically.
    Ignored if `source` is a local file.
interpolation : str
    [Optional. Default='bilinear'] Interpolation
    algorithm to be passed to `imshow`. See
    `matplotlib.pyplot.imshow` for further details.
attribution : str
    [Optional. Defaults to attribution specified by the source of the map tiles]
    Text to be added at the bottom of the axis. This
    defaults to the attribution of the provider specified
    in `source` if available. Specify False to not
    automatically add an attribution, or a string to pass
    a custom attribution.

Returns
-------
ax : AxesSubplot
    Matplotlib axis with `x_lim` and `y_lim` set in Web
    Mercator (EPSG=3857) containing the basemap

Examples
--------

>>> lvl = cx.Place('Liverpool')
>>> lvl.plot()

NF)   rD   figsizeT)extentinterpolationXYxlabelylabelattributiontitle)r>   r?   pltsubplotsr#   imshowsetr9   r   dictr   getr   set_axis_off)
r0   axr,   rH   rN   r>   r)   rP   axisofffigs
             r4   plot
Place.plot   s    R WW}}:ll84GCJJEG
		"	?
c#&dkkD,#788[=P++//-8KB,FFFOO	    c                     SR                  U R                  U R                  U R                  U R                  R
                  S S 5      nU$ )Nz.Place : {} | n_tiles: {} | zoom : {} | im : {}   )r=   r#   r.   r,   r>   shape)r0   r%   s     r4   __repr__Place.__repr__   s=    <CCJJdiir1B
 r]   )r)   r?   r(   r   r>   r*   r+   r&   r.   r   r#   r%   r$   r   r'   r,   r   )__name__
__module____qualname____firstlineno____doc__gp	geocoders	Nominatim_default_user_agentr5   r/   r
   r	   r[   ra   __static_attributes__ r]   r4   r   r      sN    5t ''3F'G+Z2 ]PT <|r]   r   c                    [         R                  " S[        5        [        U [        5      (       d  U nUnUnOTU R
                  nUc4  U R                  nUSL a#  Uu  pp[        X5      u  p[        X5      u  pXX/nUc  U R                  OUnUc  [        R                  " SS9u  pUR                  XqS9  UR                  SSS9  Ub  UR                  US	9  U(       a  [        X65        USL a  UR                  5         U$ )
a  Plot a map of the given place.

Parameters
----------
place : instance of Place or ndarray
    The map to plot. If an ndarray, this must be an image corresponding
    to a map. If an instance of ``Place``, the extent of the image and name
    will be inferred from the bounding box.
ax : instance of matplotlib Axes object or None
    The axis on which to plot. If None, one will be created.
axis_off : bool
    Whether to turn off the axis border and ticks before plotting.
attribution : str
    [Optional. Default to standard `ATTRIBUTION`] Text to be added at the
    bottom of the axis.

Returns
-------
ax : instance of matplotlib Axes object or None
    The axis on the map is plotted.
zThe method `plot_map` is deprecated and will be removed from the library in future versions. Please use either `add_basemap` or the internal method `Place.plot`T)   ro   rE   )rG   rI   rJ   rK   rO   )warningswarnDeprecationWarningr9   r   r>   r?   r   r#   rQ   rR   rS   rT   r   rW   )r#   r)   rP   rX   axis_offlatlonrN   r>   r'   r(   r%   r&   rZ   s                r4   plot_mapru      s    0 MM0 	 eU##XX<>>D~!
aa|a|a|$}%	z,,x0IIbIFF#cF"
U(4
Ir]   )NNNTTN)rg   geopyrh   numpyr   matplotlib.pyplotpyplotrQ   rp   tiler   r   r   r   r   plottingr	   r
   r    r   xyzservicesr   randomrandint_valrk   objectr   ru   rm   r]   r4   <module>r      sd    3     M M : :  $ 
yy!(/ @F @H TX;r]   