2008-08-05 18:13:06 +00:00
|
|
|
from django.contrib.gis.db import models
|
2009-03-30 17:15:49 +00:00
|
|
|
from django.contrib.gis.tests.utils import mysql, spatialite
|
2008-08-05 18:13:06 +00:00
|
|
|
|
|
|
|
# MySQL spatial indices can't handle NULL geometries.
|
|
|
|
null_flag = not mysql
|
|
|
|
|
|
|
|
class Country(models.Model):
|
|
|
|
name = models.CharField(max_length=30)
|
|
|
|
mpoly = models.MultiPolygonField() # SRID, by default, is 4326
|
|
|
|
objects = models.GeoManager()
|
|
|
|
def __unicode__(self): return self.name
|
|
|
|
|
|
|
|
class City(models.Model):
|
|
|
|
name = models.CharField(max_length=30)
|
2009-03-30 17:15:49 +00:00
|
|
|
point = models.PointField()
|
2008-08-05 18:13:06 +00:00
|
|
|
objects = models.GeoManager()
|
|
|
|
def __unicode__(self): return self.name
|
|
|
|
|
2008-11-05 17:51:11 +00:00
|
|
|
# This is an inherited model from City
|
|
|
|
class PennsylvaniaCity(City):
|
|
|
|
county = models.CharField(max_length=30)
|
2011-09-09 22:34:23 +00:00
|
|
|
founded = models.DateTimeField(null=True)
|
2008-11-05 17:51:11 +00:00
|
|
|
objects = models.GeoManager() # TODO: This should be implicitly inherited.
|
|
|
|
|
2008-08-05 18:13:06 +00:00
|
|
|
class State(models.Model):
|
|
|
|
name = models.CharField(max_length=30)
|
|
|
|
poly = models.PolygonField(null=null_flag) # Allowing NULL geometries here.
|
|
|
|
objects = models.GeoManager()
|
|
|
|
def __unicode__(self): return self.name
|
|
|
|
|
2010-01-29 02:20:58 +00:00
|
|
|
class Track(models.Model):
|
|
|
|
name = models.CharField(max_length=30)
|
|
|
|
line = models.LineStringField()
|
|
|
|
objects = models.GeoManager()
|
|
|
|
def __unicode__(self): return self.name
|
|
|
|
|
2009-03-30 17:15:49 +00:00
|
|
|
if not spatialite:
|
|
|
|
class Feature(models.Model):
|
|
|
|
name = models.CharField(max_length=20)
|
|
|
|
geom = models.GeometryField()
|
|
|
|
objects = models.GeoManager()
|
|
|
|
def __unicode__(self): return self.name
|
2008-08-05 18:13:06 +00:00
|
|
|
|
2009-03-30 17:15:49 +00:00
|
|
|
class MinusOneSRID(models.Model):
|
|
|
|
geom = models.PointField(srid=-1) # Minus one SRID.
|
|
|
|
objects = models.GeoManager()
|