diff --git a/src/ol/format/polylineformat.js b/src/ol/format/polylineformat.js index 34720b105f..cceee15d53 100644 --- a/src/ol/format/polylineformat.js +++ b/src/ol/format/polylineformat.js @@ -256,28 +256,6 @@ ol.format.Polyline.encodeUnsignedInteger = function(num) { }; -/** - * Decode one single unsigned integer from an encoded string - * - * @param {string} encoded An encoded string. - * @return {number} The decoded unsigned integer. - */ -ol.format.Polyline.decodeUnsignedInteger = function(encoded) { - var result = 0; - var shift = 0; - var i, ii; - for (i = 0, ii = encoded.length; i < ii; ++i) { - var b = encoded.charCodeAt(i) - 63; - result |= (b & 0x1f) << shift; - if (b < 0x20) { - break; - } - shift += 5; - } - return result; -}; - - /** * @inheritDoc */ diff --git a/test/spec/ol/format/polylineformat.test.js b/test/spec/ol/format/polylineformat.test.js index 6394adf04f..8190eae7e0 100644 --- a/test/spec/ol/format/polylineformat.test.js +++ b/test/spec/ol/format/polylineformat.test.js @@ -246,21 +246,21 @@ describe('ol.format.Polyline', function() { describe('decodeUnsignedInteger', function() { it('returns expected value', function() { - var decodeUnsignedInteger = ol.format.Polyline.decodeUnsignedInteger; + var decodeUnsignedIntegers = ol.format.Polyline.decodeUnsignedIntegers; - expect(decodeUnsignedInteger('?')).to.eql(0); - expect(decodeUnsignedInteger('@')).to.eql(1); - expect(decodeUnsignedInteger('A')).to.eql(2); - expect(decodeUnsignedInteger(']')).to.eql(30); - expect(decodeUnsignedInteger('^')).to.eql(31); - expect(decodeUnsignedInteger('_@')).to.eql(32); + expect(decodeUnsignedIntegers('?')).to.eql([0]); + expect(decodeUnsignedIntegers('@')).to.eql([1]); + expect(decodeUnsignedIntegers('A')).to.eql([2]); + expect(decodeUnsignedIntegers(']')).to.eql([30]); + expect(decodeUnsignedIntegers('^')).to.eql([31]); + expect(decodeUnsignedIntegers('_@')).to.eql([32]); - expect(decodeUnsignedInteger('__@')).to.eql(32 * 32); - expect(decodeUnsignedInteger('__D')).to.eql(5 * 32 * 32); - expect(decodeUnsignedInteger('___@')).to.eql(32 * 32 * 32); + expect(decodeUnsignedIntegers('__@')).to.eql([32 * 32]); + expect(decodeUnsignedIntegers('__D')).to.eql([5 * 32 * 32]); + expect(decodeUnsignedIntegers('___@')).to.eql([32 * 32 * 32]); // from the "Encoded Polyline Algorithm Format" page at Google - expect(decodeUnsignedInteger('mD')).to.eql(174); + expect(decodeUnsignedIntegers('mD')).to.eql([174]); }); });