Skip to content

Commit ded2877

Browse files
authored
Add PROJ projection (#5317)
* Rectifying 9.0.0 changes * Explicitly add proj to ISIS deps * Fix field output in qview advanced tracking tool * Initial addition of PROJ into ISIS * Added changelog entry * Near finished state of the PROJ plugin * Exposed using PROJ strings in cam2map * Fixed radii acquisition in IProj * Adjusted how radii is acquired from proj and remove equator check from XYRange * Clean up headers in base projection classes * Fix reading existing ISIS mapping groups from geotiffs * Fixed changelog * Get ellipsoid information from proj crs if no radii in mapping group * Added IProj tests * Remove forced planetographic lat conversion in IProj * Update tests to resemble ISIS equirectangular projection tests * Update cam2map and IProj to extract necessary parameters and error reporting from proj * Updated useproj option exclusions * Initial stub in for useproj example * Added proj example jpegs * Fixed cam2map xml spacing * Finished up cam2map example * Added thumbnail assets
1 parent 5d79fc1 commit ded2877

File tree

18 files changed

+725
-210
lines changed

18 files changed

+725
-210
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ ctest FunctionalTestJigsawApollo to validate this output. [#5710](https://github
5353
- Added the ability to disable individual options for parameters in ISIS GUIs [#5849](https://github.com/DOI-USGS/ISIS3/pull/5849)
5454
- Added PAD or SHRINK options to crop for crops that extend beyond the source image [#5843](https://github.com/DOI-USGS/ISIS3/pull/5843)
5555
- Added std:: namespace for isinf, fixes build errors for some versions of c++
56+
- Adds PROJ into ISIS, and exposes the capability with a new class called IProj. [#5317](https://github.com/DOI-USGS/ISIS3/pull/5317)
5657

5758
### Changed
5859
- Removed Arm dependency on xalan-c, as it does not build for now on conda-forge. This requires turning off doc building on Arm. Also changed some variables to avoid name clashes on Arm with clang 16. [#5802](https://github.com/DOI-USGS/ISIS3/pull/5802)

isis/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ find_package(NN REQUIRED)
305305
find_package(OpenCV 3.1.0 REQUIRED)
306306
find_package(PCL REQUIRED)
307307
find_package(Protobuf REQUIRED CONFIG)
308+
find_package(PROJ REQUIRED)
308309
find_package(Qwt 6 REQUIRED)
309310
find_package(SuperLU 4.3 REQUIRED)
310311
find_package(SpiceQL REQUIRED)
142 KB
Loading
11.6 MB
Loading
40.6 KB
Loading
1.63 MB
Loading

isis/src/base/apps/cam2map/cam2map.cpp

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include "Target.h"
1212
#include "TProjection.h"
1313

14+
#include <proj.h>
15+
1416
using namespace std;
1517

1618
namespace Isis {
@@ -31,7 +33,61 @@ namespace Isis {
3133

3234
// Get the map projection file provided by the user
3335
Pvl userMap;
34-
userMap.read(ui.GetFileName("MAP"));
36+
if (ui.GetBoolean("USEPROJ")) {
37+
PvlGroup mappingGroup("Mapping");
38+
mappingGroup.addKeyword(PvlKeyword("ProjectionName", "IProj"));
39+
mappingGroup.addKeyword(PvlKeyword("ProjStr", ui.GetAsString("PROJString")));
40+
QString projStr = mappingGroup["ProjStr"][0];
41+
PJ_CONTEXT *projContext = proj_context_create();
42+
proj_log_level(projContext, PJ_LOG_ERROR);
43+
44+
/* Create a projection. */
45+
PJ *outputProj = proj_create(projContext, projStr.toStdString().c_str());
46+
47+
if (!outputProj) {
48+
proj_context_destroy(projContext);
49+
QString msg = "Unable to create projection from [" + projStr + "].";
50+
throw IException(IException::User, msg, _FILEINFO_);
51+
}
52+
53+
// Read the radii information from the PROJ projection
54+
PJ *ellipsoid = proj_get_ellipsoid(projContext, outputProj);
55+
56+
if (ellipsoid == nullptr) {
57+
proj_destroy(outputProj);
58+
proj_context_destroy(projContext);
59+
QString msg = "Unable to create ellipsoid from [" + projStr + "]";
60+
throw IException(IException::User, msg, _FILEINFO_);
61+
}
62+
63+
double equatorialRadius;
64+
double polarRadius;
65+
66+
int res = proj_ellipsoid_get_parameters(projContext, ellipsoid,
67+
&equatorialRadius,
68+
&polarRadius,
69+
nullptr,
70+
nullptr);
71+
72+
proj_destroy(ellipsoid);
73+
proj_destroy(outputProj);
74+
proj_context_destroy(projContext);
75+
76+
if (res == 0) {
77+
QString msg = "Unable to get ellipsoid information from [" + projStr + "]";
78+
throw IException(IException::User, msg, _FILEINFO_);
79+
}
80+
81+
mappingGroup.addKeyword(PvlKeyword("EquitorialRadius", toString(equatorialRadius, 15)));
82+
mappingGroup.addKeyword(PvlKeyword("PolarRadius", toString(polarRadius, 15)));
83+
mappingGroup.addKeyword(PvlKeyword("LatitudeType", "Planetographic"));
84+
mappingGroup.addKeyword(PvlKeyword("LongitudeDirection", "PositiveEast"));
85+
mappingGroup.addKeyword(PvlKeyword("LongitudeDomain", "180", "degrees"));
86+
userMap.addGroup(mappingGroup);
87+
}
88+
else {
89+
userMap.read(ui.GetFileName("MAP"));
90+
}
3591
PvlGroup &userGrp = userMap.findGroup("Mapping", Pvl::Traverse);
3692

3793
cam2map(&icube, userMap, userGrp, ui, log);

0 commit comments

Comments
 (0)