44 Plugin ProjectionFactory::m_projPlugin;
73 if (m_projPlugin.fileName() ==
"") {
74 FileName localFile(
"Projection.plugin");
76 m_projPlugin.read(localFile.
expanded());
78 FileName systemFile(
"$ISISROOT/lib/Projection.plugin");
80 m_projPlugin.read(systemFile.
expanded());
86 QString proj = mapGroup[
"ProjectionName"];
91 ptr = m_projPlugin.GetPlugin(proj);
94 QString msg =
"Unsupported projection, unable to find plugin for [" +
107 QString message =
"Unable to initialize Projection information ";
108 message +=
"from group [Mapping]";
136 bool allowDefaults) {
141 if (m_projPlugin.fileName() ==
"") {
142 FileName localFile(
"Projection.plugin");
144 m_projPlugin.read(localFile.
expanded());
146 FileName systemFile(
"$ISISROOT/lib/Projection.plugin");
148 m_projPlugin.read(systemFile.
expanded());
154 QString proj = mapGroup[
"ProjectionName"];
157 QFunctionPointer ptr;
159 ptr = m_projPlugin.GetPlugin(proj);
162 QString msg =
"Unsupported projection, unable to find plugin for [" +
171 return (
Projection *) (*plugin)(label, allowDefaults);
174 QString message =
"Unable to initialize Projection information ";
175 message +=
"from group [Mapping]";
205 int &samples,
int &lines,
210 double localRadius = proj->
LocalRadius(trueScaleLat);
216 double scale, pixelResolution;
219 pixelResolution = mapGroup[
"PixelResolution"];
220 scale = (2.0 *
Isis::PI * localRadius) / (360.0 * pixelResolution);
227 scale = mapGroup[
"Scale"];
228 pixelResolution = (2.0 *
Isis::PI * localRadius) / (360.0 * scale);
240 bool sizeFound =
false;
241 double upperLeftX =
Null, upperLeftY =
Null;
244 samples = dims[
"Samples"];
245 lines = dims[
"Lines"];
247 upperLeftX = mapGroup[
"UpperLeftCornerX"];
248 upperLeftY = mapGroup[
"UpperLeftCornerY"];
251 if (!sizeMatch) sizeFound =
false;
259 QString msg =
"Invalid ground range [MinimumLatitude,MaximumLatitude,";
260 msg +=
"MinimumLongitude,MaximumLongitude] missing or invalid";
264 double minX, maxX, minY, maxY;
265 if (!proj->
XYRange(minX, maxX, minY, maxY)) {
266 QString msg =
"Invalid ground range [MinimumLatitude,MaximumLatitude,";
267 msg +=
"MinimumLongitude,MaximumLongitude] cause invalid computation ";
268 msg +=
"of image size";
283 double minXFlipped = minX;
284 double maxXFlipped = maxX;
285 double minYFlipped = minY;
286 double maxYFlipped = maxY;
297 if (fabs(fmod(minXFlipped, pixelResolution)) > 1.0e-6) {
298 if (pixelResolution - fabs(fmod(minXFlipped, pixelResolution)) > 1.0e-6) {
299 double sampleOffset = floor(minXFlipped / pixelResolution);
301 minXFlipped = sampleOffset * pixelResolution;
311 if (maxXFlipped < minXFlipped + pixelResolution) {
312 maxXFlipped = minXFlipped + pixelResolution;
324 if (fabs(fmod(maxYFlipped, pixelResolution)) > 1.0e-6) {
325 if (abs(pixelResolution - fabs(fmod(maxYFlipped, pixelResolution))) > 1.0e-6) {
326 double lineOffset = ceil(maxYFlipped / pixelResolution);
327 maxYFlipped = lineOffset * pixelResolution;
335 if (minYFlipped > maxYFlipped - pixelResolution) {
336 minYFlipped = maxYFlipped - pixelResolution;
341 samples = (int)((maxXFlipped - minXFlipped) / pixelResolution + 0.5);
342 lines = (int)((maxYFlipped - minYFlipped) / pixelResolution + 0.5);
351 upperLeftX = minXFlipped;
361 upperLeftY = maxYFlipped;
382 (QString) mapGroup[
"PixelResolution"],
383 "meters/pixel"), Isis::Pvl::Replace);
386 (QString) mapGroup[
"Scale"],
387 "pixels/degree"), Isis::Pvl::Replace);
390 (QString) mapGroup[
"UpperLeftCornerX"],
391 "meters"), Isis::Pvl::Replace);
394 (QString) mapGroup[
"UpperLeftCornerY"],
395 "meters"), Isis::Pvl::Replace);
398 (QString) mapGroup[
"EquatorialRadius"],
399 "meters"), Isis::Pvl::Replace);
402 (QString) mapGroup[
"PolarRadius"],
403 "meters"), Isis::Pvl::Replace);
413 QString msg =
"Unable to create projection";
416 finalError.
append(errors);
449 int &samples,
int &lines,
bool sizeMatch) {
461 double scale, pixelResolution;
464 pixelResolution = mapGroup[
"PixelResolution"];
465 scale = (2.0 *
Isis::PI * localRadius) / (360.0 * pixelResolution);
471 scale = mapGroup[
"Scale"];
472 pixelResolution = (2.0 *
Isis::PI * localRadius) / (360.0 * scale);
488 bool sizeFound =
false;
489 double upperLeftX =
Null, upperLeftY =
Null;
492 samples = dims[
"Samples"];
493 lines = dims[
"Lines"];
495 upperLeftX = mapGroup[
"UpperLeftCornerX"];
496 upperLeftY = mapGroup[
"UpperLeftCornerY"];
510 QString msg =
"Invalid ring range [MinimumRingRadius,MaximumRingRadius,";
511 msg +=
"MinimumRingLongitude,MaximumRingLongitude] missing or invalid";
515 double minX, maxX, minY, maxY;
516 if (!proj->
XYRange(minX, maxX, minY, maxY)) {
517 QString msg =
"Invalid ring range [MinimumRingRadius,MaximumRingRadius,";
518 msg +=
"MinimumRingLongitude,MaximumRingLongitude] cause invalid computation ";
519 msg +=
"of image size";
529 if (fabs(fmod(minX, pixelResolution)) > 1.0e-6) {
530 if (pixelResolution - fabs(fmod(minX, pixelResolution)) > 1.0e-6) {
531 double sampleOffset = floor(minX / pixelResolution);
532 minX = sampleOffset * pixelResolution;
537 if (maxX < minX + pixelResolution) {
538 maxX = minX + pixelResolution;
540 if (fabs(fmod(maxY, pixelResolution)) > 1.0e-6) {
541 if (pixelResolution - fabs(fmod(maxY, pixelResolution)) > 1.0e-6) {
542 double lineOffset = -1.0 * ceil(maxY / pixelResolution);
543 maxY = -1.0 * lineOffset * pixelResolution;
548 if (minY > maxY - pixelResolution) {
549 minY = maxY - pixelResolution;
553 samples = (int)((maxX - minX) / pixelResolution + 0.5);
554 lines = (int)((maxY - minY) / pixelResolution + 0.5);
571 mapGroup.AddKeyword(
Isis::PvlKeyword(
"SampleProjectionOffset", sampleOffset),
579 (QString) mapGroup[
"PixelResolution"],
580 "meters/pixel"), Isis::Pvl::Replace);
583 (QString) mapGroup[
"Scale"],
584 "pixels/degree"), Isis::Pvl::Replace);
587 (QString) mapGroup[
"UpperLeftCornerX"],
588 "meters"), Isis::Pvl::Replace);
591 (QString) mapGroup[
"UpperLeftCornerY"],
592 "meters"), Isis::Pvl::Replace);
602 QString msg =
"Unable to create projection";
605 finalError.
append(errors);
638 int &samples,
int &lines,
643 double localRadius = proj->
LocalRadius(trueScaleLat);
648 double scale, pixelResolution;
651 pixelResolution = mapGroup[
"PixelResolution"];
652 scale = (2.0 *
Isis::PI * localRadius) / (360.0 * pixelResolution);
657 scale = mapGroup[
"Scale"];
658 pixelResolution = (2.0 *
Isis::PI * localRadius) / (360.0 * scale);
669 double minX = DBL_MAX;
670 double maxX = -DBL_MAX;
671 double minY = DBL_MAX;
672 double maxY = -DBL_MAX;
675 int eband = cam.
Bands();
677 for(
int band = 1; band <= eband; band++) {
681 for(
int line = 0; line <= cam.
Lines(); line++) {
685 for(samp = 0; samp <= cam.
Samples(); samp++) {
686 if (cam.
SetImage((
double)samp + 0.5, (
double)line + 0.5)) {
695 if ((line != 0) && (line != cam.
Lines()))
break;
702 for(samp = cam.
Samples(); samp >= 0; samp--) {
703 if (cam.
SetImage((
double)samp + 0.5, (
double)line + 0.5)) {
721 if (cam.
Sample() >= 0.5 && cam.
Line() >= 0.5 &&
736 if (cam.
Sample() >= 0.5 && cam.
Line() >= 0.5 &&
754 for(
double lat = p_minlat; lat <= p_maxlat; lat += (p_maxlat - p_minlat) / 10.0) {
755 if (SetUniversalGround(lat, 0.0)) {
756 if (Sample() >= 0.5 && Line() >= 0.5 &&
757 Sample() <= p_samples + 0.5 && Line() <= p_lines + 0.5) {
768 for(
double lat = p_minlat; lat <= p_maxlat; lat += (p_maxlat - p_minlat) / 10.0) {
769 if (SetUniversalGround(lat, 180.0)) {
770 if (Sample() >= 0.5 && Line() >= 0.5 &&
771 Sample() <= p_samples + 0.5 && Line() <= p_lines + 0.5) {
772 p_minlon180 = -180.0;
787 if (fabs(fmod(minX, pixelResolution)) > 1.0e-6) {
788 if (pixelResolution - fabs(fmod(minX, pixelResolution)) > 1.0e-6) {
789 double sampleOffset = floor(minX / pixelResolution);
790 minX = sampleOffset * pixelResolution;
795 if (maxX < minX + pixelResolution) {
796 maxX = minX + pixelResolution;
798 if (fabs(fmod(maxY, pixelResolution)) > 1.0e-6) {
799 if (pixelResolution - fabs(fmod(maxY, pixelResolution)) > 1.0e-6) {
800 double lineOffset = -1.0 * ceil(maxY / pixelResolution);
801 maxY = -1.0 * lineOffset * pixelResolution;
806 if (minY > maxY - pixelResolution) {
807 minY = maxY - pixelResolution;
811 samples = (int)((maxX - minX) / pixelResolution + 0.5);
812 lines = (int)((maxY - minY) / pixelResolution + 0.5);
815 double upperLeftX = minX;
819 double upperLeftY = maxY;
825 (QString) mapGroup[
"PixelResolution"],
826 "meters/pixel"), Isis::Pvl::Replace);
829 (QString) mapGroup[
"Scale"],
830 "pixels/degree"), Isis::Pvl::Replace);
833 (QString) mapGroup[
"UpperLeftCornerX"],
834 "meters"), Isis::Pvl::Replace);
837 (QString) mapGroup[
"UpperLeftCornerY"],
838 "meters"), Isis::Pvl::Replace);
841 (QString) mapGroup[
"EquatorialRadius"],
842 "meters"), Isis::Pvl::Replace);
845 (QString) mapGroup[
"PolarRadius"],
846 "meters"), Isis::Pvl::Replace);
856 QString msg =
"Unable to create projection";
889 int &samples,
int &lines,
Camera &cam) {
899 double scale, pixelResolution;
902 pixelResolution = mapGroup[
"PixelResolution"];
903 scale = (2.0 *
Isis::PI * localRadius) / (360.0 * pixelResolution);
910 scale = mapGroup[
"Scale"];
911 pixelResolution = (2.0 *
Isis::PI * localRadius) / (360.0 * scale);
915 "meters/pixel"), Isis::Pvl::Replace);
921 double minX = DBL_MAX;
922 double maxX = -DBL_MAX;
923 double minY = DBL_MAX;
924 double maxY = -DBL_MAX;
927 int eband = cam.
Bands();
929 for(
int band = 1; band <= eband; band++) {
933 for(
int line = 0; line <= cam.
Lines(); line++) {
937 for(samp = 0; samp <= cam.
Samples(); samp++) {
938 if (cam.
SetImage((
double)samp + 0.5, (
double)line + 0.5)) {
947 if ((line != 0) && (line != cam.
Lines()))
break;
954 for(samp = cam.
Samples(); samp >= 0; samp--) {
955 if (cam.
SetImage((
double)samp + 0.5, (
double)line + 0.5)) {
975 for(
double rad = p_minRadius; rad <= p_maxRadius; rad += (p_maxRadius - p_minRadius) / 10.0) {
976 if (SetUniversalGround(rad, 0.0)) {
977 if (Sample() >= 0.5 && Line() >= 0.5 &&
978 Sample() <= p_samples + 0.5 && Line() <= p_lines + 0.5) {
989 for(
double rad = p_minrad; rad <= p_maxrad; rad += (p_maxrad - p_minrad) / 10.0) {
990 if (SetUniversalGround(rad, 180.0)) {
991 if (Sample() >= 0.5 && Line() >= 0.5 &&
992 Sample() <= p_samples + 0.5 && Line() <= p_lines + 0.5) {
1008 if (fabs(fmod(minX, pixelResolution)) > 1.0e-6) {
1009 if (pixelResolution - fabs(fmod(minX, pixelResolution)) > 1.0e-6) {
1010 double sampleOffset = floor(minX / pixelResolution);
1011 minX = sampleOffset * pixelResolution;
1016 if (maxX < minX + pixelResolution) {
1017 maxX = minX + pixelResolution;
1020 if (fabs(fmod(maxY, pixelResolution)) > 1.0e-6) {
1021 if (pixelResolution - fabs(fmod(maxY, pixelResolution)) > 1.0e-6) {
1022 double lineOffset = -1.0 * ceil(maxY / pixelResolution);
1023 maxY = -1.0 * lineOffset * pixelResolution;
1028 if (minY > maxY - pixelResolution) {
1029 minY = maxY - pixelResolution;
1033 samples = (int)((maxX - minX) / pixelResolution + 0.5);
1034 lines = (int)((maxY - minY) / pixelResolution + 0.5);
1037 double upperLeftX = minX;
1039 Isis::Pvl::Replace);
1041 double upperLeftY = maxY;
1043 Isis::Pvl::Replace);
1047 (QString) mapGroup[
"PixelResolution"],
1048 "meters/pixel"), Isis::Pvl::Replace);
1051 (QString) mapGroup[
"Scale"],
1052 "pixels/degree"), Isis::Pvl::Replace);
1055 (QString) mapGroup[
"UpperLeftCornerX"],
1056 "meters"), Isis::Pvl::Replace);
1059 (QString) mapGroup[
"UpperLeftCornerY"],
1060 "meters"), Isis::Pvl::Replace);
1070 QString msg =
"Unable to create projection";
1071 if (label.
fileName() !=
"") msg +=
" from file [" + label.
fileName() +
"]";
1086 return CreateFromCube(*cube.
label());
1098 return RingsCreateFromCube(*cube.
label());
1116 double pixelResolution = mapGroup[
"PixelResolution"];
1119 double upperLeftX = mapGroup[
"UpperLeftCornerX"];
1120 double upperLeftY = mapGroup[
"UpperLeftCornerY"];
1133 QString msg =
"Unable to initialize cube projection";
1134 if (label.
fileName() !=
"") msg +=
" from file [" + label.
fileName() +
"]";
1155 double pixelResolution = mapGroup[
"PixelResolution"];
1158 double upperLeftX = mapGroup[
"UpperLeftCornerX"];
1159 double upperLeftY = mapGroup[
"UpperLeftCornerY"];
1172 QString msg =
"Unable to initialize cube projection";
1173 if (label.
fileName() !=
"") msg +=
" from file [" + label.
fileName() +
"]";
double meters() const
Get the distance in meters.
const double Null
Value for an Isis Null pixel.
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
bool SetUniversalGround(const double lat, const double lon)
This method is used to set the latitude/longitude which must be Planetocentric (latitude) and Positiv...
File name manipulation and expansion.
const double PI
The mathematical constant PI.
double UniversalLatitude() const
Returns the planetocentric latitude, in degrees, at the surface intersection point in the body fixed ...
Base class for Map TProjections.
void append(const IException &exceptionSource)
Appends the given exception (and its list of previous exceptions) to this exception's causational exc...
Namespace for the standard library.
void SetWorldMapper(WorldMapper *mapper)
If desired the programmer can use this method to set a world mapper to be used in the SetWorld...
bool IsGood() const
This indicates if the last invocation of SetGround, SetCoordinate, SetUniversalGround, or SetWorld was with successful or not.
double XCoord() const
This returns the projection X provided SetGround, SetCoordinate, SetUniversalGround, or SetWorld returned with success.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
void addKeyword(const PvlKeyword &keyword, const InsertMode mode=Append)
Add a keyword to the container.
Loads plugins from a shared library.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
bool hasObject(const QString &name) const
Returns a boolean value based on whether the object exists in the current PvlObject or not...
Distance LocalRadius() const
Returns the local radius at the intersection point.
bool SetUniversalGround(const double latitude, const double longitude)
Sets the lat/lon values to get the sample/line values.
bool SetImage(const double sample, const double line)
Sets the sample/line values of the image to get the lat/lon values.
Base class for Map Projections.
bool HasGroundRange() const
This indicates if the longitude direction type is positive west (as opposed to postive east)...
Contains multiple PvlContainers.
#define _FILEINFO_
Macro for the filename and line number.
double Sample()
Returns the current sample number.
A single keyword-value pair.
virtual double TrueScaleRingRadius() const
This method returns the radius of true scale.
double LocalRadius(double lat) const
This method returns the local radius in meters at the specified latitude position.
double YCoord() const
This returns the projection Y provided SetGround, SetCoordinate, SetUniversalGround, or SetWorld returned with success.
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
virtual bool SetGround(const double ringRadius, const double ringLongitude)
This method is used to set the ring radius/longitude (assumed to be of the correct LatitudeType...
Container for cube-like labels.
double UniversalLongitude() const
Returns the positive east, 0-360 domain longitude, in degrees, at the surface intersection point in t...
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...
virtual bool IsBandIndependent()
Virtual method that checks if the band is independent.
Base class for Map Projections of plane shapes.
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
int Bands() const
Returns the number of bands in the image.
Displacement is a signed length, usually in meters.
double Line()
Returns the current line number.
int Lines() const
Returns the number of lines in the image.
int Samples() const
Returns the number of samples in the image.
QString fileName() const
Returns the filename used to initialise the Pvl object.
Namespace for ISIS/Bullet specific routines.
virtual 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...
virtual void SetBand(const int band)
Virtual method that sets the band number.
bool fileExists() const
Returns true if the file exists; false otherwise.
virtual double TrueScaleLatitude() const
This method returns the latitude of true scale.
IO Handler for Isis Cubes.
virtual 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...