o
    ó<âg©  ã                   @   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   ú]/var/www/html/venv/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    