OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
granule_extract_metadata.c
Go to the documentation of this file.
1 #include "mfhdf.h"
2 
3 int read_extract_metadata(int32 sd_id,
5  int32 *extract_pixel_count,
6  int32 *extract_line_offset,
7  int32 *extract_line_count) {
8 
9  int32 attr_index;
11  *extract_pixel_count = -1;
12  *extract_line_offset = -1;
13  *extract_line_count = -1;
14 
15  attr_index = SDfindattr(sd_id, "Extract Pixel Offset");
16  if (attr_index != FAIL)
17  SDreadattr(sd_id, attr_index, (VOIDP) extract_pixel_offset);
18 
19  attr_index = SDfindattr(sd_id, "Extract Pixel Count");
20  if (attr_index != FAIL)
21  SDreadattr(sd_id, attr_index, (VOIDP) extract_pixel_count);
22 
23  attr_index = SDfindattr(sd_id, "Extract Line Offset");
24  if (attr_index != FAIL)
25  SDreadattr(sd_id, attr_index, (VOIDP) extract_line_offset);
26 
27  attr_index = SDfindattr(sd_id, "Extract Line Count");
28  if (attr_index != FAIL)
29  SDreadattr(sd_id, attr_index, (VOIDP) extract_line_count);
30 
31  return SUCCEED;
32 }
33 
34 int write_extract_metadata(int32 sd_id,
36  int32 extract_pixel_count,
37  int32 extract_line_offset,
38  int32 extract_line_count) {
39 
40  if (extract_pixel_offset != -1)
41  SDsetattr(sd_id, "Extract Pixel Offset",
42  DFNT_INT32, 1,
43  (VOIDP) &extract_pixel_offset);
44 
45  if (extract_pixel_count != -1)
46  SDsetattr(sd_id, "Extract Pixel Count",
47  DFNT_INT32, 1,
48  (VOIDP) &extract_pixel_count);
49 
50  if (extract_line_offset != -1)
51  SDsetattr(sd_id, "Extract Line Offset",
52  DFNT_INT32, 1,
53  (VOIDP) &extract_line_offset);
54 
55  if (extract_line_count != -1)
56  SDsetattr(sd_id, "Extract Line Count",
57  DFNT_INT32, 1,
58  (VOIDP) &extract_line_count);
59 
60  return SUCCEED;
61 }
int write_extract_metadata(int32 sd_id, int32 extract_pixel_offset, int32 extract_pixel_count, int32 extract_line_offset, int32 extract_line_count)
#define FAIL
Definition: ObpgReadGrid.h:18
int32 extract_line_count
Definition: Preprocess.c:66
HDF4 data type of the output SDS Default is DFNT_FLOAT32 Common types used DFNT_INT32
int32 extract_pixel_offset
Definition: Preprocess.c:63
int32 extract_line_offset
Definition: Preprocess.c:65
int32 extract_pixel_count
Definition: Preprocess.c:64
int read_extract_metadata(int32 sd_id, int32 *extract_pixel_offset, int32 *extract_pixel_count, int32 *extract_line_offset, int32 *extract_line_count)