index-3.html 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <!DOCTYPE html>
  2. <html prefix="og: http://ogp.me/ns# article: http://ogp.me/ns/article# " vocab="http://ogp.me/ns" lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width">
  6. <title>Pleasant Programmer (old posts, page 3) | Pleasant Programmer</title>
  7. <link href="assets/css/rst.css" rel="stylesheet" type="text/css">
  8. <link href="assets/css/code.css" rel="stylesheet" type="text/css">
  9. <link href="assets/css/theme.css" rel="stylesheet" type="text/css">
  10. <link href="assets/css/custom.css" rel="stylesheet" type="text/css">
  11. <link rel="alternate" type="application/rss+xml" title="RSS" href="rss.xml">
  12. <link rel="canonical" href="http://pleasantprogrammer.com/index-3.html">
  13. <link rel="prev" href="index.html" type="text/html">
  14. <link rel="next" href="index-2.html" type="text/html">
  15. <script type="text/javascript" src="//use.typekit.net/iwm5axp.js"></script><script type="text/javascript">try{Typekit.load();}catch(e){}</script><!--[if lt IE 9]><script src="assets/js/html5.js"></script><![endif]-->
  16. </head>
  17. <body>
  18. <a href="#content" class="sr-only sr-only-focusable">Skip to main content</a>
  19. <header id="header" role="banner"><div class="thomas">
  20. <img src="assets/img/thomas.gif" alt="DJ THOMAS IN DA HAUS"><img src="assets/img/thomas.png" alt="Pleasant Programmer">
  21. </div>
  22. <h1 id="brand"><a href="http://pleasantprogrammer.com/" title="Pleasant Programmer" rel="home">
  23. <span id="blog-title">Pleasant Programmer</span>
  24. </a></h1>
  25. <nav id="menu" role="navigation"><ul>
  26. <li class="twitter"><a href="http://twitter.com/pleasantprog">@pleasantprog</a></li>
  27. <li><a href="archive.html">Archives</a></li>
  28. <li><a href="categories/index.html">Tags</a></li>
  29. <li><a href="rss.xml">RSS</a></li>
  30. </ul></nav></header><div id="container">
  31. <main id="content" role="main"><div class="postindex">
  32. <article class="h-entry post-text"><header><h1 class="p-name entry-title">
  33. <a href="posts/geocoding-services.html" class="u-url">Geocoding Services</a>
  34. </h1>
  35. </header><div class="e-content entry-content">
  36. <div>
  37. <p>A key component for any routing service is being able to do geocoding. Most people who are looking for routes most probably don't know exactly where their start and end points are on the map. Even then, manually looking for a location on a map is a time-consuming task.</p>
  38. <p>The gold standard for doing geocoding right now is Google Maps. It's hard to find a better location search experience. If they actually provided routing for jeeps here in the Philippines, I imagine there wouldn't be <em>that</em> much you could do for the competition.</p>
  39. <p>When the competition started though, I took it as a challenge to avoid Google Maps as much as possible. I wanted to see how much is currently possible with other options such as OpenStreetMap. In fact, OSM does have a geocoding service called <a href="http://nominatim.openstreetmap.org">Nominatim</a>.</p>
  40. <p>Sadly, for a mapping app, what you want to do is not simply just geocoding. With geocoding, you take an address and turn it into coordinates. When you want to search for a place in a mapping app, you take part of an address, infer the rest of it, and give the user options to choose from.</p>
  41. <p>Given a typical mapping app, you might type in "ateneo" and expect it to give you Ateneo de Manila University. With typical geocoding services like Nominatim or even Google's <a href="https://developers.google.com/maps/documentation/javascript/geocoding">geocoding API</a>, you probably won't get any result for this. What you want to use is the <a href="https://developers.google.com/maps/documentation/javascript/places">Places API</a> which provides an autocomplete search box. Using it, when you type in "ateneo", it automatically suggests in the dropdown, "Ateneo de Manila University".</p>
  42. <p>A downside to using the Places API is that it's against the terms of service to use it with something that isn't Google Maps, which means no OpenStreetMap. If there were more time, writing your own autocompletion engine using OpenStreetMap's data will probably be a better long term solution.</p>
  43. <p>For now, since the competition's deadline is just a few days away, I'll be using Google Maps.</p>
  44. </div>
  45. </div>
  46. <small class="dateline">Posted: <time class="published dt-published" datetime="2013-09-25T12:26:59+08:00" title="2013-09-25 12:26">2013-09-25 12:26</time></small>
  47. | <small class="commentline">
  48. <a href="posts/geocoding-services.html#disqus_thread" data-disqus-identifier="cache/posts/geocoding-services.html">Comments</a>
  49. </small>
  50. </article><article class="h-entry post-text"><header><h1 class="p-name entry-title">
  51. <a href="posts/jeep-and-bus-schedules.html" class="u-url">Jeep and Bus Schedules</a>
  52. </h1>
  53. </header><div class="e-content entry-content">
  54. <div>
  55. <p>Wouldn't it be wonderful if there were no buses or jeepneys in the Philippines over the weekends? It would truly be a cyclist's paradise. Imagine biking along EDSA, normally that would be a death sentence, but according to the GTFS data, you shouldn't worry. I can assure you, it's still a death sentence.</p>
  56. <p>The GTFS spec defines 2 ways of statically specifying trip schedules. You can define the exact times that a service will arrive at a stop. You can also specify between what times the service is active and how often a new bus or jeep leaves the first stop. You also define which days those rules apply. You could say every MWF, the bus operates from 9:00AM to 9:00PM and every TTH, the bus services from 3:00AM to 11:00PM.</p>
  57. <p>This should be sufficient in theory, but real world conditions like traffic or the weather could throw the schedules off. To solve this, there's another spec, GTFS-realtime. This allows transit agencies to push temporary schedule updates and service announcements.</p>
  58. <p>Like much everything else about the Philippine transit system, there aren't really any "schedules" to speak of. It's generally whenever the buses or jeeps feel like it. So we have no static schedules. We don't have a central agency or the tracking technology to make it feasible to push updates via GTFS-RT.</p>
  59. <p>Ideally, we shouldn't bother inputting the schedule information into GTFS. Only the route data is really important for jeeps and buses. However, the schedule information is required in the GTFS, and routing apps wouldn't work without it. So we have to add a reasonable trip schedule for jeeps and buses.</p>
  60. <p>The current GTFS data does define these trip schedules. We assume that jeeps and buses operate between 6:00AM and 11:00PM and a new jeep passes by every 10 minutes. Also, jeeps and buses are defined to only operate on weekdays.</p>
  61. <p>While there might be jeeps who change routes or don't operate on weekends, I'm pretty sure that jeeps and buses run on weekends. We'll have to fix it ourselves temporarily since there's no central GTFS feed yet.</p>
  62. <pre class="code literal-block"><span class="c"># 724594 seems to be the service id used by jeeps and buses</span>
  63. sed -i .bak <span class="s1">'/^724594/ s/0,0/1,1/'</span> calendar.txt
  64. </pre>
  65. <p>Another thing we could do is to adjust the time between buses, although the improvement is arguable. With the current 10 minutes between jeeps, it might provide some routes a significant advantage just because the timing is right. So you might get differing route suggestions depending on what time you planned the route. This makes sense when you're sure what the times are, so you can minimize the wait, but with jeeps, you never really know how long the wait will actually be.</p>
  66. <p>If we set the frequency to one minute, it <em>might</em> give better routes by eliminating the timing issue. Or not, it's kind of hard to tell.</p>
  67. <pre class="code literal-block"><span class="c"># jeep and bus route ids tend to start with 72</span>
  68. sed -i .bak <span class="s1">'/^72/ s/,600/,60/'</span> frequencies.txt
  69. </pre>
  70. <p>Overall, the problems we're having is a symptom of the mismatch between our transit system and the GTFS. It would be great if our transit system gets better and we don't need to do hackish things for it to fit the GTFS, but that's still a dream. For now, all we can really do is fit a triangle into a square hole.</p>
  71. </div>
  72. </div>
  73. <small class="dateline">Posted: <time class="published dt-published" datetime="2013-07-28T16:26:31+08:00" title="2013-07-28 16:26">2013-07-28 16:26</time></small>
  74. | <small class="commentline">
  75. <a href="posts/jeep-and-bus-schedules.html#disqus_thread" data-disqus-identifier="cache/posts/jeep-and-bus-schedules.html">Comments</a>
  76. </small>
  77. </article>
  78. </div>
  79. <nav class="postindexpager"><ul class="pager clearfix">
  80. <li class="previous">
  81. <a href="index.html" rel="prev">← Newer posts</a>
  82. </li>
  83. <li class="next">
  84. <a href="index-2.html" rel="next">Older posts →</a>
  85. </li>
  86. </ul></nav><script>var disqus_shortname="pleasantprog";(function(){var a=document.createElement("script");a.async=true;a.src="//"+disqus_shortname+".disqus.com/count.js";(document.getElementsByTagName("head")[0]||document.getElementsByTagName("body")[0]).appendChild(a)}());</script></main><footer id="footer" role="contentinfo"><p><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/deed.en_US"><img alt="CC-BY-SA" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/80x15.png"></a> © 2015 Thomas Dy - Powered by <a href="http://getnikola.com">Nikola</a></p>
  87. </footer>
  88. </div>
  89. <script src="assets/js/konami.js"></script><script src="http://code.jquery.com/jquery-2.0.3.min.js"></script><script>
  90. var easter_egg = new Konami();
  91. easter_egg.code = function() {
  92. $(".thomas").toggleClass("whoa");
  93. $("body").scrollTop(0);
  94. }
  95. easter_egg.load();
  96. // love you, thomas!
  97. // yours, @_phi + @meggykawsek
  98. </script>
  99. </body>
  100. </html>