isce3 0.25.0
Loading...
Searching...
No Matches
DEMInterpolator.h
1// -*- C++ -*-
2// -*- coding: utf-8 -*-
3//
4// Author: Bryan Riel
5// Copyright 2017-2018
6
7#pragma once
8
9#include <memory>
10#include <string>
11#include "forward.h"
12
13// pyre
14#include <pyre/journal.h>
15
16// isce3::core
17#include <isce3/core/forward.h>
18#include <isce3/io/forward.h>
19
20#include <isce3/core/Constants.h>
21#include <isce3/core/Interpolator.h>
22#include <isce3/error/ErrorCode.h>
23
24// DEMInterpolator declaration
26
27 using cartesian_t = isce3::core::Vec3;
28
29 public:
31 inline DEMInterpolator(float height = 0.0, int epsg = 4326) :
32 _haveRaster{false},
33 _refHeight{height},
34 _haveStats{true},
35 _minValue{height},
36 _meanValue{height},
37 _maxValue{height},
38 _epsgcode{epsg},
39 _interpMethod{isce3::core::BILINEAR_METHOD} {}
40
42 inline DEMInterpolator(float height,
43 isce3::core::dataInterpMethod method,
44 int epsg = 4326) :
45 _haveRaster{false},
46 _refHeight{height},
47 _haveStats{true},
48 _minValue{height},
49 _meanValue{height},
50 _maxValue{height},
51 _epsgcode{epsg},
52 _interpMethod{method} {}
53
62 isce3::error::ErrorCode loadDEM(isce3::io::Raster& demRaster,
63 double min_x, double max_x, double min_y, double max_y,
64 const int dem_raster_band = 1);
65
70 void loadDEM(isce3::io::Raster &demRaster,
71 const int dem_raster_band = 1);
72
73 // Print stats
74 void declare() const;
75
87 void computeMinMaxMeanHeight(float &minValue, float &maxValue,
88 float &meanValue);
89
91 double interpolateLonLat(double lon, double lat) const;
93 double interpolateXY(double x, double y) const;
94
96 double xStart() const { return _xstart; }
98 void xStart(double xstart) { _xstart = xstart; }
99
101 double yStart() const { return _ystart; }
103 void yStart(double ystart) { _ystart = ystart; }
104
106 double deltaX() const { return _deltax; }
108 void deltaX(double deltax) { _deltax = deltax; }
109
111 double deltaY() const { return _deltay; }
113 void deltaY(double deltay) { _deltay = deltay; }
114
116 double midX() const { return _xstart + 0.5*width()*_deltax; }
118 double midY() const { return _ystart + 0.5*length()*_deltay; }
120 cartesian_t midLonLat() const;
121
123 bool haveRaster() const { return _haveRaster; }
124
126 double refHeight() const { return _refHeight; }
128 void refHeight(double h) {
129 _refHeight = h;
130 if (not haveRaster()) {
131 _minValue = h;
132 _meanValue = h;
133 _maxValue = h;
134 }
135 }
136
138 bool haveStats() const { return _haveStats; }
139
141 inline float meanHeight() const {
142 validateStatsAccess("meanHeight");
143 return _meanValue;
144 }
145
147 inline float maxHeight() const {
148 validateStatsAccess("maxHeight");
149 return _maxValue;
150 }
151
153 inline float minHeight() const {
154 validateStatsAccess("minHeight");
155 return _minValue;
156 }
157
159 float * data() { return _dem.data(); }
160
162 const float* data() const { return _dem.data(); }
163
165 inline size_t width() const { return (_haveRaster ? _dem.width() : _width); }
167 inline void width(int width) { _width = width; }
168
170 inline size_t length() const { return (_haveRaster ? _dem.length() : _length); }
172 inline void length(int length) { _length = length; }
173
175 inline int epsgCode() const { return _epsgcode; }
177 void epsgCode(int epsgcode);
178
180 inline isce3::core::ProjectionBase* proj() const {return _proj.get(); }
181
183 inline isce3::core::dataInterpMethod interpMethod() const {
184 return _interpMethod;
185 }
186
187 inline void interpMethod(isce3::core::dataInterpMethod interpMethod) {
188 _interpMethod = interpMethod;
189 }
190
191 private:
192 // Flag indicating whether we have access to a DEM raster
193 bool _haveRaster;
194 // Constant value if no raster is provided
195 float _refHeight;
196 // Statistics
197 bool _haveStats;
198 float _minValue;
199 float _meanValue;
200 float _maxValue;
201 // Pointer to a ProjectionBase
202 int _epsgcode;
203 std::shared_ptr<isce3::core::ProjectionBase> _proj;
204 // Pointer to an Interpolator
205 isce3::core::dataInterpMethod _interpMethod;
206 std::shared_ptr<isce3::core::Interpolator<float>> _interp;
207 // 2D array for storing DEM subset
209 // Starting x/y for DEM subset and spacing
210 double _xstart, _ystart, _deltax, _deltay;
211 int _width, _length;
212
213 // Check if stats are accessed before they're computed.
214 void validateStatsAccess(const std::string& method) const;
215};
Data structure for a 2D row-major matrix.
Definition Matrix.h:23
Abstract base class for individual projections.
Definition Projections.h:21
Definition DEMInterpolator.h:25
isce3::core::dataInterpMethod interpMethod() const
Get interpolator method enum.
Definition DEMInterpolator.h:183
double refHeight() const
Get reference height of interpolator.
Definition DEMInterpolator.h:126
int epsgCode() const
Get EPSG code for input DEM.
Definition DEMInterpolator.h:175
void yStart(double ystart)
Set starting Y coordinate.
Definition DEMInterpolator.h:103
const float * data() const
Get pointer to underlying DEM data.
Definition DEMInterpolator.h:162
double deltaY() const
Get Y spacing.
Definition DEMInterpolator.h:111
void deltaX(double deltax)
Set X spacing.
Definition DEMInterpolator.h:108
float * data()
Get pointer to underlying DEM data.
Definition DEMInterpolator.h:159
bool haveRaster() const
Flag indicating whether a DEM raster has been loaded.
Definition DEMInterpolator.h:123
double yStart() const
Get starting Y coordinate.
Definition DEMInterpolator.h:101
float minHeight() const
Get min height value.
Definition DEMInterpolator.h:153
void deltaY(double deltay)
Set Y spacing.
Definition DEMInterpolator.h:113
void computeMinMaxMeanHeight(float &minValue, float &maxValue, float &meanValue)
Compute min, max, and mean DEM height.
Definition DEMInterpolator.cpp:515
double xStart() const
Get starting X coordinate.
Definition DEMInterpolator.h:96
float meanHeight() const
Get mean height value.
Definition DEMInterpolator.h:141
DEMInterpolator(float height=0.0, int epsg=4326)
Constructor with custom reference height and bilinear interpolation.
Definition DEMInterpolator.h:31
void interpMethod(isce3::core::dataInterpMethod interpMethod)
Set interpolator method enum.
Definition DEMInterpolator.h:187
void refHeight(double h)
Set reference height of interpolator.
Definition DEMInterpolator.h:128
double deltaX() const
Get X spacing.
Definition DEMInterpolator.h:106
isce3::core::ProjectionBase * proj() const
Get Pointer to a ProjectionBase.
Definition DEMInterpolator.h:180
isce3::error::ErrorCode loadDEM(isce3::io::Raster &demRaster, double min_x, double max_x, double min_y, double max_y, const int dem_raster_band=1)
Read in subset of data from a DEM with a supported projection.
Definition DEMInterpolator.cpp:29
cartesian_t midLonLat() const
Get mid longitude and latitude.
Definition DEMInterpolator.cpp:580
float maxHeight() const
Get max height value.
Definition DEMInterpolator.h:147
double midY() const
Get mid Y coordinate.
Definition DEMInterpolator.h:118
double midX() const
Get mid X coordinate.
Definition DEMInterpolator.h:116
bool haveStats() const
Flag indicating if stats are already known.
Definition DEMInterpolator.h:138
size_t width() const
Get width of DEM data used for interpolation.
Definition DEMInterpolator.h:165
double interpolateLonLat(double lon, double lat) const
Interpolate at a given longitude and latitude.
Definition DEMInterpolator.cpp:593
size_t length() const
Get length of DEM data used for interpolation.
Definition DEMInterpolator.h:170
void length(int length)
Set length of DEM data used for interpolation.
Definition DEMInterpolator.h:172
double interpolateXY(double x, double y) const
Interpolate at native XY coordinates of DEM.
Definition DEMInterpolator.cpp:618
void xStart(double xstart)
Set starting X coordinate.
Definition DEMInterpolator.h:98
DEMInterpolator(float height, isce3::core::dataInterpMethod method, int epsg=4326)
Constructor with custom reference height and custom interpolator method.
Definition DEMInterpolator.h:42
void width(int width)
Set width of DEM data used for interpolation.
Definition DEMInterpolator.h:167
Data structure meant to handle Raster I/O operations.
Definition Raster.h:32
base interpolator is an abstract base class
Definition BinarySearchFunc.cpp:5

Generated for ISCE3.0 by doxygen 1.13.2.