
    \iN                         % S r SSKJr  SSKrSSKrS/rSrSrSr\	\
S'    " S	 S
\5      r " S S\5      r " S S\5      rS rS\	4S jr " S S\" SS5      5      r\" SSSSSS5      r S\4S jrS\4S jrg)zAffine transformation matrices

The Affine package is derived from Casey Duncan's Planar package. See the
copyright statement below.
    )
namedtupleNAffinezSean Gilliesz2.4.0gh㈵>EPSILONc                       \ rS rSrSrg)AffineError/    N)__name__
__module____qualname____firstlineno____static_attributes__r	       R/var/www/html/kml_chatgpt/mouzaenv/lib/python3.13/site-packages/affine/__init__.pyr   r   /   s    r   r   c                       \ rS rSrSrSrg)TransformNotInvertibleError3   z#The transform could not be invertedr	   Nr
   r   r   r   __doc__r   r	   r   r   r   r   3   s    -r   r   c                       \ rS rSrSrSrg)UndefinedRotationError7   z;The rotation angle could not be computed for this transformr	   Nr   r	   r   r   r   r   7   s    Er   r   c                 d   ^  T R                   nT R                  nU4U 4S jjnXl        [        X2S9$ )zSpecial property decorator that caches the computed
property value in the object's instance dict the first
time it is accessed.
c                 v   >  U R                   U   $ ! [         a    T" U 5      =U R                   U'   nUs $ f = fN)__dict__KeyError)selfnamevaluefuncs      r   gettercached_property.<locals>.getterC   sB    	==&& 	*.t*4DMM$%L	s    #88)doc)r
   r   	func_nameproperty)r!   r   r$   r"   s   `   r   cached_propertyr'   ;   s2    
 ==D
,,C  F$$r   degc                     U S-  n U S:X  a  gU S:X  a  gU S:X  a  g[         R                  " U 5      n[         R                  " U5      [         R                  " U5      4$ )zReturn the cosine and sin for the given angle in degrees.

With special-case handling of multiples of 90 for perfect right
angles.
g     v@g     V@)              ?g     f@)      r   g     p@)r   r,   )mathradianscossin)r(   rads     r   cos_sin_degr2   N   sT     +C
d{		
,,s
C88C=$((3-''r   c                      \ rS rSrSr\r   S7S\S\S\S\S\S\S	\S
\S\4S jjr\	S\S\S\S\S\S\4S j5       r
\	S 5       r\	S\S\4S j5       r\	S 5       r\	S8S\S\4S jj5       r\	S9S\4S jj5       r\	S 5       rS\4S jrS\4S jrS rS r\S\4S j5       r\S\4S  j5       r\S\4S! j5       r\S" 5       r\S\4S# j5       r\S\4S$ j5       r\S\4S% j5       r\S\4S& j5       r \S\4S' j5       r!\S\4S( j5       r"\S\4S) j5       r#\S\4S* j5       r$\S+ 5       r%\4S,\S\4S- jjr&S\4S. jr'\'=r(=r)r*S/ r+\+r,S0 r-S1 r.S2 r/S:S3 jr0S4 r1\2Rf                  r3S5 r4S6r5g);r   _   aD  Two dimensional affine transform for 2D linear mapping.

Parameters
----------
a, b, c, d, e, f : float
    Coefficients of an augmented affine transformation matrix

    | x' |   | a  b  c | | x |
    | y' | = | d  e  f | | y |
    | 1  |   | 0  0  1 | | 1 |

    `a`, `b`, and `c` are the elements of the first row of the
    matrix. `d`, `e`, and `f` are the elements of the second row.

Attributes
----------
a, b, c, d, e, f, g, h, i : float
    The coefficients of the 3x3 augmented affine transformation
    matrix

    | x' |   | a  b  c | | x |
    | y' | = | d  e  f | | y |
    | 1  |   | g  h  i | | 1 |

    `g`, `h`, and `i` are always 0, 0, and 1.

The Affine package is derived from Casey Duncan's Planar package.
See the copyright statement below.  Parallel lines are preserved by
these transforms. Affine transforms can perform any combination of
translations, scales/flips, shears, and rotations.  Class methods
are provided to conveniently compose transforms from these
operations.

Internally the transform is stored as a 3x3 transformation matrix.
The transform may be constructed directly by specifying the first
two rows of matrix values as 6 floats. Since the matrix is an affine
transform, the last row is always ``(0, 0, 1)``.

N.B.: multiplication of a transform and an (x, y) vector *always*
returns the column vector that is the matrix multiplication product
of the transform and (x, y) as a column vector, no matter which is
on the left or right side. This is obviously not the case for
matrices and vectors in general, but provides a convenience for
users of this class.

abcdefghic
                 v    [         R                  U US-  US-  US-  US-  US-  US-  US-  US-  U	S-  4	5      $ )zCreate a new object

Parameters
----------
a, b, c, d, e, f : float
    Elements of an augmented affine transformation matrix.
r+   tuple__new__)
clsr5   r6   r7   r8   r9   r:   r;   r<   r=   s
             r   rA   Affine.__new__   s\    & }}CCCCCCCCC

 	
