
    Dh8                        S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SK	J
r
  S SKJrJrJrJrJrJrJrJrJrJrJrJrJr  S SKJrJrJrJr  S SKrS SK J!r!J"r"J#r#  S SK$J%r%J&r&J'r'J(r(J)r)   S SK*r+\(       a  SSK-J.r.  \\\/      r0\\0\\0   4   r1\\2\/\3\\44   r5\\5S4   r6\\3\2\/S4   r7\\\/      r8\\\\/         r9\\#\!S	4   r:\S
   r;\<" \\-   \-   5      r=\=R}                  S5        \=R                  S5        S\\/   S\\/   4S jr@S\1SS4S jrAS\0S\\\/      4S jrBS\1S\\\\/      \\\\/         4   4S jrCS\S\4S jrD  S?S\S\\   S\2S\24S jjrES\2S\34S jrF  S@S\S\\/\/4   S\2S\\G   S\R                  4
S jjrIS\S\\\/S4      4S  jrJ SAS\S!\3S\\\\/         4S" jjrKS#\8S\94S$ jrLS%\2S\24S& jrMS'\2S(\2S\34S) jrNS*\2S\24S+ jrO\
S\2S\\2   4S, j5       rPS-\"S\"4S. jrQS/\"S0\S\"4S1 jrRS2\6S\\2\54   4S3 jrSS2\6S\\2\54   4S4 jrTS5\2S\24S6 jrUS5\2S\24S7 jrVS8\2S\24S9 jrWS\"S\#4S: jrX " S; S<5      rYS=\\2\G\/4   S\24S> jrZg! \, a    Sr+ GNf = f)B    N)contextmanager)TYPE_CHECKINGAnyCallableDictIterableIteratorListLiteralOptionalSequenceTupleTypeUnion)urlparseuses_netlocuses_paramsuses_relative)DivElementFigure)_locations_mirror_parse_sizenone_maxnone_min	write_png   )Popupr   )bottomright
bottomlefttoprighttopleft datalocationreturnc           
         [        U [        R                  5      (       d&  [        bC  [        U [        R                  5      (       a$  [        R
                  " U 5      R                  5       n [        U S5      (       d  [        SU < S[        U 5       S35      e[        U 5      S:w  a  [        SU < S35      e U S   U S   4nU H>  n [        U5        [        R                  " [        U5      5      (       d  M5  [        S5      e   U Vs/ s H  n[        U5      PM     sn$ ! [        [        4 a    [        S	U < S[        U 5       S35      ef = f! [        [        4 a    [        S
U< S[        U5       S35      ef = fs  snf )zValidate a single lat/lon coordinate pair and convert to a list

Validate that location:
* is a sized variable
* with size 2
* allows indexing (i.e. has an ordering)
* where both values are floats (or convertible to float)
* and both values are not NaN
__len__zPLocation should be a sized variable, for example a list or a tuple, instead got z	 of type .   z:Expected two (lat, lon) values for location, instead got: r   r   zKLocation should support indexing, like a list or a tuple does, instead got z5Location should consist of two numerical values, but z is not convertible to float.z$Location values cannot contain NaNs.)
isinstancenpndarraypd	DataFramesqueezetolisthasattr	TypeErrortypelen
ValueErrorKeyErrorfloatmathisnan)r%   coordscoordxs       cC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\folium/utilities.pyvalidate_locationr?   E   s    (BJJ''
:h==::h'..08Y'':l)DN#316
 	

 8}$<q*
 	

1+x{+ 	%L ::eEl##CDD  %%fE!Hf%% x  
))1Id8n=MQP
 	

 :& 	iye5RT 	 &s   7
D! E	F!-E-E>	locationsc                      [        U 5         [        [        U 5      5        g! [         a    [        SU < S35      ef = f! [         a    [	        S5      ef = f)zHHelper function that does basic validation of line and multi-line types.zGLocations should be an iterable with coordinate pairs, but instead got r)   zLocations is empty.N)iterr3   nextStopIterationr6   )r@   s    r>   _validate_locations_basicsrE   r   sj    
Y0T)_  
  )}A/
 	

  0.//0s   # A >Ac                 p    [        U 5      n [        U 5        U  Vs/ s H  n[        U5      PM     sn$ s  snf )z3Validate an iterable with lat/lon coordinate pairs.)if_pandas_df_convert_to_numpyrE   r?   )r@   
coord_pairs     r>   validate_locationsrI      s2    -i8Iy)<EFIjj)IFFFs   3c                 d   [        U 5      n [        U 5         [        [        [	        [        [	        [        [	        U 5      5      5      5      5      5      5        U  Vs/ s H  n[        U5      PM     sn$ s  snf ! [        [        4 a%    U  Vs/ s H  n[        U5      PM     Os  snf sns $ f = f)zDValidate an iterable with possibly nested lists of coordinate pairs.)	rG   rE   r8   rC   rB   rI   r3   rD   r?   )r@   lstrH   s      r>   validate_multi_locationsrL      s     .i8Iy)>d4T$tI"789:;< 4==9C"3'9=== }% K@IJ	*!*-	JJKs$   AA: A5:B/B$#	B/.B/objc                 j    [         b+  [        U [         R                  5      (       a  U R                  $ U $ )zReturn a Numpy array from a Pandas dataframe.

Iterating over a DataFrame has weird side effects, such as the first
row being the column names. Converting to Numpy is more safe.
)r.   r+   r/   values)rM   s    r>   rG   rG      s(     
~*S",,77zz
    imagecolormaporiginc                 t   [        U [        5      (       a  [        U 5      (       dx  [        R                  R                  U 5      S   SS n[        U S5       nUR                  5       nSSS5        [        R                  " W5      R                  S5      nSU SU 3nOySU R                  R                  ;   a5  [        XUS	9n[        R                  " U5      R                  S5      nS
U 3nO*[        R                  " [        R                   " U 5      5      nUR#                  SS5      $ ! , (       d  f       N= f)a  
Infers the type of an image argument and transforms it into a URL.

Parameters
----------
image: string or array-like object
    *  If string is a path to an image file, its content will be converted and
       embedded in the output URL.
    *  If string is a URL, it will be linked in the output URL.
    *  Otherwise a string will be assumed to be JSON and embedded in the
       output URL.
    *  If array-like, it will be converted to PNG base64 string and embedded in the
       output URL.
origin: ['upper' | 'lower'], optional, default 'upper'
    Place the [0, 0] index of the array in the upper left or
    lower left corner of the axes.
colormap: callable, used only for `mono` image.
    Function of the form [x -> (r,g,b)] or [x -> (r,g,b,a)]
    for transforming a mono image into RGB.
    It must output iterables of length 3 or 4, with values between
    0. and 1.  You can use colormaps from `matplotlib.cm`.

r   Nrbzutf-8zdata:image/z;base64,r-   )rS   rR   zdata:image/png;base64,
 )r+   str_is_urlospathsplitextopenreadbase64	b64encodedecode	__class____name__r   jsonloadsdumpsreplace)rQ   rR   rS   
fileformatfimg
b64encodedurls           r>   image_to_urlrn      s    8 %gennWW%%e,R04
%!&&(C %%c*11':
J<x
|<	eoo..	.x@%%c*11':
&zl3 jjE*+;;tS!! s   D))
D7rm   c                 \     [        U 5      R                  [        ;   $ ! [         a     gf = f)z+Check to see if `url` has a valid protocol.F)r   scheme_VALID_URLS	Exception)rm   s    r>   rZ   rZ      s.    }##{22 s    
++
lat_bounds
height_outc           
         S n[         R                  " U 5      R                  5       nUR                  u  pgn[	        US   S5      n	[        US   S5      n
Uc  UnUS:X  a  USSS2SS2SS24   nU	[         R                  " S	U-  S
S	U-  -
  U5      X-
  -  -   nU" U	5      [         R                  " S	U-  S
S	U-  -
  U5      U" U
5      U" U	5      -
  -  -   n[         R                  " X7U45      n[        U5       H@  n[        U5       H.  n[         R                  " X" U5      USS2X4   5      USS2X4'   M0     MB     US:X  a  USSS2SS2SS24   nU$ )a  
Transforms an image computed in (longitude,latitude) coordinates into
the a Mercator projection image.

Parameters
----------

data: numpy array or equivalent list-like object.
    Must be NxM (mono), NxMx3 (RGB) or NxMx4 (RGBA)

lat_bounds : length 2 tuple
    Minimal and maximal value of the latitude of the image.
    Bounds must be between -85.051128779806589 and 85.051128779806589
    otherwise they will be clipped to that values.

origin : ['upper' | 'lower'], optional, default 'upper'
    Place the [0,0] index of the array in the upper left or lower left
    corner of the axes.

height_out : int, default None
    The expected height of the output.
    If None, the height of the input is used.

See https://en.wikipedia.org/wiki/Web_Mercator for more details.

c                     [         R                  " [         R                  " U [         R                  -  S-  5      5      S-  [         R                  -  $ )Ng     f@)r,   arcsinhtanpi)r=   s    r>   mercator$mercator_transform.<locals>.mercator   s5    zz"&&RUUU!234u<ruuDDrP   r   gIECUr   gIECU@NupperrU   g      ?g      ?)
r,   
atleast_3dcopyshapemaxminlinspacezerosrangeinterp)r$   rs   rS   rt   rz   arrayheightwidthnblayerslat_minlat_maxlatslatslatsoutijs                   r>   mercator_transformr      sn   BE MM$$$&E#kkF8*Q-!45G*Q-!34G
 ddAqj!R[[vsS6\/A6J D  2;;j#j 00*$	'	Xg.	.$0 0H hh
8<=C5\xA99Xx~uQW~NC1L ! 
 $B$1*oJrP   .c              #     #    [        U [        [        45      (       a  U nOSU ;   a(  U S    Vs/ s H  nUS   (       d  M  US   S   PM     nnOXSU ;   a  U S   (       a  U S   S   O/ nO=SU ;   a%  U S   S   (       a  SU S   S   ;   a  U S   S   S   nOU R                  SU 5      nU H@  n[        U[        [
        45      (       a  [        U5      v     g[        U5       Sh  vN   MB     gs  snf  N7f)z@
Returns all the coordinate tuples from a geometry or feature.

featuresgeometrycoordinates
geometriesr   N)r+   tuplelistgetr8   intiter_coords)rM   r;   geomr<   s       r>   r   r     s    
 #t}%%	s	 J
'J ,D]+' 	 

 
s	36z?Z/a S.q11\"1%m4,eeS\**-"5))) 
( *s#   ,C5C. C.BC5$C3%C5lonlatc                    SS/SS//n[        U 5       HW  n[        US   S   US   5      [        US   S   US   5      /[        US   S   US   5      [        US   S   US   5      //nMY     U(       a  [        U5      nU$ )zY
Computes the bounds of the object in the form
[[lat_min, lon_min], [lat_max, lon_max]]

Nr   r   )r   r   r   r   )r@   r   boundspoints       r>   
get_boundsr   9  s     -1$<$*FFY' 1uQx01uQx0
 1uQx01uQx0	
 ( "6*MrP   r   c           
      |    U  VVs/ s H"  o Vs/ s H  o"b  [        U5      OS PM     snPM$     snn$ s  snf s  snnf N)r8   )r   yr=   s      r>   normalize_bounds_typer   S  s7    FLMf!<!QU1XD0!<fMM<Ms   	8388keyc                 b    SR                  S [        U R                  S5      5       5       5      $ )zConvert a python_style_variable_name to lowerCamelCase.

Examples
--------
>>> camelize("variable_name")
'variableName'
>>> camelize("variableName")
'variableName'
r#   c              3   V   #    U  H  u  pUS :  a  UR                  5       OUv   M!     g7f)r   N)
capitalize).0r   r=   s      r>   	<genexpr>camelize.<locals>.<genexpr>a  s%     X>WdaQU1<<>1>Ws   ')_)join	enumeratesplit)r   s    r>   camelizer   W  s'     77Xi		RU>WXXXrP   obj1obj2c                 0    [        U 5      [        U5      :H  $ )zg
Return True/False if the normalized rendered version of
two folium map objects are the equal or not.

)	normalize)r   r   s     r>   compare_renderedr   d  s     T?io--rP   renderedc                     SR                  U R                  5        Vs/ s H)  oR                  5       (       d  M  UR                  5       PM+     sn5      nUR                  SS5      nU$ s  snf )zBReturn the input string without non-functional spaces or newlines.r#   z, ,)r   
splitlinesstriprh   )r   liner   s      r>   r   r   m  sS    
''H,?,?,AR,ADZZ\<4::<,AR
SC
++dC
 CJ Ss
   A)A)c              #     #    Sn [         R                  " SSS9u  p![        R                  " U[	        U [
        5      (       a  U R                  S5      OU 5        [        R                  " U5        Uv   [        R                  R                  U5      (       a  [        R                  " U5        gg! [        R                  R                  U5      (       a  [        R                  " U5        f f = f7f)z9Yields the path of a temporary HTML file containing data.r#   z.htmlfolium_)suffixprefixutf8N)tempfilemkstempr[   writer+   rY   encodecloser\   isfileremove)r$   filepathfids      r>   temp_html_filepathr   t  s      H  ((	J
Zc-B-Bdkk&)M
77>>(##IIh $277>>(##IIh $s   C0A.B0 4<C00=C--C0item_originalc                    [         R                   " U 5      n[        R                  " 5       R                  Ul        [        US5      (       ax  [        UR                  5      S:  a_  [        R                  " 5       nUR                  R                  5        H&  n[        U5      nXl        XBUR                  5       '   M(     X!l        U$ )zBReturn a recursive deep-copy of item where each copy has a new ID.	_childrenr   )r~   uuiduuid4hex_idr2   r5   r   collectionsOrderedDictrO   	deep_copy_parentget_name)r   itemchildren_newsubitem_originalsubitems        r>   r   r     s    99]#Dzz|DHt[!!c$..&9A&="..0 $ 5 5 7 01G"O/6))+, !8 &KrP   elementclsc                 v    U R                   nUc  [        SU 35      e[        X!5      (       d  [        X!5      $ U$ )z:Return the first object in the parent tree of class `cls`.z2The top of the tree was reached without finding a )r   r6   r+   get_obj_in_upper_tree)r   r   parents      r>   r   r     s>    __F~McUSTTf""$V11MrP   kwargsc                  v    U R                  5        VVs0 s H  u  pUc  M
  [        U5      U_M     snn$ s  snnf )z=Return a dict with lower-camelcase keys and non-None values..)itemsr   r   r   values      r>   parse_optionsr     s0    39<<>W>ZSU HSM5 >WWWs   	55c                  b    U R                  5        VVs0 s H  u  pUc  M
  X_M     snn$ s  snnf )z"Return a dict without None values.)r   r   s      r>   remove_emptyr     s(    )/M:35JCJMMMs   	++textc                 2    [         R                  " SSU 5      $ )z6Escape backticks so text can be used in a JS template.z(?<!\\)`z\`)resubr   s    r>   escape_backticksr     s    66+ud++rP   c                 &    U R                  SS5      $ )N"z\")rh   r   s    r>   escape_double_quotesr     s    <<U##rP   r\   c                 P    SR                  S U R                  S5       5       5      $ )zBConvert a path like obj1.obj2 to array notation: ["obj1"]["obj2"].r#   c              3   @   #    U  H  nS [        U5       S3v   M     g7f)z["z"]N)r   )r   r=   s     r>   r   ?javascript_identifier_path_to_array_notation.<locals>.<genexpr>  s      M_R,Q/03_s   r)   )r   r   )r\   s    r>   ,javascript_identifier_path_to_array_notationr     s    77MTZZ_MMMrP   c                 ^    U R                  5       n[        U[        5      (       d   S5       eU$ )z=Return the root element of the tree and assert it's a Figure.z8You cannot render this Element if it is not in a Figure.)get_rootr+   r   )rM   figures     r>   get_and_assert_figure_rootr     s:    \\^F  BAB  MrP   c                   6    \ rS rSrSrS\\S 4   4S jrS rSr	g)JsCodei  zWrapper around Javascript code.js_codec                 ^    [        U[        5      (       a  UR                  U l        g Xl        g r   )r+   r   r   )selfr   s     r>   __init__JsCode.__init__  s    gv&& 'DL"LrP   c                     U R                   $ r   r   )r   s    r>   __str__JsCode.__str__  s    ||rP   r  N)
rd   
__module____qualname____firstlineno____doc__r   rY   r   r  __static_attributes__ rP   r>   r   r     s    )#c8m 4 #rP   r   r   c                     [        U [        [        45      (       a  U  S3$ U SS S:w  a  U SS S;  a  [        S5      eU $ )z,Parse a font size value, if number set as pxpxNrem)emr  z2The font size must be expressed in rem, em, or px.)r+   r   r8   r6   )r   s    r>   parse_font_sizer    sK    %#u&&|bc
e%*L"@MNNLrP   )Nr|   )r|   N)F)[r`   r   r~   re   r9   r[   r   r   r   
contextlibr   typingr   r   r   r   r   r	   r
   r   r   r   r   r   r   urllib.parser   r   r   r   numpyr,   branca.elementr   r   r   branca.utilitiesr   r   r   r   r   pandasr.   ImportErrorr   r   r8   TypeLineTypeMultiLinerY   booldictTypeJsonValueNoNoneTypeJsonValueTypePathOptions
TypeBoundsTypeBoundsReturnTypeContainerTypePositionsetrq   discardaddr?   rE   rI   rL   rG   rn   rZ   r   r-   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r
  rP   r>   <module>r(     s-        	 	   %    K J  / /   HUO$h 223Ch<= )4/0c5$./huo&
Xe_-. fc7*+IJ -+-;<   B   *& *&DK *&Z0- 0D 0G( GtDK/@ G>>
4Ud4U#4556> 	s 	s 	 $()")"x )" )" 		)"X    $	?
?eUl#? ? 	?
 ZZ?D*S *XeE3J&78 *B  
$x
 4N* N1A N
Y# 
Y# 
Y.3 .c .d .   
 S 
 Xc] 
  
 W  7  ' XM Xd38K3K.L X
N= NT#7J2J-K N
,3 ,3 ,
$s $s $Ns Ns N
G  
 
5c51 c }  	Bs   2I I'&I'