From 07e34672b516248daa6733c9715edd928eea1a17 Mon Sep 17 00:00:00 2001 From: bartvde Date: Thu, 24 Feb 2011 11:24:50 +0000 Subject: [PATCH] OpenLayers.Util.getFormattedLonLat does not deal correctly with 60 seconds and 60 minutes, p=mattnott,jorix, r=me,marcjansen (closes #2852) git-svn-id: http://svn.openlayers.org/trunk/openlayers@11405 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Util.js | 9 +++++++++ tests/Util.html | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index 414ae4c856..4c9cd014da 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -1849,6 +1849,15 @@ OpenLayers.Util.getFormattedLonLat = function(coordinate, axis, dmsOption) { coordinateseconds = Math.round(coordinateseconds*10); coordinateseconds /= 10; + if( coordinateseconds >= 60) { + coordinateseconds -= 60; + coordinateminutes += 1; + if( coordinateminutes >= 60) { + coordinateminutes -= 60; + coordinatedegrees += 1; + } + } + if( coordinatedegrees < 10 ) { coordinatedegrees = "0" + coordinatedegrees; } diff --git a/tests/Util.html b/tests/Util.html index c921df9bfe..7232b650ce 100644 --- a/tests/Util.html +++ b/tests/Util.html @@ -1101,6 +1101,12 @@ t.eq(OpenLayers.Util.toFloat(b1), OpenLayers.Util.toFloat(b2), "toFloat rounds large floats correctly #2"); } + function test_getFormattedLonLat(t) { + t.plan(1); + var z = 2 + (4/60) - 0.000002 ; + t.eq(OpenLayers.Util.getFormattedLonLat(z,"lon"), "02°04'00\"E", + "LonLat does not show 60 seconds."); + }