Skip to content

Commit c6e0e75

Browse files
gshiromaGitHub Enterprise
authored andcommitted
Quick update to RTC loadDemFromProj() (#794)
* update RTC loadDemFromProj() margin parameters from geogrid units to DEM pixels * fix access to DEM raster methods * add docstrings and default values to RTC loadDemFromProj()
1 parent 13acf0b commit c6e0e75

File tree

2 files changed

+36
-16
lines changed

2 files changed

+36
-16
lines changed

cxx/isce3/geometry/RTC.cpp

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,15 +1131,15 @@ void computeRtcBilinearDistribution(isce3::io::Raster& dem_raster,
11311131
isce3::error::ErrorCode loadDemFromProj(isce3::io::Raster& dem_raster,
11321132
const double minX, const double maxX, const double minY,
11331133
const double maxY, DEMInterpolator* dem_interp_block,
1134-
isce3::core::ProjectionBase* proj, const double margin_x,
1135-
const double margin_y)
1134+
isce3::core::ProjectionBase* proj, const int dem_margin_x_in_pixels,
1135+
const int dem_margin_y_in_pixels)
11361136
{
11371137

1138-
Vec3 geogrid_min_xy = {minX - margin_x, std::min(minY, maxY) - margin_y, 0};
1139-
Vec3 geogrid_max_xy = {maxX + margin_x, std::max(minY, maxY) + margin_y, 0};
1138+
Vec3 geogrid_min_xy = {minX, std::min(minY, maxY), 0};
1139+
Vec3 geogrid_max_xy = {maxX, std::max(minY, maxY), 0};
11401140
double min_x, max_x, min_y, max_y;
11411141

1142-
if (proj->code() == dem_raster.getEPSG()) {
1142+
if (proj == nullptr || proj->code() == dem_raster.getEPSG()) {
11431143

11441144
Vec3 dem_min_xy, dem_max_xy;
11451145

@@ -1153,9 +1153,9 @@ isce3::error::ErrorCode loadDemFromProj(isce3::io::Raster& dem_raster,
11531153
std::unique_ptr<isce3::core::ProjectionBase> dem_proj(
11541154
isce3::core::createProj(dem_raster.getEPSG()));
11551155
auto p1_llh = proj->inverse({geogrid_min_xy[0], geogrid_min_xy[1], 0});
1156-
auto p2_llh = proj->inverse({geogrid_max_xy[0], geogrid_max_xy[1], 0});
1157-
auto p3_llh = proj->inverse({geogrid_min_xy[0], geogrid_min_xy[1], 0});
1158-
auto p4_llh = proj->inverse({geogrid_max_xy[0], geogrid_max_xy[1], 0});
1156+
auto p2_llh = proj->inverse({geogrid_min_xy[0], geogrid_max_xy[1], 0});
1157+
auto p3_llh = proj->inverse({geogrid_max_xy[0], geogrid_min_xy[1], 0});
1158+
auto p4_llh = proj->inverse({geogrid_max_xy[0], geogrid_max_xy[1], 0});;
11591159

11601160
Vec3 p1_xy, p2_xy, p3_xy, p4_xy;
11611161

@@ -1173,6 +1173,14 @@ isce3::error::ErrorCode loadDemFromProj(isce3::io::Raster& dem_raster,
11731173
std::max(p1_xy[1], p2_xy[1]), std::max(p3_xy[1], p4_xy[1]));
11741174
}
11751175

1176+
float margin_x = dem_margin_x_in_pixels * dem_raster.dx();
1177+
float margin_y = dem_margin_y_in_pixels * std::abs(dem_raster.dy());
1178+
1179+
min_x -= margin_x;
1180+
max_x += margin_x;
1181+
min_y -= margin_y;
1182+
max_y += margin_y;
1183+
11761184
isce3::error::ErrorCode error_code;
11771185
_Pragma("omp critical")
11781186
{
@@ -1250,21 +1258,18 @@ void _RunBlock(const int jmax, const int block_size,
12501258
(geogrid.spacingY() * (ii_0 + this_block_size_with_upsampling)) /
12511259
geogrid_upsampling;
12521260

1253-
double margin_x;
1254-
double margin_y;
1255-
12561261
if (geogrid.epsg() == dem_raster.getEPSG()) {
12571262
GetDemCoords = GetDemCoordsSameEpsg;
12581263

12591264
} else {
12601265
GetDemCoords = GetDemCoordsDiffEpsg;
12611266
}
12621267

1263-
margin_x = std::abs(geogrid.spacingX()) * 100;
1264-
margin_y = std::abs(geogrid.spacingY()) * 100;
1268+
const int dem_margin_in_pixels = 100;
12651269

12661270
auto error_code = loadDemFromProj(dem_raster, minX, maxX, minY, maxY,
1267-
&dem_interp_block, proj, margin_x, margin_y);
1271+
&dem_interp_block, proj, dem_margin_in_pixels,
1272+
dem_margin_in_pixels);
12681273

12691274
if (error_code != isce3::error::ErrorCode::Success) {
12701275
return;

cxx/isce3/geometry/RTC.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,26 @@ inline isce3::core::Vec3 GetDemCoordsDiffEpsg(double x, double y,
337337
const DEMInterpolator& dem_interp,
338338
isce3::core::ProjectionBase* input_proj);
339339

340+
/** Load DEM raster into a DEMInterpolator object around a given bounding box
341+
* in the same or different coordinate system as the DEM raster
342+
*
343+
* @param[in] dem_raster DEM raster
344+
* @param[in] minX Minimum X/easting position
345+
* @param[in] maxX Maximum X/easting position
346+
* @param[in] minY Minimum Y/northing position
347+
* @param[in] maxY Maximum Y/northing position
348+
* @param[out] dem_interp_block DEM interpolation object
349+
* @param[in] proj Projection object (nullptr to use same
350+
* DEM projection)
351+
* @param[in] dem_margin_x_in_pixels DEM X/easting margin in pixels
352+
* @param[in] dem_margin_y_in_pixels DEM Y/northing margin in pixels
353+
*/
340354
isce3::error::ErrorCode loadDemFromProj(isce3::io::Raster& dem_raster,
341355
const double minX, const double maxX, const double minY,
342356
const double maxY, DEMInterpolator* dem_interp_block,
343-
isce3::core::ProjectionBase* proj, const double margin_x,
344-
const double margin_y);
357+
isce3::core::ProjectionBase* proj = nullptr,
358+
const int dem_margin_x_in_pixels = 50,
359+
const int dem_margin_y_in_pixels = 50);
345360

346361
void areaProjIntegrateSegment(double y1, double y2, double x1, double x2,
347362
int length, int width,

0 commit comments

Comments
 (0)