<?php | <?php |
date_default_timezone_set('Australia/ACT'); | date_default_timezone_set('Australia/ACT'); |
$debugOkay = Array( | $debugOkay = Array( |
"session", | "session", |
"json", | "json", |
"phperror", | "phperror", |
"awsotp", | "awsotp", |
//"squallotp", | //"squallotp", |
//"vanilleotp", | //"vanilleotp", |
"database", | "database", |
"other" | "other" |
); | ); |
$cloudmadeAPIkey = "daa03470bb8740298d4b10e3f03d63e6"; | $cloudmadeAPIkey = "daa03470bb8740298d4b10e3f03d63e6"; |
$googleMapsAPIkey = "ABQIAAAA95XYXN0cki3Yj_Sb71CFvBTPaLd08ONybQDjcH_VdYtHHLgZvRTw2INzI_m17_IoOUqH3RNNmlTk1Q"; | $googleMapsAPIkey = "ABQIAAAA95XYXN0cki3Yj_Sb71CFvBTPaLd08ONybQDjcH_VdYtHHLgZvRTw2INzI_m17_IoOUqH3RNNmlTk1Q"; |
$otpAPIurl = 'http://localhost:8080/opentripplanner-api-webapp/'; | $otpAPIurl = 'http://localhost:8080/opentripplanner-api-webapp/'; |
if (isDebug("awsotp") || php_uname('n') == "maxious.xen.prgmr.com") { | if (isDebug("awsotp") || php_uname('n') == "maxious.xen.prgmr.com") { |
$otpAPIurl = 'http://bus-main.lambdacomplex.org:8080/opentripplanner-api-webapp/'; | $otpAPIurl = 'http://bus-main.lambdacomplex.org:8080/opentripplanner-api-webapp/'; |
} | } |
if (isDebug("dotcloudotp") || php_uname('n') == "actbus-www") { | if (isDebug("dotcloudotp") || php_uname('n') == "actbus-www") { |
$otpAPIurl = 'http://otp.actbus.dotcloud.com/opentripplanner-api-webapp/'; | $otpAPIurl = 'http://otp.actbus.dotcloud.com/opentripplanner-api-webapp/'; |
} | } |
if (isDebug("squallotp")) { | if (isDebug("squallotp")) { |
$otpAPIurl = 'http://10.0.1.108:5080/opentripplanner-api-webapp/'; | $otpAPIurl = 'http://10.0.1.108:5080/opentripplanner-api-webapp/'; |
} | } |
if (isDebug("vanilleotp")) { | if (isDebug("vanilleotp")) { |
$otpAPIurl = 'http://10.0.1.135:8080/opentripplanner-api-webapp/'; | $otpAPIurl = 'http://10.0.1.135:8080/opentripplanner-api-webapp/'; |
} | } |
if (isDebug("phperror")) error_reporting(E_ALL ^ E_NOTICE); | if (isDebug("phperror")) error_reporting(E_ALL ^ E_NOTICE); |
$labsPath = ""; | $labsPath = ""; |
if (strstr($_SERVER['PHP_SELF'],"labs")) $labsPath = "../"; | if (strstr($_SERVER['PHP_SELF'],"labs")) $labsPath = "../"; |
function isDebugServer() | function isDebugServer() |
{ | { |
return !isset($_SERVER['SERVER_NAME']) || $_SERVER['SERVER_NAME'] == "10.0.1.154" || $_SERVER['SERVER_NAME'] == "10.1.0.4" || $_SERVER['SERVER_NAME'] == "localhost" || $_SERVER['SERVER_NAME'] == "127.0.0.1" ; | return isset($_SERVER['SERVER_NAME']) && ( $_SERVER['SERVER_NAME'] == "10.0.1.154" || $_SERVER['SERVER_NAME'] == "10.1.0.4" || $_SERVER['SERVER_NAME'] == |
"localhost" || $_SERVER['SERVER_NAME'] == "127.0.0.1") ; | |
} | } |
include_once ("common-geo.inc.php"); | include_once ("common-geo.inc.php"); |
include_once ("common-net.inc.php"); | include_once ("common-net.inc.php"); |
include_once ("common-transit.inc.php"); | include_once ("common-transit.inc.php"); |
include_once ("common-db.inc.php"); | include_once ("common-db.inc.php"); |
include_once ("common-request.inc.php"); | include_once ("common-request.inc.php"); |
include_once ("common-session.inc.php"); | include_once ("common-session.inc.php"); |
include_once ("common-template.inc.php"); | include_once ("common-template.inc.php"); |
function isAnalyticsOn() | function isAnalyticsOn() |
{ | { |
return !isDebugServer(); | return !isDebugServer(); |
} | } |
function isDebug($debugReason = "other") | function isDebug($debugReason = "other") |
{ | { |
global $debugOkay; | global $debugOkay; |
return in_array($debugReason, $debugOkay, false) && isDebugServer(); | return in_array($debugReason, $debugOkay, false) && isDebugServer(); |
} | } |
function debug($msg, $debugReason = "other") | function debug($msg, $debugReason = "other") |
{ | { |
if (isDebug($debugReason)) echo "\n<!-- " . date(DATE_RFC822) . "\n $msg -->\n"; | if (isDebug($debugReason)) echo "\n<!-- " . date(DATE_RFC822) . "\n $msg -->\n"; |
} | } |
function isJQueryMobileDevice() | function isJQueryMobileDevice() |
{ | { |
// http://forum.jquery.com/topic/what-is-the-best-way-to-detect-all-useragents-which-can-handle-jquery-mobile#14737000002087897 | // http://forum.jquery.com/topic/what-is-the-best-way-to-detect-all-useragents-which-can-handle-jquery-mobile#14737000002087897 |
$user_agent = $_SERVER['HTTP_USER_AGENT']; | $user_agent = $_SERVER['HTTP_USER_AGENT']; |
return preg_match('/iphone/i', $user_agent) || preg_match('/android/i', $user_agent) || preg_match('/webos/i', $user_agent) || preg_match('/ios/i', $user_agent) || preg_match('/bada/i', $user_agent) || preg_match('/maemo/i', $user_agent) || preg_match('/meego/i', $user_agent) || preg_match('/fennec/i', $user_agent) || (preg_match('/symbian/i', $user_agent) && preg_match('/s60/i', $user_agent) && $browser['majorver'] >= 5) || (preg_match('/symbian/i', $user_agent) && preg_match('/platform/i', $user_agent) && $browser['majorver'] >= 3) || (preg_match('/blackberry/i', $user_agent) && $browser['majorver'] >= 5) || (preg_match('/opera mobile/i', $user_agent) && $browser['majorver'] >= 10) || (preg_match('/opera mini/i', $user_agent) && $browser['majorver'] >= 5); | return preg_match('/iphone/i', $user_agent) || preg_match('/android/i', $user_agent) || preg_match('/webos/i', $user_agent) || preg_match('/ios/i', $user_agent) || preg_match('/bada/i', $user_agent) || preg_match('/maemo/i', $user_agent) || preg_match('/meego/i', $user_agent) || preg_match('/fennec/i', $user_agent) || (preg_match('/symbian/i', $user_agent) && preg_match('/s60/i', $user_agent) && $browser['majorver'] >= 5) || (preg_match('/symbian/i', $user_agent) && preg_match('/platform/i', $user_agent) && $browser['majorver'] >= 3) || (preg_match('/blackberry/i', $user_agent) && $browser['majorver'] >= 5) || (preg_match('/opera mobile/i', $user_agent) && $browser['majorver'] >= 10) || (preg_match('/opera mini/i', $user_agent) && $browser['majorver'] >= 5); |
} | } |
function isFastDevice() | function isFastDevice() |
{ | { |
$ua = $_SERVER['HTTP_USER_AGENT']; | $ua = $_SERVER['HTTP_USER_AGENT']; |
$fastDevices = Array( | $fastDevices = Array( |
"Mozilla/5.0 (X11;", | "Mozilla/5.0 (X11;", |
"Mozilla/5.0 (Windows;", | "Mozilla/5.0 (Windows;", |
"Mozilla/5.0 (iP", | "Mozilla/5.0 (iP", |
"Mozilla/5.0 (Linux; U; Android", | "Mozilla/5.0 (Linux; U; Android", |
"Mozilla/4.0 (compatible; MSIE" | "Mozilla/4.0 (compatible; MSIE" |
); | ); |
$slowDevices = Array( | $slowDevices = Array( |
"J2ME", | "J2ME", |
"MIDP", | "MIDP", |
"Opera/", | "Opera/", |
"Mozilla/2.0 (compatible;", | "Mozilla/2.0 (compatible;", |
"Mozilla/3.0 (compatible;" | "Mozilla/3.0 (compatible;" |
); | ); |
return true; | return true; |
} | } |
function array_flatten($a, $f = array()) | function array_flatten($a, $f = array()) |
{ | { |
if (!$a || !is_array($a)) return ''; | if (!$a || !is_array($a)) return ''; |
foreach ($a as $k => $v) { | foreach ($a as $k => $v) { |
if (is_array($v)) $f = array_flatten($v, $f); | if (is_array($v)) $f = array_flatten($v, $f); |
else $f[$k] = $v; | else $f[$k] = $v; |
} | } |
return $f; | return $f; |
} | } |
function remove_spaces($string) | function remove_spaces($string) |
{ | { |
return str_replace(' ', '', $string); | return str_replace(' ', '', $string); |
} | } |
function object2array($object) | function object2array($object) |
{ | { |
if (is_object($object)) { | if (is_object($object)) { |
foreach ($object as $key => $value) { | foreach ($object as $key => $value) { |
$array[$key] = $value; | $array[$key] = $value; |
} | } |
} | } |
else { | else { |
$array = $object; | $array = $object; |
} | } |
return $array; | return $array; |
} | } |
function startsWith($haystack, $needle, $case = true) | function startsWith($haystack, $needle, $case = true) |
{ | { |
if ($case) { | if ($case) { |
return (strcmp(substr($haystack, 0, strlen($needle)) , $needle) === 0); | return (strcmp(substr($haystack, 0, strlen($needle)) , $needle) === 0); |
} | } |
return (strcasecmp(substr($haystack, 0, strlen($needle)) , $needle) === 0); | return (strcasecmp(substr($haystack, 0, strlen($needle)) , $needle) === 0); |
} | } |
function endsWith($haystack, $needle, $case = true) | function endsWith($haystack, $needle, $case = true) |
{ | { |
if ($case) { | if ($case) { |
return (strcmp(substr($haystack, strlen($haystack) - strlen($needle)) , $needle) === 0); | return (strcmp(substr($haystack, strlen($haystack) - strlen($needle)) , $needle) === 0); |
} | } |
return (strcasecmp(substr($haystack, strlen($haystack) - strlen($needle)) , $needle) === 0); | return (strcasecmp(substr($haystack, strlen($haystack) - strlen($needle)) , $needle) === 0); |
} | } |
function bracketsMeanNewLine($input) | function bracketsMeanNewLine($input) |
{ | { |
return str_replace(")", "</small>", str_replace("(", "<br><small>", $input)); | return str_replace(")", "</small>", str_replace("(", "<br><small>", $input)); |
} | } |
function sksort(&$array, $subkey = "id", $sort_ascending = false) | function sksort(&$array, $subkey = "id", $sort_ascending = false) |
{ | { |
if (count($array)) $temp_array[key($array) ] = array_shift($array); | if (count($array)) $temp_array[key($array) ] = array_shift($array); |
foreach ($array as $key => $val) { | foreach ($array as $key => $val) { |
$offset = 0; | $offset = 0; |
$found = false; | $found = false; |
foreach ($temp_array as $tmp_key => $tmp_val) { | foreach ($temp_array as $tmp_key => $tmp_val) { |
if (!$found and strtolower($val[$subkey]) > strtolower($tmp_val[$subkey])) { | if (!$found and strtolower($val[$subkey]) > strtolower($tmp_val[$subkey])) { |
$temp_array = array_merge((array)array_slice($temp_array, 0, $offset) , array( | $temp_array = array_merge((array)array_slice($temp_array, 0, $offset) , array( |
$key => $val | $key => $val |
) , array_slice($temp_array, $offset)); | ) , array_slice($temp_array, $offset)); |
$found = true; | $found = true; |
} | } |
$offset++; | $offset++; |
} | } |
if (!$found) $temp_array = array_merge($temp_array, array( | if (!$found) $temp_array = array_merge($temp_array, array( |
$key => $val | $key => $val |
)); | )); |
} | } |
if ($sort_ascending) $array = array_reverse($temp_array); | if ($sort_ascending) $array = array_reverse($temp_array); |
else $array = $temp_array; | else $array = $temp_array; |
} | } |
function sktimesort(&$array, $subkey = "id", $sort_ascending = false) | function sktimesort(&$array, $subkey = "id", $sort_ascending = false) |
{ | { |
if (count($array)) $temp_array[key($array) ] = array_shift($array); | if (count($array)) $temp_array[key($array) ] = array_shift($array); |
foreach ($array as $key => $val) { | foreach ($array as $key => $val) { |
$offset = 0; | $offset = 0; |
$found = false; | $found = false; |
foreach ($temp_array as $tmp_key => $tmp_val) { | foreach ($temp_array as $tmp_key => $tmp_val) { |
if (!$found and strtotime($val[$subkey]) > strtotime($tmp_val[$subkey])) { | if (!$found and strtotime($val[$subkey]) > strtotime($tmp_val[$subkey])) { |
$temp_array = array_merge((array)array_slice($temp_array, 0, $offset) , array( | $temp_array = array_merge((array)array_slice($temp_array, 0, $offset) , array( |
$key => $val | $key => $val |
) , array_slice($temp_array, $offset)); | ) , array_slice($temp_array, $offset)); |
$found = true; | $found = true; |
} | } |
$offset++; | $offset++; |
} | } |
if (!$found) $temp_array = array_merge($temp_array, array( | if (!$found) $temp_array = array_merge($temp_array, array( |
$key => $val | $key => $val |
)); | )); |
} | } |
if ($sort_ascending && isset($temp_array)) $array = array_reverse($temp_array); | if ($sort_ascending && isset($temp_array)) $array = array_reverse($temp_array); |
else $array = $temp_array; | else $array = $temp_array; |
} | } |
function r_implode( $glue, $pieces ) | function r_implode( $glue, $pieces ) |
{ | { |
foreach( $pieces as $r_pieces ) | foreach( $pieces as $r_pieces ) |
{ | { |
if( is_array( $r_pieces ) ) | if( is_array( $r_pieces ) ) |
{ | { |
$retVal[] = r_implode( $glue, $r_pieces ); | $retVal[] = r_implode( $glue, $r_pieces ); |
} | } |
else | else |
{ | { |
$retVal[] = $r_pieces; | $retVal[] = $r_pieces; |
} | } |
} | } |
return implode( $glue, $retVal ); | return implode( $glue, $retVal ); |
} | } |
?> | ?> |
<?php | <?php |
include ('../include/common.inc.php'); | include ('../include/common.inc.php'); |
include_header("MyWay Delta Calculate", "mywayDeltaCalc"); | include_header("MyWay Delta Calculate", "mywayDeltaCalc"); |
flush(); | |
ob_flush(); | |
function abssort($a, $b) | function abssort($a, $b) |
{ | { |
if ($a['timeDiff'] == $b['timeDiff']) { | if ($a['timeDiff'] == $b['timeDiff']) { |
return 0; | return 0; |
} | } |
return (abs($a['timeDiff']) < abs($b['timeDiff'])) ? -1 : 1; | return (abs($a['timeDiff']) < abs($b['timeDiff'])) ? -1 : 1; |
} | } |
//collect all observation not in delta | //collect all observation not in delta |
$query = "select * from myway_observations INNER JOIN myway_stops | $query = "select * from myway_observations INNER JOIN myway_stops |
ON myway_observations.myway_stop=myway_stops.myway_stop INNER JOIN myway_routes | ON myway_observations.myway_stop=myway_stops.myway_stop INNER JOIN myway_routes |
ON myway_observations.myway_route=myway_routes.myway_route | ON myway_observations.myway_route=myway_routes.myway_route |
WHERE observation_id NOT IN | WHERE observation_id NOT IN |
( | ( |
SELECT observation_id | SELECT observation_id |
FROM myway_timingdeltas | FROM myway_timingdeltas |
)"; | )"; |
debug($query, "database"); | debug($query, "database"); |
$query = $conn->prepare($query); | $query = $conn->prepare($query); |
$query->execute(); | $query->execute(); |
if (!$query) { | if (!$query) { |
databaseError($conn->errorInfo()); | databaseError($conn->errorInfo()); |
return Array(); | return Array(); |
} | } |
$uncalcdObservations = $query->fetchAll(); | $uncalcdObservations = $query->fetchAll(); |
//Display count | //Display count |
echo "<h3>" . sizeof($uncalcdObservations) . " observations not yet processed</h2>"; | echo "<h3>" . sizeof($uncalcdObservations) . " observations not yet processed</h2>"; |
//foreach observation not in delta | //foreach observation not in delta |
foreach ($uncalcdObservations as $obsv) { | foreach ($uncalcdObservations as $obsv) { |
//var_dump($obsv); | //var_dump($obsv); |
echo "<h3>Observation {$obsv['observation_id']}:</h1> | echo "<h3>Observation {$obsv['observation_id']}:</h1> |
<small>{$obsv['myway_stop']} @ {$obsv['time']} on {$obsv['myway_route']}</small><br>"; | <small>{$obsv['myway_stop']} @ {$obsv['time']} on {$obsv['myway_route']}</small><br>"; |
if ($obsv["stop_code"] == "") { | if ($obsv["stop_code"] == "") { |
echo "error, stop '{$obsv['myway_stop']}' unknown"; | echo "error, stop '{$obsv['myway_stop']}' unknown"; |
continue; | continue; |
} | } |
if ($obsv["route_full_name"] == "") { | if ($obsv["route_full_name"] == "") { |
echo "error, route '{$obsv['myway_route']}' unknown"; | echo "error, route '{$obsv['myway_route']}' unknown"; |
continue; | continue; |
} | } |
// :convert timestamp into time of day and date | // convert timestamp into time of day and date |
// timezones from http://www.postgresql.org/docs/8.0/static/datetime-keywords.html | |
$time = date("H:i:s", strtotime($obsv['time'])); | $time = date("H:i:s", strtotime($obsv['time'])); |
$time_tz = date("H:i:s", strtotime($obsv['time']))." AESST"; | |
$search_time = date("H:i:s", strtotime($obsv['time'])-(30*60)); // 30 minutes margin | $search_time = date("H:i:s", strtotime($obsv['time'])-(30*60)); // 30 minutes margin |
$date = date("c", strtotime($obsv['time'])); | $date = date("c", strtotime($obsv['time'])); |
$timing_period = service_period(strtotime($date)); | $timing_period = service_period(strtotime($date)); |
$potentialStops = getStopsByStopCode($obsv["stop_code"], $obsv["stop_street"]); | $potentialStops = getStopsByStopCode($obsv["stop_code"], $obsv["stop_street"]); |
//:get myway_stops records | //:get myway_stops records |
//:search by starts with stopcode and starts with street if street is not null | //:search by starts with stopcode and starts with street if street is not null |
//no result, skip and display error | //no result, skip and display error |
if (sizeof($potentialStops) < 1) { | if (sizeof($potentialStops) < 1) { |
echo "error, potential stops for stopcode {$obsv["stop_code"]} street {$obsv["stop_street"]} unknown"; | echo "error, potential stops for stopcode {$obsv["stop_code"]} street {$obsv["stop_street"]} unknown"; |
continue; | continue; |
} | } |
//print out stops | //print out stops |
echo "Matched stops: "; | echo "Matched stops: "; |
foreach ($potentialStops as $potentialStop) echo $potentialStop['stop_code'] . " "; | foreach ($potentialStops as $potentialStop) echo $potentialStop['stop_code'] . " "; |
echo "<br>"; | echo "<br>"; |
//:get myway_route record | //:get myway_route record |
//no result, skip and display error | //no result, skip and display error |
//print out route | //print out route |
$potentialRoute = getRouteByFullName($obsv["route_full_name"]); | $potentialRoute = getRouteByFullName($obsv["route_full_name"]); |
if ($potentialRoute["route_short_name"] == "") { | if ($potentialRoute["route_short_name"] == "") { |
echo "error, route '{$obsv["route_full_name"]}' unknown"; | echo "error, route '{$obsv["route_full_name"]}' unknown"; |
continue; | continue; |
} | } |
echo "Matched route: {$potentialRoute['route_short_name']}{$potentialRoute['route_long_name']} {$timing_period}<br>"; | echo "Matched route: {$potentialRoute['route_short_name']}{$potentialRoute['route_long_name']} {$timing_period}<br>"; |
$timeDeltas = Array(); | $timeDeltas = Array(); |
foreach ($potentialStops as $potentialStop) { | foreach ($potentialStops as $potentialStop) { |
$stopRoutes = getStopRoutes($potentialStop['stop_id'], $timing_period); | $stopRoutes = getStopRoutes($potentialStop['stop_id'], $timing_period); |
$foundRoute = Array(); | $foundRoute = Array(); |
foreach ($stopRoutes as $stopRoute) { | foreach ($stopRoutes as $stopRoute) { |
//Check if this route stops at each stop | //Check if this route stops at each stop |
if ($stopRoute['route_short_name'] . $stopRoute['route_long_name'] == $obsv["route_full_name"]) { | if ($stopRoute['route_short_name'] . $stopRoute['route_long_name'] == $obsv["route_full_name"]) { |
echo "Matching route {$stopRoute['route_id']} found at {$potentialStop['stop_code']}<br>"; | echo "Matching route {$stopRoute['route_id']} found at {$potentialStop['stop_code']}<br>"; |
$foundRoute = $stopRoute; | $foundRoute = $stopRoute; |
//if does get tripstoptimes for this route | //if does get tripstoptimes for this route |
$trips = getStopTrips($potentialStop['stop_id'], $timing_period, $search_time); | $trips = getStopTrips($potentialStop['stop_id'], $timing_period, $search_time); |
foreach ($trips as $trip) { | foreach ($trips as $trip) { |
//echo $trip['route_id']." ".$stopRoute['route_id'].";"; | //echo $trip['route_id']." ".$stopRoute['route_id'].";"; |
if ($trip['route_id'] == $stopRoute['route_id']) { | if ($trip['route_id'] == $stopRoute['route_id']) { |
$timedTrip = getTimeInterpolatedTripAtStop($trip['trip_id'], $trip['stop_sequence']); | $timedTrip = getTimeInterpolatedTripAtStop($trip['trip_id'], $trip['stop_sequence']); |
$actual_time = strtotime($time); | $actual_time = strtotime($time); |
$trip_time = strtotime($timedTrip['arrival_time']); | $trip_time = strtotime($timedTrip['arrival_time']); |
$timeDiff = $actual_time - $trip_time; | $timeDiff = $actual_time - $trip_time; |
//work out time delta, put into array with index of delta | //work out time delta, put into array with index of delta |
$timeDeltas[] = Array( | $timeDeltas[] = Array( |
"timeDiff" => $timeDiff, | "timeDiff" => $timeDiff, |
"stop_code" => $potentialStop['stop_code'], | "stop_code" => $potentialStop['stop_code'], |
"stop_sequence" => $timedTrip['stop_sequence'] | "stop_sequence" => $timedTrip['stop_sequence'] |
); | ); |
echo "Found trip {$trip['trip_id']} at stop {$potentialStop['stop_code']} (#{$potentialStop['stop_id']}, sequence #{$trip['stop_sequence']})<br>"; | echo "Found trip {$trip['trip_id']} at stop {$potentialStop['stop_code']} (#{$potentialStop['stop_id']}, sequence #{$trip['stop_sequence']})<br>"; |
echo "Arriving at {$timedTrip['arrival_time']}, difference of " . round($timeDiff / 60, 2) . " minutes<br>"; | echo "Arriving at {$timedTrip['arrival_time']}, difference of " . round($timeDiff / 60, 2) . " minutes<br>"; |
} | } |
} | } |
break; // because have found route | break; // because have found route |
} | } |
} | } |
if (sizeof($foundRoute) < 1) { | if (sizeof($foundRoute) < 1) { |
//print out that stops/does not stop | //print out that stops/does not stop |
echo "No matching routes found at {$potentialStop['stop_code']}<br>"; | echo "No matching routes found at {$potentialStop['stop_code']}<br>"; |
var_dump($stopRoutes); | var_dump($stopRoutes); |
flush(); | |
} | } |
} | } |
// lowest delta is recorded delta | // lowest delta is recorded delta |
usort($timeDeltas, "abssort"); | usort($timeDeltas, "abssort"); |
$lowestDelta = $timeDeltas[0]["timeDiff"]; | $lowestDelta = $timeDeltas[0]["timeDiff"]; |
if (sizeof($timeDeltas) != 0) { | if (sizeof($timeDeltas) != 0) { |
echo "Lowest difference of " . round($lowestDelta / 60, 2) . " minutes will be recorded for this observation<br>"; | echo "Lowest difference of " . round($lowestDelta / 60, 2) . " minutes will be recorded for this observation<br>"; |
$observation_id = $obsv['observation_id']; | $observation_id = $obsv['observation_id']; |
$route_full_name = $obsv['route_full_name']; | $route_full_name = $obsv['route_full_name']; |
$stop_code = $timeDeltas[0]["stop_code"]; | $stop_code = $timeDeltas[0]["stop_code"]; |
$stop_sequence = $timeDeltas[0]["stop_sequence"]; | $stop_sequence = $timeDeltas[0]["stop_sequence"]; |
$stmt = $conn->prepare("insert into myway_timingdeltas (observation_id, route_full_name, stop_code, timing_delta, time, date, timing_period, stop_sequence) | $stmt = $conn->prepare("insert into myway_timingdeltas (observation_id, route_full_name, stop_code, timing_delta, time, date, timing_period, stop_sequence) |
values (:observation_id, :route_full_name, :stop_code, :timing_delta, :time, :date, :timing_period, :stop_sequence)"); | values (:observation_id, :route_full_name, :stop_code, :timing_delta, :time, :date, :timing_period, :stop_sequence)"); |
$stmt->bindParam(':observation_id', $observation_id); | $stmt->bindParam(':observation_id', $observation_id); |
$stmt->bindParam(':route_full_name', $route_full_name); | $stmt->bindParam(':route_full_name', $route_full_name); |
$stmt->bindParam(':stop_code', $stop_code); | $stmt->bindParam(':stop_code', $stop_code); |
$stmt->bindParam(':timing_delta', $lowestDelta); | $stmt->bindParam(':timing_delta', $lowestDelta); |
$stmt->bindParam(':time', $time); | $stmt->bindParam(':time', $time_tz); |
$stmt->bindParam(':date', $date); | $stmt->bindParam(':date', $date); |
$stmt->bindParam(':timing_period', $timing_period); | $stmt->bindParam(':timing_period', $timing_period); |
$stmt->bindParam(':stop_sequence', $stop_sequence); | $stmt->bindParam(':stop_sequence', $stop_sequence); |
// insert a record | // insert a record |