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