Skip to content

Commit

Permalink
adding a couple more environment variables for demonstrating those in…
Browse files Browse the repository at this point in the history
… the workshop
  • Loading branch information
dudash committed Apr 20, 2016
1 parent c5aca5d commit a4321eb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 2 additions & 0 deletions dc-metro-map/README-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ WARNING: WMAAT changes their public key from time to time, make sure what you ar

You can see the results of a full query in the file exampledata.json

### Environment Variables
You can have some fun by setting a couple different environment variables. Try BEERME=true and/or RAINBOW=true.

Thanks for reading!
- Dudash
Expand Down
16 changes: 13 additions & 3 deletions dc-metro-map/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ var rest = require('restler');
// CONSTANTS AND HELPERS
//-----------------------------------------------------------------------------
var API_KEY_PLACEHOLDER = process.env.WMATA_API_KEY || '6b700f7ea9db408e9745c207da7ca827';
var BEERME = process.env.BEERME || false;
var RAINBOW = process.env.RAINBOW || false;
console.log("using WMATA API Key - " + API_KEY_PLACEHOLDER);
if (BEERME == 'true') { console.log("Beer Me! "); }
if (RAINBOW == 'true') { console.log("Rainbows! "); }

// var DCBEER = {
// type: "FeatureCollection",
// features: [{
Expand All @@ -28,7 +33,12 @@ console.log("using WMATA API Key - " + API_KEY_PLACEHOLDER);
//-----------------------------------------------------------------------------
function wmataJsonToGeoJson(jsonData) {
var dataOut = { type: "FeatureCollection", features: [] };
var markerSym = "bus";
var markerColor = "#000000";
if (BEERME == 'true') { markerSym = "beer"; }

jsonData.BusPositions.forEach(function(item, index) {
if (RAINBOW == 'true') { markerColor = '#'+(Math.random()*0xFFFFFF<<0).toString(16); }
dataOut.features.push({type:"Feature",
geometry: {
type: "Point",
Expand All @@ -38,8 +48,8 @@ function wmataJsonToGeoJson(jsonData) {
title: "Bus #" + item['VehicleID'],
description: item['TripHeadsign'],
'marker-size': "small",
"marker-color": "#000000",
"marker-symbol": "bus",
"marker-color": markerColor,
"marker-symbol": markerSym,
}
});
});
Expand All @@ -49,7 +59,7 @@ function wmataJsonToGeoJson(jsonData) {
//-----------------------------------------------------------------------------
/* GET home page. */
router.get('/', function(req, res, next) {
res.render('dcmetro', { title: 'DC Metro Stations' });
res.render('dcmetro', { title: 'DC Metro Stations', BEERME: BEERME });
});

//-----------------------------------------------------------------------------
Expand Down

0 comments on commit a4321eb

Please sign in to comment.