17.07.2015 Views

OCTranspoLive: A live OCTranspo GPS bus location application for ...

OCTranspoLive: A live OCTranspo GPS bus location application for ...

OCTranspoLive: A live OCTranspo GPS bus location application for ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

AcknowledgmentsI would like to take this opportunity to thank Dr. Tony White <strong>for</strong> his supervisionthroughout the duration of this project. His experience in distributed systems hashelped me make better design choices <strong>for</strong> the <strong>application</strong>'s architecture. Beyond thisproject Dr. White's instruction during Comp 4104 proved invaluable <strong>for</strong> this projectand surely <strong>for</strong> anything else I do in my career. I hope this <strong>application</strong> proves usefulto him or perhaps a student interested in Android development.I would also like to thank Michael Du Plessis <strong>for</strong> sparking my interest in Androiddevelopment. Michael has always been very willing to provide assistance when askedboth <strong>for</strong> this project and all the other work with done together during our undergrad.3


5 Project Results 296 Conclusion 306.1 Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316.2 Future improvements . . . . . . . . . . . . . . . . . . . . . . . . . . . 326.3 Contributions to the Field . . . . . . . . . . . . . . . . . . . . . . . . 326.4 Concepts and Technologies Learned . . . . . . . . . . . . . . . . . . . 337 References 348 Appendices 358.1 CD Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358.2 Development Environment . . . . . . . . . . . . . . . . . . . . . . . . 358.3 Project Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365


system by utilizing the Java programming language. For this project Android SDKAPI level 14 was used. The ADT (Android Development Tools) plugin along withEclipse provides all the tools needed to start programming <strong>for</strong> Android[1]. The SDKallows the user to setup virtual devices using the Virtual Devices Manager.Thisdevice emulation is useful <strong>for</strong> testing dierent API levels but is very slow. As such, Ideveloped mostly using a hardware device attached via USB.Also provided by Google is their close-source Google Apps <strong>for</strong> Android. Installingthese with the SDK manager allowed me to use the Google Maps library. An Android<strong>application</strong> is made up of one or more Activities. Android Activities have the lifecycledetailed in Figure 1. For this project background threads were utilized <strong>for</strong> networkoperations such as HTTP requests and this meant thread management had to be keptin mind during all the states of the Activity lifecycle to avoid having resources usedwhen not needed.8


Figure 1: Android Activity Lifecycle1.2.2 SQLite DatabaseThe Android operating system ships with a relational database called SQLite. SQLiteis a like-weight database which can be used to store data on the. For this project itwas used to keep persistent data such as the user's favourite <strong>bus</strong> stops. The AndroidAPI provides a class SQLiteDatabase which exposes methods to manage an SQLitedatabase in Java[2].9


1.2.3 <strong>OCTranspo</strong> Developer API<strong>OCTranspo</strong> on March 22nd, 2012 opened its <strong>live</strong> <strong>GPS</strong> <strong>bus</strong> <strong>location</strong> API to developers.I registered <strong>for</strong> an API key and registered <strong><strong>OCTranspo</strong>Live</strong> as an <strong>application</strong> using myaccount. The API uses HTTP requests and responses as the data de<strong>live</strong>ry mechanism.The responses are returned as XML[3]. This is less than ideal and JSON would haveprovided a much better data <strong>for</strong>mat. JSON is an easier data <strong>for</strong>mat to work withconsidering libraries are already built-in to Android and the key-value structure makesnavigating a response much simpler. One can register <strong>for</strong> an OC Transpo Live NextBus Arrival Data Feed API key at http://www.octranspo1.com/developers.1.2.4 MySQL DatabaseMySQL is a very popular relational database management system (RDBMS). Thismeans it includes not only the database itself but all the management tools.Forthis project a database was needed to allow me make queries on the data providedby <strong>OCTranspo</strong>. The data itself is several les of plain text and not very useful onits own. It is the database of choice <strong>for</strong> a new generation of <strong>application</strong>s built onthe LAMP stack (Linux, Apache, MySQL, PHP / Perl / Python)[4], and as I hadexperience installing and managing MySQL installation it was an ideal choice.1.2.5 Google Maps APIGoogle provides their Map library <strong>for</strong> use on the Android plat<strong>for</strong>m. Using the AndroidSDK Manager in Eclipse Google Apps <strong>for</strong> Android can be downloaded allowing accessto the Maps library. When congure this allows us to use com.google.android.maps.MapViewin layouts. This is used in the MapViewActivity which is detailed in a later section.Using the Maps library we can then draw custom overlays on top of a map. This is10


done to draw <strong>bus</strong> stops and <strong>bus</strong> <strong>location</strong> in the Android client.2 MotivationLike most public transportation systems, the service in Ottawa relies on public roads.Athough estimates can be made, stop schedules cannot provide accurate arrival times<strong>for</strong> <strong>bus</strong>es as trac conditions dictate the true arrival times in the end. Since movingto Ottawa at the beginning of my undergrad I've experienced the main frustrationshared by most Ottawa public transportation riders I've spoken with; never knowingwhen the <strong>bus</strong> will come. Many of my friends and roommates over the years havecomplained about this aspect of the service. I always thought that there should be abetter solution than consulting the static timetable provided by <strong>OCTranspo</strong> only togo outside and wait 30 minutes <strong>for</strong> you <strong>bus</strong> when it was scheduled to arrive 5 minutesafter you got to the stop. I thought if I could make an <strong>application</strong> that would provideapproximate arrival times then I could be sparred from the weather. In winter I couldgo inside a coee shop near the stop and grab a warm coee, and in the summer Icould purchase a cool beverage and enjoy it in the air conditioning while waiting<strong>for</strong> the <strong>bus</strong> to arrive. So, having purchased an Android smartphone about a yearago, I thought an <strong>application</strong> to address this problem was the ideal candidate <strong>for</strong> myupcoming honours project.3 Goals and ObjectivesMy motivations outlined in the previous section provided me with a set of featuresI desired the <strong>application</strong> to have. With these in mind I was able to deconstruct the<strong>application</strong> into separate components and from there provide myself with a list of11


goals that needed to be achieved to bring the project to fruition.• Develop an <strong>application</strong> showing a dynamic timetable <strong>for</strong> a route at a <strong>bus</strong> stop.• Show <strong>bus</strong> <strong>location</strong>s on a Google Map. It should automatically refresh the <strong>location</strong>s.• Make use of devices with <strong>GPS</strong> chips to nd stops near a user.• Make an attractive and user friendly interface.• Parse <strong>OCTranspo</strong> text data set and insert into queryable database.• Create an HTTP based API <strong>for</strong> use by the Android client.The rst two goals in my opinion are most important. The <strong>application</strong> should befast and the data provided by a simple uncluttered interface to provide a good userexperience. This is the purpose of an <strong>application</strong>; to provide the user with valuablein<strong>for</strong>mation with the least amount of work on their part. By meeting the above goalsI feel that I will have nished an <strong>application</strong> that is both useful to myself and manyothers using the public transportation system in Ottawa.4 Application DesignThis project was divided into three main components. They are list below:• The Android client. This is what the user interacts with. It has to be quick and simple to use.The user should not be concerned about any other components making upthe system. To them this is the entire <strong>application</strong>.12


