2016-11-05 18:35:58 +08:00
|
|
|
from django.contrib.gis.db import models
|
2009-12-24 04:45:08 +08:00
|
|
|
|
2013-11-03 04:12:09 +08:00
|
|
|
|
2014-01-01 18:01:46 +08:00
|
|
|
class NamedModel(models.Model):
|
2009-12-24 04:45:08 +08:00
|
|
|
name = models.CharField(max_length=30)
|
2014-01-01 18:01:46 +08:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
abstract = True
|
|
|
|
|
2013-10-17 16:17:41 +08:00
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
2009-12-24 04:45:08 +08:00
|
|
|
|
2013-11-03 04:12:09 +08:00
|
|
|
|
2014-01-01 18:01:46 +08:00
|
|
|
class City(NamedModel):
|
|
|
|
point = models.PointField(geography=True)
|
2013-10-17 16:17:41 +08:00
|
|
|
|
2015-03-21 23:59:30 +08:00
|
|
|
class Meta:
|
|
|
|
app_label = 'geogapp'
|
|
|
|
|
2014-01-01 18:01:46 +08:00
|
|
|
|
|
|
|
class Zipcode(NamedModel):
|
2014-01-01 19:07:43 +08:00
|
|
|
code = models.CharField(max_length=10)
|
2014-01-01 18:01:46 +08:00
|
|
|
poly = models.PolygonField(geography=True)
|
2009-12-25 22:37:57 +08:00
|
|
|
|
2013-11-03 04:12:09 +08:00
|
|
|
|
2014-01-01 18:01:46 +08:00
|
|
|
class County(NamedModel):
|
2009-12-25 22:37:57 +08:00
|
|
|
state = models.CharField(max_length=20)
|
|
|
|
mpoly = models.MultiPolygonField(geography=True)
|
2013-10-17 16:17:41 +08:00
|
|
|
|
2015-03-21 23:59:30 +08:00
|
|
|
class Meta:
|
|
|
|
app_label = 'geogapp'
|
|
|
|
|
2013-10-17 16:17:41 +08:00
|
|
|
def __str__(self):
|
|
|
|
return ' County, '.join([self.name, self.state])
|