MISR Toolkit  1.5.1
MtkSomXYToLatLonAry.c
Go to the documentation of this file.
1 /*===========================================================================
2 = =
3 = MtkSomXYToLatLonAry =
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 "MisrError.h"
20 #include "proj.h"
21 #include "gctp_prototypes.h"
22 #include <stddef.h>
23 
42  int path,
43  int nelement,
44  const double *som_x,
45  const double *som_y,
46  double *lat_dd,
47  double *lon_dd )
48 {
49  MTKt_status status_code; /* Return status of this function */
50  MTKt_status status; /* Return status */
51  MTKt_MisrProjParam pp; /* Projection parameters */
52  int iflg; /* GCTP status flag */
53  double lat_r; /* Latitude in radians */
54  double lon_r; /* Longitude in radians */
55  int i; /* Loop index */
56  int (*inv_trans[MAXPROJ+1])(double, double, double*, double*); /* Array of function ptrs (Not used) */
57 
58  if (som_x == NULL || som_y == NULL || lat_dd == NULL || lon_dd == NULL)
60 
61  if (nelement < 0)
63 
64  status = MtkPathToProjParam(path, 0, &pp);
65  MTK_ERR_COND_JUMP(status);
66 
68  NULL, NULL, &iflg, inv_trans);
69  if (iflg)
71 
72  for (i = 0; i < nelement; i++) {
73  iflg = sominv(som_x[i], som_y[i], &lon_r, &lat_r);
74  if (iflg)
76 
77  status = MtkRadToDd(lat_r, &lat_dd[i]);
78  MTK_ERR_COND_JUMP(status);
79 
80  status = MtkRadToDd(lon_r, &lon_dd[i]);
81  MTK_ERR_COND_JUMP(status);
82  }
83 
84  return MTK_SUCCESS;
85 
86 ERROR_HANDLE:
87  return status_code;
88 }
#define MAXPROJ
Definition: proj.h:84
MISR Projection Parameters.
double projparam[15]
#define MTK_ERR_CODE_JUMP(code)
Definition: MisrError.h:175
int sominv(double y, double x, double *lon, double *lat)
MTKt_status MtkPathToProjParam(int path, int resolution_meters, MTKt_MisrProjParam *pp)
Get projection parameters.
MTKt_status MtkSomXYToLatLonAry(int path, int nelement, const double *som_x, const double *som_y, double *lat_dd, double *lon_dd)
Convert array of SOM X, SOM Y to array of latitude, longitude.
#define MTK_ERR_COND_JUMP(code)
Definition: MisrError.h:188
MTKt_status
Definition: MisrError.h:11
MTKt_status MtkRadToDd(double rad, double *dd)
Convert radians to decimal degrees.
Definition: MtkRadToDd.c:38
int inv_init(int insys, int inzone, const double *inparm, int indatum, char *fn27, char *fn83, int *iflg, int(*inv_trans[])(double, double, double *, double *))

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