Skip to content

Instantly share code, notes, and snippets.

@jedahan
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jedahan/11351894 to your computer and use it in GitHub Desktop.
Save jedahan/11351894 to your computer and use it in GitHub Desktop.
data.gov example
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();
}
})
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