
 X                 @   s   d  Z  d d l m Z d d l m Z d d l m Z m Z d d l m	 Z	 d d l
 m Z e Gd d   d e j   Z Gd	 d
   d
 e j e  Z d d   Z e	 j e d e d S)zK
 The GeometryColumns and SpatialRefSys models for the SpatiaLite backend.
    )SpatialRefSysMixin)DatabaseWrapper)
connectionmodels)connection_created)python_2_unicode_compatiblec               @   s   e  Z d  Z d Z e j d d  Z e j d d  Z e j   Z	 e j d d  Z
 e j   Z Gd d   d  Z e d d	    Z e d
 d    Z d d   Z d S)SpatialiteGeometryColumnsz7
    The 'geometry_columns' table from SpatiaLite.
    
max_length   primary_keyTc               @   s"   e  Z d  Z d Z d Z d Z d S)zSpatialiteGeometryColumns.MetagisZgeometry_columnsFN)__name__
__module____qualname__	app_labeldb_tablemanaged r   r   ^/home/ubuntu/projects/ifolica/build/django/django/contrib/gis/db/backends/spatialite/models.pyMeta   s   r   c             C   s   d S)zg
        Returns the name of the metadata column used to store the feature table
        name.
        f_table_namer   )clsr   r   r   table_name_col   s    z(SpatialiteGeometryColumns.table_name_colc             C   s   d S)zl
        Returns the name of the metadata column used to store the feature
        geometry column.
        f_geometry_columnr   )r   r   r   r   geom_col_name#   s    z'SpatialiteGeometryColumns.geom_col_namec             C   s&   d |  j  |  j |  j |  j |  j f S)Nz%s.%s - %dD %s field (SRID: %d))r   r   coord_dimensiontypesrid)selfr   r   r   __str__+   s    z!SpatialiteGeometryColumns.__str__N)r   r   r   __doc__r   	CharFieldr   r   IntegerFieldr   r   Zspatial_index_enabledr   classmethodr   r   r   r   r   r   r   r      s   r   c               @   s   e  Z d  Z d Z e j d d  Z e j d d  Z e j   Z	 e j d d  Z
 e j d d  Z e d d    Z Gd	 d
   d
  Z d S)SpatialiteSpatialRefSysz6
    The 'spatial_ref_sys' table from SpatiaLite.
    r   Tr	   r
   i   c             C   s6   t  |  d  r |  j Sd d l m } | |  j  j S)Nsrtextr   )SpatialReference)hasattrr%   Zdjango.contrib.gis.gdalr&   	proj4textwkt)r   r&   r   r   r   r)   ;   s    zSpatialiteSpatialRefSys.wktc               @   s"   e  Z d  Z d Z d Z d Z d S)zSpatialiteSpatialRefSys.Metar   Zspatial_ref_sysFN)r   r   r   r   r   r   r   r   r   r   r   B   s   r   N)r   r   r   r    r   r"   r   r!   Z	auth_nameZ	auth_sridZref_sys_namer(   propertyr)   r   r   r   r   r   r$   1   s   r$   c             K   s   t  j t d t r t j j d } | d k rl t j d t	 j
 d d   t j d t	 j d d	   q t j d t	 j
 d d
   n  d S)zr
    Adds fields after establishing a database connection to prevent database
    operations at compile time.
    senderr      r%   r	   i   r   Z	db_columnZgeometry_type   N)r   Z
disconnect"add_spatial_version_related_fieldsr   r   opsspatial_versionr$   Zadd_to_classr   r!   r   r"   )r+   kwargsr0   r   r   r   r.   H   s    r.   r+   N)r    Z*django.contrib.gis.db.backends.base.modelsr   Z.django.contrib.gis.db.backends.spatialite.baser   Z	django.dbr   r   Zdjango.db.backends.signalsr   Zdjango.utils.encodingr   ZModelr   r$   r.   connectr   r   r   r   <module>   s   %