PageRenderTime 2142ms CodeModel.GetById 2125ms RepoModel.GetById 0ms app.codeStats 0ms

/django/contrib/gis/tests/geoapp/models.py

https://code.google.com/p/mango-py/
Python | 46 lines | 36 code | 8 blank | 2 comment | 1 complexity | 16a8d74a8412a58dfd11be9d84706d56 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. from django.contrib.gis.db import models
  2. from django.contrib.gis.tests.utils import mysql, spatialite
  3. # MySQL spatial indices can't handle NULL geometries.
  4. null_flag = not mysql
  5. class Country(models.Model):
  6. name = models.CharField(max_length=30)
  7. mpoly = models.MultiPolygonField() # SRID, by default, is 4326
  8. objects = models.GeoManager()
  9. def __unicode__(self): return self.name
  10. class City(models.Model):
  11. name = models.CharField(max_length=30)
  12. point = models.PointField()
  13. objects = models.GeoManager()
  14. def __unicode__(self): return self.name
  15. # This is an inherited model from City
  16. class PennsylvaniaCity(City):
  17. county = models.CharField(max_length=30)
  18. founded = models.DateTimeField(null=True)
  19. objects = models.GeoManager() # TODO: This should be implicitly inherited.
  20. class State(models.Model):
  21. name = models.CharField(max_length=30)
  22. poly = models.PolygonField(null=null_flag) # Allowing NULL geometries here.
  23. objects = models.GeoManager()
  24. def __unicode__(self): return self.name
  25. class Track(models.Model):
  26. name = models.CharField(max_length=30)
  27. line = models.LineStringField()
  28. objects = models.GeoManager()
  29. def __unicode__(self): return self.name
  30. if not spatialite:
  31. class Feature(models.Model):
  32. name = models.CharField(max_length=20)
  33. geom = models.GeometryField()
  34. objects = models.GeoManager()
  35. def __unicode__(self): return self.name
  36. class MinusOneSRID(models.Model):
  37. geom = models.PointField(srid=-1) # Minus one SRID.
  38. objects = models.GeoManager()