
    =h5:              
          % S 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	J
r
JrJrJrJrJr  SSKJrJr   SSKr\R,                  (       a  SSKJr  \R2                  R5                  \R2                  R7                  \5      5      r\\S'   \\ \!\\\!\4   4   r"S\4S jr# S$S	\\!   S
\ S\\\!\4      4S jjr$S\\   S\ S\\   4S jr%S%S\S\ S\\   4S jjr&  S&S\	S\S\
S4   S\S\4S jjr'  S'S\	S\S\S\
S4   S\(4S jjr)S\S\4S jr*S\"S\\!\4   4S jr+S r,S r-S\\!   S \\!   S\\!   4S! jr.S\\!   S \\!   S\\!   4S" jr/S\\\4   S\04S# jr1g! \ a    Sr GN,f = f)(zA
Utilities
-------

Utility module for Folium helper functions.

    N)AnyCallableListOptionalSequenceTupleUnionEnvironmentPackageLoaderColorMaprootpathreturnc                  (    [        [        SS5      S9$ )zGet Jinja templates.branca	templates)loaderr
        cC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\branca/utilities.pyget_templatesr   $   s    mHkBCCr   legend_values
max_labelsc                     [        U 5      U:  a  [        U 5      nU$ [        [        R                  " [        U 5      U-  5      5      n/ nU SSU2    H  nX$/-  nUS/US-
  -  -  nM     U$ )z
Downsamples the number of legend values so that there isn't a collision
of text on the legend colorbar (within reason). The colorbar seems to
support ~10 entries as a maximum.

N    )lenlistintmathceil)r   r   legend_ticksspaceris        r   legend_scalerr&   )   s     =J&M*  TYYs=1J>?@xx(ACLRDFQJ//L ) r   hexListnColorsc           
         S n/ n[        U SS U SS 5       Hl  u  pESn[        U5       HV  nU" USS USS Xg5      nU" USS USS Xg5      n	U" USS USS Xg5      n
UR                  S	R                  S
XU
/5      5        MX     Mn     / n[        U5       HA  n[	        U5      US-
  -  n[        U[        U5      S-
  -  5      nUR                  X7   5        MC     U$ )z
Given a list of hexcode values, will return a list of length
nColors where the colors are linearly interpolated between the
(r, g, b) tuples that are given.
c                     Sn[        U5      US-
  -  n[        X5      [        X5      -
  n[        [        [        X5      XV-  -   5      5      R                  S5      S   n[	        U5      S:w  a  SU-   nU$ )zx
Return the value correct value of a number that is in between start
and finish, for use in a loop of length *length*.

   r   x   0)floatr    hexsplitr   )startfinishlengthr%   basefractionrayngethexs           r   _scalelinear_gradient.<locals>._scaleF   st     8vz*V"S%553s5'(*;;<=CCCHLt9>:Dr   Nr-   r   i           r   #)ziprangeappendjoinr0   r    r   )r'   r(   r:   	allColorsr3   endnInterpolateindexrgbresultcounterr7   s                 r   linear_gradientrM   ?   s    I'#2,4
 <(EuQqz3q8\AAuQqz3q8\AAuQqz3q8\AARWWc1^45	 )	 5 F>>Wq[1HI 234i&' " Mr   
color_codenc                    SnSn[        U[        5      (       d  [        S[        U5      -  5      eX:  a  [	        S5      eX:  a  [	        S5      e[        U [
        5      (       d  [	        S[        U 5       S35      eU SS	 S
:X  a(  U S	S nUS-   [        U5      R                  S5      -   nSnO$U nUS-   [        U5      R                  S5      -   nSn[        [        R                  R                  [        S5      5       n[        R                  " UR                  5       5      nS	S	S	5        [        [        R                  R                  [        S5      5       n[        R                  " UR                  5       5      n	S	S	S	5        [        [        R                  R                  [        S5      5       n[        R                  " UR                  5       5      S   n
S	S	S	5        UW
;  a  [	        US-   5      eSnWR                  U5      c  SnU(       GdP  W	U   S:X  a  / nU H:  nUS-   U;   d  M  UR!                  [        UR#                  S5      S   5      5        M<     [	        SU-   S-   [        [%        U5      5      -   S-   [        ['        U5      5      -   5      eUnSnUR)                  5        Hg  nSU;  a  M  UR#                  S5      S   U:w  a  M%  [        UR#                  S5      S   5      U:  d  MH  Un[        UR#                  S5      S   5      nMi     U(       d  [+        UR                  U5      U5      nU$ [+        UR                  U5      S	S	S2   U5      n U$ U(       d  UR                  US	5      nU$ UR                  US	5      S	S	S2   nU$ ! , (       d  f       GN}= f! , (       d  f       GN5= f! , (       d  f       GN= f)z{
Generate a colorbrewer color scheme of length 'len', type 'scheme.
Live examples can be seen at http://colorbrewer2.org/

   r<   zn has to be an int, not a %szLThe maximum number of colors in a ColorBrewer sequential color series is 253zJThe minimum number of colors in a ColorBrewer sequential color series is 3z color should be a string, not a .N_r_r.   TFz_schemes.jsonzscheme_info.jsonzscheme_base_codes.jsoncodesz  is not a valid ColorBrewer codeQualitativer   zgExpanded color support is not available for Qualitative schemes; restrict the number of colors for the z code to between z and r   r-   )
isinstancer    	TypeErrortype
ValueErrorstrzfillopenospathrC   r   jsonloadsreadgetrB   r2   minmaxkeysrM   )rN   rO   	maximum_n	minimum_n	base_codecore_color_codecolor_reversefschemesscheme_infocore_schemesexplicit_schemematching_qualskeylongest_scheme_namelongest_scheme_nsn_namecolor_schemes                     r   color_brewerrx   j   s    IIa6a@AA 	}:
 	
 	}8
 	

 j#&&;D<L;MQOPP"#$sO	#c/CFLLO;	#c/CFLLO;	bggll8_5	6!**QVVX& 
7 
bggll8%78	9Qjj* 
: 
bggll8%=>	?1zz!&&(+G4 
@ $%GGHHO{{?#+ y!]2Ns?c)"))#ciinQ.?*@A  -  &	&
 c.)*+  c.)*+	 	 #, "<<>g%==%a(I5w}}S)!,-0@@*1''*7==+=a+@'A$ * !.w{{;N/OQRS   /KK 34TrT:  	 ";;=L  #;;=ddCLw 
7	6 
:	9 
@	?s$    %N%N-4(N?
N*-
N<?
Oimagecolormapr   originc                    [        U S5      (       a  [        U S5      (       a-  U R                  R                  5       R                  S5      S   nOSnSR	                  U[
        R                  " U R                  5       5      R                  S5      5      nO[        U [        5      (       dY  [        U [        5      (       dD  [        U S5      (       a3  [        XUS	9nS
[
        R                  " U5      R                  S5      -   nO*[        R                  " [        R                  " U 5      5      nUR!                  SS5      $ )a;  Infers the type of an image argument and transforms it into a URL.

Parameters
----------
image: string, file or array-like object
    * If string, it will be written directly in the output file.
    * If file, it's content will be converted as embedded in the
      output file.
    * If array-like, it will be converted to PNG base64 string and
      embedded in the output.
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 : ColorMap or 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.  Hint : you can use colormaps from `matplotlib.cm`.
rc   namerR   r-   pngzdata:image/{};base64,{}zutf-8__iter__)r{   rz   zdata:image/png;base64,
 )hasattrr}   lowerr2   formatbase64	b64encoderc   decoderX   r\   bytes	write_pngra   rb   dumpsreplace)ry   rz   r{   
fileformaturlr~   s         r   image_to_urlr      s    0 uf5&!!))+11#6r:JJ'..UZZ\*11':
 %%%E5)A)AI I
 x@&)9)9#)>)E)Eg)NN jjE*+;;tS!!r   datac                 f   SSK Jn  [        c  [        S5      e[	        X#5      (       a  UR
                  nO[        U5      (       a  UnOS n[        R                  " U 5      nUR                  u  pgnUS;  a  [        S5      eUR                  XgU4:X  d   eUS:X  ai  [        R                  " [        [        XER                  5       5      5      5      nUR                  S   nUS	;  a  [        S
5      eUR                  XgU45      nUR                  XgU4:X  d   eUS:X  a/  [        R                  " U[        R                   " XgS45      4SS9nSnUR                  XgU4:X  d   eUS:X  d   eUR"                  S:w  am  [        R$                  " SSS9   US-  UR'                  SS9R                  S5      -  nSU[        R(                  " U5      ) '   SSS5        UR+                  S5      nUS:X  a  USSS2SS2SS24   nSR-                  [/        U5       V	s/ s H  n	SXYSS2SS24   R1                  5       -   PM!     sn	5      n
S nSR-                  SU" S[2        R4                  " SXvSSSSS5      5      U" S[6        R8                  " U
S 5      5      U" S!S5      /5      $ ! , (       d  f       N= fs  sn	f )"a  
Transform an array of data into a PNG string.
This can be written to disk using binary I/O, or encoded using base64
for an inline PNG like this:

>>> png_str = write_png(array)
>>> "data:image/png;base64," + png_str.encode("base64")

Inspired from
http://stackoverflow.com/questions/902761/saving-a-numpy-array-as-an-image

Parameters
----------
data: numpy array or equivalent list-like object.
     Must be NxM (mono), NxMx3 (RGB) or NxMx4 (RGBA)
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 : ColorMap subclass or callable, optional
    Only needed to transform mono images into RGB. You have three options:
    - use a subclass of `ColorMap` like `LinearColorMap`
    - use a colormap from `matplotlib.cm`
    - use a custom function of the form [x -> (r,g,b)] or [x -> (r,g,b,a)].
      It must output iterables of length 3 or 4 with values between 0 and 1.

Returns
-------
PNG formatted byte string
r   r   Nz4The NumPy package is required for this functionalityc                     X U S4$ )Nr   r   r,   s    r   <lambda>write_png.<locals>.<lambda>(  s
    qQlr   )r   r<      z5Data must be NxM (mono), NxMx3 (RGB), or NxMx4 (RGBA)r   )r<   r   z9colormap must provide colors oflength 3 (RGB) or 4 (RGBA)r<   r.   )axisr   uint8ignore)divideinvalidg     o@)r   r   )r   r   r   r   r-   r       c                     X-   n[         R                  " S[        U5      5      U-   [         R                  " SS[        R                  " U5      -  5      -   $ )Nz!Il    )structpackr   zlibcrc32)png_tagr   
chunk_heads      r   png_packwrite_png.<locals>.png_packO  sJ    ^
KKc$i(kk$
TZZ
-C CDE	
r   s   PNG

s   IHDRz!2I5B      s   IDAT	   s   IEND)branca.colormapr   npImportErrorrX   rgba_floats_tuplecallable
atleast_3dshaper[   arrayr   mapravelreshapeconcatenateonesdtypeerrstaterf   isfiniteastyperC   rA   tobytesr   r   r   compress)r   r{   rz   r   colormap_callabler   heightwidthnblayersr%   raw_datar   s               r   r   r      s   D )	zSTT(%%$66	(		$2MM$E#kkF8y STT;;6(33331}c"3[[]CDE;;q>6!N  vh78;;6(33331}rwwq/A'BC!L;;6(3333q== {{g[[(;EMEII6I$:$B$B9$MME)*E2;;u%%& < W% ddAqj! xxU6]S]5Aq>#9#9#;;]STH
 88 Wfkk'5!Q1aPQWdmmHa89Wc"		
 ) <; Ts   ?J&J.
J+outc           
      (   SR                  [        [        U 5      5       VVs/ s H  u  pU[        U 5      S-
  :  aB  UR	                  5       (       a-  XS-      R                  5       (       a  SUR                  5       -   OcU[        U 5      S-
  :  aB  UR                  5       (       a-  XS-      R	                  5       (       a  UR                  5       S-   OUR                  5       PM     snn5      R                  S5      R                  SS5      $ s  snnf )Nr   r   rU   __)	rC   	enumerater   r   isupperislowerr   lstripr   )r   r%   r,   s      r   	_camelifyr   a  s     GG !*$s) 4 !5 s3x!|+		E
@R@R@T@T aggi  !3s8a</AIIKKCAJDVDVDXDX GGIO!" !5 
	s	%s   CD
valuec                 &   [        U [        [        45      (       a  [        U 5      S4$ [        U [        5      (       ag  [        R
                  " SU R                  5       5      nU(       a+  [        UR                  S5      5      UR                  S5      4$ [        SU < S35      e[        U [        5      (       aI  [        U S   [        [        45      (       a+  [        U S   [        5      (       a  [        U S   5      U S   4$ [        SU < S35      e)	Npxz([\d.]+)\s?(\w{1,5}|%)r   r.   zCannot parse z+, it should be a number followed by a unit.r   zC, it should be a number or a string containing a number and a unit.)rX   r    r0   r\   re	fullmatchstripgroupr[   tuplerY   )r   matchs     r   _parse_sizer   x  s    %#u&&U|T!!	E3		 6FQ(%++a.88y(ST  	5%  uQx#u..uQx%% eAhq**E9$gh
 	
r   c                     [        U S5      (       a>  [        U S   S5      (       a  [        [        [        U 5      5      $ [        U SSS2   5      $ U $ )zMirrors the points in a list-of-list-of-...-of-list-of-points.
For example:
>>> _locations_mirror([[[1, 2], [3, 4]], [5, 6], [7, 8]])
[[[2, 1], [4, 3]], [6, 5], [8, 7]]

r   r   Nr-   )r   r   r   _locations_mirrorr   s    r   r   r     sL     q*1Q4$$-q122$B$= r   c                 Z    [        U S5      (       a  [        [        [        U 5      5      $ U $ )z?Transforms recursively a list of iterables into a list of list.r   )r   r   r   _locations_tolistr   s    r   r   r     s'    q*C)1-..r   r,   yc                 ,    U c  U$ Uc  U $ [        X5      $ N)re   r,   r   s     r   none_minr          y	
1yr   c                 ,    U c  U$ Uc  U $ [        X5      $ r   )rf   r   s     r   none_maxr     r   r   c                     [        U [        [        45      (       aN  [        U 5      (       a<  [        U S   [        [        45      (       a  / nU  H  nU[	        U5      -  nM     U$ U /$ / $ [        SU < S35      e)zIterates over a list representing a feature, and returns a list of points,
whatever the shape of the array (Point, MultiPolyline, etc).
r   zList/tuple type expected. Got rR   )rX   r   r   r   iter_pointsr[   )r,   r   r   s      r   r   r     sv     !dE]##q66!A$u..A;q>)C 
s
I9!a@AAr   )
   )r   )Nupper)r   N)2__doc__r   ra   r!   r_   r   r   typingr   r   r   r   r   r   r   r	   jinja2r   r   numpyr   r   TYPE_CHECKINGr   r   r`   abspathdirname__file__r   r\   __annotations__r    r0   TypeParseSizer   r&   rM   rx   r   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>r      sP      	 	    H H H - 
(  9:# : c5#uUCZ'889D{ D E? 
%s

,(T#Y ( (c (V^S ^S ^c ^F 37."."J$./." ." 		."f 26b
bb J$./b 	bJ3 3 .
} 
ucz): 
4  HUO   HUO  B5u% B$ BK  	Bs   E$ $E0/E0