
    h>0                         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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)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       M/var/www/html/env/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                 
   [        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  a+  [        R                  " U R                  U R
                  5        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  a+  [        R                  " U R                  U R
                  5        US
:X  a  U R#                  U5        gUS:X  a  U R%                  U5        gg! [         a     Nf = 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   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_wktset_axis_strategystrintptr_type	TypeErrorr	   import_user_inputimport_epsg)self	srs_inputsrs_typer%   sridr
   bufs          r   __init__SpatialReference.__init__6   s    *x&;<<L  %=	(=(=u||HSM2DHOOI&)"7"77&&txxA	3'' 9~%,	 	3''H	==11CH3h>??uC 3-C,,s#C =	I  H??i333""488T__=v""9-Y'  A  s    G5 5
HH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r1   targets     r   __getitem__SpatialReference.__getitem__q   s/    0 fe$$??F++??6**r   c                     U R                   $ )zUse 'pretty' WKT.)
pretty_wktr1   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,   r.   r&   get_attr_valuer(   r   )r1   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   rL   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%   rA   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(   rA   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(   rA   s    r   rZ   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(   rA   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(   rA   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localrA   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,   rO   r.   r$   rA   s    r   r4   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   r1   unitsrk   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.rp   rr   s      r   rq   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   rr   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.ry   rr   s      r   rz   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)
rh   rj   r&   rq   r(   r   r   ri   rz   r   rr   s      r   rs   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_flatteningrA   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   rA   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   rA   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   rA   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(   rA   s    r   ri   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(   rA   s    r   rj   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(   rA   s    r   rh   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(   )r1   r    s     r   r0   SpatialReference.import_epsg+      txx&r   c                 F    [         R                  " U R                  U5        g)z0Import the Spatial Reference from a PROJ string.N)r&   	from_projr(   )r1   projs     r   import_projSpatialReference.import_proj/  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   )r1   
user_inputs     r   r/   "SpatialReference.import_user_input3  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   )r1   r   s     r   r)   SpatialReference.import_wkt7  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(   )r1   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   rA   s    r   r   SpatialReference.wkt@  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   )r1   simplifys     r   r@   SpatialReference.pretty_wktE  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   rA   s    r   r   SpatialReference.projJ  s      ||DHHeHJ&788r   c                     U R                   $ )zAlias for proj().)r   rA   s    r   proj4SpatialReference.proj4O  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   )r1   dialects     r   r   SpatialReference.xmlT  s'     {{488U8:%6G8LMMr   )r%   r(   ) r"   N)r   )r   )-r   r   r   r   __doc__r&   release_srs
destructorr6   r=   rB   r:   rJ   rO   rS   rW   rZ   r^   rb   propertyrk   r4   rt   rq   r{   rz   rs   r   r   r   r   ri   rj   rh   r0   r   r/   r)   r   r   r@   r   r   r   r   r   r   r   r   r   -   s    !!J9(v+:
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)CoordTransformiZ  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   r.   r&   new_ct_ptrr(   rk   
_srs1_name
_srs2_name)r1   sourcer<   s      r   r6   CoordTransform.__init__^  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   rA   s    r   rB   CoordTransform.__str__h  s    04QQr   )r   r   r(   N)r   r   r   r   r   r&   
destroy_ctr   r6   rB   r   r   r   r   r   r   Z  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.prototypesr
   r&   django.utils.encodingr   r   r   r   r   r   r   r   <module>r      sO   : * )   1 6 : 8 
jNx jNZ	RX Rr   