r   c           	      *    U R                  XX1XVU5      $ )z{Use same coefficient order as GDAL's GetGeoTransform().

:param c, a, b, f, d, e: 6 floats ordered by GDAL.
:rtype: Affine
)rA   )rB   r7   r5   r6   r:   r8   r9   s          r   	from_gdalAffine.from_gdal   s     {{31q11r   c                     [         $ )z/Return the identity transform.

:rtype: Affine
)identity)rB   s    r   rH   Affine.identity   s	     r   xoffyoffc                 @    [         R                  U SSUSSUSSS4	5      $ )zCreate a translation transform from an offset vector.

:param xoff: Translation x offset.
:type xoff: float
:param yoff: Translation y offset.
:type yoff: float
:rtype: Affine
r+   r*   r?   )rB   rJ   rK   s      r   translationAffine.translation   s(     }}S3T3T3S"QRRr   c                     [        U5      S:X  a  [        US   5      =p#OUu  p#[        R                  XSSSUSSSS4	5      $ )a  Create a scaling transform from a scalar or vector.

:param scaling: The scaling factor. A scalar value will
    scale in both dimensions equally. A vector scaling
    value scales the dimensions independently.
:type scaling: float or sequence
:rtype: Affine
   r   r*   r+   )lenfloatr@   rA   )rB   scalingsxsys       r   scaleAffine.scale   sL     w<1GAJ''BFB}}SsCb#sC"MNNr   x_angley_anglec                     [         R                  " [         R                  " U5      5      n[         R                  " [         R                  " U5      5      n[        R	                  U SUSUSSSSS4	5      $ )zCreate a shear transform along one or both axes.

:param x_angle: Shear angle in degrees parallel to the x-axis.
:type x_angle: float
:param y_angle: Shear angle in degrees parallel to the y-axis.
:type y_angle: float
:rtype: Affine
r+   r*   )r-   tanr.   r@   rA   )rB   rX   rY   mxmys        r   shearAffine.shear   sV     XXdll7+,XXdll7+,}}S3CS#sC"MNNr   Nanglec                     [        U5      u  p4Uc  [        R                  XU* SXCSSSS4	5      $ Uu  pV[        R                  U UU* XUU-  -
  Xd-  -   UUXeU-  -
  Xc-  -
  SSS4	5      $ )am  Create a rotation transform at the specified angle.

A pivot point other than the coordinate system origin may be
optionally specified.

:param angle: Rotation angle in degrees, counter-clockwise
    about the pivot point.
:type angle: float
:param pivot: Point to rotate about, if omitted the rotation is
    about the origin.
