[OpenLayers-Commits] r12172 - in trunk/openlayers: lib/OpenLayers
tests
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Mon Jul 18 08:58:45 EDT 2011
Author: ahocevar
Date: 2011-07-18 05:58:43 -0700 (Mon, 18 Jul 2011)
New Revision: 12172
Modified:
trunk/openlayers/lib/OpenLayers/Util.js
trunk/openlayers/tests/Util.html
Log:
fixing dateline handling of Util.getFormattedLonLat. p=cayenne, r=me (closes #3411)
Modified: trunk/openlayers/lib/OpenLayers/Util.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Util.js 2011-07-15 14:07:39 UTC (rev 12171)
+++ trunk/openlayers/lib/OpenLayers/Util.js 2011-07-18 12:58:43 UTC (rev 12172)
@@ -1865,6 +1865,9 @@
if (!dmsOption) {
dmsOption = 'dms'; //default to show degree, minutes, seconds
}
+
+ coordinate = (coordinate+540)%360 - 180; // normalize for sphere being round
+
var abscoordinate = Math.abs(coordinate);
var coordinatedegrees = Math.floor(abscoordinate);
Modified: trunk/openlayers/tests/Util.html
===================================================================
--- trunk/openlayers/tests/Util.html 2011-07-15 14:07:39 UTC (rev 12171)
+++ trunk/openlayers/tests/Util.html 2011-07-18 12:58:43 UTC (rev 12172)
@@ -1146,10 +1146,12 @@
"toFloat rounds large floats correctly #2");
}
function test_getFormattedLonLat(t) {
- t.plan(1);
+ t.plan(3);
var z = 2 + (4/60) - 0.000002 ;
t.eq(OpenLayers.Util.getFormattedLonLat(z,"lon"), "02°04'00\"E",
"LonLat does not show 60 seconds.");
+ t.eq(OpenLayers.Util.getFormattedLonLat(-181, "lon"), "179°00'00\"E", "crossing dateline from the west results in correct east coordinate");
+ t.eq(OpenLayers.Util.getFormattedLonLat(181, "lon"), "179°00'00\"W", "crossing dateline from the east results in correct west coordinate");
}
</script>
</head>
More information about the Commits
mailing list