§
    Ÿj0  ã                   ó¾   — d Z ddlmZmZmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZ ddlmZmZ  G d	„ d
e¦  «        Z G d„ de
¦  «        Z G d„ de
¦  «        ZdS )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                   ó   — e Zd ZdZdZdS )Ú	AxisOrderr   é   N)Ú__name__Ú
__module__Ú__qualname__ÚTRADITIONALÚ	AUTHORITY© ó    úh/var/www/finuniver-perm.ru/html/student/venv/lib/python3.11/site-packages/django/contrib/gis/gdal/srs.pyr   r   (   s   € € € € € Ø€KØ€I€I€Ir   r   c                   ó*  — e Zd ZdZej        Zd)d„Zd„ Zd„ Z	d*d	„Z
d
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Z d„ Z!d „ Z"d!„ Z#d"„ Z$d#„ Z%ed$„ ¦   «         Z&ed*d%„¦   «         Z'ed&„ ¦   «         Z(ed'„ ¦   «         Z)ed+d(„¦   «         Z*dS ),ÚSpatialReferencezé
    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."
    Ú ÚuserNc                 óØ  — t          |t          t          f¦  «        st          d¦  «        ‚|pt          j        | _        |dk    rqt          j        t          d¦  «        ¦  «        | _	        |  
                    |¦  «         | j        t          j        k    rt          j        | j	        | j        ¦  «         dS t          |t          ¦  «        r&	 t          |¦  «        }d|z  }nT# t          $ r Y nHw xY wt          |t          ¦  «        rd}n,t          || j        ¦  «        r|}d}nt          d|z  ¦  «        ‚|dk    r|}n#t          d¦  «        }t          j        |¦  «        }|st!          d	|z  ¦  «        ‚|| _	        | j        t          j        k    rt          j        | j	        | j        ¦  «         |d
k    r|                      |¦  «         dS |dk    r|                      |¦  «         dS dS )a$  
        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: %sr   )Ú
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__zSpatialReference.__init__6   s  € õ ˜*¥xµÐ&;Ñ<Ô<ð 	ÝØLñô ð ð %Ð=­	Ô(=ˆŒØ�uÒÐÝ”|¥H¨S¡M¤MÑ2Ô2ˆDŒHØ�OŠO˜IÑ&Ô&Ð&ØŒ¥)Ô"7Ò7Ð7ÝÔ& t¤x°´ÑAÔAÐAØˆFÝ˜	¥3Ñ'Ô'ð 	@ðõ ˜9‘~”~�Ø%¨Ñ,�	�	øÝð ð ð Ø�ðøøøå˜	¥3Ñ'Ô'ð 	@àˆHˆHÝ˜	 4¤=Ñ1Ô1ð 	@ØˆCØˆHˆHåÐ3°hÑ>Ñ?Ô?Ð?à�uÒÐàˆCˆCõ ˜3‘-”-ˆCÝ”,˜sÑ#Ô#ˆCð ð 	ÝØ=À	ÑIñô ð ð ˆDŒHàŒ?�iÔ3Ò3Ð3ÝÔ" 4¤8¨T¬_Ñ=Ô=Ð=à�vÒÐØ×"Ò" 9Ñ-Ô-Ð-Ð-Ð-Ø˜ÒÐØ×Ò˜YÑ'Ô'Ð'Ð'Ð'ð  Ðs   ÃC! Ã!
C.Ã-C.c                 ój   — t          |t          ¦  «        r
 | j        |Ž S |                      |¦  «        S )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©r.   Útargets     r   Ú__getitem__zSpatialReference.__getitem__q   s7   € õ0 �f�eÑ$Ô$ð 	+Ø"�4”? FÐ+Ð+à—?’? 6Ñ*Ô*Ð*r   c                 ó   — | j         S )zUse 'pretty' WKT.)Ú
