MISR Toolkit  1.5.1
MtkDdToDms.c
Go to the documentation of this file.
1 /*===========================================================================
2 = =
3 = MtkDdToDms =
4 = =
5 =============================================================================
6 
7  Jet Propulsion Laboratory
8  MISR
9  MISR Toolkit
10 
11  Copyright 2005, California Institute of Technology.
12  ALL RIGHTS RESERVED.
13  U.S. Government Sponsorship acknowledged.
14 
15 ============================================================================*/
16 
17 #include "MisrUnitConv.h"
18 #include "MisrError.h"
19 #include <math.h>
20 
34  double dd,
35  double *dms )
36 {
37  MTKt_status status_code; /* Return status of this function */
38  int sgn; /* Sign of input */
39  int deg; /* Degrees */
40  int min; /* Minutes */
41  double sec; /* Seconds */
42  double ang; /* Absolute value dms angle */
43 
44  if (dms == NULL)
46 
47  /* determine sign */
48 
49  if (dd < 0.0) {
50  sgn = -1;
51  } else {
52  sgn = 1;
53  }
54  ang = fabs(dd);
55 
56  /* find degrees */
57 
58  deg = (int)ang;
59  if (deg > 360) return MTK_OUTBOUNDS;
60 
61  /* find minutes */
62 
63  ang = (ang - deg) * 60.0;
64  min = (int)ang;
65  if (min > 60) return MTK_OUTBOUNDS;
66 
67  /* find seconds */
68 
69  sec = (ang - min) * 60.0;
70 
71  if (sec > 60.0) return MTK_OUTBOUNDS;
72 
73  /* pack sign, degrees, minutes, seconds into dms */
74 
75  *dms = sgn * (deg * 1000000 + min * 1000 + sec);
76 
77  return MTK_SUCCESS;
78 
79 ERROR_HANDLE:
80  return status_code;
81 }
#define MTK_ERR_CODE_JUMP(code)
Definition: MisrError.h:175
MTKt_status MtkDdToDms(double dd, double *dms)
Convert decimal degrees to packed degrees, minutes, seconds.
Definition: MtkDdToDms.c:33
MTKt_status
Definition: MisrError.h:11
HDFFCLIBAPI void * min

MISR Toolkit - Copyright © 2005 - 2020 Jet Propulsion Laboratory
Generated on Fri Jun 19 2020 22:49:51