-
Notifications
You must be signed in to change notification settings - Fork 1
Mobile App Design Considerations
Interesting in creating a mobile app that uses OneBusAway for real-time transit data? You're in the right place.
Before you start your own app, check out the existing open-source OneBusAway (OBA) apps to get ideas, and make sure you're not duplicating features that already exist:
You might even want to contact the developers and see if you can pitch in to add new features to the existing apps.
Like many open-source projects, OneBusAway is changing quickly. Check out the [OBA RESTful API Roadmap] (https://github.com/OneBusAway/onebusaway-application-modules/wiki/RESTful-API-Roadmap) for a list of APIs that are currently supported in OneBusAway, as well as the plan for what APIs will be supported in the future.
Also check out the SIRI Element to UI Mappings for a description of the SIRI element fields and how they should be shown to transit riders.
In general, we suggest using the JSON interfaces for OneBusAway. JSON is a more compact representation of data than XML, and therefore more efficient. This means less data sent over the wireless network and better battery life for a mobile phone.
To conform with the SIRI standard, XML and JSON element labels are in PascalCase (i.e., not camelCase, where the first letter is lower-case).
XML:
<RecordedAtTime>2012-09-12T09:27:52.867-04:00</RecordedAtTime>
JSON:
"RecordedAtTime":"2012-08-21T12:07:21.485-04:00"
Java-based JSON and XML data binding parsers such as Jackson can typically be configured to handle PascalCase, even though they typically expect camelCase, since the Java POJOs used in data binding typically define fields in camelCase.
However this presents a problem for certain attributes. Consider the following XML:
<Summary xml:lang="EN">b/d 1:00pm until f/n. local and express buses run w/delays & detours. POTUS visit in MANH. Allow additional travel time Details at www.mta.info</Summary>
The xml:lang
attribute must remain lower-case because of XML language attribute definition defined by W3C. Therefore, if you configure your JSON or XML parser to use PascalCase for elements, be aware that you will need to configure it to make an exception for attributes such as xml:lang
.
TODO - add how to handle xml:lang in Jackson, also add this to SiriRestClient pages.
Below are some pointers for developing OneBusAway apps on various mobile platforms.
We've created Siri Rest Client, an open-source reference implementation Android app that shows how to access and parse SIRI data in both JSON and XML format. Feel free to use this project as a basis for your app, as the source code is licensed under Apache 2.0.
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