Last active
August 29, 2015 14:00
-
-
Save jedahan/11351894 to your computer and use it in GitHub Desktop.
data.gov example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('request'); | |
var T = require("timbre"); | |
var program = require('commander'); | |
program | |
.version('0.0.1') | |
.option('-c, --city [city]', 'Choose your city', 'city') | |
.parse(process.argv); | |
var secret_key = "vNx1rFIEKAjG8YsbizTjNjVZVq4ekE5aQ64leJsr&" | |
var url = 'https://api.data.gov/nrel/alt-fuel-stations/v1/nearest.json?api_key='+secret_key | |
url = url + '&location='+encodeURIComponent(program.city) | |
console.log(url); | |
request.get({url:url, json:true} , function (error, response, nearest_stations) { | |
if (!error && response.statusCode == 200) { | |
var first_station = nearest_stations.fuel_stations[0]; | |
console.log("latitude: "+first_station.latitude); | |
console.log("longitude: "+first_station.longitude); | |
T("sin", {freq:Math.round(20*first_station.latitude), mul:0.5}).play(); | |
T("sin", {freq:Math.round(20*first_station.longitude), mul:0.5}).play(); | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('request'); | |
var secret_key = "vNx1rFIEKAjG8YsbizTjNjVZVq4ekE5aQ64leJsr&" | |
var url = 'https://api.data.gov/nrel/alt-fuel-stations/v1/nearest.json?api_key='+secret_key+'&location=Commack+NY' | |
request.get({url:url, json:true} , function (error, response, nearest_stations) { | |
if (!error && response.statusCode == 200) { | |
var first_station = nearest_stations.fuel_stations[0]; | |
console.log("latitude: "+first_station.latitude); | |
console.log("longitude: "+first_station.longitude); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment