isce3  0.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
DEMInterpolator.h
1 // -*- C++ -*-
2 // -*- coding: utf-8 -*-
3 //
4 // Author: Bryan Riel
5 // Copyright 2017-2018
6 
7 #pragma once
8 
9 #include "forward.h"
10 
11 // pyre
12 #include <pyre/journal.h>
13 
14 // isce3::core
15 #include <isce3/core/forward.h>
16 #include <isce3/core/Constants.h>
17 #include <isce3/core/Interpolator.h>
18 
19 #include <isce3/io/forward.h>
20 
21 // DEMInterpolator declaration
23 
25 
26  public:
28  inline DEMInterpolator() :
29  _haveRaster{false},
30  _refHeight{0.0},
31  _meanValue{0.0},
32  _maxValue{0.0},
33  _interpMethod{isce3::core::BILINEAR_METHOD} {}
34 
36  inline DEMInterpolator(float height, int epsg = 4326) :
37  _haveRaster{false},
38  _refHeight{height},
39  _meanValue{height},
40  _maxValue{height},
41  _epsgcode{epsg},
42  _interpMethod{isce3::core::BILINEAR_METHOD} {}
43 
45  inline DEMInterpolator(float height,
47  int epsg = 4326) :
48  _haveRaster{false},
49  _refHeight{height},
50  _meanValue{height},
51  _maxValue{height},
52  _epsgcode{epsg},
53  _interpMethod{method} {}
54 
57 
59  void loadDEM(isce3::io::Raster &demRaster,
60  double minX, double maxX,
61  double minY, double maxY);
62 
64  void loadDEM(isce3::io::Raster &demRaster);
65 
66  // Print stats
67  void declare() const;
68 
70  void computeHeightStats(float &maxValue, float &meanValue,
71  pyre::journal::info_t &info);
72 
74  double interpolateLonLat(double lon, double lat) const;
76  double interpolateXY(double x, double y) const;
77 
79  double xStart() const { return _xstart; }
81  void xStart(double xstart) { _xstart = xstart; }
82 
84  double yStart() const { return _ystart; }
86  void yStart(double ystart) { _ystart = ystart; }
87 
89  double deltaX() const { return _deltax; }
91  void deltaX(double deltax) { _deltax = deltax; }
92 
94  double deltaY() const { return _deltay; }
96  void deltaY(double deltay) { _deltay = deltay; }
97 
99  double midX() const { return _xstart + 0.5*width()*_deltax; }
101  double midY() const { return _ystart + 0.5*length()*_deltay; }
103  cartesian_t midLonLat() const;
104 
106  bool haveRaster() const { return _haveRaster; }
107 
109  double refHeight() const { return _refHeight; }
111  void refHeight(double h) { _refHeight = h; }
112 
114  inline double meanHeight() const { return _meanValue; }
115 
117  inline double maxHeight() const { return _maxValue; }
118 
120  float * data() { return _dem.data(); }
121 
123  const float* data() const { return _dem.data(); }
124 
126  inline size_t width() const { return (_haveRaster ? _dem.width() : _width); }
128  inline void width(int width) { _width = width; }
129 
131  inline size_t length() const { return (_haveRaster ? _dem.length() : _length); }
133  inline void length(int length) { _length = length; }
134 
136  inline int epsgCode() const { return _epsgcode; }
138  inline void epsgCode(int epsgcode) { _epsgcode = epsgcode; }
139 
142  return _interpMethod;
143  }
146  _interpMethod = interpMethod;
147  }
148 
149  private:
150  // Flag indicating whether we have access to a DEM raster
151  bool _haveRaster;
152  // Constant value if no raster is provided
153  float _refHeight;
154  // Statistics
155  float _meanValue;
156  float _maxValue;
157  // Pointer to a ProjectionBase
158  int _epsgcode;
159  isce3::core::ProjectionBase * _proj = nullptr;
160  // Pointer to an Interpolator
161  isce3::core::dataInterpMethod _interpMethod;
162  isce3::core::Interpolator<float> * _interp = nullptr;
163  // 2D array for storing DEM subset
165  // Starting x/y for DEM subset and spacing
166  double _xstart, _ystart, _deltax, _deltay;
167  int _width, _length;
168 };
void width(int width)
Set width of DEM data used for interpolation.
Definition: DEMInterpolator.h:128
void computeHeightStats(float &maxValue, float &meanValue, pyre::journal::info_t &info)
Compute max and mean DEM height.
Definition: DEMInterpolator.cpp:167
dataInterpMethod
Enumeration type to indicate interpolation method.
Definition: Constants.h:23
const float * data() const
Get pointer to underlying DEM data.
Definition: DEMInterpolator.h:123
Definition: DEMInterpolator.h:22
void interpMethod(isce3::core::dataInterpMethod interpMethod)
Set interpolator method enum.
Definition: DEMInterpolator.h:145
double interpolateXY(double x, double y) const
Interpolate at native XY coordinates of DEM.
Definition: DEMInterpolator.cpp:235
void deltaX(double deltax)
Set X spacing.
Definition: DEMInterpolator.h:91
void refHeight(double h)
Set reference height of interpolator.
Definition: DEMInterpolator.h:111
void loadDEM(isce3::io::Raster &demRaster, double minX, double maxX, double minY, double maxY)
Read in subset of data from a DEM with a supported projection.
Definition: DEMInterpolator.cpp:32
isce3::core::dataInterpMethod interpMethod() const
Get interpolator method enum.
Definition: DEMInterpolator.h:141
double midX() const
Get mid X coordinate.
Definition: DEMInterpolator.h:99
double deltaX() const
Get X spacing.
Definition: DEMInterpolator.h:89
size_t length() const
Get length of DEM data used for interpolation.
Definition: DEMInterpolator.h:131
void deltaY(double deltay)
Set Y spacing.
Definition: DEMInterpolator.h:96
double maxHeight() const
Get max height value.
Definition: DEMInterpolator.h:117
cell_t * data()
Access to data buffer.
Definition: Matrix.icc:219
double midY() const
Get mid Y coordinate.
Definition: DEMInterpolator.h:101
float * data()
Get pointer to underlying DEM data.
Definition: DEMInterpolator.h:120
size_t length() const
Get matrix length.
Definition: Matrix.icc:357
double deltaY() const
Get Y spacing.
Definition: DEMInterpolator.h:94
bool haveRaster() const
Flag indicating whether a DEM raster has been loaded.
Definition: DEMInterpolator.h:106
cartesian_t midLonLat() const
Get mid longitude and latitude.
Definition: DEMInterpolator.cpp:198
Abstract base class for individual projections.
Definition: Projections.h:22
~DEMInterpolator()
Destructor.
Definition: DEMInterpolator.cpp:14
size_t width() const
Get width of DEM data used for interpolation.
Definition: DEMInterpolator.h:126
void yStart(double ystart)
Set starting Y coordinate.
Definition: DEMInterpolator.h:86
DEMInterpolator(float height, isce3::core::dataInterpMethod method, int epsg=4326)
Constructor with custom reference height and custom interpolator method.
Definition: DEMInterpolator.h:45
double meanHeight() const
Get mean height value.
Definition: DEMInterpolator.h:114
double xStart() const
Get starting X coordinate.
Definition: DEMInterpolator.h:79
void epsgCode(int epsgcode)
Set EPSG code for input DEM.
Definition: DEMInterpolator.h:138
void length(int length)
Set length of DEM data used for interpolation.
Definition: DEMInterpolator.h:133
void xStart(double xstart)
Set starting X coordinate.
Definition: DEMInterpolator.h:81
DEMInterpolator(float height, int epsg=4326)
Constructor with custom reference height and bilinear interpolation.
Definition: DEMInterpolator.h:36
int epsgCode() const
Get EPSG code for input DEM.
Definition: DEMInterpolator.h:136
size_t width() const
Get matrix width.
Definition: Matrix.icc:349
DEMInterpolator()
Default constructor with reference height of 0, bilinear interpolation.
Definition: DEMInterpolator.h:28
double yStart() const
Get starting Y coordinate.
Definition: DEMInterpolator.h:84
double refHeight() const
Get reference height of interpolator.
Definition: DEMInterpolator.h:109
Data structure meant to handle Raster I/O operations.
Definition: Raster.h:34
double interpolateLonLat(double lon, double lat) const
Interpolate at a given longitude and latitude.
Definition: DEMInterpolator.cpp:211

Generated for ISCE3.0 by doxygen 1.8.5.