bes Updated for version 3.20.13
HDFEOS2ArraySwathDimMapField.h
1
2// Retrieves the latitude and longitude of the HDF-EOS2 Swath with dimension map
3// Authors: MuQun Yang <myang6@hdfgroup.org>
4// Copyright (c) 2010-2012 The HDF Group
6
7// Currently the handling of swath data fields with dimension maps is the same as other data fields(HDFEOS2Array_RealField.cc etc)
8// The reason to keep it in separate is, in theory, that data fields with dimension map may need special handlings.
9// So we will leave it here for this release(2010-8), it may be removed in the future. HDFEOS2Array_RealField.cc may be used.
10
11#ifdef USE_HDFEOS2_LIB
12#ifndef HDFEOS2ARRAYSWATHDIMMAPFIELD_H
13#define HDFEOS2ARRAYSWATHDIMMAPFIELD_H
14
15#include <libdap/Array.h>
16using namespace libdap;
17
18#include "HDFCFUtil.h"
19#include "HdfEosDef.h"
20
21#include "HDFEOS2EnumType.h"
22
23class HDFEOS2ArraySwathDimMapField:public Array
24{
25 public:
26 HDFEOS2ArraySwathDimMapField (int rank, const std::string & filename, bool isgeofile, const int sdfd, const int swathfd, const std::string & gridname, const std::string & swathname, const std::string & fieldname, const std::vector < struct dimmap_entry >&dimmaps, SOType sotype, const string & n = "", BaseType * v = nullptr):
27 Array (n, v),
28 rank (rank),
29 filename(filename),
30 isgeofile(isgeofile),
31 sdfd(sdfd),
32 swfd(swathfd),
33 gridname (gridname),
34 swathname (swathname),
35 fieldname (fieldname),
36 dimmaps(dimmaps),
37 sotype(sotype){
38 }
39
40 ~ HDFEOS2ArraySwathDimMapField () override = default;
41
42 // Standard way to pass the coordinates of the subsetted region from the client to the handlers
43 int format_constraint (int *cor, int *step, int *edg);
44
45#if 0
46 // Obtain Field value
47 template < class T > int GetFieldValue (int32, const std::string &,std::vector < struct dimmap_entry >&, std::vector < T > &, std::vector<int32>&);
48
49 // The internal routine to do the interpolation
50 template < class T > int _expand_dimmap_field (std::vector < T > *pvals, int32 rank, int32 dimsa[], int dimindex, int32 ddimsize, int32 offset, int32 inc);
51
52 // subsetting routine to ensure the subsetted field to be returned.
53 template < class T > bool FieldSubset (T * outlatlon, std::vector<int32>&newdims, T * latlon, int32 * offset, int32 * count, int32 * step);
54 // subsetting routine to ensure the subsetted 1D field to be returned.
55 template < class T > bool Field1DSubset (T * outlatlon, int majordim, T * latlon, int32 * offset, int32 * count, int32 * step);
56
57 // subsetting routine to ensure the subsetted 2D field to be returned.
58 template < class T > bool Field2DSubset (T * outlatlon, int majordim, int minordim, T * latlon, int32 * offset, int32 * count, int32 * step);
59 // subsetting routine to ensure the subsetted 2D field to be returned.
60 template < class T > bool Field3DSubset (T * outlatlon, std::vector<int32>& newdims, T * latlon, int32 * offset, int32 * count, int32 * step);
61
62#endif
63 BaseType *ptr_duplicate () override
64 {
65 return new HDFEOS2ArraySwathDimMapField (*this);
66 }
67
68 // Read the data
69 virtual bool read () override;
70
71 private:
72
73 // Field array rank
74 int rank;
75
76 // HDF-EOS2 file name
77 std::string filename;
78
79 bool isgeofile;
80
81 int sdfd;
82
83 int swfd;
84
85 // HDF-EOS2 grid name
86 std::string gridname;
87
88 // HDF-EOS2 swath name
89 std::string swathname;
90
91 // HDF-EOS2 field name
92 std::string fieldname;
93
94 // Swath dimmap info.
95 std::vector < struct dimmap_entry >dimmaps;
96
97 // MODIS scale and offset type
98 // Some MODIS files don't use the CF linear equation y = scale * x + offset,
99 // the scaletype distinguishs products following different scale and offset rules.
100 SOType sotype;
101
102 int write_dap_data_scale_comp(int32 swid, const int nelms, std::vector<int32> &offset32, std::vector<int32> &count32, std::vector<int32> &step32);
103 int write_dap_data_disable_scale_comp(int32 swid, const int nelms, std::vector<int32> &offset32,std::vector<int32> &count32,std::vector<int32> &step32);
104 // Obtain Field value
105 template < class T > int GetFieldValue (int32, const std::string &,std::vector < struct dimmap_entry >&, std::vector < T > &, std::vector<int32>&);
106
107 // The internal routine to do the interpolation
108 template < class T > int _expand_dimmap_field (std::vector < T > *pvals, int32 rank, int32 dimsa[], int dimindex, int32 ddimsize, int32 offset, int32 inc) const;
109
110 // subsetting routine to ensure the subsetted field to be returned.
111 template < class T > bool FieldSubset (T * outlatlon, const std::vector<int32>&newdims, T * latlon, const int32 * offset, const int32 * count, const int32 * step) ;
112 // subsetting routine to ensure the subsetted 1D field to be returned.
113 template < class T > bool Field1DSubset (T * outlatlon, const int majordim, T * latlon, const int32 * offset, const int32 * count, const int32 * step);
114
115 // subsetting routine to ensure the subsetted 2D field to be returned.
116 template < class T > bool Field2DSubset (T * outlatlon, const int majordim, const int minordim, T * latlon, const int32 * offset, const int32 * count, const int32 * step);
117 // subsetting routine to ensure the subsetted 2D field to be returned.
118 template < class T > bool Field3DSubset (T * outlatlon, const std::vector<int32>& newdims, T * latlon, const int32 * offset, const int32 * count, const int32 * step);
119
120
121 // Close file IDs for swath and SDS. This routine is mostly for cleaning up resources when errors occur.
122 void close_fileid(const int32 swid, const int32 sfid);
123
124 // Check is the retrieved number of elements is smaller or equal to the total number of elements in an array.
125 bool check_num_elems_constraint(const int num_elems,const std::vector<int32>&newdims) const;
126};
127
128
129#endif
130#endif
void close_fileid(hid_t fid)
Definition: h5get.cc:434