Isis 3 Programmer Reference
IdealCamera.cpp
Go to the documentation of this file.
1 
23 #include "IdealCamera.h"
24 
25 #include <iomanip>
26 #include <string>
27 
28 #include <QDebug>
29 #include <QString>
30 
31 #include "CameraDistortionMap.h"
32 #include "CameraFocalPlaneMap.h"
33 #include "IException.h"
34 #include "IString.h"
35 #include "iTime.h"
38 #include "LineScanCameraSkyMap.h"
39 #include "NaifStatus.h"
40 #include "Pvl.h"
41 
42 using namespace std;
43 namespace Isis {
76  IdealCamera::IdealCamera(Cube &cube) : Camera(cube) {
78 
79  // Since this is an ideal camera, we'll call it Ideal Spacecraft
80  m_spacecraftNameLong = "Ideal Spacecraft";
81  m_spacecraftNameShort = "Ideal";
82  m_instrumentNameLong = "Ideal Camera";
83  m_instrumentNameShort = "Ideal";
84 
85  // Get required keywords from instrument group
86  PvlGroup &inst = cube.label()->findGroup("Instrument", Pvl::Traverse);
87 
88  // Setup camera characteristics from instrument
89 
90  if (inst.hasKeyword("FocalLength")) {
91  SetFocalLength(inst["FocalLength"]);
92  }
93  else {
94  SetFocalLength(readValue("IDEAL_FOCAL_LENGTH", SpiceDoubleType).toDouble());
95  }
96 
97  if (inst.hasKeyword("PixelPitch")) {
98  SetPixelPitch(inst["PixelPitch"]);
99  }
100  else {
101  SetPixelPitch(readValue("IDEAL_PIXEL_PITCH", SpiceDoubleType).toDouble());
102  }
103 
104  double et = inst["EphemerisTime"];
105 
106  double exposureDuration = 0.0;
107  if (inst.hasKeyword("ExposureDuration")) {
108  exposureDuration = ((double) inst["ExposureDuration"]) / 1000.0;
109  }
110 
111  double sampleDetectors = inst["SampleDetectors"];
112  double lineDetectors = inst["LineDetectors"];
113 
114  // These variables are used for maintaining compatibility with older versions of the
115  // ideal camera (noproj before it modified the naif keywords group) and for cubes without the
116  // naif keywords group at all.
117  int xDependency = inst["FocalPlaneXDependency"];
118  int yDependency = CameraFocalPlaneMap::Line;
119  // Pixel direction
120  double xdir = 1.0;
121  double ydir = 1.0;
122  double sdir = xdir;
123  double ldir = ydir;
124 
125  if (inst.hasKeyword("TransX")) xdir = inst["TransX"];
126  if (inst.hasKeyword("TransY")) ydir = inst["TransY"];
127 
128  if (xDependency == CameraFocalPlaneMap::Line) {
129  yDependency = CameraFocalPlaneMap::Sample;
130  sdir = ydir;
131  ldir = xdir;
132  }
133 
134  // Put the translation coefficients into the Naif kernel pool so the
135  // CameraFocalPlaneClass can find them
136  try {
137  readValue("IDEAL_TRANSX", SpiceDoubleType);
138  }
139  catch (IException &) {
140  double keyval[3];
141  keyval[0] = 0.;
142  if (inst.hasKeyword("TransX0")) {
143  keyval[0] = inst["TransX0"];
144  }
145 
146  keyval[xDependency] = PixelPitch() * xdir;
147  keyval[yDependency] = 0.;
148 
149  storeValue("IDEAL_TRANSX", 0, SpiceDoubleType, keyval[0]);
150  storeValue("IDEAL_TRANSX", 1, SpiceDoubleType, keyval[1]);
151  storeValue("IDEAL_TRANSX", 2, SpiceDoubleType, keyval[2]);
152  pdpool_c("IDEAL_TRANSX", 3, keyval);
153  }
154 
155  try {
156  readValue("IDEAL_TRANSY", SpiceDoubleType);
157  }
158  catch (IException &) {
159  double keyval[3];
160  keyval[0] = 0.;
161  if (inst.hasKeyword("TransY0")) {
162  keyval[0] = inst["TransY0"];
163  }
164 
165  keyval[yDependency] = PixelPitch() * ydir;
166  keyval[xDependency] = 0.;
167 
168  storeValue("IDEAL_TRANSY", 0, SpiceDoubleType, keyval[0]);
169  storeValue("IDEAL_TRANSY", 1, SpiceDoubleType, keyval[1]);
170  storeValue("IDEAL_TRANSY", 2, SpiceDoubleType, keyval[2]);
171  pdpool_c("IDEAL_TRANSY", 3, keyval);
172  }
173 
174  try {
175  readValue("IDEAL_TRANSS", SpiceDoubleType);
176  }
177  catch (IException &) {
178  double keyval[3];
179  keyval[0] = 0.;
180  if (inst.hasKeyword("TransS0")) {
181  keyval[0] = inst["TransS0"];
182  }
183 
184  keyval[xDependency] = 1 / PixelPitch() * sdir;
185  keyval[yDependency] = 0.;
186 
187  storeValue("IDEAL_TRANSS", 0, SpiceDoubleType, keyval[0]);
188  storeValue("IDEAL_TRANSS", 1, SpiceDoubleType, keyval[1]);
189  storeValue("IDEAL_TRANSS", 2, SpiceDoubleType, keyval[2]);
190  pdpool_c("IDEAL_TRANSS", 3, keyval);
191  }
192 
193  try {
194  readValue("IDEAL_TRANSL", SpiceDoubleType);
195  }
196  catch (IException &) {
197  double keyval[3];
198  keyval[0] = 0.;
199  if (inst.hasKeyword("TransL0")) {
200  keyval[0] = inst["TransL0"];
201  }
202 
203  keyval[yDependency] = 1 / PixelPitch() * ldir;
204  keyval[xDependency] = 0.0;
205 
206  storeValue("IDEAL_TRANSL", 0, SpiceDoubleType, keyval[0]);
207  storeValue("IDEAL_TRANSL", 1, SpiceDoubleType, keyval[1]);
208  storeValue("IDEAL_TRANSL", 2, SpiceDoubleType, keyval[2]);
209  pdpool_c("IDEAL_TRANSL", 3, keyval);
210  }
211 
212  // Create correct camera type
213  QString type = (QString) inst["InstrumentType"];
214  if (type.toUpper() == "FRAMING") {
215  p_framing = true;
216  new CameraDetectorMap(this);
217  CameraFocalPlaneMap *fmap = new CameraFocalPlaneMap(this, 0);
218  fmap->SetDetectorOrigin(sampleDetectors / 2.0 + 0.5,
219  lineDetectors / 2.0 + 0.5);
220  new CameraDistortionMap(this);
221  new CameraGroundMap(this);
222  new CameraSkyMap(this);
223 
224  setTime(et);
225  LoadCache();
226  }
227  else if (type.toUpper() == "LINESCAN") {
228  p_framing = false;
230  CameraFocalPlaneMap *fmap = new CameraFocalPlaneMap(this, 0);
231  fmap->SetDetectorOrigin(sampleDetectors / 2.0 + 0.5,
232  0.0);
233  new CameraDistortionMap(this);
234  new LineScanCameraGroundMap(this);
235  new LineScanCameraSkyMap(this);
236 
237  LoadCache();
239  }
240  else {
241  QString msg = "Unknown InstrumentType [" +
242  (QString) inst["InstrumentType"] + "]";
244  }
245  }
246 
247 
250 
251 
259  string msg = "No CK Frame ID for Ideal Camera class";
261  }
262 
263 
271  string msg = "No CK Reference ID for Ideal Camera class";
273  }
274 
275 
283  string msg = "No SPK Target ID for Ideal Camera class";
285  }
286 
287 
295  string msg = "No SPK Center ID for Ideal Camera class";
297  }
298 
299 
307  string msg = "No SPK Reference ID for Ideal Camera class";
309  }
310 
311 
318  return m_instrumentNameLong;
319  }
320 
321 
328  return m_instrumentNameShort;
329  }
330 
331 
338  return m_spacecraftNameLong;
339  }
340 
341 
348  return m_spacecraftNameShort;
349  }
350 }
351 
352 
363  return new Isis::IdealCamera(cube);
364 }
void SetFocalLength()
Reads the focal length from the instrument kernel.
Definition: Camera.cpp:1430
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Definition: PvlObject.h:141
QString m_instrumentNameShort
Shortened instrument name.
Definition: IdealCamera.h:104
void SetPixelPitch()
Reads the Pixel Pitch from the instrument kernel.
Definition: Camera.cpp:1437
Namespace for the standard library.
The x value of the focal plane maps to a sample.
Search child objects.
Definition: PvlObject.h:170
void SetDetectorOrigin(const double sample, const double line)
Set the detector origin.
double toDouble(const QString &string)
Global function to convert from a string to a double.
Definition: IString.cpp:164
virtual int SpkReferenceId() const
SPK Reference ID.
Convert between undistorted focal plane and ground coordinates.
Convert between parent image coordinates and detector coordinates.
Convert between undistorted focal plane and ground coordinates.
virtual QString spacecraftNameLong() const
This method returns the full spacecraft name.
Convert between distorted focal plane and detector coordinates.
Contains multiple PvlContainers.
Definition: PvlGroup.h:57
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:40
A type of error that could only have occurred due to a mistake on the user&#39;s part (e...
Definition: IException.h:142
Isis::Camera * IdealCameraPlugin(Isis::Cube &cube)
External C function for createing the camera plugin.
Distort/undistort focal plane coordinates.
double PixelPitch() const
Returns the pixel pitch.
Definition: Camera.cpp:2754
virtual int SpkCenterId() const
SPK Center ID.
QString m_instrumentNameLong
Full instrument name.
Definition: IdealCamera.h:103
virtual int CkReferenceId() const
CK Reference ID.
void setTime(const iTime &time)
By setting the time you essential set the position of the spacecraft and body as indicated in the cla...
Definition: Sensor.cpp:112
virtual QString instrumentNameLong() const
This method returns the full instrument name.
Convert between undistorted focal plane and ra/dec coordinates.
void LoadCache()
This loads the spice cache big enough for this image.
Definition: Camera.cpp:2432
virtual int CkFrameId() const
CK frame ID.
Ideal Camera Model.
Definition: IdealCamera.h:73
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Definition: Cube.cpp:1346
bool p_framing
true if framing camera
Definition: IdealCamera.h:102
QString m_spacecraftNameLong
Full spacecraft name.
Definition: IdealCamera.h:105
~IdealCamera()
Destroys the IdealCamera object.
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
Definition: NaifStatus.cpp:43
Isis exception class.
Definition: IException.h:107
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
Convert between undistorted focal plane and ra/dec coordinates.
Definition: CameraSkyMap.h:48
virtual int SpkTargetId() const
SPK Target ID.
virtual QString instrumentNameShort() const
This method returns the shortened instrument name.
SpiceDouble type.
Definition: Spice.h:358
virtual double exposureDuration() const
Return the exposure duration for the pixel that the camera is set to.
Definition: Camera.cpp:3075
QVariant readValue(QString key, SpiceValueType type, int index=0)
This should be used for reading ALL text naif kernel values.
Definition: Spice.cpp:1017
The x value of the focal plane maps to a line.
Convert between parent image coordinates and detector coordinates.
QString m_spacecraftNameShort
Shortened spacecraft name.
Definition: IdealCamera.h:106
virtual QString spacecraftNameShort() const
This method returns the shortened spacecraft name.
IO Handler for Isis Cubes.
Definition: Cube.h:170