dmsFormat()
dmsFormat()
| Version: | 1.0 build 20070811 |
|---|---|
| Requires: | Adobe ColdFusion 5.0 or greater |
| Total size: | 1.15 KB |
| Download time: | 0.20 seconds at 56kbps |
| Edition: | Freeware |
Description
Display an angle in degrees, minutes, and seconds. Optionally, append a sign indicator in order to represent latitudes and longitudes.
Returns
A string representing the angle.
Category
Math
Parameters
| Parameter | Type | Required? | Default | Description |
|---|---|---|---|---|
| value | numeric | Yes | The angle as decimal degrees. | |
| signIndicators | string | No | Optional sign indicators to be appended. The first character is the positive sign and the second is negative. For example, 'EW' for longitude and 'NS' for latitude. |
UDF source
<cfscript> /** * Display an angle in degrees, minutes, and seconds. Optionally, append a sign indicator * in order to represent latitudes and longitudes. * * @param value The angle as decimal degrees (Required) * @param signIndicators Optional sign indicators to be appended. The first character is the positive * sign and the second is negative. For example, 'EW' for longitude and 'NS' for latitude. * @return string * @author Matthew Walker, WWW.eswsoftware.com * @version 1, 2007-08-11 */ function dmsFormat(value) { var temp = abs(value); var d = int(temp); var m = 0; var s = 0; var signIndicator = arrayLen(arguments) gt 1; var result = ""; temp = (temp - d) * 60; m = int(temp); temp = (temp - m) * 60; s = int(temp); result = "#d#&##176; #numberFormat(m, "00")#&##8242; #numberFormat(s, "00")#&##8243;"; if ( signIndicator ) if ( value lt 0 ) result = result & " " & right(arguments[2],1); else result = result & " " & left(arguments[2],1); else if ( value lt 0 ) result = "-" & result; return result; } </cfscript>
World Wide Web
