Created
March 29, 2015 11:20
-
-
Save TheSkorm/26afa62fc7d562908869 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 fs = require('fs'); | |
| var obj = JSON.parse(fs.readFileSync('inventory', 'utf8')); | |
| multiple = {} | |
| for (i = 0; i < obj['gameBasket']['inventory'].length; i++) { | |
| if ("portalCoupler" in obj['gameBasket']['inventory'][i][2]) { | |
| var title = obj['gameBasket']['inventory'][i][2]['portalCoupler']['portalTitle'].replace("\"", "") | |
| var locsplit = obj['gameBasket']['inventory'][i][2]['portalCoupler']['portalLocation'].split(','); | |
| var latE6 = parseInt(locsplit[0], 16); | |
| var lngE6 = parseInt(locsplit[1], 16); | |
| if (latE6 >= 2147483648) latE6 -= 4294967296; | |
| if (lngE6 >= 2147483648) lngE6 -= 4294967296; | |
| var latlng = { | |
| 'lat': latE6 / 1E6, | |
| 'lng': lngE6 / 1E6 | |
| } | |
| var key = title + "-" + obj['gameBasket']['inventory'][i][2]['portalCoupler']['portalLocation'] | |
| if (key in multiple) { | |
| multiple[key]["count"] = multiple[key]["count"] + 1 | |
| } else { | |
| multiple[key] = { | |
| name: title, | |
| lat: latlng['lat'], | |
| lng: latlng['lng'], | |
| count: 1 | |
| } | |
| } | |
| } | |
| } | |
| for (var key in multiple) { | |
| if (multiple.hasOwnProperty(key)) { | |
| console.log("\"" + multiple[key]["name"] + "\"," + multiple[key]["count"] + "," + multiple[key]["lat"]+ "," + multiple[key]["lng"]) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment