gtfs v 1
This commit is contained in:
parent
07e1c7a1dc
commit
ea2de8d494
0
chaloBEST/gtfs/__init__.py
Normal file
0
chaloBEST/gtfs/__init__.py
Normal file
0
chaloBEST/gtfs/fstops.json
Normal file
0
chaloBEST/gtfs/fstops.json
Normal file
34
chaloBEST/gtfs/gtfs_export.py
Normal file
34
chaloBEST/gtfs/gtfs_export.py
Normal 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)
|
||||||
|
|
1
chaloBEST/gtfs/routes.txt
Normal file
1
chaloBEST/gtfs/routes.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
route_id,route_short_name,route_long_name,route_type
|
1
chaloBEST/gtfs/stops.txt
Normal file
1
chaloBEST/gtfs/stops.txt
Normal 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
|
|
@ -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,
|
||||||
|
@ -264,9 +265,12 @@ def fire_up():
|
||||||
CsvLoader(model)
|
CsvLoader(model)
|
||||||
|
|
||||||
loadFKinRouteDetail()
|
loadFKinRouteDetail()
|
||||||
# also
|
|
||||||
#importUniqueRoutes()
|
|
||||||
|
|
||||||
|
# also
|
||||||
|
importUniqueRoutes()
|
||||||
|
print "loading UniqueRoute..."
|
||||||
|
postclean.copydefaultStopLocations()
|
||||||
|
postclean.copynames2display_name()
|
||||||
|
|
||||||
#----------------------------------------------------------
|
#----------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user