public static function image_tag($size, $trip, $upcoming_stops) { $tag = ''; $url = "http://maps.google.com/maps/api/staticmap?"; $center = '42.35904, -71.09355'; $zoom = 13; $markers = "color:red"; foreach ($upcoming_stops as $stop) { $stop = ShuttleSchedule::getStop($stop); $markers .= '|' . $stop->lat . ',' . $stop->lon; } $params = array( 'size' => $size . 'x' . $size, 'markers' => $markers, 'sensor' => 'false', ); if (count($trip->shape->points) > 1) { $path = 'weight:3|color:red|enc:'; $numPoints = count($trip->shape->points); $totalCount = 0; $usedCount = 0; $prevLat = 0; $prevLon = 0; $latSum = 0; $lonSum = 0; foreach ($trip->shape->points as $point) { $latSum += $point[0]; $lonSum += $point[1]; $lat = $point[0] - $prevLat; $lon = $point[1] - $prevLon; $prevLat = $point[0]; $prevLon = $point[1]; $path .= base64EncodeNumber($lat) . base64EncodeNumber($lon); $usedCount++; } $center = strval($latSum / $usedCount) . ',' . strval($lonSum / $usedCount); $params['path'] = $path; } else { $params['zoom'] = $zoom; } $params['center']= $center; $query = $url . http_build_query($params); $tag = '<img src="' . $query . '" width="' . $size . '" height="' . $size . '" id="mapimage" alt="Map" />'; return $tag; }
$stop_id = $row['stop_id']; $next_seconds = -1; $source = 'null'; $route_preds = ShuttleSchedule::getNextLoop($route_id); if (array_key_exists('lastUpdate', $route_preds)) { unset($route_preds['lastUpdate']); $source = 'nextbus'; } else { $source = 'schedule'; } $stop_preds = $route_preds[$stop_id]; $next_time = $stop_preds[0]; $next_seconds = $next_time - $time; $stopname = ShuttleSchedule::getStop($stop_id)->name; if ($next_seconds > 0 && $next_seconds < SHUTTLE_NOTIFY_THRESHOLD) { $shuttle = $route->long_name; $minutes = intval($next_seconds / 60); $timestr = date('g:ia', $next_time); switch ($source) { case 'nextbus': $message = "$shuttle arriving at $stopname in $minutes minutes ($timestr)"; break; case 'schedule': $message = "$shuttle (NOT GPS TRACKED) scheduled to arrive at $stopname in $minutes minutes ($timestr)"; break; }