parser.js
1 //Change the URL to whichever city you'd like to parse. You can then execute this file with node.js from the command line: 2 //node parser.js 3 4 //The results will be a multi-dimensional array that you can just plug into the bike helmet code for the city you live in! 5 //Make sure to also update the #define with the size of the array. This is the last number that is output after running this parser. 6 7 var request = require('request'); 8 var BIKE_SHARE_URL = 'http://api.citybik.es/citibikenyc.json'; 9 request(BIKE_SHARE_URL, function (error, response, body) { 10 if (!error && response.statusCode == 200) { 11 var comma = ","; 12 var locations = JSON.parse(body); 13 locations.forEach(function(l, i) { 14 if (i === locations.length-1) 15 comma = ""; 16 17 console.log(" {" + (l.lat / 1000000).toFixed(6) + ", " + (l.lng / 1000000).toFixed(6) + "}" + comma); 18 }); 19 20 console.log(locations.length); 21 } 22 });