From d1b00824fc4c76a817abab97170ebfa9810639eb Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Sat, 18 May 2013 15:24:57 +0200 Subject: [PATCH] Format/EncodedPolyline: Change default factor to 1e5 This matches the factors in the other methods and the default of the original algorithm. Having this set at 1 before can be considered as a bug. --- lib/OpenLayers/Format/EncodedPolyline.js | 4 ++-- tests/Format/EncodedPolyline.html | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/OpenLayers/Format/EncodedPolyline.js b/lib/OpenLayers/Format/EncodedPolyline.js index 60925a2604..e10e8b27e3 100644 --- a/lib/OpenLayers/Format/EncodedPolyline.js +++ b/lib/OpenLayers/Format/EncodedPolyline.js @@ -103,7 +103,7 @@ OpenLayers.Format.EncodedPolyline = OpenLayers.Class(OpenLayers.Format, { * coordinates. */ decode: function(encoded, dims, opt_factor) { - var factor = opt_factor || 1; + var factor = opt_factor || 1e5; var flatPoints = this.decodeDeltas(encoded, dims, factor); var flatPointsLength = flatPoints.length; @@ -179,7 +179,7 @@ OpenLayers.Format.EncodedPolyline = OpenLayers.Class(OpenLayers.Format, { * {String} An encoded string */ encode: function (points, dims, opt_factor) { - var factor = opt_factor || 1; + var factor = opt_factor || 1e5; var flatPoints = []; var pointsLength = points.length; diff --git a/tests/Format/EncodedPolyline.html b/tests/Format/EncodedPolyline.html index 65624a1434..14663479b8 100644 --- a/tests/Format/EncodedPolyline.html +++ b/tests/Format/EncodedPolyline.html @@ -106,8 +106,8 @@ for (i in decodedPoints) { var point = basePoints[i]; var decodedPoint = decodedPoints[i]; - t.eq(point[0], decodedPoint[0]); - t.eq(point[1], decodedPoint[1]); + t.eq(parseInt(decodedPoint[0] * 1e5), point[0]); + t.eq(parseInt(decodedPoint[1] * 1e5), point[1]); } } @@ -141,7 +141,7 @@ var format = new OpenLayers.Format.EncodedPolyline(); - t.eq(format.encode(basePoints, 2), encoded); + t.eq(format.encode(basePoints, 2, 1), encoded); } function test_encodeDeltas_returns_expected_value(t) {