gtfs v5, trips.txt
This commit is contained in:
commit
cce68a90c7
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
from mumbai.models import *
|
from mumbai.models import *
|
||||||
import json
|
import json
|
||||||
from settings import *
|
from settings import *
|
||||||
|
@ -152,13 +151,15 @@ def export_trips():
|
||||||
|
|
||||||
def export_stop_times():
|
def export_stop_times():
|
||||||
filedude = csv.writer(open(join(PROJECT_ROOT, "gtfs/stop_times.txt"), "w"), delimiter=",", quotechar='"', quoting=csv.QUOTE_MINIMAL)
|
filedude = csv.writer(open(join(PROJECT_ROOT, "gtfs/stop_times.txt"), "w"), delimiter=",", quotechar='"', quoting=csv.QUOTE_MINIMAL)
|
||||||
filedude.writerow(["trip_id","arrival_time","departure_time","stop_id","stop_sequence"])
|
filedude.writerow(["trip_id","arrival_time","departure_time","stop_id","stop_sequence"])
|
||||||
|
#routelist = getRoutesHavingAllLocs()
|
||||||
routelist = getRoutesHavingAllLocs()
|
routelist = RouteDetails.objects.filter(route_code='2820')
|
||||||
|
routelist.append(RouteDetails.objects.get(route_code='2894'))
|
||||||
|
|
||||||
for route in routelist:
|
#1. get routeDetails
|
||||||
rds = RouteDetail.objects.filter('route'=route).order_by('serial')
|
#2.
|
||||||
|
for r in routelist:
|
||||||
|
rds = RouteDetail.objects.filter(route=r).order_by('serial')
|
||||||
|
|
||||||
for rd in rds:
|
for rd in rds:
|
||||||
#filedude.writerow()
|
filedude.writerow()
|
||||||
|
|
||||||
|
|
|
@ -146,6 +146,9 @@ def importUniqueRoutes():
|
||||||
obj = UniqueRoute(route=routeObj, is_full=thisRoute['is_full'], distance=distance, from_stop_txt=thisRoute['from'], to_stop_txt=thisRoute['to'])
|
obj = UniqueRoute(route=routeObj, is_full=thisRoute['is_full'], distance=distance, from_stop_txt=thisRoute['from'], to_stop_txt=thisRoute['to'])
|
||||||
if obj.is_full: #If the route is the primary route, we can get stop codes easily from RouteDetails first / last stop
|
if obj.is_full: #If the route is the primary route, we can get stop codes easily from RouteDetails first / last stop
|
||||||
from_to = getFromToStopsForRoute(routeObj)
|
from_to = getFromToStopsForRoute(routeObj)
|
||||||
|
if not from_to:
|
||||||
|
routeDoesNotExistErrors.append({'from_to_not_found': route})
|
||||||
|
continue
|
||||||
obj.from_stop = from_to[0]
|
obj.from_stop = from_to[0]
|
||||||
if not stopMapping.has_key(obj.from_stop_txt):
|
if not stopMapping.has_key(obj.from_stop_txt):
|
||||||
stopMapping[obj.from_stop_txt] = from_to[0].name
|
stopMapping[obj.from_stop_txt] = from_to[0].name
|
||||||
|
|
|
@ -49,6 +49,8 @@ class Area(models.Model):
|
||||||
geometry = models.PolygonField(blank=True, null=True)
|
geometry = models.PolygonField(blank=True, null=True)
|
||||||
alt_names = generic.GenericRelation("AlternativeName")
|
alt_names = generic.GenericRelation("AlternativeName")
|
||||||
|
|
||||||
|
def get_absolute_url(self):
|
||||||
|
return "/area/%s/" % self.name
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
@ -122,6 +124,9 @@ class Route(models.Model):
|
||||||
distance = models.DecimalField(max_digits=3, decimal_places=1)
|
distance = models.DecimalField(max_digits=3, decimal_places=1)
|
||||||
stages = models.IntegerField()
|
stages = models.IntegerField()
|
||||||
|
|
||||||
|
def get_absolute_url(self):
|
||||||
|
return "/route/%s/" % self.alias
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.alias
|
return self.alias
|
||||||
|
|
||||||
|
|
|
@ -20,3 +20,19 @@ def route(request, alias):
|
||||||
'routeDetails': routeDetails
|
'routeDetails': routeDetails
|
||||||
})
|
})
|
||||||
return render_to_response("route.html", context)
|
return render_to_response("route.html", context)
|
||||||
|
|
||||||
|
def areas(request):
|
||||||
|
context = RequestContext(request, {
|
||||||
|
'areas': Area.objects.all()
|
||||||
|
})
|
||||||
|
return render_to_response("areas.html", context)
|
||||||
|
|
||||||
|
def area(request, name):
|
||||||
|
area = get_object_or_404(Area, name=name)
|
||||||
|
stops = Stop.objects.filter(area=area).order_by('name')
|
||||||
|
context = RequestContext(request, {
|
||||||
|
'area': area,
|
||||||
|
'stops': stops
|
||||||
|
})
|
||||||
|
return render_to_response("area.html", context)
|
||||||
|
|
||||||
|
|
33
chaloBEST/templates/area.html
Normal file
33
chaloBEST/templates/area.html
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block title %} Area: {{ area.name }} {% endblock %}
|
||||||
|
|
||||||
|
{% block head %}
|
||||||
|
<style type="text/css">
|
||||||
|
.has_point {
|
||||||
|
color: #0f0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.no_point {
|
||||||
|
color: #f00;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
color: #00f;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<ul id="stopList">
|
||||||
|
{% for s in stops %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ s.get_absolute_url }}" class="{% if s.point %} has_point {% else %} no_point {% endif %}">{{ s.name }}</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{% endblock %}
|
36
chaloBEST/templates/areas.html
Normal file
36
chaloBEST/templates/areas.html
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
Areas
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block head %}
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function() {
|
||||||
|
$('#searchFilter').keyup(function() {
|
||||||
|
var val = $(this).val().toLowerCase();
|
||||||
|
$('.listItem').each(function() {
|
||||||
|
var txt = $(this).text().toLowerCase();
|
||||||
|
if (txt.indexOf(val) != -1) {
|
||||||
|
$(this).show();
|
||||||
|
} else {
|
||||||
|
$(this).hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
Filter: <input id="searchFilter" />
|
||||||
|
<ul id="routesList">
|
||||||
|
{% for a in areas %}
|
||||||
|
<li class="area listItem">
|
||||||
|
<a href="{{ a.get_absolute_url }}" title="view stops for route">{{ a.name }}</a>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{% endblock %}
|
|
@ -23,7 +23,7 @@ a:hover {
|
||||||
<ul id="stopList">
|
<ul id="stopList">
|
||||||
{% for r in routeDetails %}
|
{% for r in routeDetails %}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ r.stop.get_absolute_url }}" class="{% if has_point %} has_point {% else %} no_point {% endif %}">{{ r.stop.name }}</a>
|
<a href="{{ r.stop.get_absolute_url }}" class="{% if r.stop.point %} has_point {% else %} no_point {% endif %}">{{ r.stop.name }}</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
{% block head %}
|
{% block head %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function() {
|
$(function() {
|
||||||
$('#searchRoutes').change(function() {
|
$('#searchFilter').keyup(function() {
|
||||||
var val = $(this).val().toLowerCase();
|
var val = $(this).val().toLowerCase();
|
||||||
$('.route').each(function() {
|
$('.listItem').each(function() {
|
||||||
var txt = $(this).text().toLowerCase();
|
var txt = $(this).text().toLowerCase();
|
||||||
if (txt.indexOf(val) != -1) {
|
if (txt.indexOf(val) != -1) {
|
||||||
$(this).show();
|
$(this).show();
|
||||||
|
@ -24,11 +24,11 @@ $(function() {
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
Filter: <input id="searchRoutes" />
|
Filter: <input id="searchFilter" />
|
||||||
<ul id="routesList">
|
<ul id="routesList">
|
||||||
{% for r in routes %}
|
{% for r in routes %}
|
||||||
<li class="route">
|
<li class="route listItem">
|
||||||
<a href="/route/{{r.alias}}" title="view stops for route">{{ r.alias }}</a> - {{ r.from_stop.name }} to {{ r.to_stop.name }}
|
<a href="{{r.get_absolute_url}}" title="view stops for route">{{ r.alias }}</a> - {{ r.from_stop.name }} to {{ r.to_stop.name }}
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -12,6 +12,9 @@ urlpatterns = patterns('',
|
||||||
url(r'^static/(?P<path>.*)$','django.views.static.serve', {'document_root':'./static'}),
|
url(r'^static/(?P<path>.*)$','django.views.static.serve', {'document_root':'./static'}),
|
||||||
(r'^routes/$', 'mumbai.views.routes'),
|
(r'^routes/$', 'mumbai.views.routes'),
|
||||||
(r'^route/(?P<alias>[a-zA-Z0-9\s\-]*?)/$', 'mumbai.views.route'),
|
(r'^route/(?P<alias>[a-zA-Z0-9\s\-]*?)/$', 'mumbai.views.route'),
|
||||||
|
(r'^areas/$', 'mumbai.views.areas'),
|
||||||
|
(r'^area/(?P<name>.*?)/$', 'mumbai.views.area'),
|
||||||
|
|
||||||
# Uncomment the admin/doc line below to enable admin documentation:
|
# Uncomment the admin/doc line below to enable admin documentation:
|
||||||
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
||||||
#(r'^grappelli/', include('grappelli.urls')),
|
#(r'^grappelli/', include('grappelli.urls')),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user