Peter H. Li > WebService-Nextbus-Agency > WebService::Nextbus::Agency

Download:
WebService-Nextbus-Agency-0.12.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.12   Source  

NAME ^

WebService::Nextbus::Agency - Superclass for data structures designed for Nextbus website (www.nextbus.com)

SYNOPSIS ^

  use WebService::Nextbus;
  $nb = new WebService::Nextbus;
  $nb->buildAgency('sf-muni'); # Scraping the webpages repeatedly can take time
  @stops = $nb->agencies->{'sf-muni'}->str2stopCodes('N', 'judah', 'Chu Dub');

  # OR...

  use WebService::Nextbus::Agency::SFMUNI;
  $muniAgency = new WebService::Nextbus::Agency::SFMUNI;
  @stops = $muniAgency->str2stopCodes('N', 'judah', 'Church and Duboce');

@stops can now be used as valid GET arguments on the nextbus webpage.

DESCRIPTION ^

WebService::Nextbus::Agency implements a basic data structure for storing and retrieving information on the various agencies monitored by the Nextbus website (www.nextbus.com). Nextbus provides a GPS system for predicting the arrival times of transit vehicles. In order to screen scrape the website effectively, one must be familiar with the GET arguments used by the site. This module provides the data structure for storing this info once it has been determined for a particular transit agency.

The "SYNOPSIS" indicates how the object can be used to retrieve the GET argument that the website requires for returning GPS information for a particular stop on a particular route of the sf-muni agency. There are basically two methods: determine the relevant GET arguments by screen scraping the Nextbus website using WebService::Nextbus, or load a prepared data structure from a helper subclass.

So far, only the WebService::Nextbus::Agency::SFMUNI subclass has been implemented. With the screen scraping of WebService::Nextbus available, however, it should be simple to create more helper subclasses by running WebService::Nextbus->buildAgency for the agency of choice and then using Storable to serialize the resulting routes tree for retrieval by the new helper subclass.

Once the proper GET code has been retrieved, a web useragent can use the argument to build a URL for the desired information. This useragent function will probably eventually be incorporated into WebService::Nextbus, which is already a LWP::UserAgent.

The entire functionality of this module will eventually be made obsolete by the anticipated development of an official WebService (W3C standard) by the Nextbus team. However, this is useful in the interim, and if Nextbus ends up charging for their service, then this will continue to be developed.

EXPORT

None by default; OO interface.

ERROR CHECKING ^

Watch out! No error checking yet...

REQUIRES ^

Tests require the Test::More module. Subclass SFMUNI (and likely any additional subclasses created for other agencies) requires the Storable module.

AUTHOR ^

Peter H. Li<lt>phli@cpan.org<gt>

COPYRIGHT ^

Licensed by Creative Commons http://creativecommons.org/licenses/by-nc-sa/2.0/

SEE ALSO ^

WebService::Nextbus, WebService::Nextbus::Agency::SFMUNI, Storable, LWP::UserAgent, perl.

syntax highlighting: