@@ -1131,15 +1131,15 @@ void computeRtcBilinearDistribution(isce3::io::Raster& dem_raster,
1131
1131
isce3::error::ErrorCode loadDemFromProj (isce3::io::Raster& dem_raster,
1132
1132
const double minX, const double maxX, const double minY,
1133
1133
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 )
1136
1136
{
1137
1137
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 };
1140
1140
double min_x, max_x, min_y, max_y;
1141
1141
1142
- if (proj->code () == dem_raster.getEPSG ()) {
1142
+ if (proj == nullptr || proj ->code () == dem_raster.getEPSG ()) {
1143
1143
1144
1144
Vec3 dem_min_xy, dem_max_xy;
1145
1145
@@ -1153,9 +1153,9 @@ isce3::error::ErrorCode loadDemFromProj(isce3::io::Raster& dem_raster,
1153
1153
std::unique_ptr<isce3::core::ProjectionBase> dem_proj (
1154
1154
isce3::core::createProj (dem_raster.getEPSG ()));
1155
1155
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 });;
1159
1159
1160
1160
Vec3 p1_xy, p2_xy, p3_xy, p4_xy;
1161
1161
@@ -1173,6 +1173,14 @@ isce3::error::ErrorCode loadDemFromProj(isce3::io::Raster& dem_raster,
1173
1173
std::max (p1_xy[1 ], p2_xy[1 ]), std::max (p3_xy[1 ], p4_xy[1 ]));
1174
1174
}
1175
1175
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
+
1176
1184
isce3::error::ErrorCode error_code;
1177
1185
_Pragma (" omp critical" )
1178
1186
{
@@ -1250,21 +1258,18 @@ void _RunBlock(const int jmax, const int block_size,
1250
1258
(geogrid.spacingY () * (ii_0 + this_block_size_with_upsampling)) /
1251
1259
geogrid_upsampling;
1252
1260
1253
- double margin_x;
1254
- double margin_y;
1255
-
1256
1261
if (geogrid.epsg () == dem_raster.getEPSG ()) {
1257
1262
GetDemCoords = GetDemCoordsSameEpsg;
1258
1263
1259
1264
} else {
1260
1265
GetDemCoords = GetDemCoordsDiffEpsg;
1261
1266
}
1262
1267
1263
- margin_x = std::abs (geogrid.spacingX ()) * 100 ;
1264
- margin_y = std::abs (geogrid.spacingY ()) * 100 ;
1268
+ const int dem_margin_in_pixels = 100 ;
1265
1269
1266
1270
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);
1268
1273
1269
1274
if (error_code != isce3::error::ErrorCode::Success) {
1270
1275
return ;
0 commit comments