Isis 3 Programmer Reference
LoCameraFiducialMap.cpp
1
7/* SPDX-License-Identifier: CC0-1.0 */
8
9#include "LoCameraFiducialMap.h"
10
11#include "Affine.h"
12#include "CameraGroundMap.h"
13#include "CameraSkyMap.h"
14#include "IString.h"
15
16using namespace std;
17
18namespace Isis {
28 // Get the Instrument label information needed to define the fiducial map for this frame
29 p_naifIkCode = naifIkCode;
30 ReadFiducials(inst);
31
32 // Set the x-axis direction. The medium camera is reversed.
33 int xdir;
34 if(naifIkCode % 2 == 0) {
35 xdir = -1;
36 }
37 else {
38 xdir = 1;
39 }
40 CreateTrans(xdir);
41 }
42
43
54
55 // Try to read the fiducials from the labels
56 try {
57 // Fiducial mapping to define the Focal Plane map
58 PvlKeyword &fSamps = inst["FiducialSamples"];
59 PvlKeyword &fLines = inst["FiducialLines"];
60 PvlKeyword &fXs = inst["FiducialXCoordinates"];
61 PvlKeyword &fYs = inst["FiducialYCoordinates"];
62
63 for(int i = 0; i < fSamps.size(); i++) {
64 p_fidSamples.push_back(toDouble(fSamps[i]));
65 p_fidLines.push_back(toDouble(fLines[i]));
66 p_fidXCoords.push_back(toDouble(fXs[i]));
67 p_fidYCoords.push_back(toDouble(fYs[i]));
68 }
69 }
70 catch(IException &e) {
71 string msg = "Unable to read fiducial mapping from cube labels - ";
72 msg += "Input cube must be processed in Isis 2 through lofixlabel ";
73 msg += "and converted to Isis with pds2isis";
74 throw IException(e, IException::User, msg, _FILEINFO_);
75 }
76 }
77
78
87 // Setup focal plane map
88 Affine *fptrans = new Affine();
89
90 try {
91 fptrans->Solve(&p_fidSamples[0], (double *) &p_fidLines[0],
92 (double *) &p_fidXCoords[0], (double *) &p_fidYCoords[0],
93 p_fidSamples.size());
94
95 }
96 catch(IException &e) {
97 string msg = "Unable to create fiducial map.";
98 throw IException(IException::User, msg, _FILEINFO_);
99 }
100
101 // Get the coefficients
102 vector<double> transx;
103 vector<double> transy;
104 transx = fptrans->Coefficients(1);
105 transy = fptrans->Coefficients(2);
106
107 // Medium camera has a reversed x-axis
108 for(int icoef = 0; icoef < 3; icoef++) {
109 transx[icoef] *= xdir;
110 };
111
112 // Correct the Affine order - move the constant to the front
113 transx.insert(transx.begin(), transx[2]);
114 transx.pop_back();
115 transy.insert(transy.begin(), transy[2]);
116 transy.pop_back();
117
118 string icode = "INS" + IString(p_naifIkCode);
119 string icodex = icode + "_TRANSX";
120 string icodey = icode + "_TRANSY";
121 pdpool_c(icodex.c_str(), 3, (double( *)) &transx[0]);
122 pdpool_c(icodey.c_str(), 3, (double( *)) &transy[0]);
123
124 vector<double> transs;
125 vector<double> transl;
126 transs = fptrans->InverseCoefficients(1);
127 transl = fptrans->InverseCoefficients(2);
128
129 // Correct the Affine order - move the constant to the front
130 transs.insert(transs.begin(), transs[2]);
131 transs.pop_back();
132 transl.insert(transl.begin(), transl[2]);
133 transl.pop_back();
134
135 // Medium camera has a reversed x-axis
136 transs[1] *= xdir;
137 transl[1] *= xdir;
138
139 string icodes = icode + "_ITRANSS";
140 string icodel = icode + "_ITRANSL";
141 pdpool_c(icodes.c_str(), 3, (double( *)) &transs[0]);
142 pdpool_c(icodel.c_str(), 3, (double( *)) &transl[0]);
143 }
144}
Affine basis function.
Definition Affine.h:65
Isis exception class.
Definition IException.h:91
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Definition IException.h:126
Adds specific functionality to C++ strings.
Definition IString.h:165
void ReadFiducials(PvlGroup &inst)
Reads the fiducials from the instrument group of the labels.
std::vector< double > p_fidSamples
Image sample positions of fiducial map.
std::vector< double > p_fidLines
Image line positions of fiducial map.
std::vector< double > p_fidXCoords
Focal plane X positions of fiducial map.
void CreateTrans(int xdir)
Creates focal plane affine transform.
std::vector< double > p_fidYCoords
Focal plane Y positions of fiducial map.
LoCameraFiducialMap(PvlGroup &inst, const int naifIkCode)
Constructs mapping between Lunar Orbiter detectors and focal plane x/y.
int p_naifIkCode
Naif instrument code.
Contains multiple PvlContainers.
Definition PvlGroup.h:41
A single keyword-value pair.
Definition PvlKeyword.h:87
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
double toDouble(const QString &string)
Global function to convert from a string to a double.
Definition IString.cpp:149
Namespace for the standard library.