Project

orochi

0.0
No commit activity in last 3 years
No release in over 3 years
A ruby gem that helps ActiveRecord-ize directions and route data
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.0.0
~> 1.5.2
>= 0
~> 2.3.0

Runtime

 Project Readme

orochi

A ruby gem that helps ActiveRecord-ize directions and route data.

Note: this gem has only been tested in Rails 3

setup

sudo gem install orochi
rake orochi:awaken

quick start

Orochi needs to know which models you intend to make routeable. So any model that has a start and stop destination can be represented as:

class YourModel < ActiveRecord::Base
  acts_as_routeable
end

Orochi still isn’t quite smart enough to make the association on its own, so for the time being you will have to generate a migration:

rails generate migration add_router_id_to_your_model

add in the necessary columns:

class AddRouterIdToYourModel < ActiveRecord::Migration
  self.up
    add_column :your_models, :router_id, :integer, :references => :routers
  end
  self.down
    remove_column :your_models, :router_id
  end
end

then run the migration:

db:migrate

Now you’re set up and ready to go!

usage

your_model_instance.set_endpoints!("start_address", "stop_address")
your_model_instance.route!

Now you can do some of the following:

your_model_instance.polyline # Polyline representation for Google Maps
your_model_instance.directions # List of directions
your_model_instance.reverse # A creates a router with the reversed address + routes
your_model_instance.includes?(point_of_interest) # Returns if point of interest is within your route