MISR Toolkit
1.5.1
UnitConv
src
MtkDmsToDegMinSec.c
Go to the documentation of this file.
1
/*===========================================================================
2
= =
3
= MtkDmsToDegMinSec =
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
33
MTKt_status
MtkDmsToDegMinSec
(
34
double
dms,
35
int
*deg,
36
int
*
min
,
37
double
*sec )
38
{
39
MTKt_status
status_code;
/* Return status of this function */
40
int
sgn;
/* Sign of input */
41
double
ang;
/* Absolute value dms angle */
42
43
if
(deg == NULL || min == NULL || sec == NULL)
44
MTK_ERR_CODE_JUMP
(
MTK_NULLPTR
);
45
46
/* determine sign */
47
48
if
(dms < 0.0) {
49
sgn = -1;
50
}
else
{
51
sgn = 1;
52
}
53
ang = fabs(dms);
54
55
/* find degrees */
56
57
*deg = (int)(ang / 1000000.0);
58
if
(*deg > 360)
return
MTK_OUTBOUNDS
;
59
60
/* find minutes */
61
62
*min = (int)((ang - *deg * 1000000.0) / 1000.0);
63
if
(*min > 60)
return
MTK_OUTBOUNDS
;
64
65
/* find seconds */
66
67
*sec = ang - *deg * 1000000.0 - *min * 1000.0;
68
if
(*sec > 60.0)
return
MTK_OUTBOUNDS
;
69
70
/* Replace sign */
71
72
*deg *= sgn;
73
74
return
MTK_SUCCESS
;
75
76
ERROR_HANDLE:
77
return
status_code;
78
}
MTK_NULLPTR
Definition:
MisrError.h:19
MtkDmsToDegMinSec
MTKt_status MtkDmsToDegMinSec(double dms, int *deg, int *min, double *sec)
Convert packed degrees, minutes, seconds to unpacked.
Definition:
MtkDmsToDegMinSec.c:33
MTK_ERR_CODE_JUMP
#define MTK_ERR_CODE_JUMP(code)
Definition:
MisrError.h:175
MTK_SUCCESS
Definition:
MisrError.h:12
MTK_OUTBOUNDS
Definition:
MisrError.h:14
MisrUnitConv.h
MisrError.h
MTKt_status
MTKt_status
Definition:
MisrError.h:11
min
HDFFCLIBAPI void * min
Definition:
hproto_fortran.h:256
MISR Toolkit - Copyright © 2005 - 2020 Jet Propulsion Laboratory
Generated on Fri Jun 19 2020 22:49:51