Fix view.sh startup location
--- a/common-template.inc.php
+++ b/common-template.inc.php
@@ -122,7 +122,7 @@
or enter an address/co-ordinates in the box below.</div>';
}
echo '<div data-role="collapsible" data-collapsed="' . !$geoerror . '">
- <h3>Change Time/Place...</h3>
+ <h3>Change Time/Place (' . $_SESSION['time'] . ' '.ucwords(service_period()).')...</h3>
<form action="" method="post">
<div class="ui-body">
<div data-role="fieldcontain">
--- a/layar_api.php
+++ b/layar_api.php
@@ -9,7 +9,6 @@
$page_end = $max_page + filter_var($_REQUEST['pageKey'], FILTER_SANITIZE_NUMBER_INT);
$lat = filter_var($_REQUEST['lat'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
$lon = filter_var($_REQUEST['lon'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
-if (isset($_REQUEST['radius'])) $radius = filter_var($_REQUEST['radius'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
$url = $APIurl . "/json/neareststops?lat=$lat&lon=$lon&limit=50";
$contents = json_decode(getPage($url));
debug(print_r($contents, true));
@@ -24,24 +23,22 @@
$hotspot['lat'] = floor($row[2] * 1000000);
$hotspot['lon'] = floor($row[3] * 1000000);
$hotspot['distance'] = distance($row[2], $row[3], $_REQUEST['lat'], $_REQUEST['lon']);
- if (!isset($_REQUEST['radius']) || $hotspot['distance'] < $radius) {
- $hotspot['actions'] = Array(
- Array(
- "label" => 'View more trips/information',
- 'uri' => 'http://bus.lambdacomplex.org/' . 'stop.php?stopid=' . $row[0]
- )
- );
- $url = $APIurl . "/json/stoptrips?stop=" . $row[0] . "&time=" . midnight_seconds() . "&service_period=" . service_period() . "&limit=4&time_range=" . str(90 * 60);
- $trips = json_decode(getPage($url));
- debug(print_r($trips, true));
- foreach ($trips as $key => $row) {
- if ($key < 3) {
- $hotspot['line' . strval($key + 2) ] = $row[1][1] . ' @ ' . midnight_seconds_to_time($row[0]);
- }
+ $hotspot['actions'] = Array(
+ Array(
+ "label" => 'View more trips/information',
+ 'uri' => 'http://bus.lambdacomplex.org/' . 'stop.php?stopid=' . $row[0]
+ )
+ );
+ $url = $APIurl . "/json/stoptrips?stop=" . $row[0] . "&time=" . midnight_seconds() . "&service_period=" . service_period() . "&limit=4&time_range=" . strval(90 * 60);
+ $trips = json_decode(getPage($url));
+ debug(print_r($trips, true));
+ foreach ($trips as $key => $row) {
+ if ($key < 3) {
+ $hotspot['line' . strval($key + 2) ] = $row[1][1] . ' @ ' . midnight_seconds_to_time($row[0]);
}
- if (sizeof($trips) == 0) $hotspot['line2'] = 'No trips in the near future.';
- $output['hotspots'][] = $hotspot;
}
+ if (sizeof($trips) == 0) $hotspot['line2'] = 'No trips in the near future.';
+ $output['hotspots'][] = $hotspot;
}
}
if (sizeof($hotspot) > 0) {
--- a/schedule_viewer.py
+++ b/schedule_viewer.py
@@ -361,7 +361,7 @@
schedule = self.server.schedule
lat = float(params.get('lat'))
lon = float(params.get('lon'))
- limit = int(params.get('limit'))
+ limit = int(params.get('limit',5))
scale = int(params.get('scale',5)) # 5 = neighbourhood ~ 1km, 4= town 5 by 7km
stops = []
@@ -385,6 +385,7 @@
stops.append(s)
if scale == 5:
+ print stops
return [StopToTuple(s) for s in stops]
else:
dist_stop_list = []
@@ -396,7 +397,8 @@
elif dist < dist_stop_list[-1][0]:
bisect.insort(dist_stop_list, (dist, s))
dist_stop_list.pop() # Remove stop with greatest distance
- return [StopToTuple(s) for s in dist_stop_list]
+ print dist_stop_list
+ return [StopToTuple(s) for dist, s in dist_stop_list]
def handle_json_GET_boundboxstops(self, params):
"""Return a list of up to 'limit' stops within bounding box with 'n','e'
@@ -516,7 +518,7 @@
requested_time = int(params.get('time', 0))
limit = int(params.get('limit', 15))
service_period = params.get('service_period', None)
- time_range = params.get('time_range', 24*60*60)
+ time_range = int(params.get('time_range', 24*60*60))
filtered_time_trips = []
--- a/view.sh
+++ b/view.sh
@@ -1,3 +1,6 @@
-python schedule_viewer.py --feed=/var/www/cbrfeed.zip \
+ #!/bin/sh
+ f=`dirname $0`
+ cd $f
+ python schedule_viewer.py --feed=/var/www/cbrfeed.zip \
--key=ABQIAAAA95XYXN0cki3Yj_Sb71CFvBTPaLd08ONybQDjcH_VdYtHHLgZvRTw2INzI_m17_IoOUqH3RNNmlTk1Q