OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
untfz.c
Go to the documentation of this file.
1 /*******************************************************************************
2 NAME UNTFZ
3 
4 PURPOSE: This function determines the convergence factor between the
5  input unit type and the output unit type. Valid types include:
6 
7  0 = Radians 3 = Seconds of arc
8  1 = U.S. feet 4 = Degrees of arc
9  2 = Meters 5 = International feet
10 
11 ALGORITHM REFERENCES
12 
13 1. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
14  Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
15  State Government Printing Office, Washington D.C., 1987.
16 
17 2. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections",
18  U.S. Geological Survey Professional Paper 1453 , United State Government
19  Printing Office, Washington D.C., 1989.
20 *******************************************************************************/
21 #include "oli_cproj.h"
22 #include "oli_local.h"
23 
24 static double factors[6][6] = {
25  {1.0, 0.0, 0.0, 206264.8062470963, 57.295779513082323, 0.0},
26  {0.0, 1.0, .3048006096012192, 0.0, 0.0, 1.000002000004},
27  {0.0, 3.280833333333333, 1.0, 0.0, 0.0, 3.280839895013124},
28  {.484813681109536e-5, 0.0, 0.0, 1.0, .27777777777778e-3, 0.0},
29  {.01745329251994329, 0.0, 0.0, 3600, 1.0, 0.0},
30  {0.0, .999998, .3048, 0.0, 0.0, 1.0}};
31 
32 /* Convert DMS packed angle into deg
33 ----------------------------------*/
34 long untfz
35 (
36  long inunit,
37  long outunit,
38  double *factor
39 )
40 {
41 if ((outunit >= 0) && (outunit <= MAXUNIT) && (inunit >= 0)
42  && (inunit <= MAXUNIT))
43  {
44  *factor = factors[inunit][outunit];
45 
46  /* Angle units can not be converted to length units
47  ------------------------------------------------*/
48  if (*factor == 0.0)
49  {
50  GCTP_PRINT_ERROR("Incompatable unit codes");
51  return(1101);
52  }
53  }
54 else
55  {
56  GCTP_PRINT_ERROR("Illegal source or target unit code");
57  return(5);
58  }
59 
60 return(OK);
61 }
#define GCTP_PRINT_ERROR(format,...)
Definition: oli_local.h:81
long untfz(long inunit, long outunit, double *factor)
Definition: untfz.c:35
#define MAXUNIT
Definition: proj_define.h:75
#define OK
Definition: ancil.h:30