| 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 |
|
| 11 |
from django.contrib.gis.db import models |
| 12 |
from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin |
| 13 |
|
| 14 |
|
| 15 |
class OracleGeometryColumns(models.Model): |
| 16 |
"Maps to the Oracle USER_SDO_GEOM_METADATA table." |
| 17 |
|
| 18 |
table_name = models.CharField(max_length=32) |
| 19 |
column_name = models.CharField(max_length=1024) |
| 20 |
srid = models.IntegerField(primary_key=True) |
| 21 |
# TODO: Add support for `diminfo` column (type MDSYS.SDO_DIM_ARRAY). |
| 22 |
|
| 23 |
class Meta: |
| 24 |
app_label = "gis" |
| 25 |
db_table = "USER_SDO_GEOM_METADATA" |
| 26 |
managed = False |
| 27 |
|
| 28 |
def __str__(self): |
| 29 |
return "%s - %s (SRID: %s)" % (self.table_name, self.column_name, self.srid) |
| 30 |
|
| 31 |
@classmethod |
| 32 |
def table_name_col(cls): |
| 33 |
""" |
| 34 |
Return the name of the metadata column used to store the feature table |
| 35 |
name. |
| 36 |
""" |
| 37 |
return "table_name" |
| 38 |
|
| 39 |
@classmethod |
| 40 |
def geom_col_name(cls): |
| 41 |
""" |
| 42 |
Return the name of the metadata column used to store the feature |
| 43 |
geometry column. |
| 44 |
""" |
| 45 |
return "column_name" |
| 46 |
|
| 47 |
|
| 48 |
class OracleSpatialRefSys(models.Model, SpatialRefSysMixin): |
| 49 |
"Maps to the Oracle MDSYS.CS_SRS table." |
| 50 |
|
| 51 |
cs_name = models.CharField(max_length=68) |
| 52 |
srid = models.IntegerField(primary_key=True) |
| 53 |
auth_srid = models.IntegerField() |
| 54 |
auth_name = models.CharField(max_length=256) |
| 55 |
wktext = models.CharField(max_length=2046) |
| 56 |
# Optional geometry representing the bounds of this coordinate |
| 57 |
# system. By default, all are NULL in the table. |
| 58 |
cs_bounds = models.PolygonField(null=True) |
| 59 |
|
| 60 |
class Meta: |
| 61 |
app_label = "gis" |
| 62 |
db_table = "CS_SRS" |
| 63 |
managed = False |
| 64 |
|
| 65 |
@property |
| 66 |
def wkt(self): |
| 67 |
return self.wktext |