~canonical-django/canonical-django/project-template

« back to all changes in this revision

Viewing changes to trunk/python-packages/django/contrib/gis/tests/layermap/models.py

  • Committer: Matthew Nuzum
  • Date: 2008-11-13 05:46:03 UTC
  • Revision ID: matthew.nuzum@canonical.com-20081113054603-v0kvr6z6xyexvqt3
adding to version control

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from django.contrib.gis.db import models
 
2
 
 
3
class State(models.Model):
 
4
    name = models.CharField(max_length=20)
 
5
    objects = models.GeoManager()
 
6
 
 
7
class 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
 
 
13
class CountyFeat(models.Model):
 
14
    name = models.CharField(max_length=25)
 
15
    poly = models.PolygonField(srid=4269)
 
16
    objects = models.GeoManager()
 
17
 
 
18
class 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
 
 
26
class 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
# Mapping dictionaries for the models above.
 
33
co_mapping = {'name' : 'Name',
 
34
              'state' : {'name' : 'State'}, # ForeignKey's use another mapping dictionary for the _related_ Model (State in this case).
 
35
              'mpoly' : 'MULTIPOLYGON', # Will convert POLYGON features into MULTIPOLYGONS.
 
36
              }
 
37
 
 
38
cofeat_mapping = {'name' : 'Name',
 
39
                  'poly' : 'POLYGON',
 
40
                  }
 
41
 
 
42
city_mapping = {'name' : 'Name',
 
43
                'population' : 'Population',
 
44
                'density' : 'Density',
 
45
                'dt' : 'Created',
 
46
                'point' : 'POINT',
 
47
                }
 
48
 
 
49
inter_mapping = {'name' : 'Name',
 
50
                 'length' : 'Length',
 
51
                 'path' : 'LINESTRING',
 
52
                 }