o
    Pf                     @   sx   d dl mZmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 G dd deeeZG dd	 d	eZG d
d deZdS )    )ABCabstractmethod)Template)
JSCSSMixin)MacroElement)path_optionsc                       sJ   e Zd ZdZedZdgZdef fddZe	e
defdd	Z  ZS )
_BaseFromEncodeda  Base Interface to create folium objects from encoded strings.

    Derived classes must define `_encoding_type` property which returns the string
    representation of the folium object to create from the encoded string.

    Parameters
    ----------
    encoded: str
        The raw encoded string from the Polyline Encoding Algorithm. See:
        https://developers.google.com/maps/documentation/utilities/polylinealgorithm
    **kwargs:
        Object options as accepted by leaflet.
    a%  
        {% macro script(this, kwargs) %}

            var {{ this.get_name() }} = L.{{ this._encoding_type }}.fromEncoded(
                {{ this.encoded|tojson }},
                {{ this.options|tojson }}
            ).addTo({{ this._parent.get_name() }});

        {% endmacro %}
        )zpolyline-encodedzGhttps://cdn.jsdelivr.net/npm/polyline-encoded@0.0.9/Polyline.encoded.jsencodedc                    s   t    || _d S )N)super__init__r	   )selfr	   	__class__ b/home/deployuser/azure_apps/autowriter/venv/lib/python3.10/site-packages/folium/plugins/encoded.pyr   -   s   

z_BaseFromEncoded.__init__returnc                 C   s   t )zAAn abstract getter to return the type of folium object to create.)NotImplementedErrorr   r   r   r   _encoding_type1   s   z_BaseFromEncoded._encoding_type)__name__
__module____qualname____doc__r   	_template
default_jsstrr   propertyr   r   __classcell__r   r   r   r   r   
   s    r   c                       8   e Zd ZdZdef fddZedefddZ  ZS )PolyLineFromEncodeda  Create PolyLines directly from the encoded string.

    Parameters
    ----------
    encoded: str
        The raw encoded string from the Polyline Encoding Algorithm. See:
        https://developers.google.com/maps/documentation/utilities/polylinealgorithm
    **kwargs:
        Polyline options as accepted by leaflet. See:
        https://leafletjs.com/reference.html#polyline

    Adapted from https://github.com/jieter/Leaflet.encoded

    Examples
    --------
    >>> from folium import Map
    >>> from folium.plugins import PolyLineFromEncoded
    >>> m = Map()
    >>> encoded = r"_p~iF~cn~U_ulLn{vA_mqNvxq`@"
    >>> PolyLineFromEncoded(encoded=encoded, color="green").add_to(m)
    r	   c                    s,   d| _ t j|d tdddi|| _d S )Nr   )r	   lineTr   _namer
   r   r   optionsr   r	   kwargsr   r   r   r   O   s   zPolyLineFromEncoded.__init__r   c                 C      dS ):Return the name of folium object created from the encoded.Polyliner   r   r   r   r   r   T      z"PolyLineFromEncoded._encoding_type	r   r   r   r   r   r   r   r   r   r   r   r   r   r   8   
    r   c                       r   )PolygonFromEncodeda  Create Polygons directly from the encoded string.

    Parameters
    ----------
    encoded: str
        The raw encoded string from the Polyline Encoding Algorithm. See:
        https://developers.google.com/maps/documentation/utilities/polylinealgorithm
    **kwargs:
        Polygon options as accepted by leaflet. See:
        https://leafletjs.com/reference.html#polygon

    Adapted from https://github.com/jieter/Leaflet.encoded

    Examples
    --------
    >>> from folium import Map
    >>> from folium.plugins import PolygonFromEncoded
    >>> m = Map()
    >>> encoded = r"w`j~FpxivO}jz@qnnCd}~Bsa{@~f`C`lkH"
    >>> PolygonFromEncoded(encoded=encoded).add_to(m)
    r	   c                    s,   d| _ t | tddd d|| _d S )Nr,   T)r    radiusr   r!   r$   r   r   r   r   q   s   zPolygonFromEncoded.__init__r   c                 C   r&   )r'   Polygonr   r   r   r   r   r   v   r)   z!PolygonFromEncoded._encoding_typer*   r   r   r   r   r,   Z   r+   r,   N)abcr   r   jinja2r   folium.elementsr   folium.featuresr   folium.vector_layersr   r   r   r,   r   r   r   r   <module>   s    ."