
    h                     r    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  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)numpyc                   2   \ rS rSrSr\rS'S 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 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 5       r#\S 5       r$\S  5       r%S! r&\S" 5       r'\S# 5       r(\S$ 5       r)S%r*g&)(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      R/var/www/html/env/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                    [        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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_set_point_2dlenr,   )r   r/   valuen_argspoint_setters        r   __setitem__GEOSCoordSeq.__setitem__.   s     edE]++Uz%77T  99>dggF--LF--Lu:@AAU"r   c                 R    SUs=::  a  U R                   :  d  O  [        SU-  5      eg)zCheck the given index.r   zinvalid GEOS Geometry index: %sN)r   
IndexErrorr.   s     r   r,   GEOSCoordSeq._checkindexF   s)    U&TYY&>FGG 'r   c                 8    US:  d  US:  a  [        SU-  5      eg)zCheck the given dimension.r   r4   zinvalid ordinate dimension "%d"Nr	   )r   dims     r   	_checkdimGEOSCoordSeq._checkdimK   s%    7cAg AC GHH r   c                 h    [         R                  " U R                  U[        [	        5       5      5      $ N)capics_getxr   r   r   r.   s     r   _get_xGEOSCoordSeq._get_xP        ||DHHeU8:->??r   c                 h    [         R                  " U R                  U[        [	        5       5      5      $ rH   )rI   cs_getyr   r   r   r.   s     r   _get_yGEOSCoordSeq._get_yS   rM   r   c                 h    [         R                  " U R                  U[        [	        5       5      5      $ rH   )rI   cs_getzr   r   r   r.   s     r   _get_zGEOSCoordSeq._get_zV   rM   r   c                 F    [         R                  " U R                  X5        g rH   )rI   cs_setxr   r   r/   r;   s      r   _set_xGEOSCoordSeq._set_xY       TXXu,r   c                 F    [         R                  " U R                  X5        g rH   )rI   cs_setyr   rX   s      r   _set_yGEOSCoordSeq._set_y\   r[   r   c                 F    [         R                  " U R                  X5        g rH   )rI   cs_setzr   rX   s      r   _set_zGEOSCoordSeq._set_z_   r[   r   c                 t    U R                   S:X  a  U R                  (       a  U R                  $ U R                  $ )Nr3   )r7   r   _get_point_3d_get_point_2dr#   s    r   r-   GEOSCoordSeq._point_getterb   s)    %)YY!^t!!WTEWEWWr   c                 F    U R                  U5      U R                  U5      4$ rH   )rK   rP   r.   s     r   rf   GEOSCoordSeq._get_point_2df   s    E"DKK$677r   c                 f    U R                  U5      U R                  U5      U R                  U5      4$ rH   )rK   rP   rT   r.   s     r   re   GEOSCoordSeq._get_point_3di   s*    E"DKK$6E8JKKr   c                 P    Uu  p4U R                  X5        U R                  X5        g rH   )rY   r^   )r   r/   r;   xys        r   r9   GEOSCoordSeq._set_point_2dl   s!    EEr   c                 t    Uu  p4nU R                  X5        U R                  X5        U R                  X5        g rH   )rY   r^   rb   )r   r/   r;   rm   rn   r   s         r   r8   GEOSCoordSeq._set_point_3dq   s/    a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,   rE   rI   cs_getordinater   r   r   )r   	dimensionr/   s      r   getOrdinateGEOSCoordSeq.getOrdinatex   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,   rE   rI   cs_setordinater   )r   rt   r/   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   ru   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ry   rX   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   rX   s      r   setYGEOSCoordSeq.setY   r   r   c                 &    U R                  SU5      $ )z(Get Z with the value at the given index.r4   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.r4   Nr   rX   s      r   setZGEOSCoordSeq.setZ   r   r   c                 f    [         R                  " U R                  [        [	        5       5      5      $ )z,Return the size of this coordinate sequence.)rI   
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.)rI   
cs_getdimsr   r   r   r#   s    r   r7   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                 j    [        [        R                  " U R                  5      U R                  5      $ )zClone this coordinate sequence.)r   rI   cs_cloner   r   r#   s    r   cloneGEOSCoordSeq.clone   s     DMM$((3TYY??r   c           	         ^ ^ T R                   (       a  SmOSmSSR                  U U4S j[        [        T 5      5       5       5      R	                  5       -  $ )z2Return the KML representation for the coordinates.z	%s,%s,%s z%s,%s,0 z<coordinates>%s</coordinates> c              3   4   >#    U  H  nTTU   -  v   M     g 7frH    ).0r   r   substrs     r   	<genexpr>#GEOSCoordSeq.kml.<locals>.<genexpr>   s     A0@1ftAw&0@   )r   joinr   r:   strip)r   r   s   `@r   kmlGEOSCoordSeq.kml   sH    
 99 FF+ggAc$i0@AAGGIJ	
r   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rH   r   )r   r   	get_points     r   r   %GEOSCoordSeq.tuple.<locals>.<genexpr>   s     48aYq\\8r   )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   rI   	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)+__name__
__module____qualname____firstlineno____doc__r   ptr_typer   r    r$   r)   r0   r>   r,   rE   rK   rP   rT   rY   r^   rb   propertyr-   rf   re   r9   r8   ru   ry   r}   r   r   r   r   r   r   r7   r   r   r   r(   r   __static_attributes__r   r   r   r   r      s'   MH
)
#0H
I
@@@--- X X8L
R?******
 : : : :  @ 
 
 5 5  r   r   N)r   ctypesr   r   r   r   django.contrib.gis.geosr   rI   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 6 1 7 2 .C8 Cr   