You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

models.py 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. """
  2. The GeometryColumns and SpatialRefSys models for the Oracle spatial
  3. backend.
  4. It should be noted that Oracle Spatial does not have database tables
  5. named according to the OGC standard, so the closest analogs are used.
  6. For example, the `USER_SDO_GEOM_METADATA` is used for the GeometryColumns
  7. model and the `SDO_COORD_REF_SYS` is used for the SpatialRefSys model.
  8. """
  9. from django.contrib.gis.db import models
  10. from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin
  11. class OracleGeometryColumns(models.Model):
  12. "Maps to the Oracle USER_SDO_GEOM_METADATA table."
  13. table_name = models.CharField(max_length=32)
  14. column_name = models.CharField(max_length=1024)
  15. srid = models.IntegerField(primary_key=True)
  16. # TODO: Add support for `diminfo` column (type MDSYS.SDO_DIM_ARRAY).
  17. class Meta:
  18. app_label = 'gis'
  19. db_table = 'USER_SDO_GEOM_METADATA'
  20. managed = False
  21. def __str__(self):
  22. return '%s - %s (SRID: %s)' % (self.table_name, self.column_name, self.srid)
  23. @classmethod
  24. def table_name_col(cls):
  25. """
  26. Return the name of the metadata column used to store the feature table
  27. name.
  28. """
  29. return 'table_name'
  30. @classmethod
  31. def geom_col_name(cls):
  32. """
  33. Return the name of the metadata column used to store the feature
  34. geometry column.
  35. """
  36. return 'column_name'
  37. class OracleSpatialRefSys(models.Model, SpatialRefSysMixin):
  38. "Maps to the Oracle MDSYS.CS_SRS table."
  39. cs_name = models.CharField(max_length=68)
  40. srid = models.IntegerField(primary_key=True)
  41. auth_srid = models.IntegerField()
  42. auth_name = models.CharField(max_length=256)
  43. wktext = models.CharField(max_length=2046)
  44. # Optional geometry representing the bounds of this coordinate
  45. # system. By default, all are NULL in the table.
  46. cs_bounds = models.PolygonField(null=True)
  47. class Meta:
  48. app_label = 'gis'
  49. db_table = 'CS_SRS'
  50. managed = False
  51. @property
  52. def wkt(self):
  53. return self.wktext