<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"><channel><title>Pleasant Programmer</title><link>http://pleasantprogrammer.com</link><description></description><lastBuildDate>Wed, 24 Jul 2013 23:54:41 GMT</lastBuildDate><generator>nikola</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Highways in OTP</title><link>http://pleasantprogrammer.com/posts/highways-in-otp.html</link><description>&lt;html&gt;&lt;body&gt;&lt;p&gt;One of the weird things that happens with OTP is sometimes it gives absurdly roundabout routes. Here is OTP's suggested route for walking from UP to Ateneo:&lt;/p&gt;
&lt;p&gt;&lt;img alt="Roundabout route from UP to Ateneo" src="/galleries/transit/otproundabout.png"&gt;&lt;/p&gt;
&lt;p&gt;This is just so hilariously wrong. It's much simpler to just walk along Katipunan Avenue.&lt;/p&gt;
&lt;p&gt;OTP couldn't possibly be that dumb though, so there must be something we're doing wrong. If you notice, Katipunan Avenue is colored red compared to the other streets. OTP seems to be avoiding any path that goes along Katipunan Avenue. The problem might have something to do with the "road type" designated to Katipunan.&lt;/p&gt;
&lt;p&gt;Apparently, by default OTP will consider roads of type &lt;code&gt;trunk&lt;/code&gt; to be non-walkable and non-bikable. This is documented in the &lt;a href="http://wiki.openstreetmap.org/wiki/OpenTripPlanner"&gt;OpenStreetMap wiki&lt;/a&gt; and the &lt;a href="https://github.com/openplans/OpenTripPlanner/wiki/GraphBuilder#permissions-and-bicycle-safety"&gt;OTP wiki&lt;/a&gt; as well. There are actually multiple ways to go about this then. The first solution that came to mind was to just edit the original OSM XML file.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre&gt;&lt;span class="n"&gt;sed&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bak&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;trunk&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;primary&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;g&lt;/span&gt; &lt;span class="n"&gt;manila&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;osm&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;And rebuild the graph. It doesn't really matter much because the OSM data isn't used to render the maps. It's just used to build the routing data. This is actually what I did for &lt;a href="http://maps.pleasantprogrammer.com"&gt;maps.pleasantprogrammer.com&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;It's also possible to set the default way properties in OTP. Instead of disallowing walking and biking on &lt;code&gt;highway=trunk&lt;/code&gt; we could allow that. This is not much better than the &lt;code&gt;sed&lt;/code&gt; solution though. It's better since you keep the weighting done by OTP, but you're still saying that all trunks are walkable which might not be the case.&lt;/p&gt;
&lt;p&gt;The most correct way to actually fix this is to go through each of the trunks and specifying &lt;code&gt;foot=yes&lt;/code&gt; and &lt;code&gt;bicycle=yes&lt;/code&gt; for those trunks that are actually walkable. You could either do this locally with the dumped data, or contribute it directly to OSM. I'm not sure on the particulars with updating OSM though.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</description><guid>http://pleasantprogrammer.com/posts/highways-in-otp.html</guid><pubDate>Wed, 24 Jul 2013 15:15:57 GMT</pubDate></item><item><title>Elevation Data in OTP</title><link>http://pleasantprogrammer.com/posts/elevation-data-in-otp.html</link><description>&lt;html&gt;&lt;body&gt;&lt;p&gt;&lt;img alt="OpenTripPlanner showing elevation data" src="/galleries/transit/otpelevation.png"&gt;&lt;/p&gt;
&lt;p&gt;One thing I hadn't tested out last time was OTP's support for elevation data. It makes use of this by showing the elevation you have to traverse while walking along the suggested route. It can also take it into account when suggesting bike routes.&lt;/p&gt;
&lt;p&gt;The &lt;a href="https://github.com/openplans/OpenTripPlanner/wiki/FiveMinutes"&gt;5 minute tutorial&lt;/a&gt; actually discusses the elevation data briefly, but a more in-depth thing you can look at is the &lt;a href="https://github.com/openplans/OpenTripPlanner/wiki/GraphBuilder#elevation-data"&gt;GraphBuilder documentation&lt;/a&gt;. It suggests using the ASTER dataset which is free but requires registration. I just opted to use the SRTM data available from the &lt;a href="http://www.philgis.org/freegisdata.htm"&gt;PhilGIS website&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I don't know about the ASTER dataset, but the PhilGIS data was in the ERDAS img format. OTP only supports GeoTIFF so there was a need to convert it beforehand. You can use &lt;a href="http://www.gdal.org/"&gt;GDAL&lt;/a&gt; for this. You'd just then run,&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre&gt; &lt;span class="n"&gt;gdal_translate&lt;/span&gt; &lt;span class="n"&gt;srtm41_90m_phl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;img&lt;/span&gt; &lt;span class="n"&gt;phil&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tiff&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Afterwards, it's just a matter of following the OTP instructions on using a local elevation dataset. The process actually doubled the size of the generated Graph.obj so it might not be ideal if you're running on limited RAM.&lt;/p&gt;
&lt;p&gt;I've actually hosted a &lt;a href="http://maps.pleasantprogrammer.com"&gt;working example&lt;/a&gt;. It's pretty much at the limits of the RAM so it might be slow and unreliable, but you can test it out just for fun. Please don't abuse it though.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</description><guid>http://pleasantprogrammer.com/posts/elevation-data-in-otp.html</guid><pubDate>Tue, 23 Jul 2013 10:23:00 GMT</pubDate></item><item><title>GraphServer</title><link>http://pleasantprogrammer.com/posts/graphserver.html</link><description>&lt;html&gt;&lt;body&gt;&lt;p&gt;Link: &lt;a href="http://graphserver.github.io/graphserver/"&gt;http://graphserver.github.io/graphserver/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;One other routing webapp I saw was GraphServer. It's actually more of a general purpose Graph library which supports GTFS and OSM data than an actual dedicated routing software like OpenTripPlanner. It's also based off python and C instead of Java, so it feels a lot less heavy.&lt;/p&gt;
&lt;p&gt;The instructions on the website are already pretty good. There are just some minor errors with it. Where it says &lt;code&gt;gs_gtfsdb_build&lt;/code&gt;, you should actually use &lt;code&gt;gs_gtfsdb_compile&lt;/code&gt;. Also, when running &lt;code&gt;gs_osmdb_compile&lt;/code&gt; you might need to use &lt;code&gt;-t&lt;/code&gt; for tolerant in case you follow the instructions on chopping up the original OSM data.&lt;/p&gt;
&lt;p&gt;A nice suggestion from the GraphServer instructions was to crop the OSM data to minimize the graph size. This is actually quite helpful if you downloaded the entire Philippine OSM dump. It reduced the original 900MB file to 135MB which was a lot more workable. I did hit a problem with their instructions though. The linked version of osmosis is an old one, which doesn't support 64-bit ids. The &lt;a href="http://wiki.openstreetmap.org/wiki/Osmosis"&gt;latest version of Osmosis&lt;/a&gt; easily did the job though.&lt;/p&gt;
&lt;p&gt;The actual routing though, was not exactly good. I only tried one route which should normally take 1-2 transfers, it suggested a route which involved 4+ transfers. It also didn't provide any alternate routes aside from that one. I'm not sure if it's a limitation of the provided routeserver, but I didn't bother checking if it supported parameters which might provide better routes.&lt;/p&gt;
&lt;p&gt;I think graphserver could be useful, but it seems more involved than say OpenTripPlanner. There do seem to be people who use graphserver for their routing apps, but for the bounds of the contest, or just as a side project, it might require too much effort.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</description><guid>http://pleasantprogrammer.com/posts/graphserver.html</guid><pubDate>Tue, 23 Jul 2013 06:48:29 GMT</pubDate></item><item><title>Transit Wand</title><link>http://pleasantprogrammer.com/posts/transit-wand.html</link><description>&lt;html&gt;&lt;body&gt;&lt;p&gt;Link: &lt;a href="https://play.google.com/store/apps/details?id=com.conveyal.transitwand"&gt;http://transitwand.com&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Overall, this was the simplest of the &lt;a href="http://philippine-transit.hackathome.com/use-this-code/"&gt;open-source transit tools&lt;/a&gt; to actually get up and running. There's already a deployed instance of the server, and you can easily download the phone app via the &lt;a href="https://play.google.com/store/apps/details?id=com.conveyal.transitwand"&gt;Play Store&lt;/a&gt;. Even running the server by yourself didn't have any of the hiccups I had with GTFS Editor.&lt;/p&gt;
&lt;p&gt;The phone app is actually quite simple. It allows you to capture a trip, which will record your GPS coordinates as you ride public transit. It also allows you to mark points of the trip where you stop and also how long the stop took. Lastly, it allows you to record embarking and disembarking passengers which is potentially useful for ridership data.&lt;/p&gt;
&lt;p&gt;After doing a capture session, you can review the data on the phone. It will plot out the route on a map, with markers for the stops. You then either delete the data if it looks wrong, or you can upload it to the Transit Wand server. Uploading involves registering an account, but it's free and you don't even actually need to put in a username or anything. It simply registers the phone's IMEI on the server and gives you a 6-digit identifier.&lt;/p&gt;
&lt;p&gt;You can then use the 6-digit identifier to view the data on Transit Wand's server, which is good since uploading any data automatically deletes it from the phone. There really isn't much else you can do with it though. It just allows you to view the data, and export it as a &lt;a href="https://en.wikipedia.org/wiki/Shapefile"&gt;Shapefile&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;As is, this is purely a data collection client-server app. Barring looking at the database, there is no way to get a list of phones which have collected data. Only the person who initiated the data collection knows the 6-digit code to view their data. There's also no way to extract the ridership information from the server yet. This isn't to say that the data won't eventually go public though.&lt;/p&gt;
&lt;p&gt;An interesting thing you &lt;em&gt;can&lt;/em&gt; do with the Transit Wand data is import it into GTFS Editor to make a new route. You don't even have to manually download and upload the data. Just type in your 6-digit identifier and it will give you a list of routes you've captured via Transit Wand. This is wonderful as you get all the stop data, as well as the shape of the route.&lt;/p&gt;
&lt;p&gt;I imagine these two tools were how the DOTC came up with all the GTFS data we have now. What I don't understand is why the shape data isn't present. Importing from Transit Wand already gets you shape data. There are even facilities to edit the shape within the editor if clean up is necessary. The only problem I saw was the fact that you can't easily move stops, you have to input coordinates to change the position.&lt;/p&gt;
&lt;p&gt;It &lt;em&gt;might&lt;/em&gt; also be possible that when the DOTC was still collecting the data, the route collection or editing features weren't present yet. That would just be lame and depressing though.&lt;/p&gt;
&lt;p&gt;Overall, Transit Wand does what it's supposed to do. You collect data, and then upload it to a server. There is a lot of room for improvement though. It would be nice to have a better API that allows access to more of the data. Building in analysis tools for the ridership data might also be a welcome thing. I imagine it would also be great if you could encourage people to use the app and upload their own trips.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</description><guid>http://pleasantprogrammer.com/posts/transit-wand.html</guid><pubDate>Mon, 15 Jul 2013 14:45:20 GMT</pubDate></item><item><title>Fare Data</title><link>http://pleasantprogrammer.com/posts/fare-data.html</link><description>&lt;html&gt;&lt;body&gt;&lt;p&gt;As part of the data released by the DOTC, we also have the &lt;a href="http://philippine-transit.hackathome.com/dataset-philippines-transit-information-service-gtfs/"&gt;fare matrix&lt;/a&gt; for aircon buses, ordinary buses and jeeps. All as wonderful images. The data is also actually available from the &lt;a href="http://ltfrb.gov.ph/main/farerates"&gt;LTFRB website&lt;/a&gt;. Generally, the fare scheme is represented as "pay &lt;em&gt;X&lt;/em&gt; pesos for the first &lt;em&gt;Y&lt;/em&gt; kilometers, pay &lt;em&gt;Z&lt;/em&gt; for every succeeding kilometer." Instead of a table, we can simply represent this as a formula instead,&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre&gt;&lt;span class="n"&gt;base_fare&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;distance&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;initial&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;per_km&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;The relevant values for the three services are:&lt;/p&gt;
&lt;table&gt;&lt;tr&gt;&lt;td&gt;type&lt;/td&gt;
    &lt;td&gt;base_fare&lt;/td&gt;
    &lt;td&gt;initial&lt;/td&gt;
    &lt;td&gt;per_km&lt;/td&gt;
  &lt;/tr&gt;&lt;tr&gt;&lt;td&gt;bus aircon&lt;/td&gt;
    &lt;td&gt;12.00&lt;/td&gt;
    &lt;td&gt;5 km&lt;/td&gt;
    &lt;td&gt;2.20&lt;/td&gt;
  &lt;/tr&gt;&lt;tr&gt;&lt;td&gt;bus ordinary&lt;/td&gt;
    &lt;td&gt;10.00&lt;/td&gt;
    &lt;td&gt;5 km&lt;/td&gt;
    &lt;td&gt;1.85&lt;/td&gt;
  &lt;/tr&gt;&lt;tr&gt;&lt;td&gt;jeep aircon&lt;/td&gt;
    &lt;td&gt;8.00&lt;/td&gt;
    &lt;td&gt;4 km&lt;/td&gt;
    &lt;td&gt;1.40&lt;/td&gt;
  &lt;/tr&gt;&lt;/table&gt;&lt;p&gt;It isn't as simple as that though. Fares are also rounded to the nearest 25 centavos. So we'd need to round them off correctly. This can be achieved by doing,&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre&gt;&lt;span class="n"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;calculated_fare&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;4.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mf"&gt;4.0&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;There's also the discounted fare for students, senior citizens and persons with disability. They get 20% off the fare (prior to rounding) and the resulting fare is rounded off as well.&lt;/p&gt;
&lt;p&gt;Doing just this, we actually do get the same results as the fare matrices in the image for the most part. There are some discrepancies with the discounted jeep fares. I've tried to resolve it by tweaking around with the formulas, but it really doesn't make sense in any way. I presume these were manually adjusted for one reason or another.&lt;/p&gt;
&lt;p&gt;Here's a &lt;a href="/uploads/farematrix.rb"&gt;script&lt;/a&gt; that generates CSVs of all the three fare matrices. If you're too lazy to run it, here are links to the &lt;a href="/uploads/pub_aircon.csv"&gt;aircon bus&lt;/a&gt;, &lt;a href="/uploads/pub_ordinary.csv"&gt;ordinary bus&lt;/a&gt; and &lt;a href="/uploads/puj.csv"&gt;jeep&lt;/a&gt; fare matrices.&lt;/p&gt;
&lt;h4&gt;GTFS compatibility&lt;/h4&gt;
&lt;p&gt;As is, the provided GTFS data does not have any fare data. I imagine this is because the existing spec doesn't have good support for distance-based fares like we have in the Philippines. Judging from the &lt;a href="https://code.google.com/p/googletransitdatafeed/wiki/FareExamples"&gt;fare examples&lt;/a&gt;, the only reasonable way we could implement distance-based fares is following example 6. This would involve setting a fare for each possible pair of stops based on the distance between them. This isn't exactly ideal. In fact, the people originally working on the DOTC project have voiced &lt;a href="https://groups.google.com/forum/#!topic/gtfs-fare-wg/V63xRSnQJGw"&gt;issues&lt;/a&gt; and made &lt;a href="https://groups.google.com/forum/#!msg/gtfs-changes/uybrAokZ9Cg/rqlzXdMypUgJ"&gt;proposals&lt;/a&gt; for having distance-based fares included into GTFS.&lt;/p&gt;
&lt;p&gt;Apparently, public transit fares are a really complicated thing. You have fares based on distance, number of stops passed through, and transfers which may or may not cost extra. Not only that, you might have discounted fares, or first-class vs economy fares. The community will want to get it right before it's formally included in the spec. You can see the current state of the consolidated &lt;a href="https://docs.google.com/document/d/1mK3--o5g4-3cCXaqmch92U63JTwChh0L2VCmcDViIlM/edit"&gt;GTFS fare proposal here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Even in it's proposal form though, we might have hope of being able to see these being used. There's currently a &lt;a href="https://github.com/OneBusAway/onebusaway-gtfs-modules/pull/30"&gt;pull request&lt;/a&gt; for supporting the distance-based fare scheme into the OneBusAway libraries. The libraries actually used by GTFS Editor and OpenTripPlanner for working with GTFS data.&lt;/p&gt;
&lt;h4&gt;Remaining Problems&lt;/h4&gt;
&lt;p&gt;Given all that, it would probably still be a long way before this allows us to make a really good routing app. We still don't have shape data, so the distance estimates would really be rough estimates at best. There's no support for rounding to the nearest centavo. I realize that's just nitpicking, but if we want something truly polished, even that has to be taken care of.&lt;/p&gt;
&lt;p&gt;We also don't know if the jeeps or buses strictly follow the distance-based scheme. After all, if you can get on and off anywhere, you can't really measure distance that exactly. I assume they generally work off the notion of "zones" than actual distance travelled. In that sense, they work more similarly to the LRT which has fares based on how many stops you pass. For jeeps and buses, your fare is probably based more on how many "zones" you pass through.&lt;/p&gt;
&lt;h4&gt;Conclusion&lt;/h4&gt;
&lt;p&gt;Philip, a co-worker of mine at By Implication, had suggested that we might want to use a different model than what the GTFS proposes. I have to agree with him. At this point, the GTFS doesn't really fit with our system. But I do think that open data and standards are great. In fact, I applaud the developers who made proposals for the fare system, as those are great first steps towards making the GTFS a more universal standard.&lt;/p&gt;
&lt;p&gt;Side note: I'd also actually really like to hear about the DOTC developers' experience with the project. It would be nice if they had a devblog.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</description><guid>http://pleasantprogrammer.com/posts/fare-data.html</guid><pubDate>Sat, 13 Jul 2013 13:15:09 GMT</pubDate></item><item><title>GTFS Editor</title><link>http://pleasantprogrammer.com/posts/gtfs-editor.html</link><description>&lt;html&gt;&lt;body&gt;&lt;p&gt;Link: &lt;a href="https://github.com/conveyal/gtfs-editor"&gt;https://github.com/conveyal/gtfs-editor&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; they really meant under development&lt;/p&gt;
&lt;p&gt;When I first saw the source of GTFS Editor, I was ecstatic. They used &lt;a href="http://playframework.com/"&gt;Play framework&lt;/a&gt;!!! Not only that, they're targeting PostgreSQL as the main database. Those are our favorite tools for building webapps at By Implication. I was a bit sad though, when I saw it was on the 1.x release of Play though. I did have some experience with that release, but not as much compared to 2.x.&lt;/p&gt;
&lt;p&gt;Getting it to actually run though, wasn't very pleasant. The initial setup was easy enough. Get &lt;a href="http://www.playframework.com/download"&gt;Play 1.2.5&lt;/a&gt;, install Postgres with PostGIS, clone the repo and create backing database in Postgres. Some minor additional steps you need are to create the PostGIS extension on the database. The schema is automatically generated and applied by Play so that should be all that's necessary. Wonderful. Then, run play, open a browser, go to &lt;a href="http://localhost:9000"&gt;http://localhost:9000&lt;/a&gt;, compilation error. Fantastic.&lt;/p&gt;
&lt;p&gt;If you don't want to go through the technical details, you can just jump to the &lt;a href="/posts/gtfs-editor.html#conclusion"&gt;conclusion&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;Let's Debug!&lt;/h3&gt;
&lt;p&gt;I'll be splitting the next section up into 2 parts. In the first pass, I'll talk about what I did to just get the app to run but I won't try hard to fix any bugs. This generally is what I do when I try to get apps to run. I'll also be dropping enough information so that you can actually figure out what the real problem is. In the second pass, I'll explain what the problems were and how I fixed them.&lt;/p&gt;
&lt;h4&gt;First Pass&lt;/h4&gt;
&lt;p&gt;A thing to note about Play (and one of the reasons it's a lovely Java framework) is that you don't need to do manual compilation. Just edit some source files, refresh your browser and it will automatically do the compilation for you. One less argument for using PHP. It even shows you (in the browser!) the source and which line of code caused the compilation error. So that's what I saw, &lt;code&gt;Error: type Check already defined&lt;/code&gt;&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre&gt;&lt;span class="nd"&gt;@Retention&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;RetentionPolicy&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;RUNTIME&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@Target&lt;/span&gt;&lt;span class="o"&gt;({&lt;/span&gt;&lt;span class="n"&gt;ElementType&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;METHOD&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ElementType&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;TYPE&lt;/span&gt;&lt;span class="o"&gt;})&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nd"&gt;@interface&lt;/span&gt; &lt;span class="n"&gt;Check&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="c1"&gt;// error here&lt;/span&gt;

    &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="nf"&gt;value&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;You also know that typical behavior among programmers where your program doesn't compile, but you keep trying to compile it anyway hoping that it will magically just work. That's what I did, and it actually ran. I couldn't really just let this pass, so I decided to try deleting &lt;code&gt;Check.java&lt;/code&gt;. I got another compilation error, &lt;code&gt;Error: type Secure already defined&lt;/code&gt;&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Secure&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;Controller&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="c1"&gt;// error here&lt;/span&gt;

    &lt;span class="nd"&gt;@Before&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;unless&lt;/span&gt;&lt;span class="o"&gt;={&lt;/span&gt;&lt;span class="s"&gt;"login"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"authenticate"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"logout"&lt;/span&gt;&lt;span class="o"&gt;})&lt;/span&gt;

    &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;checkAccess&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="kd"&gt;throws&lt;/span&gt; &lt;span class="n"&gt;Throwable&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;At that point, I just decided to just debug it later. It works by just forcing it anyway. So I put &lt;code&gt;Check.java&lt;/code&gt; back in and proceeded to just refresh until it compiled and ran.&lt;/p&gt;
