gtfs v5, trips.txt
This commit is contained in:
commit
cce68a90c7
|
@ -1,4 +1,3 @@
|
|||
|
||||
from mumbai.models import *
|
||||
import json
|
||||
from settings import *
|
||||
|
@ -152,13 +151,15 @@ def export_trips():
|
|||
|
||||
def export_stop_times():
|
||||
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"])
|
||||
|
||||
routelist = getRoutesHavingAllLocs()
|
||||
filedude.writerow(["trip_id","arrival_time","departure_time","stop_id","stop_sequence"])
|
||||
#routelist = getRoutesHavingAllLocs()
|
||||
routelist = RouteDetails.objects.filter(route_code='2820')
|
||||
routelist.append(RouteDetails.objects.get(route_code='2894'))
|
||||
|
||||
for route in routelist:
|
||||
rds = RouteDetail.objects.filter('route'=route).order_by('serial')
|
||||
#1. get routeDetails
|
||||
#2.
|
||||
for r in routelist:
|
||||
rds = RouteDetail.objects.filter(route=r).order_by('serial')
|
||||
|
||||
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'])
|
||||
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)
|
||||
if not from_to:
|
||||
routeDoesNotExistErrors.append({'from_to_not_found': route})
|
||||
continue
|
||||
obj.from_stop = from_to[0]
|
||||
if not stopMapping.has_key(obj.from_stop_txt):
|
||||
stopMapping[obj.from_stop_txt] = from_to[0].name
|
||||
|
|
|
@ -49,6 +49,8 @@ class Area(models.Model):
|
|||
geometry = models.PolygonField(blank=True, null=True)
|
||||
alt_names = generic.GenericRelation("AlternativeName")
|
||||
|
||||
def get_absolute_url(self):
|
||||
return "/area/%s/" % self.name
|
||||
|
||||
def __unicode__(self):
|
||||
return self.name
|
||||
|
@ -122,6 +124,9 @@ class Route(models.Model):
|
|||
distance = models.DecimalField(max_digits=3, decimal_places=1)
|
||||
stages = models.IntegerField()
|
||||
|
||||
def get_absolute_url(self):
|
||||
return "/route/%s/" % self.alias
|
||||
|
||||
def __unicode__(self):
|
||||
return self.alias
|
||||
|
||||
|
|
|
@ -20,3 +20,19 @@ def route(request, alias):
|
|||
'routeDetails': routeDetails
|
||||
})
|
||||
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">
|
||||
{% for r in routeDetails %}
|
||||
<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>
|
||||
|
||||
{% endfor %}
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
{% block head %}
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
$('#searchRoutes').change(function() {
|
||||
$('#searchFilter').keyup(function() {
|
||||
var val = $(this).val().toLowerCase();
|
||||
$('.route').each(function() {
|
||||
$('.listItem').each(function() {
|
||||
var txt = $(this).text().toLowerCase();
|
||||
if (txt.indexOf(val) != -1) {
|
||||
$(this).show();
|
||||
|
@ -24,11 +24,11 @@ $(function() {
|
|||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
Filter: <input id="searchRoutes" />
|
||||
Filter: <input id="searchFilter" />
|
||||
<ul id="routesList">
|
||||
{% for r in routes %}
|
||||
<li class="route">
|
||||
<a href="/route/{{r.alias}}" title="view stops for route">{{ r.alias }}</a> - {{ r.from_stop.name }} to {{ r.to_stop.name }}
|
||||
<li class="route listItem">
|
||||
<a href="{{r.get_absolute_url}}" title="view stops for route">{{ r.alias }}</a> - {{ r.from_stop.name }} to {{ r.to_stop.name }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
|
|
@ -12,6 +12,9 @@ urlpatterns = patterns('',
|
|||
url(r'^static/(?P<path>.*)$','django.views.static.serve', {'document_root':'./static'}),
|
||||
(r'^routes/$', 'mumbai.views.routes'),
|
||||
(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:
|
||||
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
||||
#(r'^grappelli/', include('grappelli.urls')),
|
||||
|
|
Loading…
Reference in New Issue
Block a user