MISR Toolkit  1.5.1
MtkDegMinSecToDms.c
Go to the documentation of this file.
1 /*===========================================================================
2 = =
3 = MtkDegMinSecToDms =
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 #include <stdlib.h>
21 
36  int deg,
37  int min,
38  double sec,
39  double *dms )
40 {
41 
42  MTKt_status status_code; /* Return status of this function */
43  int sgn; /* Sign of input */
44 
45  if (dms == NULL)
47 
48  /* determine sign */
49 
50  if (deg < 0) {
51  sgn = -1;
52  } else {
53  sgn = 1;
54  }
55  deg = abs(deg);
56 
57  /* Check degrees, minutes, seconds bounds */
58 
59  if (deg > 360) return MTK_OUTBOUNDS;
60  if (min > 60) return MTK_OUTBOUNDS;
61  if (sec > 60.0) return MTK_OUTBOUNDS;
62 
63  /* Deg, min, sec to dms */
64 
65  *dms = sgn * (deg * 1000000.0 + min * 1000.0 + sec);
66 
67  return MTK_SUCCESS;
68 
69 ERROR_HANDLE:
70  return status_code;
71 }
#define MTK_ERR_CODE_JUMP(code)
Definition: MisrError.h:175
MTKt_status
Definition: MisrError.h:11
HDFFCLIBAPI void * min
MTKt_status MtkDegMinSecToDms(int deg, int min, double sec, double *dms)
Convert unpacked Degrees, minutes, seconds to packed.

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