&lt;p&gt;The next problem is a sort of common thing most webapp developers have to solve one way or another. How do you set up the initial admin account? Phrased a different way, how do I login to this thing? The first thing I tried was just add a user into the &lt;code&gt;account&lt;/code&gt; table directly. One problem though was how to set the password correctly. Plaintext obviously wouldn't work.&lt;/p&gt;
&lt;p&gt;Another note regarding Play 1.x, it provides the &lt;a href="http://www.playframework.com/documentation/1.2.5/secure"&gt;secure module&lt;/a&gt; which handles logins and keeping state, you simply need to implement the method &lt;code&gt;boolean authenticate(String username, String password)&lt;/code&gt;. It leaves the actual process of verifying the login to the programmer. This can be exploited by just making the method return &lt;code&gt;true&lt;/code&gt; and then any login would work. No need to actually set the password. Excellent.&lt;/p&gt;
&lt;p&gt;And we're logged in, just in time to encounter a runtime exception. This also works much like compilation errors in Play. It shows a page with the error and the relevant source lines. Now we get, &lt;code&gt;IndexOutOfBoundsException occured : Index: 0, Size: 0&lt;/code&gt;&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"agencyId"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="n"&gt;Agency&lt;/span&gt; &lt;span class="n"&gt;agency&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;agencies&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// error here&lt;/span&gt;

    &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;put&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"agencyId"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;agency&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;put&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"agencyName"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;agency&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Apparently, we need to have an agency. That's generally simple enough. You just manually insert an agency into the &lt;code&gt;agency&lt;/code&gt; table. After that's done, we finally have a view of the actual application. It's very Bootstrap-y, but that's just fine. The workflow though, is not perfectly intuitive, but I'll talk about that some other day.&lt;/p&gt;
