PageRenderTime 19ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://code.google.com/p/mango-py/
Python | 69 lines | 54 code | 13 blank | 2 comment | 0 complexity | 0d8d24eff90f6c48345f70081387f457 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. from django.contrib.gis.db import models
  2. class State(models.Model):
  3. name = models.CharField(max_length=20)
  4. objects = models.GeoManager()
  5. class County(models.Model):
  6. name = models.CharField(max_length=25)
  7. state = models.ForeignKey(State)
  8. mpoly = models.MultiPolygonField(srid=4269) # Multipolygon in NAD83
  9. objects = models.GeoManager()
  10. class CountyFeat(models.Model):
  11. name = models.CharField(max_length=25)
  12. poly = models.PolygonField(srid=4269)
  13. objects = models.GeoManager()
  14. class City(models.Model):
  15. name = models.CharField(max_length=25)
  16. population = models.IntegerField()
  17. density = models.DecimalField(max_digits=7, decimal_places=1)
  18. dt = models.DateField()
  19. point = models.PointField()
  20. objects = models.GeoManager()
  21. class Interstate(models.Model):
  22. name = models.CharField(max_length=20)
  23. length = models.DecimalField(max_digits=6, decimal_places=2)
  24. path = models.LineStringField()
  25. objects = models.GeoManager()
  26. # Same as `City` above, but for testing model inheritance.
  27. class CityBase(models.Model):
  28. name = models.CharField(max_length=25)
  29. population = models.IntegerField()
  30. density = models.DecimalField(max_digits=7, decimal_places=1)
  31. point = models.PointField()
  32. objects = models.GeoManager()
  33. class ICity1(CityBase):
  34. dt = models.DateField()
  35. class ICity2(ICity1):
  36. dt_time = models.DateTimeField(auto_now=True)
  37. class Invalid(models.Model):
  38. point = models.PointField()
  39. # Mapping dictionaries for the models above.
  40. co_mapping = {'name' : 'Name',
  41. 'state' : {'name' : 'State'}, # ForeignKey's use another mapping dictionary for the _related_ Model (State in this case).
  42. 'mpoly' : 'MULTIPOLYGON', # Will convert POLYGON features into MULTIPOLYGONS.
  43. }
  44. cofeat_mapping = {'name' : 'Name',
  45. 'poly' : 'POLYGON',
  46. }
  47. city_mapping = {'name' : 'Name',
  48. 'population' : 'Population',
  49. 'density' : 'Density',
  50. 'dt' : 'Created',
  51. 'point' : 'POINT',
  52. }
  53. inter_mapping = {'name' : 'Name',
  54. 'length' : 'Length',
  55. 'path' : 'LINESTRING',
  56. }