§
    Ÿj¶  ã                   óz   — 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 ddlmZ ddlmZ  G d„ d	e
¦  «        Zd
S )z«
This module houses the GEOSCoordSeq object, which is used internally
by GEOSGeometry to house the actual coordinates of the Point,
LineString, and LinearRing geometries.
é    )ÚbyrefÚc_byteÚc_doubleÚc_uint)Ú
prototypes)ÚGEOSBase©ÚGEOSException)ÚCS_PTR)Únumpyc                   óT  — e Zd ZdZeZd&d„Zd„ Zd„ Zd„ Z	d„ Z
d„ Zd	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zed„ ¦   «         Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z d„ Z!ed„ ¦   «         Z"ed„ ¦   «         Z#ed „ ¦   «         Z$d!„ Z%ed"„ ¦   «         Z&ed#„ ¦   «         Z'ed$„ ¦   «         Z(d%S )'ÚGEOSCoordSeqzGThe internal representation of a list of coordinates inside a Geometry.Fc                 ój   — t          |t          ¦  «        st          d¦  «        ‚|| _        || _        dS )zInitialize from a GEOS pointer.z4Coordinate sequence should initialize with a CS_PTR.N)Ú
isinstancer   Ú	TypeErrorÚ_ptrÚ_z)ÚselfÚptrÚzs      úm/var/www/finuniver-perm.ru/html/student/venv/lib/python3.11/site-packages/django/contrib/gis/geos/coordseq.pyÚ__init__zGEOSCoordSeq.__init__   s6   € å˜#�vÑ&Ô&ð 	TÝÐRÑSÔSÐSØˆŒ	ØˆŒˆˆó    c              #   óL   K  — t          | j        ¦  «        D ]}| |         V — ŒdS )z3Iterate over each point in the coordinate sequence.N)ÚrangeÚsize)r   Úis     r   Ú__iter__zGEOSCoordSeq.__iter__   s8   è è € å�t”yÑ!Ô!ð 	ð 	ˆAØ�q”'ˆMˆMˆMˆMð	ð 	r   c                 ó   — | j         S )z7Return the number of points in the coordinate sequence.)r   ©r   s    r   Ú__len__zGEOSCoordSeq.__len__!   s
   € àŒyÐr   c                 ó*   — t          | j        ¦  «        S )z<Return the string representation of the coordinate sequence.)ÚstrÚtupler    s    r   Ú__str__zGEOSCoordSeq.__str__%   s   € å�4”:‰ŒÐr   c                 óV   — |                       |¦  «         |                      |¦  «        S )z8Return the coordinate sequence value at the given index.)Ú_checkindexÚ_point_getter©r   Úindexs     r   Ú__getitem__zGEOSCoordSeq.__getitem__)   s*   € à×Ò˜ÑÔÐØ×!Ò! %Ñ(Ô(Ð(r   c                 ór  — t          |t          t          f¦  «        rn1t          rt          |t          j        ¦  «        rnt          d¦  «        ‚| j        dk    r| j        r
d}| j        }n	d}| j	        }t          |¦  «        |k    rt          d¦  «        ‚|                      |¦  «          |||¦  «         dS )z5Set the coordinate sequence value at the given index.zBMust set coordinate with a sequence (list, tuple, or numpy array).é   é   z"Dimension of value does not match.N)r   Úlistr$   r   Úndarrayr   Údimsr   Ú_set_point_3dÚ_set_point_2dÚlenr'   )r   r*   ÚvalueÚn_argsÚpoint_setters        r   Ú__setitem__zGEOSCoordSeq.__setitem__.   sË   € õ �e�d¥E˜]Ñ+Ô+ð 	ØÝð 	•z %­¬Ñ7Ô7ð 	ØåØTñô ð ð Œ9˜Š>ˆ>˜dœgˆ>ØˆFØÔ-ˆLˆLàˆFØÔ-ˆLÝˆu‰:Œ:˜ÒÐÝÐ@ÑAÔAÐAØ×Ò˜ÑÔÐØˆ�U˜EÑ"Ô"Ð"Ð"Ð"r   c                 óR   — d|cxk    r| j         k     sn t          d|z  ¦  «        ‚dS )zCheck the given index.r   zinvalid GEOS Geometry index: %sN)r   Ú
IndexErrorr)   s     r   r'   zGEOSCoordSeq._checkindexF   s?   € à�UÐ&Ð&Ò&Ð&˜TœYÒ&Ð&Ð&Ð&ÝÐ>ÀÑFÑGÔGÐGð 'Ð&r   c                 óB   — |dk     s|dk    rt          d|z  ¦  «        ‚dS )zCheck the given dimension.r   r.   zinvalid ordinate dimension "%d"Nr	   )r   Údims     r   Ú	_checkdimzGEOSCoordSeq._checkdimK   s.   € à�Š7ˆ7�c˜A’g�gÝÐ AÀCÑ GÑHÔHÐHð �gr   c                 ój   — t          j        | j        |t          t	          ¦   «         ¦  «        ¦  «        S ©N)ÚcapiÚcs_getxr   r   r   r)   s     r   Ú_get_xzGEOSCoordSeq._get_xP   ó$   € ÝŒ|˜DœH e­Uµ8±:´:Ñ->Ô->Ñ?Ô?Ð?r   c                 ój   — t          j        | j        |t          t	          ¦   «         ¦  «        ¦  «        S r?   )r@   Úcs_getyr   r   r   r)   s     r   Ú_get_yzGEOSCoordSeq._get_yS   rC   r   c                 ój   — t          j        | j        |t          t	          ¦   «         ¦  «        ¦  «        S r?   )r@   Úcs_getzr   r   r   r)   s     r   Ú_get_zzGEOSCoordSeq._get_zV   rC   r   c                 ó<   — t          j        | j        ||¦  «         d S r?   )r@   Úcs_setxr   ©r   r*   r5   s      r   Ú_set_xzGEOSCoordSeq._set_xY   ó   € ÝŒ�T”X˜u eÑ,Ô,Ð,Ð,Ð,r   c                 ó<   — t          j        | j        ||¦  «         d S r?   )r@   Úcs_setyr   rL   s      r   Ú_set_yzGEOSCoordSeq._set_y\   rN   r   c                 ó<   — t          j        | j        ||¦  «         d S r?   )r@   Úcs_setzr   rL   s      r   Ú_set_zzGEOSCoordSeq._set_z_   rN   r   c                 óB   — | j         dk    r| j        r| j        n| j        S )Nr-   )r1   r   Ú_get_point_3dÚ_get_point_2dr    s    r   r(   zGEOSCoordSeq._point_getterb   s#   € à%)¤Y°!¢^ ^¸¼ ^ˆtÔ!Ð!ÀTÔEWÐWr   c                 óV   — |                       |¦  «        |                      |¦  «        fS r?   )rB   rF   r)   s     r   rW   zGEOSCoordSeq._get_point_2df   s%   € Ø—’˜EÑ"Ô" D§K¢K°Ñ$6Ô$6Ð7Ð7r   c                 ó~   — |                       |¦  «        |                      |¦  «        |                      |¦  «        fS r?   )rB   rF   rI   r)   s     r   rV   zGEOSCoordSeq._get_point_3di   s3   € Ø—’˜EÑ"Ô" D§K¢K°Ñ$6Ô$6¸¿ºÀEÑ8JÔ8JÐKÐKr   c                 óh   — |\  }}|                       ||¦  «         |                      ||¦  «         d S r?   )rM   rQ   )r   r*   r5   ÚxÚys        r   r3   zGEOSCoordSeq._set_point_2dl   s9   € Ø‰ˆˆ1Ø�Š�E˜1ÑÔÐØ�Š�E˜1ÑÔÐÐÐr   c                 ó–   — |\  }}}|                       ||¦  «         |                      ||¦  «         |                      ||¦  «         d S r?   )rM   rQ   rT   )r   r*   r5   r[   r\   r   s         r   r2   zGEOSCoordSeq._set_point_3dq   sO   € Ø‰ˆˆ1ˆaØ�Š�E˜1ÑÔÐØ�Š�E˜1ÑÔÐØ�Š�E˜1ÑÔÐÐÐr   c           	      óÀ   — |                       |¦  «         |                      |¦  «         t          j        | j        ||t          t          ¦   «         ¦  «        ¦  «        S )z3Return the value for the given dimension and index.)r'   r=   r@   Úcs_getordinater   r   r   )r   Ú	dimensionr*   s      r   ÚgetOrdinatezGEOSCoordSeq.getOrdinatex   sM   € à×Ò˜ÑÔÐØ�Š�yÑ!Ô!Ð!ÝÔ" 4¤8¨U°I½uÅXÁZÄZÑ?PÔ?PÑQÔQÐQr   c                 ó’   — |                       |¦  «         |                      |¦  «         t          j        | j        |||¦  «         dS )z0Set the value for the given dimension and index.N)r'   r=   r@   Úcs_setordinater   )r   r`   r*   r5   s       r   ÚsetOrdinatezGEOSCoordSeq.setOrdinate~   sG   € à×Ò˜ÑÔÐØ�Š�yÑ!Ô!Ð!ÝÔ˜DœH e¨Y¸Ñ>Ô>Ð>Ð>Ð>r   c                 ó.   — |                       d|¦  «        S )zGet the X value at the index.r   ©ra   r)   s     r   ÚgetXzGEOSCoordSeq.getX„   ó   € à×Ò  5Ñ)Ô)Ð)r   c                 ó4   — |                       d||¦  «         dS )z(Set X with the value at the given index.r   N©rd   rL   s      r   ÚsetXzGEOSCoordSeq.setXˆ   ó    € à×Ò˜˜E 5Ñ)Ô)Ð)Ð)Ð)r   c                 ó.   — |                       d|¦  «        S )z#Get the Y value at the given index.é   rf   r)   s     r   ÚgetYzGEOSCoordSeq.getYŒ   rh   r   c                 ó4   — |                       d||¦  «         dS )z(Set Y with the value at the given index.rn   Nrj   rL   s      r   ÚsetYzGEOSCoordSeq.setY�   rl   r   c                 ó.   — |                       d|¦  «        S )z(Get Z with the value at the given index.r.   rf   r)   s     r   ÚgetZzGEOSCoordSeq.getZ”   rh   r   c                 ó4   — |                       d||¦  «         dS )z(Set Z with the value at the given index.r.   Nrj   rL   s      r   ÚsetZzGEOSCoordSeq.setZ˜   rl   r   c                 óh   — t          j        | j        t          t	          ¦   «         ¦  «        ¦  «        S )z,Return the size of this coordinate sequence.)r@   Ú
cs_getsizer   r   r   r    s    r   r   zGEOSCoordSeq.size�   ó"   € õ Œ˜tœx­­v©x¬x©¬Ñ9Ô9Ð9r   c                 óh   — t          j        | j        t          t	          ¦   «         ¦  «        ¦  «        S )z2Return the dimensions of this coordinate sequence.)r@   Ú
cs_getdimsr   r   r   r    s    r   r1   zGEOSCoordSeq.dims¢   rx   r   c                 ó   — | j         S )zƒ
        Return whether this coordinate sequence is 3D. This property value is
        inherited from the parent Geometry.
        )r   r    s    r   ÚhaszzGEOSCoordSeq.hasz§   s   € ð Œwˆr   c                 óZ   — t          t          j        | j        ¦  «        | j        ¦  «        S )zClone this coordinate sequence.)r   r@   Úcs_cloner   r|   r    s    r   ÚclonezGEOSCoordSeq.clone°   s    € å�DœM¨$¬(Ñ3Ô3°T´YÑ?Ô?Ð?r   c           	      óÀ   ‡ ‡— ‰ j         rdŠndŠdd                     ˆ ˆfd„t          t          ‰ ¦  «        ¦  «        D ¦   «         ¦  «                             ¦   «         z  S )z2Return the KML representation for the coordinates.z	%s,%s,%s z%s,%s,0 z<coordinates>%s</coordinates>Ú c              3   ó.   •K  — | ]}‰‰|         z  V — Œd S r?   © )Ú.0r   r   Úsubstrs     €€r   ú	<genexpr>z#GEOSCoordSeq.kml.<locals>.<genexpr>¿   s,   øè è € ÐAÐA¨1�f˜t AœwÑ&ÐAÐAÐAÐAÐAÐAr   )r|   Újoinr   r4   Ústrip)r   r…   s   `@r   ÚkmlzGEOSCoordSeq.kml´   sk   øø€ ð
 Œ9ð 	 Ø ˆFˆFàˆFà+Ø�gŠgÐAÐAÐAÐAÐAµµc¸$±i´iÑ0@Ô0@ÐAÑAÔAÑAÔA×GÒGÑIÔIñJð	
