This commit is contained in:
Johnson Chetty 2012-02-15 14:46:24 +01:00
parent 07e1c7a1dc
commit ea2de8d494
7 changed files with 74 additions and 5 deletions

View File

View File

View File

@ -0,0 +1,34 @@
from mumbai.models import *
routebeer = []
def routeWithLocationData(route):
# get the route detail
routeDetails = RouteDetail.objects.filter(route_code=route.code).order_by('serial')
for rd in routeDetails :
if rd.stop.point is None:
return False
else:
pass
return True
def getRoutesHavingAllLocs():
filteredroutes = []
for route in Route.objects.all():
if routeWithLocationData(route):
filteredroutes.append(route)
return filteredroutes
def export_routes():
pointstoplist = Stop.objects.filter(point__isnull=False)
for rd in RouteDetail.objects.all():
if rd.stop in pointstoplist :
routebeer.append(rd)

View File

@ -0,0 +1 @@
route_id,route_short_name,route_long_name,route_type

1
chaloBEST/gtfs/stops.txt Normal file
View File

@ -0,0 +1 @@
s,t,o,p,_,i,d,",",s,t,o,p,_,n,a,m,e,",",s,t,o,p,_,l,a,t,",",s,t,o,p,_,l,o,n

View File

@ -7,6 +7,7 @@ import datetime
import sys import sys
from django.contrib.gis.geos import Point from django.contrib.gis.geos import Point
from imports.import_atlas import getFromToStopsForRoute, importUniqueRoutes from imports.import_atlas import getFromToStopsForRoute, importUniqueRoutes
from imports import postload_cleanup as postclean
globalerr = [] globalerr = []
def RouteType_save(entry): def RouteType_save(entry):
@ -173,7 +174,7 @@ def StopLocation_save(entry):
saveorder = ["Fare","Holiday","Area","Road","Depot","Stop", "StopMarathi","AreaMarathi","RouteDetail", "Route","RouteType","HardCodedRoute"] saveorder = ["Fare","Holiday","Area","Road","Depot","Stop", "StopMarathi","AreaMarathi","RouteDetail", "Route","RouteType","HardCodedRoute","StopLocation" ]
mappingtosave = { mappingtosave = {
"Fare":Fare_save, "Fare":Fare_save,
@ -196,7 +197,7 @@ mappingtosave = {
def loadFKinRouteDetail(): def loadFKinRouteDetail():
err=[] err=[]
good_saves = 0 good_saves = 0
print "\n Loading foreign keys into Route Details ... " print "\nLoading foreign keys into Route Details ... "
for rd in RouteDetail.objects.all(): for rd in RouteDetail.objects.all():
try: try:
rd.route=Route.objects.get(code=rd.route_code) rd.route=Route.objects.get(code=rd.route_code)
@ -264,10 +265,13 @@ def fire_up():
CsvLoader(model) CsvLoader(model)
loadFKinRouteDetail() loadFKinRouteDetail()
# also # also
#importUniqueRoutes() importUniqueRoutes()
print "loading UniqueRoute..."
postclean.copydefaultStopLocations()
postclean.copynames2display_name()
#---------------------------------------------------------- #----------------------------------------------------------
""" """

View File

@ -2,6 +2,7 @@ from mumbai.models import *
#"Road, Area, Landmark, Stop" #"Road, Area, Landmark, Stop"
def copynames2display_name(): def copynames2display_name():
print "Copying names to display_name field..."
for obj in Stop.objects.all(): for obj in Stop.objects.all():
obj.display_name =obj.name obj.display_name =obj.name
obj.save() obj.save()
@ -16,8 +17,36 @@ def copynames2display_name():
obj.save() obj.save()
def copydefaultStopLocations(): def copydefaultStopLocations():
print "Loading default locations for Stop.point field..."
for stp in Stop.objects.all(): for stp in Stop.objects.all():
if stp.stoplocation_set.count()>0 : if stp.stoplocation_set.count()>0 :
stp.point = stp.stoplocation_set.all()[0].point stp.point = stp.stoplocation_set.all()[0].point
stp.save() stp.save()
"""
def addStopstoRoutes():
print "Getting stops linked to Routes..."
for r in Route.objects.all():
try:
r.stop = Stop.objects.get(name=)
"""
def routeWithLocationData(route):
# get the route detail
routeDetails = RouteDetail.objects.filter(route_code=route.code).order_by('serial')
for rd in routeDetails :
if rd.stop.point is None:
return False
else:
pass
return True
def getRoutes_w_loc():
filteredroutes = []
for route in Route.objects.all():
if routeWithLocationData(route):
filteredroutes.append(route)
return filteredroutes