&lt;p&gt;That's not the end of it though, we still have to fix these bugs. The developer obviously didn't have to put up with this when they were working, so what happened? Also, the log is showing some weird things,&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre&gt;~        _            _
~  _ __ | | __ _ _  _| |
~ | '_ \| |/ _' | || |_|
~ |  __/|_|\____|\__ (_)
~ |_|            |__/
~
~ play! 1.2.5, http://www.playframework.org
~
~ Ctrl+C to stop
~
CompilerOracle: exclude jregex/Pretokenizer.next
Listening for transport dt_socket at address: 8000
23:32:14,943 INFO  ~ Starting /Users/thomas/Workspace/maps/gtfs-editor
23:32:14,948 WARN  ~ Declaring modules in application.conf is deprecated. Use dependencies.yml instead (module.secure)
23:32:14,948 INFO  ~ Module secure is available (/Users/thomas/.root/opt/play-1.2.5/modules/secure)
23:32:15,830 WARN  ~ You're running Play! in DEV mode
23:32:15,952 INFO  ~ Listening for HTTP on port 9000 (Waiting a first request to start) ...
23:32:28,792 ERROR ~

@6f02fa9dd
Internal Server Error (500) for request GET /

Compilation error (In /app/controllers/Check.java around line 10)
The file /app/controllers/Check.java could not be compiled. Error raised is : The type Check is already defined

