Skip to content

chiditarod/cartographer

Repository files navigation

Cartographer

Ruby on Rails app that finds viable routes for the CHIditarod, based on customizable criteria like leg length, overall race length, etc.

Build Status Maintainability Test Coverage

Google API Setup

Your Google Cloud Platform account and associated API key must have access to the following APIs:

Runtime Environment

Variable Name Purpose
GOOGLE_API_KEY Google Cloud Platform API key with access to the APIs listed above.
MOCK_MAP When true load a fake route map instead of querying the Google Static API.

Example Usage

Seed

bundle exec rake db:seed
GOOGLE_API_KEY=... bundle exec rails c

Generate all Legs using Google Maps API

BulkLegCreator.perform_now(Location.pluck(:id))

Generate Routes

RouteGenerator.call(Race.first)
winners = Route.complete
puts winners.map(&:to_csv)
puts winners.map(&:to_s)

selected = winners.select{|r| r.name != nil}
selected.map(&:to_csv)

Geocode Locations using Google Maps API

GeocodeLocationJob.perform_now(Location.pluck(:id))

Clean things up

Race.destroy_all; Route.destroy_all; Leg.destroy_all; Location.destroy_all; Leg.destroy_all; nil

Developer Setup

Tested using OSX Mojave 10.14.2.

Prerequisites

Install rbenv & Ruby

brew install rbenv
rbenv install $(cat .ruby-version)
gem install bundler

Install Gems

brew install libffi libpq

bundle config --local build.ffi --with-ldflags="-L/usr/local/opt/libffi/lib"
bundle config --local build.pg --with-opt-dir="/usr/local/opt/libpq"
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/opt/libffi/lib/pkgconfig"

bundle install