2009-12-23 20:45:08 +00:00
|
|
|
from django.contrib.gis.db import models
|
2012-08-12 10:32:08 +00:00
|
|
|
from django.utils.encoding import python_2_unicode_compatible
|
2009-12-23 20:45:08 +00:00
|
|
|
|
2013-11-02 20:12:09 +00:00
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
@python_2_unicode_compatible
|
2014-01-01 10:01:46 +00:00
|
|
|
class NamedModel(models.Model):
|
2009-12-23 20:45:08 +00:00
|
|
|
name = models.CharField(max_length=30)
|
2014-01-01 10:01:46 +00:00
|
|
|
|
2009-12-23 20:45:08 +00:00
|
|
|
objects = models.GeoManager()
|
2013-10-17 08:17:41 +00:00
|
|
|
|
2014-01-01 10:01:46 +00:00
|
|
|
class Meta:
|
|
|
|
abstract = True
|
|
|
|
|
2013-10-17 08:17:41 +00:00
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
2009-12-23 20:45:08 +00:00
|
|
|
|
2013-11-02 20:12:09 +00:00
|
|
|
|
2014-01-01 10:01:46 +00:00
|
|
|
class City(NamedModel):
|
|
|
|
point = models.PointField(geography=True)
|
2013-10-17 08:17:41 +00:00
|
|
|
|
2014-01-01 10:01:46 +00:00
|
|
|
|
|
|
|
class Zipcode(NamedModel):
|
2014-01-01 11:07:43 +00:00
|
|
|
code = models.CharField(max_length=10)
|
2014-01-01 10:01:46 +00:00
|
|
|
poly = models.PolygonField(geography=True)
|
2009-12-25 14:37:57 +00:00
|
|
|
|
2013-11-02 20:12:09 +00:00
|
|
|
|
2014-01-01 10:01:46 +00:00
|
|
|
class County(NamedModel):
|
2009-12-25 14:37:57 +00:00
|
|
|
state = models.CharField(max_length=20)
|
|
|
|
mpoly = models.MultiPolygonField(geography=True)
|
2013-10-17 08:17:41 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return ' County, '.join([self.name, self.state])
|