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

80 lines
2.2 KiB
Python
Raw Normal View History

from django.contrib.gis.db import models
2013-11-03 04:12:09 +08:00
class State(models.Model):
name = models.CharField(max_length=20)
objects = models.GeoManager()
2013-11-03 04:12:09 +08:00
class County(models.Model):
name = models.CharField(max_length=25)
state = models.ForeignKey(State)
2013-11-03 05:02:56 +08:00
mpoly = models.MultiPolygonField(srid=4269) # Multipolygon in NAD83
objects = models.GeoManager()
2013-11-03 04:12:09 +08:00
class CountyFeat(models.Model):
name = models.CharField(max_length=25)
poly = models.PolygonField(srid=4269)
objects = models.GeoManager()
2013-11-03 04:12:09 +08:00
class City(models.Model):
name = models.CharField(max_length=25)
name_txt = models.TextField(default='')
population = models.IntegerField()
density = models.DecimalField(max_digits=7, decimal_places=1)
dt = models.DateField()
point = models.PointField()
objects = models.GeoManager()
2013-11-03 04:12:09 +08:00
class Interstate(models.Model):
name = models.CharField(max_length=20)
length = models.DecimalField(max_digits=6, decimal_places=2)
path = models.LineStringField()
objects = models.GeoManager()
2013-11-03 04:12:09 +08:00
# Same as `City` above, but for testing model inheritance.
class CityBase(models.Model):
name = models.CharField(max_length=25)
population = models.IntegerField()
density = models.DecimalField(max_digits=7, decimal_places=1)
point = models.PointField()
objects = models.GeoManager()
2013-11-03 04:12:09 +08:00
class ICity1(CityBase):
dt = models.DateField()
2013-11-03 04:12:09 +08:00
class ICity2(ICity1):
dt_time = models.DateTimeField(auto_now=True)
2013-11-03 04:12:09 +08:00
class Invalid(models.Model):
point = models.PointField()
# Mapping dictionaries for the models above.
2013-10-27 09:27:42 +08:00
co_mapping = {'name': 'Name',
2013-11-03 05:02:56 +08:00
'state': {'name': 'State'}, # ForeignKey's use another mapping dictionary for the _related_ Model (State in this case).
'mpoly': 'MULTIPOLYGON', # Will convert POLYGON features into MULTIPOLYGONS.
}
2013-10-27 09:27:42 +08:00
cofeat_mapping = {'name': 'Name',
'poly': 'POLYGON',
}
2013-10-27 09:27:42 +08:00
city_mapping = {'name': 'Name',
'population': 'Population',
'density': 'Density',
'dt': 'Created',
'point': 'POINT',
}
2013-10-27 09:27:42 +08:00
inter_mapping = {'name': 'Name',
'length': 'Length',
'path': 'LINESTRING',
}