:type pivot: sequence
:rtype: Affine
r*   r+   )r2   r@   rA   )rB   r`   pivotcasapxpys          r   rotationAffine.rotation   s     U#===B3RS#sC&PQQFB==CbL27*bL27*
 r   c                 .    [         R                  U S5      $ )zCreate the permutation transform

For 2x2 matrices, there is only one permutation matrix that is
not the identity.

:rtype: Affine
)	r*   r+   r*   r+   r*   r*   r*   r*   r+   r?   )rB   rS   s     r   permutationAffine.permutation  s     }}S"OPPr   returnc                     SU -  $ )zConcise string representation.z;|% .2f,% .2f,% .2f|
|% .2f,% .2f,% .2f|
|% .2f,% .2f,% .2f|r	   r   s    r   __str__Affine.__str__  s     R 	r   c                     SU SS -  $ )zPrecise string representation.z%Affine(%r, %r, %r,
       %r, %r, %r)N   r	   rn   s    r   __repr__Affine.__repr__#  s    ;tBQxGGr   c                     U R                   U R                  U R                  U R                  U R                  U R
                  4$ )zJReturn same coefficient order as GDAL's SetGeoTransform().

:rtype: tuple
)r7   r5   r6   r:   r8   r9   rn   s    r   to_gdalAffine.to_gdal'  s/    
 ??r   c                     U R                   U R                  U R                  U R                  U R                  U R
                  4$ )zReturn an affine transformation matrix compatible with shapely

Shapely's affinity module expects an affine transformation matrix
in (a,b,d,e,xoff,yoff) order.

:rtype: tuple
)r5   r6   r8   r9   rJ   rK   rn   s    r   
to_shapelyAffine.to_shapely.  s/     		499EEr   c                     U R                   $ )zAlias for 'c')r7   rn   s    r   rJ   Affine.xoff8       vvr   c                     U R                   $ )zAlias for 'f')r:   rn   s    r   rK   Affine.yoff=  r}   r   c           	      $    U u	  pp4pVpxn	X-  X$-  -
  $ )zThe determinant of the transform matrix.

This value is equal to the area scaling factor when the
transform is applied to a shape.
r	   
r   r5   r6   r7   r8   r9   r:   r;   r<   r=   s
             r   determinantAffine.determinantB  s"     %)!aA!uqu}r   c           	      H   U u	  pp4n      nUS-  US-  -   US-  -   US-  -   nX-  X$-  -
  S-  nUS-  S-  U-
  nUS:  a  Sn[         R                  " US-  [         R                  " U5      -   5      n	[         R                  " US-  [         R                  " U5      -
  5      n
X4$ )zThe absolute scaling factors of the transformation.

This tuple represents the absolute value of the scaling factors of the
transformation, sorted from bigger to smaller.
      g-q=r   )r-   sqrt)r   r5   r6   _r8   r9   tracedetdeltal1l2s              r   _scalingAffine._scalingL  s     %)!aAq!Q
 Qa!q&(161uqu}"
Q$5=EYYuqy499U#334YYuqy499U#334vr   c                 b    U R                   u  p[        R                  " US-  US-  -
  5      U-  $ )zThe eccentricity of the affine transformation.

This value represents the eccentricity of an ellipse under
this affine transformation.

Raises NotImplementedError for improper transformations.
r   )r   r-   r   )r   r   r   s      r   eccentricityAffine.eccentricityc  s0     yyq27*+b00r   c           	          U u	  pp4n      nU R                   (       d  U R                  (       a?  U R                  u  pcXF-  X-  p[        R                  " Xx5      S-  [        R
                  -  $ [        e)a  The rotation angle in degrees of the affine transformation.

This is the rotation angle in degrees of the affine transformation,
assuming it is in the form M = R S, where R is a rotation and S is a
scaling.

Raises UndefinedRotationError for improper and degenerate
transformations.
   )	is_properis_degenerater   r-   atan2pir   )	r   r5   r6   r   r7   r8   r   yxs	            r   rotation_angleAffine.rotation_angleo  s`     %)!aAq!Q>>T//MMEB616q::a#c)DGG33((r   c                 `    U [         L =(       d     U R                  [         U R                  5      $ )zKTrue if this transform equals the identity matrix,
within rounding limits.
)rH   almost_equals	precisionrn   s    r   is_identityAffine.is_identity  s%    
 xO4#5#5h#OOr   c           	          U u	  pp4pVpxn	[        U5      U R                  :  =(       a    [        U5      U R                  :  =(       d7    [        U5      U R                  :  =(       a    [        U5      U R                  :  $ )zTrue if the transform is rectilinear.

i.e., whether a shape would remain axis-aligned, within rounding
limits, after applying the transform.
absr   r   s
             r   is_rectilinearAffine.is_rectilinear  sb     %)!aA!A'CCFT^^,C 
FT^^#?A(?	
r   c           	      P    U u	  pp4pVpxn	[        X-  XE-  -   5      U R                  :  $ )zTrue if the transform is conformal.

