bes Updated for version 3.20.10
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 = 0):
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 virtual ~ HDFEOS2ArraySwathDimMapField ()
40 {
41 }
42
43 // Standard way to pass the coordinates of the subsetted region from the client to the handlers
44 int format_constraint (int *cor, int *step, int *edg);
45
46#if 0
47 // Obtain Field value
48 template < class T > int GetFieldValue (int32, const std::string &,std::vector < struct dimmap_entry >&, std::vector < T > &, std::vector<int32>&);
49
50 // The internal routine to do the interpolation
51 template < class T > int _expand_dimmap_field (std::vector < T > *pvals, int32 rank, int32 dimsa[], int dimindex, int32 ddimsize, int32 offset, int32 inc);
52
53 // subsetting routine to ensure the subsetted field to be returned.
54 template < class T > bool FieldSubset (T * outlatlon, std::vector<int32>&newdims, T * latlon, int32 * offset, int32 * count, int32 * step);
55 // subsetting routine to ensure the subsetted 1D field to be returned.
56 template < class T > bool Field1DSubset (T * outlatlon, int majordim, T * latlon, int32 * offset, int32 * count, int32 * step);
57
58 // subsetting routine to ensure the subsetted 2D field to be returned.
59 template < class T > bool Field2DSubset (T * outlatlon, int majordim, int minordim, T * latlon, int32 * offset, int32 * count, int32 * step);
60 // subsetting routine to ensure the subsetted 2D field to be returned.
61 template < class T > bool Field3DSubset (T * outlatlon, std::vector<int32>& newdims, T * latlon, int32 * offset, int32 * count, int32 * step);
62
63#endif
64 BaseType *ptr_duplicate ()
65 {
66 return new HDFEOS2ArraySwathDimMapField (*this);
67 }
68
69 // Read the data
70 virtual bool read ();
71
72 private:
73
74 // Field array rank
75 int rank;
76
77 // HDF-EOS2 file name
78 std::string filename;
79
80 bool isgeofile;
81
82 int sdfd;
83
84 int swfd;
85
86 // HDF-EOS2 grid name
87 std::string gridname;
88
89 // HDF-EOS2 swath name
90 std::string swathname;
91
92 // HDF-EOS2 field name
93 std::string fieldname;
94
95 // Swath dimmap info.
96 std::vector < struct dimmap_entry >dimmaps;
97
98 // MODIS scale and offset type
99 // Some MODIS files don't use the CF linear equation y = scale * x + offset,
100 // the scaletype distinguishs products following different scale and offset rules.
101 SOType sotype;
102
103 int write_dap_data_scale_comp(int32 swid, const int nelms, std::vector<int32> &offset32, std::vector<int32> &count32, std::vector<int32> &step32);
104 int write_dap_data_disable_scale_comp(int32 swid, const int nelms, std::vector<int32> &offset32,std::vector<int32> &count32,std::vector<int32> &step32);
105 // Obtain Field value
106 template < class T > int GetFieldValue (int32, const std::string &,std::vector < struct dimmap_entry >&, std::vector < T > &, std::vector<int32>&);
107
108 // The internal routine to do the interpolation
109 template < class T > int _expand_dimmap_field (std::vector < T > *pvals, int32 rank, int32 dimsa[], int dimindex, int32 ddimsize, int32 offset, int32 inc);
110
111 // subsetting routine to ensure the subsetted field to be returned.
112 template < class T > bool FieldSubset (T * outlatlon, const std::vector<int32>&newdims, T * latlon, int32 * offset, int32 * count, int32 * step);
113 // subsetting routine to ensure the subsetted 1D field to be returned.
114 template < class T > bool Field1DSubset (T * outlatlon, const int majordim, T * latlon, int32 * offset, int32 * count, int32 * step);
115
116 // subsetting routine to ensure the subsetted 2D field to be returned.
117 template < class T > bool Field2DSubset (T * outlatlon, const int majordim, const int minordim, T * latlon, int32 * offset, int32 * count, int32 * step);
118 // subsetting routine to ensure the subsetted 2D field to be returned.
119 template < class T > bool Field3DSubset (T * outlatlon, const std::vector<int32>& newdims, T * latlon, int32 * offset, int32 * count, int32 * step);
120
121
122 // Close file IDs for swath and SDS. This routine is mostly for cleaning up resources when errors occur.
123 void close_fileid(const int32 swid, const int32 sfid);
124
125 // Check is the retrieved number of elements is smaller or equal to the total number of elements in an array.
126 bool check_num_elems_constraint(const int num_elems,const std::vector<int32>&newdims);
127};
128
129
130#endif
131#endif
void close_fileid(hid_t fid)
Definition: h5get.cc:433