OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
GEO_maneuver.c
Go to the documentation of this file.
1 #include "PGS_TD.h"
2 #include "GEO_main_func.h"
3 #include "PGS_MODIS_35251.h"
4 
5 #define MANEUVER_LUN 600002
6 
7 PGSt_SMF_status GEO_in_maneuver(
8  PGSt_double tai1993
9 )
103 {
104 #define MAX_MANEUVERS \
105  (PGSd_PC_VALUE_LENGTH_MAX/(2* sizeof "2010-05-25T12:57:04.000"))
106 
107  static PGSt_double maneuver_list[MAX_MANEUVERS][2];
108  static int count = -1;
109  int man;
110  char msgbuf[PGSd_PC_VALUE_LENGTH_MAX + 32];
111  char filefunc[] = __FILE__ ", GEO_in_maneuver";
112 
113  if(count == -1)
114  {
115  char maneuver_string[PGSd_PC_VALUE_LENGTH_MAX];
116  char const *pstart = maneuver_string;
117 
118  count = 0;
119  switch(PGS_PC_GetConfigData(MANEUVER_LUN, maneuver_string))
120  {
121  case PGSPC_W_NO_CONFIG_FOR_ID:
122  return PGS_S_SUCCESS; /* Empty maneuver list. */
123 
124  case PGS_S_SUCCESS:
125  break;
126 
127  default:
128  /* Unexpected return value, probably PGSPC_E_DATA_ACCESS_ERROR */
129  sprintf(msgbuf, "PGS_PC_GetConfigData(%ld)", (long)MANEUVER_LUN);
130  modsmf(MODIS_E_GEO, msgbuf, filefunc);
131 
132  return MODIS_E_GEO;
133  }
134 
135  while(*pstart && count < MAX_MANEUVERS)
136  {
137  int val;
138  for(val=0; val<2; val++)
139  {
140  char *pblank = strchr(pstart, ' ');
141 
142  if(!pblank)
143  {
144  sprintf(msgbuf, "time string = \"%s\"", pstart);
145  modsmf(MODIS_E_BAD_INPUT_ARG, msgbuf, filefunc);
146 
147  return MODIS_E_BAD_INPUT_ARG;
148  }
149 
150  *pblank = 'T';
151  pblank = strchr(pblank+1, ' ');
152  if(pblank)
153  *pblank = '\0';
154 
155  if(PGS_TD_UTCtoTAI((char*)pstart, maneuver_list[count] + val)
156  != PGS_S_SUCCESS)
157  {
158  sprintf(msgbuf, "PGS_TD_UTCtoTAI(\"%s\")", pstart);
159  modsmf(MODIS_E_GEO, msgbuf, filefunc);
160 
161  return MODIS_E_GEO;
162  }
163 
164  if(pblank)
165  pstart = pblank+1;
166  else
167  {
168  if(val == 0)
169  { /* Second time value is not correctly recorded. */
170  sprintf(msgbuf, "maneuver_string = \"%s\"",
171  maneuver_string);
172  modsmf(MODIS_E_BAD_INPUT_ARG, msgbuf, filefunc);
173 
174  return MODIS_E_BAD_INPUT_ARG;
175  }
176  while(*pstart)
177  pstart++;
178  }
179  }
180  count++;
181  }
182  }
183 
184  /* The count will almost always be 0, and when it is not, it will almost
185  * always be 1, so the simplest search algorithm is also the best:
186  */
187  for(man = 0; man < count; man++)
188  if(maneuver_list[man][0] < tai1993 && tai1993 < maneuver_list[man][1])
189  return MODIS_N_GEO_MANEUVER;
190 
191  return PGS_S_SUCCESS;
192 }
193 
#define MANEUVER_LUN
Definition: GEO_maneuver.c:5
#define MODIS_E_BAD_INPUT_ARG
#define MODIS_E_GEO
#define MODIS_N_GEO_MANEUVER
#define MAX_MANEUVERS
PGSt_SMF_status GEO_in_maneuver(PGSt_double tai1993)
Definition: GEO_maneuver.c:7
void pblank()
Definition: proj_report.c:265
msiBandIdx val
Definition: l1c_msi.cpp:34
int count
Definition: decode_rs.h:79