7#include "CameraPointInfo.h"
15#include "CameraFocalPlaneMap.h"
17#include "CubeManager.h"
19#include "IException.h"
23#include "SpecialPixel.h"
24#include "TProjection.h"
95 const bool allowOutside,
const bool allowErrors) {
139 const bool allowOutside,
140 const bool allowErrors) {
163 const bool allowOutside,
164 const bool allowErrors) {
188 const bool allowOutside,
const bool allowErrors) {
206 string msg =
"Please set a cube before setting parameters";
239 gp->addKeyword(
PvlKeyword(
"PlanetocentricLatitude"));
240 gp->addKeyword(
PvlKeyword(
"PlanetographicLatitude"));
241 gp->addKeyword(
PvlKeyword(
"PositiveEast360Longitude"));
242 gp->addKeyword(
PvlKeyword(
"PositiveEast180Longitude"));
243 gp->addKeyword(
PvlKeyword(
"PositiveWest360Longitude"));
244 gp->addKeyword(
PvlKeyword(
"PositiveWest180Longitude"));
245 gp->addKeyword(
PvlKeyword(
"BodyFixedCoordinate"));
247 gp->addKeyword(
PvlKeyword(
"SampleResolution"));
249 gp->addKeyword(
PvlKeyword(
"ObliqueDetectorResolution"));
250 gp->addKeyword(
PvlKeyword(
"ObliquePixelResolution"));
251 gp->addKeyword(
PvlKeyword(
"ObliqueLineResolution"));
252 gp->addKeyword(
PvlKeyword(
"ObliqueSampleResolution"));
253 gp->addKeyword(
PvlKeyword(
"SpacecraftPosition"));
254 gp->addKeyword(
PvlKeyword(
"SpacecraftAzimuth"));
256 gp->addKeyword(
PvlKeyword(
"TargetCenterDistance"));
257 gp->addKeyword(
PvlKeyword(
"SubSpacecraftLatitude"));
258 gp->addKeyword(
PvlKeyword(
"SubSpacecraftLongitude"));
259 gp->addKeyword(
PvlKeyword(
"SpacecraftAltitude"));
261 gp->addKeyword(
PvlKeyword(
"SubSpacecraftGroundAzimuth"));
263 gp->addKeyword(
PvlKeyword(
"SubSolarAzimuth"));
265 gp->addKeyword(
PvlKeyword(
"SubSolarLatitude"));
266 gp->addKeyword(
PvlKeyword(
"SubSolarLongitude"));
267 gp->addKeyword(
PvlKeyword(
"SubSolarGroundAzimuth"));
276 gp->addKeyword(
PvlKeyword(
"LookDirectionBodyFixed"));
277 gp->addKeyword(
PvlKeyword(
"LookDirectionJ2000"));
278 gp->addKeyword(
PvlKeyword(
"LookDirectionCamera"));
280 if (allowErrors) gp->addKeyword(
PvlKeyword(
"Error"));
291 gp->addKeyword(
PvlKeyword(
"PlanetocentricLatitude"));
292 gp->addKeyword(
PvlKeyword(
"PlanetographicLatitude"));
293 gp->addKeyword(
PvlKeyword(
"PositiveEast360Longitude"));
294 gp->addKeyword(
PvlKeyword(
"PositiveEast180Longitude"));
295 gp->addKeyword(
PvlKeyword(
"PositiveWest360Longitude"));
296 gp->addKeyword(
PvlKeyword(
"PositiveWest180Longitude"));
297 gp->addKeyword(
PvlKeyword(
"BodyFixedCoordinate"));
299 gp->addKeyword(
PvlKeyword(
"SampleResolution"));
301 gp->addKeyword(
PvlKeyword(
"SpacecraftPosition"));
302 gp->addKeyword(
PvlKeyword(
"SpacecraftAzimuth"));
304 gp->addKeyword(
PvlKeyword(
"TargetCenterDistance"));
305 gp->addKeyword(
PvlKeyword(
"SubSpacecraftLatitude"));
306 gp->addKeyword(
PvlKeyword(
"SubSpacecraftLongitude"));
307 gp->addKeyword(
PvlKeyword(
"SpacecraftAltitude"));
309 gp->addKeyword(
PvlKeyword(
"SubSpacecraftGroundAzimuth"));
311 gp->addKeyword(
PvlKeyword(
"SubSolarAzimuth"));
313 gp->addKeyword(
PvlKeyword(
"SubSolarLatitude"));
314 gp->addKeyword(
PvlKeyword(
"SubSolarLongitude"));
315 gp->addKeyword(
PvlKeyword(
"SubSolarGroundAzimuth"));
324 gp->addKeyword(
PvlKeyword(
"LookDirectionBodyFixed"));
325 gp->addKeyword(
PvlKeyword(
"LookDirectionJ2000"));
326 gp->addKeyword(
PvlKeyword(
"LookDirectionCamera"));
327 gp->addKeyword(
PvlKeyword(
"ObliqueDetectorResolution"));
328 gp->addKeyword(
PvlKeyword(
"ObliquePixelResolution"));
329 gp->addKeyword(
PvlKeyword(
"ObliqueLineResolution"));
330 gp->addKeyword(
PvlKeyword(
"ObliqueSampleResolution"));
331 if (allowErrors) gp->addKeyword(
PvlKeyword(
"Error"));
338 bool noErrors = passed;
341 error =
"Requested position does not project in camera model; no surface intersection";
346 error =
"Requested position does not project in camera model; not inside cube";
352 for (
int i = 0; i < gp->keywords(); i++) {
353 QString name = (*gp)[i].name();
355 if (name ==
"BodyFixedCoordinate" || name ==
"SpacecraftPosition" ||
356 name ==
"SunPosition") {
357 (*gp)[i].addValue(
"NULL");
358 (*gp)[i].addValue(
"NULL");
359 (*gp)[i].addValue(
"NULL");
362 (*gp)[i].setValue(
"NULL");
366 double spB[3], sB[3];
369 gp->findKeyword(
"SpacecraftPosition").addValue(
toString(spB[0]),
"km");
370 gp->findKeyword(
"SpacecraftPosition").addValue(
toString(spB[1]),
"km");
371 gp->findKeyword(
"SpacecraftPosition").addValue(
toString(spB[2]),
"km");
375 gp->findKeyword(
"SunPosition").addValue(
toString(sB[0]),
"km");
376 gp->findKeyword(
"SunPosition").addValue(
toString(sB[1]),
"km");
377 gp->findKeyword(
"SunPosition").addValue(
toString(sB[2]),
"km");
380 gp->findKeyword(
"SunPosition").addValue(
"Null");
381 gp->findKeyword(
"SunPosition").addValue(
"Null");
382 gp->findKeyword(
"SunPosition").addValue(
"Null");
386 gp->findKeyword(
"LookDirectionBodyFixed").addValue(
toString(lookB[0]),
"DEGREE");
387 gp->findKeyword(
"LookDirectionBodyFixed").addValue(
toString(lookB[1]),
"DEGREE");
388 gp->findKeyword(
"LookDirectionBodyFixed").addValue(
toString(lookB[2]),
"DEGREE");
392 gp->findKeyword(
"LookDirectionJ2000").addValue(
toString(lookJ[0]),
"DEGREE");
393 gp->findKeyword(
"LookDirectionJ2000").addValue(
toString(lookJ[1]),
"DEGREE");
394 gp->findKeyword(
"LookDirectionJ2000").addValue(
toString(lookJ[2]),
"DEGREE");
397 gp->findKeyword(
"LookDirectionJ2000").addValue(
"Null");
398 gp->findKeyword(
"LookDirectionJ2000").addValue(
"Null");
399 gp->findKeyword(
"LookDirectionJ2000").addValue(
"Null");
405 gp->findKeyword(
"LookDirectionCamera").addValue(
toString(lookC[0]),
"DEGREE");
406 gp->findKeyword(
"LookDirectionCamera").addValue(
toString(lookC[1]),
"DEGREE");
407 gp->findKeyword(
"LookDirectionCamera").addValue(
toString(lookC[2]),
"DEGREE");
410 gp->findKeyword(
"LookDirectionCamera").addValue(
"Null");
411 gp->findKeyword(
"LookDirectionCamera").addValue(
"Null");
412 gp->findKeyword(
"LookDirectionCamera").addValue(
"Null");
417 gp->findKeyword(
"Error").setValue(error);
421 gp->findKeyword(
"EphemerisTime").setValue(
423 gp->findKeyword(
"EphemerisTime").addComment(
"Time");
425 gp->findKeyword(
"UTC").setValue(utc);
426 gp->findKeyword(
"SpacecraftPosition").addComment(
"Spacecraft Information");
427 gp->findKeyword(
"SunPosition").addComment(
"Sun Information");
428 gp->findKeyword(
"Phase").addComment(
"Illumination and Other");
436 b.SetBasePosition(intSamp, intLine, 1);
439 double pB[3], spB[3], sB[3];
441 double ssplat, ssplon, ocentricLat, ographicLat, pe360Lon, pw360Lon;
449 gp->findKeyword(
"RightAscension").setValue(
toString(
453 gp->findKeyword(
"RightAscension").setValue(
"Null");
456 gp->findKeyword(
"Declination").setValue(
toString(
460 gp->findKeyword(
"Declination").setValue(
"Null");
463 gp->findKeyword(
"PlanetocentricLatitude").setValue(
toString(ocentricLat),
"DEGREE");
469 radii[0].kilometers(),
470 radii[2].kilometers());
471 gp->findKeyword(
"PlanetographicLatitude").setValue(
toString(ographicLat),
"DEGREE");
474 gp->findKeyword(
"PositiveEast360Longitude").setValue(
toString(pe360Lon),
"DEGREE");
477 gp->findKeyword(
"PositiveEast180Longitude").setValue(
toString(
482 gp->findKeyword(
"PositiveWest360Longitude").setValue(
toString(pw360Lon),
"DEGREE");
485 gp->findKeyword(
"PositiveWest180Longitude").setValue(
489 gp->findKeyword(
"BodyFixedCoordinate").addValue(
toString(pB[0]),
"km");
490 gp->findKeyword(
"BodyFixedCoordinate").addValue(
toString(pB[1]),
"km");
491 gp->findKeyword(
"BodyFixedCoordinate").addValue(
toString(pB[2]),
"km");
493 gp->findKeyword(
"LocalRadius").setValue(
toString(
495 gp->findKeyword(
"SampleResolution").setValue(
toString(
497 gp->findKeyword(
"LineResolution").setValue(
toString(
500 gp->findKeyword(
"ObliqueDetectorResolution").setValue(
502 gp->findKeyword(
"ObliqueLineResolution").setValue(
504 gp->findKeyword(
"ObliqueSampleResolution").setValue(
506 gp->findKeyword(
"ObliquePixelResolution").setValue(
512 gp->findKeyword(
"SpacecraftPosition").addValue(
toString(spB[0]),
"km");
513 gp->findKeyword(
"SpacecraftPosition").addValue(
toString(spB[1]),
"km");
514 gp->findKeyword(
"SpacecraftPosition").addValue(
toString(spB[2]),
"km");
515 gp->findKeyword(
"SpacecraftPosition").addComment(
"Spacecraft Information");
519 gp->findKeyword(
"SpacecraftAzimuth").setValue(
toString(spacecraftAzi),
"DEGREE");
522 gp->findKeyword(
"SpacecraftAzimuth").setValue(
"NULL");
525 gp->findKeyword(
"SlantDistance").setValue(
toString(
527 gp->findKeyword(
"TargetCenterDistance").setValue(
toString(
530 gp->findKeyword(
"SubSpacecraftLatitude").setValue(
toString(ssplat),
"DEGREE");
531 gp->findKeyword(
"SubSpacecraftLongitude").setValue(
toString(ssplon),
"DEGREE");
532 gp->findKeyword(
"SpacecraftAltitude").setValue(
toString(
534 gp->findKeyword(
"OffNadirAngle").setValue(
toString(
539 gp->findKeyword(
"SubSpacecraftGroundAzimuth").setValue(
544 gp->findKeyword(
"SunPosition").addValue(
toString(sB[0]),
"km");
545 gp->findKeyword(
"SunPosition").addValue(
toString(sB[1]),
"km");
546 gp->findKeyword(
"SunPosition").addValue(
toString(sB[2]),
"km");
547 gp->findKeyword(
"SunPosition").addComment(
"Sun Information");
550 gp->findKeyword(
"SunPosition").addValue(
"Null");
551 gp->findKeyword(
"SunPosition").addValue(
"Null");
552 gp->findKeyword(
"SunPosition").addValue(
"Null");
553 gp->findKeyword(
"SunPosition").addComment(
"Sun Information");
559 gp->findKeyword(
"SubSolarAzimuth").setValue(
toString(sunAzi),
"DEGREE");
562 gp->findKeyword(
"SubSolarAzimuth").setValue(
"NULL");
566 gp->findKeyword(
"SubSolarAzimuth").setValue(
"NULL");
570 gp->findKeyword(
"SolarDistance").setValue(
toString(
574 gp->findKeyword(
"SolarDistance").setValue(
"NULL");
579 gp->findKeyword(
"SubSolarLatitude").setValue(
toString(sslat),
"DEGREE");
580 gp->findKeyword(
"SubSolarLongitude").setValue(
toString(sslon),
"DEGREE");
586 gp->findKeyword(
"SubSolarGroundAzimuth").setValue(
toString(subsolgrdaz),
"DEGREE");
589 gp->findKeyword(
"SubSolarGroundAzimuth").setValue(
"NULL");
593 gp->findKeyword(
"SubSolarLatitude").setValue(
"NULL");
594 gp->findKeyword(
"SubSolarLongitude").setValue(
"NULL");
595 gp->findKeyword(
"SubSolarGroundAzimuth").setValue(
"NULL");
599 gp->findKeyword(
"Phase").addComment(
"Illumination and Other");
600 gp->findKeyword(
"Incidence").setValue(
toString(
602 gp->findKeyword(
"Emission").setValue(
toString(
607 gp->findKeyword(
"NorthAzimuth").setValue(
toString(northAzi),
"DEGREE");
610 gp->findKeyword(
"NorthAzimuth").setValue(
"NULL");
613 gp->findKeyword(
"EphemerisTime").setValue(
toString(
615 gp->findKeyword(
"EphemerisTime").addComment(
"Time");
617 gp->findKeyword(
"UTC").setValue(utc);
619 gp->findKeyword(
"LocalSolarTime").setValue(
toString(
623 gp->findKeyword(
"LocalSolarTime").setValue(
"Null");
626 gp->findKeyword(
"SolarLongitude").setValue(
toString(
630 gp->findKeyword(
"SolarLongitude").setValue(
"Null");
634 gp->findKeyword(
"LookDirectionBodyFixed").addValue(
toString(lookB[0]),
"DEGREE");
635 gp->findKeyword(
"LookDirectionBodyFixed").addValue(
toString(lookB[1]),
"DEGREE");
636 gp->findKeyword(
"LookDirectionBodyFixed").addValue(
toString(lookB[2]),
"DEGREE");
637 gp->findKeyword(
"LookDirectionBodyFixed").addComment(
"Look Direction Unit Vectors in Body Fixed, J2000, and Camera Coordinate Systems.");
641 gp->findKeyword(
"LookDirectionJ2000").addValue(
toString(lookJ[0]),
"DEGREE");
642 gp->findKeyword(
"LookDirectionJ2000").addValue(
toString(lookJ[1]),
"DEGREE");
643 gp->findKeyword(
"LookDirectionJ2000").addValue(
toString(lookJ[2]),
"DEGREE");
646 gp->findKeyword(
"LookDirectionJ2000").addValue(
"Null");
647 gp->findKeyword(
"LookDirectionJ2000").addValue(
"Null");
648 gp->findKeyword(
"LookDirectionJ2000").addValue(
"Null");
654 gp->findKeyword(
"LookDirectionCamera").addValue(
toString(lookC[0]),
"DEGREE");
655 gp->findKeyword(
"LookDirectionCamera").addValue(
toString(lookC[1]),
"DEGREE");
656 gp->findKeyword(
"LookDirectionCamera").addValue(
toString(lookC[2]),
"DEGREE");
659 gp->findKeyword(
"LookDirectionCamera").addValue(
"Null");
660 gp->findKeyword(
"LookDirectionCamera").addValue(
"Null");
661 gp->findKeyword(
"LookDirectionCamera").addValue(
"Null");
665 if (allowErrors) gp->findKeyword(
"Error").setValue(
"NULL");
Buffer for containing a three dimensional section of an image.
double NorthAzimuth()
Returns the North Azimuth.
virtual double SampleResolution()
Returns the sample resolution at the current position in meters.
static double GroundAzimuth(double glat, double glon, double slat, double slon)
Computes and returns the ground azimuth between the ground point and another point of interest,...
double SpacecraftAzimuth()
Return the Spacecraft Azimuth.
virtual double Line() const
Returns the current line number.
double SunAzimuth()
Returns the Sun Azimuth.
virtual double ObliquePixelResolution(bool useLocal=true)
Returns the oblique pixel resolution at the current position in meters/pixel.
virtual double Sample() const
Returns the current sample number.
double OffNadirAngle()
Return the off nadir angle in degrees.
virtual bool SetImage(const double sample, const double line)
Sets the sample/line values of the image to get the lat/lon values.
virtual double LineResolution()
Returns the line resolution at the current position in meters.
bool InCube()
This returns true if the current Sample() or Line() value is outside of the cube (meaning the point m...
virtual bool SetUniversalGround(const double latitude, const double longitude)
Sets the lat/lon values to get the sample/line values.
virtual double ObliqueLineResolution(bool useLocal=true)
Returns the oblique line resolution at the current position in meters.
virtual double ObliqueSampleResolution(bool useLocal=true)
Returns the oblique sample resolution at the current position in m.
virtual double ObliqueDetectorResolution(bool useLocal=true)
This method returns the Oblique Detector Resolution if the Look Vector intersects the target and if t...
void SetCSVOutput(bool csvOutput)
Set the output format (true is CSV, false is PVL)
Camera * m_camera
The camera to extract point information from.
virtual PvlGroup * GetPointInfo(bool passed, bool outside, bool errors)
GetPointInfo builds the PvlGroup containing all the important information derived from the Camera.
CubeManager * m_usedCubes
The cubeManager used to open the current cube.
Camera * camera()
Retrieves a pointer to the camera.
PvlGroup * SetCenter(const bool outside=false, const bool error=false)
SetCenter sets the image coordinates to the center of the image.
Cube * cube()
Retrieves a pointer to the current cube.
CameraPointInfo()
Constructor, initializes CubeManager and other variables for use.
bool m_csvOutput
Boolean to keep track of output format (CSV or PVL)
PvlGroup * SetSample(const double sample, const bool outside=false, const bool error=false)
SetSample sets the image coordinates to the center line and the given sample.
PvlGroup * SetGround(const double latitude, const double longitude, const bool outside=false, const bool error=false)
SetGround sets a latitude, longitude grrund coordinate in the camera so data can be accessed.
bool CheckCube()
CheckCube checks that a cube has been set before the data for a point is accessed.
virtual ~CameraPointInfo()
Destructor, deletes CubeManager object used.
PvlGroup * SetImage(const double sample, const double line, const bool outside=false, const bool error=false)
SetImage sets a sample, line image coordinate in the camera so data can be accessed.
PvlGroup * SetLine(const double line, const bool outside=false, const bool error=false)
SetLine sets the image coordinates to the center sample and the given line.
void SetCube(const QString &cubeFileName)
SetCube opens the given cube in a CubeManager.
Cube * m_currentCube
The cube to extract camera information from.
IO Handler for Isis Cubes.
Camera * camera()
Return a camera associated with the cube.
PixelType pixelType() const
void read(Blob &blob, const std::vector< PvlKeyword > keywords=std::vector< PvlKeyword >()) const
This method will read data from the specified Blob object.
virtual QString fileName() const
Returns the opened cube's filename.
Class for quick re-accessing of cubes based on file name.
Cube * OpenCube(const QString &cubeFileName)
This method opens a cube.
void SetNumOpenCubes(unsigned int numCubes)
This sets the maximum number of opened cubes for this instance of CubeManager.
Distance measurement, usually in meters.
double meters() const
Get the distance in meters.
@ Unknown
A type of error that cannot be classified as any of the other error types.
@ Programmer
This error is for when a programmer made an API call that was illegal.
Contains multiple PvlContainers.
A single keyword-value pair.
double LocalSolarTime()
Return the local solar time in hours.
virtual double UniversalLatitude() const
Returns the planetocentric latitude, in degrees, at the surface intersection point in the body fixed ...
virtual double RightAscension()
Returns the right ascension angle (sky longitude).
virtual double SolarDistance() const
Returns the distance between the sun and surface point in AU.
bool HasSurfaceIntersection() const
Returns if the last call to either SetLookDirection or SetUniversalGround had a valid intersection wi...
virtual double SlantDistance() const
Return the distance between the spacecraft and surface point in kmv.
double SpacecraftAltitude()
Returns the distance from the spacecraft to the subspacecraft point in km.
virtual std::vector< double > lookDirectionBodyFixed() const
Returns the look direction in the body fixed coordinate system.
virtual std::vector< double > lookDirectionJ2000() const
Returns the look direction in the camera coordinate system.
virtual double PhaseAngle() const
Returns the phase angle in degrees.
virtual double IncidenceAngle() const
Returns the incidence angle in degrees.
virtual double UniversalLongitude() const
Returns the positive east, 0-360 domain longitude, in degrees, at the surface intersection point in t...
void Coordinate(double p[3]) const
Returns the x,y,z of the surface intersection in BodyFixed km.
Distance LocalRadius() const
Returns the local radius at the intersection point.
virtual double Declination()
Returns the declination angle (sky latitude).
virtual double EmissionAngle() const
Returns the emission angle in degrees.
void LookDirection(double v[3]) const
Returns the look direction in the camera coordinate system.
virtual Longitude solarLongitude()
Returns the solar longitude.
virtual double targetCenterDistance() const
Calculates and returns the distance from the spacecraft to the target center.
virtual void subSolarPoint(double &lat, double &lon)
Returns the sub-solar latitude/longitude in universal coordinates (0-360 positive east,...
void radii(Distance r[3]) const
Returns the radii of the body in km.
void instrumentPosition(double p[3]) const
Returns the spacecraft position in body-fixed frame km units.
virtual iTime time() const
Returns the ephemeris time in seconds which was used to obtain the spacecraft and sun positions.
virtual void sunPosition(double p[3]) const
Fills the input vector with sun position information, in either body-fixed or J2000 reference frame a...
virtual void subSpacecraftPoint(double &lat, double &lon)
Returns the sub-spacecraft latitude/longitude in universal coordinates (0-360 positive east,...
static double To180Domain(const double lon)
This method converts a longitude into the -180 to 180 domain.
static double ToPositiveWest(const double lon, const int domain)
This method converts a longitude into the positive west direction.
double ToPlanetographic(const double lat) const
This method converts a planetocentric latitude to a planetographic latitude.
This is free and unencumbered software released into the public domain.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
bool IsValidPixel(const double d)
Returns if the input pixel is valid.
QString PixelToString(double d, double precision=8)
Takes a double pixel value and returns the name of the pixel type as a string.
Namespace for the standard library.