MISR Toolkit  1.5.1
MtkTimeRangeToOrbitList.c
Go to the documentation of this file.
1 /*===========================================================================
2 = =
3 = MtkTimeRangeToOrbitList =
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 "MisrOrbitPath.h"
18 #include "MisrError.h"
19 #include <stdlib.h>
20 
39  const char *start_time,
40  const char *end_time,
41  int *orbitcnt,
42  int **orbitlist )
43 {
44  MTKt_status status; /* Return status */
45  MTKt_status status_code; /* Return code of this function */
46  int start_orbit;
47  int start_path;
48  int end_orbit;
49  int end_path;
50  int *list = NULL;
51  int i;
52 
53  if (start_time == NULL || end_time == NULL ||
54  orbitcnt == NULL || orbitlist == NULL)
56 
57  /* Find start orbit */
58  status = MtkTimeToOrbitPath(start_time,&start_orbit,&start_path);
59  if (status == MTK_BAD_ARGUMENT)
60  {
61  status = MtkTimeToOrbitPath("2000-02-25T01:00:00Z",&start_orbit,&start_path);
62  MTK_ERR_COND_JUMP(status);
63  }
64  else if (status != MTK_SUCCESS)
65  MTK_ERR_CODE_JUMP(status)
66 
67  /* Find end orbit */
68  status = MtkTimeToOrbitPath(end_time,&end_orbit,&end_path);
69  MTK_ERR_COND_JUMP(status);
70 
71  if (start_orbit > end_orbit)
73 
74  *orbitcnt = end_orbit - start_orbit + 1;
75 
76  list = (int*)malloc(*orbitcnt * sizeof(int));
77  if (list == NULL)
79 
80  for (i = 0; i < *orbitcnt; ++i)
81  list[i] = start_orbit + i;
82 
83  *orbitlist = list;
84 
85  return MTK_SUCCESS;
86 
87  ERROR_HANDLE:
88  return status_code;
89 }
MTKt_status MtkTimeToOrbitPath(const char *datetime, int *orbit, int *path)
Given time return orbit number and path number.
#define MTK_ERR_CODE_JUMP(code)
Definition: MisrError.h:175
MTKt_status MtkTimeRangeToOrbitList(const char *start_time, const char *end_time, int *orbitcnt, int **orbitlist)
Given start time and end time return list of orbits.
#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