MISR Toolkit  1.5.1
MtkPathToProjParam.c
Go to the documentation of this file.
1 /*===========================================================================
2 = =
3 = MtkPathToProjParam =
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 "MisrCoordQuery.h"
18 #include "MisrUnitConv.h"
19 #include "MisrProjParam.h"
20 #include <stddef.h>
21 /* M_PI is not defined in math.h in Linux unless __USE_BSD is defined */
22 /* and you can define it at the gcc command-line if -ansi is set */
23 #ifndef __USE_BSD
24 # define __USE_BSD
25 #endif
26 #include <math.h>
27 
42  int path,
43  int resolution_meters,
44  MTKt_MisrProjParam *pp )
45 {
46  MTKt_status status_code; /* Return status of this function */
48  /* MISR projection parameters */
49  MTKt_status status; /* Return status */
50  double asclong; /* Long of ascending node in dms */
51  double lambda0; /* Path 1 long of ascending node (radians) */
52  double lambda; /* Current path long of ascending node (rad) */
53  int resolution; /* Desired resolution */
54  float resfactor; /* Resolution scale factor */
55  int i; /* Loop index */
56 
57  if (pp == NULL)
59 
60  /* Use default resolution if NULL is passed */
61  if (resolution_meters == 0)
62  resolution = RESOLUTION;
63  else
64  resolution = resolution_meters;
65 
66  /* Check the bounds of path */
67  if (path < 1 || path > NPATH)
69 
70  /* Compute resolution scale factor */
71  resfactor = pp_temp.resolution / (float)resolution;
72 
73  /* Compute longitude of ascending node for this path from first path */
74  status = MtkDmsToRad(PP5_ASCLONG, &lambda0);
75  MTK_ERR_COND_JUMP(status);
76 
77  lambda = lambda0 - (2.0 * M_PI / NPATH) * (path - 1);
78 
79  status = MtkRadToDms(lambda, &asclong);
80  MTK_ERR_COND_JUMP(status);
81 
82  /* Set path and resolution dependent projection parameters. */
83  pp_temp.path = path;
84  pp_temp.projparam[4] = asclong;
85  pp_temp.nline = (int)(pp_temp.nline * resfactor);
86  pp_temp.nsample = (int)(pp_temp.nsample * resfactor);
87  pp_temp.resolution = resolution;
88 
89  for (i = 0; i < NBLOCK - 2; i++) {
90  pp_temp.reloffset[i] *= resfactor;
91  }
92 
93  *pp = pp_temp;
94 
95  return MTK_SUCCESS;
96 
97 ERROR_HANDLE:
98  return status_code;
99 }
MISR Projection Parameters.
double projparam[15]
#define MTK_ERR_CODE_JUMP(code)
Definition: MisrError.h:175
float reloffset[179]
#define RESOLUTION
Definition: MisrProjParam.h:54
MTKt_status MtkPathToProjParam(int path, int resolution_meters, MTKt_MisrProjParam *pp)
Get projection parameters.
MTKt_status MtkRadToDms(double rad, double *dms)
Convert radians to packed degrees, minutes, seconds.
Definition: MtkRadToDms.c:38
#define NBLOCK
Definition: MisrProjParam.h:51
MTKt_status MtkDmsToRad(double dms, double *rad)
Convert packed degrees, minutes, seconds to Radians.
Definition: MtkDmsToRad.c:38
#define PP5_ASCLONG
Definition: MisrProjParam.h:40
#define NPATH
Definition: MisrProjParam.h:31
#define MTKT_MISRPROJPARAM_INIT
#define MTK_ERR_COND_JUMP(code)
Definition: MisrError.h:188
MTKt_status
Definition: MisrError.h:11

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