r   c                 ó’   ‡— | j         }| j        Š|dk    r ‰d¦  «        S t          ˆfd„t          |¦  «        D ¦   «         ¦  «        S )z3Return a tuple version of this coordinate sequence.rn   r   c              3   ó.   •K  — | ]} ‰|¦  «        V — Œd S r?   rƒ   )r„   r   Ú	get_points     €r   r†   z%GEOSCoordSeq.tuple.<locals>.<genexpr>É   s+   øè è € Ð4Ð4 a�Y�Y˜q‘\”\Ð4Ð4Ð4Ð4Ð4Ð4r   )r   r(   r$   r   )r   ÚnrŒ   s     @r   r$   zGEOSCoordSeq.tupleÂ   sT   ø€ ð ŒIˆØÔ&ˆ	Ø�Š6ˆ6Ø�9˜Q‘<”<ÐÝÐ4Ð4Ð4Ð4­5°©8¬8Ð4Ñ4Ô4Ñ4Ô4Ð4r   c                 óÄ   — t          ¦   «         }t          j        | j        t	          |¦  «        ¦  «        s!t          dt          j        j        z  ¦  «        ‚|j        dk    S )z<Return whether this coordinate sequence is counterclockwise.z*Error encountered in GEOS C function "%s".rn   )r   r@   Ú	cs_is_ccwr   r   r
   Ú	func_namer5   )r   Úrets     r   Úis_counterclockwisez GEOSCoordSeq.is_counterclockwiseË   sV   € õ ‰hŒhˆÝŒ~˜dœh­¨c©
