o
    Pf                     @   sf   d dl Z d dlZd dlmZ d dlmZ d dlmZ d dl	m
Z
mZmZmZmZ G dd deeZdS )    N)Template)
JSCSSMixin)Layer)if_pandas_df_convert_to_numpynone_maxnone_minparse_optionsvalidate_locationc                       sJ   e Zd ZdZedZdgZ												d fd
d	Zdd Z  Z	S )HeatMapaQ  
    Create a Heatmap layer

    Parameters
    ----------
    data : list of points of the form [lat, lng] or [lat, lng, weight]
        The points you want to plot.
        You can also provide a numpy.array of shape (n,2) or (n,3).
    name : string, default None
        The name of the Layer, as it will appear in LayerControls.
    min_opacity  : default 1.
        The minimum opacity the heat will start at.
    max_zoom : default 18
        Zoom level where the points reach maximum intensity (as intensity
        scales with zoom), equals maxZoom of the map by default
    radius : int, default 25
        Radius of each "point" of the heatmap
    blur : int, default 15
        Amount of blur
    gradient : dict, default None
        Color gradient config. e.g. {0.4: 'blue', 0.65: 'lime', 1: 'red'}
    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.
    z
        {% macro script(this, kwargs) %}
            var {{ this.get_name() }} = L.heatLayer(
                {{ this.data|tojson }},
                {{ this.options|tojson }}
            );
        {% endmacro %}
        )zleaflet-heat.jszahttps://cdn.jsdelivr.net/gh/python-visualization/folium@main/folium/templates/leaflet_heat.min.jsN      ?         Tc                    s   t  j|||	|
d d| _t|}dd |D | _tt| jr&td|	dd r3t
jddd	 td|||||d
|| _d S )N)nameoverlaycontrolshowr
   c                 S   s,   g | ]}g t |d d |dd  qS )N   )r	   ).0line r   c/home/deployuser/azure_apps/autowriter/venv/lib/python3.10/site-packages/folium/plugins/heat_map.py
<listcomp>R   s     z$HeatMap.__init__.<locals>.<listcomp>zdata may not contain NaNs.max_valzbThe `max_val` parameter is no longer necessary. The largest intensity is calculated automatically.r   )
stacklevel)min_opacitymax_zoomradiusblurgradientr   )super__init___namer   datanpanyisnan
ValueErrorpopwarningswarnr   options)selfr#   r   r   r   r   r   r   r   r   r   kwargs	__class__r   r   r!   A   s,   zHeatMap.__init__c                 C   sx   ddgddgg}| j D ].}t|d d |d t|d d |d gt|d d |d t|d d |d gg}q|S )z
        Computes the bounds of the object itself (not including it's children)
        in the form [[lat_min, lon_min], [lat_max, lon_max]].

        Nr      )r#   r   r   )r,   boundspointr   r   r   _get_self_boundsf   s   

zHeatMap._get_self_bounds)	Nr   r   r   r   NTTT)
__name__
__module____qualname____doc__r   	_template
default_jsr!   r3   __classcell__r   r   r.   r   r
      s$    
%r
   )r)   numpyr$   jinja2r   folium.elementsr   
folium.mapr   folium.utilitiesr   r   r   r   r	   r
   r   r   r   r   <module>   s    	