play.exceptions.CompilationException: The type Check is already defined
    at play.classloading.ApplicationCompiler$2.acceptResult(ApplicationCompiler.java:246)
    at org.eclipse.jdt.internal.compiler.Compiler.handleInternalException(Compiler.java:672)
    at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:516)
    at play.classloading.ApplicationCompiler.compile(ApplicationCompiler.java:282)
    at play.classloading.ApplicationClassloader.getAllClasses(ApplicationClassloader.java:426)
    at play.Play.start(Play.java:516)
    at play.Play.detectChanges(Play.java:630)
    at play.Invoker$Invocation.init(Invoker.java:198)
    at Invocation.HTTP Request(Play!)
23:32:31,551 INFO  ~ Connected to jdbc:postgresql://127.0.0.1/gtfs_editor
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/thomas/Workspace/maps/gtfs-editor/lib/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/thomas/.root/opt/play-1.2.5/framework/lib/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
23:32:32,490 INFO  ~ Initializing HBSpatialExtension
23:32:32,492 INFO  ~ Attempting to load Hibernate Spatial Provider org.hibernatespatial.postgis.DialectProvider
23:32:32,494 INFO  ~ Checking for default configuration file.
23:32:32,496 INFO  ~ No configuration file hibernate-spatial.cfg.xml on the classpath.
23:32:34,077 INFO  ~ Application 'gtfs-editor' is now started !
23:32:34,151 INFO  ~ Bootstrapping Database...
23:32:34,297 DEBUG ~ select count(*) as col_0_0_ from Agency agency0_ limit ?
play.exceptions.UnexpectedException: Unexpected Error
    at play.vfs.VirtualFile.contentAsString(VirtualFile.java:180)
    at play.templates.TemplateLoader.load(TemplateLoader.java:78)
    at play.test.Fixtures.loadModels(Fixtures.java:174)
    at jobs.BootstrapDatabase.doJob(BootstrapDatabase.java:57)
    at play.jobs.Job.doJobWithResult(Job.java:50)
    at play.jobs.Job.call(Job.java:146)
    at play.jobs.Job.run(Job.java:132)
    at play.jobs.JobsPlugin.afterApplicationStart(JobsPlugin.java:116)
    at play.plugins.PluginCollection.afterApplicationStart(PluginCollection.java:531)
    at play.Play.start(Play.java:547)
    at play.Play.detectChanges(Play.java:630)
    at play.Invoker$Invocation.init(Invoker.java:198)
    at play.server.PlayHandler$NettyInvocation.init(PlayHandler.java:189)
    at play.Invoker$Invocation.run(Invoker.java:276)
    at play.server.PlayHandler$NettyInvocation.run(PlayHandler.java:229)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:680)
Caused by: play.exceptions.UnexpectedException: Unexpected Error
    at play.vfs.VirtualFile.inputstream(VirtualFile.java:111)
    at play.vfs.VirtualFile.contentAsString(VirtualFile.java:178)
    ... 22 more
Caused by: java.io.FileNotFoundException: /Users/thomas/.root/opt/play-1.2.5/modules/docviewer/app/initial-agencies-data.yml (No such file or directory)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.&amp;lt;init&amp;gt;(FileInputStream.java:120)
    at play.vfs.VirtualFile.inputstream(VirtualFile.java:109)
    ... 23 more
23:32:34,316 ERROR ~ java.lang.RuntimeException: Cannot load fixture initial-agencies-data.yml: Unexpected Error
23:32:40,989 DEBUG ~ select account0_.id as id15_, account0_.active as active15_, account0_.admin as admin15_, account0_.agency_id as agency9_15_, account0_.email as email15_, account0_.lastLogin as lastLogin15_, account0_.password as password15_, account0_.passwordChangeToken as password7_15_, account0_.username as username15_ from Account account0_ where account0_.username=? limit ?
23:32:40,994 DEBUG ~ select count(*) as col_0_0_ from Account account0_ limit ?
23:32:40,999 DEBUG ~ select nextval ('hibernate_sequence')
23:32:41,051 DEBUG ~ insert into Account (active, admin, agency_id, email, lastLogin, password, passwordChangeToken, username, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
23:32:41,061 DEBUG ~ select agency0_.id as id24_, agency0_.color as color24_, agency0_.defaultLat as defaultLat24_, agency0_.defaultLon as defaultLon24_, agency0_.defaultRouteType_id as default12_24_, agency0_.gtfsAgencyId as gtfsAgen5_24_, agency0_.lang as lang24_, agency0_.name as name24_, agency0_.phone as phone24_, agency0_.systemMap as systemMap24_, agency0_.timezone as timezone24_, agency0_.url as url24_ from Agency agency0_ order by agency0_.name
23:32:41,175 ERROR ~

@6f02fa9dg
Internal Server Error (500) for request GET /

Execution exception (In /app/controllers/Application.java around line 57)
IndexOutOfBoundsException occured : Index: 0, Size: 0

play.exceptions.JavaExecutionException: Index: 0, Size: 0
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:237)
    at Invocation.HTTP Request(Play!)
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.ArrayList.RangeCheck(ArrayList.java:547)
    at java.util.ArrayList.get(ArrayList.java:322)
    at controllers.Application.initSession(Application.java:57)
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:510)
    at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:484)
    at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:479)
    at play.mvc.ActionInvoker.handleBefores(ActionInvoker.java:328)
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:142)
    ... 1 more
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;After &lt;code&gt;23:32:34&lt;/code&gt; is when I get the login page. &lt;code&gt;23:32:40&lt;/code&gt; is after I've logged in.&lt;/p&gt;
&lt;h4&gt;Second Pass&lt;/h4&gt;
&lt;p&gt;So how did you do? First, the error that &lt;code&gt;type Check already defined&lt;/code&gt; usually does mean that &lt;code&gt;Check&lt;/code&gt; was already defined elsewhere. Looking in the app folder though, there was nothing of the sort. It's the only one there that was &lt;code&gt;Check.java&lt;/code&gt;. But remember the secure module? Modules work by providing source files and Play just compiles them all together. Bingo, &lt;code&gt;Check.java&lt;/code&gt;. Doing a diff shows nothing was changed. So the solution really was just simply delete &lt;code&gt;Check.java&lt;/code&gt; and also &lt;code&gt;Secure.java&lt;/code&gt;. No more compilation errors!&lt;/p&gt;
&lt;p&gt;The next question is, how do you get the initial user? There actually is some code that looks like it creates the default admin user,&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Security&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;isConnected&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="o"&gt;...&lt;/span&gt;
    &lt;span class="n"&gt;Account&lt;/span&gt; &lt;span class="n"&gt;account&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Account&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;find&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"username = ?"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Security&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;connected&lt;/span&gt;&lt;span class="o"&gt;()).&lt;/span&gt;&lt;span class="na"&gt;first&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="o"&gt;...&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;account&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;Account&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;count&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;account&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Account&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"admin"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"admin"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"admin@test.com"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;account&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;save&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;...&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;You can actually see this in action at &lt;code&gt;23:32:41,051&lt;/code&gt; in the log. So what's wrong with all of this? The account creation happened after I've already logged in. In fact, &lt;code&gt;Security.isConnected()&lt;/code&gt; checks whether the user is already logged in or not. How does this even make sense?&lt;/p&gt;
