OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimDblGrid.h
Go to the documentation of this file.
1 //*****************************************************************************
2 // O S S I M
3 //
4 // FILE: ossimDblGrid.h
5 //
6 // License: See top level LICENSE.txt file.
7 //
8 // AUTHOR: Oscar Kramer
9 //
10 // DESCRIPTION:
11 // Contains declaration of class ossimDblGrid. This object class maintains
12 // a regular grid of floating point (double) values. Access methods to the
13 // grid include interpolation between grid nodes. Capability is included
14 // to address the grid in an arbitrary, floating-point u, v coordinate
15 // system which is related to the integer grid x, y system by scale and
16 // offset:
17 //
18 // u = Sx*(x + Xo), v = Sy*(y + Y0)
19 //
20 // where Xo, Yo is the origin of the U/V cood system. Sx, Sy are the scale
21 // relations. For example, if the grid is being used to hold a grid of
22 // elevation posts, then the origin will be the SW corner post ground point,
23 // and the scale will be derived from the post spacing. Both origin and
24 // spacing are specified to the constructor.
25 //
26 //*****************************************************************************
27 // $Id: ossimDblGrid.h 20044 2011-09-06 15:02:43Z oscarkramer $
28 
29 #ifndef ossimDblGrid_HEADER
30 #define ossimDblGrid_HEADER
31 
32 #include <ossim/base/ossimDpt.h>
33 #include <ossim/base/ossimIpt.h>
34 #include <ossim/base/ossimDrect.h>
35 #include <ossim/base/ossimCommon.h>
36 
37 class ossimDrect;
38 
39 /*!****************************************************************************
40  *
41  * CLASS: ossimDblGrid
42  *
43  *****************************************************************************/
45 {
46 public:
50  ossimDblGrid ();
51 
55  ossimDblGrid (const ossimDblGrid& source_to_copy);
56 
60  ossimDblGrid (const ossimIpt& size,
61  const ossimDpt& origin,
62  const ossimDpt& spacing,
63  double null_value = OSSIM_DEFAULT_NULL_PIX_DOUBLE);
64 
71  ossimDblGrid (const ossimDrect& uv_rect,
72  const ossimDpt& spacing,
73  double null_value = OSSIM_DEFAULT_NULL_PIX_DOUBLE);
74 
75  ~ossimDblGrid ();
76 
80  void initialize(const ossimIpt& size,
81  const ossimDpt& origin,
82  const ossimDpt& spacing,
83  double null_value = OSSIM_DEFAULT_NULL_PIX_DOUBLE );
84  void initialize(const ossimDrect& uv_rect,
85  const ossimDpt& spacing,
86  double null_value = OSSIM_DEFAULT_NULL_PIX_DOUBLE);
91  void enableExtrapolation(bool arg=true) { theExtrapIsEnabled = arg;}
92 
93  void deallocate();
97  void fill(double fill_value);
98 
102  void clear() { fill(theNullValue); }
103 
107  void setNode (const ossimIpt& p,
108  const double& value) { setNode(p.x, p.y, value); }
109  void setNode (int x, int y, const double& value);
110 
111  double getNode (const ossimIpt& p) const { return getNode(p.x, p.y); }
112  double getNode (int x, int y) const;
113 
119  void setNearestNode(const ossimDpt& uv_point,
120  const double& value);
121 
128  void interpolateNullValuedNodes(const double& decay_rate=10.0);
129 
138  void filter(int size_x, int size_y, double* kernel);
139 
144  {
145  BILINEAR
146  };
147  void setInterpolationType (InterpType interp);
148 
150  {
151  CONTINUOUS = 0, // Default continuous grid with no limits on values
152  SAWTOOTH_90= 1, // For angles between -90 and 90 deg such as latitude
153  WRAP_180 = 2, // For angles between -180 and 180 with discontinuity at limits (typically used for longitude)
154  WRAP_360 = 3 // For angles between 0 and 360 with discontinuity at limits (typically used for rotations)
155  };
156  void setDomainType(DomainType dt) { theDomainType = dt; }
157 
161  double operator() (const ossimDpt& uv_point) const {return (*this)(uv_point.u, uv_point.v);}
162  double value (const ossimDpt& uv_point) const {return (*this)(uv_point.u, uv_point.v);}
163 
164  double operator() (const double& u, const double& v) const;
165  double value (const double& u, const double& v) const {return (*this)(u,v);}
166 
170  const ossimDblGrid& operator = (const ossimDblGrid& grid);
171 
175  double minValue() const { return theMinValue; }
176  double maxValue() const { return theMaxValue; }
177  double nullValue() const { return theNullValue; }
178  double meanValue();
179  double meanStdDev();
180 
181  void setMinValue(double value) {theMinValue = value;}
182  void setMaxValue(double value) {theMaxValue = value;}
183  void setNullValue(double value) {theNullValue = value;}
187  const ossimIpt& size() const { return theSize; }
188  const ossimDpt& origin() const { return theOrigin; }
189  const ossimDpt& spacing() const { return theSpacing; }
190  unsigned long getSizeInBytes() const { return theSize.x*theSize.y*sizeof(double); }
191 
195  bool isInside(const ossimDpt& p) const {return isInside(p.u, p.v);}
196  bool isInside(const double& u, const double& v) const;
197 
201  bool save(std::ostream& os, const char* descr) const;
202  bool load(std::istream& is);
203 
204  friend std::ostream& operator << (std::ostream& os, const ossimDblGrid& grid);
205 
206 private:
207 
208  void computeMean();
209  double interpolate(double x, double y) const;
210  double extrapolate(double x, double y) const;
211 
213  void constrain(double& value) const;
214 
215  ossim_uint32 index(int x, int y) const { return y*theSize.x + x; }
216 
217  double* theGridData;
221  double theMinValue;
222  double theMaxValue;
223  double theNullValue;
224  double theMeanValue;
225  double theDeviation;
229 
230 };
231 
232 #endif
233 
ossim_uint32 x
ossimDpt theOrigin
Definition: ossimDblGrid.h:219
ossimDpt theSpacing
Definition: ossimDblGrid.h:220
bool theMeanIsComputed
Definition: ossimDblGrid.h:226
#define OSSIMDLLEXPORT
double theDeviation
Definition: ossimDblGrid.h:225
double u
Definition: ossimDpt.h:164
ossim_uint32 y
bool isInside(const ossimDpt &p) const
Definition: ossimDblGrid.h:195
double value(const double &u, const double &v) const
Definition: ossimDblGrid.h:165
const ossimIpt & size() const
Definition: ossimDblGrid.h:187
void setDomainType(DomainType dt)
Definition: ossimDblGrid.h:156
void setNullValue(double value)
Definition: ossimDblGrid.h:183
double theMeanValue
Definition: ossimDblGrid.h:224
double maxValue() const
Definition: ossimDblGrid.h:176
double * theGridData
Definition: ossimDblGrid.h:217
void enableExtrapolation(bool arg=true)
Definition: ossimDblGrid.h:91
ostream & operator<<(ostream &out, const ossimAxes &axes)
Definition: ossimAxes.h:88
unsigned long getSizeInBytes() const
Definition: ossimDblGrid.h:190
#define OSSIM_DEFAULT_NULL_PIX_DOUBLE
double theNullValue
Definition: ossimDblGrid.h:223
yy_size_t size
double minValue() const
Definition: ossimDblGrid.h:175
void setMinValue(double value)
Definition: ossimDblGrid.h:181
unsigned int ossim_uint32
bool theExtrapIsEnabled
Definition: ossimDblGrid.h:227
double getNode(const ossimIpt &p) const
Definition: ossimDblGrid.h:111
ossimIpt theSize
Definition: ossimDblGrid.h:218
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
ossim_uint32 index(int x, int y) const
Definition: ossimDblGrid.h:215
const ossimDpt & origin() const
Definition: ossimDblGrid.h:188
ossim_int32 y
Definition: ossimIpt.h:142
DomainType theDomainType
Definition: ossimDblGrid.h:228
double nullValue() const
Definition: ossimDblGrid.h:177
ossim_int32 x
Definition: ossimIpt.h:141
double value(const ossimDpt &uv_point) const
Definition: ossimDblGrid.h:162
void setMaxValue(double value)
Definition: ossimDblGrid.h:182
void setNode(const ossimIpt &p, const double &value)
Definition: ossimDblGrid.h:107
double theMinValue
Definition: ossimDblGrid.h:221
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
double v
Definition: ossimDpt.h:165
double theMaxValue
Definition: ossimDblGrid.h:222
const ossimDpt & spacing() const
Definition: ossimDblGrid.h:189