• The <strong><strong>OCTranspo</strong>Live</strong> API. This is a server written in Java. It provides a RESTful API, used to providein<strong>for</strong>mation to the Android client using HTTP requests.• The MySQL database. The MySQL database contains all the schedule data provided by OC-Transpo, all queryable.The next few sections of the report will provide the reader with a more detailed viewof these components.4.1 <strong><strong>OCTranspo</strong>Live</strong> (Android client)<strong><strong>OCTranspo</strong>Live</strong> is the Android client that interacts with the servers to obtain <strong>bus</strong>schedule related data. That data is in turn displayed to the user in whatever <strong>for</strong>m ismost relevant to the Activity class the <strong>application</strong> is in. For example the <strong>GPS</strong> dataobtained <strong>for</strong> a <strong>bus</strong> route at a particular stops is used by both the Activity showinga dynamic timetable and the Activity visualizing it on a map. In total the Androidclient is composed of 8 Activity classes.• MainViewActivity• StopsNearActivity• StopScheduleActivity• PlannerActivity• PlannerWebActivity13


• FavouritesActivity• MapViewActivity• MyPreferencesActivityI will now go through each Activity class and provide the reader with some detailsabout the functionality and what use case scenario might lead a user to that particularActivity.4.1.1 MainViewActivityMainViewActivity is what the user is rst presented with when the <strong>application</strong> islaunched. In Android the activity launched is set in the le AndroidManifest.xml,along with many other <strong>application</strong> settings. The snippet from <strong><strong>OCTranspo</strong>Live</strong>'s AndroidManifest.xmlsetting this Activity class to be launched can is provided to thereading in Listing 1.Listing 1: MainViewActity in AnroidManifest14


This Activity class extends ListActivity and implements the list selection listeners.The ArrayAdapter class called MainMenuArrayAdapter provides the list adapter<strong>for</strong> the MainViewActivity class. The rows in MainMenuArrayAdapter use a layoutspecifying a LinearLayout composed of an ImageView on the left side followed by aTextView. I found the default look of rows in a ListView to not be visually appealingso I opted to create a custom drawable to use <strong>for</strong> the rows.rowView . setBackgroundResource (R. drawable . customshape ) ;This gives the list items in MainViewActivity the attractive rounded corners thatcan be seen in Figure 2. One of my goals <strong>for</strong> this project was to make the userinterface as simple and visually appealing as possible. I believe providing the userwith only a few clearly seperated options in the main menu achieves the simplicityand usability I had in mind.Figure 2: Main menu15


4.1.2 StopsNearActivityOne of the options the user can select from the main menu is to look <strong>for</strong> stops nearthem. This will create and Intent object and then start the StopsNearActivity usingstartActivity. When this Activity is created the <strong>location</strong> services are used to nd theuser's <strong>location</strong>. If available the <strong>GPS</strong> will be used <strong>for</strong> a ne-grained <strong>location</strong> and ifnot Google's <strong>location</strong> service will be used, provided the WiFi on the device is turnedon. When the user's coordinates are found a request is made to the <strong><strong>OCTranspo</strong>Live</strong>API. This is done using an HTTP GET request like the one below.Listing 2: Near Stops Requesthttp : / / l o c a l h o s t :8080/ octranspo_api / r e s t / stops / near ? l a t=45.4104& lon =−75.6935Figure 3: Finding <strong>bus</strong> stops near youIn Figure 3 the rst screenshot shows what the user will see while waiting <strong>for</strong>16


