bes  Updated for version 3.20.6
misrinv.cc
1 // The code in this file is adopted from A.7.2 of MISR data products specifications
2 // // Revision S
3 // // https://eosweb.larc.nasa.gov/sites/default/files/project/misr/DPS_v50_RevS.pdf)
4 //
5 #ifdef USE_HDFEOS2_LIB
6 #include "misrproj.h" /* Prototype for this function */
7 #include "errormacros.h" /* Error macros */
8 extern int nb;
9 extern int nl;
10 extern int ns;
11 extern float absOffset[NBLOCK];
12 extern double ulc[2];
13 extern double lrc[2];
14 extern double sx;
15 extern double sy;
16 extern double xc;
17 extern double yc;
18 #define FUNC_NAMEm "misrinv"
19 int misrinv(
20  const int block, /* Input block */
21  const float line, /* Input line */
22  const float sample, /* Input sample */
23  double* x, /* Output SOM X coordinate */
24  double* y /* Output SOM Y coordinate */
25 )
26 {
27  int n; /* Number of line to current block */
28  char msg[STRLEN]; /* Warning message */
29  /* Check Arguments */
30  if (block < 1 || block > NBLOCK) {
31  snprintf(msg, STRLEN, "block is out of range (0 < %d < %d)", block, nb);
32  WRN_LOG_JUMP(msg);
33  }
34  if (line < -0.5 || line > nl - 0.5) {
35  snprintf(msg, STRLEN, "line is out of range (0 < %e < %d)", line, nl);
36  WRN_LOG_JUMP(msg);
37  }
38  if (sample < -0.5 || sample > ns - 0.5) {
39  snprintf(msg, STRLEN, "sample is out of range (0 < %e < %d)", sample, ns);
40  WRN_LOG_JUMP(msg);
41  }
42  /* Compute SOM x/y coordinates in ulc/lrc units (meters) */
43 
44  n = (int)((block - 1) * nl * sx);
45  *x = (double)(xc + n + (line * sx));
46  *y = (double)(yc + ((sample + absOffset[block-1]) * sy));
47  return(0);
48 ERROR_HANDLE:
49  *x = -1e-9;
50  *y = -1e-9;
51  return(1);
52 }
53 #endif