From: Maxious Date: Tue, 20 Mar 2012 23:34:01 +0000 Subject: Multidimensional bus delay analysis X-Git-Url: http://maxious.lambdacomplex.org/git/?p=busui.git&a=commitdiff&h=073b8b4d2a645ad7ac3ca589615870a8335bd870 --- Multidimensional bus delay analysis --- --- a/.gitmodules +++ b/.gitmodules @@ -10,4 +10,9 @@ [submodule "js/yepnope"] path = js/yepnope url = https://github.com/SlexAxton/yepnope.js.git - +[submodule "javascripts/tesseract"] + path = javascripts/tesseract + url = https://github.com/square/tesseract.git +[submodule "javascripts/d3"] + path = javascripts/d3 + url = https://github.com/mbostock/d3.git --- a/include/db/servicealert-dao.inc.php +++ b/include/db/servicealert-dao.inc.php @@ -106,19 +106,7 @@ function getFutureAlerts() { global $conn; - $query = "SELECT id,extract('epoch' from start) as start, extract('epoch' from \"end\") as \"end\",cause,effect,header,description,url from servicealerts_alerts where NOW() < \"end\""; - // debug($query, "database"); - $query = $conn->prepare($query); - $query->execute(); - if (!$query) { - databaseError($conn->errorInfo()); - return Array(); - } - return $query->fetchAll(); -} -function getAllAlerts() { - global $conn; - $query = "SELECT id,extract('epoch' from start) as start, extract('epoch' from \"end\") as \"end\",cause,effect,header,description,url from servicealerts_alerts"; + $query = "SELECT id,extract('epoch' from start) as start, extract('epoch' from \"end\") as \"end\",cause,effect,header,description,url from servicealerts_alerts where NOW() > start or NOW() < \"end\""; // debug($query, "database"); $query = $conn->prepare($query); $query->execute(); --- /dev/null +++ b/labs/busdelay.csv.php @@ -1,1 +1,52 @@ +prepare(' +SELECT * from myway_timingdeltas' + , array(PDO::ATTR_CURSOR => PDO::FETCH_ORI_NEXT)); +$query->execute(); +$errors = $conn->errorInfo(); +if ($errors[2] != "") { + die("Export terminated, db error" . print_r($errors, true)); +} + +$headers = Array("date", "delay", "distance", "origin", "destination"); + +$fp = fopen('php://output', 'w'); +if ($fp && $query) { + //header('Content-Type: text/csv'); + header('Pragma: no-cache'); + header('Expires: 0'); + fputcsv($fp, $headers); + while ($r = $query->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_NEXT)) { + $row = Array(); + foreach ($headers as $i => $fieldName) { + switch ($fieldName) { + case "date": + $row[] = date("dm",strtotime($r['date'])).date("Hi",strtotime($r['time'])); + break; + case "delay": + $row[] = $r['timing_delta']; + break; + case "distance": + $row[] = $r['stop_sequence']; + break; + case "origin": + $row[] = $r['myway_stop']; + break; + case "destination": + $row[] = $r['route_name']; + break; + default: + break; + } + } + fputcsv($fp, array_values($row)); + } + die; +} +?> + + --- /dev/null +++ b/labs/busdelay.php @@ -1,1 +1,498 @@ - + + +Tesseract + + + +
+
+
Time of Day
+
+
+
Arrival Delay (min.)
+
+
+
Distance (mi.)
+
+
+
Date
+
+
+ + + +
+
+
+ + + + + + + + + --- a/rtpis/servicealert_editor.php +++ b/rtpis/servicealert_editor.php @@ -82,7 +82,7 @@ '; + echo "'; } ?>
" . date("c", $alert['start']) . "
to
" . date("c", $alert['end']) . "
" .$alert['header']."
". $alert['description'] . '
edit
" . date("c", $alert['start']) . "" . date("c", $alert['end']) . "" . substr($alert['description'], 0, 999) . 'edit