17#include "Displacement.h"
19#include "IException.h"
22#include "PvlKeyword.h"
23#include "RingPlaneProjection.h"
24#include "SpecialPixel.h"
25#include "TProjection.h"
26#include "WorldMapper.h"
88 m_mappingGrp = label.findGroup(
"Mapping", Pvl::Traverse);
128 if (str.toUpper() ==
"SKY")
m_sky =
true;
135 catch(IException &e) {
136 QString msg =
"Projection failed. Invalid label group [Mapping]";
137 throw IException(e, IException::Unknown, msg, _FILEINFO_);
158 if (
Name() != proj.
Name())
return false;
173 return !(*
this == proj);
183 m_projectionType = ptype;
193 return m_projectionType;
412 if (coord1 == Null || coord2 == Null) {
441 if (coord1 == Null || coord2 == Null) {
496 projectionX =
m_mapper->ProjectionX(worldX);
497 projectionY =
m_mapper->ProjectionY(worldY);
500 projectionX = worldX;
501 projectionY = worldY;
504 return SetCoordinate(projectionX, projectionY);
561 if (projectionX == Null) {
562 throw IException(IException::Unknown,
563 "Unable to convert to world x. The given x-value ["
564 + IString(projectionX) +
"] is invalid.",
568 return m_mapper->WorldX(projectionX);
589 if (projectionY == Null) {
590 throw IException(IException::Unknown,
591 "Unable to convert to world y. The given y-value ["
592 + IString(projectionY) +
"] is invalid.",
596 return m_mapper->WorldY(projectionY);
617 if (worldX == Null) {
618 throw IException(IException::Unknown,
619 "Unable to convert to projection x. The given x-value ["
620 + IString(worldX) +
"] is invalid.",
624 return m_mapper->ProjectionX(worldX);
645 if (worldY == Null) {
646 throw IException(IException::Unknown,
647 "Unable to convert to projection y. The given y-value ["
648 + IString(worldY) +
"] is invalid.",
652 return m_mapper->ProjectionY(worldY);
701 int iangle = (int)angle;
702 double mins = abs(angle - iangle) * 60.0;
703 int imins = (int)mins;
704 double secs = (mins - imins) * 60.0;
705 int isecs = (int)secs;
706 double frac = (secs - isecs) * 1000.0;
707 if (frac >= 1000.0) {
720 s << iangle <<
" " << setw(2) << setfill(
'0')
721 << imins <<
"m " << setw(2) << setfill(
'0') << isecs <<
"." <<
722 setprecision(3) << frac <<
"s";
723 return s.str().c_str();
736 double tangle = angle;
737 while (tangle < 0.0) tangle += 360.0;
738 while (tangle > 360.0) tangle -= 360.0;
740 int ihrs = (int)(hrs);
741 double mins = (hrs - ihrs) * 60.0;
742 int imins = (int)(mins);
743 double secs = (mins - imins) * 60.0;
744 int isecs = (int)(secs);
745 double msecs = (secs - isecs) * 1000.0;
746 int imsecs = (int)(msecs + 0.5);
747 if (imsecs >= 1000) {
760 s << setw(2) << setfill(
'0') << ihrs <<
"h " << setw(2) << setfill(
'0') <<
761 imins <<
"m " << setw(2) << setfill(
'0') << isecs <<
"." << imsecs <<
"s";
762 return s.str().c_str();
775 if (x == Null || y == Null) {
785 m_x = x * cos(rot) + y * sin(rot);
786 m_y = y * cos(rot) - x * sin(rot);
799 if (x == Null || y == Null) {
815 return m_x * cos(rot) -
m_y * sin(rot);
826 return m_y * cos(rot) +
m_x * sin(rot);
1369 PvlKeyword xKeyword(
"UpperLeftCornerX",
toString(x.
meters()),
"meters");
1370 PvlKeyword yKeyword(
"UpperLeftCornerY",
toString(y.
meters()),
"meters");
Displacement is a signed length, usually in meters.
double meters() const
Get the displacement in meters.
double m_y
This contains the rotated Y coordinate for a specific projection at the position indicated by m_latit...
static double ToHours(double angle)
Converts the given angle (in degrees) to hours by using the ratio 15 degrees per hour.
double ToWorldY(const double projectionY) const
This method converts a projection y value to a world y value.
virtual bool SetUniversalGround(const double coord1, const double coord2)
This method is used to set the lat/lon or radius/azimuth (i.e.
void SetWorldMapper(WorldMapper *mapper)
If desired the programmer can use this method to set a world mapper to be used in the SetWorld,...
double m_rotation
Rotation of map (usually zero)
ProjectionType
This enum defines the subclasses of Projection supported in Isis.
@ Triaxial
These projections are used to map triaxial and irregular-shaped bodies.
WorldMapper * m_mapper
This points to a mapper passed into the SetWorldMapper method.
double Resolution() const
This method returns the resolution for mapping world coordinates into projection coordinates.
virtual bool operator==(const Projection &proj)
This method determines whether two map projection objects are equal by comparing the resolution,...
double XCoord() const
This returns the projection X provided SetGround, SetCoordinate, SetUniversalGround,...
double m_maximumX
See minimumX description.
virtual bool SetWorld(const double x, const double y)
This method is used to set a world coordinate.
virtual ~Projection()
Destroys the Projection object.
bool IsSky() const
Returns true if projection is sky and false if it is land.
virtual bool HasGroundRange() const
This indicates if the longitude direction type is positive west (as opposed to postive east).
double ToWorldX(const double projectionX) const
This method converts a projection x value to a world x value.
double m_pixelResolution
Pixel resolution value from the PVL mapping group, in meters/pixel.
void SetUpperLeftCorner(const Displacement &x, const Displacement &y)
This method is used to find the XY range for oblique aspect projections (non-polar projections) by "w...
bool m_groundRangeGood
Indicates if the ground range (min/max lat/lons) were read from the labels.
double PixelResolution() const
Returns the pixel resolution value from the PVL mapping group in meters/pixel.
virtual bool SetUnboundUniversalGround(const double coord1, const double coord2)
This method is used to set the lat/lon or radius/azimuth (i.e.
virtual double WorldY() const
This returns the world Y coordinate provided SetGround, SetCoordinate, SetUniversalGround,...
double YCoord() const
This returns the projection Y provided SetGround, SetCoordinate, SetUniversalGround,...
virtual double WorldX() const
This returns the world X coordinate provided SetGround, SetCoordinate, SetUniversalGround,...
double ToProjectionY(const double worldY) const
This method converts a world y value to a projection y value.
virtual QString Name() const =0
This method returns the name of the map projection.
double GetX() const
Calculates the unrotated form of current x value.
bool operator!=(const Projection &proj)
This method determines whether two map projection objects are not equal.
bool m_good
Indicates if the contents of m_x, m_y, m_latitude, and m_longitude are valid.
double m_minimumX
The data elements m_minimumX, m_minimumY, m_maximumX, and m_maximumY are convience data elements when...
Projection(Pvl &label)
Constructs an empty Projection object.
PvlGroup m_mappingGrp
Mapping group that created this projection.
static QString ToHMS(double angle)
Converts the given angle (in degrees) to hours, minutes, seconds.
double m_minimumY
See minimumX description.
bool m_sky
Indicates whether projection is sky or land.
double Rotation() const
Returns the value of the Rotation keyword from the mapping group.
double ToProjectionX(const double worldX) const
This method converts a world x value to a projection x value.
double GetY() const
Calculates the unrotated form of the current y value.
virtual bool IsEquatorialCylindrical()
This method returns true if the projection is equatorial cylindrical.
void SetXY(double x, double y)
This protected method is a helper for derived classes.
bool IsGood() const
This indicates if the last invocation of SetGround, SetCoordinate, SetUniversalGround,...
double m_x
This contains the rotated X coordinate for a specific projection at theposition indicated by m_latitu...
ProjectionType projectionType() const
Returns an enum value for the projection type.
void setProjectionType(const ProjectionType ptype)
Sets the projection subclass type.
double m_maximumY
See minimumX description.
void SetComputedXY(double x, double y)
This protected method is a helper for derived classes.
static QString ToDMS(double angle)
Converts the given angle (in degrees) to degrees, minutes, seconds.
Base class for Map Projections of plane shapes.
bool SetUniversalGround(const double ringRadius, const double ringLongitude)
This method is used to set the ring radius/longitude which must be PositiveEast/Domain360 (ring longi...
Base class for Map TProjections.
bool SetUnboundUniversalGround(const double coord1, const double coord2)
This method is used to set the latitude/longitude.
virtual bool SetUniversalGround(const double lat, const double lon)
This method is used to set the latitude/longitude which must be Planetocentric (latitude) and Positiv...
Create a mapping between a projection and other coordinate system.
This is free and unencumbered software released into the public domain.
QString toString(const LinearAlgebra::Vector &vector, int precision)
A global function to format LinearAlgebra::Vector as a QString with the given precision.
Namespace for the standard library.