¬
Ñ3Ô3ð 	ÝØ<½t¼~Ô?WÑWñô ð ð Œy˜AŠ~Ðr   N)F))Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úptr_typer   r   r!   r%   r+   r8   r'   r=   rB   rF   rI   rM   rQ   rT   Úpropertyr(   rW   rV   r3   r2   ra   rd   rg   rk   ro   rq   rs   ru   r   r1   r|   r   r‰   r$   r’   rƒ   r   r   r   r      s‘  € € € € € ØMÐMà€Hðð ð ð ðð ð ð
ð ð ðð ð ð)ð )ð )ð
#ð #ð #ð0Hð Hð Hð
Ið Ið Ið
@ð @ð @ð@ð @ð @ð@ð @ð @ð-ð -ð -ð-ð -ð -ð-ð -ð -ð ðXð Xñ „XðXð8ð 8ð 8ðLð Lð Lðð ð ð
ð ð ðRð Rð Rð?ð ?ð ?ð*ð *ð *ð*ð *ð *ð*ð *ð *ð*ð *ð *ð*ð *ð *ð*ð *ð *ð
 ð:ð :ñ „Xð:ð ð:ð :ñ „Xð:ð ðð ñ „Xðð@ð @ð @ð ð
ð 
ñ „Xð
ð ð5ð 5ñ „Xð5ð ðð ñ „Xðð ð r   r   N)r–   Úctypesr   r   r   r   Údjango.contrib.gis.geosr   r@   Údjango.contrib.gis.geos.baser   Údjango.contrib.gis.geos.errorr
   Údjango.contrib.gis.geos.libgeosr   Údjango.contrib.gis.shortcutsr   r   rƒ   r   r   ú<module>rŸ      sÍ   ððð ð 3Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2à 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø 7Ð 7Ð 7Ð 7Ð 7Ð 7Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2Ø .Ð .Ð .Ð .Ð .Ð .ðCð Cð Cð Cð C�8ñ Cô Cð Cð Cð Cr   