
    Dh&                       S 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JrJrJr  SSK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JrJr  SSKJ r   SSK!J"r"  SSK#J$r$  SS	K%J&r&J'r'J(r(J)r)J*r*J+r+J,r,  SS
K-J.r.  SSK/J0r0J1r1J2r2J3r3J4r4J5r5J6r6J7r7J8r8J9r9J:r:J;r;J<r<J=r=J>r>J?r?J@r@  SSKAJBrBJCrCJDrDJErE   " S S\"\*5      rF " S S\"5      rG " S S\5      rH " S S\)5      rI\\J\\J\
\\J\K4      4   4   rL " S S5      rM " S S\"\)5      rN " S S\5      rO " S S\O5      rP " S S\O5      rQ " S S \'5      rR " S! S"\5      rS " S# S$\5      rT " S% S&\5      rU " S' S(\5      rV " S) S*\(5      rW " S+ S,\'5      rX " S- S.\"\&5      rYg)/z.
Leaflet GeoJson and miscellaneous features.

    N)
AnyCallableDictIterableListOptionalSequenceTupleUnionget_args)ColorMapLinearColormapStepColormap)DivElementFigureHtmlIFrameJavascriptLinkMacroElement)color_brewer)
JSCSSMixin)Map)ClassFeatureGroupIconLayerMarkerPopupTooltip)Template)JsCodeTypeBoundsReturnTypeContainerTypeJsonValueTypeLineTypePathOptionsTypePosition_parse_sizeescape_backticks
get_boundsget_obj_in_upper_treeimage_to_url,javascript_identifier_path_to_array_notationnone_maxnone_minremove_emptyvalidate_locations)CircleCircleMarkerPolyLinepath_optionsc                      ^  \ rS rSrSr\" S5      rS/r     SS\\	   S\
S\
S	\
S
\\\S4   S\\\S4   S\4U 4S jjjrSrU =r$ )RegularPolygonMarker?   aw  
Custom markers using the Leaflet Data Vis Framework.

Parameters
----------
location: tuple or list
    Latitude and Longitude of Marker (Northing, Easting)
number_of_sides: int, default 4
    Number of polygon sides
rotation: int, default 0
    Rotation angle in degrees
radius: int, default 15
    Marker radius, in pixels
popup: string or Popup, optional
    Input text or visualization for object displayed when clicking.
tooltip: str or folium.Tooltip, optional
    Display a text when hovering over the object.
**kwargs:
    See vector layers path_options for additional arguments.

https://humangeo.github.io/leaflet-dvf/

a  
        {% macro script(this, kwargs) %}
            var {{ this.get_name() }} = new L.RegularPolygonMarker(
                {{ this.location|tojson }},
                {{ this.options|tojavascript }}
            ).addTo({{ this._parent.get_name() }});
        {% endmacro %}
        )dvf_jszShttps://cdnjs.cloudflare.com/ajax/libs/leaflet-dvf/0.3.0/leaflet-dvf.markers.min.jsNlocationnumber_of_sidesrotationradiuspopuptooltipkwargsc                    > [         TU ]  XUS9  SU l        [        SSUS.UD6U l        U R                  R                  [        UUS95        g )N)r?   r@   r8   F)liner>   )r<   r=    )super__init___namer6   optionsupdatedict)	selfr;   r<   r=   r>   r?   r@   rA   	__class__s	           bC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\folium/features.pyrF   RegularPolygonMarker.__init__j   sT     	@+
#HvHH /!	
    rG   rH   )   r      NN)__name__
__module____qualname____firstlineno____doc__r!   	_template
default_jsr	   floatintr   r   strr    r'   rF   __static_attributes____classcell__rL   s   @rM   r8   r8   ?   s    0 		I	
J  !)--1
5/
 
 	

 
 UC%&
 wT)*
 "
 
rO   r8   c                      ^  \ rS rSrSr\" S5      r/ SQr     SS\S\	\
\S4   S\	\
\S4   S	\	\
\4   S
\	\
\4   S\4U 4S jjjrU 4S jrSrU =r$ )Vega   a  
Creates a Vega chart element.

Parameters
----------
data: JSON-like str or object
    The Vega description of the chart.
    It can also be any object that has a method `to_json`,
    so that you can (for instance) provide a `vincent` chart.
width: int or str, default None
    The width of the output element.
    If None, either data['width'] (if available) or '100%' will be used.
    Ex: 120, '120px', '80%'
height: int or str, default None
    The height of the output element.
    If None, either data['width'] (if available) or '100%' will be used.
    Ex: 120, '120px', '80%'
left: int or str, default '0%'
    The horizontal distance of the output with respect to the parent
    HTML object. Ex: 120, '120px', '80%'
top: int or str, default '0%'
    The vertical distance of the output with respect to the parent
    HTML object. Ex: 120, '120px', '80%'
position: str, default 'relative'
    The `position` argument that the CSS shall contain.
    Ex: 'relative', 'absolute'

 ))d3z9https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js)vegaz=https://cdnjs.cloudflare.com/ajax/libs/vega/1.4.3/vega.min.js)jqueryz+https://code.jquery.com/jquery-3.7.1.min.jsNdatawidthheightlefttoppositionc                   > [         TU ]  5         SU l        [        US5      (       a  UR	                  5       OUU l        [        U R
                  [        5      (       a%  [        R                  " U R
                  5      U l        [        Uc  U R
                  R                  SS5      OU5      U l        [        Uc  U R
                  R                  SS5      OU5      U l        [        U5      U l        [        U5      U l        X`l        g )Nra   to_jsonrh   100%ri   )rE   rF   rG   hasattrrn   rg   
isinstancer\   jsonloadsr)   getrh   ri   rj   rk   rl   rK   rg   rh   ri   rj   rk   rl   rL   s          rM   rF   Vega.__init__   s     	
&-dI&>&>DLLND	dii%%

499-DI !.3mDIIMM'6*

 "/5~DIIMM(F+6
  %	s# rO   c           	        > [         TU ]  " S0 UD6  [        R                  " U R                  5      U l        U R
                  R                  R                  [        [        S5      R                  XS95      U R                  5       S9  U R
                  R                  R                  [        [        S5      R                  U S95      U R                  5       S9  U R                  5       n[        U[        5      (       d   S5       eUR                  R                  [        [        S5      R                  " SSU 0UD65      U R                  5       S9  UR                  R                  [        S	5      S
S9  g)/Renders the HTML representation of the element.>
            <div id="{{this.get_name()}}"></div>
            thisrA   namezH
            vega_parse({{this.json}},{{this.get_name()}});
            r{   8You cannot render this Element if it is not in a Figure.b  
            <style> #{{this.get_name()}} {
                position : {{this.position}};
                width : {{this.width[0]}}{{this.width[1]}};
                height: {{this.height[0]}}{{this.height[1]}};
                left: {{this.left[0]}}{{this.left[1]}};
                top: {{this.top[0]}}{{this.top[1]}};
            </style>
            r{   zqfunction vega_parse(spec, div) {
            vg.parse.spec(spec, function(chart) { chart({el:div}).update(); });}
vega_parseNrD   )rE   renderrr   dumpsrg   _parenthtml	add_childr   r!   get_namescriptget_rootrq   r   header)rK   rA   figurerL   s      rM   r   Vega.render   s{     JJtyy)	## &d&2  	$ 		
 	%% &d&#  	& 		
 F
 
 	FE	F 
 	
 &
 
. #
. '-
.  	  	
" 	T  	  	
rO   rG   rg   ri   rr   rj   rl   rk   rh   NN0%r   relative)rS   rT   rU   rV   rW   r!   rX   rY   r   r   r[   r\   rF   r   r]   r^   r_   s   @rM   ra   ra      s    : IJ (,(, $#"!! S#t^$! c3n%	!
 CHo! 38_! ! !48
 8
rO   ra   c                   6  ^  \ rS rSrSr\" S5      r     SS\S\\	\
S4   S\\	\
S4   S\\	\
4   S	\\	\
4   S
\
4U 4S jjjrS r\S\\	   4S j5       rS\S\SS4S jrS\S\SS4S jrS\S\SS4S jrS\S\SS4S jrS\SS4S jrS\S\SS4S jrSrU =r$ )VegaLite   a  
Creates a Vega-Lite chart element.

Parameters
----------
data: JSON-like str or object
    The Vega-Lite description of the chart.
    It can also be any object that has a method `to_json`,
    so that you can (for instance) provide an `Altair` chart.
width: int or str, default None
    The width of the output element.
    If None, either data['width'] (if available) or '100%' will be used.
    Ex: 120, '120px', '80%'
height: int or str, default None
    The height of the output element.
    If None, either data['width'] (if available) or '100%' will be used.
    Ex: 120, '120px', '80%'
left: int or str, default '0%'
    The horizontal distance of the output with respect to the parent
    HTML object. Ex: 120, '120px', '80%'
top: int or str, default '0%'
    The vertical distance of the output with respect to the parent
    HTML object. Ex: 120, '120px', '80%'
position: str, default 'relative'
    The `position` argument that the CSS shall contain.
    Ex: 'relative', 'absolute'

rc   Nrg   rh   ri   rj   rk   rl   c                 n  > [         U R                  U ]  5         SU l        [	        US5      (       a  UR                  5       OUU l        [        U R                  [        5      (       a%  [        R                  " U R                  5      U l        [        R                  " U R                  5      U l	        [        Uc  U R                  R                  SS5      OU5      U l        [        Uc  U R                  R                  SS5      OU5      U l        [        U5      U l        [        U5      U l        X`l        g )Nr   rn   rh   ro   ri   )rE   rL   rF   rG   rp   rn   rg   rq   r\   rr   rs   r   r)   rt   rh   ri   rj   rk   rl   ru   s          rM   rF   VegaLite.__init__  s     	dnnd,.
&-dI&>&>DLLND	dii%%

499-DIJJtyy)	 !.3mDIIMM'6*

 "/5~DIIMM(F+6
  %	s# rO   c           	         U R                   n[        U[        [        [        45      (       d  [        S5      eUR                  R                  [        [        S5      R                  XS95      U R                  5       S9  U R                  5       n[        U[        5      (       d   S5       eUR                  R                  [        [        S5      R                  " SSU 0UD65      U R                  5       S9  U R                  U R                  U R                   U R"                  U R$                  S.nUR'                  U R(                  U R                  5      nU" X2S	9  g
)rx   z>VegaLite elements can only be added to a Figure, Div, or Popupry   rz   r|   r   r   r{   )         rQ      )r   parentNrD   )r   rq   r   r   r   	TypeErrorr   r   r   r!   r   r   r   r   _embed_vegalite_v1_embed_vegalite_v2_embed_vegalite_v3_embed_vegalite_v4_embed_vegalite_v5rt   vegalite_major_version)rK   rA   r   r   embed_mappingembed_vegalites         rM   r   VegaLite.render6  sj   &63"677P  	 &d&2  	 		
 F
 
 	FE	F 
 	
 &
 
