highways-in-otp.html 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <!DOCTYPE html>
  2. <html lang="en-us">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="generator" content="Hugo 0.15" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <link rel="stylesheet" href="/assets/css/theme.css">
  8. <link rel="alternate" href="/rss.xml" type="application/rss+xml" title="Pleasant Programmer">
  9. <script type="text/javascript" src="//use.typekit.net/iwm5axp.js"></script>
  10. <script type="text/javascript">try{Typekit.load();}catch(e){}</script>
  11. <title>Highways in OTP - Pleasant Programmer</title>
  12. </head>
  13. <body>
  14. <header id="header" role="banner">
  15. <div id="thomas">
  16. <img src="/assets/img/thomas.gif" alt="DJ THOMAS IN DA HAUS">
  17. <img src="/assets/img/thomas.png" alt="Pleasant Programmer">
  18. </div>
  19. <h1 class="site-title"><a href="/">Pleasant Programmer</a></h1>
  20. <nav id="menu" role="navigation">
  21. <ul>
  22. <li class="twitter">
  23. <a href="http://twitter.com/pleasantprog">@pleasantprog</a>
  24. </li>
  25. <li><a href="/posts.html">archives</a></li>
  26. <li><a href="/tags/index.html">tags</a></li>
  27. <li><a href="/rss.xml">rss</a></li>
  28. </ul>
  29. </nav>
  30. </header>
  31. <div id="container">
  32. <main id="content" role="main">
  33. <article itemscope itemtype="http://schema.org/BlogPosting">
  34. <h1 class="p-name entry-title" itemprop="headline name">
  35. <a href="/posts/highways-in-otp.html">Highways in OTP</a></h1>
  36. <small>
  37. <span class="dateline">Posted: <time itemprop="datePublished" datetime="2013-07-24">2013-07-24</time></span>
  38. | More posts about
  39. <a class="tag p-category" href="/tags/philippine-transit-app.html" rel="tag">
  40. philippine-transit-app
  41. </a>
  42. <a class="tag p-category" href="/tags/programming.html" rel="tag">
  43. programming
  44. </a>
  45. </small>
  46. <div class="e-content entry-content" itemprop="entry-text">
  47. <p>One of the weird things that happens with OTP is sometimes it gives absurdly roundabout routes. Here is OTP&rsquo;s suggested route for walking from UP to Ateneo:</p>
  48. <p><img src="../galleries/transit/otproundabout.png" alt="Roundabout route from UP to Ateneo" /></p>
  49. <p>This is just so hilariously wrong. It&rsquo;s much simpler to just walk along Katipunan Avenue.</p>
  50. <p>OTP couldn&rsquo;t possibly be that dumb though, so there must be something we&rsquo;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 &ldquo;road type&rdquo; designated to Katipunan.</p>
  51. <p>Apparently, by default OTP will consider roads of type <code>trunk</code> to be non-walkable and non-bikable. This is documented in the <a href="http://wiki.openstreetmap.org/wiki/OpenTripPlanner">OpenStreetMap wiki</a> and the <a href="https://github.com/openplans/OpenTripPlanner/wiki/GraphBuilder#permissions-and-bicycle-safety">OTP wiki</a> 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.</p>
  52. <div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%">sed -i .bak s/trunk/primary/g manila.osm
  53. </pre></div>
  54. <p>And rebuild the graph. It doesn&rsquo;t really matter much because the OSM data isn&rsquo;t used to render the maps. It&rsquo;s just used to build the routing data. This is actually what I did for <a href="http://maps.pleasantprogrammer.com">maps.pleasantprogrammer.com</a>.</p>
  55. <p>It&rsquo;s also possible to set the default way properties in OTP. Instead of disallowing walking and biking on <code>highway=trunk</code> we could allow that. This is not much better than the <code>sed</code> solution though. It&rsquo;s better since you keep the weighting done by OTP, but you&rsquo;re still saying that all trunks are walkable which might not be the case.</p>
  56. <p>The most correct way to actually fix this is to go through each of the trunks and specifying <code>foot=yes</code> and <code>bicycle=yes</code> for those trunks that are actually walkable. You could either do this locally with the dumped data, or contribute it directly to OSM. I&rsquo;m not sure on the particulars with updating OSM though.</p>
  57. </div>
  58. <aside class="postpromonav">
  59. <nav>
  60. <ul class="pager clearfix">
  61. <li class="previous">
  62. <a href="/posts/jeep-and-bus-schedules.html" rel="prev" title="Jeep and Bus Schedules">&larr; Previous post</a>
  63. </li>
  64. <li class="next">
  65. <a href="/posts/elevation-data-in-otp.html" rel="next" title="Elevation Data in OTP">Next post &rarr;</a>
  66. </li>
  67. </ul>
  68. </nav>
  69. </aside>
  70. <section class="comments">
  71. <div id="disqus_thread"></div>
  72. <script type="text/javascript">
  73. var disqus_shortname = 'pleasantprog';
  74. var disqus_url = 'http:\/\/pleasantprogrammer.com\/posts\/highways-in-otp.html';
  75. var disqus_title = 'Highways in OTP';
  76. var disqus_identifier = 'cache/posts/highways-in-otp.html';
  77. (function() {
  78. var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
  79. dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
  80. (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
  81. })();
  82. </script>
  83. <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
  84. <a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
  85. </section>
  86. </article>
  87. </main>
  88. <footer id="footer" role="contentinfo">
  89. <p>
  90. <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/deed.en_US">
  91. <img alt="CC-BY-SA" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/80x15.png">
  92. </a> &copy; 2015 Thomas Dy - Powered by <a href="http://gohugo.io">Hugo</a></p>
  93. </footer>
  94. </div>
  95. <script src="/assets/js/konami.js"></script>
  96. <script>
  97. var easter_egg = new Konami();
  98. easter_egg.code = function() {
  99. var el = document.getElementById('thomas');
  100. if(el.className == "whoa") {
  101. el.className = "";
  102. }
  103. else {
  104. el.className = "whoa";
  105. }
  106. document.body.scrollTop = document.documentElement.scrollTop = 0;
  107. }
  108. easter_egg.load();
  109. </script>
  110. </body>
  111. </html>