Skip to content

Commit

Permalink
Minor bugfixes for recent point2dem changes
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-alexandrov committed Jan 9, 2025
1 parent 9c215c7 commit edd05b0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
1 change: 1 addition & 0 deletions .github/workflows/update_mac_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ echo "Pushing the updated tarball to the cloud"
[email protected]:NeoGeographyToolkit/StereoPipelineTest.git
gh=/home/oalexan1/miniconda3/envs/gh/bin/gh
tag=0.0.1
echo Wipe the old tests and upload the new ones
$gh release -R $repo delete $tag # wipe old tarball
notes="Update test results"
$gh release -R $repo create $tag $binaries --title $tag --notes "$notes" # upload new
Expand Down
9 changes: 6 additions & 3 deletions docs/tools/point2dem.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ Use the option ``--t_srs`` to set a desired output projection. The projection
should be local to the current area of interest.

If this is not set, the ``point2dem`` program inherits the projection from the
input images, if those are mapprojected (:numref:`mapproj-example`). If the
input is a LAS file having a projection, that will be used. If the input is a
CSV file, the projection from ``--csv-srs`` will be used.
input images, if those are mapprojected (:numref:`mapproj-example`) and the
projection is not geographic.

If the input is a LAS file having a projection that is not geographic, that will
be used. If the input is a CSV file, the projection from ``--csv-srs`` will be
used.

If none of these are applicable, in the latest ASP (:numref:`release`),
``point2dem`` automatically finds a good local projection in meters. For ASP
Expand Down
16 changes: 13 additions & 3 deletions src/asp/Core/PointToDem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,12 @@ void chip_convert_to_tif(DemOptions const& opt,

} // End function chip_convert_to_tif

// Auto-computed local projection
// Auto-compute a local projection. It is assumed that the datum is known.
void setAutoProj(double lat, double lon,
vw::cartography::GeoReference & output_georef) {

std::string datum = output_georef.datum().name();
if (datum.find("WGS_1984") != std::string::npos) {
vw::cartography::Datum datum = output_georef.datum();
if (datum.name().find("WGS_1984") != std::string::npos) {

vw::cartography::Datum user_datum = output_georef.datum();
if (lat > 84)
Expand Down Expand Up @@ -275,6 +275,8 @@ void setProjection(DemOptions const& opt, cartography::GeoReference & output_geo
// Shorten notation
double lon = opt.proj_lon, lat = opt.proj_lat, s = opt.proj_scale;
double e = opt.false_easting, n = opt.false_northing;

vw::cartography::Datum datum = output_georef.datum();

switch (opt.projection) {
case SINUSOIDAL:
Expand Down Expand Up @@ -315,6 +317,14 @@ void setProjection(DemOptions const& opt, cartography::GeoReference & output_geo
vw::vw_throw(ArgumentErr() << "No projection was set.\n");
}

// Must re-apply the datum name, otherwise it gets lost.
// TODO(oalexan1): This fix should go deeper. Likely all the way to
// set_wkt(). But this will need very careful testing as that may
// have unintended consequences.
std::string lc_datum_name = boost::to_lower_copy(output_georef.datum().name());
if (lc_datum_name.find("unknown") != std::string::npos)
output_georef.set_datum(datum);

return;
}

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 @@ -570,8 +570,9 @@ int main(int argc, char *argv[]) {
}

// Finalize setting the projection. This is is normally auto-determined.
if ((opt.target_srs_string.empty() || opt.target_srs_string == "auto")
&& !opt.input_is_projected) {
if ((opt.target_srs_string.empty() || opt.target_srs_string == "auto") &&
(!have_input_georef || !output_georef.is_projected()) &&
!opt.input_is_projected) {
// Find the median lon lat and reapply this to the georef. Must be done
// after estimating the lonlat box.
if (std::isnan(opt.proj_lon) && std::isnan(opt.proj_lat))
Expand Down

0 comments on commit edd05b0

Please sign in to comment.