2
The GeometryColumns and SpatialRefSys models for the PostGIS backend.
4
from django.db import models
5
from django.contrib.gis.models import SpatialRefSysMixin
7
# Checking for the presence of GDAL (needed for the SpatialReference object)
8
from django.contrib.gis.gdal import HAS_GDAL
10
from django.contrib.gis.gdal import SpatialReference
12
class GeometryColumns(models.Model):
14
The 'geometry_columns' table from the PostGIS. See the PostGIS
15
documentation at Ch. 4.2.2.
17
f_table_catalog = models.CharField(max_length=256)
18
f_table_schema = models.CharField(max_length=256)
19
f_table_name = models.CharField(max_length=256)
20
f_geometry_column = models.CharField(max_length=256)
21
coord_dimension = models.IntegerField()
22
srid = models.IntegerField(primary_key=True)
23
type = models.CharField(max_length=30)
26
db_table = 'geometry_columns'
29
def table_name_col(cls):
30
"Class method for returning the table name column for this model."
33
def __unicode__(self):
34
return "%s.%s - %dD %s field (SRID: %d)" % \
35
(self.f_table_name, self.f_geometry_column,
36
self.coord_dimension, self.type, self.srid)
38
class SpatialRefSys(models.Model, SpatialRefSysMixin):
40
The 'spatial_ref_sys' table from PostGIS. See the PostGIS
41
documentaiton at Ch. 4.2.1.
43
srid = models.IntegerField(primary_key=True)
44
auth_name = models.CharField(max_length=256)
45
auth_srid = models.IntegerField()
46
srtext = models.CharField(max_length=2048)
47
proj4text = models.CharField(max_length=2048)
50
db_table = 'spatial_ref_sys'