2011-10-01 11:07:03 +00:00
|
|
|
from django.contrib.gis.db import models
|
|
|
|
from django.contrib.contenttypes.models import ContentType
|
|
|
|
from django.contrib.contenttypes import generic
|
|
|
|
|
|
|
|
|
|
|
|
LANGUAGE_CHOICES = (
|
|
|
|
('en', 'English'),
|
|
|
|
('ma', 'Marathi'),
|
|
|
|
('hi', 'Hindi'),
|
|
|
|
)
|
|
|
|
|
|
|
|
ALTERNATIVE_NAME_TYPES = (
|
|
|
|
('colloquial', 'Colloquial'),
|
|
|
|
('official', 'Official'),
|
|
|
|
('historical', 'Historical'),
|
|
|
|
('other', 'Other'),
|
|
|
|
)
|
|
|
|
|
|
|
|
DIRECTION_CHOICES = (
|
|
|
|
('up', 'Up'),
|
|
|
|
('down', 'Down'),
|
|
|
|
('ring', 'Ring'),
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class Stop(models.Model):
|
|
|
|
stopcode = models.IntegerField(unique=True, db_index=True)
|
2011-07-16 06:11:20 +00:00
|
|
|
stopname = models.CharField(max_length=512)
|
2011-10-01 11:07:03 +00:00
|
|
|
areacode = models.ForeignKey('Area')
|
|
|
|
displayname = models.CharField(max_length=512)
|
2011-10-12 11:28:13 +00:00
|
|
|
# smlength = models.IntegerField()
|
2011-07-16 06:11:20 +00:00
|
|
|
|
2011-07-16 13:26:27 +00:00
|
|
|
def __unicode__(self):
|
2011-10-01 11:07:03 +00:00
|
|
|
return self.stopname
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AlternativeName(models.Model):
|
|
|
|
name = models.CharField(max_length=255)
|
|
|
|
language = models.CharField(max_length=10, choices=LANGUAGE_CHOICES)
|
|
|
|
typ = models.CharField(max_length=64, choices=ALTERNATIVE_NAME_TYPES)
|
|
|
|
priority = models.IntegerField(default=0)
|
|
|
|
content_type = models.ForeignKey(ContentType)
|
|
|
|
object_id = models.PositiveIntegerField()
|
|
|
|
content_object = generic.GenericForeignKey('content_type', 'object_id')
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
|
|
|
|
class PhysicalStop(models.Model):
|
|
|
|
point = models.PointField(blank=True)
|
|
|
|
stop = models.ForeignKey(Stop)
|
|
|
|
direction = models.CharField(choices=DIRECTION_CHOICES, max_length=16)
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.stop.displayname
|
|
|
|
|
|
|
|
|
|
|
|
class Area(models.Model):
|
|
|
|
areacode = models.IntegerField(unique=True, db_index=True)
|
|
|
|
areaname = models.CharField(max_length=512)
|
|
|
|
polygon = models.PolygonField(blank=True)
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.areaname
|
2011-07-16 13:26:27 +00:00
|
|
|
|
|
|
|
|
2011-07-16 06:11:20 +00:00
|
|
|
class Atlas(models.Model):
|
2011-10-01 11:07:03 +00:00
|
|
|
routecode = models.CharField(max_length=512, db_index=True)
|
2011-07-16 06:11:20 +00:00
|
|
|
route = models.CharField(max_length=512)
|
|
|
|
busfrom = models.CharField(max_length=512)
|
|
|
|
firstfrom = models.CharField(max_length=512)
|
|
|
|
lastfrom = models.CharField(max_length=512)
|
|
|
|
busto = models.CharField(max_length=512)
|
|
|
|
firstto = models.CharField(max_length=512)
|
|
|
|
lastto = models.CharField(max_length=512)
|
|
|
|
routespan = models.CharField(max_length=512)
|
|
|
|
runtime7to11 = models.CharField(max_length=512)
|
|
|
|
runtime11to17 = models.CharField(max_length=512)
|
|
|
|
runtime17toend = models.CharField(max_length=512)
|
|
|
|
runtimenight = models.CharField(max_length=512)
|
|
|
|
headwaybefore7 = models.CharField(max_length=512)
|
|
|
|
headway7to11 = models.CharField(max_length=512)
|
|
|
|
headway11to17 = models.CharField(max_length=512)
|
|
|
|
headway17to20 = models.CharField(max_length=512)
|
|
|
|
headway20tolast = models.CharField(max_length=512)
|
|
|
|
reliefpoint = models.CharField(max_length=512)
|
|
|
|
traveltime = models.CharField(max_length=512)
|
|
|
|
scheduletype = models.CharField(max_length=512)
|
|
|
|
|
2011-07-16 13:26:27 +00:00
|
|
|
def __unicode__(self):
|
|
|
|
return self.route
|
|
|
|
|
|
|
|
|
2011-10-01 11:07:03 +00:00
|
|
|
class RouteType(models.Model):
|
2011-07-16 06:11:20 +00:00
|
|
|
typenumber = models.IntegerField()
|
|
|
|
routetype = models.CharField(max_length=512)
|
|
|
|
|
2011-07-16 13:26:27 +00:00
|
|
|
def __unicode__(self):
|
|
|
|
return self.routetype
|
|
|
|
|
|
|
|
|
2011-10-01 11:07:03 +00:00
|
|
|
class Route(models.Model):
|
2011-07-16 06:11:20 +00:00
|
|
|
routecode = models.CharField(max_length=512)
|
|
|
|
stopserial = models.IntegerField()
|
|
|
|
stageno = models.IntegerField()
|
2011-10-01 11:07:03 +00:00
|
|
|
stopcode = models.ForeignKey('Stop')
|
|
|
|
physical_stop = models.ForeignKey('PhysicalStop')
|
2011-07-16 06:11:20 +00:00
|
|
|
stage = models.CharField(max_length=512)
|
|
|
|
km = models.FloatField()
|
2011-10-01 11:07:03 +00:00
|
|
|
stopname = models.CharField(max_length=512)
|
|
|
|
|
2011-07-16 06:11:20 +00:00
|
|
|
class Meta:
|
2011-10-01 11:07:03 +00:00
|
|
|
abstract = True
|
2011-07-16 06:11:20 +00:00
|
|
|
|
2011-07-16 13:26:27 +00:00
|
|
|
def __unicode__(self):
|
|
|
|
return self.routecode
|
|
|
|
|
2011-10-01 11:07:03 +00:00
|
|
|
class RegularRoute(Route):
|
|
|
|
pass
|
|
|
|
|
|
|
|
class AcExpressRoute(Route):
|
|
|
|
pass
|
|
|
|
|
|
|
|
class AsRoute(Route):
|
|
|
|
pass
|
|
|
|
|
|
|
|
class Expressroutes(Route):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2011-07-16 06:11:20 +00:00
|
|
|
|
2011-07-16 13:26:27 +00:00
|
|
|
|
2011-10-01 11:07:03 +00:00
|
|
|
'''
|
2011-07-16 06:11:20 +00:00
|
|
|
class LocationsPoint(models.Model):
|
|
|
|
id = models.IntegerField(primary_key=True)
|
|
|
|
latitude = models.DecimalField(max_digits=13, decimal_places=10)
|
|
|
|
longitude = models.DecimalField(max_digits=13, decimal_places=10)
|
|
|
|
class Meta:
|
|
|
|
db_table = u'locations_point'
|
|
|
|
|
2011-07-16 13:26:27 +00:00
|
|
|
def __unicode__(self):
|
|
|
|
return str(self.id)
|
|
|
|
|
2011-07-16 06:11:20 +00:00
|
|
|
class LocationsLocationtype(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
slug = models.CharField(max_length=50, primary_key=True)
|
|
|
|
class Meta:
|
|
|
|
db_table = u'locations_locationtype'
|
|
|
|
|
2011-07-16 13:26:27 +00:00
|
|
|
def __unicode__(self):
|
|
|
|
return self.name
|
|
|
|
|
2011-07-16 06:11:20 +00:00
|
|
|
class LocationsLocation(models.Model):
|
|
|
|
id = models.IntegerField(primary_key=True)
|
|
|
|
point = models.ForeignKey(LocationsPoint)
|
|
|
|
type = models.ForeignKey(LocationsLocationtype)
|
|
|
|
# parent_type = models.ForeignKey(DjangoContentType)
|
|
|
|
parent_id = models.IntegerField()
|
|
|
|
class Meta:
|
|
|
|
db_table = u'locations_location'
|
2011-07-16 13:26:27 +00:00
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return str(self.id)
|
2011-10-01 11:07:03 +00:00
|
|
|
'''
|