
    (ph2                         S r SSK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KJr  SS	KJrJr   " S
 S\5      r " S S\
5      r " S S\
5      rg)a6  
The Spatial Reference class, represents OGR Spatial Reference objects.

Example:
>>> from django.contrib.gis.gdal import SpatialReference
>>> srs = SpatialReference('WGS84')
>>> print(srs)
GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.257223563,
            AUTHORITY["EPSG","7030"]],
        TOWGS84[0,0,0,0,0,0,0],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0,
        AUTHORITY["EPSG","8901"]],
    UNIT["degree",0.01745329251994328,
        AUTHORITY["EPSG","9122"]],
    AUTHORITY["EPSG","4326"]]
>>> print(srs.proj)
+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs
>>> print(srs.ellipsoid)
(6378137.0, 6356752.3142451793, 298.25722356300003)
>>> print(srs.projected, srs.geographic)
False True
>>> srs.import_epsg(32140)
>>> print(srs.name)
NAD83 / Texas South Central
    )byrefc_char_pc_int)IntEnum)NoneType)GDALBase)SRSException)GDAL_VERSION)srs)force_bytes	force_strc                       \ rS rSrSrSrSrg)	AxisOrder)   r       N)__name__
__module____qualname____firstlineno__TRADITIONAL	AUTHORITY__static_attributes__r       N/var/www/html/venv/lib/python3.13/site-packages/django/contrib/gis/gdal/srs.pyr   r   )   s    KIr   r   c                      \ rS rSrSr\R                  rS(S jrS r	S r
S)S j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 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r \S 5       r!S r"S r#S r$S  r%S! r&\S" 5       r'\S)S# j5       r(\S$ 5       r)\S% 5       r*\S*S& j5       r+S'r,g)+SpatialReference.   z
A wrapper for the OGRSpatialReference object. According to the GDAL web site,
the SpatialReference object "provide[s] services to represent coordinate
systems (projections and datums) and to transform between them."
Nc                 8   [        U[        [        45      (       d  [        S5      eU=(       d    [        R                  U l        US:X  a  [        R                  " [        S5      5      U l	        U R                  U5        U R
                  [        R                  :X  a6  [        S:  a,  [        R                  " U R                  U R
                  5        gU R
                  [        R                  :w  a"  [        S:  a  [        SU R
                  -  5      eg[        U[        5      (       a   [        U5      nSU-  nOE[        U[        5      (       a  SnO-[        XR                  5      (       a  UnS	nO[!        S
U-  5      eUS	:X  a  UnO![        S5      n[        R                  " U5      nU(       d  [#        SU-  5      eXPl	        U R
                  [        R                  :X  a6  [        S:  a,  [        R                  " U R                  U R
                  5        O@U R
                  [        R                  :w  a"  [        S:  a  [        SU R
                  -  5      eUS:X  a  U R%                  U5        gUS:X  a  U R'                  U5        gg! [         a     GNf = f)z
Create a GDAL OSR Spatial Reference object from the given input.
The input may be string of OGC Well Known Text (WKT), an integer
EPSG code, a PROJ string, and/or a projection "well known" shorthand
string (one of 'WGS84', 'WGS72', 'NAD27', 'NAD83').
z:SpatialReference.axis_order must be an AxisOrder instance.wktr   )   r   z"%s is not supported in GDAL < 3.0.NzEPSG:%depsgogrzInvalid SRS type "%s"z+Could not create spatial reference from: %suser)
isinstancer   r   
ValueErrorr   
axis_ordercapinew_srsr   ptr
import_wktr
   set_axis_strategystrintptr_type	TypeErrorr	   import_user_inputimport_epsg)self	srs_inputsrs_typer'   sridr   bufs          r   __init__SpatialReference.__init__7   s    *x&;<<L  %=	(=(=u||HSM2DHOOI&)"7"77LF<R&&txxA  I$9$99lV>S !E!WXX	3'' 9~%,	 	3''H	==11CH3h>??uC 3-C,,s#C =	I  H??i3338N""488T__=__	 5 55,:OADOOSTTv""9-Y'  E  s   +J 
JJc                 l    [        U[        5      (       a  U R                  " U6 $ U R                  U5      $ )a  
Return the value of the given string attribute node, None if the node
doesn't exist.  Can also take a tuple as a parameter, (target, child),
where child is the index of the attribute in the WKT.  For example:

>>> wkt = 'GEOGCS["WGS 84", DATUM["WGS_1984, ... AUTHORITY["EPSG","4326"]]'
>>> srs = SpatialReference(wkt) # could also use 'WGS84', or 4326
>>> print(srs['GEOGCS'])
WGS 84
>>> print(srs['DATUM'])
WGS_1984
>>> print(srs['AUTHORITY'])
EPSG
>>> print(srs['AUTHORITY', 1]) # The authority value
4326
>>> print(srs['TOWGS84', 4]) # the fourth value in this wkt
0
>>> # For the units authority, have to use the pipe symbole.
>>> print(srs['UNIT|AUTHORITY'])
EPSG
>>> print(srs['UNIT|AUTHORITY', 1]) # The authority value for the units
9122
)r%   tuple
attr_valuer3   targets     r   __getitem__SpatialReference.__getitem__v   s/    0 fe$$??F++??6**r   c                     U R                   $ )zUse 'pretty' WKT.)
pretty_wktr3   s    r   __str__SpatialReference.__str__   s    r   c                     [        U[        5      (       a  [        U[        5      (       d  [        e[        R
                  " U R                  [        U5      U5      $ )z
The attribute value for the given target node (e.g. 'PROJCS'). The index
keyword specifies an index of the child node to return.
)r%   r-   r.   r0   r(   get_attr_valuer*   r   )r3   r>   indexs      r   r<   SpatialReference.attr_value   s@    
 &#&&j.D.DO""488[-@%HHr   c                 h    [         R                  " U R                  Uc  U5      $ [        U5      5      $ )z;Return the authority name for the given string target node.)r(   get_auth_namer*   r   r=   s     r   	auth_nameSpatialReference.auth_name   4    !!HHf
 	
4?4G
 	
r   c                 h    [         R                  " U R                  Uc  U5      $ [        U5      5      $ )z;Return the authority code for the given string target node.)r(   get_auth_coder*   r   r=   s     r   	auth_codeSpatialReference.auth_code   rN   r   c                 f    [        [        R                  " U R                  5      U R                  S9$ )z/Return a clone of this SpatialReference object.)r'   )r   r(   	clone_srsr*   r'   rC   s    r   cloneSpatialReference.clone   s     txx 8T__UUr   c                 D    [         R                  " U R                  5        g)z7Morph this SpatialReference from ESRI's format to EPSG.N)r(   morph_from_esrir*   rC   s    r   	from_esriSpatialReference.from_esri   s    TXX&r   c                 D    [         R                  " U R                  5        g)z
This method inspects the WKT of this SpatialReference, and will
add EPSG authority nodes where an EPSG identifier is applicable.
N)r(   identify_epsgr*   rC   s    r   r\   SpatialReference.identify_epsg   s    
 	488$r   c                 D    [         R                  " U R                  5        g)z-Morph this SpatialReference to ESRI's format.N)r(   morph_to_esrir*   rC   s    r   to_esriSpatialReference.to_esri   s    488$r   c                 D    [         R                  " U R                  5        g)z5Check to see if the given spatial reference is valid.N)r(   srs_validater*   rC   s    r   validateSpatialReference.validate   s    $((#r   c                     U R                   (       a  U R                  S5      $ U R                  (       a  U R                  S5      $ U R                  (       a  U R                  S5      $ g)z*Return the name of this Spatial Reference.PROJCSGEOGCSLOCAL_CSN)	projectedr<   
geographiclocalrC   s    r   nameSpatialReference.name   sI     >>??8,,__??8,,ZZ??:..r   c                 `     [        U R                  SS95      $ ! [        [        4 a     gf = f)z=Return the SRID of top-level authority, or None if undefined.N)r>   )r.   rQ   r0   r&   rC   s    r   r6   SpatialReference.srid   s4    	t~~T~233:& 		s    --c                 n    [         R                  " U R                  [        [	        5       5      5      u  pU$ )z$Return the name of the linear units.r(   linear_unitsr*   r   r   r3   unitsrm   s      r   linear_nameSpatialReference.linear_name   s(     ''%
2CDr   c                 n    [         R                  " U R                  [        [	        5       5      5      u  pU$ )z%Return the value of the linear units.rr   rt   s      r   rs   SpatialReference.linear_units   s(     ''%
2CDr   c                 n    [         R                  " U R                  [        [	        5       5      5      u  pU$ )z%Return the name of the angular units.r(   angular_unitsr*   r   r   rt   s      r   angular_nameSpatialReference.angular_name   s(     ((53DEr   c                 n    [         R                  " U R                  [        [	        5       5      5      u  pU$ )z&Return the value of the angular units.r{   rt   s      r   r|   SpatialReference.angular_units   s(     ((53DEr   c                 d   Su  pU R                   (       d  U R                  (       a5  [        R                  " U R                  [        [        5       5      5      u  pOEU R                  (       a4  [        R                  " U R                  [        [        5       5      5      u  pUb  [        U5      nX4$ )z
Return a 2-tuple of the units value and the units name. Automatically
determine whether to return the linear or angular units.
)NN)
rj   rl   r(   rs   r*   r   r   rk   r|   r   rt   s      r   ru   SpatialReference.units   sv     !>>TZZ++DHHeHJ6GHKE4__,,TXXuXZ7HIKET?D}r   c                 H    U R                   U R                  U R                  4$ )zg
Return a tuple of the ellipsoid parameters:
 (semimajor axis, semiminor axis, and inverse flattening)
)
semi_major
semi_minorinverse_flatteningrC   s    r   	ellipsoidSpatialReference.ellipsoid  s     $2I2IJJr   c                 f    [         R                  " U R                  [        [	        5       5      5      $ )z6Return the Semi Major Axis for this Spatial Reference.)r(   r   r*   r   r   rC   s    r   r   SpatialReference.semi_major
       txxuw88r   c                 f    [         R                  " U R                  [        [	        5       5      5      $ )z6Return the Semi Minor Axis for this Spatial Reference.)r(   r   r*   r   r   rC   s    r   r   SpatialReference.semi_minor  r   r   c                 f    [         R                  " U R                  [        [	        5       5      5      $ )z9Return the Inverse Flattening for this Spatial Reference.)r(   invflatteningr*   r   r   rC   s    r   r   #SpatialReference.inverse_flattening  s!     !!$((E%'N;;r   c                 T    [        [        R                  " U R                  5      5      $ )zL
Return True if this SpatialReference is geographic
 (root node is GEOGCS).
)boolr(   isgeographicr*   rC   s    r   rk   SpatialReference.geographic  s     D%%dhh/00r   c                 T    [        [        R                  " U R                  5      5      $ )zFReturn True if this SpatialReference is local (root node is LOCAL_CS).)r   r(   islocalr*   rC   s    r   rl   SpatialReference.local"  s     DLL*++r   c                 T    [        [        R                  " U R                  5      5      $ )z_
Return True if this SpatialReference is a projected coordinate system
 (root node is PROJCS).
)r   r(   isprojectedr*   rC   s    r   rj   SpatialReference.projected'  s     D$$TXX.//r   c                 F    [         R                  " U R                  U5        g)z=Import the Spatial Reference from the EPSG code (an integer).N)r(   	from_epsgr*   )r3   r"   s     r   r2   SpatialReference.import_epsg0      txx&r   c                 F    [         R                  " U R                  U5        g)z0Import the Spatial Reference from a PROJ string.N)r(   	from_projr*   )r3   projs     r   import_projSpatialReference.import_proj4  r   r   c                 X    [         R                  " U R                  [        U5      5        g)z>Import the Spatial Reference from the given user input string.N)r(   from_user_inputr*   r   )r3   
user_inputs     r   r1   "SpatialReference.import_user_input8  s    TXX{:'>?r   c           
      |    [         R                  " U R                  [        [	        [        U5      5      5      5        g)z2Import the Spatial Reference from OGC WKT (string)N)r(   from_wktr*   r   r   r   )r3   r    s     r   r+   SpatialReference.import_wkt<  s#    dhhh{3/?&@ ABr   c                 F    [         R                  " U R                  U5        g)z0Import the Spatial Reference from an XML string.N)r(   from_xmlr*   )r3   xmls     r   
import_xmlSpatialReference.import_xml@  s    dhh$r   c                 f    [         R                  " U R                  [        [	        5       5      5      $ )z8Return the WKT representation of this Spatial Reference.)r(   to_wktr*   r   r   rC   s    r   r    SpatialReference.wktE  s      {{488U8:%677r   c                 h    [         R                  " U R                  [        [	        5       5      U5      $ )z.Return the 'pretty' representation of the WKT.)r(   to_pretty_wktr*   r   r   )r3   simplifys     r   rB   SpatialReference.pretty_wktJ  s$     !!$((E(*,=xHHr   c                 f    [         R                  " U R                  [        [	        5       5      5      $ )z:Return the PROJ representation for this Spatial Reference.)r(   to_projr*   r   r   rC   s    r   r   SpatialReference.projO  s      ||DHHeHJ&788r   c                     U R                   $ )zAlias for proj().)r   rC   s    r   proj4SpatialReference.proj4T  s     yyr   c                 z    [         R                  " U R                  [        [	        5       5      [        U5      5      $ )z8Return the XML representation of this Spatial Reference.)r(   to_xmlr*   r   r   r   )r3   dialects     r   r   SpatialReference.xmlY  s'     {{488U8:%6G8LMMr   )r'   r*   ) r$   N)r   )r   )-r   r   r   r   __doc__r(   release_srs
destructorr8   r?   rD   r<   rL   rQ   rU   rY   r\   r`   rd   propertyrm   r6   rv   rs   r}   r|   ru   r   r   r   r   rk   rl   rj   r2   r   r1   r+   r   r    rB   r   r   r   r   r   r   r   r   r   .   s    !!J=(~+:
I

V'%%$
 	 	    
  
  
  
   K K 9 9 9 9 < <
 1 1 , , 0 0''@C%
 8 8 I I 9 9   N Nr   r   c                   <    \ rS rSrSr\R                  rS rS r	Sr
g)CoordTransformi_  z,The coordinate system transformation object.c                    [        U[        5      (       a  [        U[        5      (       d  [        S5      e[        R                  " UR
                  UR
                  5      U l        UR                  U l        UR                  U l	        g)z;Initialize on a source and target SpatialReference objects.z2source and target must be of type SpatialReferenceN)
r%   r   r0   r(   new_ct_ptrr*   rm   
_srs1_name
_srs2_name)r3   sourcer>   s      r   r8   CoordTransform.__init__c  s`    &"233:$<
 <
 PQQ;;v{{FKK8 ++ ++r   c                 @    SU R                   < SU R                  < S3$ )NzTransform from "z" to "")r   r   rC   s    r   rD   CoordTransform.__str__m  s    04QQr   )r   r   r*   N)r   r   r   r   r   r(   
destroy_ctr   r8   rD   r   r   r   r   r   r   _  s    2J&Rr   r   N)r   ctypesr   r   r   enumr   typesr   django.contrib.gis.gdal.baser   django.contrib.gis.gdal.errorr	   django.contrib.gis.gdal.libgdalr
   "django.contrib.gis.gdal.prototypesr   r(   django.utils.encodingr   r   r   r   r   r   r   r   <module>r      sR   : * )   1 6 8 : 8 
nNx nNb	RX Rr   