PageRenderTime 62ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/django/contrib/gis/db/backends/oracle/models.py

https://code.google.com/p/mango-py/
Python | 65 lines | 37 code | 8 blank | 20 comment | 0 complexity | a742e5de1c7613434085f655284fda85 MD5 | raw file
Possible License(s): BSD-3-Clause
  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.models.fields import GeometryField
  11. from django.contrib.gis.db.backends.base import SpatialRefSysMixin
  12. class GeometryColumns(models.Model):
  13. "Maps to the Oracle USER_SDO_GEOM_METADATA table."
  14. table_name = models.CharField(max_length=32)
  15. column_name = models.CharField(max_length=1024)
  16. srid = models.IntegerField(primary_key=True)
  17. # TODO: Add support for `diminfo` column (type MDSYS.SDO_DIM_ARRAY).
  18. class Meta:
  19. db_table = 'USER_SDO_GEOM_METADATA'
  20. managed = False
  21. @classmethod
  22. def table_name_col(cls):
  23. """
  24. Returns the name of the metadata column used to store the
  25. the feature table name.
  26. """
  27. return 'table_name'
  28. @classmethod
  29. def geom_col_name(cls):
  30. """
  31. Returns the name of the metadata column used to store the
  32. the feature geometry column.
  33. """
  34. return 'column_name'
  35. def __unicode__(self):
  36. return '%s - %s (SRID: %s)' % (self.table_name, self.column_name, self.srid)
  37. class SpatialRefSys(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. objects = models.GeoManager()
  48. class Meta:
  49. db_table = 'CS_SRS'
  50. managed = False
  51. @property
  52. def wkt(self):
  53. return self.wktext
  54. @classmethod
  55. def wkt_col(cls):
  56. return 'wktext'