Skip to content

Instantly share code, notes, and snippets.

@robert-chiniquy
Created March 13, 2013 05:05
Show Gist options
  • Save robert-chiniquy/5149524 to your computer and use it in GitHub Desktop.
Save robert-chiniquy/5149524 to your computer and use it in GitHub Desktop.
quick geocode script
var geocoder = require('geocoder');
var async = require('async');
var eodata = require('./data.json');
process.stdout.write('[\n');
async.mapLimit(eodata, 1, function(item, callback) {
setTimeout(function() {
geocoder.geocode(item.StreetAddress, function(err, result) {
if (!result.results[0]) {
callback(result.status);
return;
}
// result.results[0].geometry.location = {lat:, lng:}
item.location = result.results[0].geometry.location;
process.stdout.write(JSON.stringify(item, undefined, 2));
process.stdout.write(',\n');
callback();
});
}, 20000);
}, function(err, results) {
if (err) {
process.stderr.write(err);
return;
}
process.stdout.write('\n]');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment