diff --git a/src/ol/format/polylineformat.js b/src/ol/format/polylineformat.js index c19f4dae72..a30d20eaea 100644 --- a/src/ol/format/polylineformat.js +++ b/src/ol/format/polylineformat.js @@ -237,21 +237,6 @@ ol.format.Polyline.decodeUnsignedIntegers = function(encoded) { }; -/** - * Encode one single floating point number and return an encoded string - * - * @param {number} num Floating point number that should be encoded. - * @param {number=} opt_factor The factor by which num will be multiplied. - * The remaining decimal places will get rounded away. - * @return {string} The encoded string. - */ -ol.format.Polyline.encodeFloat = function(num, opt_factor) { - var factor = goog.isDef(opt_factor) ? opt_factor : 1e5; - num = Math.round(num * factor); - return ol.format.Polyline.encodeSignedInteger(num); -}; - - /** * Encode one single signed integer and return an encoded string * diff --git a/test/spec/ol/format/polylineformat.test.js b/test/spec/ol/format/polylineformat.test.js index c91f570dba..d8689d30b5 100644 --- a/test/spec/ol/format/polylineformat.test.js +++ b/test/spec/ol/format/polylineformat.test.js @@ -140,24 +140,24 @@ describe('ol.format.Polyline', function() { describe('encodeFloat', function() { it('returns expected value', function() { - var encodeFloat = ol.format.Polyline.encodeFloat; + var encodeFloats = ol.format.Polyline.encodeFloats; - expect(encodeFloat(0.00000)).to.eql('?'); - expect(encodeFloat(-0.00001)).to.eql('@'); - expect(encodeFloat(0.00001)).to.eql('A'); - expect(encodeFloat(-0.00002)).to.eql('B'); - expect(encodeFloat(0.00002)).to.eql('C'); - expect(encodeFloat(0.00015)).to.eql(']'); - expect(encodeFloat(-0.00016)).to.eql('^'); + expect(encodeFloats([0.00000])).to.eql('?'); + expect(encodeFloats([-0.00001])).to.eql('@'); + expect(encodeFloats([0.00001])).to.eql('A'); + expect(encodeFloats([-0.00002])).to.eql('B'); + expect(encodeFloats([0.00002])).to.eql('C'); + expect(encodeFloats([0.00015])).to.eql(']'); + expect(encodeFloats([-0.00016])).to.eql('^'); - expect(encodeFloat(-0.1, 10)).to.eql('@'); - expect(encodeFloat(0.1, 10)).to.eql('A'); + expect(encodeFloats([-0.1], 10)).to.eql('@'); + expect(encodeFloats([0.1], 10)).to.eql('A'); - expect(encodeFloat(16 * 32 / 1e5)).to.eql('__@'); - expect(encodeFloat(16 * 32 * 32 / 1e5)).to.eql('___@'); + expect(encodeFloats([16 * 32 / 1e5])).to.eql('__@'); + expect(encodeFloats([16 * 32 * 32 / 1e5])).to.eql('___@'); // from the "Encoded Polyline Algorithm Format" page at Google - expect(encodeFloat(-179.9832104)).to.eql('`~oia@'); + expect(encodeFloats([-179.9832104])).to.eql('`~oia@'); }); });