PageRenderTime 222ms CodeModel.GetById 100ms app.highlight 5ms RepoModel.GetById 116ms app.codeStats 0ms

/django/contrib/gis/tests/geoapp/models.py

https://code.google.com/p/mango-py/
Python | 46 lines | 36 code | 8 blank | 2 comment | 3 complexity | 16a8d74a8412a58dfd11be9d84706d56 MD5 | raw file
 1from django.contrib.gis.db import models
 2from django.contrib.gis.tests.utils import mysql, spatialite
 3
 4# MySQL spatial indices can't handle NULL geometries.
 5null_flag = not mysql
 6
 7class Country(models.Model):
 8    name = models.CharField(max_length=30)
 9    mpoly = models.MultiPolygonField() # SRID, by default, is 4326
10    objects = models.GeoManager()
11    def __unicode__(self): return self.name
12
13class City(models.Model):
14    name = models.CharField(max_length=30)
15    point = models.PointField()
16    objects = models.GeoManager()
17    def __unicode__(self): return self.name
18
19# This is an inherited model from City
20class PennsylvaniaCity(City):
21    county = models.CharField(max_length=30)
22    founded = models.DateTimeField(null=True)
23    objects = models.GeoManager() # TODO: This should be implicitly inherited.
24
25class State(models.Model):
26    name = models.CharField(max_length=30)
27    poly = models.PolygonField(null=null_flag) # Allowing NULL geometries here.
28    objects = models.GeoManager()
29    def __unicode__(self): return self.name
30
31class Track(models.Model):
32    name = models.CharField(max_length=30)
33    line = models.LineStringField()
34    objects = models.GeoManager()
35    def __unicode__(self): return self.name
36
37if not spatialite:
38    class Feature(models.Model):
39        name = models.CharField(max_length=20)
40        geom = models.GeometryField()
41        objects = models.GeoManager()
42        def __unicode__(self): return self.name
43
44    class MinusOneSRID(models.Model):
45        geom = models.PointField(srid=-1) # Minus one SRID.
46        objects = models.GeoManager()