Live JSON API yeilds incorrect dates close to midnight.

21 views
Skip to first unread message

Daniel

unread,
Feb 20, 2012, 12:39:22 AM2/20/12
to SEPTAdev
Something wacky seems to be going on with the DateTime results on the
online bus/trolly feed.

For example, for the URL below (trolley 34, Baltimore and 60th Ave,
direction outbound, and 7 results) there are the following errors in
the results.

There are duplicate schedules which is easy enough to detect and
remove, so that isn't a massive deal. The big problem is that close to
midnight (and even after midnight), the schedules that occur *past*
midnight have a correct 'day' value but an incorrect DateTime value.

For instance, It's 12:37am right now on Monday, but the schedule
results for the below URL return "Mon" and "02\/19\/12 12:30 am".
Today is the twentieth, so i'm not sure if the 12:30am is actually for
today (which I assume) or 24 hours ago, on the 19th.

Many thanks guys!
Daniel

The URL in question:
http://www3.septa.org/hackathon/BusSchedules/?req1=20859&req2=34&req3=o&req6=7

Here is the json result as this only seems to manifest itself around
the turn of a new day:

{"34":[{"StopName":"Baltimore Av & 60th
St","Route":"34","date":"12:30a","day":"Mon","Direction":"0","DateCalender":"02\/
19\/12 12:30 am"},{"StopName":"Baltimore Av & 60th
St","Route":"34","date":"12:30a","day":"Mon","Direction":"0","DateCalender":"02\/
19\/12 12:30 am"},{"StopName":"Baltimore Av & 60th
St","Route":"34","date":"1:00a","day":"Mon","Direction":"0","DateCalender":"02\/
19\/12 01:00 am"},{"StopName":"Baltimore Av & 60th
St","Route":"34","date":"1:00a","day":"Mon","Direction":"0","DateCalender":"02\/
19\/12 01:00 am"},{"StopName":"Baltimore Av & 60th
St","Route":"34","date":"1:16a","day":"Mon","Direction":"0","DateCalender":"02\/
19\/12 01:16 am"},{"StopName":"Baltimore Av & 60th
St","Route":"34","date":"1:16a","day":"Mon","Direction":"0","DateCalender":"02\/
19\/12 01:16 am"},{"StopName":"Baltimore Av & 60th
St","Route":"34","date":"1:46a","day":"Mon","Direction":"0","DateCalender":"02\/
19\/12 01:46 am"}]}

Kenny Chapman

unread,
Feb 20, 2012, 11:30:21 AM2/20/12
to sept...@googlegroups.com
I also found that if you change the Direction to "1" or "i" from "0" that there is no change. I found this on several routes

Daniel

unread,
Feb 20, 2012, 11:34:46 AM2/20/12
to SEPTAdev
Oh man. I noticed that but was assuming both directions had the same
schedule. That's a way bigger problem than mine, and could be
disastrous as i'm close to releasing my app to testers, and this would
cause incorrect schedules.

Kenny Chapman

unread,
Feb 20, 2012, 11:48:45 AM2/20/12
to sept...@googlegroups.com
Yeah, I was about to update my app using this api instead of the gtfs until I ran across this

Justin Brathwaite

unread,
Feb 20, 2012, 12:13:38 PM2/20/12
to sept...@googlegroups.com, SEPTAdev
I think what you are seeing is a midnight trip for Monday. In the GTFS those trips are on the same day but coded 24:00 for midnight and 25:00 for 1:00 am. Have to adjust the function that outputs this. Thanks for the heads up!

Sent from my iPhone

Daniel Watson

unread,
Feb 20, 2012, 12:27:09 PM2/20/12
to sept...@googlegroups.com

Many thanks Justin for the quick response. Do you have any idea what could be causing the schedules for both directions on some routes to be exactly the same? That one is a bit more worrying!

Daniel

unread,
Feb 20, 2012, 12:34:04 PM2/20/12
to SEPTAdev
Oh, and I swear than for all the work you've all put in on this in the
last week, I owe you guys lunch.

On Feb 20, 12:27 pm, Daniel Watson <dan...@staticfish.com> wrote:
> Many thanks Justin for the quick response. Do you have any idea what could
> be causing the schedules for both directions on some routes to be exactly
> the same? That one is a bit more worrying!
> On Feb 20, 2012 12:13 PM, "Justin Brathwaite" <jbrath...@yahoo.com> wrote:
>
>
>
>
>
>
>
> > I think what you are seeing is a midnight trip for Monday. In the GTFS
> > those trips are on the same day but coded 24:00 for midnight and 25:00 for
> > 1:00 am. Have to adjust the function that outputs this. Thanks for the
> > heads up!
>
> > Sent from my iPhone
>
> > On Feb 20, 2012, at 12:39 AM, Daniel <dan...@staticfish.com> wrote:
>
> > > Something wacky seems to be going on with the DateTime results on the
> > > online bus/trolly feed.
>
> > > For example, for the URL below (trolley 34, Baltimore and 60th Ave,
> > > direction outbound, and 7 results) there are the following errors in
> > > the results.
>
> > > There are duplicate schedules which is easy enough to detect and
> > > remove, so that isn't a massive deal. The big problem is that close to
> > > midnight (and even after midnight), the schedules that occur *past*
> > > midnight have a correct 'day' value but an incorrect DateTime value.
>
> > > For instance, It's 12:37am right now on Monday, but the schedule
> > > results for the below URL return "Mon" and "02\/19\/12 12:30 am".
> > > Today is the twentieth, so i'm not sure if the 12:30am is actually for
> > > today (which I assume) or 24 hours ago, on the 19th.
>
> > > Many thanks guys!
> > > Daniel
>
> > > The URL in question:
>
> >http://www3.septa.org/hackathon/BusSchedules/?req1=20859&req2=34&req3...

Justin B

unread,
Feb 21, 2012, 1:30:44 PM2/21/12
to SEPTAdev
The reason for this is there is a function called check_criteria and
takes the stop_id and route_name and checks the GTFS for the possible
directions this route has for the specific stop_id. Some stops going
in the other direction may be on the other side of the street, hence a
different stop_id. So some stop/route combinations only have one valid
direction and the api defaults to a valid direction. If you do not
include a specific route you can specific a different i/o and it will
vary the result set.

On Feb 20, 12:27 pm, Daniel Watson <dan...@staticfish.com> wrote:
> Many thanks Justin for the quick response. Do you have any idea what could
> be causing the schedules for both directions on some routes to be exactly
> the same? That one is a bit more worrying!
> On Feb 20, 2012 12:13 PM, "Justin Brathwaite" <jbrath...@yahoo.com> wrote:
>
>
>
>
>
>
>
> > I think what you are seeing is a midnight trip for Monday. In the GTFS
> > those trips are on the same day but coded 24:00 for midnight and 25:00 for
> > 1:00 am. Have to adjust the function that outputs this. Thanks for the
> > heads up!
>
> > Sent from my iPhone
>
> > On Feb 20, 2012, at 12:39 AM, Daniel <dan...@staticfish.com> wrote:
>
> > > Something wacky seems to be going on with the DateTime results on the
> > > online bus/trolly feed.
>
> > > For example, for the URL below (trolley 34, Baltimore and 60th Ave,
> > > direction outbound, and 7 results) there are the following errors in
> > > the results.
>
> > > There are duplicate schedules which is easy enough to detect and
> > > remove, so that isn't a massive deal. The big problem is that close to
> > > midnight (and even after midnight), the schedules that occur *past*
> > > midnight have a correct 'day' value but an incorrect DateTime value.
>
> > > For instance, It's 12:37am right now on Monday, but the schedule
> > > results for the below URL return "Mon" and "02\/19\/12 12:30 am".
> > > Today is the twentieth, so i'm not sure if the 12:30am is actually for
> > > today (which I assume) or 24 hours ago, on the 19th.
>
> > > Many thanks guys!
> > > Daniel
>
> > > The URL in question:
>
> >http://www3.septa.org/hackathon/BusSchedules/?req1=20859&req2=34&req3...

Justin B

unread,
Feb 21, 2012, 1:44:51 PM2/21/12
to SEPTAdev
I think I fixed the dates. You should see the correct dates on
midnight trips. The reason for the duplicates is because sometimes
there are two buses waiting at the same stop at a particular time.

On Feb 20, 12:39 am, Daniel <dan...@staticfish.com> wrote:
> Something wacky seems to be going on with the DateTime results on the
> online bus/trolly feed.
>
> For example, for the URL below (trolley 34, Baltimore and 60th Ave,
> direction outbound, and 7 results) there are the following errors in
> the results.
>
> There are duplicate schedules which is easy enough to detect and
> remove, so that isn't a massive deal. The big problem is that close to
> midnight (and even after midnight), the schedules that occur *past*
> midnight have a correct 'day' value but an incorrect DateTime value.
>
> For instance, It's 12:37am right now on Monday, but the schedule
> results for the below URL return "Mon" and "02\/19\/12 12:30 am".
> Today is the twentieth, so i'm not sure if the 12:30am is actually for
> today (which I assume) or 24 hours ago, on the 19th.
>
> Many thanks guys!
> Daniel
>
> The URL in question:http://www3.septa.org/hackathon/BusSchedules/?req1=20859&req2=34&req3...

Daniel Watson

unread,
Feb 21, 2012, 1:46:13 PM2/21/12
to sept...@googlegroups.com

That's great, and everything you said makes sense. I guess you really have to get your mind in "transport mode".

Thanks again.

Justin B

unread,
Feb 21, 2012, 1:48:39 PM2/21/12
to SEPTAdev
No problem..Hah sometimes I dream about Bus data.

On Feb 21, 1:46 pm, Daniel Watson <dan...@staticfish.com> wrote:
> That's great, and everything you said makes sense. I guess you really have
> to get your mind in "transport mode".
>
> Thanks again.

Justin B

unread,
Feb 21, 2012, 3:11:59 PM2/21/12
to SEPTAdev
I forgot to mention one more thing. Sometimes you will see duplicates
at the end of a loop because a bus might be ending its trip and then
starting a new one. We tried using the stop sequence in the GFTS to
eliminate  the duplicates but it made the query time increase too much
and took away some valid results, so we decided to leave them in
there.

On Feb 21, 1:46 pm, Daniel Watson <dan...@staticfish.com> wrote:
> That's great, and everything you said makes sense. I guess you really have
> to get your mind in "transport mode".
>
> Thanks again.

Daniel Watson

unread,
Feb 21, 2012, 3:37:12 PM2/21/12
to sept...@googlegroups.com
Thanks for the info - I think I am going to filter away duplicates anyway, so that's cool. Sometimes I still get duplicate times with different DateCal dates (the previous day). This is most noticeable for stops with seldom scheduled departures (Stop: Derby transportation centre old, Trolley 13 towards 13th Street) is particularly noticeable.
Reply all
Reply to author
Forward
0 new messages