i.e., if angles between points are preserved after applying the
transform, within rounding limits.  This implies that the
transform has no effective shear.
r   r   s
             r   is_conformalAffine.is_conformal  s0     %)!aA!1515=!DNN22r   c           	          U u	  pp4pVpxn	U R                   =(       aK    [        SX-  XD-  -   -
  5      U R                  :  =(       a"    [        SX"-  XU-  -   -
  5      U R                  :  $ )aI  True if the transform is orthonormal.

Which means that the transform represents a rigid motion, which
has no effective scaling or shear. Mathematically, this means
that the axis vectors of the transform matrix are perpendicular
and unit-length.  Applying an orthonormal transform to a shape
always results in a congruent shape.
r+   )r   r   r   r   s
             r   is_orthonormalAffine.is_orthonormal  sh     %)!aA! <C1515=)*T^^;<C1515=)*T^^;	
r   c                      U R                   S:H  $ )zTrue if this transform is degenerate.

Which means that it will collapse a shape to an effective area
of zero. Degenerate transforms cannot be inverted.
r*   r   rn   s    r   r   Affine.is_degenerate  s     3&&r   c                      U R                   S:  $ )zTTrue if this transform is proper.

Which means that it does not include reflection.
r*   r   rn   s    r   r   Affine.is_proper  s     #%%r   c           	      $    U u	  pp4pV    nX4X%4X644$ )z6The values of the transform as three 2D column vectorsr	   )r   r5   r6   r7   r8   r9   r:   r   s           r   column_vectorsAffine.column_vectors  s)     %)!aA!Qvvv%%r   r   c                 F    S H  n[        X   X   -
  5      U:  d  M    g   g)zCompare transforms for approximate equality.

:param other: Transform being compared.
:type other: Affine
:return: True if absolute difference between each element
    of each respective transform matrix < ``self.precision``.
)r   rP   r      r      FT)r   )r   otherr   r=   s       r   r   Affine.almost_equals  s,     $A47UX%&)3 $ r   c                     [         $ r   )NotImplementedr   r   s     r   __gt__Affine.__gt__  s    r   c                     [        S5      e)NzOperation not supported)	TypeErrorr   s     r   __add__Affine.__add__  s    122r   c                 z   U u	  p#pEpg    n[        U[        5      (       ab  Uu	  ppp    n[        R                  U R                  X)-  X<-  -   X*-  X=-  -   X+-  X>-  -   U-   XY-  Xl-  -   XZ-  Xm-  -   X[-  Xn-  -   U-   SSS4	5      $  Uu  nnX-  UU-  -   U-   X-  UU-  -   U-   4$ ! [
        [        4 a	    [        s $ f = f)ah  Multiplication

Apply the transform using matrix multiplication, creating
a resulting object of the same type.  A transform may be applied
to another transform, a vector, vector array, or shape.

:param other: The object to transform.
:type other: Affine, :class:`~planar.Vec2`,
    :class:`~planar.Vec2Array`, :class:`~planar.Shape`
:rtype: Same as ``other``
r*   r+   )
isinstancer   r@   rA   	__class__
ValueErrorr   r   )r   r   rd   sbscsdsesfr   oaobocodoeofvxvys                    r   __mul__Affine.__mul__  s     +/'1aeV$$.3+BBBAq!==Gbg%Gbg%Gbg%*Gbg%Gbg%Gbg%*
 &B"r')B."r'0AB0FGG	* &%%&s   B! !B:9B:c                     [         R                  " S[        SS9  [        U[        5      (       a   eU R                  U5      $ )a4  Right hand multiplication

.. deprecated:: 2.3.0
    Right multiplication will be prohibited in version 3.0. This method
    will raise AffineError.

