Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.
/ gettheresafe Public archive

Find the route with the most city lights. 🔦

License

Notifications You must be signed in to change notification settings

FlyteWizard/gettheresafe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GetThereSafe

GetThereSafe is an application that uses the Google Maps Platform and the City of Victoria Open Data to map out the route with the most city lights.

The original application was created during nwHacks 2016. GetThereSafe won 1st prize for "Best Use of Data Analytics to Solve a Social Problem" during nwHacks 2016.

Live Demo

There is no live demo because Google Maps Platform no longer has a free tier, and pricing is too expensive for a developer making no income on an application.

Demo

Landing Page

Address 1

Address 2

Routes

Contributors

Getting Started

By following the instructions below, you should be able to get a local copy working and be able to deploy your own instance of the GetThereSafe application with Heroku.

Requirements

Local Development

  1. Clone the repository on your local machine in your working directory and change into the gettheresafe directory.
cd working-directory

git clone [email protected]:FlyteWizard/gettheresafe.git

cd gettheresafe
  1. Install all the dependencies in requirements.txt.
pip install -r requirements.txt

# or

pip3 install -r requirements.txt
  1. Create a .env file based on .env.example.
GOOGLE_API_KEY=
DATABASE_URL=
  1. Create a Google Maps Platform Project. You will need to activate Geocoding API, Directions API, and Maps JavaScript API.

  2. Generate a frontend API Key with Google Maps Platform. This key will be what we use on the frontend and will need to be restricted.

  3. Generate a backend API Key with Google Maps Platform. This key will be what we use on the backend, and should be kept secret.

  4. Add your backend API Key to your .env file. Replace YOUR_SUPER_SECRET_API_KEY with your backend API Key.

GOOGLE_API_KEY=YOUR_SUPER_SECRET_API_KEY
DATABASE_URL=
  1. Add your frontend API Key to the index.html file. Replace YOUR_NOT_SO_SECRET_API_KEY with your frontend API Key.
  <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_NOT_SO_SECRET_API_KEY&callback=initMap" async defer></script> <!-- Google Map -->
  1. Install Postgres App and Postgres CLI Tools.

  2. Open and Initialize the Postgres App.

  3. Start the Postgres App. You will need to Postgres App running when developing locally.

  4. Create a local database with the Postgres App CLI. You can name the database anything you want, but we will name it gettheresafe.

createdb gettheresafe
  1. If you have new data points to add to citylights.csv you can add them and then run formatcsv.py to format the new data points.
python formatcsv.py

# or

python3 formatcsv.py
  1. Populate local database with contents from citylightsdb.csv.
psql gettheresafe

CREATE TABLE coords (ID integer, LNG float, LAT float);

\copy coords FROM './citylightsdb.csv' WITH (FORMAT csv);

TABLE coords;
  1. Add your database URL to your .env file.
GOOGLE_API_KEY=YOUR_SUPER_SECRET_API_KEY
DATABASE_URL=postgresql:https://localhost/gettheresafe
  1. Run the app locally.
flask run

# or 

python app.py

# or 

python3 app.py
  1. Head over to https://127.0.0.1:5000/ to view your application.

Deploying

  1. Add access restrictions to your frontend API Key. This is important to prevent your API Key from being misused.

  2. Create a new app on Heroku. Within your gettheresafe directory, run the following commands.

heroku create gettheresafe-username
  1. Add Heroku Postgres Add-on.
heroku addons:create heroku-postgresql:hobby-dev --app gettheresafe-username
  1. Add your local database to the Heroku Postgres database.

Run heroku pg:info --app gettheresafe-username to find your database name. Replace [HEROKU_POSTGRESQL_MAGENTA] with your Heroku Postgres database name.

heroku pg:push gettheresafe HEROKU_POSTGRESQL_MAGENTA --app gettheresafe-username
  1. Add your Heroku Postgres database URL to your Heroku config vars.
heroku pg:promote HEROKU_POSTGRESQL_MAGENTA --app gettheresafe-username
  1. Set your backend API Key in your Heroku config vars.
heroku config:set GOOGLE_API_KEY=YOUR_SUPER_SECRET_API_KEY --app gettheresafe-username
  1. Push app to Heroku.
git push heroku master
  1. Your app should be live at https://gettheresafe-username.herokuapp.com.

Tools

Resources