Last active
April 18, 2020 02:06
-
-
Save ProfFan/4fa75ec40e94100fb00da022dcbca336 to your computer and use it in GitHub Desktop.
decode georgia power outage map
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
function decodePos(t) { | |
var e = []; | |
try { | |
for (var n = t.length, r = 0, o = null, i = 0, u = 0; r < n;) { | |
var a = void 0, | |
c = 0, | |
s = 0; | |
do { | |
a = t.charCodeAt(r) - 63, r += 1, s |= (31 & a) << c, c += 5 | |
} while (a >= 32); | |
i += 1 & s ? ~(s >> 1) : s >> 1, c = 0, s = 0; | |
do { | |
a = t.charCodeAt(r) - 63, r += 1, s |= (31 & a) << c, c += 5 | |
} while (a >= 32); | |
o = [i / 1e5, (u += 1 & s ? ~(s >> 1) : s >> 1) / 1e5], e.push(o) | |
} | |
} catch (t) {} | |
return e | |
} |
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
function e() { | |
var e = {}; | |
e.getTiles = function (t, n) { for (var r = e.project(t.north, t.west, n), o = e.project(t.south, t.east, n), i = [], a = r.y; a <= o.y; a += 1)for (var s = r.x; s <= o.x; s += 1)i.push({ x: s, y: a, q: e.calculateQuadKey(s, a, n) }); return i } | |
e.calculateQuadKey = function (e, t, n) { for (var r = [], o = n; o > 0; o--) { var i = "0", a = 1 << o - 1; 0 != (e & a) && i++, 0 != (t & a) && (i++, i++), r.push(i) } return r.join("") } | |
e.project = function (e, t, n) { var r = Math.sin(e * (Math.PI / 180)), o = 1 << n; return r = Math.min(Math.max(r, -.9999), .9999), { x: Math.floor((.5 + t / 360) * o), y: Math.floor((.5 - Math.log((1 + r) / (1 - r)) / (4 * Math.PI)) * o) } } | |
return e; | |
} | |
/* Example: | |
e().getTiles({"south":33.52839809871717,"west":-84.78265357809967,"north":34.06818488 | |
659131,"east":-83.99163795309967}, 10) | |
[ | |
{ x: 270, y: 408, q: '0320023110' }, | |
{ x: 271, y: 408, q: '0320023111' }, | |
{ x: 272, y: 408, q: '0320032000' }, | |
{ x: 273, y: 408, q: '0320032001' }, | |
{ x: 270, y: 409, q: '0320023112' }, | |
{ x: 271, y: 409, q: '0320023113' }, | |
{ x: 272, y: 409, q: '0320032002' }, | |
{ x: 273, y: 409, q: '0320032003' }, | |
{ x: 270, y: 410, q: '0320023130' }, | |
{ x: 271, y: 410, q: '0320023131' }, | |
{ x: 272, y: 410, q: '0320032020' }, | |
{ x: 273, y: 410, q: '0320032021' } | |
] | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment