Fix layar API
Fix layar API
Add current time/timing period to heading of panel to change those settings

--- 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,14 +9,15 @@
 $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));
 $stopNum = 0;
 foreach ($contents as $row) {
+    
 	$stopNum++;
 	if ($stopNum > $page_start && $stopNum <= $page_end) {
+            
 		$hotspot = Array();
 		$hotspot['id'] = $row[0];
 		$hotspot['title'] = $row[1];
@@ -25,13 +26,14 @@
 		$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);
+			$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) {

--- 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 = []
     
@@ -396,7 +396,7 @@
         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]
+      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 +516,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 = []