Archive

Archive for June, 2008

Mobile Friendly Metro Bus Trip Planner

June 23rd, 2008

Lately I have been working on developing a metro bus trip planner website which is mobile friendly for Indian Cities. Main goal of this website was to make it mobile friendly.

But soon realized that its pretty challenging especially because of lack of structured data like timetables, schedules, route information available readily as a service. I thought of scrapping the corresponding sites but was still lacking the useful data. However I stuck to my plan and wanted to make use of whatever data I could get. I am just finished with extracting data for Mumbai from here. The information I was able to extract was bus route numbers, station names, route information, fare information for a particular bus between any two stations and distance. There is no accurate way to get bus departure and arrival times from this information. And the data which can be scrapped is limited only to landmarks and does not have all the bus stops. So for now I just wanted to support time independent paths and change overs. I know that this might not be of much use but wanted to prove it instead of guessing it. Lets see whats the outcome is.

So from this project I wanted to see if I can extract some kind of framework for trip planning websites (public transport). I see a major need for this as many people are starting to opt for public transport.

In this process I refreshed some of the graph algorithms (Dijkstra’s, Floyd-Warshall, Strongly Connected, A*, etc). I also stumbled upon some of the research papers on Public Transportation and some existing solutions. So far no road blocks other than lack of data.

For now I am running O(n^3) Floyd-Warshall algorithm to determine All Pairs Shortest Paths. But I am sure I can make lot of optimizations because of the kind of structure. Will dig into this soon and post my findings.

Update: I finished generating all the shortest and cheapest routes between any two landmarks. This process need not be done in real-time based on user input as the routes are same every day and change less often. Now I am collecting data about local trains and need to run the above algorithm again to combine train routes with bus routes. Any suggestions on this are welcome.

rails ,

Migrating to Rails2.1

June 3rd, 2008

Hurrah! Rails-2.1 is out and is too tempting. Its time to jump start the migration. Though my team uses SVN, I use git and connect to svn using git-svn. This provides me an opportunity to try out rails-2.1 on our website fundu.mobi without disrupting the flow. Git makes it so easy to create my own branch on my system and test the latest stuff without fear. And anybody out there who wants to live on edge, must use GIT. This and a few posts after this will focus on my journey to Rails-2.1. To recap new features in Rails-2.1 are mentioned in great detail here. So now lets jump into the process.
Before I begin here are my system details

  • OS: Ubuntu (Hardy)
  • Ruby: 1.8.6
  • Git installed

Freeze Rails-2.0.2

I am still in my master branch. I unpacked Rails-2.0.2 into vendor/rails directory. I should have done it earlier, but better later than never. Luckily we are using VPS (slicehost) so we had control on which version of rails we wanted to run. However to try experimenting with Rails-2.1, I decided it would be better if I remove any dependency on system rails gem. Tested this change out and committed changes to master. To get 2.0.2 from git use the following steps
git clone git://github.com/rails/rails.git vendor/rails
cd vendor/rails
git checkout v2.0.2

Create Branch

Now I created a branch with name rails2.1
git checkout -b rails2.1

Freeze Rails-2.1

Checkout Rails-2.1 tagged version from github
cd vendor/rails
git checkout v2.1.0

Changes to Config

Before doing anything I had to run the following command to update the configuration files to work with 2.1
rake rails:update
I also had to remove the following line from environment/development.rb
config.action_view.cache_template_extensions = false
Now I verified the setup by running ./script/console and checked that there are no errors or warnings in the logs.
Umm lets try to run the server, and there comes my first hurdle! when I try to visit the home page of the app I get

Could not find RubyGem activerecord (>= 1.10.1)
 
/usr/local/lib/site_ruby/1.8/rubygems.rb:523:in `report_activate_error'
/usr/local/lib/site_ruby/1.8/rubygems.rb:131:in `activate'
/usr/local/lib/site_ruby/1.8/rubygems.rb:155:in `activate'
/usr/local/lib/site_ruby/1.8/rubygems.rb:154:in `each'
/usr/local/lib/site_ruby/1.8/rubygems.rb:154:in `activate'
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in `require'
vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in `new_constants_in'
vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in `require'
app/controllers/welcome_controller.rb:1
/usr/bin/thin:19:in `load'
/usr/bin/thin:19
 
This error occurred while loading the following files:
feed_tools

Seems like the above error was because of some strange dependency of AR in feed_tools. I unpacked feed_tools to vendor directory and somehow the error was no more. More investigation on this later, lets move on.

That’s about it, website is running as before.

rails