// Mathematical helpfunctions

// calculate the decimal degree, only used if we add a input box
function deg2Dec( d ) {
    var g = Math.floor(d) ;
    return g + (d-g)/0.6 ;
} // deg2Dec

// format a decimal degree to a text with degree, minutes & seconds
function dec2Deg( d ) {
    d = Math.abs(d) ;
    var g = Math.floor(d) ;
    var r = 60 * (d-g) ;
    var m = Math.floor(r) ;
    r = 60 * (r-m) ;
    var s = Math.floor(r) ;
    return g + "&deg; " + (m<10?'0':'') + m + "' " + (s<10?'0':'') + s +'" ' ;
} // dec2Deg

// Format a position, given its latitude and longitude in decimaldegrees
function formatLatLng( lat, lng ) {
    return dec2Deg(lat) + (lat<0?' S':' N') + ' ' + dec2Deg(lng) + (lng<0?' V':' &Oslash')  ;
} // formatLatLng

// Format a position, given its latitude and longitude in decimaldegrees
function textLatLng( lat, lng ) {
    return formatLatLng( lat, lng ).replace( /&deg;/g, " " ) ;
} // textLatLng