pretty_wkt©r.   s    r   Ú__str__zSpatialReference.__str__Ž   s
   € àŒÐr   r   c                 ó´   — t          |t          ¦  «        rt          |t          ¦  «        st          ‚t	          j        | j        t          |¦  «        |¦  «        S )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   )r.   r8   Úindexs      r   r6   zSpatialReference.attr_value“   sK   € õ
 ˜&¥#Ñ&Ô&ð 	­j¸ÅÑ.DÔ.Dð 	ÝˆOÝÔ" 4¤8­[¸Ñ-@Ô-@À%ÑHÔHÐHr   c                 óX   — t          j        | j        |€|nt          |¦  «        ¦  «        S )z;Return the authority name for the given string target node.)r#   Úget_auth_namer%   r   r7   s     r   Ú	auth_namezSpatialReference.auth_nameœ   ó.   € åÔ!ØŒH  �f�fµKÀÑ4GÔ4Gñ
ô 
ð 	
r   c                 óX   — t          j        | j        |€|nt          |¦  «        ¦  «        S )z;Return the authority code for the given string target node.)r#   Úget_auth_coder%   r   r7   s     r   Ú	auth_codezSpatialReference.auth_code¢   rD   r   c                 ó\   — t          t          j        | j        ¦  «        | j        ¬¦  «        S )z/Return a clone of this SpatialReference object.)r"   )r   r#   Ú	clone_srsr%   r"   r<   s    r   ÚclonezSpatialReference.clone¨   s#   € å¥¤¨t¬xÑ 8Ô 8ÀTÄ_ÐUÑUÔUÐUr   c                 ó8   — t          j        | j        ¦  «         dS )z7Morph this SpatialReference from ESRI's format to EPSG.N)r#   Úmorph_from_esrir%   r<   s    r   Ú	from_esrizSpatialReference.from_esri¬   s   € åÔ˜TœXÑ&Ô&Ð&Ð&Ð&r   c                 ó8   — t          j        | j        ¦  «         dS )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%   r<   s    r   rO   zSpatialReference.identify_epsg°   s   € õ
 	Ô˜4œ8Ñ$Ô$Ð$Ð$Ð$r   c                 ó8   — t          j        | j        ¦  «         dS )z-Morph this SpatialReference to ESRI's format.N)r#   Úmorph_to_esrir%   r<   s    r   Úto_esrizSpatialReference.to_esri·   s   € åÔ˜4œ8Ñ$Ô$Ð$Ð$Ð$r   c                 ó8   — t          j        | j        ¦  «         dS )z5Check to see if the given spatial reference is valid.N)r#   Úsrs_validater%   r<   s    r   ÚvalidatezSpatialReference.validate»   s   € åÔ˜$œ(Ñ#Ô#Ð#Ð#Ð#r   c                 ó®   — | j         r|                      d¦  «        S | j        r|                      d¦  «        S | j        r|                      d¦  «        S dS )z*Return the name of this Spatial Reference.ÚPROJCSÚGEOGCSÚLOCAL_CSN)Ú	projectedr6   Ú
