2008-08-06 02:13:06 +08:00
|
|
|
from django.contrib.gis.db import models
|
2008-09-02 06:15:35 +08:00
|
|
|
from django.contrib.localflavor.us.models import USStateField
|
2008-08-06 02:13:06 +08:00
|
|
|
|
|
|
|
class Location(models.Model):
|
|
|
|
point = models.PointField()
|
|
|
|
objects = models.GeoManager()
|
2009-04-02 00:01:50 +08:00
|
|
|
def __unicode__(self): return self.point.wkt
|
2008-08-06 02:13:06 +08:00
|
|
|
|
|
|
|
class City(models.Model):
|
|
|
|
name = models.CharField(max_length=50)
|
2008-09-02 06:15:35 +08:00
|
|
|
state = USStateField()
|
2008-08-06 02:13:06 +08:00
|
|
|
location = models.ForeignKey(Location)
|
|
|
|
objects = models.GeoManager()
|
2009-04-02 00:01:50 +08:00
|
|
|
def __unicode__(self): return self.name
|
2008-12-06 09:52:14 +08:00
|
|
|
|
|
|
|
class AugmentedLocation(Location):
|
|
|
|
extra_text = models.TextField(blank=True)
|
|
|
|
objects = models.GeoManager()
|
|
|
|
|
|
|
|
class DirectoryEntry(models.Model):
|
|
|
|
listing_text = models.CharField(max_length=50)
|
|
|
|
location = models.ForeignKey(AugmentedLocation)
|
|
|
|
objects = models.GeoManager()
|
2009-03-04 06:10:15 +08:00
|
|
|
|
|
|
|
class Parcel(models.Model):
|
|
|
|
name = models.CharField(max_length=30)
|
|
|
|
city = models.ForeignKey(City)
|
|
|
|
center1 = models.PointField()
|
|
|
|
# Throwing a curveball w/`db_column` here.
|
|
|
|
center2 = models.PointField(srid=2276, db_column='mycenter')
|
|
|
|
border1 = models.PolygonField()
|
|
|
|
border2 = models.PolygonField(srid=2276)
|
|
|
|
objects = models.GeoManager()
|
|
|
|
def __unicode__(self): return self.name
|
2009-06-03 12:49:16 +08:00
|
|
|
|
|
|
|
# These use the GeoManager but do not have any geographic fields.
|
|
|
|
class Author(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
objects = models.GeoManager()
|
|
|
|
|
|
|
|
class Book(models.Model):
|
|
|
|
title = models.CharField(max_length=100)
|
2009-06-30 00:31:21 +08:00
|
|
|
author = models.ForeignKey(Author, related_name='books', null=True)
|
2009-06-03 12:49:16 +08:00
|
|
|
objects = models.GeoManager()
|