Created
October 1, 2014 23:30
-
-
Save aaronlidman/ab0e26f163c0bd06f4e4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 osmium = require('osmium'); | |
var users = {}; | |
var reader = new osmium.Reader(process.argv[2], { | |
'node': true, | |
'way': true, | |
'relation': true | |
}); | |
var handler = new osmium.Handler(); | |
handler.on('node', function(node) { | |
users[node.user] = (users[node.user] || 0) + 1; | |
}); | |
handler.on('way', function(way) { | |
users[way.user] = (users[way.user] || 0) + 1; | |
}); | |
handler.on('relation', function(relation) { | |
users[relation.user] = (users[relation.user] || 0) + 1; | |
}); | |
handler.on('done', function() { | |
var sort = []; | |
for (var user in users) { | |
sort.push([user, users[user]]); | |
} | |
sort.sort(function(a,b) { return b[1] - a[1]; }); | |
console.log(sort); | |
}); | |
osmium.apply(reader, handler); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment