rasdaman complete source
qtencode.hh
Go to the documentation of this file.
1 /*
2  * This file is part of rasdaman community.
3  *
4  * Rasdaman community is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * Rasdaman community is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTrABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16  *
17  * Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
18 rasdaman GmbH.
19  *
20  * For more information please see <http://www.rasdaman.org>
21  * or contact Peter Baumann via <baumann@rasdaman.com>.
22  */
23 
24 #ifndef _QTENCODE__
25 #define _QTENCODE__
26 
27 #include "raslib/error.hh"
28 #include "qlparser/qtmdd.hh"
30 #include "tilemgr/tile.hh"
31 #include "raslib/type.hh"
32 
33 // GDAL headers
34 #include "gdal_priv.h"
35 
36 class GDALDataset;
37 
38 /**************************************************************
39  *
40  *
41  * COMMENTS:
42  *
43  ************************************************************/
44 
45 //@ManMemo: Module: {\bf qlparser}
46 
47 /*@Doc:
48  *
49  * The class allows to encode MDDs to various formats as supported by the GDAL library.
50  * From rasql it is invoked with the encode function with the following signature:
51  *
52  * encode( mddExpr, gdalFormat, formatParams )
53  *
54  * - gdalFormat is the GDAL format identifier to which mddExpr will be encoded.
55  * To see the list of supported formats, run gdal_translate
56  * - formatParams are parameters specific to each format driver, they should
57  * be specified in this format:
58  *
59  * name1=value1;name2=value2;...
60 */
61 
62 class QtEncode : public QtUnaryOperation
63 {
64 public:
65 
67  QtEncode( QtOperation *mddOp, char* format ) throw(r_Error);
68 
70  QtEncode( QtOperation *mddOp, char* format, char* params ) throw(r_Error);
71 
73  ~QtEncode();
74 
76  QtData* evaluate( QtDataList* inputList ) throw (r_Error);
77 
79  virtual QtAreaType getAreaType();
80 
82  const QtTypeElement& checkType( QtTypeTuple* typeTuple );
83 
85  virtual void printTree( int tab, std::ostream& s = std::cout, QtChildType mode = QT_ALL_NODES );
86 
87 private:
88 
90  QtData* evaluateMDD(QtMDD *mdd) throw (r_Error);
91 
93  GDALDataType getGdalType(r_Type* rasType);
94 
96  r_Data_Format getDataFormat(char* format);
97 
98  // convert rasdaman tile to GDAL dataset
99  GDALDataset* convertTileToDataset(Tile* sourceTile, int nBands, r_Type* bandType);
100 
101  void initParams(char* params);
102  void setDouble(const char* paramName, double* value);
103  void setString(const char* paramName, std::string* value);
104 
106  static const QtNodeType nodeType = QT_ENCODE;
107 
108  QtOperation *mddOp;
109  char* format;
110  char** fParams;
111 
112  struct GenericParams
113  {
114  double xmin;
115  double xmax;
116  double ymax;
117  double ymin;
118 
119  std::string crs; // string representation of the coordinate reference system
120  std::string metadata; // further metadata of the result
121  std::vector<double> nodata; // nodata values of the result
122  };
123 
124  GenericParams gParams;
125 };
126 
127 #endif // _QTENCODE__
128 
virtual void printTree(int tab, std::ostream &s=std::cout, QtChildType mode=QT_ALL_NODES)
debugging method
virtual QtAreaType getAreaType()
test if the edge to the parent node is of type mdd or atomic
std::vector< QtData * > QtDataList
list of QtData pointers
Definition: qtnode.hh:77
QtAreaType
Definition: qtnode.hh:180
Definition: qtnode.hh:463
Definition: qtencode.hh:62
Definition: error.hh:88
Definition: qtdata.hh:83
Definition: raslib/type.hh:56
QtChildType
Definition: qtnode.hh:186
QtNodeType
Definition: qtnode.hh:93
Definition: qtnode.hh:394
const QtTypeElement & checkType(QtTypeTuple *typeTuple)
type check
Definition: qtunaryoperation.hh:52
r_Data_Format
Definition: mddtypes.hh:133
~QtEncode()
destructor
Definition: tile.hh:80
QtData * evaluate(QtDataList *inputList)
method for evaluating the node
Definition: qtnode.hh:171
QtEncode(QtOperation *mddOp, char *format)
constructor getting the mdd operand and format to which to encode it
Definition: qtoperation.hh:57
Definition: qtnode.hh:190
Definition: qtmdd.hh:58