MISR Toolkit  1.5.1
MtkDmsToDd.c
Go to the documentation of this file.
1 /*===========================================================================
2 = =
3 = MtkDmsToDd =
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 dms,
35  double *dd )
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 (dd == NULL)
46 
47  /* determine sign */
48 
49  if (dms < 0.0) {
50  sgn = -1;
51  } else {
52  sgn = 1;
53  }
54  ang = fabs(dms);
55 
56  /* find degrees */
57 
58  deg = (int)(ang / 1000000.0);
59  if (deg > 360) return MTK_OUTBOUNDS;
60 
61  /* find minutes */
62 
63  min = (int)((ang - deg * 1000000.0) / 1000.0);
64  if (min > 60) return MTK_OUTBOUNDS;
65 
66  /* find seconds */
67 
68  sec = ang - deg * 1000000.0 - min * 1000.0;
69  if (sec > 60.0) return MTK_OUTBOUNDS;
70 
71  /* pack sign, degrees, minutes, seconds into dd */
72 
73  *dd = sgn * (deg * 3600.0 + min * 60.0 + sec) / 3600.0;
74 
75  return MTK_SUCCESS;
76 
77 ERROR_HANDLE:
78  return status_code;
79 }
MTKt_status MtkDmsToDd(double dms, double *dd)
Convert packed degrees, minutes, seconds to decimal degrees.
Definition: MtkDmsToDd.c:33
#define MTK_ERR_CODE_JUMP(code)
Definition: MisrError.h:175
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