11#include "IException.h"
12#include "TProjection.h"
15#include "PvlKeyword.h"
20 IProj::IProj(Pvl &label,
bool allowDefaults) :
22 PvlGroup &mapGroup = label.findGroup(
"Mapping", Pvl::Traverse);
23 if (!mapGroup.hasKeyword(
"ProjStr")) {
24 QString message =
"No ProjStr keyword in mapping group, either add a ProjStr or select a different projection method";
25 throw IException(IException::User, message, _FILEINFO_);
27 m_C = proj_context_create();
28 proj_log_level(m_C, PJ_LOG_ERROR);
30 m_userOutputProjStr =
new QString(mapGroup[
"ProjStr"]);
33 std::string projString = m_userOutputProjStr->toStdString();
34 m_outputProj = proj_create(m_C, projString.c_str());
37 QString msg =
"Unable to create projection from [" + QString(projString.c_str()) +
"]";
38 throw IException(IException::User, msg, _FILEINFO_);
42 PJ *ellipsoid = proj_get_ellipsoid(m_C, m_outputProj);
44 if (ellipsoid ==
nullptr) {
45 QString msg =
"Unable to create ellipsoid from [" + *m_userOutputProjStr +
"]";
46 throw IException(IException::User, msg, _FILEINFO_);
49 int res = proj_ellipsoid_get_parameters(m_C, ellipsoid,
55 proj_destroy(ellipsoid);
58 QString msg =
"Unable to get ellipsoid information from [" + *m_userOutputProjStr +
"]";
59 throw IException(IException::User, msg, _FILEINFO_);
62 m_llaProj = proj_crs_get_geodetic_crs(m_C, m_outputProj);
65 QString msg =
"Unable to create lla projection from [" + QString(projString.c_str()) +
"]";
66 throw IException(IException::Programmer, msg, _FILEINFO_);
69 m_llaProj2outputProj = proj_create_crs_to_crs_from_pj(m_C, m_llaProj, m_outputProj, 0, 0);
70 if (0 == m_llaProj2outputProj) {
71 QString msg =
"Unable to create transform from [" + QString(projString.c_str()) +
"]";
72 throw IException(IException::User, msg, _FILEINFO_);
78 delete m_userOutputProjStr;
79 proj_destroy(m_llaProj);
80 proj_destroy(m_outputProj);
81 proj_destroy(m_llaProj2outputProj);
82 proj_context_destroy(m_C);
104 mapping.addKeyword(PvlKeyword(
"EquatorialRadius",
toString(
m_equatorialRadius, 15),
"meters"), PvlContainer::InsertMode::Replace);
105 mapping.addKeyword(PvlKeyword(
"PolarRadius",
toString(
m_polarRadius, 15),
"meters"), PvlContainer::InsertMode::Replace);
106 mapping += PvlKeyword(
"ProjStr", *m_userOutputProjStr);
129 PJ_COORD c_out = proj_trans(m_llaProj2outputProj, PJ_FWD, c_in);
142 PJ_COORD c_out = proj_trans(m_llaProj2outputProj, PJ_INV, c_in);
176 double &minY,
double &maxY) {
bool SetGround(const double lat, const double lon)
This method is used to set the latitude/longitude (assumed to be of the correct LatitudeType,...
bool SetCoordinate(const double x, const double y)
This method is used to set the projection x/y.
bool XYRange(double &minX, double &maxX, double &minY, double &maxY)
This method is used to determine the x/y range which completely covers the area of interest specified...
QString Version() const
Returns the version of the map projection.
PvlGroup Mapping()
This function returns the keywords that this projection uses.
QString Name() const
Returns the name of the map projection, "Proj".
~IProj()
Destroys the IProj object.
double m_maximumX
See minimumX description.
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...
double m_minimumY
See minimumX description.
void SetXY(double x, double y)
This protected method is a helper for derived classes.
double m_maximumY
See minimumX description.
void SetComputedXY(double x, double y)
This protected method is a helper for derived classes.
Base class for Map TProjections.
double m_longitude
This contains the currently set longitude value.
double m_minimumLatitude
Contains the minimum latitude for the entire ground range.
double m_polarRadius
Polar radius of the target.
double m_maximumLongitude
Contains the maximum longitude for the entire ground range.
double m_equatorialRadius
Polar radius of the target.
void XYRangeCheck(const double latitude, const double longitude)
This convience function is established to assist in the development of the XYRange virtual method.
double m_minimumLongitude
Contains the minimum longitude for the entire ground range.
double m_maximumLatitude
Contains the maximum latitude for the entire ground range.
virtual PvlGroup Mapping()
This function returns the keywords that this projection uses.
double m_latitude
This contains the currently set latitude value.
This is free and unencumbered software released into the public domain.
Isis::TProjection * IProjPlugin(Isis::Pvl &lab, bool allowDefaults)
This is the function that is called in order to instantiate a Sinusoidal object.
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.