o
    Pf
3                     @   s   d Z ddlmZmZmZmZ ddlmZ ddlm	Z	 ddl
mZmZmZ ddlmZmZmZmZmZmZmZ 	dd	ed
ee defddZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZdS )zG
Wraps leaflet Polyline, Polygon, Rectangle, Circle, and CircleMarker

    )ListOptionalSequenceUnion)MacroElement)Template)MarkerPopupTooltip)TypeLineTypeMultiLineTypePathOptionscamelize
get_boundsvalidate_locationsvalidate_multi_locationsFNlineradiuskwargsc           	      K   s4  dd |  D }i }| r|dd|ddd}|r#|d|i |d	d
}|dd}|r4d}n
|s>|}|dd}|dd}|durO|d|i |dr[|d|d< |dd||dd|dd|dd|dd|dd|dd|||dd|dd|ddd}|| |S ) aX	  
    Contains options and constants shared between vector overlays
    (Polygon, Polyline, Circle, CircleMarker, and Rectangle).

    Parameters
    ----------
    stroke: Bool, True
        Whether to draw stroke along the path.
        Set it to false to disable borders on polygons or circles.
    color: str, '#3388ff'
        Stroke color.
    weight: int, 3
        Stroke width in pixels.
    opacity: float, 1.0
        Stroke opacity.
    line_cap: str, 'round' (lineCap)
        A string that defines shape to be used at the end of the stroke.
        https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linecap
    line_join: str, 'round' (lineJoin)
        A string that defines shape to be used at the corners of the stroke.
        https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linejoin
    dash_array: str, None (dashArray)
        A string that defines the stroke dash pattern.
        Doesn't work on Canvas-powered layers in some old browsers.
        https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray
    dash_offset:, str, None (dashOffset)
        A string that defines the distance into the dash pattern to start the dash.
        Doesn't work on Canvas-powered layers in some old browsers.
        https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dashoffset
    fill: Bool, False
        Whether to fill the path with color.
        Set it to false to disable filling on polygons or circles.
    fill_color: str, default to `color` (fillColor)
        Fill color. Defaults to the value of the color option.
    fill_opacity: float, 0.2 (fillOpacity)
        Fill opacity.
    fill_rule: str, 'evenodd' (fillRule)
        A string that defines how the inside of a shape is determined.
        https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill-rule
    bubbling_mouse_events: Bool, True (bubblingMouseEvents)
        When true a mouse event on this path will trigger the same event on the
        map (unless L.DomEvent.stopPropagation is used).
    gradient: bool, default None
        When a gradient on the stroke and fill is available,
        allows turning it on or off.

    Note that the presence of `fill_color` will override `fill=False`.

    This function accepts both snake_case and lowerCamelCase equivalents.

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

    c                 S   s   i | ]	\}}t ||qS  )r   ).0keyvaluer   r   `/home/deployuser/azure_apps/autowriter/venv/lib/python3.10/site-packages/folium/vector_layers.py
<dictcomp>P   s    z path_options.<locals>.<dictcomp>smoothFactorg      ?noClipF)r   r   r   colorz#3388ff	fillColorTfillgradientNtagsstrokeweight   opacitylineCaproundlineJoin	dashArray
dashOffsetfillOpacityg?fillRuleevenoddbubblingMouseEvents)r"   r   r#   r%   r&   r(   r)   r*   r   r   r+   r,   r.   )itemspopupdateget)	r   r   r   extra_optionsr   
fill_colorr   r    defaultr   r   r   path_options   sH   9













r6   c                
       sb   e Zd ZdZ		ddedeeedf deeedf f fddZ	de
e
ee   fd	d
Z  ZS )BaseMultiLocationzRBase class for vector classes with multiple coordinates.

    :meta private:

    N	locationspopuptooltipc                    sl   t    t|| _|d ur| t|tr|ntt| |d ur4| t|tr+|ntt| d S d S )N)	super__init__r   r8   	add_child
isinstancer	   strr
   )selfr8   r9   r:   	__class__r   r   r<      s   

 zBaseMultiLocation.__init__returnc                 C   
   t | jS z(Compute the bounds of the object itself.r   r8   r@   r   r   r   _get_self_bounds      
z"BaseMultiLocation._get_self_boundsNN)__name__
__module____qualname____doc__r   r   r	   r?   r
   r<   r   r   floatrH   __classcell__r   r   rA   r   r7   }   s    	"r7   c                       s*   e Zd ZdZedZd fdd	Z  ZS )PolyLinea  Draw polyline overlays on a map.

    See :func:`folium.vector_layers.path_options` for the `Path` options.

    Parameters
    ----------
    locations: list of points (latitude, longitude)
        Latitude and Longitude of line (Northing, Easting)
        Pass multiple sequences of coordinates for a multi-polyline.
    popup: str or folium.Popup, default None
        Input text or visualization for object displayed when clicking.
    tooltip: str or folium.Tooltip, default None
        Display a text when hovering over the object.
    smooth_factor: float, default 1.0
        How much to simplify the polyline on each zoom level.
        More means better performance and smoother look,
        and less means more accurate representation.
    no_clip: Bool, default False
        Disable polyline clipping.
    **kwargs
        Other valid (possibly inherited) options. See:
        https://leafletjs.com/reference.html#polyline

    a  
        {% macro script(this, kwargs) %}
            var {{ this.get_name() }} = L.polyline(
                {{ this.locations|tojson }},
                {{ this.options|tojson }}
            ).addTo({{this._parent.get_name()}});
        {% endmacro %}
        Nc                    s0   t  j|||d d| _tdddi|| _d S )Nr9   r:   rQ   r   Tr   r;   r<   _namer6   optionsr@   r8   r9   r:   r   rA   r   r   r<      s   zPolyLine.__init__rJ   )rK   rL   rM   rN   r   	_templater<   rP   r   r   rA   r   rQ      s    rQ   c                
       sT   e Zd ZdZedZ		d
dedeee	df dee
e	df def fdd	Z  ZS )Polygona  Draw polygon overlays on a map.

    See :func:`folium.vector_layers.path_options` for the `Path` options.

    Parameters
    ----------
    locations: list of points (latitude, longitude)
        - One list of coordinate pairs to define a polygon. You don't have to
          add a last point equal to the first point.
        - If you pass a list with multiple of those it will make a multi-
          polygon.
    popup: string or folium.Popup, default None
        Input text or visualization for object displayed when clicking.
    tooltip: str or folium.Tooltip, default None
        Display a text when hovering over the object.
    **kwargs
        Other valid (possibly inherited) options. See:
        https://leafletjs.com/reference.html#polygon

    a  
        {% macro script(this, kwargs) %}
            var {{ this.get_name() }} = L.polygon(
                {{ this.locations|tojson }},
                {{ this.options|tojson }}
            ).addTo({{this._parent.get_name()}});
        {% endmacro %}
        Nr8   r9   r:   r   c                    s2   t  j|||d d| _tddd d|| _d S )NrR   rX   Tr   r   r   rS   rV   rA   r   r   r<      s   zPolygon.__init__rJ   )rK   rL   rM   rN   r   rW   r   r   r	   r?   r
   r   r<   rP   r   r   rA   r   rX      s     rX   c                
       sn   e Zd ZdZedZ		ddedeee	df dee
e	df def fdd	Zd
eeee   fddZ  ZS )	RectangleaX  Draw rectangle overlays on a map.

    See :func:`folium.vector_layers.path_options` for the `Path` options.

    Parameters
    ----------
    bounds: [(lat1, lon1), (lat2, lon2)]
        Two lat lon pairs marking the two corners of the rectangle.
    popup: string or folium.Popup, default None
        Input text or visualization for object displayed when clicking.
    tooltip: str or folium.Tooltip, default None
        Display a text when hovering over the object.
    **kwargs
        Other valid (possibly inherited) options. See:
        https://leafletjs.com/reference.html#rectangle

    a  
        {% macro script(this, kwargs) %}
            var {{this.get_name()}} = L.rectangle(
                {{ this.locations|tojson }},
                {{ this.options|tojson }}
            ).addTo({{this._parent.get_name()}});
        {% endmacro %}
        Nboundsr9   r:   r   c                    s   t    d| _tddd d|| _t|| _t| jdks#J d|d ur7| t	|t
r0|nt
t| |d urM| t	|trD|ntt| d S d S )N	rectangleTrY      zNeed two lat/lon pairsr   )r;   r<   rT   r6   rU   r   r8   lenr=   r>   r	   r?   r
   )r@   r[   r9   r:   r   rA   r   r   r<     s   

 zRectangle.__init__rC   c                 C   rD   rE   rF   rG   r   r   r   rH   !  rI   zRectangle._get_self_boundsrJ   )rK   rL   rM   rN   r   rW   r   r   r	   r?   r
   r   r<   r   r   rO   rH   rP   r   r   rA   r   rZ      s"    "rZ   c                       d   e Zd ZdZedZ				ddeee  dede	e
edf de	eedf d	ef
 fd
dZ  ZS )Circlea  
    Class for drawing circle overlays on a map.

    It's an approximation and starts to diverge from a real circle closer to
    the poles (due to projection distortion).

    See :func:`folium.vector_layers.path_options` for the `Path` options.

    Parameters
    ----------
    location: tuple[float, float]
        Latitude and Longitude pair (Northing, Easting)
    popup: string or folium.Popup, default None
        Input text or visualization for object displayed when clicking.
    tooltip: str or folium.Tooltip, default None
        Display a text when hovering over the object.
    radius: float
        Radius of the circle, in meters.
    **kwargs
        Other valid (possibly inherited) options. See:
        https://leafletjs.com/reference.html#circle

    a  
        {% macro script(this, kwargs) %}
            var {{ this.get_name() }} = L.circle(
                {{ this.location|tojson }},
                {{ this.options|tojson }}
            ).addTo({{ this._parent.get_name() }});
        {% endmacro %}
        N2   locationr   r9   r:   r   c                    2   t  j|||d d| _tdd|d|| _d S )NrR   circleFrY   r   rS   r@   rb   r   r9   r:   r   rA   r   r   r<   J     zCircle.__init__)Nra   NNrK   rL   rM   rN   r   rW   r   r   rO   r   r	   r?   r
   r   r<   rP   r   r   rA   r   r`   &  s(    
r`   c                       r_   )CircleMarkera  
    A circle of a fixed size with radius specified in pixels.

    See :func:`folium.vector_layers.path_options` for the `Path` options.

    Parameters
    ----------
    location: tuple[float, float]
        Latitude and Longitude pair (Northing, Easting)
    popup: string or folium.Popup, default None
        Input text or visualization for object displayed when clicking.
    tooltip: str or folium.Tooltip, default None
        Display a text when hovering over the object.
    radius: float, default 10
        Radius of the circle marker, in pixels.
    **kwargs
        Other valid (possibly inherited) options. See:
        https://leafletjs.com/reference.html#circlemarker

    a  
        {% macro script(this, kwargs) %}
            var {{ this.get_name() }} = L.circleMarker(
                {{ this.location|tojson }},
                {{ this.options|tojson }}
            ).addTo({{ this._parent.get_name() }});
        {% endmacro %}
        N
   rb   r   r9   r:   r   c                    rc   )NrR   rh   FrY   r   rS   re   rA   r   r   r<   x  rf   zCircleMarker.__init__)Nri   NNrg   r   r   rA   r   rh   W  s(    
rh   )FN)rN   typingr   r   r   r   branca.elementr   jinja2r   
folium.mapr   r	   r
   folium.utilitiesr   r   r   r   r   r   r   boolrO   r6   r7   rQ   rX   rZ   r`   rh   r   r   r   r   <module>   s(    $
f+-61