MobilityLab / TransitScreen

Transit screen configuration and display.
http://mobilitylab.org/2012/01/05/experimental-real-time-transit-screens-come-to-arlington-and-dc/
MIT License
132 stars 21 forks source link

when NextBus has no predictions, XML isn't handled properly #51

Open TransitScreen opened 12 years ago

TransitScreen commented 12 years ago

This causes the screen to show up empty because of the lack of error-handling.

The XML looks like:

<body copyright="All data copyright DC Circulator 2012."><predictions agencyTitle="DC Circulator" routeTitle="Georgetown - Union Station" routeTag="yellow" stopTitle="K Street NW And 24th Street NW" stopTag="k24th_w" dirTitleBecauseNoPredictions="Westbound">
</predictions><predictions agencyTitle="DC Circulator" routeTitle="Georgetown - Union Station Night" routeTag="gtownpm" stopTitle="K Street NW And 24th Street NW" stopTag="k24th_w" dirTitleBecauseNoPredictions="Westbound">
</predictions></body>

in transit_functions_helper we want something like:

$destination = (string) $busxml->predictions->dirTitleBecauseNoPredictions;

instead of:

$destination = (string) $busxml->predictions->direction[0]->attributes()->title;

TransitScreen commented 12 years ago

Patch might look like:

elseif(is_null($busxml->predictions->direction[0])){ $destination = (string) $busxml->predictions[0]['dirTitleBecauseNoPredictions']; $out = ''; }

TransitScreen commented 12 years ago

Normal XML looks like: