Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/lvestats/lib/chart/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/lvestats/lib/chart/__pycache__/polysimplify.cpython-311.pyc

�

)�f���h�dZddlmZddlmZddlmZmZddlZ	d�Z
d�Zd�ZGd	�d
e
��ZdS)a�
Visvalingam-Whyatt method of poly-line vertex reduction

Visvalingam, M and Whyatt J D (1993)
"Line Generalisation by Repeated Elimination of Points", Cartographic J., 30 (1), 46 - 51

Described here:
http://web.archive.org/web/20100428020453/http://www2.dcs.hull.ac.uk/CISRG/publications/DPs/DP10/DP10.html

=========================================

The MIT License (MIT)

Copyright (c) 2014 Elliot Hallmark

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

================================
�)�absolute_import)�range)�Iterable�ListNc���t|d|d|dz
z|d|d|dz
zz|d|d|dz
zz��dzS)z>
    calculates the area of a triangle given its vertices
    r��@)�abs)�p1�p2�p3s   ��/builddir/build/BUILDROOT/lve-stats-4.2.8-1.el8.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/lvestats/lib/chart/polysimplify.py�
triangle_arear.s`���r�!�u�b��e�B�q�E�k�"�2�a�5�"�Q�%��1��+�#6�6�r�!�u�b��e�B�q�E�k�7J�J�K�K�B�N�N�c�d�tjt|��f|j��}tj|d<tj|d<|dd�}|dd�}|dd�}|dd�}tj|��}tj|dd�df|dd�df|���tj|dd�df||���tj|dd�df|dd�df|���tj|dd�df||���tj|||���tj|dd�df|dd�df|���tj|dd�df||���tj|||���tj	||���|dz}|S)	z�
    take an (N,2) array of points and return an (N,1)
    array of the areas of those triangles, where the first
    and last areas are np.inf

    see triangle_area for algorithm
    r���N���r�)�outr	)
�np�empty�len�dtype�inf�
empty_like�subtract�multiply�addr
)�arr�resultrrr
�accr�acc1s       r�triangle_areas_from_arrayr#5s����X�s�3�x�x�k�3�9�
-�
-�F���F�1�I���F�2�J�	�S�b�S��B�	�Q�r�T��B�	�Q�R�R��B��!�B�$�<�D�
�=����D��K��1�1�1�a�4��"�Q�Q�Q��T�(��-�-�-�-��K��1�1�1�a�4��$�t�,�,�,�,��K��1�1�1�a�4��"�Q�Q�Q��T�(��-�-�-�-��K��1�1�1�a�4��$�t�,�,�,�,��F�4��d�+�+�+�+��K��1�1�1�a�4��"�Q�Q�Q��T�(��-�-�-�-��K��1�1�1�a�4��$�t�,�,�,�,��F�4��d�+�+�+�+��F�4�T������B�J�D��Mrc�*�||dzd�||d�<dS)z�
    Quick trick to remove an item from a numpy array without
    creating a new object.  Rather than the array shape changing,
    the final value just gets repeated to fill the space.

    ~3.5x faster than numpy.delete
    rNr�)�s�is  r�remover(\s!����!����g�A�a��d�G�G�Grc��eZdZdeeeddfd�Zd�Zdeeefd�Zdeeefd�Z	deeefd�Z
dS)	�VWSimplifier�pts�returnNc��tj|tj���|_|���|_t
|jd���|_dS)z�
        Initialize with points. takes some time to build
        the thresholds but then all threshold filtering later 
        is ultra fast
        )rT)�reverseN)r�array�float32r+�build_thresholds�
thresholds�sorted�ordered_thresholds)�selfr+s  r�__init__zVWSimplifier.__init__isL���8�C�r�z�2�2�2����/�/�1�1���"(���$�"G�"G�"G����rc��|j}t|��}t|��}tt	|����}tj|��}|dd�}tj|��}||}t||��|�	|��|t
j
k�r#d}		t|||dz
||||||dz��}
||}|
|kr|}
|}	|
||<|
||<n#t$rYnwxYw|dkr^t|||dz
|||dz
|||��}||kr|}|dz
}	||||dz
<|||dz
<|	ptj|��}|�	|��||}t||��|t
j
k��#|S)z�
        compute the area value of each vertex, which one would
        use to mask an array of points for any threshold value.

        returns a numpy.array (length of pts)  of the areas.
        NFrr)
r+rr#�listrr�copy�argminr(�poprr�
IndexError)
r5r+�nmax�
real_areas�real_indices�areasr'�min_vert�	this_area�skip�
right_area�	right_idx�	left_areas
             rr1zVWSimplifier.build_thresholdsss���h���3�x�x��.�s�3�3�
��E�$�K�K�(�(����
�#�#������O���9�U�#�#���(�O�	��u�h����	
���h�����"�&� � ��D�
-�*�3�q��!��}�+=�+.�q��{�+;�S��8�A�:��=O�Q�Q�
��h�K�	���*�*�"+�J�
$�D�)3�
�9�%�",��h����)�
�
�
���
����,�!�|�|�)�#�a���
�m�*<�*-�a���
�m�*<�c�!�H�+�>N�P�P�	��	�)�)� )�I�#�A�:�D�,5�
�1�X�a�Z�=�)�$-��h�q�j�!��/�r�y��/�/�H�
�E�E�(�O�O�O��h��I��5�(�#�#�#�g�"�&� � �h�s�5;D
�
D�Dc�R�|j|j|k���S�N)r+r2�tolist)r5�	thresholds  r�from_thresholdzVWSimplifier.from_threshold�s"������I�5�6�>�>�@�@�@rc��|j}	|t|��}|j|j|k}n#t$r
|j}YnwxYw|���SrH)r4�intr+r2r<rI)r5�nr2rJr s     r�from_numberzVWSimplifier.from_number�sn���,�
�	;�"�3�q�6�6�*�I��X�d�o�	�9�:�F�F���	�	�	��X�F�F�F�	�����}�}���s�5�A	�A	c��|dks|dkrtd���|�|t|j��z��S)NrrzRatio must be 0<r<=1)�
ValueErrorrOrr2)r5�rs  r�
from_ratiozVWSimplifier.from_ratio�sE����6�6�Q��U�U��3�4�4�4��#�#�A�c�$�/�&:�&:�$:�;�;�;r)�__name__�
__module__�__qualname__rr�floatr6r1rKrOrSr%rrr*r*gs�������H�H�T�%�[�1�H�d�H�H�H�H�O�O�O�bA�4��U��+<�A�A�A�A���T�%�[� 1�����<�t�D��K�0�<�<�<�<�<�<rr*)�__doc__�
__future__r�builtinsr�typingrr�numpyrrr#r(�objectr*r%rr�<module>r^s���"�"�F'�&�&�&�&�&�������!�!�!�!�!�!�!�!�����O�O�O� � � �N���n<�n<�n<�n<�n<�6�n<�n<�n<�n<�n<r

Hacked By AnonymousFox1.0, Coded By AnonymousFox