(coordinate, encodeOffsets, encodeScale)
| 68 | } |
| 69 | |
| 70 | function decodeRing(coordinate, encodeOffsets, encodeScale) { |
| 71 | var result = []; |
| 72 | var prevX = encodeOffsets[0]; |
| 73 | var prevY = encodeOffsets[1]; |
| 74 | |
| 75 | for (var i = 0; i < coordinate.length; i += 2) { |
| 76 | var x = coordinate.charCodeAt(i) - 64; |
| 77 | var y = coordinate.charCodeAt(i + 1) - 64; |
| 78 | // ZigZag decoding |
| 79 | x = (x >> 1) ^ (-(x & 1)); |
| 80 | y = (y >> 1) ^ (-(y & 1)); |
| 81 | // Delta decoding |
| 82 | x += prevX; |
| 83 | y += prevY; |
| 84 | |
| 85 | prevX = x; |
| 86 | prevY = y; |
| 87 | // Dequantize |
| 88 | result.push([x / encodeScale, y / encodeScale]); |
| 89 | } |
| 90 | |
| 91 | return result; |
| 92 | } |
| 93 | |
| 94 | // Export for testing. |
| 95 | if (typeof module !== 'undefined') { |
no outgoing calls
no test coverage detected
searching dependent graphs…