Skip to content

Commit

Permalink
Merge pull request #108 from rogerfraser/master
Browse files Browse the repository at this point in the history
New geoid functionality and additional code coverage
  • Loading branch information
rogerfraser committed Apr 29, 2021
2 parents 6522532 + 2cfdde2 commit 4555183
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 5 deletions.
2 changes: 2 additions & 0 deletions dynadjust/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ if (BUILD_TESTING)
add_test (NAME geo-ntv2-create-02 COMMAND $<TARGET_FILE:dnageoidwrapper> -d ${CMAKE_SOURCE_DIR}/../sampleData/ausgeoid09_gda94_v1.01_clip_1x1.dat -c -g ausgeoid_clip_1.0.1.0.gsb --grid-shift radians --grid-version 1.0.1.0 --system-fr ___GDA94 --system-to ___AHD71 --sub-grid-n 1D-grid --creation 21.04.2021 --update 22.04.2021)
add_test (NAME geo-ntv2-export-01 COMMAND $<TARGET_FILE:dnageoidwrapper> -g ${CMAKE_SOURCE_DIR}/../sampleData/gnss-network-geoid.gsb --export-ntv2-asc)
add_test (NAME geo-ntv2-export-02 COMMAND $<TARGET_FILE:dnageoidwrapper> -g ./gnss-network-geoid.gsb.asc --export-ntv2-gsb)
add_test (NAME imp-outside COMMAND $<TARGET_FILE:dnaimportwrapper> -n outside ${CMAKE_SOURCE_DIR}/../sampleData/urban-network.stn ${CMAKE_SOURCE_DIR}/../sampleData/urban-network.msr)
add_test (NAME geo-outside COMMAND $<TARGET_FILE:dnageoidwrapper> outside -g ${CMAKE_SOURCE_DIR}/../sampleData/gnss-network-geoid.gsb --convert --verbose 1)

# bash command to check results
add_test (NAME test-gnss-network COMMAND bash -c "diff <(tail -n +53 gnss.simult.adj) <(tail -n +53 ${CMAKE_SOURCE_DIR}/../sampleData/gnss.simult.adj.expected)")
Expand Down
58 changes: 54 additions & 4 deletions dynadjust/dynadjust/dnageoidwrapper/dnageoidwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,51 @@ bool ExportNTv2GridToBinary(dna_geoid_interpolation* g, const char* dat_gridfile
return true;
}

void ReturnBadStationRecords(dna_geoid_interpolation* g, project_settings& p)
{
string records, filename(p.g.network_name);
string badpointsPath(formPath<string>(p.g.output_folder, filename, "gil"));
stringstream ss;
std::ofstream badpoints_log;

ss << "- Error: Could not open " << filename << " for writing." << endl;
try {
// Create dynadjust log file. Throws runtime_error on failure.
file_opener(badpoints_log, badpointsPath);
}
catch (const runtime_error& e) {
ss << e.what();
throw boost::enable_current_exception(runtime_error(ss.str()));
}
catch (...) {
throw boost::enable_current_exception(runtime_error(ss.str()));
}

// Print formatted header
print_file_header(badpoints_log, "DYNADJUST GEOID INTERPOLATION LOG FILE");

badpoints_log << setw(PRINT_VAR_PAD) << left << "File name:" << badpointsPath << endl << endl;

badpoints_log << setw(PRINT_VAR_PAD) << left << "Command line arguments: ";
badpoints_log << p.n.command_line_arguments << endl << endl;

badpoints_log << setw(PRINT_VAR_PAD) << left << "Network name:" << p.g.network_name << endl;
badpoints_log << setw(PRINT_VAR_PAD) << left << "Stations file:" << system_complete(p.n.bst_file).string() << endl;
badpoints_log << setw(PRINT_VAR_PAD) << left << "Geoid model: " << system_complete(p.n.ntv2_geoid_file).string() << endl << endl;

badpoints_log << setw(PRINT_VAR_PAD) << left << "Stations not interpolated:" << g->PointsNotInterpolated() << endl << endl;

records = g->ReturnBadStationRecords();

badpoints_log << records << endl;

badpoints_log.close();

cout << endl << " See " << badpointsPath << " to view the list of stations for which an" << endl <<
" N-value could not be interpolated." << endl;

}



bool createGridIndex(dna_geoid_interpolation* g, const char* gridfilePath, const char* gridfileType, const int& quiet)
Expand Down Expand Up @@ -1018,15 +1063,20 @@ int main(int argc, char* argv[])
else
cout << " stations";

cout << " could not be interpolated";
cout << " could not be interpolated. ";

if (p.g.verbose > 0)
{
cout << ":" << endl;
cout << g.ReturnBadStationRecords();
try {
ReturnBadStationRecords(&g, p);
}
catch (const runtime_error& e) {
// print error message, and continue
cout << "- Error: " << e.what() << endl;
}
}
else
cout << ". To view the list of stations " << endl <<
cout << "To view the list of stations " << endl <<
" for which a height could not be interpolated, call " << __BINARY_NAME__ << " with --verbose-level 1." << endl;
}
// If this point is reached, then this wrapper must have been called
Expand Down
2 changes: 1 addition & 1 deletion dynadjust/dynadjust/dynadjust/dynadjust.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ int main(int argc, char* argv[])

ss << "- Error: Could not open dynadjust.log for writing." << endl;
try {
// Create segmentation file. Throws runtime_error on failure.
// Create dynadjust log file. Throws runtime_error on failure.
file_opener(dynadjust_log, dynadjustLogFilePath);
}
catch (const runtime_error& e) {
Expand Down

0 comments on commit 4555183

Please sign in to comment.