geographicÚlocalr<   s    r   ÚnamezSpatialReference.nameÀ   s]   € ð Œ>ð 	Ø—?’? 8Ñ,Ô,Ð,ØŒ_ð 	Ø—?’? 8Ñ,Ô,Ð,ØŒZð 	Ø—?’? :Ñ.Ô.Ð.à�4r   c                 óz   — 	 t          |                      d¬¦  «        ¦  «        S # t          t          f$ r Y dS w xY w)z=Return the SRID of top-level authority, or None if undefined.N)r8   )r)   rG   r+   r!   r<   s    r   r1   zSpatialReference.sridÌ   sJ   € ð	Ý�t—~’~¨T�~Ñ2Ô2Ñ3Ô3Ð3øÝ�:Ð&ð 	ð 	ð 	Ø�4�4ð	øøøs   ‚"% ¥:¹:c                 ór   — t          j        | j        t          t	          ¦   «         ¦  «        ¦  «        \  }}|S )z$Return the name of the linear units.©r#   Úlinear_unitsr%   r   r   ©r.   Úunitsr]   s      r   Úlinear_namezSpatialReference.linear_nameÕ   s-   € õ Ô'¨¬µ%½¹
¼
Ñ2CÔ2CÑDÔD‰ˆˆtØˆr   c                 ór   — t          j        | j        t          t	          ¦   «         ¦  «        ¦  «        \  }}|S )z%Return the value of the linear units.r`   rb   s      r   ra   zSpatialReference.linear_unitsÛ   s-   € õ Ô'¨¬µ%½¹
¼
Ñ2CÔ2CÑDÔD‰ˆˆtØˆr   c                 ór   — t          j        | j        t          t	          ¦   «         ¦  «        ¦  «        \  }}|S )z%Return the name of the angular units.©r#   Úangular_unitsr%   r   r   rb   s      r   Úangular_namezSpatialReference.angular_nameá   s-   € õ Ô(¨¬µ5½¹¼Ñ3DÔ3DÑEÔE‰ˆˆtØˆr   c                 ór   — t          j        | j        t          t	          ¦   «         ¦  «        ¦  «        \  }}|S )z&Return the value of the angular units.rg   rb   s      r   rh   zSpatialReference.angular_unitsç   s-   € õ Ô(¨¬µ5½¹¼Ñ3DÔ3DÑEÔE‰ˆˆtØˆr   c                 ó:  — d\  }}| j         s| j        r7t          j        | j        t          t          ¦   «         ¦  «        ¦  «        \  }}n=| j        r6t          j        | j        t          t          ¦   «         ¦  «        ¦  «        \  }}|�t          |¦  «        }||fS )z˜
        Return a 2-tuple of the units value and the units name. Automatically
        determine whether to return the linear or angular units.
        )NN)
rZ   r\   r#   ra   r%   r   r   r[   rh   r   rb   s      r   rc   zSpatialReference.unitsí   s’   € ð !‰ˆˆtØŒ>ð 	J˜TœZð 	JÝÔ+¨D¬Hµe½H¹J¼JÑ6GÔ6GÑHÔH‰KˆE�4�4ØŒ_ð 	JÝÔ,¨T¬Xµu½X¹Z¼ZÑ7HÔ7HÑIÔI‰KˆE�4ØÐÝ˜T‘?”?ˆDØ�tˆ}Ðr   c                 ó*   — | j         | j        | j        fS )z
        Return a tuple of the ellipsoid parameters:
         (semimajor axis, semiminor axis, and inverse flattening)
        )Ú
semi_majorÚ
semi_minorÚinverse_flatteningr<   s    r   Ú	ellipsoidzSpatialReference.ellipsoidý   s   € ð ” ¤°$Ô2IÐJÐJr   c                 óh   — t          j        | j        t          t	          ¦   «         ¦  «        ¦  «        S )z6Return the Semi Major Axis for this Spatial Reference.)r#   rm   r%   r   r   r<   s    r   rm   zSpatialReference.semi_major  ó"   € õ Œ˜tœx­­u©w¬w©¬Ñ8Ô8Ð8r   c                 óh   — t          j        | j        t          t	          ¦   «         ¦  «        ¦  «        S )z6Return the Semi Minor Axis for this Spatial Reference.)r#   rn   r%   r   r   r<   s    r   rn   zSpatialReference.semi_minor
  rr   r   c                 óh   — t          j        | j        t          t	          ¦   «         ¦  «        ¦  «        S )z9Return the Inverse Flattening for this Spatial Reference.)r#   Úinvflatteningr%   r   r   r<   s    r   ro   z#SpatialReference.inverse_flattening  s#   € õ Ô! $¤(­Eµ%±'´'©N¬NÑ;Ô;Ð;r   c                 óN   — t          t          j        | j        ¦  «        ¦  «        S )zd
        Return True if this SpatialReference is geographic
         (root node is GEOGCS).
        )Úboolr#   Úisgeographicr%   r<   s    r   r[   zSpatialReference.geographic  s   € õ •DÔ% d¤hÑ/Ô/Ñ0Ô0Ð0r   c                 óN   — t          t          j        | j        ¦  «        ¦  «        S )zFReturn True if this SpatialReference is local (root node is LOCAL_CS).)rw   r#   Úislocalr%   r<   s    r   r\   zSpatialReference.local  s   € õ •D”L ¤Ñ*Ô*Ñ+Ô+Ð+r   c                 óN   — t          t          j        | j        ¦  «        ¦  «        S )zw
        Return True if this SpatialReference is a projected coordinate system
         (root node is PROJCS).
        )rw   r#   Úisprojectedr%   r<   s    r   rZ   zSpatialReference.projected"  s   € õ •DÔ$ T¤XÑ.Ô.Ñ/Ô/Ð/r   c                 ó:   — t          j        | j        |¦  «         dS )z=Import the Spatial Reference from the EPSG code (an integer).N)r#   Ú	from_epsgr%   )r.   r   s     r   r-   zSpatialReference.import_epsg+  ó   € åŒ�t”x Ñ&Ô&Ð&Ð&Ð&r   c                 ó:   — t          j        | j        |¦  «         dS )z0Import the Spatial Reference from a PROJ string.N)r#   Ú	from_projr%   )r.   Úprojs     r   Úimport_projzSpatialReference.import_proj/  r   r   c                 óT   — t          j        | j        t          |¦  «        ¦  «         dS )z>Import the Spatial Reference from the given user input string.N)r#   Úfrom_user_inputr%   r   )r.   Ú
user_inputs     r   r,   z"SpatialReference.import_user_input3  s%   € åÔ˜TœX¥{°:Ñ'>Ô'>Ñ?Ô?Ð?Ð?Ð?r   c           
      óˆ   — t          j        | j        t          t	          t          |¦  «        ¦  «        ¦  «        ¦  «         dS )z2Import the Spatial Reference from OGC WKT (string)N)r#   Úfrom_wktr%   r   r   r   )r.   r   s     r   r&   zSpatialReference.import_wkt7  s4   € åŒ�d”h¥¥h­{¸3Ñ/?Ô/?Ñ&@Ô&@Ñ AÔ AÑBÔBÐBÐBÐBr   c                 ó:   — t          j        | j        |¦  «         dS )z0Import the Spatial Reference from an XML string.N)r#   Úfrom_xmlr%   )r.   Úxmls     r   Ú
import_xmlzSpatialReference.import_xml;  s   € åŒ�d”h Ñ$Ô$Ð$Ð$Ð$r   c                 óh   — t          j        | j        t          t	          ¦   «         ¦  «        ¦  «        S )z8Return the WKT representation of this Spatial Reference.)r#   Úto_wktr%   r   r   r<   s    r   r   zSpatialReference.wkt@  s$   € õ Œ{˜4œ8¥U­8©:¬:Ñ%6Ô%6Ñ7Ô7Ð7r   c                 ój   — t          j        | j        t          t	          ¦   «         ¦  «        |¦  «        S )z.Return the 'pretty' representation of the WKT.)r#   Úto_pretty_wktr%   r   r   )r.   Úsimplifys     r   r;   zSpatialReference.pretty_wktE  s'   € õ Ô! $¤(­Eµ(±*´*Ñ,=Ô,=¸xÑHÔHÐHr   c                 óh   — t          j        | j        t          t	          ¦   «         ¦  «        ¦  «        S )z:Return the PROJ representation for this Spatial Reference.)r#   Úto_projr%   r   r   r<   s    r   r‚   zSpatialReference.projJ  s$   € õ Œ|˜DœH¥e­H©J¬JÑ&7Ô&7Ñ8Ô8Ð8r   c                 ó   — | j         S )zAlias for proj().)r‚   r<   s    r   Úproj4zSpatialReference.proj4O  s   € ð ŒyÐr   c                 ó„   — t          j        | j        t          t	          ¦   «         ¦  «        t          |¦  «        ¦  «        S )z8Return the XML representation of this Spatial Reference.)r#   Úto_xmlr%   r   r   r   )r.   Údialects     r   r‹   zSpatialReference.xmlT  s.   € õ Œ{˜4œ8¥U­8©:¬:Ñ%6Ô%6½ÀGÑ8LÔ8LÑMÔMÐMr   )r   r   N)r   )r   )+r   r   r   Ú__doc__r#   Úrelease_srsÚ
destructorr3   r9   r=   r6   rC   rG   rJ   rM   rO   rR   rU   Úpropertyr]   r1   rd   ra   ri   rh   rc   rp   rm   rn   ro   r[   r\   rZ   r-   rƒ   r,   r&   rŒ   r   r;   r‚   r•   r‹   r   r   r   r   r   -   sH  € € € € € ðð ð Ô!€Jð9(ð 9(ð 9(ð 9(ðv+ð +ð +ð:ð ð ð
Ið Ið Ið Ið
ð 
ð 
ð
ð 
ð 
ðVð Vð Vð'ð 'ð 'ð%ð %ð %ð%ð %ð %ð$ð $ð $ð
 ð	ð 	ñ „Xð	ð ðð ñ „Xðð ðð ñ „Xðð
 ðð ñ „Xðð
 ðð ñ „Xðð
 ðð ñ „Xðð
 ðð ñ „Xðð ðKð Kñ „XðKð ð9ð 9ñ „Xð9ð ð9ð 9ñ „Xð9ð ð<ð <ñ „Xð<ð
 ð1ð 1ñ „Xð1ð ð,ð ,ñ „Xð,ð ð0ð 0ñ „Xð0ð'ð 'ð 'ð'ð 'ð 'ð@ð @ð @ðCð Cð Cð%ð %ð %ð
 ð8ð 8ñ „Xð8ð ðIð Ið Iñ „XðIð ð9ð 9ñ „Xð9ð ðð ñ „Xðð ðNð Nð Nñ „XðNð Nð Nr   r   c                   ó,   — e Zd ZdZej        Zd„ Zd„ ZdS )ÚCoordTransformz,The coordinate system transformation object.c                 óð   — t          |t          ¦  «        rt          |t          ¦  «        st          d¦  «        ‚t          j        |j        |j        ¦  «        | _        |j        | _        |j        | _	        dS )z;Initialize on a source and target SpatialReference objects.z2source and target must be of type SpatialReferenceN)
r    r   r+   r#   Únew_ctÚ_ptrr%   r]   Ú
_srs1_nameÚ
_srs2_name)r.   Úsourcer8   s      r   r3   zCoordTransform.__init___  sl   € å˜&Õ"2Ñ3Ô3ð 	R½:ØÕ$ñ<
ô <
ð 	Rõ ÐPÑQÔQÐQÝ”;˜vœ{¨F¬KÑ8Ô8ˆŒØ œ+ˆŒØ œ+ˆŒˆˆr   c                 ó(   — d| j         ›d| j        ›d�S )NzTransform from "z" to "ú")r¢   r£   r<   s    r   r=   zCoordTransform.__str__i  s   € € Ø04´°°ÀÄÀÀÐQÐQr   N)	r   r   r   r™   r#   Ú
destroy_ctr›   r3   r=   r   r   r   rž   rž   Z  sD   € € € € € Ø2Ð2à”€Jð&ð &ð &ðRð Rð Rð Rð 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¯      sD  ððð ð: *Ð )Ð )Ð )Ð )Ð )Ð )Ð )Ð )Ð )Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø :Ð :Ð :Ð :Ð :Ð :Ø 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8ðð ð ð ð �ñ ô ð ð
jNð jNð jNð jNð jN�xñ jNô jNð jNðZ	Rð Rð Rð Rð R�Xñ Rô Rð Rð Rð Rr   