o
    i                     @   s   d dl mZ G dd dZdS )    )gdalc                   @   s   e Zd ZdZedd Zedd Zedd Zedd	 Zed
d Z	edd Z
edd Zedd Zedd Zedd Zedd Zedd Zedd Zedd Zed$dd Zd!d" Zd#S )%SpatialRefSysMixinz~
    The SpatialRefSysMixin is a class used by the database-dependent
    SpatialRefSys objects to reduce redundant code.
    c              
   C   s   t | dr
| j S zt| j| _| jW S  ty) } z|}W Y d}~nd}~ww zt| j| _| jW S  tyI } z|}W Y d}~nd}~ww td| j|f )z8
        Return a GDAL SpatialReference object.
        _srsNz9Could not get OSR SpatialReference from WKT: %s
Error:
%s)	hasattrr   cloner   SpatialReferencewktsrs	Exception	proj4text)selfemsg r   j/var/www/html/formularioweb/env/lib/python3.10/site-packages/django/contrib/gis/db/backends/base/models.pyr	   
   s*   

zSpatialRefSysMixin.srsc                 C      | j jS )z
        Return a tuple of the ellipsoid parameters:
        (semimajor axis, semiminor axis, and inverse flattening).
        )r	   	ellipsoidr   r   r   r   r   (   s   zSpatialRefSysMixin.ellipsoidc                 C   r   )zReturn the projection name.)r	   namer   r   r   r   r   0      zSpatialRefSysMixin.namec                 C   
   | j d S )z4Return the spheroid name for this spatial reference.spheroidr	   r   r   r   r   r   5      
zSpatialRefSysMixin.spheroidc                 C   r   )z,Return the datum for this spatial reference.datumr   r   r   r   r   r   :   r   zSpatialRefSysMixin.datumc                 C   r   )z$Is this Spatial Reference projected?)r	   	projectedr   r   r   r   r   ?   r   zSpatialRefSysMixin.projectedc                 C   r   )z Is this Spatial Reference local?)r	   localr   r   r   r   r   D   r   zSpatialRefSysMixin.localc                 C   r   )z%Is this Spatial Reference geographic?)r	   
geographicr   r   r   r   r   I   r   zSpatialRefSysMixin.geographicc                 C   r   )zReturn the linear units name.)r	   linear_namer   r   r   r   r   N   r   zSpatialRefSysMixin.linear_namec                 C   r   )zReturn the linear units.)r	   linear_unitsr   r   r   r   r   S   r   zSpatialRefSysMixin.linear_unitsc                 C   r   )z%Return the name of the angular units.)r	   angular_namer   r   r   r   r    X   r   zSpatialRefSysMixin.angular_namec                 C   r   )zReturn the angular units.)r	   angular_unitsr   r   r   r   r!   ]   r   z SpatialRefSysMixin.angular_unitsc                 C   s.   | 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   r   r   r   unitsb   s
   zSpatialRefSysMixin.unitsc                 C   s   t |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   r   r   r   	get_unitsl   s   zSpatialRefSysMixin.get_unitsTc                 C   sZ   t |}|j}|d }|s||fS t|dkr"|d |d }}n|\}}d|||f S )z
        Class method used by GeometryField on initialization to
        retrieve the `SPHEROID[..]` parameters from the given WKT.
        r      r      zSPHEROID["%s",%s,%s])r   r   r   len)r#   r   stringr	   sphere_paramssphere_nameradius
flatteningr   r   r   get_spheroidt   s   
zSpatialRefSysMixin.get_spheroidc                 C   s
   t | jS )zG
        Return the string representation, a 'pretty' OGC WKT.
        )strr	   r   r   r   r   __str__   s   
zSpatialRefSysMixin.__str__N)T)__name__
__module____qualname____doc__propertyr	   r   r   r   r   r   r   r   r   r   r    r!   r"   classmethodr$   r-   r/   r   r   r   r   r      sB    












	
r   N)django.contrib.gisr   r   r   r   r   r   <module>   s    