From: maxious ";
- //$viaPoints = viaPointNames($trip['trip_id'], $trip['stop_sequence']);
- //if ($viaPoints != "") echo '' . $trip['route_short_name'] . " " . $trip['route_long_name'] . "
Via: ' . $viaPoints . '';
+ $viaPoints = viaPointNames($trip['trip_id'], $trip['stop_sequence']);
+ if ($viaPoints != "") echo '
Via: ' . $viaPoints . '';
if (sizeof($tripStopNumbers) > 0) {
echo '
Boarding At: ';
foreach ($tripStopNumbers[$trip['trip_id']] as $key) {
--- a/transitdata.sql
+++ /dev/null
@@ -1,59 +1,1 @@
---
--- PostgreSQL database dump
---
-SET statement_timeout = 0;
-SET client_encoding = 'UTF8';
-SET standard_conforming_strings = off;
-SET check_function_bodies = false;
-SET client_min_messages = warning;
-SET escape_string_warning = off;
-
-SET search_path = public, pg_catalog;
-
-SET default_tablespace = '';
-
-SET default_with_oids = false;
-
---
--- Name: trips; Type: TABLE; Schema: public; Owner: postgres; Tablespace:
---
-
-CREATE TABLE trips (
- route_id integer,
- trip_id integer NOT NULL,
- trip_headsign text,
- service_id text
-);
-
-
-ALTER TABLE public.trips OWNER TO postgres;
-
---
--- Data for Name: trips; Type: TABLE DATA; Schema: public; Owner: postgres
---
-
-COPY trips (route_id, trip_id, trip_headsign, service_id) FROM stdin;
-\.
-
-
---
--- Name: trips_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:
---
-
-ALTER TABLE ONLY trips
- ADD CONSTRAINT trips_pkey PRIMARY KEY (trip_id);
-
-
---
--- Name: routetrips; Type: INDEX; Schema: public; Owner: postgres; Tablespace:
---
-
-CREATE INDEX routetrips ON trips USING btree (route_id);
-
-
---
--- PostgreSQL database dump complete
---
-
-
--- a/trip.php
+++ b/trip.php
@@ -3,95 +3,81 @@
$tripid = filter_var($_REQUEST['tripid'], FILTER_SANITIZE_NUMBER_INT);
$stopid = filter_var($_REQUEST['stopid'], FILTER_SANITIZE_NUMBER_INT);
$routeid = filter_var($_REQUEST['routeid'], FILTER_SANITIZE_NUMBER_INT);
+
$routetrips = Array();
+
if ($_REQUEST['routeid'] && !$_REQUEST['tripid']) {
- $tripid = 0;
- $url = $APIurl . "/json/routetrips?route_id=" . $routeid;
- $routetrips = json_decode(getPage($url));
- foreach ($routetrips as $trip) {
- if ($trip[2] > midnight_seconds()) {
- $tripid = $trip[1];
- break;
- }
- }
- if ($tripid == 0) $tripid = $routetrips[0][1];
+ $trip = getRouteNextTrip($routeid);
+ $tripid = $trip['trip_id'];
+} else {
+ $trip = getTrip($tripid);
+ $routeid = $trip["route_id"];
}
-$url = $APIurl . "/json/triprows?trip=" . $tripid;
-$trips = array_flatten(json_decode(getPage($url)));
-if (sizeof($routetrips) == 0) {
- $routeid = $trips[1]->route_id;
- $url = $APIurl . "/json/routetrips?route_id=" . $trips[1]->route_id;
- $routetrips = json_decode(getPage($url));
-}
-include_header("Stops on " . $trips[1]->route_short_name . ' ' . $trips[1]->route_long_name, "trip");
-trackEvent("Route/Trip View","View Route", $trips[1]->route_short_name . ' ' . $trips[1]->route_long_name, $trips[1]->route_id);
-$url = $APIurl . "/json/tripstoptimes?trip=" . $tripid;
-$json = json_decode(getPage($url));
-$stops = $json[0];
-$times = $json[1];
-$viaPoints = Array();
-foreach ($stops as $stop) {
- if (!startsWith($stop[5], "Wj")) {
- $viaPoints[] = $stop[1];
- }
-}
-echo 'Via:
' . implode(", ", $viaPoints) . '
' . midnight_seconds_to_time($stopsGrouped['startTime']) . ' to ' . midnight_seconds_to_time($stopsGrouped['endTime']) . '
'; - echo bracketsMeanNewLine($row[1]); + + echo '' . $stopsGrouped['startTime'] . ' to ' . $stopsGrouped['endTime'] . '
'; + echo bracketsMeanNewLine($tripStopTime["stop_name"]); echo '' . midnight_seconds_to_time($times[$key]) . '
'; - echo bracketsMeanNewLine($row[1]); + echo ''; + echo '' . $tripStopTime['arrival_time'] . '
'; + echo bracketsMeanNewLine($tripStopTime['stop_name']); echo ''; flush(); @ob_flush(); } } else { // this is a duplicated line item - if ($key - 1 <= 0 || ($stops[$key][1] != $stops[$key - 1][1])) { + if ($key - 1 <= 0 || ($tripStopTimes[$key]['stop_name'] != $tripStopTimes[$key - 1]['stop_name'])) { // first duplicate $stopsGrouped = Array( - "name" => $row[1], - "startTime" => $times[$key], + "name" => $tripStopTime['stop_name'], + "startTime" => $tripStopTime['arrival_time'], "stop_ids" => Array( - $row[0] + $tripStopTime['stop_id'] ) ); } else { // subsequent duplicates - $stopsGrouped["stop_ids"][] = $row[0]; - $stopsGrouped["endTime"] = $times[$key]; + $stopsGrouped["stop_ids"][] = $tripStopTime['stop_id']; + $stopsGrouped["endTime"] = $tripStopTime['arrival_time']; } } } --- a/updatedb.php +++ b/updatedb.php @@ -1,9 +1,11 @@