1 from django
.contrib
.gis
.db
import models
2 from django
.contrib
.gis
.tests
.utils
import mysql
, spatialite
4 # MySQL spatial indices can't handle NULL geometries.
7 class 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
13 class 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
19 # This is an inherited model from City
20 class PennsylvaniaCity(City
):
21 county
= models
.CharField(max_length
=30)
22 objects
= models
.GeoManager() # TODO: This should be implicitly inherited.
24 class State(models
.Model
):
25 name
= models
.CharField(max_length
=30)
26 poly
= models
.PolygonField(null
=null_flag
) # Allowing NULL geometries here.
27 objects
= models
.GeoManager()
28 def __unicode__(self
): return self
.name
30 class Track(models
.Model
):
31 name
= models
.CharField(max_length
=30)
32 line
= models
.LineStringField()
33 objects
= models
.GeoManager()
34 def __unicode__(self
): return self
.name
37 class Feature(models
.Model
):
38 name
= models
.CharField(max_length
=20)
39 geom
= models
.GeometryField()
40 objects
= models
.GeoManager()
41 def __unicode__(self
): return self
.name
43 class MinusOneSRID(models
.Model
):
44 geom
= models
.PointField(srid
=-1) # Minus one SRID.
45 objects
= models
.GeoManager()