2008-08-06 02:13:06 +08:00
|
|
|
"""
|
|
|
|
The GeometryColumns and SpatialRefSys models for the Oracle spatial
|
|
|
|
backend.
|
|
|
|
|
|
|
|
It should be noted that Oracle Spatial does not have database tables
|
|
|
|
named according to the OGC standard, so the closest analogs are used.
|
|
|
|
For example, the `USER_SDO_GEOM_METADATA` is used for the GeometryColumns
|
|
|
|
model and the `SDO_COORD_REF_SYS` is used for the SpatialRefSys model.
|
|
|
|
"""
|
2009-12-22 23:18:51 +08:00
|
|
|
from django.contrib.gis.db import models
|
2015-01-13 04:20:40 +08:00
|
|
|
from django.contrib.gis.db.backends.base.models 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
|
|
|
|
2013-11-03 01:18:46 +08:00
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
@python_2_unicode_compatible
|
2014-06-08 15:54:35 +08:00
|
|
|
class OracleGeometryColumns(models.Model):
|
2008-08-06 02:13:06 +08:00
|
|
|
"Maps to the Oracle USER_SDO_GEOM_METADATA table."
|
|
|
|
table_name = models.CharField(max_length=32)
|
|
|
|
column_name = models.CharField(max_length=1024)
|
|
|
|
srid = models.IntegerField(primary_key=True)
|
|
|
|
# TODO: Add support for `diminfo` column (type MDSYS.SDO_DIM_ARRAY).
|
2013-10-22 18:21:07 +08:00
|
|
|
|
2008-08-06 02:13:06 +08:00
|
|
|
class Meta:
|
2014-06-08 15:54:35 +08:00
|
|
|
app_label = 'gis'
|
2008-08-06 02:13:06 +08:00
|
|
|
db_table = 'USER_SDO_GEOM_METADATA'
|
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
|
|
|
"""
|
2014-04-27 01:18:45 +08:00
|
|
|
Returns the name of the metadata column used to store the feature table
|
|
|
|
name.
|
2008-09-10 03:19:51 +08:00
|
|
|
"""
|
2008-08-06 02:13:06 +08:00
|
|
|
return 'table_name'
|
|
|
|
|
2008-09-10 03:19:51 +08:00
|
|
|
@classmethod
|
|
|
|
def geom_col_name(cls):
|
|
|
|
"""
|
2014-04-27 01:18:45 +08:00
|
|
|
Returns the name of the metadata column used to store the feature
|
|
|
|
geometry column.
|
2008-09-10 03:19:51 +08:00
|
|
|
"""
|
|
|
|
return 'column_name'
|
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
def __str__(self):
|
2008-08-06 02:13:06 +08:00
|
|
|
return '%s - %s (SRID: %s)' % (self.table_name, self.column_name, self.srid)
|
|
|
|
|
2013-11-03 01:18:46 +08:00
|
|
|
|
2014-06-08 15:54:35 +08:00
|
|
|
class OracleSpatialRefSys(models.Model, SpatialRefSysMixin):
|
2008-08-06 02:13:06 +08:00
|
|
|
"Maps to the Oracle MDSYS.CS_SRS table."
|
|
|
|
cs_name = models.CharField(max_length=68)
|
|
|
|
srid = models.IntegerField(primary_key=True)
|
|
|
|
auth_srid = models.IntegerField()
|
|
|
|
auth_name = models.CharField(max_length=256)
|
|
|
|
wktext = models.CharField(max_length=2046)
|
2009-12-22 23:18:51 +08:00
|
|
|
# Optional geometry representing the bounds of this coordinate
|
|
|
|
# system. By default, all are NULL in the table.
|
|
|
|
cs_bounds = models.PolygonField(null=True)
|
|
|
|
objects = models.GeoManager()
|
2008-08-06 02:13:06 +08:00
|
|
|
|
|
|
|
class Meta:
|
2014-06-08 15:54:35 +08:00
|
|
|
app_label = 'gis'
|
2008-08-06 02:13:06 +08:00
|
|
|
db_table = 'CS_SRS'
|
2009-04-17 06:25:01 +08:00
|
|
|
managed = False
|
2008-08-06 02:13:06 +08:00
|
|
|
|
|
|
|
@property
|
|
|
|
def wkt(self):
|
|
|
|
return self.wktext
|