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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. """
  2. The GeometryColumns and SpatialRefSys models for the PostGIS backend.
  3. """
  4. from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin
  5. from django.db import models
  6. class PostGISGeometryColumns(models.Model):
  7. """
  8. The 'geometry_columns' view from PostGIS. See the PostGIS
  9. documentation at Ch. 4.3.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. app_label = 'gis'
  20. db_table = 'geometry_columns'
  21. managed = False
  22. def __str__(self):
  23. return '%s.%s - %dD %s field (SRID: %d)' % (
  24. self.f_table_name,
  25. self.f_geometry_column,
  26. self.coord_dimension,
  27. self.type,
  28. self.srid,
  29. )
  30. @classmethod
  31. def table_name_col(cls):
  32. """
  33. Return the name of the metadata column used to store the feature table
  34. name.
  35. """
  36. return 'f_table_name'
  37. @classmethod
  38. def geom_col_name(cls):
  39. """
  40. Return the name of the metadata column used to store the feature
  41. geometry column.
  42. """
  43. return 'f_geometry_column'
  44. class PostGISSpatialRefSys(models.Model, SpatialRefSysMixin):
  45. """
  46. The 'spatial_ref_sys' table from PostGIS. See the PostGIS
  47. documentation at Ch. 4.2.1.
  48. """
  49. srid = models.IntegerField(primary_key=True)
  50. auth_name = models.CharField(max_length=256)
  51. auth_srid = models.IntegerField()
  52. srtext = models.CharField(max_length=2048)
  53. proj4text = models.CharField(max_length=2048)
  54. class Meta:
  55. app_label = 'gis'
  56. db_table = 'spatial_ref_sys'
  57. managed = False
  58. @property
  59. def wkt(self):
  60. return self.srtext