Another reason you may want to re-generate coordinates is so you can use the bike share system in your city with the helmet! It isn't limited to the NYC Citi Bike system.
The below code will parse the wonderful citybik.es api:
//Change the URL to whichever city you'd like to parse. You can then execute this file with node.js from the command line: //node parser.js //The results will be a multi-dimensional array that you can just plug into the bike helmet code for the city you live in! //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. var request = require('request'); var BIKE_SHARE_URL = 'http://api.citybik.es/citibikenyc.json'; request(BIKE_SHARE_URL, function (error, response, body) { if (!error && response.statusCode == 200) { var comma = ","; var locations = JSON.parse(body); locations.forEach(function(l, i) { if (i === locations.length-1) comma = ""; console.log(" {" + (l.lat / 1000000).toFixed(6) + ", " + (l.lng / 1000000).toFixed(6) + "}" + comma); }); console.log(locations.length); } });
To start with, you'll need node.js. It's a really easy install. Navigate to http://nodejs.org, and follow the installation instructions for your operating system (Windows, Linux, and OS X are supported).
Next, create a folder somewhere (mine is titled 'cityparser'). Then, create a file in that folder titled parser.js and copy and paste the above snippet of code into that file, and save it.
Now, open your favorite command line utility (Terminal.app, cmd.exe, etc) and navigate into the 'cityparser' folder.
Now, we need to install the one dependency that is required for the parser to run. Execute the following from within the cityparser folder:
npm install request
Execute the following command to run the parser:
node parser.js
For example, these are the last few of my output:
{40.715348, -73.960241}, {40.741472, -73.983209}, {40.736502, -73.978094}, {40.744449, -73.983035}, {40.702550, -73.989402}, {40.698920, -73.973329}, {40.716887, -73.963198}, {40.734160, -73.980242}, {40.725500, -74.004451}, {40.705311, -73.971000}, {40.765909, -73.976341} 311
Open the citybik.es api page, and scroll down to the section titled "System" and "JSON". Choose your location from the dropdown, and then replace it in the parser.js file variable "BIKE_SHARE_URL" and re-run the program.
Ok, now to set up your sketch. The last number in the results is the count of locations in that bike share. Take that number and place it in the sketch for the size of the array:
#define LAT_LON_SIZE 311
float lat_lon[LAT_LON_SIZE][2] PROGMEM = { {40.767272, -73.993928}, {40.719115, -74.006666}, {40.711174, -74.000165}, {40.683826, -73.976323}, {40.702550, -73.989402}, {40.698920, -73.973329}, {40.716887, -73.963198}, {40.734160, -73.980242}, {40.725500, -74.004451}, {40.705311, -73.971000}, {40.765909, -73.976341} };