PageRenderTime 36ms CodeModel.GetById 18ms app.highlight 15ms RepoModel.GetById 1ms 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
 1from django.contrib.gis.db import models
 2
 3class State(models.Model):
 4    name = models.CharField(max_length=20)
 5    objects = models.GeoManager()
 6
 7class County(models.Model):
 8    name = models.CharField(max_length=25)
 9    state = models.ForeignKey(State)
10    mpoly = models.MultiPolygonField(srid=4269) # Multipolygon in NAD83
11    objects = models.GeoManager()
12
13class CountyFeat(models.Model):
14    name = models.CharField(max_length=25)
15    poly = models.PolygonField(srid=4269)
16    objects = models.GeoManager()
17
18class City(models.Model):
19    name = models.CharField(max_length=25)
20    population = models.IntegerField()
21    density = models.DecimalField(max_digits=7, decimal_places=1)
22    dt = models.DateField()
23    point = models.PointField()
24    objects = models.GeoManager()
25
26class Interstate(models.Model):
27    name = models.CharField(max_length=20)
28    length = models.DecimalField(max_digits=6, decimal_places=2)
29    path = models.LineStringField()
30    objects = models.GeoManager()
31
32# Same as `City` above, but for testing model inheritance.
33class CityBase(models.Model):
34    name = models.CharField(max_length=25)
35    population = models.IntegerField()
36    density = models.DecimalField(max_digits=7, decimal_places=1)
37    point = models.PointField()
38    objects = models.GeoManager()
39
40class ICity1(CityBase):
41    dt = models.DateField()
42    
43class ICity2(ICity1):
44    dt_time = models.DateTimeField(auto_now=True)
45
46class Invalid(models.Model):
47    point = models.PointField()
48
49# Mapping dictionaries for the models above.
50co_mapping = {'name' : 'Name',
51              'state' : {'name' : 'State'}, # ForeignKey's use another mapping dictionary for the _related_ Model (State in this case).
52              'mpoly' : 'MULTIPOLYGON', # Will convert POLYGON features into MULTIPOLYGONS.
53              }
54
55cofeat_mapping = {'name' : 'Name',
56                  'poly' : 'POLYGON',
57                  }
58
59city_mapping = {'name' : 'Name',
60                'population' : 'Population',
61                'density' : 'Density',
62                'dt' : 'Created',
63                'point' : 'POINT',
64                }
65
66inter_mapping = {'name' : 'Name',
67                 'length' : 'Length',
68                 'path' : 'LINESTRING',
69                 }