PageRenderTime 30ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://code.google.com/p/mango-py/
Python | 66 lines | 61 code | 1 blank | 4 comment | 0 complexity | 1977605e79b1cd6fecaf4f8f0e745c54 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. """
  2. The GeometryColumns and SpatialRefSys models for the PostGIS backend.
  3. """
  4. from django.db import models
  5. from django.contrib.gis.db.backends.base import SpatialRefSysMixin
  6. class GeometryColumns(models.Model):
  7. """
  8. The 'geometry_columns' table from the PostGIS. See the PostGIS
  9. documentation at Ch. 4.2.2.
  10. """
  11. f_table_catalog = models.CharField(max_length=256)
  12. f_table_schema = models.CharField(max_length=256)
  13. f_table_name = models.CharField(max_length=256)
  14. f_geometry_column = models.CharField(max_length=256)
  15. coord_dimension = models.IntegerField()
  16. srid = models.IntegerField(primary_key=True)
  17. type = models.CharField(max_length=30)
  18. class Meta:
  19. db_table = 'geometry_columns'
  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 'f_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 'f_geometry_column'
  35. def __unicode__(self):
  36. return "%s.%s - %dD %s field (SRID: %d)" % \
  37. (self.f_table_name, self.f_geometry_column,
  38. self.coord_dimension, self.type, self.srid)
  39. class SpatialRefSys(models.Model, SpatialRefSysMixin):
  40. """
  41. The 'spatial_ref_sys' table from PostGIS. See the PostGIS
  42. documentaiton at Ch. 4.2.1.
  43. """
  44. srid = models.IntegerField(primary_key=True)
  45. auth_name = models.CharField(max_length=256)
  46. auth_srid = models.IntegerField()
  47. srtext = models.CharField(max_length=2048)
  48. proj4text = models.CharField(max_length=2048)
  49. class Meta:
  50. db_table = 'spatial_ref_sys'
  51. managed = False
  52. @property
  53. def wkt(self):
  54. return self.srtext
  55. @classmethod
  56. def wkt_col(cls):
  57. return 'srtext'