. #
. '-
.  	  	
$ &&&&&&&&&&8
 '**'')@)@
 	f4rO   returnc                     SU R                   ;  a  g U R                   S   n[        UR                  S5      S   R                  S5      S   R                  S5      5      $ )Nz$schema/.r   v)rg   r[   splitlstrip)rK   schemas     rM   r   VegaLite.vegalite_major_versionm  sS    DII%9%6<<$R(..s3A6==cBCCrO   r   r   c                     U R                  US9  UR                  R                  [        S5      SS9  UR                  R                  [        S5      SS9  UR                  R                  [        S5      SS9  g )	Nr   $https://cdn.jsdelivr.net/npm//vega@5re   r|   z(https://cdn.jsdelivr.net/npm/vega-lite@5	vega-lite)https://cdn.jsdelivr.net/npm/vega-embed@6
vega-embed_vega_embedr   r   r   rK   r   r   s      rM   r   VegaLite._embed_vegalite_v5v  ~    'AB 	  	
 	EF[ 	  	
 	FG 	  	
rO   c                     U R                  US9  UR                  R                  [        S5      SS9  UR                  R                  [        S5      SS9  UR                  R                  [        S5      SS9  g )	Nr   r   re   r|   z(https://cdn.jsdelivr.net/npm/vega-lite@4r   r   r   r   r   s      rM   r   VegaLite._embed_vegalite_v4  r   rO   c                     U R                  US9  UR                  R                  [        S5      SS9  UR                  R                  [        S5      SS9  UR                  R                  [        S5      SS9  g )	Nr   z#https://cdn.jsdelivr.net/npm/vega@4re   r|   z(https://cdn.jsdelivr.net/npm/vega-lite@3r   )https://cdn.jsdelivr.net/npm/vega-embed@3r   r   r   s      rM   r   VegaLite._embed_vegalite_v3  ~    '@A 	  	
 	EF[ 	  	
 	FG 	  	
rO   c                     U R                  US9  UR                  R                  [        S5      SS9  UR                  R                  [        S5      SS9  UR                  R                  [        S5      SS9  g )	Nr   z#https://cdn.jsdelivr.net/npm/vega@3re   r|   z(https://cdn.jsdelivr.net/npm/vega-lite@2r   r   r   r   r   s      rM   r   VegaLite._embed_vegalite_v2  r   rO   c                     UR                   R                  [        [        S5      R	                  U S95      U R                  5       S9  g )Nz
                    vegaEmbed({{this.get_name()}}, {{this.json}})
                        .then(function(result) {})
                        .catch(console.error);
                r~   r|   )r   r   r   r!   r   r   )rK   r   s     rM   r   VegaLite._vega_embed  sG     &d&#  	  	
rO   c                    UR                   R                  [        [        S5      R	                  U S95      U R                  5       S9  UR                  R                  [        S5      SS9  UR                  R                  [        S5      SS9  UR                  R                  [        S5      S	S9  UR                  R                  [        S
5      SS9  g )Na-  
                    var embedSpec = {
                        mode: "vega-lite",
                        spec: {{this.json}}
                    };
                    vg.embed(
                        {{this.get_name()}}, embedSpec, function(error, result) {}
                    );
                r~   r|   zhttps://d3js.org/d3.v3.min.jsrd   z9https://cdnjs.cloudflare.com/ajax/libs/vega/2.6.5/vega.jsre   zChttps://cdnjs.cloudflare.com/ajax/libs/vega-lite/1.3.1/vega-lite.jsr   zEhttps://cdnjs.cloudflare.com/ajax/libs/vega-embed/2.2.0/vega-embed.jsr   )r   r   r   r!   r   r   r   r   r   s      rM   r   VegaLite._embed_vegalite_v1  s    
 &d&#  	  	
" 	:;$ 	  	
 	VW 	  	
 	U 	 	  	
 	W 	 	  	
rO   r   r   )rS   rT   rU   rV   rW   r!   rX   r   r   r[   r\   rF   r   propertyr   r   r   r$   r   r   r   r   r   r   r]   r^   r_   s   @rM   r   r      sP   : I
 (,(, $#"!! S#t^$! c3n%	!
 CHo! 38_! ! !855n D D D
 
 
4 

 
 
4 

 
 
4 

 
 
4 

- 
D 
$
 $
 $
4 $
 $
rO   r   c            #       ^  ^  \ rS rSrSr\" S5      r              S#S\S\\	   S\\	   S\
S	\\   S
\
S\
S\
S\\   S\\\SS4   S\
S\S   S\
S\\   S\\\\S4   S\4 U 4S jjjrS\S\4S jrS\S\4S jrS$S jrS\	S	\SS4S jrS\4S jrS\\\\         4S  jrU 4S! jrS"rU =r$ )%GeoJsoni  aC  
Creates a GeoJson object for plotting into a Map.

Parameters
----------
data: file, dict or str.
    The GeoJSON data you want to plot.
    * If file, then data will be read in the file and fully
    embedded in Leaflet's JavaScript.
    * If dict, then data will be converted to JSON and embedded
    in the JavaScript.
    * If str, then data will be passed to the JavaScript as-is.
    * If `__geo_interface__` is available, the `__geo_interface__`
    dictionary will be serialized to JSON and
    reprojected if `to_crs` is available.

style_function: function, default None
    Function mapping a GeoJson Feature to a style dict.
highlight_function: function, default None
    Function mapping a GeoJson Feature to a style dict for mouse events.
popup_keep_highlighted: bool, default False
    Whether to keep the highlighting active while the popup is open
name : string, default None
    The name of the Layer, as it will appear in LayerControls
overlay : bool, default True
    Adds the layer as an optional overlay (True) or the base layer (False).
control : bool, default True
    Whether the Layer will be included in LayerControls
show: bool, default True
    Whether the layer will be shown on opening.
smooth_factor: float, default None
    How much to simplify the polyline on each zoom level. More means
    better performance and smoother look, and less means more accurate
    representation. Leaflet defaults to 1.0.
tooltip: GeoJsonTooltip, Tooltip or str, default None
    Display a text when hovering over the object. Can utilize the data,
    see folium.GeoJsonTooltip for info on how to do that.
popup: GeoJsonPopup, optional
    Show a different popup for each feature by passing a GeoJsonPopup object.
marker: Circle, CircleMarker or Marker, optional
    If your data contains Point geometry, you can format the markers by passing a Circle,
    CircleMarker or Marker object with your wanted options. The `style_function` and
    `highlight_function` will also target the marker object you passed.
embed: bool, default True
    Whether to embed the data in the html file or not. Note that disabling
    embedding is only supported if you provide a file link or URL.
zoom_on_click: bool, default False
    Set to True to enable zooming in on a geometry when clicking on it.
on_each_feature: JsCode, optional
    Javascript code to be called on each feature.
    See https://leafletjs.com/examples/geojson/
    `onEachFeature` for more information.
**kwargs
    Keyword arguments are passed to the geoJson object as extra options.

Examples
--------
>>> # Providing filename that shall be embedded.
>>> GeoJson("foo.json")
>>> # Providing filename that shall not be embedded.
>>> GeoJson("foo.json", embed=False)
>>> # Providing dict.
>>> GeoJson(json.load(open("foo.json")))
>>> # Providing string.
>>> GeoJson(open("foo.json").read())

>>> # Provide a style_function that color all states green but Alabama.
>>> style_function = lambda x: {
...     "fillColor": (
...         "#0000ff" if x["properties"]["name"] == "Alabama" else "#00ff00"
...     )
... }
>>> GeoJson(geojson, style_function=style_function)

a  
        {% macro script(this, kwargs) %}
        {%- if this.style %}
        function {{ this.get_name() }}_styler(feature) {
            switch({{ this.feature_identifier }}) {
                {%- for style, ids_list in this.style_map.items() if not style == 'default' %}
                {% for id_val in ids_list %}case {{ id_val|tojson }}: {% endfor %}
                    return {{ style }};
                {%- endfor %}
                default:
                    return {{ this.style_map['default'] }};
            }
        }
        {%- endif %}
        {%- if this.highlight %}
        function {{ this.get_name() }}_highlighter(feature) {
            switch({{ this.feature_identifier }}) {
                {%- for style, ids_list in this.highlight_map.items() if not style == 'default' %}
                {% for id_val in ids_list %}case {{ id_val|tojson }}: {% endfor %}
                    return {{ style }};
                {%- endfor %}
                default:
                    return {{ this.highlight_map['default'] }};
            }
        }
        {%- endif %}

        {%- if this.marker %}
        function {{ this.get_name() }}_pointToLayer(feature, latlng) {
            var opts = {{ this.marker.options | tojavascript }};
            {% if this.marker._name == 'Marker' and this.marker.icon %}
            const iconOptions = {{ this.marker.icon.options | tojavascript }}
            const iconRootAlias = L{%- if this.marker.icon._name == "Icon" %}.AwesomeMarkers{%- endif %}
            opts.icon = new iconRootAlias.{{ this.marker.icon._name }}(iconOptions)
            {% endif %}
            {%- if this.style_function %}
            let style = {{ this.get_name()}}_styler(feature)
            Object.assign({%- if this.marker.icon -%}opts.icon.options{%- else -%} opts {%- endif -%}, style)
            {% endif %}
            return new L.{{this.marker._name}}(latlng, opts)
        }
        {%- endif %}

        function {{this.get_name()}}_onEachFeature(feature, layer) {
            {%- if this.on_each_feature %}
            ({{this.on_each_feature}})(feature, layer);
            {%- endif %}

            layer.on({
                {%- if this.highlight %}
                mouseout: function(e) {
                    if(typeof e.target.setStyle === "function"){
                        {%- if this.popup_keep_highlighted %}
                        if (!e.target.isPopupOpen())
                        {%- endif %}
                            {{ this.get_name() }}.resetStyle(e.target);
                    }
                },
                mouseover: function(e) {
                    if(typeof e.target.setStyle === "function"){
                        const highlightStyle = {{ this.get_name() }}_highlighter(e.target.feature)
                        e.target.setStyle(highlightStyle);
                    }
                },
                {%- if this.popup_keep_highlighted %}
                popupopen: function(e) {
                    if(typeof e.target.setStyle === "function"){
                        const highlightStyle = {{ this.get_name() }}_highlighter(e.target.feature)
                        e.target.setStyle(highlightStyle);
                        e.target.bindPopup(e.popup)
                    }
                },
                popupclose: function(e) {
                    if(typeof e.target.setStyle === "function"){
                        {{ this.get_name() }}.resetStyle(e.target);
                        e.target.unbindPopup()
                    }
                },
                {%- endif %}
                {%- endif %}
                {%- if this.zoom_on_click %}
                click: function(e) {
                    if (typeof e.target.getBounds === 'function') {
                        {{ this.parent_map.get_name() }}.fitBounds(e.target.getBounds());
                    }
                    else if (typeof e.target.getLatLng === 'function'){
                        let zoom = {{ this.parent_map.get_name() }}.getZoom()
                        zoom = zoom > 12 ? zoom : zoom + 1
                        {{ this.parent_map.get_name() }}.flyTo(e.target.getLatLng(), zoom)
                    }
                }
                {%- endif %}
            });
        };
        var {{ this.get_name() }} = L.geoJson(null, {
            {%- if this.smooth_factor is not none  %}
                smoothFactor: {{ this.smooth_factor|tojson }},
            {%- endif %}
                onEachFeature: {{ this.get_name() }}_onEachFeature,
            {% if this.style %}
                style: {{ this.get_name() }}_styler,
            {%- endif %}
            {%- if this.marker %}
                pointToLayer: {{ this.get_name() }}_pointToLayer,
            {%- endif %}
            ...{{this.options | tojavascript }}
        });

        function {{ this.get_name() }}_add (data) {
            {{ this.get_name() }}
                .addData(data);
        }
        {%- if this.embed %}
            {{ this.get_name() }}_add({{ this.data|tojson }});
        {%- else %}
            $.ajax({{ this.embed_link|tojson }}, {dataType: 'json', async: false})
                .done({{ this.get_name() }}_add);
        {%- endif %}

        {%- if not this.style %}
        {{this.get_name()}}.setStyle(function(feature) {return feature.properties.style;});
        {%- endif %}

        {% endmacro %}
        Nrg   style_functionhighlight_functionpopup_keep_highlightedr}   overlaycontrolshowsmooth_factorr@   GeoJsonTooltipembedr?   GeoJsonPopupzoom_on_clickon_each_featuremarkerrA   c                   > [         TU ]  XVXxS9  SU l        Xl        S U l        S U l        S U l        Xl        US LU l        US LU l	        Xl
        U(       a+  [        U[        [        [        45      (       d  [        S5      eU(       a  Uc  [!        S5      eX@l        Xl        Xl        [)        S0 UD6U l        U R-                  U5      U l        U R                  (       d  U R                  (       ai  U R1                  5         Ub  U R3                  US5        X l        0 U l        Ub  U R3                  US5        X0l        0 U l        U R=                  5       U l        [        U
[@        [B        45      (       a  U RE                  U
5        OU
b  U RE                  [C        U
5      5        [        U[F        [H        45      (       a  U RE                  U5        g g )Nr}   r   r   r   r   zLOnly Marker, Circle, and CircleMarker are supported as GeoJson marker types.z;A popup is needed to use the popup_keep_highlighted featurer   r   rD   )%rE   rF   rG   r   
embed_linkrr   
parent_mapr   style	highlightr   rq   r3   r4   r   r   
ValueErrorr   r   r   r1   rH   process_datarg   convert_to_feature_collection_validate_functionr   	style_mapr   highlight_mapfind_identifierfeature_identifierr   r    r   r   r   )rK   rg   r   r   r   r}   r   r   r   r   r@   r   r?   r   r   r   rA   rL   s                    rM   rF   GeoJson.__init__  s   & 	dWP

)-	*#4/
+47*fv|V&DEEb  "emM  '=#.#-f-%%d+	::..0)''8HI&4#')!-''(:<PQ*<'+-"&*&:&:&<D#g899NN7# NN77+,elE233NN5! 4rO   r   c                 $   [        U[        5      (       a	  SU l        U$ [        U[        5      (       a  UR	                  5       R                  S5      (       a(  U R                  (       d  Xl        U R                  U5      $ UR                  5       S   S;   a  SU l        [        R                  " U5      $ U R                  (       d  Xl        [        U5       n[        R                  " UR                  5       5      sSSS5        $ [        US5      (       a]  SU l        [        US5      (       a  UR                  S5      n[        R                  " [        R                  " UR                   5      5      $ [#        S	U< 35      e! , (       d  f       g= f)
z8Convert an unknown data input into a geojson dictionary.T)zhttp:zftp:zhttps:r   z[{N__geo_interface__to_crsz	EPSG:4326z3Cannot render objects with any missing geometries: )rq   rJ   r   r\   lower
startswithr   get_geojson_from_webr   rr   rs   openreadrp   r   r   r   r   )rK   rg   fs      rM   r   GeoJson.process_data  s!   dD!!DJKc""zz|&&'BCCzz&*O0066q!T)!
zz$''zz&*O$Z1::affh/  ZT.//DJtX&&{{;/::djj)?)?@AAHQ   Zs   $F
Furlc                 J    [         R                  " U5      R                  5       $ N)requestsrt   rr   )rK   r   s     rM   r   GeoJson.get_geojson_from_web  s    ||C %%''rO   c                     U R                   S   S:X  a  gU R                  (       d  [        S5      eSU R                   R                  5       ;  a  SU R                   S.U l         SU R                   /S.U l         g)	z;Convert data into a FeatureCollection if it is not already.typeFeatureCollectionNzData is not a FeatureCollection, but it should be to apply style or highlight. Because `embed=False` it cannot be converted into one.
Either change your geojson data to a FeatureCollection, set `embed=True` or disable styling.geometryFeature)r   r   )r   features)rg   r   r   keysrK   s    rM   r   %GeoJson.convert_to_feature_collection  sh    99V 33zzJ  TYY^^--!*		BDI0tyykJ	rO   funcc                     U R                   S   (       d  gU R                   S   S   n[        U5      (       a  [        U" U5      [        5      (       d  [	        U S35      eg)zp
Tests `self.style_function` and `self.highlight_function` to ensure
they are functions returning dictionaries.
r   Nr   zX should be a function that accepts items from data['features'] and returns a dictionary.)rg   callablerq   rJ   r   )rK   r   r}   test_features       rM   r   GeoJson._validate_function"  sb     yy$yy,Q/~~Z\0BD%I%I& = =  &JrO   c           
      f   U R                   S   nU Vs1 s H  o"R                  SS5      iM     nnSU;  a  [        U5      [        U5      :X  a  g[        S U 5       5      (       a  US   S    Hw  nU Vs1 s HH  n[	        US   R                  US5      [
        [        45      (       d  M3  US   R                  US5      iMJ     nn[        U5      [        U5      :X  d  Mr  SU 3s  $    U R                  (       a#  [        U5       H  u  pg[        U5      US'   M     g[        S	5      es  snf s  snf )
zFind a unique identifier for each feature, create it if needed.

According to the GeoJSON specs a feature:
 - MAY have an 'id' field with a string or numerical value.
 - MUST have a 'properties' field. The content can be any json object
   or even null.

r   idNz
feature.idc              3   b   #    U  H%  n[        UR                  S S5      [        5      v   M'     g7f)
propertiesN)rq   rt   rJ   ).0feats     rM   	<genexpr>*GeoJson.find_identifier.<locals>.<genexpr>B  s%     P%$z$((<6==%s   -/r   r  zfeature.properties.zThere is no unique identifier for each feature and because `embed=False` it cannot be added. Consider adding an `id` field to your geojson data or set `embed=True`. )
rg   rt   lenallrq   r\   r[   r   	enumerater   )rK   featsr  
unique_idskeyunique_valuesifeatures           rM   r   GeoJson.find_identifier3  s)    		*%7<=uthhtT*u
=z!c*oU&CP%PPPQx- !&! %!$|"4"8"8d"Cc3ZP 6D&**35 %  !
 }%U3066 . ::'.
 #A /?
 	
% >!s   D)62D.,D.c                 *    [        U R                  SS9$ )z
Computes the bounds of the object itself (not including it's children)
in the form [[lat_min, lon_min], [lat_max, lon_max]].

T)lonlat)r+   rg   r   s    rM   _get_self_boundsGeoJson._get_self_boundsV  s     $))D11rO   c                   > [        U [        5      U l        U R                  (       d  U R                  (       a  U R
                  S   (       a  [        U R
                  U R                  U 5      nU R                  (       a   UR                  U R                  5      U l
        U R                  (       a   UR                  U R                  5      U l        [        TU ]=  5         g )Nr   )r,   r   r   r   r   rg   GeoJsonStyleMapperr   get_style_mapr   r   get_highlight_mapr   r   rE   r   )rK   rA   mapperrL   s      rM   r   GeoJson.render^  s    /c:JJ$..dii
.C'		43J3JDQFzz!'!5!5d6I6I!J~~%+%=%=d>U>U%V"rO   )rG   rg   r   r   r   r   r   r   rr   r   r   rH   r   r   r   r   r   r   r   )NNFNTTTNNTNFNNr   N)rS   rT   rU   rV   rW   r!   rX   r   r   r   boolr\   rZ   r   r    r"   r3   r4   r   rF   rJ   r   r   r   r   r   r   r  r   r]   r^   r_   s   @rM   r   r     s   JX |	~IF .215',")-?C*.#,0<@!@"@" !*@" %X.	@"
 !%@" sm@" @" @" @"  @" sG%5t;<@" @" '@" @" "&)@"  flFD89!@"" #@" @"D  8( ( (K"x s t "!
 !
F2$tHUO'<"= 2	 	rO   r   c                       \ rS rSrSrS\S\S\4S jrS\	S\
4S	 jrS
\	S\
4S jrS\	S\S\
4S jrS\S\\\4   4S jr\S\S\4S j5       r\S\
SS4S j5       rSrg)r  im  zCCreate dicts that map styling to GeoJson features.

:meta private:
rg   r   geojson_objc                 (    Xl         X l        X0l        g r   rg   r   r"  )rK   rg   r   r"  s       rM   rF   GeoJsonStyleMapper.__init__s  s     	"4&rO   r   r   c                 &    U R                  US5      $ )z5Return a dict that maps style parameters to features.r   _create_mapping)rK   r   s     rM   r   GeoJsonStyleMapper.get_style_map}  s    ##NG<<rO   r   c                 &    U R                  US5      $ )z9Return a dict that maps highlight parameters to features.r   r'  )rK   r   s     rM   r  $GeoJsonStyleMapper.get_highlight_map  s    ##$6DDrO   r   switchc                    0 nU R                   S    H  nU" U5      nUS:X  av  UR                  5        Hb  u  pg[        U[        5      (       d  M  UR                  c!  U R
                  Ul        UR                  5         SUR                  5       -   S-   XV'   Md     U R                  U5      nU R                  U5      nUR                  U/ 5      R                  U5        M     U R                  U5        U$ )z(Internal function to create the mapping.r   r   z{{'z'}})rg   itemsrq   r   r   r"  r   r   _to_keyget_feature_id
setdefaultappend_set_default_key)	rK   r   r,  mappingr  contentr  value
feature_ids	            rM   r(  "GeoJsonStyleMapper._create_mapping  s    $&yy,G7mG ")--/JC!%66 ==0,0,<,<EM!LLN',u~~/?'?%'G #2 ,,w'C,,W5JsB'..z: - 	g&rO   r  c                     U R                   R                  S5      SS n[        R                  " [        R
                  X!5      n[        U[        [        45      (       d   eU$ )z'Return a value identifying the feature.r   r   N)	r   r   	functoolsreduceoperatorgetitemrq   r\   r[   )rK   r  fieldsr6  s       rM   r0  !GeoJsonStyleMapper.get_feature_id  sS    ((..s3AB7  !1!16C%#s,,,,rO   dc                 p    [         R                  " U SS9nUR                  SS5      R                  SS5      $ )z6Convert dict to str and enable Jinja2 template syntax.T)	sort_keysz"{{z{{z}}"z}})rr   r   replace)r@  as_strs     rM   r/  GeoJsonStyleMapper._to_key  s2     A.~~eT*225$??rO   r4  Nc                 6    [        X R                  S9nXS'   X	 g)z@Replace the field with the most features with a 'default' field.)r  defaultN)maxrt   )r4  key_longests     rM   r3  #GeoJsonStyleMapper._set_default_key  s      '{{3(	 rO   r$  )rS   rT   rU   rV   rW   rJ   r\   r   rF   r   TypeStyleMappingr  r  r(  r   r[   r0  staticmethodr/  r3  r]   rD   rO   rM   r  r  m  s    
''  ' 	'=H =9I =EH EAQ EH c >N (d uS#X  @4 @C @ @
 !"2 !t ! !rO   r  c                      ^  \ rS rSrSr\" S5      rS/r       SS\S\	S\
\   S	\
\	   S
\S\S\S\
\   S\\	\S4   4U 4S jjjrSS jrU 4S jrS\4S jrSrU =r$ )TopoJsoni  a  
Creates a TopoJson object for plotting into a Map.

Parameters
----------
data: file, dict or str.
    The TopoJSON data you want to plot.
    * If file, then data will be read in the file and fully
    embedded in Leaflet's JavaScript.
    * If dict, then data will be converted to JSON and embedded
    in the JavaScript.
    * If str, then data will be passed to the JavaScript as-is.

object_path: str
    The path of the desired object into the TopoJson structure.
    Ex: 'objects.myobject'.
style_function: function, default None
    A function mapping a TopoJson geometry to a style dict.
name : string, default None
    The name of the Layer, as it will appear in LayerControls
overlay : bool, default False
    Adds the layer as an optional overlay (True) or the base layer (False).
control : bool, default True
    Whether the Layer will be included in LayerControls.
show: bool, default True
    Whether the layer will be shown on opening.
smooth_factor: float, default None
    How much to simplify the polyline on each zoom level. More means
    better performance and smoother look, and less means more accurate
    representation. Leaflet defaults to 1.0.
tooltip: GeoJsonTooltip, Tooltip or str, default None
    Display a text when hovering over the object. Can utilize the data,
    see folium.GeoJsonTooltip for info on how to do that.

Examples
--------
>>> # Providing file that shall be embedded.
>>> TopoJson(open("foo.json"), "object.myobject")
>>> # Providing filename that shall not be embedded.
>>> TopoJson("foo.json", "object.myobject")
>>> # Providing dict.
>>> TopoJson(json.load(open("foo.json")), "object.myobject")
>>> # Providing string.
>>> TopoJson(open("foo.json").read(), "object.myobject")

>>> # Provide a style_function that color all states green but Alabama.
>>> style_function = lambda x: {
...     "fillColor": (
...         "#0000ff" if x["properties"]["name"] == "Alabama" else "#00ff00"
...     )
... }
>>> TopoJson(topo_json, "object.myobject", style_function=style_function)

a  
        {% macro script(this, kwargs) %}
            var {{ this.get_name() }}_data = {{ this.data|tojson }};
            var {{ this.get_name() }} = L.geoJson(
                topojson.feature(
                    {{ this.get_name() }}_data,
                    {{ this.get_name() }}_data{{ this._safe_object_path }}
                ),
                {
                {%- if this.smooth_factor is not none %}
                    smoothFactor: {{ this.smooth_factor|tojson }},
                {%- endif %}
                }
            ).addTo({{ this._parent.get_name() }});
            {{ this.get_name() }}.setStyle(function(feature) {
                return feature.properties.style;
            });
        {% endmacro %}
        )topojsonzEhttps://cdnjs.cloudflare.com/ajax/libs/topojson/1.6.9/topojson.min.jsNrg   object_pathr   r}   r   r   r   r   r@   c
                   > [         T
U ]  XEXgS9  SU l        S[        U5      ;   a#  SU l        [
        R                  " U5      U l        O-[        U5      [        L a  SU l        Xl        OSU l        Xl        X l
        [        U5      U l        U=(       d    S U l        Xl        [        U	[         ["        45      (       a  U R%                  U	5        g U	b  U R%                  [#        U	5      5        g g )Nr   rN  r   TFc                     0 $ r   rD   )xs    rM   <lambda>#TopoJson.__init__.<locals>.<lambda>!  s    2rO   )rE   rF   rG   dirr   rr   loadrg   r   rJ   rP  r.   _safe_object_pathr   r   rq   r   r    r   )rK   rg   rP  r   r}   r   r   r   r   r@   rL   s             rM   rF   TopoJson.__init__  s     	dWP
SYDJ		$DI$Z4DJIDJI&!M"
 ->*g899NN7# NN77+, !rO   r   c                   ^ U4S jmT" U R                   U R                  R                  S5      5      S   nU HC  nUR                  S0 5      R                  S0 5      R	                  U R                  U5      5        ME     g)z9Applies self.style_function to each feature of self.data.c                 d   > [        U5      (       a  T" U R                  US   5      USS  5      $ U $ )Nr   r   )r  rt   )rg   r   recursive_gets     rM   r\  *TopoJson.style_data.<locals>.recursive_get-  s1    4yy$TXXd1g%6QRAArO   r   
geometriesr  r   N)rg   rP  r   r1  rI   r   )rK   r^  r  r\  s      @rM   
style_dataTopoJson.style_data*  su    	 #499d.>.>.D.DS.IJ

 "G|R0;;GRHOO##G, "rO   c                 F   > U R                  5         [        TU ]  " S0 UD6  g)rx   NrD   )r_  rE   r   rK   rA   rL   s     rM   r   TopoJson.render;  s      rO   c                 f   U R                   (       d  [        S5      eSu  pp4U R                  S    HF  nSu  pgU H9  u  pXh-  nXy-  n[        Xa5      n[	        Xb5      n[        Xs5      n[	        Xt5      nM;     MH     U R                  S   S   S   U R                  S   S   S   U-  -   U R                  S   S   S	   U R                  S   S   S	   U-  -   /U R                  S   S   S   U R                  S   S   S   U-  -   U R                  S   S   S	   U R                  S   S   S	   U-  -   //$ )
z~
Computes the bounds of the object itself (not including it's children)
in the form [[lat_min, lon_min], [lat_max, lon_max]]

z/Cannot compute bounds of non-embedded TopoJSON.)NNNNarcs)r   r   	transform	translater   scaler   )r   r   rg   r0   r/   )
rK   xminxmaxyminymaxarcrS  ydxdys
             rM   r+   TopoJson.get_bounds@  sm    zzNOO!7D99V$CDA((((  % 		+&{3A6))K(1!4t;<		+&{3A6))K(1!4t;< 		+&{3A6))K(1!4t;<		+&{3A6))K(1!4t;<
 	
rO   )rG   rX  rg   r   rP  r   r   )NNTTTNNr  )rS   rT   rU   rV   rW   r!   rX   rY   r   r\   r   r   r   rZ   r   r    rF   r_  r   r#   r+   r]   r^   r_   s   @rM   rN  rN    s    5n 	I.	
J .2")--1%-%- %- !*	%-
 sm%- %- %- %-  %- sGT)*%- %-N"!
!
, !
 !
rO   rN  c                      ^  \ rS rSrSrSr     SS\\   S\\\      S\	S\	S\\   S	\4U 4S
 jjjr
SS jrU 4S jrSrU =r$ )GeoJsonDetailid  z@Base class for GeoJsonTooltip and GeoJsonPopup.

:meta private:
at  
    function(layer){
    let div = L.DomUtil.create('div');
    {% if this.fields %}
    let handleObject = feature => {
        if (feature === null) {
            return '';
        } else if (typeof(feature)=='object') {
            return JSON.stringify(feature);
        } else {
            return feature;
        }
    }
    let fields = {{ this.fields | tojson | safe }};
    let aliases = {{ this.aliases | tojson | safe }};
    let table = '<table>' +
        String(
        fields.map(
        (v,i)=>
        `<tr>{% if this.labels %}
            <th>${aliases[i]{% if this.localize %}.toLocaleString(){% endif %}}</th>
            {% endif %}
            <td>${handleObject(layer.feature.properties[v]){% if this.localize %}.toLocaleString(){% endif %}}</td>
        </tr>`).join(''))
    +'</table>';
    div.innerHTML=table;
    {% endif %}
    return div
    }
    r>  aliaseslabelslocalizer   
class_namec                   > [         TU ]  5         [        U[        [        45      (       d   S5       eUb<  [        U[        [        45      (       d   e[        U5      [        U5      :X  d   S5       e[        U[        5      (       d   S5       e[        U[        5      (       d   S5       eSU l        Xl        Ub  UOUU l	        X0l
        X@l        X`l        U(       a#  [        U[        5      (       d   S5       eXPl        g g )Nz&Please pass a list or tuple to fields.z-fields and aliases must have the same length.z labels requires a boolean value.zlocalize must be bool.rs  z8Pass a valid inline HTML style property string to style.)rE   rF   rq   listtupler  r   rG   r>  rt  ru  rv  rw  r\   r   )rK   r>  rt  ru  rv  r   rw  rL   s          rM   rF   GeoJsonDetail.__init__  s    	T5M
 
 	43	4 
 ge}5555v;##  ?>?  &$''K)KK'(D))C+CC)$
")"5w6 $s  JIJ  J rO   c                    [        U R                  [        5      (       d   e[        U R                  R                  S   5       VVs/ s HD  u  pUS   (       d  M  US   S   S:X  d  M  UR                  S5      b  UR                  S5      OUPMF     nnn[        U5      (       a,  [        R                  " U R                   SU S3[        5        ggs  snnf )	zRChecks for GeoJson GeometryCollection features to warn user about incompatibility.r   r   r   GeometryCollectionr  Nzr is not configured to render for GeoJson GeometryCollection geometries. Please consider reworking these features: zS to MultiPolygon for full functionality.
https://tools.ietf.org/html/rfc7946#page-9)rq   r   r   r  rg   rt   anywarningswarnrG   UserWarning)rK   r  r  geom_collectionss       rM   warn_for_geometry_collections+GeoJsonDetail.warn_for_geometry_collections  s    $,,0000 !*$,,*;*;J*G H
 Hz" X 
#F+/CC X\)B)NGKK%TWW H 	 
   MM::, ==M<N O== 	 !
s   C
C))Cc                   > U R                  5       n[        U R                  [        5      (       ag  [	        U R                  R
                  S   (       a-  U R                  R
                  S   S   S   R                  5       O/ 5      nU R                  5         O[        U R                  [        5      (       ae  U R                  R                  R                  S5      S   n[	        U R                  R
                  S   U   S   S   S   R                  5       5      nO[        SU R                   S	35      e[	        S
 U 5       5      nU R                   H  nXS;   a  M
   SU SU S35       e   UR                  R                  [!        [#        S5      R%                  U S95      U R'                  5       S-   S9  [(        TU ]I  5         g)rx   r   r   r  r   r   objectsr^  zYou cannot add a z5 to anything other than a GeoJson or TopoJson object.c              3   4   #    U  H  oS ;  d  M
  Uv   M     g7f))r   r   NrD   )r  rS  s     rM   r	  'GeoJsonDetail.render.<locals>.<genexpr>  s     H11G(GQQs   		z
The field z, is not available in the data. Choose from: a=  
                    <style>
                        .{{ this.class_name }} {
                            {{ this.style }}
                        }
                       .{{ this.class_name }} table{
                            margin: auto;
                        }
                        .{{ this.class_name }} tr{
                            text-align: left;
                        }
                        .{{ this.class_name }} th{
                            padding: 2px; padding-right: 8px;
                        }
                    </style>
            r~   
tablestyler|   N)r   rq   r   r   rz  rg   r   r  rN  rP  r   r   rG   r>  r   r   r   r!   r   r   rE   )rK   rA   r   r   obj_namer6  rL   s         rM   r   GeoJsonDetail.render  s   dllG,,<<$$Z0 !!*-a0>CCED
 ..0h//||//55c:2>H!!),X6|DQG $&D #DJJ< 0. .  HHH[[EWE7"NtfTUVW ! 	" &d&#%( </+ 	  	
0 	rO   )rG   rt  rw  r>  ru  rv  r   )NTFNgeojsondetailr  )rS   rT   rU   rV   rW   base_templater	   r\   r   r   rF   r  r   r]   r^   r_   s   @rM   rs  rs  d  s    
MD ,0#) (3-( 	
  }  B"3 3rO   rs  c                      ^  \ rS rSrSr\" S\R                  -   S-   5      r      SS\	\
   S\\	\
      S\S\S	\\
   S
\
S\S\4U 4S jjjrSrU =r$ )r   i  a  
Create a tooltip that uses data from either geojson or topojson.

Parameters
----------
fields: list or tuple.
    Labels of GeoJson/TopoJson 'properties' or GeoPandas GeoDataFrame
    columns you'd like to display.
aliases: list/tuple of strings, same length/order as fields, default None.
    Optional aliases you'd like to display in the tooltip as field name
    instead of the keys of `fields`.
labels: bool, default True.
    Set to False to disable displaying the field names or aliases.
localize: bool, default False.
    This will use JavaScript's .toLocaleString() to format 'clean' values
    as strings for the user's location; i.e. 1,000,000.00 comma separators,
    float truncation, etc.
    Available for most of JavaScript's primitive types (any data you'll
    serve into the template).
style: str, default None.
    HTML inline style properties like font and colors. Will be applied to
    a div with the text in it.
sticky: bool, default True
    Whether the tooltip should follow the mouse.
**kwargs: Assorted.
    These values will map directly to the Leaflet Options. More info
    available here: https://leafletjs.com/reference.html#tooltip

Examples
--------
# Provide fields and aliases, with Style.
>>> GeoJsonTooltip(
...     fields=["CNTY_NM", "census-pop-2015", "census-md-income-2015"],
...     aliases=["County", "2015 Census Population", "2015 Median Income"],
...     localize=True,
...     style=(
...         "background-color: grey; color: white; font-family:"
...         "courier new; font-size: 24px; padding: 10px;"
...     ),
... )
# Provide fields, with labels off and fixed tooltip positions.
>>> GeoJsonTooltip(fields=("CNTY_NM",), labels=False, sticky=False)
zT
    {% macro script(this, kwargs) %}
    {{ this._parent.get_name() }}.bindTooltip(zf,{{ this.tooltip_options | tojavascript }});
                     {% endmacro %}
                     r>  rt  ru  rv  r   rw  stickyrA   c           	      j   > [         T	U ]  UUUUUUS9  SU l        UR                  XvS.5        Xl        g )N)r>  rt  ru  rv  r   rw  r   )r  rw  )rE   rF   rG   rI   tooltip_options)
rK   r>  rt  ru  rv  r   rw  r  rA   rL   s
            rM   rF   GeoJsonTooltip.__init__(  sG     	! 	 	
 &
BC%rO   )rG   r  )NTFNfoliumtooltipTrS   rT   rU   rV   rW   r!   rs  r  rX   r	   r\   r   r   r%   rF   r]   r^   r_   s   @rM   r   r     s    *X 	2 
%
%	&		I ,0#)&& (3-(& 	&
 & }& & &  & &rO   r   c                      ^  \ rS rSrSr\" S\R                  -   S-   5      r     SS\	\
   S\\	\
      S\S\
S	\
S
\S\4U 4S jjjrSrU =r$ )r   i@  a{  
Create a popup feature to bind to each element of a GeoJson layer based on
its attributes.

Parameters
----------
fields: list or tuple.
    Labels of GeoJson/TopoJson 'properties' or GeoPandas GeoDataFrame
    columns you'd like to display.
aliases: list/tuple of strings, same length/order as fields, default None.
    Optional aliases you'd like to display in the tooltip as field name
    instead of the keys of `fields`.
labels: bool, default True.
    Set to False to disable displaying the field names or aliases.
localize: bool, default False.
    This will use JavaScript's .toLocaleString() to format 'clean' values
    as strings for the user's location; i.e. 1,000,000.00 comma separators,
    float truncation, etc.
    Available for most of JavaScript's primitive types (any data you'll
    serve into the template).
style: str, default None.
    HTML inline style properties like font and colors. Will be applied to
    a div with the text in it.

Examples
---
gjson = folium.GeoJson(gdf).add_to(m)

folium.features.GeoJsonPopup(fields=['NAME'],
                            labels=False
                            ).add_to(gjson)
zR
    {% macro script(this, kwargs) %}
    {{ this._parent.get_name() }}.bindPopup(zd,{{ this.popup_options | tojavascript }});
                     {% endmacro %}
                     r>  rt  ru  r   rw  rv  rA   c           	      ~   > [         TU ]  UUUUUUS9  SU l        UR                  SU R                  05        Xpl        g )N)r>  rt  ru  rv  rw  r   r   rw  )rE   rF   rG   rI   rw  popup_options)	rK   r>  rt  ru  r   rw  rv  rA   rL   s	           rM   rF   GeoJsonPopup.__init__l  sM     	! 	 	
 $
|T__56#rO   )rG   r  )NTzmargin: auto;foliumpopupTr  r_   s   @rM   r   r   @  s    B 	0 
%
%	&		I ,0$'$$ (3-($ 	$
 $ $ $  $ $rO   r   c            +       8  ^  \ rS rSrSr                    S S\S\\   S\\\      S\\   S\	\
\\   4   S	\\   S
\S\S\\   S\S\S\S\\   S\S\S\S\S\\   S\\   S\S\4*U 4S jjjr\S\	\\4   S\S\	\\S4   4S j5       rU 4S jrSrU =r$ )!
Choroplethi  a  Apply a GeoJSON overlay to the map.

Plot a GeoJSON overlay on the base map. There is no requirement
to bind data (passing just a GeoJSON plots a single-color overlay),
but there is a data binding option to map your columnar data to
different feature objects with a color scale.

If data is passed as a Pandas DataFrame, the "columns" and "key-on"
keywords must be included, the first to indicate which DataFrame
columns to use, the second to indicate the layer in the GeoJSON
on which to key the data. The 'columns' keyword does not need to be
passed for a Pandas series.

Colors are generated from color brewer (https://colorbrewer2.org/)
sequential palettes. By default, linear binning is used between
the min and the max of the values. Custom binning can be achieved
with the `bins` parameter.

TopoJSONs can be passed as "geo_data", but the "topojson" keyword must
also be passed with the reference to the topojson objects to convert.
See the topojson.feature method in the TopoJSON API reference:
https://github.com/topojson/topojson/wiki/API-Reference


Parameters
----------
geo_data: string/object
    URL, file path, or data (json, dict, geopandas, etc) to your GeoJSON
    geometries
data: Pandas DataFrame or Series, default None
    Data to bind to the GeoJSON.
columns: tuple with two values, default None
    If the data is a Pandas DataFrame, the columns of data to be bound.
    Must pass column 1 as the key, and column 2 the values.
key_on: string, default None
    Variable in the `geo_data` GeoJSON file to bind the data to. Must
    start with 'feature' and be in JavaScript objection notation.
    Ex: 'feature.id' or 'feature.properties.statename'.
bins: int or sequence of scalars or str, default 6
    If `bins` is an int, it defines the number of equal-width
    bins between the min and the max of the values.
    If `bins` is a sequence, it directly defines the bin edges.
    For more information on this parameter, have a look at
    numpy.histogram function.
fill_color: string, optional
    Area fill color, defaults to blue. Can pass a hex code, color name,
    or if you are binding data, one of the following color brewer palettes:
    'BuGn', 'BuPu', 'GnBu', 'OrRd', 'PuBu', 'PuBuGn', 'PuRd', 'RdPu',
    'YlGn', 'YlGnBu', 'YlOrBr', and 'YlOrRd'.
nan_fill_color: string, default 'black'
    Area fill color for nan or missing values.
    Can pass a hex code, color name.
fill_opacity: float, default 0.6
    Area fill opacity, range 0-1.
nan_fill_opacity: float, default fill_opacity
    Area fill opacity for nan or missing values, range 0-1.
line_color: string, default 'black'
    GeoJSON geopath line color.
line_weight: int, default 1
    GeoJSON geopath line weight.
line_opacity: float, default 1
    GeoJSON geopath line opacity, range 0-1.
legend_name: string, default empty string
    Title for data legend.
topojson: string, default None
    If using a TopoJSON, passing "objects.yourfeature" to the topojson
    keyword argument will enable conversion to GeoJSON.
smooth_factor: float, default None
    How much to simplify the polyline on each zoom level. More means
    better performance and smoother look, and less means more accurate
    representation. Leaflet defaults to 1.0.
highlight: boolean, default False
    Enable highlight functionality when hovering over a GeoJSON area.
use_jenks: bool, default False
    Use jenkspy to calculate bins using "natural breaks"
    (Fisher-Jenks algorithm). This is useful when your data is unevenly
    distributed.
name : string, optional
    The name of the layer, as it will appear in LayerControls
overlay : bool, default True
    Adds the layer as an optional overlay (True) or the base layer (False).
control : bool, default True
    Whether the Layer will be included in LayerControls.
show: bool, default True
    Whether the layer will be shown on opening.

Returns
-------
GeoJSON data layer in obj.template_vars

Examples
--------
>>> Choropleth(geo_data="us-states.json", line_color="blue", line_weight=3)
>>> Choropleth(
...     geo_data="geo.json",
...     data=df,
...     columns=["Data 1", "Data 2"],
...     key_on="feature.properties.myvalue",
...     fill_color="PuBu",
...     bins=[0, 20, 30, 40, 50, 60],
... )
>>> Choropleth(geo_data="countries.json", topojson="objects.countries")
>>> Choropleth(
...     geo_data="geo.json",
...     data=df,
...     columns=["Data 1", "Data 2"],
...     key_on="feature.properties.myvalue",
...     fill_color="PuBu",
...     bins=[0, 20, 30, 40, 50, 60],
...     highlight=True,
... )
Ngeo_datarg   columnskey_onbins
fill_colornan_fill_colorfill_opacitynan_fill_opacity
line_colorline_weightline_opacityr}   legend_namer   r   r   rO  r   r   	use_jenksc                   >^ ^^^^^	^
^^^ ^!^"^# [         T$T ]  XUUS9  ST l        T=(       d    Uc  SOSmUb  [        T5      (       d  [	        S5      eT	c  Tm	SU;   a&  US   b  US   n[
        R                  " S[        5        [        US5      (       a.  Uc   eUR                  US	   5      US
      R                  5       m!O7[        US5      (       a  UR                  5       m!OU(       a  [        U5      m!OS m!S T l        T!Gb  TGb  [        R                  " [        T!R!                  5       5      5      nU[        R"                  " U5      )    nU(       aK  S	SKJn  [)        U[*        5      (       d  [	        SU S35      e[        R                  " U" UU5      [,        S9m O[        R.                  " UUS9u  nm [1        T 5      [3        T 5      nn[        R4                  " UU:  UU:  -  5      (       a  [	        S5      e[7        T 5      S
-
  n[        TUS9m"[9        T"[        T 5      UUUS9T l        T S	   T S   :*  nT R;                  [,        5      m [        R<                  " T S   U(       a  S
OS[        R>                  -  5      T S'   TRA                  S5      (       a  TSS  OTmU U!U"UUUU	U 4S jm#OUU4S jm#U#U
UU4S jnUU4S jnU(       a  [C        UUUUS9T l"        O[G        UUUU(       a  UOS S9T l"        T RI                  T RD                  5        T R                  (       a  T RI                  T R                  5        g g )Nr   r  blueBlueszSPlease pass a valid color brewer code to fill_local. See docstring for valid codes.threshold_scalez[choropleth `threshold_scale` parameter is now depreciated in favor of the `bins` parameter.	set_indexr   r   to_dict)jenks_breaksz?bins value must be an integer when using Jenks. Invalid value "z" received.)dtype)r  zAll values are expected to fall into one of the provided bins (or to be Nan). Please check the `bins` parameter and/or your data.)n)indexvminvmaxcaptionr   zfeature.   c                   > TR                  U T5      nUc  [        ST< S35      e TU   n[        R                  " U5      (       a  T	T
4$ [        R                  " UTSS9S-
  nTU   T4$ ! [         an     [        U[        5      (       a  T[        U5         n No[        U[
        5      (       a  T[	        U5         n NT	T
4s $ ! [        [        4 a	    T	T
4s s $ f = ff = f)Nzkey_on `z` not found in GeoJSON.F)rightr   )	_get_by_keyr   KeyErrorrq   r[   r\   npisnandigitize)rS  key_of_x
value_of_x	color_idx	bin_edges
color_datacolor_ranger  r  r  r  rK   s       rM   color_scale_fun,Choropleth.__init__.<locals>.color_scale_fun`  s   ++Av6#$xz9P%QRR@!+H!5J 88J'')+;;;KK
IUKaO	"9-|;;!   
@	@%h44)3CM)BJ'#66)3CM)BJ#13C#CC$j1 @-/???@
@s;   A, ,
C$7#C#CCC$C C$C  C$c                    > TT4$ r   rD   )rS  r  r  s    rM   r  r  {  s    !<//rO   c                 (   > T" U 5      u  pTTTUUS.$ )N)weightopacitycolorfillOpacity	fillColorrD   )rS  r  r  r  r  r  r  s      rM   r   +Choropleth.__init__.<locals>.style_function~  s(    ,Q/NE%'#&" rO   c                    > TS-   TS-   S.$ )Nr   g?)r  r  rD   )rS  r  r  s    rM   r   /Choropleth.__init__.<locals>.highlight_function  s    )AolS>PQQrO   )r   r   )r   r   r   )%rE   rF   rG   r   r   r  r  DeprecationWarningrp   r  r  rJ   color_scaler  arrayry  valuesr  jenkspyr  rq   r[   rZ   	histogramminrH  r~  r  r   astype	nextafterinfr   rN  geojsonr   r   )%rK   r  rg   r  r  r  r  r  r  r  r  r  r  r}   r  r   r   r   rO  r   r   r  rA   real_valuesr  _bins_minbins_maxnb_bins
increasingr   r   r  r  r  r  rL   s%   `   ` ```````                   @@@@rM   rF   Choropleth.__init__  s   2 	dW4P!
HdlF
L$<$<= 
 #+&'(4/0MM4" 4%%&&&
3GAJ?GGIJT9%%JdJJ!f&8((4
(9(9(;#<=K%rxx'<&<=K0!$,,$++/&=  HH\+t%DER	!||KdC9!$YYhHvv{X-+2HIJJ (  )nq(G&zW=K+9o# D #126J!((/ILL"ZR266AIbM $*#4#4Z#@#@VABZfF< <60	 		R 5=-+	6DL #-+9B#5	DL 	t||$NN4++, rO   objr  r   c                    UR                  S5      nUS   nUR                  5       (       a  U[        U5         nOUR                  US 5      n[	        U5      S:  a%  SR                  USS  5      nU R                  XV5      $ U$ )Nr   r   r   )r   isdigitr[   rt   r  joinr  )clsr  r  	key_partsfirst_key_partr6  new_keys          rM   r  Choropleth._get_by_key  sz    IIcN	"1!!##N+,EGGND1Ey>Ahhy}-G??522LrO   c                    > U R                   (       aA  [        U R                  [        5      (       d   S5       eU R                  U R                   l        [        TU ]  " S0 UD6  g)z4Render the GeoJson/TopoJson and color scale objects.z)Choropleth must be added to a Map object.NrD   )r  rq   r   r   rE   r   rb  s     rM   r   Choropleth.render  sW    c  ;:;  (,||D$  rO   )rG   r  r  )NNN   Nblackg333333?Nr  r   r   Nrc   TTTNNFF)rS   rT   rU   rV   rW   r   r   r	   r\   r   r[   rZ   r   rF   classmethodrJ   ry  r  r   r]   r^   r_   s   @rM   r  r    s   oh #+/ $,-$(%!,0!""&)--g-g- smg- (3-(	g-
 g- C%()g- SMg- g- g- #5/g- g- g- g- smg- g-  !g-" #g-$ %g-& 3-'g-(  )g-* +g-, -g- g-R eD$J/ c eE3PTDT>U  	! 	!rO   r  c                      ^  \ rS rSrSr\" S5      r     SS\\   S\\	\
\
4      S\\	\
\
4      S\\	\
\
4      S\4
U 4S	 jjjrS
rU =r$ )DivIconi  a?  
Represents a lightweight icon for markers that uses a simple `div`
element instead of an image.

Parameters
----------
icon_size : tuple of 2 int
    Size of the icon image in pixels.
icon_anchor : tuple of 2 int
    The coordinates of the "tip" of the icon
    (relative to its top left corner).
    The icon will be aligned so that this point is at the
    marker's geographical location.
popup_anchor : tuple of 2 int
    The coordinates of the point from which popups will "open",
    relative to the icon anchor.
class_name : string
    A custom class name to assign to the icon.
    Leaflet defaults is 'leaflet-div-icon' which draws a little white
    square with a shadow.  We set it 'empty' in folium.
html : string
    A custom HTML code to put inside the div element.

See https://leafletjs.com/reference.html#divicon

z
        {% macro script(this, kwargs) %}
            var {{ this.get_name() }} = L.divIcon({{ this.options|tojavascript }});
        {% endmacro %}
        r   	icon_sizeicon_anchorpopup_anchorrw  c                 T   > [         TU ]  5         SU l        [        UUUUUS9U l        g )Nr  )r   r  r  r  rw  )rE   rF   rG   r1   rH   )rK   r   r  r  r  rw  rL   s         rM   rF   DivIcon.__init__  s2     	
##%!
rO   rP   )NNNNempty)rS   rT   rU   rV   rW   r!   rX   r   r\   r
   r[   rF   r]   r^   r_   s   @rM   r  r    s    6 	I #/31526!
sm
 E#s(O,
 eCHo.	

 uS#X/
 
 
rO   r  c                   <   ^  \ rS rSrSr\" S5      rU 4S jrSrU =r	$ )LatLngPopupi  z
When one clicks on a Map that contains a LatLngPopup,
a popup is shown that displays the latitude and longitude of the pointer.

a=  
            {% macro script(this, kwargs) %}
                var {{this.get_name()}} = L.popup();
                function latLngPop(e) {
                    {{this.get_name()}}
                        .setLatLng(e.latlng)
                        .setContent("Latitude: " + e.latlng.lat.toFixed(4) +
                                    "<br>Longitude: " + e.latlng.lng.toFixed(4))
                        .openOn({{this._parent.get_name()}});
                    }
                {{this._parent.get_name()}}.on('click', latLngPop);
            {% endmacro %}
            c                 0   > [         TU ]  5         SU l        g )Nr  )rE   rF   rG   )rK   rL   s    rM   rF   LatLngPopup.__init__  s    "
rO   rG   )
rS   rT   rU   rV   rW   r!   rX   rF   r]   r^   r_   s   @rM   r  r    s#     	I # #rO   r  c                   V   ^  \ rS rSrSr\" S5      rSS\\\	\
S4   4U 4S jjjrSrU =r$ )	ClickForMarkeri  a  
When one clicks on a Map that contains a ClickForMarker,
a Marker is created at the pointer's position.

Parameters
----------
popup: str or IFrame or Html, default None
    Text to display in the markers' popups.
    This can also be an Element like IFrame or Html.
    If None, the popups will display the marker's latitude and longitude.
    You can include the latitude and longitude with ${lat} and ${lng}.


Examples
--------
>>> ClickForMarker("<b>Lat:</b> ${lat}<br /><b>Lon:</b> ${lng}")

a  
            {% macro script(this, kwargs) %}
                function newMarker(e){
                    var new_mark = L.marker().setLatLng(e.latlng).addTo({{this._parent.get_name()}});
                    new_mark.dragging.enable();
                    new_mark.on('dblclick', function(e){ {{this._parent.get_name()}}.removeLayer(e.target)})
                    var lat = e.latlng.lat.toFixed(4),
                       lng = e.latlng.lng.toFixed(4);
                    new_mark.bindPopup({{ this.popup }});
                    };
                {{this._parent.get_name()}}.on('click', newMarker);
            {% endmacro %}
            Nr?   c                    > [         TU ]  5         SU l        [        U[        5      (       a  UR                  5       nU(       a  S[        U5      -   S-   U l        g SU l        g )Nr  `z-"Latitude: " + lat + "<br>Longitude: " + lng )rE   rF   rG   rq   r   r   r*   r?   )rK   r?   rL   s     rM   rF   ClickForMarker.__init__/  sN    %
eW%%LLNE/66<DJHDJrO   )rG   r?   r   )rS   rT   rU   rV   rW   r!   rX   r   r   r   r\   rF   r]   r^   r_   s   @rM   r  r    s;    & 	I 	IeFD#t$;< 	I 	IrO   r  c                   R   ^  \ rS rSrSr\" S5      rSS\\   S\	4U 4S jjjr
SrU =r$ )	ClickForLatLngi;  a
  
When one clicks on a Map that contains a ClickForLatLng,
the coordinates of the pointer's position are copied to clipboard.

Parameters
==========
format_str : str, default 'lat + "," + lng'
    The javascript string used to format the text copied to clipboard.
    eg:
    format_str = 'lat + "," + lng'              >> 46.558860,3.397397
    format_str = '"[" + lat + "," + lng + "]"'  >> [46.558860,3.397397]
alert : bool, default True
    Whether there should be an alert when something has been copied to clipboard.
a  
            {% macro script(this, kwargs) %}
                function getLatLng(e){
                    var lat = e.latlng.lat.toFixed(6),
                        lng = e.latlng.lng.toFixed(6);
                    var txt = {{this.format_str}};
                    navigator.clipboard.writeText(txt);
                    {% if this.alert %}alert("Copied to clipboard : \n    " + txt);{% endif %}
                    };
                {{this._parent.get_name()}}.on('click', getLatLng);
            {% endmacro %}
            
format_stralertc                 \   > [         TU ]  5         SU l        U=(       d    SU l        X l        g )Nr  zlat + "," + lng)rE   rF   rG   r  r  )rK   r  r  rL   s      rM   rF   ClickForLatLng.__init__Z  s'    %
$9(9
rO   )rG   r  r  )NT)rS   rT   rU   rV   rW   r!   rX   r   r\   r   rF   r]   r^   r_   s   @rM   r  r  ;  s5     	I8C=   rO   r  c                      ^  \ rS rSrSr\" S5      r      SS\S\\	\
\
4      S\\	\
\
4      S\S\\	\
\
4      S	\\	\
\
4      S
\\	\
\
4      4U 4S jjjrSrU =r$ )
CustomIconia  a  
Create a custom icon, based on an image.

Parameters
----------
icon_image : string or array-like object
    The data to use as an icon.

    * If string is a path to an image file, its content will be converted and
      embedded.
    * If string is a URL, it will be linked.
    * Otherwise a string will be assumed to be JSON and embedded.
    * If array-like, it will be converted to PNG base64 string and embedded.
icon_size : tuple of 2 int, optional
    Size of the icon image in pixels.
icon_anchor : tuple of 2 int, optional
    The coordinates of the "tip" of the icon
    (relative to its top left corner).
    The icon will be aligned so that this point is at the
    marker's geographical location.
shadow_image :  string, file or array-like object, optional
    The data for the shadow image. If not specified,
    no shadow image will be created.
shadow_size : tuple of 2 int, optional
    Size of the shadow image in pixels.
shadow_anchor : tuple of 2 int, optional
    The coordinates of the "tip" of the shadow relative to its
    top left corner (the same as icon_anchor if not specified).
popup_anchor : tuple of 2 int, optional
    The coordinates of the point from which popups will "open",
    relative to the icon anchor.

z
        {% macro script(this, kwargs) %}
        var {{ this.get_name() }} = L.icon({{ this.options|tojavascript }});
        {% endmacro %}
        
icon_imager  r  shadow_imageshadow_sizeshadow_anchorr  c           
         > [         [        U ]  5         SU l        [	        [        U5      UUU=(       a    [        U5      UUUS9U l        g )Nicon)icon_urlr  r  
shadow_urlr  r  r  )rE   r   rF   rG   r1   r-   rH   )	rK   r
  r  r  r  r  r  r  rL   s	           rM   rF   CustomIcon.__init__  sI     	dD"$
#!*-##B\(B#'%
rO   rP   )NNNNNN)rS   rT   rU   rV   rW   r!   rX   r   r   r
   r[   rF   r]   r^   r_   s   @rM   r	  r	  a  s     D 	I 0415 153726

 E#s(O,
 eCHo.	

 
 eCHo.
  c3h0
 uS#X/
 
rO   r	  c                   |   ^  \ rS rSrSr    SS\S\\   S\\	\
\   S4   S\S\\   S	\\   S
\4U 4S jjjrSrU =r$ )	ColorLinei  a%  
Draw data on a map with specified colors.

Parameters
----------
positions: iterable of (lat, lon) pairs
    The points on the line. Segments between points will be colored.
colors: iterable of float
    Values that determine the color of a line segment.
    It must have length equal to `len(positions)-1`.
colormap: branca.colormap.Colormap or list or tuple
    The colormap to use. If a list or tuple of colors is provided,
    a LinearColormap will be created from it.
nb_steps: int, default 12
    The colormap will be discretized to this number of colors.
opacity: float, default 1
    Line opacity, scale 0-1
weight: int, default 2
    Stroke weight in pixels
**kwargs
    Further parameters available. See folium.map.FeatureGroup

Returns
-------
A ColorLine object that you can `add_to` a Map.

N	positionscolorscolormapnb_stepsr  r  rA   c           
        > [         TU ]  " S0 UD6  SU l        [        U5      nUc/  [	        / SQ[        U5      [        U5      S9R                  U5      n	O[        U[        5      (       a  UR                  U5      n	O[        U[        5      (       d  [        U[        5      (       a-  [	        U[        U5      [        U5      S9R                  U5      n	O/[        U[        5      (       a  Un	O[        S[        U5       35      e0 n
[        US S USS  U5       H6  u  u  pu  pnU
R                  U	" U5      / 5      R!                  X/X//5        M8     U
R#                  5        H   u  nnU R%                  ['        UUXVS95        M"     g )	Nr  )greenyellowred)r  r  z)Unexpected type for argument `colormap`: r   r   )r  r  r  rD   )rE   rF   rG   r2   r   r  rH  to_steprq   ry  rz  r   r   r   zipr1  r2  r.  r   r5   )rK   r  r  r  r  r  r  rA   coordscmoutlat1lng1lat2lng2r  r  valrL   s                     rM   rF   ColorLine.__init__  si    	"6" 
#I.-*[[  gh	 
 .11!!(+B$'':h+F+F[[ gh	 
 ,//B;DN;KL  3514VCR[&*f1U-LT,4NN2e9b)004,1MN 2V		HCNN8Cs6ST $rO   r  )N   NN)rS   rT   rU   rV   rW   r&   r   rZ   r   r   r	   r   r[   r   rF   r]   r^   r_   s   @rM   r  r    s    @ :> $#''U'U 'U (3-56	'U
 'U 'U %'U 'U 'UrO   r  c                   b   ^  \ rS rSrSr\" S5      r S
SS.S\\   S\\	   4U 4S jjjjr
S	rU =r$ )Controli  a  
Add a Leaflet Control object to the map

Parameters
----------
control: str
    The javascript class name of the control to be rendered.
position: str
    One of "bottomright", "bottomleft", "topright", "topleft"

Examples
--------

>>> import folium
>>> from folium.features import Control, Marker
>>> from folium.plugins import Geocoder

>>> m = folium.Map(
...     location=[46.603354, 1.8883335], attr=None, zoom_control=False, zoom_start=5
... )
>>> Control("Zoom", position="topleft").add_to(m)
aU  
      {% macro script(this, kwargs) %}
          var {{ this.get_name() }} = new L.Control.{{this._name}}(
              {% for arg in this.args %}
                  {{ arg | tojavascript }},
              {% endfor %}
              {{ this.options|tojavascript }}
          ).addTo({{ this._parent.get_name() }});
      {% endmacro %}
    N)rl   r   rl   c                   > [         TU ]  5         U(       a  Xl        Ub7  UR                  5       nU[	        [
        5      =n;  a  [        SU 35      eX$S'   X0l        [        S0 UD6U l	        g )Nzposition must be one of rl   rD   )
rE   rF   rG   r   r   r(   r   argsr1   rH   )rK   r   rl   r,  rA   rL   s        rM   rF   Control.__init__  sk     	 J~~'H(> >?":4& ABB!):	#-f-rO   )rG   r,  rH   r   )rS   rT   rU   rV   rW   r!   rX   r   r\   r(   rF   r]   r^   r_   s   @rM   r*  r*    sM    . 		I "&. ,0	.#. <(	. .rO   r*  )ZrW   r:  rr   r<  r  typingr   r   r   r   r   r   r	   r
   r   r   numpyr  r   branca.colormapr   r   r   branca.elementr   r   r   r   r   r   r   branca.utilitiesr   folium.elementsr   folium.foliumr   
folium.mapr   r   r   r   r   r   r    folium.templater!   folium.utilitiesr"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   folium.vector_layersr3   r4   r5   r6   r8   ra   r   r   r\   r[   rK  r  rN  rs  r   r   r  r  r  r  r  r	  r  r*  rD   rO   rM   <module>r9     s  
         B B   * &  O O O $    & N M=
:v =
@x
: x
vf
| f
RDe DN U3U38_(=#=>>? >! >!Bs
z5 s
lJL JZL&] L&^@$= @$Fr! r!j	4
l 4
n#, #8-I\ -I`#\ #L?
 ?
DDU DUN7.j% 7.rO   