Skip to content

Commit

Permalink
Flesh out prism2asp.cc. Bigfix in parsing time. Other minor.
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-alexandrov committed Nov 12, 2024
1 parent 0bdd3c4 commit 9036f62
Show file tree
Hide file tree
Showing 6 changed files with 224 additions and 29 deletions.
8 changes: 5 additions & 3 deletions src/asp/Camera/PeruSatXML.cc
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,11 @@ void PeruSatXML::read_ephemeris(xercesc::DOMElement* ephemeris) {
std::string time_str, position_str, velocity_str;
Vector3 position_vec, velocity_vec;

cast_xmlch(get_node<DOMElement>(curr_element, "LOCATION_XYZ")->getTextContent(), position_str);
cast_xmlch(get_node<DOMElement>(curr_element, "VELOCITY_XYZ")->getTextContent(), velocity_str);
cast_xmlch(get_node<DOMElement>(curr_element, "TIME")->getTextContent(), time_str);
cast_xmlch(get_node<DOMElement>(curr_element, "LOCATION_XYZ")->getTextContent(),
position_str);
cast_xmlch(get_node<DOMElement>(curr_element, "VELOCITY_XYZ")->getTextContent(),
velocity_str);
cast_xmlch(get_node<DOMElement>(curr_element, "TIME")->getTextContent(), time_str);

bool is_start_time = false;
double time = PeruSatXML::convert_time(time_str, is_start_time);
Expand Down
5 changes: 2 additions & 3 deletions src/asp/Camera/TimeProcessing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ std::string fix_millisecond(std::string const& in_str) {
}

// See if to append more
while (num_digits_after_dot < 6) {
while (found_dot && num_digits_after_dot < 6) {
out_str += "0";
num_digits_after_dot++;
}

} else {

// The last character is not a digit, it is likely a "Z"
while (num_digits_after_dot < 6) {
while (found_dot && num_digits_after_dot < 6) {
// Append zeros
out_str += "0";
num_digits_after_dot++;
Expand All @@ -94,7 +94,6 @@ boost::posix_time::ptime parse_time(std::string const& s) {
// Ensure there are exactly 6 digits for the millisecond or else
// Boost will complain.
s2 = asp::fix_millisecond(s2);

boost::posix_time::ptime time = boost::posix_time::time_from_string(s2);

return time;
Expand Down
4 changes: 4 additions & 0 deletions src/asp/Tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ add_executable(aster2asp aster2asp.cc)
target_link_libraries(aster2asp AspSessions)
install(TARGETS aster2asp DESTINATION bin)

add_executable(prism2asp prism2asp.cc)
target_link_libraries(prism2asp AspSessions)
install(TARGETS prism2asp DESTINATION bin)

add_executable(bundle_adjust bundle_adjust.cc)
target_link_libraries(bundle_adjust AspSessions ${SOLVER_LIBRARIES})
install(TARGETS bundle_adjust DESTINATION bin)
Expand Down
31 changes: 17 additions & 14 deletions src/asp/Tools/dem_mosaic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ void priorityBlend(double out_nodata_value,
GeoReference crop_georef = crop(out_georef, bbox);
std::ostringstream os;
os << "tile_weight_" << clip_iter << ".tif";
vw_out() << "\nWriting: " << os.str() << std::endl;
vw_out() << "\nWriting: " << os.str() << "\n";
bool has_georef = true, has_nodata = true;
block_write_gdal_image(os.str(), weight_vec[clip_iter],
has_georef, crop_georef,
Expand Down Expand Up @@ -888,7 +888,7 @@ class DemMosaicView: public ImageViewBase<DemMosaicView>{
// of the precision of the inputs, for increased accuracy.
// - The image data buffers are initialized here
ImageView<double> tile (bbox.width(), bbox.height()); // the output tile (in most cases)
ImageView<double> weights(bbox.width(), bbox.height()); // accumulated weights (in most cases)
ImageView<double> weights(bbox.width(), bbox.height()); // weights (in most cases)
fill(tile, m_opt.out_nodata_value);
fill(weights, 0.0);

Expand Down Expand Up @@ -1054,8 +1054,10 @@ class DemMosaicView: public ImageViewBase<DemMosaicView>{
}

// Compute linear weights
ImageView<double> local_wts = grassfire(notnodata(select_channel(dem, 0), nodata_value),
m_opt.no_border_blend);
ImageView<double> local_wts
= grassfire(notnodata(select_channel(dem, 0), nodata_value),
m_opt.no_border_blend);

local_wts_orig = local_wts;
if (m_opt.use_centerline_weights) {
// Erode based on grassfire weights, and then overwrite the grassfire
Expand All @@ -1070,7 +1072,8 @@ class DemMosaicView: public ImageViewBase<DemMosaicView>{
}
// TODO(oalexan1): Generalize this modification and move it to VW.
centerline_weights2(create_mask_less_or_equal(select_channel(dem2, 0), nodata_value),
local_wts, m_bias, -1.0);
local_wts, m_bias, -1.0);

} // End centerline weights case

// If we don't limit the weights from above, we will have tiling artifacts,
Expand Down Expand Up @@ -1119,7 +1122,7 @@ class DemMosaicView: public ImageViewBase<DemMosaicView>{
std::ostringstream os;
os << "weights_" << dem_iter << "_" << bbox.min().x() << "_" << bbox.min().y()
<< ".tif";
vw_out() << "Writing: " << os.str() << std::endl;
vw_out() << "Writing: " << os.str() << "\n";
bool has_georef = true, has_nodata = true;
block_write_gdal_image(os.str(), local_wts,
has_georef, georef,
Expand Down Expand Up @@ -1216,7 +1219,7 @@ class DemMosaicView: public ImageViewBase<DemMosaicView>{
// pixels for each mapprojected image/DEM when doing SfS.
// The documentation has a longer explanation.
vw_out() << "\n" << bbox << " " << dem_vec[i]
<< " pixel sum: " << tile_sum[i] << std::endl;
<< " pixel sum: " << tile_sum[i] << "\n";
}
int max_index = std::distance(tile_sum.begin(),
std::max_element(tile_sum.begin(), tile_sum.end()));
Expand Down Expand Up @@ -1724,7 +1727,7 @@ int main(int argc, char *argv[]) {
opt.out_nodata_value = static_cast<double>(-std::numeric_limits<RealT>::max());
}

vw_out() << "Using output no-data value: " << opt.out_nodata_value << std::endl;
vw_out() << "Using output no-data value: " << opt.out_nodata_value << "\n";

// Form the mosaic georef. The georef of the first DEM is used as
// initial guess unless user wants to change the resolution and projection.
Expand Down Expand Up @@ -1883,7 +1886,7 @@ int main(int argc, char *argv[]) {

if (opt.tile_index >= num_tiles) {
vw_out() << "Tile with index: " << opt.tile_index
<< " is out of bounds." << std::endl;
<< " is out of bounds." << "\n";
return 0;
}

Expand Down Expand Up @@ -2040,7 +2043,7 @@ int main(int argc, char *argv[]) {

// Raster the tile to disk. Optionally cast to int (may be
// useful for mosaicking ortho images).
vw_out() << "Writing: " << dem_tile << std::endl;
vw_out() << "Writing: " << dem_tile << "\n";
bool has_georef = true, has_nodata = true;
TerminalProgressCallback tpc("asp", "\t--> ");
if (opt.output_type == "Float32")
Expand Down Expand Up @@ -2081,9 +2084,9 @@ int main(int argc, char *argv[]) {
vw_throw(NoImplErr() << "Unsupported output type: " << opt.output_type << ".\n");

vw_out() << "Number of valid (not no-data) pixels written: " << num_valid_pixels
<< "."<< std::endl;
<< ".\n";
if (num_valid_pixels == 0) {
vw_out() << "Removing tile with no valid pixels: " << dem_tile << std::endl;
vw_out() << "Removing tile with no valid pixels: " << dem_tile << "\n";
boost::filesystem::remove(dem_tile);
}

Expand All @@ -2092,10 +2095,10 @@ int main(int argc, char *argv[]) {
// Write the name of each DEM file that was used together with its index
if (opt.save_index_map) {
std::string index_map = opt.out_prefix + "-index-map.txt";
vw_out() << "Writing: " << index_map << std::endl;
vw_out() << "Writing: " << index_map << "\n";
std::ofstream ih(index_map.c_str());
for (int dem_iter = 0; dem_iter < (int)loaded_dems.size(); dem_iter++) {
ih << opt.dem_files[dem_iter] << ' ' << dem_iter << std::endl;
ih << opt.dem_files[dem_iter] << ' ' << dem_iter << "\n";
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/asp/Tools/point2dem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,15 @@ void handle_arguments(int argc, char *argv[], DemOptions& opt) {
// Extract the list of numbers from the input string
split_number_string(dem_spacing1, opt.dem_spacing);

// Check for for non-numeric or non-positive input
// Check for for non-positive input
for (size_t i = 0; i < opt.dem_spacing.size(); i++) {
if (opt.dem_spacing[i] <= 0.0)
vw_throw(ArgumentErr() << "The DEM spacing must be positive.\n" );
}

// Make sure we have a number
if (opt.dem_spacing.size() == 0)
opt.dem_spacing.push_back(0.0); // Make sure we have a number
opt.dem_spacing.push_back(0.0);

bool spacing_provided = false;
for (size_t i = 0; i < opt.dem_spacing.size(); i++) {
Expand Down
Loading

0 comments on commit 9036f62

Please sign in to comment.