&lt;p&gt;Lastly, we have the problem of the agencies. Just by looking at the log, you can safely say we're missing a file called &lt;code&gt;initial-agencies-data.yml&lt;/code&gt;. Ok, apparently it's a &lt;a href="http://www.playframework.com/documentation/1.2.5/test#fixtures"&gt;fixture&lt;/a&gt; like you would use for testing. It's easy enough to infer what the file's contents should be. We just copy it over from the GTFS data.&lt;/p&gt;
&lt;p&gt;But then where do you put the file? If you look at the log, it says &lt;code&gt;/Users/thomas/.root/opt/play-1.2.5/modules/docviewer/app/initial-agencies-data.yml&lt;/code&gt; but that doesn't look right. That's in the Play distribution directory, probably not somewhere something app-specific should go into. Well, a fixture is used for testing, so maybe the &lt;code&gt;test/&lt;/code&gt; directory? No, that doesn't work either since we're not running a test.&lt;/p&gt;
&lt;p&gt;What I ended up doing was just looking at the sources for &lt;code&gt;Fixtures.load&lt;/code&gt;. If you follow the stack trace, you end up finding &lt;code&gt;Play.javaPath&lt;/code&gt; which sort of works like PATH for Fixtures and some other things. So where can we put the file? &lt;code&gt;app/&lt;/code&gt; and &lt;code&gt;conf/&lt;/code&gt;. And with that, we're done.&lt;/p&gt;
&lt;h3 id="conclusion"&gt;Conclusion