their <strong>location</strong> to be established and to get a response from the <strong><strong>OCTranspo</strong>Live</strong> API.The response is a JSON array similar to this:Listing 3: Near Stops Response[ { " stop_lon ": −75.692749 ," d i s t a n c e ":0.0365410481320902 ,"stop_code ":"7666" ," stop_lat " : 4 5 . 4 1 0 3 5 8 , " stop_name " : "BANK /FLORA"} ,{" stop_lon ": −75.69265 ," d i s t a n c e":0.0477259843744609 ," stop_code ":"7667" ," stop_lat" : 4 5 . 4 1 0 7 4 8 , " stop_name " : "BANK / FLORA"} ,{" stop_lon": −75.693443 ," d i s t a n c e ":0.0815039906925018 ," stop_code":"2489" ," stop_lat " : 4 5 . 4 1 1 5 7 9 , " stop_name " : "BANK / MCLEOD"} ,{" stop_lon ": −75.691902 ," d i s t a n c e ":0.0918376667631642 ,"stop_code ":"2478" ," stop_lat " : 4 5 . 4 0 9 6 8 7 , " stop_name " : "CATHERINE / BANK" } ]The stops near the user are then shown on a MapViewActivity as seen in secondscreenshot in Figure 3. Clicking on one of the overlays will start a StopScheduleActivity<strong>for</strong> the selected stop. The StopScheduleActivity asks the user to select one ofthe routes available at the stop and will then download <strong>live</strong> <strong>GPS</strong> estimates of arrivaltimes and display them on a dynamic timetable <strong>for</strong> the user. StopScheduleActivitywill be discussed in detail in the next section.4.1.3 StopScheduleActivityA user gets to the StopScheduleActivity by either rst nding stops near them andthen clicking on a overlay or by selecting the second item from the ListView inthe MainViewActivity.If the use scenario is like the rst, the user will be facedwith a dialog asking them to enter the 4 digit stop number of the stop they desire17


arrival times <strong>for</strong>. Upon pressing the button labeled Get Routes, an HTTP requestto the <strong>OCTranspo</strong> Live Next Bus Arrival Data Feed API is made. In the packagecom.rakrezzik.schedule_tasks, there is a class called DownloadRouteInfo. This is anAsyncTask used to do the background network operation as Android does not allowthem on the main thread. The user will see a ProgressDialog like in the rst screenshotof Figure 4 while waiting <strong>for</strong> the HTTP request. Once the request is fullled theuser is greeted with a list of routes they may choose from. Upon selecting a routean Intent is used to start a StopScheduleActivity <strong>for</strong> that stop and route. It will looklike the second screenshot in Figure 4.Figure 4: Obtain Routes <strong>for</strong> StopThe times are updated every 30 seconds through a background thread runningand instance of a Runnable class called TimesUpdater, a private class within theStopScheduleActivity class. In the action bar below the dynamic timetable are twooptions the user can choose from. The rst, represented by an ImageButton with astar, is to add this stop and route to the user's favourites <strong>for</strong> quick access the next18


time they use the <strong>application</strong>. The second is to show the <strong>bus</strong>es, if available, to bedrawn using a custom overlay on a Google Map.4.1.4 PlannerActivityOften a public transit rider might not know what series of <strong>bus</strong>es to take in orderto get to their desired destination. <strong>OCTranspo</strong> provides the Travel Planner on theirwebsite. I thought this would be a usual feature <strong>for</strong> the <strong>application</strong>. From using theweb <strong>application</strong> I was able to determine how to <strong>for</strong>m the same requests <strong>for</strong> use in thisproject. This Activity asks the user <strong>for</strong> the the address of the origin and that of theirdesired destination and will then direct them on which <strong>bus</strong>es to take at what stops.The results are the displayed using the PlannerWebActivity using the WebView inits layout. The HTML supplied by the HTTP response is supplied to the WebViewand the directions contained within it are displayed <strong>for</strong> the user. For future versionsI wish to parse relevant details from the response such as stop numbers, to allow theusers to click on the stop to see <strong>live</strong> arrival estimates rather than rely on <strong>OCTranspo</strong>'sTravel Planner times which are static. An example PlannerActivity and the requesteddirections in a PlannerWebActivity can be seen in Figure 5.19


Figure 5: Travel Planner4.1.5 PlannerWebActivityThe PlannerWebActivity is very simple. Its sole purpose is to display the results of aquery to <strong>OCTranspo</strong>'s Travel Planner. The layout <strong>for</strong> this activity is composed of aWebView occupying the entire screen. Travel directions provided by the result of aquery to the Travel Planner can be seen in Figure 6.20


