fixing dateline handling of Util.getFormattedLonLat. p=cayenne, r=me (closes #3411)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@12172 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -1865,6 +1865,9 @@ OpenLayers.Util.getFormattedLonLat = function(coordinate, axis, dmsOption) {
|
|||||||
if (!dmsOption) {
|
if (!dmsOption) {
|
||||||
dmsOption = 'dms'; //default to show degree, minutes, seconds
|
dmsOption = 'dms'; //default to show degree, minutes, seconds
|
||||||
}
|
}
|
||||||
|
|
||||||
|
coordinate = (coordinate+540)%360 - 180; // normalize for sphere being round
|
||||||
|
|
||||||
var abscoordinate = Math.abs(coordinate);
|
var abscoordinate = Math.abs(coordinate);
|
||||||
var coordinatedegrees = Math.floor(abscoordinate);
|
var coordinatedegrees = Math.floor(abscoordinate);
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -1146,10 +1146,12 @@
|
|||||||
"toFloat rounds large floats correctly #2");
|
"toFloat rounds large floats correctly #2");
|
||||||
}
|
}
|
||||||
function test_getFormattedLonLat(t) {
|
function test_getFormattedLonLat(t) {
|
||||||
t.plan(1);
|
t.plan(3);
|
||||||
var z = 2 + (4/60) - 0.000002 ;
|
var z = 2 + (4/60) - 0.000002 ;
|
||||||
t.eq(OpenLayers.Util.getFormattedLonLat(z,"lon"), "02°04'00\"E",
|
t.eq(OpenLayers.Util.getFormattedLonLat(z,"lon"), "02°04'00\"E",
|
||||||
"LonLat does not show 60 seconds.");
|
"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>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
Reference in New Issue
Block a user