
    Dvg                     ,    d dl mZ  G d d          ZdS )    )gdalc                   d   e 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edd            Zd ZdS )SpatialRefSysMixinz~
    The SpatialRefSysMixin is a class used by the database-dependent
    SpatialRefSys objects to reduce redundant code.
    c                    t          | d          r| j                                        S 	 t          j        | j                  | _        | j        S # t          $ r}|}Y d}~nd}~ww xY w	 t          j        | j                  | _        | j        S # t          $ r}|}Y d}~nd}~ww xY wt          d| j        d|          )z8
        Return a GDAL SpatialReference object.
        _srsNz-Could not get OSR SpatialReference from WKT: z
Error:
)	hasattrr   cloner   SpatialReferencewktsrs	Exception	proj4text)selfemsgs      g/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/django/contrib/gis/db/backends/base/models.pyr   zSpatialRefSysMixin.srs
   s     4   	9??$$$
 1$(;;	x    1$.AA	x    )888SS"  s/   $A 
A&A!!A&*$B 
B%B  B%c                     | j         j        S )z
        Return a tuple of the ellipsoid parameters:
        (semimajor axis, semiminor axis, and inverse flattening).
        )r   	ellipsoidr   s    r   r   zSpatialRefSysMixin.ellipsoid(   s     x!!    c                     | j         j        S )zReturn the projection name.)r   namer   s    r   r   zSpatialRefSysMixin.name0   s     x}r   c                     | j         d         S )z4Return the spheroid name for this spatial reference.spheroidr   r   s    r   r   zSpatialRefSysMixin.spheroid5   s     x
##r   c                     | j         d         S )z,Return the datum for this spatial reference.datumr   r   s    r   r   zSpatialRefSysMixin.datum:   s     x  r   c                     | j         j        S )z$Is this Spatial Reference projected?)r   	projectedr   s    r   r   zSpatialRefSysMixin.projected?   s     x!!r   c                     | j         j        S )z Is this Spatial Reference local?)r   localr   s    r   r!   zSpatialRefSysMixin.localD   s     x~r   c                     | j         j        S )z%Is this Spatial Reference geographic?)r   
geographicr   s    r   r#   zSpatialRefSysMixin.geographicI   s     x""r   c                     | j         j        S )zReturn the linear units name.)r   linear_namer   s    r   r%   zSpatialRefSysMixin.linear_nameN   s     x##r   c                     | j         j        S )zReturn the linear units.)r   linear_unitsr   s    r   r'   zSpatialRefSysMixin.linear_unitsS        x$$r   c                     | j         j        S )z%Return the name of the angular units.)r   angular_namer   s    r   r*   zSpatialRefSysMixin.angular_nameX   r(   r   c                     | j         j        S )zReturn the angular units.)r   angular_unitsr   s    r   r,   z SpatialRefSysMixin.angular_units]   s     x%%r   c                 h    | j         s| j        r| j        | j        fS | j        r| j        | j        fS dS )z)Return a tuple of the units and the name.)NN)r   r!   r'   r%   r#   r,   r*   r   s    r   unitszSpatialRefSysMixin.unitsb   sH     > 	 TZ 	 %t'788_ 	 &(9::<r   c                 4    t          j        |          j        S )z
        Return a tuple of (unit_value, unit_name) for the given WKT without
        using any of the database fields.
        )r   r
   r.   )clsr   s     r   	get_unitszSpatialRefSysMixin.get_unitsl   s     $S))//r   Tc                     t          j        |          }|j        }|d         }|s||fS t          |          dk    r|d         |d         }}n|\  }}d|d|d|dS )	z
        Class method used by GeometryField on initialization to
        retrieve the `SPHEROID[..]` parameters from the given WKT.
        r      r      z
SPHEROID["z",,])r   r
   r   len)r0   r   stringr   sphere_paramssphere_nameradius
flattenings           r   get_spheroidzSpatialRefSysMixin.get_spheroidt   s     #C((*o 	N-- =!!Q&&%21%5}Q7G
%2"
-8[[&&&***MMr   c                 *    t          | j                  S )zG
        Return the string representation, a 'pretty' OGC WKT.
        )strr   r   s    r   __str__zSpatialRefSysMixin.__str__   s     48}}r   N)T)__name__
__module____qualname____doc__propertyr   r   r   r   r   r   r!   r#   r%   r'   r*   r,   r.   classmethodr1   r=   r@    r   r   r   r      s        
   X: " " X"   X $ $ X$ ! ! X! " " X"   X # # X# $ $ X$ % % X% % % X% & & X&     X  0 0 [0 N N N [N&    r   r   N)django.contrib.gisr   r   rG   r   r   <module>rI      sS    # # # # # #H H H H H H H H H Hr   