Figure 6: Directions in a PlannerWebActivity4.1.6 FavouritesActivityThe FavouritesActivity can be accessed only from the main menu.It is the lastoption ins the ListView and is meant to be used to quickly access frequently usedstops immediately after launch. Each favourite stop is stored in a SQLite table, whichis then queried to populate the ListView presented to the user. In Figure 7 we havethe FavouritesActivity with two stops; the rst being a stop near my house and thesecond the <strong>bus</strong> stop at Carleton University in front of the Minto Centre. Clicking onany of the items in the list will start a StopScheduleActivity, allowing the user to gofrom starting the <strong>application</strong> to looking at the dynamic timetable very quickly.21


Figure 7: Favourites4.1.7 MapViewActivityThe MapViewActivity is composed of a MapView. It is used to either display stopsas would be the case if the user selected Stops near me from the main menu, or todisplay the <strong>live</strong> <strong>GPS</strong> <strong>location</strong>s of <strong>bus</strong>es <strong>for</strong> a route. The second possibility is the resultof the user selecting Stop schedule from the main menu and then clicking the mapbutton in the resulting StopScheduleActivity. In this scenario the MapViewActivitywill send a request to the OC Transpo Live Next Bus Arrival Data Feed API every30 seconds. This is done in the MapViewActivity class using a background threadrunning an instance of the Runnable class <strong>GPS</strong>MapLocationUpdater in the packagecom.rakrezzik.map. In the run() method the AsyncTask DownloadRoute<strong>GPS</strong>Data is22


used to make the HTTP request and to handle the response.Figure 8: Map showing <strong>bus</strong> <strong>location</strong>s4.1.8 MyPreferencesActivityMyPreferencesActivity extends PreferencesActivity and is used to change some <strong>application</strong>settings using SharedPreferences.MyPreferencesActivity can be accessedby pressing the inly button of the menu in the ActionBar of the MainViewActivity.MyPreferencesActivity is populated by an xml le preference.xml which is locatedin res/xml/preferences.xml. Currently the only settings that can be changed as theURLs of the APIs used in the Android client. A version of this <strong>application</strong> would nothave these and instead would include things such as how often times get refreshed.This current MyPreferencesActivity in Figure 9 shows a screenshot of MyPreference-23


sActivity.Figure 9: Preferences using MyPreferencesActivity4.2 <strong><strong>OCTranspo</strong>Live</strong> API (Server)In order to utilize the text data provided by <strong>OCTranspo</strong> two things needed to bedone.First I needed to create a database and that will be discussed in the nextsection. The second thing was to create a web based API <strong>for</strong> the Android client touse. After some discussion with Dr. White I decided HTTP requests serving backresponses in JSON was the right choice <strong>for</strong> this project. The web container used totake the requests and serve up the responses is TomCat.The API is implemented as a servlet meant to be deployed to a web container,in this case TomCat. The servlet itself is a web <strong>application</strong> that makes use of theJAX-RS, a Java API <strong>for</strong> RESTful web services. The implementation of JAX-RS used<strong>for</strong> this project is Jersey. The way it works is by dening a path <strong>for</strong> a resource (using@Path decorator) and then implementing the HTTP methods that are needed (GET,24


POST, PUT, DELETE). Below is a snippet of the StopsResource, responsible <strong>for</strong>dealing with stop related requests.25


Listing 4: JAX-RS Resource@Path( "/ stops " )public c l a s s StopsResources {@ContextU r i I n f o u r i I n f o ;@ContextRequest r e q u e s t ;@Path( "/ stop_times /{ stop_code }" )public StopTimes getStopTimes (@PathParam( " stop_code " )S t r i n gstop_code ) {return new StopTimes ( u r i I n f o , request ,stop_code ) ;}@Path( "/ near " )public StopsNear getStopsNear (@QueryParam( " l a t " ) double lat ,@QueryParam( " lon " ) double lon ) {return new StopsNear ( u r i I n f o , request , lat ,lon ) ;}26}


