rasdaman complete source
dem.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 * MERCHANTABILITY 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 /
37 #ifndef _R_CONV_DEM_HH_
38 #define _R_CONV_DEM_HH_
39 
40 #include <sstream>
41 #include <vector>
42 #include <string>
43 #include <cstdio>
44 using std::vector;
45 using std::ofstream;
46 using std::string;
47 
48 #include "conversion/convertor.hh"
49 #include "raslib/odmgtypes.hh"
50 
51 //@ManMemo: Module {\bf conversion}
52 
53 /*@Doc:
54  DEM convertor class.
55 
56  Supported parameters are
57 
58  \begin{tabular}{lcl}
59  {\tt flipx} && int && flip image flag on x axis, default 0\\
60  {\tt flipy} && int && flip image flag on y axis, default 1\\
61  {\tt startx} && double && start value on x axis \\
62  {\tt endx} && double && end value on x axis \\
63  {\tt resx} && double && resolution on x axis \\
64  {\tt starty} && double && start value on y axis \\
65  {\tt endy} && double && end value on y axis \\
66  {\tt resy} && double && resolution on y axis \\
67  \end{tabular}
68 
69  The "flipx" parameter is a flag for mirroring the image on x axis.
70  The "flipy" parameter is a flag for mirroring the image on y axis.
71  [startx:endx, starty:endy] represents the geographical bounding box
72  of the whole image. The corresponding pixel bounding box is calculated
73  as follows:
74  if flipy is disabled:
75  [(minx-startx)/resx:(maxx-startx)/resx, (miny-starty)/resy:(maxy-starty)/resy]
76  else
77  [(minx-startx)/resx:(maxx-startx)/resx, (endy-maxy)/resy:(endy-miny)/resy]
78 
79  if flipx is disabled:
80  [(minx-startx)/resx:(maxx-startx)/resx, (miny-starty)/resy:(maxy-starty)/resy]
81  else
82  [(endx-maxx)/resx:(endx-minx)/resx, (miny-starty)/resy:(maxy-starty)/resy]
83 
84  The pairs (startx, endx, resx), (starty, endy, resy) are for the whole image(e.g image bounding)
85  and the pairs (minx,maxx, resx), (miny, maxy, resy) are for the current part of image.
86  They are used to compute the position of current image in RasDaMan coordinates.
87 */
88 
89 // r_Error code for "empty DEM result generated"; this def should go into a central list
90 // -- PB 2003-dec-03
91 #define E_DEM_EMPTY 3000
92 
93 class r_Conv_DEM : public r_Convertor
94 {
95 public:
96  // constants to handle NULL
97  static const r_Double NULL_DB;
98  static const r_Double ZERO_DB;
99  static const r_Double ZERO_DEM;
100 
101  //inner class for convertor parameters
102  class r_GeoBBox
103  {
104  public:
105  r_Double startx, endx, resx;
106  r_Double starty, endy, resy;
107  r_ULong flipy, flipx;
108  };
109 
110  r_Conv_DEM(const char* source, const r_Minterval& lengthordomain, const r_Type* tp) throw(r_Error);
111 
112  r_Conv_DEM(const char* source, const r_Minterval& lengthordomain, int tp) throw(r_Error);
113 
114  r_convDesc& convertFrom(const char* options = NULL) throw (r_Error);
115 
116  r_convDesc& convertTo(const char* options = NULL) throw (r_Error);
117 
118  const char* get_name() const throw();
119 
120  r_Data_Format get_data_format() const throw();
121 
122  r_Convertor* clone() const throw(r_Error);
123 
125  static const r_Dimension srcIntervDim;
126 
128  static const r_Dimension destIntervDim;
129 
131  static bool decodeOptions( const char* options,
132  r_GeoBBox& collBBox) throw();
133 
135  static string encodeOptions(const r_GeoBBox& collBBox) throw();
136 
138  virtual ~r_Conv_DEM( void );
139 
141  static void initGeoBBox( r_GeoBBox& cBBox );
142 
143 private:
144 
145 
147  void checkLimits() throw(r_Error);
148 
150  void readFromSrcStream() throw(r_Error);
151  void readToSrcStream() throw(r_Error);
152  void writeFromDestStream() throw(r_Error);
153  void writeToDestStream(ofstream& oFile) throw(r_Error);
154 
156  r_GeoBBox collBBox;
157 
159  static const r_ULong paramMin;
160  static const char* paramSep;
161  static const char* paramEq;
162  static const char* paramFlipX;
163  static const char* paramFlipY;
164  static const char* paramStartX;
165  static const char* paramEndX;
166  static const char* paramResX;
167  static const char* paramStartY;
168  static const char* paramEndY;
169  static const char* paramResY;
170 
171 
173  class DEMRow
174  {
175  public:
176  r_Double x,y,h;
177  };
178 
179  typedef vector<DEMRow> DEMRowVec;
180 
181  DEMRow min, max;
182  DEMRowVec demRows;
183 
184 };
185 
186 #endif
187 
Definition: raslib/type.hh:56
#define min(a, b)
Definition: defs.h:78
#define max(a, b)
Definition: defs.h:77