Notes
-----
We should not be called if other is an affine instance This is
just a guarantee, since we would potentially return the wrong
answer in that case.
z6Right multiplication will be prohibited in version 3.0r   )
stacklevel)warningswarnDeprecationWarningr   r   r   r   s     r   __rmul__Affine.__rmul__  s=     	D	

 eV,,,,||E""r   c                     [        U[        5      (       d  [        U[        5      (       a  U R                  U5      $ [        $ r   )r   r   r@   r   r   r   s     r   __imul__Affine.__imul__  s0    eV$$
5%(@(@<<&&!!r   c           	          U [         LaF  U [         :w  a;  U u	  p#pEpg    n[        U5       H"  u  n	u  pX-  X-  -   U-   X-  X-  -   U-   4X'   M$     ggg)zTransform a sequence of points or vectors in place.

:param seq: Mutable sequence of :class:`~planar.Vec2` to be
    transformed.
:returns: None, the input sequence is mutated in place.
N)rH   	enumerate)r   seqrd   r   r   r   r   r   r   r=   r   r   s               r   
itransformAffine.itransform"  sg     xDH$4.2+BBBAq!&s^	6A&16/B."0DE , %5r   c                    U R                   (       a  [        S5      eSU R                  -  nU u	  p#pEpg    nXa-  n	U* U-  n
U* U-  nX!-  n[        R	                  U R
                  XU* U	-  Xz-  -
  XU* U-  X|-  -
  SSS4	5      $ )zmReturn the inverse transform.

:raises: :except:`TransformNotInvertible` if the transform
    is degenerate.
z"Cannot invert degenerate transformr+   r*   )r   r   r   r@   rA   r   )r   idetrd   r   r   r   r   r   r   rarbrdres                r   
__invert__Affine.__invert__.  s     -.RSST%%%*.'1aYS4ZS4ZY}}NNbS2X'"rBG1CS#sS
 	
r   c                     U R                   U R                  U R                  U R                  U R                  U R
                  4$ )zPickle protocol support

Notes
-----
Normal unpickling creates a situation where __new__ receives all
9 elements rather than the 6 that are required for the
constructor.  This method ensures that only the 6 are provided.
)r5   r6   r7   r8   r9   r:   rn   s    r   __getnewargs__Affine.__getnewargs__C  s/     vvtvvtvvtvvtvvtvv==r   r	   )r*   r*   r+   )r   r   r   )rl   N)6r
   r   r   r   r   r   r   rR   rA   classmethodrE   rH   rM   rV   r^   rg   rj   strro   rs   rv   ry   r&   rJ   rK   r'   r   r   r   r   boolr   r   r   r   r   r   r   r   r   __ge____lt____le__r   __iadd__r   r   r   r   r   r@   __hash__r   r   r	   r   r   r   r   _   sD   -^ I  
 
  
 	 

  
  
  
  
  
  
D 2% 2E 2e 2 2% 2E 2 2   	Su 	SE 	S 	S O O OE O O O  U    D 	Q 	Q H# H@F e   e   U    , 	1e 	1 	1 ) ) )$ PT P P 	
 	
 	
 3d 3 3 
 
 
  't ' ' &4 & & & &
 7> e $ t   &%F%Vf3 H"&H#*"
F
& ~~H	>r   )	r5   r6   r7   r8   r9   r:   r;   r<   r=   rP   sc                 2   [        U S5      (       d  [        S5      eU R                  5       n[        U5      S:w  a  [	        S[        U5      -  5      eS U 5       u  p#pEpg[
        R                  [        X$XcXWSSS/	5      nU[        R                  SS5      -  $ )	zReturns Affine from the contents of a world file string.

This method also translates the coefficients from center- to
corner-based coordinates.

:param s: str with 6 floats ordered in a world file.
:rtype: Affine
splitzCannot split input stringrr   z!Expected 6 coefficients, found %dc              3   8   #    U  H  n[        U5      v   M     g 7fr   )rR   ).0r   s     r   	<genexpr>loadsw.<locals>.<genexpr>c  s     1&Qa&s   r*   r+   g      )	hasattrr   r   rQ   r   r@   rA   r   rM   )	r   coeffsr5   r8   r6   r9   r7   r:   centers	            r   loadswr  U  s     1g344WWYF
6{a<s6{JKK1&1A!]]6A!c3#DEFF&&tT222r   rl   c                    ^ U [         R                  SS5      -  mSR                  U4S j[        S5       5       5      S-   $ )zReturn string for a world file.

This method also translates the coefficients from corner- to
center-based coordinates.

:rtype: str
g      ?
c              3   N   >#    U  H  n[        [        TU5      5      v   M     g 7fr   )reprgetattr)r   r   r  s     r   r   dumpsw.<locals>.<genexpr>q  s      F~!T'&!,--~s   "%adbecf)r   rM   joinlist)objr  s    @r   dumpswr  h  s:     6%%c3//F99FtH~FFMMr   )r   collectionsr   r-   r   __all__
__author____version__r   rR   __annotations__	Exceptionr   r   r   r'   r2   r   rH   r   r  r  r	   r   r   <module>r     s   D #   *
 	) 	.+ .F[ F%&(U ("m>Z"OP m>` !Q1a# 
3c 3&	N3 	Nr   