This resource <strong>for</strong> example is used to return the stops near a user in JSON <strong>for</strong>matas was see in Listing 4. The StopsNear object that is returned when the path/stops/near.On the HTTP verb GET it does a query on the MySQL database, packsthe result into a JSON array, and returns the JSON array. The snippet in Listing 5below shows the implementation of that functionality.Listing 5: Near Stops GET response (/stops/near)@GET@Produces ( " a p p l i c a t i o n / j s o n " )public S t r i n g getStops ( ) {System . out . p r i n t l n ( "Lat : " + l a t ) ;System . out . p r i n t l n ( "Lon : " + lon ) ;S t r i n gquery = "SELECT stop_code , stop_name , stop_lat, stop_lon , ( (ACOS( SIN ( " + l a t +" ∗ PI ( ) / 180)∗ SIN ( stop_lat ∗ PI ( ) / 180) + " +" COS( " + l a t + " ∗ PI ( ) / 180) ∗ COS( stop_lat ∗ PI ( )/ 180) ∗COS( ( " + lon + " − stop_lon ) ∗" +" PI ( ) / 180) ) ∗ 180 / PI ( ) ) ∗ 60 ∗ 1 . 1 5 1 5 )AS d i s t a n c e FROM stopsHAVING d i s t a n c e


could easily add more resources to do all kinds of queries on the MySQL database andprovide with the <strong>application</strong> with more data. I plan in the future to implement someuser feedback functionality in order to see how accurate the <strong>OCTranspo</strong> estimatesreally are.4.3 MySQL databaseI chose MySQL database because I had previous experience with installing it on myLinux machine. The reason a database was needed is that the <strong>OCTranspo</strong> data needsto be queryable and text les don't lend themselves well to such manipulation. FirstI downloaded the <strong>OCTranspo</strong> dataset from their website. It is in the GTFS <strong>for</strong>matwhich was created by Google. The General Transit Feed Specication is a common<strong>for</strong>mat <strong>for</strong> public transportation schedules and the associated geographic in<strong>for</strong>mationsuch as <strong>bus</strong> stop <strong>location</strong>s[5]. To parse all this plain text data I wrote a Python scriptto go through all the les dened by the GTFS, create tables necessary, and populatethem. The script is named octranspo_parse.py and is on the CD included with thisreport.28


5 Project ResultsThis project in my mind was a success. All the goals I had set at the beginning weremet and in the end I believe I was able to create a useful <strong>application</strong> which I useeveryday. I think the Android client is well designed, usable, and visually appealing.The <strong>application</strong> allows users to make better choices about when to leave home or theoce to catch a <strong>bus</strong> and limits the frustrations all have had with <strong>OCTranspo</strong>. Thedevelopment of the REST API allowed me to get a taste <strong>for</strong> developing web base APIswhich are highly concurrent due to their lightweight HTTP requests and responses.Using the <strong>location</strong> services provided by the Android plat<strong>for</strong>m gave me a niceintroduction to building <strong>application</strong>s that make use of the rich set of sensory dataprovided by modern smartphones. With <strong>location</strong> data, accelerometer, and axis, itis not hard to see the potential <strong>for</strong> rich user engaging <strong>application</strong>s. I believe I willattempt make at least one other <strong>application</strong> in the near future using one or more ofthese sensors.The backend of this project I think is suitable to be scaled in the future if desired.This would require replicating the MySQL database to run on multiple servers andsome kind of load balancer in front of a few TomCat servers <strong>for</strong> the API itself. I donot have any experience with this but from my limited knowledge of scalable websystems from tech blog readings this seems to be done often and is easily achieved bysomeone with the proper experience and knowledge.Once I had the <strong>application</strong> to a suitable level of usability I installed it on twoof my roomates' phones. After a few days of use they both reported that they wereextremely please with the <strong>application</strong> and that it had saved them from blindly headingto the stop hoping that the <strong>bus</strong> would actually arrive when scheduled. I was veryplease to see that something I had developed was helping real people by aiding them29


in going about their day in a more ecient manner. By installing the <strong>application</strong> ontheir two phones I was able to test the <strong>application</strong> on two other physical devices, bothrunning dierent versions of the Android plat<strong>for</strong>m. On of the phones was running arather dated Android 2.2 and meant I had to tweak some of the code in order to runit. In the end I decided that the Android 4.x plat<strong>for</strong>m will be my target as there wastoo much to consider due to Android fragmentation.I have learned a lot while working on this project and I think I would feel com<strong>for</strong>tabledeveloping another <strong>application</strong> and improving this one in the future.6 ConclusionWhen choosing a new plat<strong>for</strong>m to develop <strong>for</strong> there will always be complicationsalong the way and a proper amount of time must be taken to become com<strong>for</strong>tabledeveloping <strong>for</strong> the plat<strong>for</strong>m. For myself learning the tools available with the Androidand well as the framework of an Android <strong>application</strong> took some time. As with mostprogrammers I began with the famous Hello World program rst seen in Kernighanand Ritchie's The C Programming Language. Google provides a few good introductorytutorials on their developer website. I found that they are lacking in number andcomplexity however. The tutorials are usually pretty simple and they do not cover alarge amount of topics. I should note that the API documentation is excellent. Butagain, navigating it requires the developer to be somewhat experienced and to knowwhat he/she is looking <strong>for</strong>.The Android tools provided with the SDK were excellent, with the exception of thegraphical layout editor. I found myself manually editing the layout's xml most of thetime. The ADT plugin provides a perfect development environment in my opinion,though I am likely too fond of Eclipse to provide a fair and balanced opinion.30


This project has allowed me to gain the experience with Android developmentI wished <strong>for</strong>.I now feel com<strong>for</strong>table with the plat<strong>for</strong>m and could work on other<strong>application</strong>s. The project itself brought lots of stress but also lots of joy. I supposethat can be said of any worthwhile learning experience.There were times whennothing seemed to work and I would search the Internet <strong>for</strong> hours hoping someonehad a solution <strong>for</strong> my problem. Working with web <strong>application</strong> APIs <strong>for</strong> the rst timewas tricky at rst, but an invaluable experience. I can see their value in exposing the<strong>application</strong> model to clients in a scalable fashion.In the end I am very pleased with the result. I think the fact that this solved areal world problem and makes my life easier makes this project worth the many hoursI put into it. The thanks I've received from my roommates has brought me muchjoy and has motivated me to continue development and eventually publish it to theAndroid Marketplace.6.1 LimitationsDue to the delay is <strong>GPS</strong> <strong>location</strong> transmission from the <strong>bus</strong>es to the <strong>OCTranspo</strong>servers coupled with the delays in receiving a request on the Android client, thetimes and <strong>location</strong>s shown maybe o by up to 2 minutes in my experience. I thinkthis is an acceptable error when compared to having only the schedule timetable asa reference.Another limitation is the lack of in<strong>for</strong>mation about the capacity of the <strong>bus</strong>. I'mnot sure how <strong>OCTranspo</strong> might get this kind of data but knowing that <strong>for</strong> examplethe <strong>bus</strong> is full would be useful as you would not be able to get on the <strong>bus</strong>.Finding stops near a devices requires that the Android smartphone have a <strong>GPS</strong>chip on it, or that WiFi is enabled in order to take advantage of Google's <strong>location</strong>31


service. I imagine there might be some budget phones on the market lacking one orboth of these.6.2 Future improvementsI plan to make a few improvement to the <strong>application</strong> when time allows. First would beto make the travel planner more usable. As it is now it only show the plan as HTML.I would like to parse through the HTML looking <strong>for</strong> <strong>bus</strong> stop numbers allowing theusers to look at the plan and then click on the <strong>bus</strong> stop they are told they shouldwait at. This will allow them to actually see when the <strong>bus</strong> will arrive and not haveto rely on the static Travel Planner times.Another improvement I think would make this <strong>application</strong> even more useful isthe addition of a widget. It would be nice to be able to add to your home screen awidget showing the arrival times <strong>for</strong> the stop you use to get to work in the morning<strong>for</strong> example. A somewhat related addition would be the ability to watch a <strong>bus</strong> andbe notied when the <strong>bus</strong> is say less than 6 minutes away.6.3 Contributions to the FieldAs the applied nature of this project it did not contribute to the eld of computerscience. The aim of the project was to solve a real world problem by creating a mobile<strong>application</strong> and deploying the system needed to drive the experience. I believe thisproject will be useful <strong>for</strong> anyone using public transportation in Ottawa and to anystudent interested in Android and web services.32


6.4 Concepts and Technologies LearnedWhile working on this project I was able to learn some knew technologies.On aconceptual level I was able to get a sense of what REST APIs are and how they canbe used to expose <strong>application</strong> models to the outside in a lightweight and scalablemanner.As <strong>for</strong> technologies, the main one was the Android plat<strong>for</strong>m. The project hasallowed me to gain enough experience with the Android plat<strong>for</strong>m and the developmenttools provided in the SDK along with the ADT plugin to feel com<strong>for</strong>table writinganother <strong>application</strong> or take on a job developing Android <strong>application</strong>s.With setting up the MySQL database I re-en<strong>for</strong>ced some previous knowledge Ihad about working with this DBMS. It also allowed me to get a taste of deployingthe components of an <strong>application</strong> to a Linux server.Although my experience with the TomCat web container and servlets was ratherfrustrating at rst I see that TomCat is a great piece of software and that along withservlets makes a great deployment plat<strong>for</strong>m.33


7 ReferencesReferences[1] http://developer.android.com/sdk/eclipse-adt.html[2] http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html[3] http://www.octranspo1.com/developers/documentation[4] http://www.mysql.com/why-mysql/[5] https://developers.google.com/transit/gtfs/34


8 Appendices8.1 CD ContentsThe CD provided with this report contains the following:• <strong><strong>OCTranspo</strong>Live</strong> (Android client) source code• <strong><strong>OCTranspo</strong>Live</strong> API source code• Python script <strong>for</strong> parsing <strong>OCTranspo</strong> GTFS data, along with the dataset.• PDF of this report8.2 Development EnvironmentThe Eclipse IDE was used <strong>for</strong> all the development with the exception of the Pythonscripts. A few tools need to be installed and congured in order to run the providedles.Tools Required• Java SDK (1.6 was used)• Android SDK (API level 14 or higher) http://developer.android.com/sdk/installing.html• ADP Plugin <strong>for</strong> Eclipse http://developer.android.com/sdk/eclipse-adt.html#installing• Android device running Android 4.0 or higher35


An emulator can be used but the <strong>application</strong> is much more useful in amobile context, away from a computer.• TomCat web server to deploy the <strong><strong>OCTranspo</strong>Live</strong> API .war le This can be dicult.There is a plugin <strong>for</strong> Eclipse that allows deploymentof web projects directly to a TomCat server. This was used <strong>for</strong> thedevelopment of this <strong>application</strong>.8.3 Project SetupThe source <strong>for</strong> OCTransLive (Android client) is provided as an Eclipse project. InEclipse, click File > Import > Existing Projects into Workspace to import the projectinto Eclipse. Then click Finish.Repeat this <strong>for</strong> <strong><strong>OCTranspo</strong>Live</strong> API (octranspo<strong>live</strong>_api). This might prove harderto get running depending on whether you have a working conguration of the TomCatplugin <strong>for</strong> Eclipse. After conguring the Server with the plugin you should be ableto run the servlet directly on the server within Eclipse.If the Android SDK along with Google Apps is installed then you can run the OC-TranspoLive <strong>application</strong> either on your phone or using the Android emulator providedwith the SDK.36

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!