Created
March 13, 2013 05:05
-
-
Save robert-chiniquy/5149524 to your computer and use it in GitHub Desktop.
quick geocode script
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 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