2008-08-06 02:13:06 +08:00
|
|
|
"""
|
|
|
|
The GeometryColumns and SpatialRefSys models for the PostGIS backend.
|
|
|
|
"""
|
|
|
|
from django.db import models
|
2009-12-22 23:18:51 +08:00
|
|
|
from django.contrib.gis.db.backends.base import SpatialRefSysMixin
|
2012-08-12 18:32:08 +08:00
|
|
|
from django.utils.encoding import python_2_unicode_compatible
|
2008-08-06 02:13:06 +08:00
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
@python_2_unicode_compatible
|
2008-08-06 02:13:06 +08:00
|
|
|
class GeometryColumns(models.Model):
|
|
|
|
"""
|
|
|
|
The 'geometry_columns' table from the PostGIS. See the PostGIS
|
|
|
|
documentation at Ch. 4.2.2.
|
|
|
|
"""
|
|
|
|
f_table_catalog = models.CharField(max_length=256)
|
|
|
|
f_table_schema = models.CharField(max_length=256)
|
|
|
|
f_table_name = models.CharField(max_length=256)
|
|
|
|
f_geometry_column = models.CharField(max_length=256)
|
|
|
|
coord_dimension = models.IntegerField()
|
|
|
|
srid = models.IntegerField(primary_key=True)
|
|
|
|
type = models.CharField(max_length=30)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
db_table = 'geometry_columns'
|
2009-04-17 06:25:01 +08:00
|
|
|
managed = False
|
2008-08-06 02:13:06 +08:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def table_name_col(cls):
|
2008-09-10 03:19:51 +08:00
|
|
|
"""
|
2009-03-31 01:15:49 +08:00
|
|
|
Returns the name of the metadata column used to store the
|
2008-09-10 03:19:51 +08:00
|
|
|
the feature table name.
|
|
|
|
"""
|
2008-08-06 02:13:06 +08:00
|
|
|
return 'f_table_name'
|
|
|
|
|
2008-09-10 03:19:51 +08:00
|
|
|
@classmethod
|
|
|
|
def geom_col_name(cls):
|
|
|
|
"""
|
2009-03-31 01:15:49 +08:00
|
|
|
Returns the name of the metadata column used to store the
|
2008-09-10 03:19:51 +08:00
|
|
|
the feature geometry column.
|
|
|
|
"""
|
|
|
|
return 'f_geometry_column'
|
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
def __str__(self):
|
2008-08-06 02:13:06 +08:00
|
|
|
return "%s.%s - %dD %s field (SRID: %d)" % \
|
|
|
|
(self.f_table_name, self.f_geometry_column,
|
|
|
|
self.coord_dimension, self.type, self.srid)
|
|
|
|
|
2009-12-22 23:18:51 +08:00
|
|
|
class SpatialRefSys(models.Model, SpatialRefSysMixin):
|
2008-08-06 02:13:06 +08:00
|
|
|
"""
|
|
|
|
The 'spatial_ref_sys' table from PostGIS. See the PostGIS
|
|
|
|
documentaiton at Ch. 4.2.1.
|
|
|
|
"""
|
|
|
|
srid = models.IntegerField(primary_key=True)
|
|
|
|
auth_name = models.CharField(max_length=256)
|
|
|
|
auth_srid = models.IntegerField()
|
|
|
|
srtext = models.CharField(max_length=2048)
|
|
|
|
proj4text = models.CharField(max_length=2048)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
db_table = 'spatial_ref_sys'
|
2009-04-17 06:25:01 +08:00
|
|
|
managed = False
|
2008-08-06 02:13:06 +08:00
|
|
|
|
|
|
|
@property
|
|
|
|
def wkt(self):
|
|
|
|
return self.srtext
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def wkt_col(cls):
|
|
|
|
return 'srtext'
|