| 1 |
""" |
|---|
| 2 |
The GeometryColumns and SpatialRefSys models for the Oracle spatial |
|---|
| 3 |
backend. |
|---|
| 4 |
|
|---|
| 5 |
It should be noted that Oracle Spatial does not have database tables |
|---|
| 6 |
named according to the OGC standard, so the closest analogs are used. |
|---|
| 7 |
For example, the `USER_SDO_GEOM_METADATA` is used for the GeometryColumns |
|---|
| 8 |
model and the `SDO_COORD_REF_SYS` is used for the SpatialRefSys model. |
|---|
| 9 |
""" |
|---|
| 10 |
from django.db import models |
|---|
| 11 |
from django.contrib.gis.models import SpatialRefSysMixin |
|---|
| 12 |
|
|---|
| 13 |
class GeometryColumns(models.Model): |
|---|
| 14 |
"Maps to the Oracle USER_SDO_GEOM_METADATA table." |
|---|
| 15 |
table_name = models.CharField(max_length=32) |
|---|
| 16 |
column_name = models.CharField(max_length=1024) |
|---|
| 17 |
srid = models.IntegerField(primary_key=True) |
|---|
| 18 |
# TODO: Add support for `diminfo` column (type MDSYS.SDO_DIM_ARRAY). |
|---|
| 19 |
class Meta: |
|---|
| 20 |
db_table = 'USER_SDO_GEOM_METADATA' |
|---|
| 21 |
|
|---|
| 22 |
@classmethod |
|---|
| 23 |
def table_name_col(cls): |
|---|
| 24 |
return 'table_name' |
|---|
| 25 |
|
|---|
| 26 |
def __unicode__(self): |
|---|
| 27 |
return '%s - %s (SRID: %s)' % (self.table_name, self.column_name, self.srid) |
|---|
| 28 |
|
|---|
| 29 |
class SpatialRefSys(models.Model, SpatialRefSysMixin): |
|---|
| 30 |
"Maps to the Oracle MDSYS.CS_SRS table." |
|---|
| 31 |
cs_name = models.CharField(max_length=68) |
|---|
| 32 |
srid = models.IntegerField(primary_key=True) |
|---|
| 33 |
auth_srid = models.IntegerField() |
|---|
| 34 |
auth_name = models.CharField(max_length=256) |
|---|
| 35 |
wktext = models.CharField(max_length=2046) |
|---|
| 36 |
#cs_bounds = models.GeometryField() |
|---|
| 37 |
|
|---|
| 38 |
class Meta: |
|---|
| 39 |
# TODO: Figure out way to have this be MDSYS.CS_SRS without |
|---|
| 40 |
# having django's quoting mess up the SQL. |
|---|
| 41 |
db_table = 'CS_SRS' |
|---|
| 42 |
|
|---|
| 43 |
@property |
|---|
| 44 |
def wkt(self): |
|---|
| 45 |
return self.wktext |
|---|
| 46 |
|
|---|
| 47 |
@classmethod |
|---|
| 48 |
def wkt_col(cls): |
|---|
| 49 |
return 'wktext' |
|---|