-
Notifications
You must be signed in to change notification settings - Fork 6
Home
SiriRestClient is an open-source reference implementation Android library for interacting with the RESTful SIRI (Service Interface for Real Time Information) interface for real-time transit data, such as that currently being used by the [MTA Bus Time API] (http://bustime.mta.info/wiki/Developers/SIRIIntro). See the SiriRestClientUI project for an example of how to use this library in an Android app.
SIRI is a public transportation standard developed by the European standards organization CEN. More information about SIRI can be found at the main SIRI website.
All SiriRestClient source code is licensed under Apache 2.0.
To add this library to your project using Maven, add the following to your pom.xml file:
<!-- SIRI POJOs -->
<dependency>
<groupId>edu.usf.cutr.siri</groupId>
<artifactId>onebusaway-siri-api-v13-pojos</artifactId>
<version>1.0.0</version>
</dependency>
<!-- SiriRestClient -->
<dependency>
<groupId>edu.usf.cutr.siri</groupId>
<artifactId>sirirestclient</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
This project was created in Eclipse using the Android SDK and Android Plugin for Eclipse. Libraries and dependencies are managed using [Maven] (http://eclipse.org/m2e/). Note that you'll need to install the m2e Android Maven plugin in Eclipse.
To get started with this project, use a Git client to clone this repository to your local computer. Then, in Eclipse do "File->Import->Maven->Existing Maven Projects", and point to the directory where you cloned the repo.
You'll also need the SIRI POJOs project for Jackson data binding. Clone this project using Git as well, and then add this as a dependency in your SiriRestClient app via "Properties->Java Build Path->Projects->Add..".
Next, you'll need to resolve a few dependencies on other projects, which is discussed in the next section below.
SiriRestClient has dependencies on Jackson for parsing JSON and XML. XML parsing requires that you install additional modified XML library artifacts in your local Maven repository. See the Modifying XML libraries for Android for details.
Please see the Parsing JSON and XML on Android wiki page for a full description of the use of Jackson with Android.
After you've completed the above steps, clean and build the project. If you have any problems, try cleaning both projects, and restarting Eclipse, then building the SiriRestClient project.
If you've modified this project and want to install the resulting artifact in your local Maven respository, run the following at the command line:
mvn clean install
See the SiriRestClientUI project for an example of how to use this library in an Android app.
We anticipate that the SIRI specification will change over time and the SIRI Plain Old Java Objects (POJOs) code will need to be regenerated. The SIRI v1.3 POJOs are maintained in their own OBA SIRI v1.3 POJOs project. If a new version of SIRI is released (e.g., v2.0), a new SIRI POJOs project will need to be created for this version of SIRI.
There are two strategies for creating new SIRI POJOs needed for data binding with a new version of SIRI:
-
Use tools such as [json gen] (http://jsongen.byingtondesign.com/) to generate POJOs based on SIRI JSON data
-
Strip the XML annotations and other characteristics that are incompatible with Android from the SIRI JAXB classes to create true POJOs that work on Android. See the current SIRI POJO project wiki for details on how to perform this manual process.
We've developed several tutorials based on what we've learned implementing the SiriRestClient, especially in the area of JSON and XML parsing on Android:
- Parsing JSON and XML on Android - Discusses how to use Jackson data binding to parse JSON and XML data in an Android app
- Modifying XML libraries for Android - Discusses the challenges of using XML parsing libraries on Android and how to overcome them