merge..
This commit is contained in:
commit
6583fae18b
|
@ -43,3 +43,31 @@ def editstops(request):
|
||||||
return render_to_response("editstops.html", context)
|
return render_to_response("editstops.html", context)
|
||||||
|
|
||||||
|
|
||||||
|
def stats(request):
|
||||||
|
total_stops_left = Stop.objects.filter(point=None).count()
|
||||||
|
areas = []
|
||||||
|
for a in Area.objects.all():
|
||||||
|
stops = Stop.objects.filter(area=a)
|
||||||
|
d = {
|
||||||
|
'area': a,
|
||||||
|
#'area_name': a.name,
|
||||||
|
'total_stops': stops.count(),
|
||||||
|
'remaining_stops': stops.filter(point=None).count()
|
||||||
|
}
|
||||||
|
areas.append(d)
|
||||||
|
routes = []
|
||||||
|
for r in Route.objects.all():
|
||||||
|
stops = Stop.objects.filter(routedetail__route=r)
|
||||||
|
d = {
|
||||||
|
'route': r,
|
||||||
|
#'route_name': r.name,
|
||||||
|
'total_stops': stops.count(),
|
||||||
|
'remaining_stops': stops.filter(point=None).count()
|
||||||
|
}
|
||||||
|
routes.append(d)
|
||||||
|
return render_to_response("stats.html", {
|
||||||
|
'total_stops_left': total_stops_left,
|
||||||
|
'areas': areas,
|
||||||
|
'routes': routes
|
||||||
|
})
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,8 @@ var API_BASE = "/1.0/",
|
||||||
var url = API_BASE + name + "/" + $target.find(".listItemText").text();
|
var url = API_BASE + name + "/" + $target.find(".listItemText").text();
|
||||||
$target.data("loading", true);
|
$target.data("loading", true);
|
||||||
var $loading = $('<span />').addClass("loadingSpan").text("Loading...").appendTo($target);
|
var $loading = $('<span />').addClass("loadingSpan").text("Loading...").appendTo($target);
|
||||||
|
$('#stopForm').remove();
|
||||||
|
$('#formCol').empty();
|
||||||
$.getJSON(url, {'srid': 3857}, function(obj) {
|
$.getJSON(url, {'srid': 3857}, function(obj) {
|
||||||
$loading.remove();
|
$loading.remove();
|
||||||
var stopsGeojson = obj.stops;
|
var stopsGeojson = obj.stops;
|
||||||
|
@ -191,6 +193,12 @@ var API_BASE = "/1.0/",
|
||||||
$form.submit();
|
$form.submit();
|
||||||
})
|
})
|
||||||
.appendTo($form);
|
.appendTo($form);
|
||||||
|
$('<br />').appendTo($form);
|
||||||
|
$('<input />').attr("type","button").val("Save")
|
||||||
|
.click(function () {
|
||||||
|
$form.submit();
|
||||||
|
})
|
||||||
|
.appendTo($form);
|
||||||
var $lat_input = $('<input />').attr("type", "hidden").val(lat).attr("id", "lat").appendTo($form);
|
var $lat_input = $('<input />').attr("type", "hidden").val(lat).attr("id", "lat").appendTo($form);
|
||||||
var $lon_input = $('<input />').attr("type", "hidden").val(lon).attr("id", "lon").appendTo($form);
|
var $lon_input = $('<input />').attr("type", "hidden").val(lon).attr("id", "lon").appendTo($form);
|
||||||
$form.submit(function(e) {
|
$form.submit(function(e) {
|
||||||
|
@ -227,7 +235,8 @@ var API_BASE = "/1.0/",
|
||||||
function initMap() {
|
function initMap() {
|
||||||
var center = new OpenLayers.LonLat(8110203.9998955, 2170000.4068373);
|
var center = new OpenLayers.LonLat(8110203.9998955, 2170000.4068373);
|
||||||
map = new OpenLayers.Map("mapCol", {
|
map = new OpenLayers.Map("mapCol", {
|
||||||
projection: new OpenLayers.Projection("EPSG:900913")
|
projection: new OpenLayers.Projection("EPSG:900913"),
|
||||||
|
displayProjection: new OpenLayers.Projection("EPSG:4326")
|
||||||
});
|
});
|
||||||
var layers = [];
|
var layers = [];
|
||||||
// layers[0] = new OpenLayers.Layer.OSM();
|
// layers[0] = new OpenLayers.Layer.OSM();
|
||||||
|
@ -239,9 +248,15 @@ var API_BASE = "/1.0/",
|
||||||
key: "AqGpO7N9ioFw3YHoPV3C8crGfJqW5YST4gGKgIOnijrUbitLlgcAS2A0M9SJrUv9",
|
key: "AqGpO7N9ioFw3YHoPV3C8crGfJqW5YST4gGKgIOnijrUbitLlgcAS2A0M9SJrUv9",
|
||||||
});
|
});
|
||||||
geojson_format = new OpenLayers.Format.GeoJSON();
|
geojson_format = new OpenLayers.Format.GeoJSON();
|
||||||
|
//
|
||||||
//yes, jsonLayer is global. Yes, I know it's wrong.
|
//yes, jsonLayer is global. Yes, I know it's wrong.
|
||||||
jsonLayer = layers[2] = new OpenLayers.Layer.Vector("Bus Stops");
|
jsonLayer = layers[2] = new OpenLayers.Layer.Vector("Bus Stops");
|
||||||
map.addLayers(layers);
|
map.addLayers(layers);
|
||||||
|
jsonLayer.events.on({
|
||||||
|
'featureselected': onFeatureSelect,
|
||||||
|
'featureunselected': onFeatureUnselect
|
||||||
|
});
|
||||||
|
|
||||||
map.setCenter(center, 12);
|
map.setCenter(center, 12);
|
||||||
var navigationControl = new OpenLayers.Control.Navigation({
|
var navigationControl = new OpenLayers.Control.Navigation({
|
||||||
defaultDblClick: function(event) {
|
defaultDblClick: function(event) {
|
||||||
|
@ -268,28 +283,30 @@ var API_BASE = "/1.0/",
|
||||||
var pt = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);
|
var pt = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);
|
||||||
var feature = new OpenLayers.Feature.Vector(pt, stop);
|
var feature = new OpenLayers.Feature.Vector(pt, stop);
|
||||||
$('.selectedStop').removeClass("no_has_point").addClass("has_point");
|
$('.selectedStop').removeClass("no_has_point").addClass("has_point");
|
||||||
//console.log("trying to add", feature);
|
|
||||||
jsonLayer.addFeatures([feature]);
|
jsonLayer.addFeatures([feature]);
|
||||||
mapControl.select(feature);
|
mapControl.select(feature);
|
||||||
}
|
}
|
||||||
// console.log(lonlat);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
map.addControl(navigationControl);
|
map.addControl(navigationControl);
|
||||||
|
|
||||||
|
// Feature selection control
|
||||||
mapControl = new OpenLayers.Control.SelectFeature(jsonLayer, {
|
mapControl = new OpenLayers.Control.SelectFeature(jsonLayer, {
|
||||||
clickout: false,
|
clickout: false,
|
||||||
toggle: true
|
toggle: true
|
||||||
});
|
});
|
||||||
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
|
||||||
map.addControl(mapControl);
|
map.addControl(mapControl);
|
||||||
// map.addControl(zoomControl);
|
|
||||||
mapControl.activate();
|
mapControl.activate();
|
||||||
// zoomControl.activate();
|
|
||||||
jsonLayer.events.on({
|
// Add a LayerSwitcher since we now have Bing
|
||||||
'featureselected': onFeatureSelect,
|
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
||||||
'featureunselected': onFeatureUnselect
|
|
||||||
});
|
// Add a permalink that opens the relevant view in OSM.org in a different window
|
||||||
|
var permalink = new OpenLayers.Control.Permalink({base: "http://www.openstreetmap.org/"});
|
||||||
|
map.addControl(permalink);
|
||||||
|
$(".olControlPermalink a").attr("target","_blank").html("View in OSM");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onFeatureSelect(e) {
|
function onFeatureSelect(e) {
|
||||||
|
@ -364,6 +381,9 @@ var API_BASE = "/1.0/",
|
||||||
$('.selectedStop').removeClass("selectedStop");
|
$('.selectedStop').removeClass("selectedStop");
|
||||||
}
|
}
|
||||||
mapControl.select(feature);
|
mapControl.select(feature);
|
||||||
|
//map.setCenter(feature.geometry);
|
||||||
|
var lonLat = new OpenLayers.LonLat(feature.geometry.x, feature.geometry.y);
|
||||||
|
map.setCenter(lonLat);
|
||||||
}
|
}
|
||||||
|
|
||||||
//return currently selected feature or false
|
//return currently selected feature or false
|
||||||
|
|
|
@ -36,16 +36,7 @@
|
||||||
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
<!--
|
|
||||||
$(function() {
|
|
||||||
$("#statcontainer").load("mumbai/stats");
|
|
||||||
var refreshId = setInterval(function() {
|
|
||||||
$("#statcontainer").load('/mumbai/stats');
|
|
||||||
}, 5000);
|
|
||||||
$.ajaxSetup({ cache: false });
|
|
||||||
});
|
|
||||||
|
|
||||||
-->
|
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
@ -55,13 +46,13 @@
|
||||||
ChaloBEST! The Stats..
|
ChaloBEST! The Stats..
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="stops"> <h2> We have {{ stops_left }} stops left! </h2> <br /> <br />
|
<div class="stops"> <h2> We have {{ total_stops_left }} stops left! </h2> <br /> <br />
|
||||||
|
|
||||||
<div class="routes"> <h3> Routes needing some love.. <h3><br />
|
<div class="routes"> <h3> Routes needing some love.. </h3><br />
|
||||||
<ul id="routesList">
|
<ul id="routesList">
|
||||||
{% for r in route_stat %}
|
{% for r in routes %}
|
||||||
<li class="route listItem">
|
<li class="route listItem">
|
||||||
<a href="{{r.route.get_absolute_url}}" title="view stops for route">{{ r.route.alias }} </a> needs {{ r.neededstops }} stop locations.
|
<a href="{{r.route.get_absolute_url}}" title="view stops for route">{{ r.route.alias }} </a> needs {{ r.remaining_stops }} stop locations out of {{ r.total_stops }}.
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -69,9 +60,9 @@
|
||||||
|
|
||||||
<div class="areas"> <h3> Areas needing some love.. </h3> <br />
|
<div class="areas"> <h3> Areas needing some love.. </h3> <br />
|
||||||
<ul id="AreasList">
|
<ul id="AreasList">
|
||||||
{% for a in area_stat %}
|
{% for a in areas %}
|
||||||
<li class="area listItem">
|
<li class="area listItem">
|
||||||
<a href="{{a.area.get_absolute_url}}" title="view stops for area">{{ a.area.name }}</a> needs {{ a.neededstops }} stop locations.
|
<a href="{{a.area.get_absolute_url}}" title="view stops for area">{{ a.area.name }}</a> needs {{ a.remaining_stops }} stop locations out of {{ a.total_stops }}.
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -12,7 +12,7 @@ urlpatterns = patterns('',
|
||||||
# Example:
|
# Example:
|
||||||
# (r'^chaloBEST/', include('chaloBEST.foo.urls')),
|
# (r'^chaloBEST/', include('chaloBEST.foo.urls')),
|
||||||
url(r'^$','chaloBEST.views.index', name='index'),
|
url(r'^$','chaloBEST.views.index', name='index'),
|
||||||
url(r'^stats/$','chaloBEST.views.stats', name='stats'),
|
url(r'^stats/$','mumbai.views.stats', name='stats'),
|
||||||
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'),
|
||||||
|
|
|
@ -17,7 +17,7 @@ def stats(request):
|
||||||
total_stops = Stop.objects.count()
|
total_stops = Stop.objects.count()
|
||||||
stops_left = total_stops
|
stops_left = total_stops
|
||||||
for stp in Stop.objects.all():
|
for stp in Stop.objects.all():
|
||||||
if stp.stoplocation_set.all():
|
if stp.point:
|
||||||
stops_left-=1
|
stops_left-=1
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,12 +27,13 @@ def stats(request):
|
||||||
area_stat = []
|
area_stat = []
|
||||||
|
|
||||||
for area in arealist:
|
for area in arealist:
|
||||||
area_stops = area.stop_set.all()
|
# area_stops = area.stop_set.all()
|
||||||
astops_left = len(area_stops)
|
# astops_left = len(area_stops)
|
||||||
for stp in area_stops:
|
astops_left = Stop.objects.filter(area=area).filter(point=None).count()
|
||||||
if stp.stoplocation_set.all():
|
# for stp in area_stops:
|
||||||
astops_left-=1
|
# if stp.point:
|
||||||
|
# astops_left-=1
|
||||||
|
#
|
||||||
area_stat.append({'area':area,'neededstops':astops_left})
|
area_stat.append({'area':area,'neededstops':astops_left})
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user