OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
paksz.c
Go to the documentation of this file.
1 /*******************************************************************************
2 NAME PAKSZ
3 
4 PURPOSE: This function converts a packed DMS angle to seconds. The
5  standard packed DMS format is:
6 
7  degrees * 1000000 + minutes * 1000 + seconds
8 
9  Example: ang = 120025045.25 yields
10  deg = 120
11  min = 25
12  sec = 45.25
13 
14  The algorithm used for the conversion is as follows:
15 
16  1. The absolute value of the angle is used.
17 
18  2. The degrees are separated out:
19  deg = ang/1000000 (fractional portion truncated)
20 
21  3. The minutes are separated out:
22  min = (ang - deg * 1000000) / 1000 (fractional
23  portion truncated)
24 
25  4. The seconds are then computed:
26  sec = ang - deg * 1000000 - min * 1000
27 
28  5. The total angle in seconds is computed:
29  sec = deg * 3600.0 + min * 60.0 + sec
30 
31  6. The sign of sec is set to that of the input angle.
32 
33 
34 ALGORITHM REFERENCES
35 
36 1. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
37  Survey Proffesional Paper 1395 (Supersedes USGS Bulletin 1532), United
38  State Government Printing Office, Washington D.C., 1987.
39 
40 2. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections",
41  U.S. Geological Survey Professional Paper 1453 , United State Government
42  Printing Office, Washington D.C., 1989.
43 *******************************************************************************/
44 #include "oli_cproj.h"
45 #include "oli_local.h"
46 
47 /* Convert DMS packed angle into deg
48 ----------------------------------*/
49 double paksz
50 (
51  double ang, /* angle which in DMS */
52  long *iflg /* error flag number */
53 )
54 {
55 double fac; /* sign flag */
56 double deg; /* degree variable */
57 double min; /* minute variable */
58 double sec; /* seconds variable */
59 double tmp; /* temporary variable */
60 long i; /* temporary variable */
61 
62 *iflg = 0;
63 
64 if (ang < 0.0)
65  fac = -1;
66 else
67  fac = 1;
68 
69 /* find degrees
70 -------------*/
71 sec = fabs(ang);
72 tmp = 1000000.0;
73 i = (long) (sec/tmp);
74 if (i > 360)
75  {
76  GCTP_PRINT_ERROR("Illegal DMS field");
77  *iflg = 1116;
78  return(ERROR);
79  }
80 else
81  deg = i;
82 
83 /* find minutes
84 -------------*/
85 sec = sec - deg * tmp;
86 tmp = 1000;
87 i = (long) (sec / tmp);
88 if (i > 60)
89  {
90  GCTP_PRINT_ERROR("Illegal DMS field");
91  *iflg = 1116;
92  return(ERROR);
93  }
94 else
95  min = i;
96 
97 /* find seconds
98 -------------*/
99 sec = sec - min * tmp;
100 if (sec > 60)
101  {
102  GCTP_PRINT_ERROR("Illegal DMS field");
103  *iflg = 1116;
104  return(ERROR);
105  }
106 else
107  sec = fac * (deg * 3600.0 + min * 60.0 + sec);
108 deg = sec / 3600.0;
109 
110 return(deg);
111 }
These are used to scale the SD before writing it to the HDF4 file The default is and which means the product is not scaled at all Since the product is usually stored as a float inside of this is a way to write the float out as a integer l2prod min
#define GCTP_PRINT_ERROR(format,...)
Definition: oli_local.h:81
#define fac
data_t tmp
Definition: decode_rs.h:74
#define fabs(a)
Definition: misc.h:93
double paksz(double ang, long *iflg)
Definition: paksz.c:50
int i
Definition: decode_rs.h:71
#define ERROR
Definition: ancil.h:24