merge..
This commit is contained in:
commit
6583fae18b
|
@ -43,3 +43,31 @@ def editstops(request):
|
|||
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();
|
||||
$target.data("loading", true);
|
||||
var $loading = $('<span />').addClass("loadingSpan").text("Loading...").appendTo($target);
|
||||
$('#stopForm').remove();
|
||||
$('#formCol').empty();
|
||||
$.getJSON(url, {'srid': 3857}, function(obj) {
|
||||
$loading.remove();
|
||||
var stopsGeojson = obj.stops;
|
||||
|
@ -191,6 +193,12 @@ var API_BASE = "/1.0/",
|
|||
$form.submit();
|
||||
})
|
||||
.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 $lon_input = $('<input />').attr("type", "hidden").val(lon).attr("id", "lon").appendTo($form);
|
||||
$form.submit(function(e) {
|
||||
|
@ -227,7 +235,8 @@ var API_BASE = "/1.0/",
|
|||
function initMap() {
|
||||
var center = new OpenLayers.LonLat(8110203.9998955, 2170000.4068373);
|
||||
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 = [];
|
||||
// layers[0] = new OpenLayers.Layer.OSM();
|
||||
|
@ -239,9 +248,15 @@ var API_BASE = "/1.0/",
|
|||
key: "AqGpO7N9ioFw3YHoPV3C8crGfJqW5YST4gGKgIOnijrUbitLlgcAS2A0M9SJrUv9",
|
||||
});
|
||||
geojson_format = new OpenLayers.Format.GeoJSON();
|
||||
//
|
||||
//yes, jsonLayer is global. Yes, I know it's wrong.
|
||||
jsonLayer = layers[2] = new OpenLayers.Layer.Vector("Bus Stops");
|
||||
map.addLayers(layers);
|
||||
jsonLayer.events.on({
|
||||
'featureselected': onFeatureSelect,
|
||||
'featureunselected': onFeatureUnselect
|
||||
});
|
||||
|
||||
map.setCenter(center, 12);
|
||||
var navigationControl = new OpenLayers.Control.Navigation({
|
||||
defaultDblClick: function(event) {
|
||||
|
@ -268,28 +283,30 @@ var API_BASE = "/1.0/",
|
|||
var pt = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);
|
||||
var feature = new OpenLayers.Feature.Vector(pt, stop);
|
||||
$('.selectedStop').removeClass("no_has_point").addClass("has_point");
|
||||
//console.log("trying to add", feature);
|
||||
jsonLayer.addFeatures([feature]);
|
||||
mapControl.select(feature);
|
||||
}
|
||||
// console.log(lonlat);
|
||||
return;
|
||||
}
|
||||
});
|
||||
map.addControl(navigationControl);
|
||||
|
||||
// Feature selection control
|
||||
mapControl = new OpenLayers.Control.SelectFeature(jsonLayer, {
|
||||
clickout: false,
|
||||
toggle: true
|
||||
});
|
||||
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
||||
map.addControl(mapControl);
|
||||
// map.addControl(zoomControl);
|
||||
mapControl.activate();
|
||||
// zoomControl.activate();
|
||||
jsonLayer.events.on({
|
||||
'featureselected': onFeatureSelect,
|
||||
'featureunselected': onFeatureUnselect
|
||||
});
|
||||
|
||||
// Add a LayerSwitcher since we now have Bing
|
||||
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
||||
|
||||
// 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) {
|
||||
|
@ -364,6 +381,9 @@ var API_BASE = "/1.0/",
|
|||
$('.selectedStop').removeClass("selectedStop");
|
||||
}
|
||||
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
|
||||
|
|
|
@ -36,16 +36,7 @@
|
|||
|
||||
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
$(function() {
|
||||
$("#statcontainer").load("mumbai/stats");
|
||||
var refreshId = setInterval(function() {
|
||||
$("#statcontainer").load('/mumbai/stats');
|
||||
}, 5000);
|
||||
$.ajaxSetup({ cache: false });
|
||||
});
|
||||
|
||||
-->
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
|
@ -55,13 +46,13 @@
|
|||
ChaloBEST! The Stats..
|
||||
</h1>
|
||||
</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">
|
||||
{% for r in route_stat %}
|
||||
{% for r in routes %}
|
||||
<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>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
@ -69,9 +60,9 @@
|
|||
|
||||
<div class="areas"> <h3> Areas needing some love.. </h3> <br />
|
||||
<ul id="AreasList">
|
||||
{% for a in area_stat %}
|
||||
{% for a in areas %}
|
||||
<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>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
|
|
@ -12,7 +12,7 @@ urlpatterns = patterns('',
|
|||
# Example:
|
||||
# (r'^chaloBEST/', include('chaloBEST.foo.urls')),
|
||||
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'}),
|
||||
(r'^routes/$', 'mumbai.views.routes'),
|
||||
(r'^route/(?P<alias>[a-zA-Z0-9\s\-]*?)/$', 'mumbai.views.route'),
|
||||
|
|
|
@ -17,7 +17,7 @@ def stats(request):
|
|||
total_stops = Stop.objects.count()
|
||||
stops_left = total_stops
|
||||
for stp in Stop.objects.all():
|
||||
if stp.stoplocation_set.all():
|
||||
if stp.point:
|
||||
stops_left-=1
|
||||
|
||||
|
||||
|
@ -27,12 +27,13 @@ def stats(request):
|
|||
area_stat = []
|
||||
|
||||
for area in arealist:
|
||||
area_stops = area.stop_set.all()
|
||||
astops_left = len(area_stops)
|
||||
for stp in area_stops:
|
||||
if stp.stoplocation_set.all():
|
||||
astops_left-=1
|
||||
|
||||
# area_stops = area.stop_set.all()
|
||||
# astops_left = len(area_stops)
|
||||
astops_left = Stop.objects.filter(area=area).filter(point=None).count()
|
||||
# for stp in area_stops:
|
||||
# if stp.point:
|
||||
# astops_left-=1
|
||||
#
|
||||
area_stat.append({'area':area,'neededstops':astops_left})
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user