
    jl"                     v    S r SSKJrJrJrJr  SSKJr  SSK	J
r
  SSKJr  SSKJrJr  SSKJr   " S S	\
5      rg
)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geos_version_tuple)numpyc                   r   \ rS rSrSr\rS0S jrS rS r	S r
S rS rS	 rS
 rS rS rS rS rS rS rS rS r\S 5       rS rS rS rS rS rS rS rS r S r!S r"S r#S r$S  r%S! r&S" r'S# r(S$ r)S% r*\S& 5       r+\S' 5       r,\S( 5       r-\S) 5       r.S* r/\S+ 5       r0\S, 5       r1\S- 5       r2S.r3g/)1GEOSCoordSeq   zGThe internal representation of a list of coordinates inside a Geometry.c                 \    [        U[        5      (       d  [        S5      eXl        X l        g)zInitialize from a GEOS pointer.z4Coordinate sequence should initialize with a CS_PTR.N)
isinstancer   	TypeError_ptr_z)selfptrzs      X/var/www/html/KUNJ/venv/lib/python3.13/site-packages/django/contrib/gis/geos/coordseq.py__init__GEOSCoordSeq.__init__   s'     #v&&RSS	    c              #   P   #    [        U R                  5       H	  nX   v   M     g7f)z3Iterate over each point in the coordinate sequence.N)rangesize)r   is     r   __iter__GEOSCoordSeq.__iter__   s     tyy!A'M "s   $&c                     U R                   $ )z7Return the number of points in the coordinate sequence.)r   r   s    r   __len__GEOSCoordSeq.__len__#   s    yyr   c                 ,    [        U R                  5      $ )z<Return the string representation of the coordinate sequence.)strtupler$   s    r   __str__GEOSCoordSeq.__str__'   s    4::r   c                 F    U R                  U5        U R                  U5      $ )z8Return the coordinate sequence value at the given index.)_checkindex_point_getterr   indexs     r   __getitem__GEOSCoordSeq.__getitem__+   s!    !!%((r   c                 l   [        U[        [        45      (       a  O6[        (       a   [        U[        R                  5      (       a  O[        S5      eU R                  S:X  a   U R                  (       a  SnU R                  nOU R                  S:X  a   U R                  (       a  SnU R                  nOOU R                  S:X  a1  U R                  (       a   U R                  (       a  SnU R                  nOSnU R                  n[        U5      U:w  a  [        S5      eU R                  U5        U" X5        g)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hasm_set_point_3d_m_set_point_4d_set_point_2dlenr-   )r   r0   valuen_argspoint_setters        r   __setitem__GEOSCoordSeq.__setitem__0   s     edE]++Uz%77T  99>dggF--LYY!^		F//LYY!^DIIF--LF--Lu:@AAU"r   c                 R    SUs=::  a  U R                   :  d  O  [        SU 35      eg)zCheck the given index.r   zInvalid GEOS Geometry index: N)r   
IndexErrorr/   s     r   r-   GEOSCoordSeq._checkindexN   s+    U&TYY&<UGDEE 'r   c                 <    US:  d  US:  a  [        SUS S35      eg)zCheck the given dimension.r   r4   zInvalid ordinate dimension: "d"Nr	   )r   dims     r   	_checkdimGEOSCoordSeq._checkdimS   s+    7cAg"?Awa HII r   c                 h    [         R                  " U R                  U[        [	        5       5      5      $ N)capics_getxr   r   r   r/   s     r   _get_xGEOSCoordSeq._get_xX        ||DHHeU8:->??r   c                 h    [         R                  " U R                  U[        [	        5       5      5      $ rO   )rP   cs_getyr   r   r   r/   s     r   _get_yGEOSCoordSeq._get_y[   rT   r   c                 h    [         R                  " U R                  U[        [	        5       5      5      $ rO   )rP   cs_getzr   r   r   r/   s     r   _get_zGEOSCoordSeq._get_z^   rT   r   c                 h    [         R                  " U R                  U[        [	        5       5      5      $ rO   )rP   cs_getmr   r   r   r/   s     r   _get_mGEOSCoordSeq._get_ma   rT   r   c                 F    [         R                  " U R                  X5        g rO   )rP   cs_setxr   r   r0   r@   s      r   _set_xGEOSCoordSeq._set_xd       TXXu,r   c                 F    [         R                  " U R                  X5        g rO   )rP   cs_setyr   rc   s      r   _set_yGEOSCoordSeq._set_yg   rf   r   c                 F    [         R                  " U R                  X5        g rO   )rP   cs_setzr   rc   s      r   _set_zGEOSCoordSeq._set_zj   rf   r   c                 F    [         R                  " U R                  X5        g rO   )rP   cs_setmr   rc   s      r   _set_mGEOSCoordSeq._set_mm   rf   r   c                 J   U R                   S:X  a  U R                  (       a  U R                  $ U R                   S:X  a  U R                  (       a  U R                  $ U R                   S:X  a.  U R                  (       a  U R                  (       a  U R
                  $ U R                  $ )Nr4   r5   )r9   r   _get_point_3dr;   _get_point_3d_m_get_point_4d_get_point_2dr$   s    r   r.   GEOSCoordSeq._point_getterp   sk    99>dgg%%%YY!^		'''YY!^DII%%%!!!r   c                 F    U R                  U5      U R                  U5      4$ rO   )rR   rW   r/   s     r   rw   GEOSCoordSeq._get_point_2dz   s    E"DKK$677r   c                 f    U R                  U5      U R                  U5      U R                  U5      4$ rO   )rR   rW   r[   r/   s     r   rt   GEOSCoordSeq._get_point_3d}   *    E"DKK$6E8JKKr   c                 f    U R                  U5      U R                  U5      U R                  U5      4$ rO   )rR   rW   r_   r/   s     r   ru   GEOSCoordSeq._get_point_3d_m   r}   r   c                     U R                  U5      U R                  U5      U R                  U5      U R                  U5      4$ rO   )rR   rW   r[   r_   r/   s     r   rv   GEOSCoordSeq._get_point_4d   s<    KKKKKKKK	
 	
r   c                 P    Uu  p4U R                  X5        U R                  X5        g rO   )rd   ri   )r   r0   r@   xys        r   r>   GEOSCoordSeq._set_point_2d   s!    EEr   c                 t    Uu  p4nU R                  X5        U R                  X5        U R                  X5        g rO   )rd   ri   rm   )r   r0   r@   r   r   r   s         r   r:   GEOSCoordSeq._set_point_3d   /    aEEEr   c                 t    Uu  p4nU R                  X5        U R                  X5        U R                  X5        g rO   )rd   ri   rq   )r   r0   r@   r   r   ms         r   r<   GEOSCoordSeq._set_point_3d_m   r   r   c                     Uu  p4pVU R                  X5        U R                  X5        U R                  X5        U R                  X5        g rO   )rd   ri   rm   rq   )r   r0   r@   r   r   r   r   s          r   r=   GEOSCoordSeq._set_point_4d   s;    
aEEEEr   c           	          U R                  U5        U R                  U5        [        R                  " U R                  X![        [        5       5      5      $ )z3Return the value for the given dimension and index.)r-   rL   rP   cs_getordinater   r   r   )r   	dimensionr0   s      r   getOrdinateGEOSCoordSeq.getOrdinate   s<    y!""488UuXZ?PQQr   c                     U R                  U5        U R                  U5        [        R                  " U R                  X!U5        g)z0Set the value for the given dimension and index.N)r-   rL   rP   cs_setordinater   )r   r   r0   r@   s       r   setOrdinateGEOSCoordSeq.setOrdinate   s2    y!DHHe>r   c                 &    U R                  SU5      $ )zGet the X value at the index.r   r   r/   s     r   getXGEOSCoordSeq.getX       5))r   c                 (    U R                  SX5        g)z(Set X with the value at the given index.r   Nr   rc   s      r   setXGEOSCoordSeq.setX       E)r   c                 &    U R                  SU5      $ )z#Get the Y value at the given index.   r   r/   s     r   getYGEOSCoordSeq.getY   r   r   c                 (    U R                  SX5        g)z(Set Y with the value at the given index.r   Nr   rc   s      r   setYGEOSCoordSeq.setY   r   r   c                 &    U R                  SU5      $ )z(Get Z with the value at the given index.r6   r   r/   s     r   getZGEOSCoordSeq.getZ   r   r   c                 (    U R                  SX5        g)z(Set Z with the value at the given index.r6   Nr   rc   s      r   setZGEOSCoordSeq.setZ   r   r   c                 &    U R                  SU5      $ )z(Get M with the value at the given index.r4   r   r/   s     r   getMGEOSCoordSeq.getM   r   r   c                 (    U R                  SX5        g)z(Set M with the value at the given index.r4   Nr   rc   s      r   setMGEOSCoordSeq.setM   r   r   c                 f    [         R                  " U R                  [        [	        5       5      5      $ )z,Return the size of this coordinate sequence.)rP   
cs_getsizer   r   r   r$   s    r   r   GEOSCoordSeq.size        txxvx99r   c                 f    [         R                  " U R                  [        [	        5       5      5      $ )z2Return the dimensions of this coordinate sequence.)rP   
cs_getdimsr   r   r   r$   s    r   r9   GEOSCoordSeq.dims   r   r   c                     U R                   $ )zk
Return whether this coordinate sequence is 3D. This property value is
inherited from the parent Geometry.
)r   r$   s    r   haszGEOSCoordSeq.hasz   s     wwr   c                 t    [        5       S:  a   [        R                  " U R                  5      $ [	        S5      e)z:
Return whether this coordinate sequence has M dimension.
)r4      z5GEOSCoordSeq with an M dimension requires GEOS 3.14+.)r   rP   cs_hasmr   NotImplementedErrorr$   s    r   r;   GEOSCoordSeq.hasm   s2    
 7*<<		**%G r   c                 j    [        [        R                  " U R                  5      U R                  5      $ )zClone this coordinate sequence.)r   rP   cs_cloner   r   r$   s    r   cloneGEOSCoordSeq.clone   s     DMM$((3TYY??r   c           	          U R                   (       a#  U  Vs/ s H  oS    SUS    SUS    3PM     nnOU  Vs/ s H  oS    SUS    S3PM     nnSR                  U5      nSU S3$ s  snf s  snf )	z2Return the KML representation for the coordinates.r   ,r   r6   z,0 z<coordinates>z</coordinates>)r   join)r   coordcoordscoordinate_strings       r   kmlGEOSCoordSeq.kml   s     99GKLteq
!E!H:QuQxj9tFLF>BCdUq
!E!H:R0dFCHHV,01@@ MCs
   A)A.c                    ^ U R                   nU R                  mUS:X  a  T" S5      $ [        U4S j[        U5       5       5      $ )z3Return a tuple version of this coordinate sequence.r   r   c              3   4   >#    U  H  nT" U5      v   M     g 7frO    ).0r    	get_points     r   	<genexpr>%GEOSCoordSeq.tuple.<locals>.<genexpr>  s     48aYq\\8s   )r   r.   r)   r   )r   nr   s     @r   r)   GEOSCoordSeq.tuple   s?     II&&	6Q<458444r   c                     [        5       n[        R                  " U R                  [	        U5      5      (       d&  [        S[        R                  R                  -  5      eUR                  S:H  $ )z<Return whether this coordinate sequence is counterclockwise.z*Error encountered in GEOS C function "%s".r   )r   rP   	cs_is_ccwr   r   r
   	func_namer@   )r   rets     r   is_counterclockwise GEOSCoordSeq.is_counterclockwise  sS     h~~dhhc
33<t~~?W?WW  yyA~r   )r   r   N)F)4__name__
__module____qualname____firstlineno____doc__r   ptr_typer   r!   r%   r*   r1   rC   r-   rL   rR   rW   r[   r_   rd   ri   rm   rq   propertyr.   rw   rt   ru   rv   r>   r:   r<   r=   r   r   r   r   r   r   r   r   r   r   r   r9   r   r;   r   r   r)   r   __static_attributes__r   r   r   r   r      se   MH
)
#<F
J
@@@@---- " "8LL

R?********
 : : : :   	 	@ A A 5 5  r   r   N)r   ctypesr   r   r   r   django.contrib.gis.geosr   rP   django.contrib.gis.geos.baser   django.contrib.gis.geos.errorr
   django.contrib.gis.geos.libgeosr   r   django.contrib.gis.shortcutsr   r   r   r   r   <module>r      s/    3 2 6 1 7 F .@8 @r   