bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
HDFEOS2ArraySwathDimMapField.h
1
2// Retrieves the latitude and longitude of the HDF-EOS2 Swath with dimension map
3// Authors: Kent Yang <myang6@hdfgroup.org>
4// Copyright (c) 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>
16#include "HDFCFUtil.h"
17#include "HdfEosDef.h"
18#include "HDFEOS2EnumType.h"
19
20class HDFEOS2ArraySwathDimMapField:public libdap::Array
21{
22 public:
23 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 = "", libdap::BaseType * v = nullptr):
24 Array (n, v),
25 rank (rank),
26 filename(filename),
27 isgeofile(isgeofile),
28 sdfd(sdfd),
29 swfd(swathfd),
30 gridname (gridname),
31 swathname (swathname),
32 fieldname (fieldname),
33 dimmaps(dimmaps),
34 sotype(sotype){
35 }
36
37 ~ HDFEOS2ArraySwathDimMapField () override = default;
38
39 // Standard way to pass the coordinates of the subsetted region from the client to the handlers
40 int format_constraint (int *cor, int *step, int *edg);
41
42 libdap::BaseType *ptr_duplicate () override
43 {
44 return new HDFEOS2ArraySwathDimMapField (*this);
45 }
46
47 // Read the data
48 bool read () override;
49
50 private:
51
52 // Field array rank
53 int rank;
54
55 // HDF-EOS2 file name
56 std::string filename;
57
58 bool isgeofile;
59
60 int sdfd;
61
62 int swfd;
63
64 // HDF-EOS2 grid name
65 std::string gridname;
66
67 // HDF-EOS2 swath name
68 std::string swathname;
69
70 // HDF-EOS2 field name
71 std::string fieldname;
72
73 // Swath dimmap info.
74 std::vector < struct dimmap_entry >dimmaps;
75
76 // MODIS scale and offset type
77 // Some MODIS files don't use the CF linear equation y = scale * x + offset,
78 // the scaletype distinguishs products following different scale and offset rules.
79 SOType sotype;
80
81 int write_dap_data_scale_comp(int32 swid, const int nelms, std::vector<int32> &offset32, std::vector<int32> &count32, std::vector<int32> &step32);
82 int write_dap_data_disable_scale_comp(int32 swid, const int nelms, std::vector<int32> &offset32,std::vector<int32> &count32,std::vector<int32> &step32);
83 // Obtain Field value
84 template < class T > int GetFieldValue (int32, const std::string &,const std::vector < struct dimmap_entry >&, std::vector < T > &, std::vector<int32>&);
85
86 // The internal routine to do the interpolation
87 template < class T > int _expand_dimmap_field (std::vector < T > *pvals, int32 rank, int32 dimsa[], int dimindex, int32 ddimsize, int32 offset, int32 inc) const;
88
89 // subsetting routine to ensure the subsetted field to be returned.
90 template < class T > bool FieldSubset (T * outlatlon, const std::vector<int32>&newdims, T * latlon, const int32 * offset, const int32 * count, const int32 * step) ;
91 // subsetting routine to ensure the subsetted 1D field to be returned.
92 template < class T > bool Field1DSubset (T * outlatlon, const int majordim, T * latlon, const int32 * offset, const int32 * count, const int32 * step);
93
94 // subsetting routine to ensure the subsetted 2D field to be returned.
95 template < class T > bool Field2DSubset (T * outlatlon, const int majordim, const int minordim, T * latlon, const int32 * offset, const int32 * count, const int32 * step);
96 // subsetting routine to ensure the subsetted 2D field to be returned.
97 template < class T > bool Field3DSubset (T * outlatlon, const std::vector<int32>& newdims, T * latlon, const int32 * offset, const int32 * count, const int32 * step);
98
99
100 // Close file IDs for swath and SDS. This routine is mostly for cleaning up resources when errors occur.
101 void close_fileid(const int32 swid, const int32 sfid);
102
103 // Check is the retrieved number of elements is smaller or equal to the total number of elements in an array.
104 bool check_num_elems_constraint(const int num_elems,const std::vector<int32>&newdims) const;
105};
106
107
108#endif
109#endif