&lt;/h3&gt;&lt;p&gt;GTFS Editor is very much in development. Just getting it to run was problematic. There also seem to be a lot of missing issues judging from the Github Issues page. If you want to try it out for yourself, I suggest you clone &lt;a href="https://github.com/thatsmydoing/gtfs-editor"&gt;my branch&lt;/a&gt; as I've fixed the issues discussed earlier. The default login is &lt;code&gt;admin:admin&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Even after getting it to run, it's still not quite usable. Not in the UX sense, but you really can't do much with it. There is no way to import the GTFS data into the webapp. There is something like import from TransitWand but even that is unclear to me. And even if we do get that running as well, we still don't have any data we can play around with. We would need database dumps from the already running tools for these to be of any use right now.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</description><guid>http://pleasantprogrammer.com/posts/gtfs-editor.html</guid><pubDate>Wed, 10 Jul 2013 03:30:01 GMT</pubDate></item><item><title>Open Trip Planner</title><link>http://pleasantprogrammer.com/posts/open-trip-planner.html</link><description>&lt;html&gt;&lt;body&gt;&lt;p&gt;Link: &lt;a href="http://www.opentripplanner.org"&gt;http://www.opentripplanner.org&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; routes pretty well; data might cause weird issues&lt;/p&gt;
&lt;p&gt;OpenTripPlanner, as the name implies, is a routing app. Given point A and point B, it can provide possible routes by taking transit, riding a bike, or a mix of both. You can also specify options on how much walking you're willing to do or if you prefer fewer transfers over trip time. It could be a good competitor to the transit directions of Google Maps.&lt;/p&gt;
&lt;p&gt;It's actually in general use by the &lt;a href="http://maps.trimet.org/"&gt;Trimet&lt;/a&gt;, Portland's public transit system. I think a good reason why they deployed OpenTripPlanner is that Portland is a very bike friendly area. OpenTripPlanner's support for multi-modal (bike + transit) routing is one thing that even Google Maps doesn't have. This actually just screams &lt;a href="http://philippine-transit.hackathome.com/prizes/"&gt;Inclusive Technology Award&lt;/a&gt;.&lt;/p&gt;
&lt;h4&gt;Setup&lt;/h4&gt;
&lt;p&gt;Getting OpenTripPlanner up and running involves a bit more downloading than OneBusAway. I'd suggest going through the &lt;a href="https://github.com/openplans/OpenTripPlanner/wiki/FiveMinutes"&gt;5-minute introduction&lt;/a&gt; if you want to actually work with the Philippine data. You will also need to download the &lt;a href="http://download.geofabrik.de/asia/philippines.html"&gt;Philippine data dump&lt;/a&gt; from OSM. You will want the &lt;code&gt;osm.bz2&lt;/code&gt; one (WARNING: 900MB unzipped).&lt;/p&gt;
&lt;p&gt;Once you get the webapp running, you'll notice the map tiles won't load correctly. This is because the default tileset used is from Mapbox which doesn't provide publicly free tilesets anymore. To actually see things on the map, you should click the + on the upper-right of the map and change the base layer to something like Open Street Map or OSM Mapquest. This has been fixed in their latest sources.&lt;/p&gt;
&lt;h4&gt;Issues&lt;/h4&gt;
&lt;p&gt;The next thing you'll notice is that you can't search for a place. You can only just pick points on the map and route between those. I'm still not exactly sure if it's supposed to have it, since the Trimet one has it. But even then adding it by using the Google Maps or MapQuest APIs shouldn't be too difficult.&lt;/p&gt;
&lt;p&gt;Another missing thing compared to the Trimet planner is being able to look at the routes akin to OneBusAway. And even then, Trimet's implementation isn't as good for exploring as OneBusAway is. Seeing the schedule or seeing which routes pass through a stop are left to an external site to do.&lt;/p&gt;
&lt;p&gt;There have been some weird issues with the routing though. A common occurence is the steps are somewhat disconnected (see image below). The left half shows OpenTripPlanner, it shows that you get off at a "stop" in EDSA and you should magically teleport to Arguilla street and start walking. To be fair, Google Maps (right half) shows that there is a street from the "stop" to Arguilla.&lt;/p&gt;
&lt;p&gt;&lt;img alt="OpenTripPlanner disconnected route" src="/galleries/transit/otp1.png"&gt;&lt;/p&gt;
&lt;p&gt;I can't say this isn't a bug. After all, OpenTripPlanner couldn't have magically known there really was a street there. If it did, it wouldn't just teleport you to the corner. I'm more inclined to think though that this is a result of not having any shape data. As a result, OpenTripPlanner might try to assume the stop could mean places within a certain radius of where it was defined.&lt;/p&gt;
&lt;p&gt;Another weird issue that pops up sometimes is where it tells you to ride a jeep past the stop you want and then after a while, get off and ride a jeep back to your stop. A more general issue is that sometimes it won't give you the best route because it thinks you have to loop around to get to where you want to be. I don't really know how common this issue pops up though. It's highly dependent on where you put the marker. If you just move the marker down a little bit, it actually does give the correct route.&lt;/p&gt;
&lt;p&gt;&lt;img alt="OpenTripPlanner loopy route" src="/galleries/transit/otp2.png"&gt;&lt;/p&gt;
&lt;p&gt;Much like the earlier problem, I can't tell if this is a bug or it's a result of the bad data. Once again though, I think the issue is more of bad data. If you look at the plotted UP-Katipunan route, the stops aren't even on the road. This probably makes it more difficult for OpenTripPlanner to actually tell if the stop and road are connected.&lt;/p&gt;
&lt;p&gt;&lt;img alt="UP Katipunan Route" src="/galleries/transit/upkatipunan.jpg"&gt;&lt;/p&gt;
&lt;p&gt;From what they said during the launch, most of the route data was collected by getting a person to ride a jeep with a smartphone. That would explain why the coordinates aren't that exact. Even then, it would have been nice if they at least cleaned up the data by moving the stops to the road. They would have had to go over them to name the stops anyway.&lt;/p&gt;
&lt;h4&gt;Conclusion&lt;/h4&gt;
&lt;p&gt;Overall though, I really like OpenTripPlanner. It handles most of the hard parts of the challenge. It provides a REST API for doing routing with the GTFS + OSM data. There's also a lot of potential for additional open source work. A lot can be done to improve the default webapp. Adding a default location searcher would greatly improve usability. Adding in the route viewing features of OneBusAway would also be nice. Alternatively, you could even write your own client that just interfaces with the API.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</description><guid>http://pleasantprogrammer.com/posts/open-trip-planner.html</guid><pubDate>Tue, 09 Jul 2013 15:16:12 GMT</pubDate></item><item><title>One Bus (or maybe Jeep) Away</title><link>http://pleasantprogrammer.com/posts/one-bus-or-maybe-jeep-away.html</link><description>&lt;html&gt;&lt;body&gt;&lt;p&gt;Link: &lt;a href="http://onebusaway.org/"&gt;http://onebusaway.org/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; no routing; useless in Philippines&lt;/p&gt;
&lt;p&gt;OneBusAway is a transit information app. It provides data on what bus stops are near you, which buses pass by. You can also get schedules and the route of a particular bus given the number. It can also provide realtime updates like how many minutes until the next bus arrives. It does not, however, provide routing. There is no support for providing directions to get from point A to point B.&lt;/p&gt;
&lt;p&gt;It's comparable to what you get in some bus stops abroad. You'd get a vicinity map and a list of buses passing through the stop. You might also get the times when the next buses will pass. It's useful for locals who already know how to get around, and want to avoid waiting for the bus. But it's not particularly good for people who want to know how to get around the city.&lt;/p&gt;
&lt;p&gt;OneBusAway is quite comprehensive in its platform support though. There is a webapp, apps for iOS, Android and Windows Phone, as well as SMS and Voice support. This would all be nice but we don't have the necessary infrastructure yet in the Philippines. We don't have bus or jeepney stops. We also wouldn't have realtime data to make the app particularly useful.&lt;/p&gt;
&lt;p&gt;You can try it out for yourself by following their &lt;a href="https://github.com/OneBusAway/onebusaway-application-modules/wiki/OneBusAway-Quickstart-Guide"&gt;Quickstart Guide&lt;/a&gt;. One caveat is you will have to add &lt;code&gt;-P tripEntriesFactory.throwExceptionOnInvalidStopToShapeMappingException=false&lt;/code&gt; when building the bundle. This has to do with the OneBusAway having difficulty matching the &lt;a href="https://github.com/OneBusAway/onebusaway-application-modules/wiki/Stop-to-Shape-Matching"&gt;stops to the shape data&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Here's some screenshots of the app with the Philippine data. Notice how you only see the stops but there isn't a line for the route. This is a problem with our GTFS data. Also, at some points it's hard to tell where the jeep is going to pass since there isn't any indication of order either. This is more of a OneBusAway problem. It usually expects there to be shape data available.&lt;/p&gt;
&lt;p&gt;&lt;a href="/galleries/transit/onebusaway1.png"&gt;&lt;img alt="OneBusAway" src="/galleries/transit/onebusaway1.png" title="All the stops along Katipunan Avenue are named Katipunan Avenue."&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It doesn't really handle too many routes passing through a stop. The list just overflows past the bubble. You can still actually read it by panning the map. It's just a bit weird though.&lt;/p&gt;
&lt;p&gt;If you also noticed, there are usually 2 of each route. This is how the jeepney data was modeled as jeep routes might be different going one way and going back. This isn't the case for all jeeps though, so it might also be an implementation issue with the GTFS editor.&lt;/p&gt;
&lt;p&gt;&lt;a href="/galleries/transit/onebusaway2.png"&gt;&lt;img alt="OneBusAway" src="/galleries/transit/onebusaway2.png"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="/galleries/transit/onebusaway3.png"&gt;&lt;img alt="OneBusAway" src="/galleries/transit/onebusaway3.png"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</description><guid>http://pleasantprogrammer.com/posts/one-bus-or-maybe-jeep-away.html</guid><pubDate>Mon, 08 Jul 2013 17:53:59 GMT</pubDate></item><item><title>Jeepney and Bus Routes</title><link>http://pleasantprogrammer.com/posts/jeepney-and-bus-routes.html</link><description>&lt;html&gt;&lt;body&gt;&lt;p&gt;In the &lt;a href="/posts/philippine-transit-app-challenge.html"&gt;last post&lt;/a&gt;, I talked about how we now have data about jeepney and bus routes in the Philippines. The data is actually in the &lt;a href="https://developers.google.com/transit/gtfs/"&gt;GTFS format&lt;/a&gt;, which is the format the Google Maps consumes transit data. Apparently, the government will be submitting the GTFS data later this year. Transit directions for Metro Manila in Google Maps would be wonderful. That said, it definitely raises the bar for the app challenge people.&lt;/p&gt;
&lt;p&gt;In the last post, I mentioned the quality of the data isn't quite good. Even before seeing the data, I was already a bit unsure of it. The key problem is how you model the routes. The GTFS format was inherently designed for more well developed and organized transit agencies which isn't exactly what we have in the Philippines now.&lt;/p&gt;
&lt;p&gt;One potential problem is the nature of the jeeps and buses. GTFS routes are a collection of trips which are a sequence of stops. However, we don't have jeepney stops, and even if we did they still just stop anywhere. There are also times where jeeps will take a shortcut if no passengers need to get dropped off along their normal route.&lt;/p&gt;
&lt;p&gt;From what I've seen of the data, they handled the first problem well enough. Stops are defined as where people typically get on the jeep or bus. This is good, but they didn't define a shape for the routes. There is no information as to which exact roads they pass through. All we have to go by are the stops to show the route on a map.&lt;/p&gt;
&lt;p&gt;&lt;img alt="sample route" src="http://i.imgur.com/NSVlryE.jpg"&gt;&lt;/p&gt;
&lt;p&gt;The problem isn't that bad though. The agencies could still add the shapes later on. Or maybe an app challenge participant could make an app around fixing the routes via crowd-sourcing or similar. The shape itself isn't that important for a rudimentary directions app, but if we want better apps, we will need better data.&lt;/p&gt;
&lt;p&gt;There were also some minor issues with the data itself. Some of the files had extra columns. This normally isn't an issue, but it caused problems for &lt;a href="https://github.com/harrisony/gtfs_SQL_importer"&gt;GTFS SQL importer&lt;/a&gt;. There were also problems with matching the shape data with the stops when I tried it with &lt;a href="http://onebusaway.org"&gt;OneBusAway&lt;/a&gt;. They could probably be &lt;a href="https://github.com/OneBusAway/onebusaway-application-modules/wiki/Stop-to-Shape-Matching"&gt;fixed&lt;/a&gt; but that's for another day.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</description><guid>http://pleasantprogrammer.com/posts/jeepney-and-bus-routes.html</guid><pubDate>Sun, 07 Jul 2013 02:32:36 GMT</pubDate></item><item><title>Philippine Transit App Challenge</title><link>http://pleasantprogrammer.com/posts/philippine-transit-app-challenge.html</link><description>&lt;html&gt;&lt;body&gt;&lt;p&gt;Last week, the DOTC launched the &lt;a href="http://philippine-transit.hackathome.com"&gt;Philippine Transit App Challenge&lt;/a&gt;. It's a competition to build something great using the newly available 1) jeepney/bus/rail routes and 2) traffic incident data in Metro Manila and Cebu.&lt;/p&gt;
&lt;p&gt;I'm actually quite excited about this as it's not everyday our government does wonderful things. Many people have been waiting for this kind of data to be available. Before, the only way to figure out which jeeps to ride to get from A to B is by asking other people. The website of the LTFRB used to just have a list of jeepney routes, but nothing else, no maps or list of stops.&lt;/p&gt;
&lt;p&gt;During the launch, they also presented how CITOM (the Cebu MMDA) is pilot-testing a &lt;a href="http://cebutraffic.org/"&gt;traffic tracking system&lt;/a&gt;. What they did was supply Android phones to taxi drivers. The phones send GPS data which can then be aggregated to see what the average speeds along streets are. This also benefits the taxi company as it provides easy tracking of their taxis compared to their old telephone/radio with pen-and-paper process.&lt;/p&gt;
&lt;p&gt;The &lt;a href="http://philippine-transit.hackathome.com/dataset-philippines-transit-information-service-gtfs/"&gt;route data&lt;/a&gt; are already available, as well as the &lt;a href="http://philippine-transit.hackathome.com/dataset-citom-traffic-alert-platform/"&gt;Cebu&lt;/a&gt; and &lt;a href="http://philippine-transit.hackathome.com/dataset-mmda-traffic-alert-platform/"&gt;Metro Manila&lt;/a&gt; incident data. You do have to register to access them though. Right now, they're just one-off dumps of the data but the various agencies have promised to provide consistently updated data. This will be provided via ASTI later in the year.&lt;/p&gt;
&lt;p&gt;I've just started looking at the route data and playing around with it. The quality could be better, but I'm glad we at least have something to work with.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</description><guid>http://pleasantprogrammer.com/posts/philippine-transit-app-challenge.html</guid><pubDate>Sat, 06 Jul 2013 16:17:37 GMT</pubDate></item></channel></rss>