Isis 3 Programmer Reference
ProcessImportPds.cpp
1
6/* SPDX-License-Identifier: CC0-1.0 */
7#include "ProcessImportPds.h"
8
9#include <QString>
10
11#include <iostream>
12#include <QString>
13#include <sstream>
14
15#include "IException.h"
16#include "ImportPdsTable.h"
17#include "IString.h"
18#include "LineManager.h"
19#include "OriginalLabel.h"
20#include "PixelType.h"
21#include "Preference.h"
22#include "Projection.h"
23#include "TProjection.h"
24#include "Pvl.h"
25#include "PvlKeyword.h"
26#include "PvlGroup.h"
27#include "PvlObject.h"
28#include "PvlTokenizer.h"
29#include "PvlToPvlTranslationManager.h"
30#include "SpecialPixel.h"
31#include "Table.h"
32#include "UserInterface.h"
33
34using namespace std;
35namespace Isis {
36
42 p_encodingType = NONE;
43 p_jp2File.clear();
45 p_projectionOffsetGroup.setName("ProjectionOffsets");
46
47 // Set up a translater for PDS file of type IMAGE
48 p_transDir = "$ISISROOT/appdata";
49 }
50
51
52 ProcessImportPds::~ProcessImportPds() {
53 }
54
55
62
63
89
90 QString str;
91
92 if (pdsXlater.InputHasKeyword("ProjectionName")) {
93 p_projection = pdsXlater.Translate("ProjectionName");
94 }
95 else {
96 QString message = "No projection name in labels";
97 throw IException(IException::Unknown, message, _FILEINFO_);
98 }
99
100 if (pdsXlater.InputHasKeyword("TargetName")) {
101 p_targetName = pdsXlater.Translate("TargetName");
102 }
103 else {
104 QString message = "No target name in labels";
105 throw IException(IException::Unknown, message, _FILEINFO_);
106 }
107
108 if (pdsXlater.InputHasKeyword("EquatorialRadius")) {
109 str = pdsXlater.Translate("EquatorialRadius");
110 p_equatorialRadius = toDouble(str) * 1000.0;
111 }
112 else {
113 QString message = "No equatorial radius name in labels";
114 throw IException(IException::User, message, _FILEINFO_);
115 }
116
117 if (pdsXlater.InputHasKeyword("PolarRadius")) {
118 str = pdsXlater.Translate("PolarRadius");
119 p_polarRadius = toDouble(str) * 1000.0;
120 }
121 else {
122 QString message = "No polar radius in labels";
123 throw IException(IException::User, message, _FILEINFO_);
124 }
125
126 if (pdsXlater.InputHasKeyword("LongitudeDirection")) {
127 p_longitudeDirection = pdsXlater.Translate("LongitudeDirection");
128 }
129 else {
130 p_longitudeDirection = pdsXlater.Translate("LongitudeDirection2");
131 }
132
134 p_latitudeType = "Planetocentric";
135 }
136 else if (pdsXlater.InputHasKeyword("LatitudeType2")) {
137 p_latitudeType = pdsXlater.Translate("LatitudeType2");
138 }
139 else {
140 p_latitudeType = pdsXlater.Translate("LatitudeType");
141 }
142
143 if (pdsXlater.InputHasKeyword("MinimumLatitude")) {
144 str = pdsXlater.Translate("MinimumLatitude");
145 try {
147 }
148 catch(IException &e) {
149 p_minimumLatitude = Isis::NULL8;
150 }
151 }
152 else {
153 p_minimumLatitude = Isis::NULL8;
154 }
155
156 if (pdsXlater.InputHasKeyword("MaximumLatitude")) {
157 str = pdsXlater.Translate("MaximumLatitude");
158 try {
160 }
161 catch(IException &e) {
162 p_maximumLatitude = Isis::NULL8;
163 }
164 }
165 else {
166 p_maximumLatitude = Isis::NULL8;
167 }
168
169 // This variable represents if the longitudes were read in as
170 // positive west
171 bool positiveWest = false;
172 if (pdsXlater.InputHasKeyword("MinimumLongitude")) {
173 str = pdsXlater.Translate("MinimumLongitude");
174 try {
175 positiveWest = true;
177 }
178 catch(IException &e) {
179 p_minimumLongitude = Isis::NULL8;
180 }
181 }
182 else if (pdsXlater.InputHasKeyword("MinimumLongitude2")) {
183 str = pdsXlater.Translate("MinimumLongitude2");
184 try {
186 }
187 catch(IException &e) {
188 p_minimumLongitude = Isis::NULL8;
189 }
190 }
191 else {
192 p_minimumLongitude = Isis::NULL8;
193 }
194
195 if (pdsXlater.InputHasKeyword("MaximumLongitude")) {
196 str = pdsXlater.Translate("MaximumLongitude");
197 try {
198 positiveWest = true;
200 }
201 catch(IException &e) {
202 p_maximumLongitude = Isis::NULL8;
203 }
204 }
205 else if (pdsXlater.InputHasKeyword("MaximumLongitude2")) {
206 str = pdsXlater.Translate("MaximumLongitude2");
207 try {
209 }
210 catch(IException &e) {
211 p_maximumLongitude = Isis::NULL8;
212 }
213 }
214 else {
215 p_maximumLongitude = Isis::NULL8;
216 }
217
218 str = pdsXlater.Translate("LongitudeDomain");
220
239 if (positiveWest && (p_longitudeDirection.compare("PositiveEast") == 0)) {
240 double tmp = p_minimumLongitude;
242 p_maximumLongitude = tmp;
243 }
244
246 // Force the change to 180
247 p_longitudeDomain = 180;
249 }
250
251 // If either the minimumLongitude or maximumLongitude are < 0, change
252 // longitude Domain to 180.
253 if (p_minimumLongitude < 0 || p_maximumLongitude < 0) {
254 p_longitudeDomain = 180;
255 }
256
257 str = pdsXlater.Translate("PixelResolution");
259 str = pdsXlater.InputKeyword("PixelResolution").unit().toUpper();
260 // Assume KM/PIXEL if the unit doesn't exist or is not METERS/PIXEL
261 if ((str != "METERS/PIXEL") && (str != "M/PIXEL") && (str != "M/PIX")) {
262 p_pixelResolution *= 1000.0;
263 }
264
265 str = pdsXlater.Translate("Scale");
266 p_scaleFactor = toDouble(str);
267
268 try {
269 str = pdsXlater.Translate("Rotation");
270 p_rotation = toDouble(str);
271 }
272 catch(IException &) {
273 // assume no rotation if the value isn't a number
274 p_rotation = 0.0;
275 }
276
277 // Look for projection offsets/mults to convert between line/samp and x/y
278 double xoff, yoff, xmult, ymult;
279 GetProjectionOffsetMults(xoff, yoff, xmult, ymult);
280
281 if (pdsXlater.InputHasKeyword("LineProjectionOffset")) {
282 str = pdsXlater.Translate("LineProjectionOffset");
283 }
284 else {
285 str = pdsXlater.Translate("LineProjectionOffset2");
286 }
287 p_lineProjectionOffset = toDouble(str);
288 p_upperLeftY = ymult * (p_lineProjectionOffset + yoff) * p_pixelResolution;
289
290 if (pdsXlater.InputHasKeyword("SampleProjectionOffset")) {
291 str = pdsXlater.Translate("SampleProjectionOffset");
292 }
293 else {
294 str = pdsXlater.Translate("SampleProjectionOffset2");
295 }
296 p_sampleProjectionOffset = toDouble(str);
297 p_upperLeftX = xmult * (p_sampleProjectionOffset + xoff) * p_pixelResolution;
298
299 p_projectionOffsetGroup.addKeyword(PvlKeyword("xOffset", QString::number(xoff)));
300 p_projectionOffsetGroup.addKeyword(PvlKeyword("yOffset", QString::number(yoff)));
301 p_projectionOffsetGroup.addKeyword(PvlKeyword("xMultiplier", QString::number(xmult)));
302 p_projectionOffsetGroup.addKeyword(PvlKeyword("yMultiplier", QString::number(ymult)));
303
304 }
305
306
315 for (unsigned int i = 0; i < OutputCubes.size(); i++) {
316 OutputCubes[i]->write(ol);
317 }
318 }
320 }
321
322
329
330
337
338
351 void ProcessImportPds::GetProjectionOffsetMults(double &xoff, double &yoff,
352 double &xmult, double &ymult) {
353
354 xmult = -1.0;
355 ymult = 1.0;
356 xoff = 0.5;
357 yoff = 0.5;
358
359 // Open projectionOffsetMults file
360 Isis::Pvl p(p_transDir + "/" + "translations/pdsProjectionLineSampToXY.def");
361
362 Isis::PvlObject &projDef = p.findObject("ProjectionOffsetMults",
364
365 for(int g = 0; g < projDef.groups(); g++) {
366 QString key = projDef.group(g)["Keyword"];
367 if (p_pdsLabel.hasKeyword(key)) {
368 QString value = p_pdsLabel[key];
369 QString pattern = projDef.group(g)["Pattern"];
370 // If value contains pattern, then set the mults to what is in translation file and
371 // update p_pdfChange
372 if (value.contains(pattern)) {
373 xmult = projDef.group(g)["xMult"];
374 ymult = projDef.group(g)["yMult"];
375 xoff = projDef.group(g)["xOff"];
376 yoff = projDef.group(g)["yOff"];
378 return;
379 }
380 }
381 }
382 }
383
384
392
393 // Create a temporary Isis::PvlToPvlTranslationManager so we can find out what
394 // type of input file we have
395 stringstream trnsStrm;
396 trnsStrm << "Group = PdsFile" << endl;
397 trnsStrm << " InputPosition = ROOT" << endl;
398 trnsStrm << " InputKey = PDS_VERSION_ID" << endl;
399 trnsStrm << "EndGroup" << endl;
400 trnsStrm << "Group = Isis2File" << endl;
401 trnsStrm << " InputPosition = ROOT" << endl;
402 trnsStrm << " InputKey = CCSD3ZF0000100000001NJPL3IF0PDS200000001" << endl;
403 trnsStrm << "EndGroup" << endl;
404 trnsStrm << "END";
405
406 Isis::PvlToPvlTranslationManager sourceXlater(inputLabel, trnsStrm);
407
408 if (sourceXlater.InputHasKeyword("PdsFile")) {
409 p_source = PDS;
410 }
411 else if (sourceXlater.InputHasKeyword("Isis2File")) {
412 p_source = ISIS2;
413 }
414 else {
415 p_source = NOSOURCE;
416 }
417
418 }
419
420
428 Table &ProcessImportPds::ImportTable(QString pdsTableName) {
429 // No table file given, let ImportPdsTable find it.
430 ImportPdsTable pdsTable(p_labelFile, "", pdsTableName);
431 // reformat the table name. If the name ends with the word "Table", remove
432 // it. (So, for example, INSTRUMENT_POINTING_TABLE gets formatted to
433 // InstrumentPointingTable and then to InstrumentPointing)
434 QString isisTableName = pdsTable.getFormattedName(pdsTableName);
435 int found = isisTableName.lastIndexOf("Table");
436 if (found == isisTableName.length() - 5) {
437 isisTableName.remove(found, 5);
438 }
439
440 Table isisTable = pdsTable.importTable(isisTableName);
441 p_tables.push_back(isisTable);
442
443 return p_tables.at(p_tables.size() - 1);
444 }
445
446
456
457 if (p_source == ISIS2) {
458
459 return true;
460 }
461 else {
462 return false;
463 }
464
465 }
466
467
475
476
484 const bool & calcOffsetOnly) {
485
486 const PvlKeyword & dataFilePointer = pdsXlater.InputKeyword("DataFilePointer");
487
488 QString dataFileName;
489 QString units;
490 QString str;
491 int offset = -1;
492
493 // If only size 1, we either have a file name or an offset
494 // Either way, when we're done with these two ifs, variables offset and
495 // dataFileName will be set.
496 if (dataFilePointer.size() == 1) {
497 try {
498 str = pdsXlater.Translate("DataFilePointer");
499 offset = toInt(str);
500 units = dataFilePointer.unit();
501 // Successful? we have an offset, means current, p_labelFile
502 // is the location of the data as well
503 dataFileName = FileName(p_labelFile).name();
504 }
505 catch(IException &e) {
506 // Failed to parse to an int, means we have a file name
507 // No offset given, so we use 1, offsets are 1 based
508 offset = 1;
509 units = "BYTES";
510 dataFileName = str;
511 }
512 }
513 // We must have a filename and an offset, in that order
514 // Expection ("filname", <offset>)
515 else if (dataFilePointer.size() == 2) {
516 dataFileName = pdsXlater.Translate("DataFilePointer", 0);
517 offset = IString(pdsXlater.Translate("DataFilePointer", 1)).ToInteger();
518 units = dataFilePointer.unit(1);
519 }
520 // Error, no value
521 else if (dataFilePointer.size() == 0) {
522 QString msg = "Data file pointer ^IMAGE or ^QUBE has no value, must"
523 "have either file name or offset or both, in [" +
524 p_labelFile + "]";
525 throw IException(IException::Unknown, msg, _FILEINFO_);
526 }
527 // Error, more than two values
528 else {
529 QString msg = "Improperly formatted data file pointer keyword ^IMAGE or "
530 "^QUBE, in [" + p_labelFile + "], must contain filename "
531 " or offset or both";
532 throw IException(IException::Unknown, msg, _FILEINFO_);
533 }
534
535 // Now, to handle the values we found
536 // the filename first, only do so if calcOffsetOnly is false
537 if (!calcOffsetOnly) {
538 Isis::FileName labelFile(p_labelFile);
539
540 // If dataFileName isn't empty, and does start at the root, use it
541 Isis::FileName dataFile;
542 if (dataFileName.size() != 0 && dataFileName.at(0) == '/')
543 dataFile = FileName(dataFileName);
544 // Otherwise, use the path to it and its name
545 else
546 dataFile = FileName(labelFile.path() + "/" + dataFileName);
547
548 // If it exists, use it
549 if (dataFile.fileExists()) {
550 SetInputFile(dataFile.expanded());
551 }
552 // Retry with downcased name, if still no luck, fail
553 else {
554 QString tmp = dataFile.expanded();
555 dataFileName = dataFileName.toLower();
556 dataFile = FileName(labelFile.path() + "/" + dataFileName);
557 if (dataFile.fileExists()) {
558 SetInputFile(dataFile.expanded());
559 }
560 else {
561 QString msg = "Unable to find input file [" + tmp + "] or [" +
562 dataFile.expanded() + "]";
563 throw IException(IException::Io, msg, _FILEINFO_);
564 }
565 }
566 }
567
568 // Now, to handle the offset
569 units = units.trimmed();
570 if (units == "BYTES" || units == "B") {
571 SetFileHeaderBytes(offset - 1);
572 }
573 else {
574 QString recSize = pdsXlater.Translate("DataFileRecordBytes");
575 SetFileHeaderBytes((offset - 1) * toInt(recSize));
576 }
577 }
578
579
595 void ProcessImportPds::ProcessLabel(const QString &pdsDataFile, PdsFileType allowedTypes) {
596 // Create a temporary Isis::PvlToPvlTranslationManager so we can find out what
597 // type of PDS file this is (i.e., Qube or Image or SpectralQube)
598 stringstream trnsStrm;
599 trnsStrm << "Group = PdsTypeImage" << endl;
600 trnsStrm << " InputPosition = ROOT" << endl;
601 trnsStrm << " InputPosition = FILE" << endl;
602 trnsStrm << " InputPosition = UNCOMPRESSED_FILE" << endl;
603 trnsStrm << " InputKey = ^IMAGE" << endl;
604 trnsStrm << "EndGroup" << endl;
605 trnsStrm << "Group = PdsCombinedSpectrum" << endl;
606 trnsStrm << " InputPosition = ROOT" << endl;
607 trnsStrm << " InputPosition = FILE" << endl;
608 trnsStrm << " InputPosition = UNCOMPRESSED_FILE" << endl;
609 trnsStrm << " InputKey = ^COMBINED_SPECTRUM" << endl;
610 trnsStrm << "EndGroup" << endl;
611 trnsStrm << "Group = PdsTypeL0" << endl;
612 trnsStrm << " InputPosition = L0_FILE" << endl;
613 trnsStrm << " InputKey = ^L0_IMAGE" << endl;
614 trnsStrm << "EndGroup" << endl;
615 trnsStrm << "Group = PdsTypeRdn" << endl;
616 trnsStrm << " InputPosition = RDN_FILE" << endl;
617 trnsStrm << " InputKey = ^RDN_IMAGE" << endl;
618 trnsStrm << "EndGroup" << endl;
619 trnsStrm << "Group = PdsTypeLoc" << endl;
620 trnsStrm << " InputPosition = LOC_FILE" << endl;
621 trnsStrm << " InputKey = ^LOC_IMAGE" << endl;
622 trnsStrm << "EndGroup" << endl;
623 trnsStrm << "Group = PdsTypeObs" << endl;
624 trnsStrm << " InputPosition = OBS_FILE" << endl;
625 trnsStrm << " InputKey = ^OBS_IMAGE" << endl;
626 trnsStrm << "EndGroup" << endl;
627 trnsStrm << "Group = PdsTypeQube" << endl;
628 trnsStrm << " InputKey = ^QUBE" << endl;
629 trnsStrm << "EndGroup" << endl;
630 trnsStrm << "Group = PdsTypeSpectralQube" << endl;
631 trnsStrm << " InputKey = ^SPECTRAL_QUBE" << endl;
632 trnsStrm << "EndGroup" << endl;
633 trnsStrm << "Group = PdsEncodingType" << endl;
634 trnsStrm << " InputPosition = COMPRESSED_FILE" << endl;
635 trnsStrm << " InputKey = ENCODING_TYPE" << endl;
636 trnsStrm << " Translation = (*,*)" << endl;
637 trnsStrm << "EndGroup" << endl;
638 trnsStrm << "Group = PdsCompressedFile" << endl;
639 trnsStrm << " InputPosition = COMPRESSED_FILE" << endl;
640 trnsStrm << " InputKey = FILE_NAME" << endl;
641 trnsStrm << " Translation = (*,*)" << endl;
642 trnsStrm << "EndGroup" << endl;
643 trnsStrm << "END";
644
645
646 //tjw
647 //Determine if we are processing a QUBE whose
648 //core data type is VAX_REAL
649
650 try {
651 PvlObject obj = p_pdsLabel.findObject("QUBE");
652 PvlKeyword coreKey = obj.findKeyword("CORE_ITEM_TYPE");
653 PvlKeyword suffixKey = obj.findKeyword("BAND_SUFFIX_ITEM_TYPE");
654 //if ( (coreKey[0] == "VAX_REAL") && (suffixKey[0] =="VAX_REAL") )
655
656 if (coreKey[0] == "VAX_REAL") {
658 }
659 }
660 catch (IException &e) {
661 }
662
663 Isis::PvlToPvlTranslationManager pdsXlater(p_pdsLabel, trnsStrm);
664
665 // Check to see if we are dealing with a JPEG2000 file
666 QString str;
667 if (pdsXlater.InputHasKeyword("PdsEncodingType")) {
668 str = pdsXlater.Translate("PdsEncodingType");
669 if (str == "JP2") {
670 p_encodingType = JP2;
671 str = pdsXlater.Translate("PdsCompressedFile");
672 if (pdsDataFile.isEmpty()) {
674 Isis::FileName ifile(lfile.path() + "/" + str);
675 if (ifile.fileExists()) {
676 p_jp2File = ifile.expanded();
677 }
678 else {
679 QString tmp = ifile.expanded();
680 str = str.toLower();
681 ifile = lfile.path() + "/" + str;
682 if (ifile.fileExists()) {
683 p_jp2File = ifile.expanded();
684 }
685 else {
686 QString msg = "Unable to find input file [" + tmp + "] or [" +
687 ifile.expanded() + "]";
688 throw IException(IException::Io, msg, _FILEINFO_);
689 }
690 }
691 }
692 }
693 else {
694 QString msg = "Unsupported encoding type in [" + p_labelFile + "]";
695 throw IException(IException::Io, msg, _FILEINFO_);
696 }
697 }
698
699
700 // Call the correct label processing
701 if ((allowedTypes & Image) == Image && pdsXlater.InputHasKeyword("PdsTypeImage")) {
702
703 ProcessPdsImageLabel(pdsDataFile);
704 }
705 else if ((allowedTypes & Qube) == Qube && pdsXlater.InputHasKeyword("PdsTypeQube")) {
706
707 ProcessPdsQubeLabel(pdsDataFile, "pdsQube.trn");
708 }
709 else if ((allowedTypes & SpectralQube) == SpectralQube &&
710 pdsXlater.InputHasKeyword("PdsTypeSpectralQube")) {
711
712 ProcessPdsQubeLabel(pdsDataFile, "pdsSpectralQube.trn");
713 }
714 else if ((allowedTypes & L0) == L0 && pdsXlater.InputHasKeyword("PdsTypeL0")) {
715
716 ProcessPdsM3Label(pdsDataFile, L0);
717 }
718 else if ((allowedTypes & Rdn) == Rdn && pdsXlater.InputHasKeyword("PdsTypeRdn")) {
719
720 ProcessPdsM3Label(pdsDataFile, Rdn);
721 }
722 else if ((allowedTypes & Loc) == Loc && pdsXlater.InputHasKeyword("PdsTypeLoc")) {
723
724 ProcessPdsM3Label(pdsDataFile, Loc);
725 }
726 else if ((allowedTypes & Obs) == Obs && pdsXlater.InputHasKeyword("PdsTypeObs")) {
727
728 ProcessPdsM3Label(pdsDataFile, Obs);
729 }
730 else if ((allowedTypes & CombinedSpectrum) == CombinedSpectrum &&
731 pdsXlater.InputHasKeyword("PdsCombinedSpectrum")) {
732
734 }
735 else {
736 QString msg = "Unknown label type in [" + p_labelFile + "]. It is possible the label file "
737+ "does not describe an image product (IMAGE, CUBE, or SPECTRALCUBE).";
738 throw IException(IException::Io, msg, _FILEINFO_);
739 }
740
741
742 // Find out if this is a PDS file or an ISIS2 file
744
745
746 return;
747 }
748
749
761 void ProcessImportPds::ProcessPdsCombinedSpectrumLabel(const QString &pdsDataFile) {
762 Isis::FileName transFile(p_transDir + "/translations/pdsCombinedSpectrum.trn");
763 Isis::PvlToPvlTranslationManager pdsXlater(p_pdsLabel, transFile.expanded());
764
765 QString str;
766
767 str = pdsXlater.Translate("CoreLinePrefixBytes");
769
770 str = pdsXlater.Translate("CoreLineSuffixBytes");
772
773 ProcessPixelBitandType(pdsXlater);
774
775 str = pdsXlater.Translate("CoreByteOrder");
776 SetByteOrder(Isis::ByteOrderEnumeration(str));
777
778 str = pdsXlater.Translate("CoreSamples");
779 int ns = toInt(str);
780 str = pdsXlater.Translate("CoreLines");
781 int nl = toInt(str);
782 str = pdsXlater.Translate("CoreBands");
783 int nb = toInt(str);
784
785 SetDimensions(ns, nl, nb);
786
787 //-----------------------------------------------------------------
788 // Find the data filename it may be the same as the label file
789 // OR the label file may contain a pointer to the data
790 //-----------------------------------------------------------------
791
792 // Use the name supplied by the application if it is there
793 if (pdsDataFile.length() > 0) {
794 ProcessDataFilePointer(pdsXlater, false);
795 }
796 // If the data is in JPEG 2000 format, then use the name of the file
797 // from the label
798 else if (p_jp2File.length() > 0) {
800 ProcessDataFilePointer(pdsXlater, true);
801 }
802 // Use the "^IMAGE or ^QUBE" label to get the filename for the image data
803 // Get the path portion from user entered label file spec
804 else {
805 // Handle filename and offset
806 ProcessDataFilePointer(pdsXlater, false);
807 }
808
809 //------------------------------------------------------------
810 // Find the image data base and multiplier
811 //------------------------------------------------------------
812 str = pdsXlater.Translate("CoreBase");
813 SetBase(toDouble(str));
814 str = pdsXlater.Translate("CoreMultiplier");
816
817 // Find the organization of the image data
818 str = pdsXlater.Translate("CoreOrganization");
819
820 if (p_encodingType == JP2) {
822 }
823 else if (str == "BSQ") {
825 }
826 else if (str == "BIP") {
828 }
829 else if (str == "BIL") {
831 }
832 else {
833 QString msg = "Unsupported axis order [" + str + "]";
834 throw IException(IException::Programmer, msg, _FILEINFO_);
835 }
836 }
837
838
855 void ProcessImportPds::ProcessPdsQubeLabel(const QString &pdsDataFile,
856 const QString &transFile) {
857
858
859 Isis::FileName tFile(p_transDir + "/translations/" + transFile);
860
861 Isis::PvlToPvlTranslationManager pdsXlater(p_pdsLabel, tFile.expanded());
862
863 QString str;
864
865
866 // Find the organization of the image data
867 // Save off which axis the samples, lines and bands are on
868 int linePos = 0;
869 int samplePos = 0;
870 int bandPos = 0;
871 int val = pdsXlater.InputKeyword("CoreOrganization").size();
872 QString tmp = "";
873 for(int i = 0; i < val; i++) {
874 str = pdsXlater.Translate("CoreOrganization", i);
875 tmp += str;
876 if (str == "SAMPLE") {
877 samplePos = i;
878 }
879 else if (str == "LINE") {
880 linePos = i;
881 }
882 else if (str == "BAND") {
883 bandPos = i;
884 }
885 else {
886 QString message = "Unknown file axis name [" + str + "]";
887 throw IException(IException::User, message, _FILEINFO_);
888 }
889 }
890
891 if (p_encodingType == JP2) {
893 }
894 else if (tmp == "SAMPLELINEBAND") {
896 }
897 else if (tmp == "BANDSAMPLELINE") {
899 }
900 else if (tmp == "SAMPLEBANDLINE") {
902 }
903 else {
904 PvlKeyword pdsCoreOrg = p_pdsLabel.findKeyword(pdsXlater.
905 InputKeywordName("CoreOrganization"), Pvl::Traverse);
906
907 stringstream pdsCoreOrgStream;
908 pdsCoreOrgStream << pdsCoreOrg;
909
910 QString msg = "Unsupported axis order [" + QString(pdsCoreOrgStream.str().c_str()) + "]";
911 throw IException(IException::Programmer, msg, _FILEINFO_);
912 }
913
914
915 // Set the number of byte preceding the second dimension (left side plane)
916 // There are no capabilities in a PDS QUBE for this
918
919 // Set the number of bytes following the second dimension (right side plane)
920 str = pdsXlater.Translate("SuffixItemSize");
921 int suffix = toInt(str);
922 str = pdsXlater.Translate("AxisSuffixCount", 0);
923 suffix *= toInt(str);
924 SetDataSuffixBytes(suffix);
925
926 str = pdsXlater.Translate("SuffixItemSize");
927
928 // Only set DataTrailerBytes if we haven't already set it elsewhere. (It's inialized to 0.)
929 if (DataTrailerBytes() == 0) {
930 int trailer = toInt(str);
931 str = pdsXlater.Translate("AxisSuffixCount", 1);
932 trailer *= toInt(str);
933 str = pdsXlater.Translate("CoreSamples", samplePos);
934 trailer *= toInt(str);
935 trailer += suffix;
936 SetDataTrailerBytes(trailer);
937 }
938
939 // Save the Data Trailer if it exists
940 if (DataTrailerBytes() != 0) {
942 }
943
944 ProcessPixelBitandType(pdsXlater);
945
946 // Set the byte order
947
948 //tjw:
949 str = pdsXlater.Translate("CoreByteOrder");
950
951 SetByteOrder(Isis::ByteOrderEnumeration(str));
952
953 //if(str == "LSB" || str == "MSB")
954 // SetByteOrder(Isis::ByteOrderEnumeration(str));
955 //else {
956 // QString msg = "Unrecognized byte order ["+str+"]";
957 // throw IException(IException::Programmer,msg,_FILEINFO_);
958 //}
959
960
961
962 // Set the number of samples, lines and bands
963 str = pdsXlater.Translate("CoreSamples", samplePos);
964 int ns = toInt(str);
965 str = pdsXlater.Translate("CoreLines", linePos);
966 int nl = toInt(str);
967 str = pdsXlater.Translate("CoreBands", bandPos);
968 int nb = toInt(str);
969 SetDimensions(ns, nl, nb);
970
971
972 // Set any special pixels values, qube, so use true
973 ProcessSpecialPixels(pdsXlater, true);
974
975 //---------------------------------------------------------------
976 // Find the data filename, it may be the same as the label file
977 // Or the label file may contain a pointer to the data
978 //---------------------------------------------------------------
979
980 // Use the name supplied by the application if it is there
981 if (pdsDataFile.length() > 0) {
982 SetInputFile(pdsDataFile);
983 ProcessDataFilePointer(pdsXlater, true);
984 }
985 // If the data is in JPEG 2000 format, then use the name of the file
986 // from the label
987 else if (p_jp2File.length() > 0) {
989 ProcessDataFilePointer(pdsXlater, true);
990 }
991 else {
992 // Handle filename and offset
993 ProcessDataFilePointer(pdsXlater, false);
994 }
995
996
997 //------------------------------------------------------------
998 // Find the image data base and multiplier
999 //------------------------------------------------------------
1000 // First see if there are base and multiplier in the band bin group
1001 if ((pdsXlater.InputHasKeyword("BandBase")) &&
1002 (pdsXlater.InputHasKeyword("BandMultiplier"))) {
1003 vector<double> bases;
1004 vector<double> mults;
1005 for(int i = 0; i < pdsXlater.InputKeyword("BandBase").size(); i++) {
1006 str = pdsXlater.Translate("BandBase", i);
1007 bases.push_back(toDouble(str));
1008 str = pdsXlater.Translate("BandMultiplier", i);
1009 mults.push_back(toDouble(str));
1010 }
1011 SetBase(bases);
1012 SetMultiplier(mults);
1013 }
1014 else {
1015 str = pdsXlater.Translate("CoreBase");
1016 SetBase(toDouble(str));
1017 str = pdsXlater.Translate("CoreMultiplier");
1018 SetMultiplier(toDouble(str));
1019 }
1020 }
1021
1022
1034 void ProcessImportPds::ProcessPdsImageLabel(const QString &pdsDataFile) {
1035 Isis::FileName transFile(p_transDir + "/translations/pdsImage.trn");
1036 Isis::PvlToPvlTranslationManager pdsXlater(p_pdsLabel, transFile.expanded());
1037
1038 QString str;
1039
1040 str = pdsXlater.Translate("CoreLinePrefixBytes");
1042
1043 str = pdsXlater.Translate("CoreLineSuffixBytes");
1045
1046 ProcessPixelBitandType(pdsXlater);
1047
1048 str = pdsXlater.Translate("CoreByteOrder");
1049 SetByteOrder(Isis::ByteOrderEnumeration(str));
1050
1051 str = pdsXlater.Translate("CoreSamples");
1052 int ns = toInt(str);
1053 str = pdsXlater.Translate("CoreLines");
1054 int nl = toInt(str);
1055 str = pdsXlater.Translate("CoreBands");
1056 int nb = toInt(str);
1057
1058 SetDimensions(ns, nl, nb);
1059
1060 // Set any special pixel values, not qube, so use false
1061 ProcessSpecialPixels(pdsXlater, false);
1062
1063 //-----------------------------------------------------------------
1064 // Find the data filename it may be the same as the label file
1065 // OR the label file may contain a pointer to the data
1066 //-----------------------------------------------------------------
1067
1068 // Use the name supplied by the application if it is there
1069 if (pdsDataFile.length() > 0) {
1070 SetInputFile(pdsDataFile);
1071 ProcessDataFilePointer(pdsXlater, true);
1072 }
1073 // If the data is in JPEG 2000 format, then use the name of the file
1074 // from the label
1075 else if (p_jp2File.length() > 0) {
1077 ProcessDataFilePointer(pdsXlater, true);
1078 }
1079 // Use the "^IMAGE or ^QUBE" label to get the filename for the image data
1080 // Get the path portion from user entered label file spec
1081 else {
1082 // Handle filename and offset
1083 ProcessDataFilePointer(pdsXlater, false);
1084 }
1085
1086 //------------------------------------------------------------
1087 // Find the image data base and multiplier
1088 //------------------------------------------------------------
1089 str = pdsXlater.Translate("CoreBase");
1090 SetBase(toDouble(str));
1091 str = pdsXlater.Translate("CoreMultiplier");
1092 SetMultiplier(toDouble(str));
1093
1094 // Find the organization of the image data
1095 str = pdsXlater.Translate("CoreOrganization");
1096
1097 if (p_encodingType == JP2) {
1099 }
1100 else if (str == "BSQ") {
1102 }
1103 else if (str == "BIP") {
1105 }
1106 else if (str == "BIL") {
1108 }
1109 else {
1110 QString msg = "Unsupported axis order [" + str + "]";
1111 throw IException(IException::Programmer, msg, _FILEINFO_);
1112 }
1113 }
1114
1115
1121 QString str;
1122 str = pdsXlater.Translate("CoreBitsPerPixel");
1123 int bitsPerPixel = toInt(str);
1124 str = pdsXlater.Translate("CorePixelType");
1125
1126 if ((str == "Real") && (bitsPerPixel == 64)) {
1127
1128 SetPixelType(Isis::Double);
1129 }
1130 else if ((str == "Real") && (bitsPerPixel == 32)) {
1131 SetPixelType(Isis::Real);
1132 }
1133 else if ((str == "Integer") && (bitsPerPixel == 8)) {
1134 SetPixelType(Isis::UnsignedByte);
1135 }
1136 else if ((str == "Integer") && (bitsPerPixel == 16)) {
1137 SetPixelType(Isis::SignedWord);
1138 }
1139 else if ((str == "Integer") && (bitsPerPixel == 32)) {
1140 SetPixelType(Isis::SignedInteger);
1141 }
1142 else if ((str == "Natural") && (bitsPerPixel == 8)) {
1143 SetPixelType(Isis::UnsignedByte);
1144 }
1145 else if ((str == "Natural") && (bitsPerPixel == 16)) {
1146 SetPixelType(Isis::UnsignedWord);
1147 }
1148 else if ((str == "Natural") && (bitsPerPixel == 16)) {
1149 SetPixelType(Isis::SignedWord);
1150 }
1151 else if ((str == "Natural") && (bitsPerPixel == 32)) {
1152 SetPixelType(Isis::UnsignedInteger);
1153 }
1154
1155 else {
1156 QString msg = "Invalid PixelType and BitsPerPixel combination [" + str +
1157 ", " + toString(bitsPerPixel) + "]";
1158 throw IException(IException::Io, msg, _FILEINFO_);
1159 }
1160 }
1161
1162
1174 void ProcessImportPds::ProcessPdsM3Label(const QString &pdsDataFile, PdsFileType fileType) {
1175 Isis::FileName transFile;
1176 if (fileType == L0) {
1177 transFile = p_transDir + "/translations/pdsL0.trn";
1178 }
1179 else if (fileType == Rdn) {
1180 transFile = p_transDir + "/translations/pdsRdn.trn";
1181 }
1182 else if (fileType == Loc) {
1183 transFile = p_transDir + "/translations/pdsLoc.trn";
1184 }
1185 else if (fileType == Obs) {
1186 transFile = p_transDir + "/translations/pdsObs.trn";
1187 }
1188 else {
1189 throw IException(IException::Programmer, "ProcessImportPds::ProcessPdsM3Label can only be "
1190 "called with file type of L0, Rdn, Loc or Obs.", _FILEINFO_);
1191 }
1192 Isis::PvlToPvlTranslationManager pdsXlater(p_pdsLabel, transFile.expanded());
1193
1194 QString str;
1195
1196 // L1B (Rdn) products do not have an prefix or suffix data. L0 have 1280 bytes at the
1197 // beginning of each line of the BIL formatted file.
1198 str = pdsXlater.Translate("CoreLinePrefixBytes");
1200
1201 str = pdsXlater.Translate("CoreLineSuffixBytes");
1203
1204 ProcessPixelBitandType(pdsXlater);
1205
1206 str = pdsXlater.Translate("CoreByteOrder");
1207 SetByteOrder(Isis::ByteOrderEnumeration(str));
1208
1209 str = pdsXlater.Translate("CoreSamples");
1210 int ns = toInt(str);
1211 str = pdsXlater.Translate("CoreLines");
1212 int nl = toInt(str);
1213 str = pdsXlater.Translate("CoreBands");
1214 int nb = toInt(str);
1215 SetDimensions(ns, nl, nb);
1216
1217 // Set any special pixel values, not qube, so use false
1218 ProcessSpecialPixels(pdsXlater, false);
1219
1220 //-----------------------------------------------------------------
1221 // Find the data filename it may be the same as the label file
1222 // OR the label file may contain a pointer to the data
1223 //-----------------------------------------------------------------
1224
1225 // Use the name supplied by the application if it is there
1226 if (pdsDataFile.length() > 0) {
1227 SetInputFile(pdsDataFile);
1228 ProcessDataFilePointer(pdsXlater, true);
1229 }
1230 // If the data is in JPEG 2000 format, then use the name of the file
1231 // from the label
1232 else if (p_jp2File.length() > 0) {
1234 ProcessDataFilePointer(pdsXlater, true);
1235 }
1236 // Use the "^IMAGE or ^QUBE" label to get the filename for the image data
1237 // Get the path portion from user entered label file spec
1238 else {
1239 // Handle filename and offset
1240 ProcessDataFilePointer(pdsXlater, false);
1241 }
1242
1243 //------------------------------------------------------------
1244 // Find the image data base and multiplier
1245 //------------------------------------------------------------
1246 str = pdsXlater.Translate("CoreBase");
1247 SetBase(toDouble(str));
1248 str = pdsXlater.Translate("CoreMultiplier");
1249 SetMultiplier(toDouble(str));
1250
1251 // Find the organization of the image data
1252 str = pdsXlater.Translate("CoreOrganization");
1253
1254 if (p_encodingType == JP2) {
1256 }
1257 else if (str == "BSQ") {
1259 }
1260 else if (str == "BIP") {
1262 }
1263 else if (str == "BIL") {
1265 }
1266 else {
1267 QString msg = "Unsupported axis order [" + str + "]";
1268 throw IException(IException::Programmer, msg, _FILEINFO_);
1269 }
1270 }
1271
1272
1277 QString str;
1278 // Set any special pixel values
1279 double pdsNull = Isis::NULL8;
1280 if (pdsXlater.InputHasKeyword("CoreNull")) {
1281 str = pdsXlater.Translate("CoreNull");
1282 if (str != "NULL") {
1283 pdsNull = toDouble(str);
1284 }
1285 }
1286 else if (!isQube && pdsXlater.InputHasKeyword("CoreNull2")) {
1287 str = pdsXlater.Translate("CoreNull2");
1288 if (str != "NULL") {
1289 pdsNull = toDouble(str);
1290 }
1291 }
1292
1293 double pdsLrs = Isis::Lrs;
1294 if (pdsXlater.InputHasKeyword("CoreLrs")) {
1295 str = pdsXlater.Translate("CoreLrs");
1296 if (str != "NULL") {
1297 pdsLrs = toDouble(str);
1298 }
1299 }
1300 else if (!isQube && pdsXlater.InputHasKeyword("CoreLrs2")) {
1301 str = pdsXlater.Translate("CoreLrs2");
1302 if (str != "NULL") {
1303 pdsLrs = toDouble(str);
1304 }
1305 }
1306
1307 double pdsLis = Isis::Lis;
1308 if (pdsXlater.InputHasKeyword("CoreLis")) {
1309 str = pdsXlater.Translate("CoreLis");
1310 if (str != "NULL") {
1311 pdsLis = toDouble(str);
1312 }
1313 }
1314 else if (!isQube && pdsXlater.InputHasKeyword("CoreLis2")) {
1315 str = pdsXlater.Translate("CoreLis2");
1316 if (str != "NULL") {
1317 pdsLis = toDouble(str);
1318 }
1319 }
1320
1321 double pdsHrs = Isis::Hrs;
1322 if (pdsXlater.InputHasKeyword("CoreHrs")) {
1323 str = pdsXlater.Translate("CoreHrs");
1324 if (str != "NULL") {
1325 pdsHrs = toDouble(str);
1326 }
1327 }
1328 else if (!isQube && pdsXlater.InputHasKeyword("CoreHrs2")) {
1329 str = pdsXlater.Translate("CoreHrs2");
1330 if (str != "NULL") {
1331 pdsHrs = toDouble(str);
1332 }
1333 }
1334
1335 double pdsHis = Isis::His;
1336 if (pdsXlater.InputHasKeyword("CoreHis")) {
1337 str = pdsXlater.Translate("CoreHis");
1338 if (str != "NULL") {
1339 pdsHis = toDouble(str);
1340 }
1341 }
1342 else if (!isQube && pdsXlater.InputHasKeyword("CoreHis2")) {
1343 str = pdsXlater.Translate("CoreHis2");
1344 if (str != "NULL") {
1345 pdsHis = toDouble(str);
1346 }
1347 }
1348
1349 SetSpecialValues(pdsNull, pdsLrs, pdsLis, pdsHrs, pdsHis);
1350 }
1351
1352
1368 const QString &pdsDataFile,
1369 PdsFileType allowedTypes) {
1370
1371 // Save the label and file for future use
1372 p_pdsLabel = pdsLabelPvl;
1373 p_labelFile = pdsDataFile;
1374 ProcessLabel(pdsDataFile, allowedTypes);
1375 }
1376
1377
1395 void ProcessImportPds::SetPdsFile(const QString &pdsLabelFile,
1396 const QString &pdsDataFile,
1397 Isis::Pvl &pdsLabel,
1398 PdsFileType allowedTypes) {
1399
1400 // Internalize the PDS label in the PVL that was passed in
1401 try {
1402 pdsLabel.read(pdsLabelFile);
1403 }
1404 catch (IException &e) {
1406 QObject::tr("This image does not contain a pds label. You will need an "
1407 "image with a PDS label or a detached PDS label for this "
1408 "image."), _FILEINFO_);
1409 }
1410
1411 // Save the label and file for future use
1412 p_pdsLabel = pdsLabel;
1413 p_labelFile = pdsLabelFile;
1414 ProcessLabel(pdsDataFile, allowedTypes);
1415 }
1416
1417
1423 for (unsigned int i = 0; i < p_tables.size(); i++) {
1424 OutputCubes[0]->write(p_tables[i]);
1425 }
1426 return;
1427 }
1428
1429
1442 return;
1443 }
1444
1445
1446
1454 // Set up a translater for Isis2 labels
1455 QString transDir = "$ISISROOT/appdata";
1456
1457 Isis::FileName transFile(transDir + "/" + "translations/isis2bandbin.trn");
1458 Isis::PvlToPvlTranslationManager isis2Xlater(p_pdsLabel, transFile.expanded());
1459
1460 // Add all the Isis2 keywords that can be translated to the requested label
1461 isis2Xlater.Auto(lab);
1462 }
1463
1464
1472 // Set up a translater for Isis2 labels
1473 QString transDir = "$ISISROOT/appdata";
1474
1475 Isis::FileName transFile(transDir + "/" + "translations/isis2instrument.trn");
1476 Isis::PvlToPvlTranslationManager isis2Xlater(p_pdsLabel, transFile.expanded());
1477
1478 // Add all the Isis2 keywords that can be translated to the requested label
1479 isis2Xlater.Auto(lab);
1480
1481 //Check StartTime for appended 'z' (Zulu time) and remove
1482 Isis::PvlGroup &inst = lab.findGroup("Instrument");
1483
1484 if (inst.hasKeyword("StartTime")) {
1485 Isis::PvlKeyword &stkey = inst["StartTime"];
1486 QString stime = stkey[0];
1487 stime = stime.remove(QRegExp("[Zz]$"));
1488 stkey = stime;
1489 }
1490 }
1491
1492
1504
1505
1513 // Set up a translater for PDS labels
1514 Isis::FileName transFile(p_transDir + "/" + "translations/pdsImageArchive.trn");
1515 Isis::PvlToPvlTranslationManager isis2Xlater(p_pdsLabel, transFile.expanded());
1516
1517 // Add all the Isis2 keywords that can be translated to the requested label
1518 isis2Xlater.Auto(lab);
1519 }
1520
1521
1529 // Set up a translater for PDS labels
1530 Isis::FileName transFile(p_transDir + "/" + "translations/pdsImageBandBin.trn");
1531 Isis::PvlToPvlTranslationManager isis2Xlater(p_pdsLabel, transFile.expanded());
1532
1533 // Add all the Isis2 keywords that can be translated to the requested label
1534 isis2Xlater.Auto(lab);
1535 }
1536
1537
1549
1550
1563
1564 // Create a temporary Isis::PvlToPvlTranslationManager so we can find out what
1565 // type of projection labels exist
1566 stringstream trnsStrm;
1567 trnsStrm << "Group = PdsProjectionTypeImage" << endl;
1568 trnsStrm << " InputPosition = IMAGE_MAP_PROJECTION" << endl;
1569 trnsStrm << " InputPosition = IMAGE_MAP_PROJECTION_CATALOG" << endl;
1570 trnsStrm << " InputKey = MAP_PROJECTION_TYPE" << endl;
1571 trnsStrm << "EndGroup" << endl;
1572 trnsStrm << "Group = PdsProjectionTypeQube" << endl;
1573 trnsStrm << " InputPosition = (QUBE,IMAGE_MAP_PROJECTION)" << endl;
1574 trnsStrm << " InputKey = MAP_PROJECTION_TYPE" << endl;
1575 trnsStrm << "EndGroup" << endl;
1576 trnsStrm << "Group = PdsProjectionTypeSpectralQube" << endl;
1577 trnsStrm << " InputPosition = (SPECTRAL_QUBE,IMAGE_MAP_PROJECTION)" << endl;
1578 trnsStrm << " InputKey = MAP_PROJECTION_TYPE" << endl;
1579 trnsStrm << "EndGroup" << endl;
1580 trnsStrm << "END";
1581
1582 Isis::PvlToPvlTranslationManager projType(p_pdsLabel, trnsStrm);
1583
1584 // Set up the correct projection translation table for this label
1585 QString transDir = "$ISISROOT/appdata";
1586
1587 Isis::FileName transFile;
1588 if (projType.InputHasKeyword("PdsProjectionTypeImage")) {
1589 transFile = transDir + "/" + "translations/pdsImageProjection.trn";
1590 }
1591 else if (projType.InputHasKeyword("PdsProjectionTypeQube")) {
1592 transFile = transDir + "/" + "translations/pdsQubeProjection.trn";
1593 }
1594 else if (projType.InputHasKeyword("PdsProjectionTypeSpectralQube")) {
1595 transFile = transDir + "/" + "translations/pdsSpectralQubeProjection.trn";
1596 }
1597 else {
1598 return;
1599 }
1600
1601 Isis::PvlToPvlTranslationManager pdsXlater(p_pdsLabel, transFile.expanded());
1602
1603 ExtractPdsProjection(pdsXlater);
1604
1605 Isis::PvlGroup mapGroup("Mapping");
1606 mapGroup += Isis::PvlKeyword("ProjectionName", p_projection);
1607 mapGroup += Isis::PvlKeyword("TargetName", p_targetName);
1608 mapGroup += Isis::PvlKeyword("EquatorialRadius", toString(p_equatorialRadius), "meters");
1609 mapGroup += Isis::PvlKeyword("PolarRadius", toString(p_polarRadius), "meters");
1610 mapGroup += Isis::PvlKeyword("LongitudeDirection", p_longitudeDirection);
1611 mapGroup += Isis::PvlKeyword("LongitudeDomain", toString(p_longitudeDomain));
1612 mapGroup += Isis::PvlKeyword("LatitudeType", p_latitudeType);
1613 if (p_minimumLatitude != Isis::NULL8) {
1614 mapGroup += Isis::PvlKeyword("MinimumLatitude", toString(p_minimumLatitude));
1615 }
1616 if (p_maximumLatitude != Isis::NULL8) {
1617 mapGroup += Isis::PvlKeyword("MaximumLatitude", toString(p_maximumLatitude));
1618 }
1619 if (p_minimumLongitude != Isis::NULL8) {
1620 mapGroup += Isis::PvlKeyword("MinimumLongitude", toString(p_minimumLongitude));
1621 }
1622 if (p_maximumLongitude != Isis::NULL8) {
1623 mapGroup += Isis::PvlKeyword("MaximumLongitude", toString(p_maximumLongitude));
1624 }
1625
1626 // if both longitudes exist, verify they are ordered correctly
1627 if (p_minimumLongitude != Isis::NULL8 && p_maximumLongitude != Isis::NULL8) {
1629 if (p_longitudeDomain == 180) {
1630 mapGroup["MinimumLongitude"] = toString(-180);
1631 mapGroup["MaximumLongitude"] = toString(180);
1632 }
1633 else {
1634 mapGroup["MinimumLongitude"] = toString(0);
1635 mapGroup["MaximumLongitude"] = toString(360);
1636 }
1637 }
1638 }
1639
1640 mapGroup += Isis::PvlKeyword("PixelResolution", toString(p_pixelResolution), "meters/pixel");
1641 mapGroup += Isis::PvlKeyword("Scale", toString(p_scaleFactor), "pixels/degree");
1642 mapGroup += Isis::PvlKeyword("UpperLeftCornerX", toString(p_upperLeftX), "meters");
1643 mapGroup += Isis::PvlKeyword("UpperLeftCornerY", toString(p_upperLeftY), "meters");
1644 if (p_rotation != 0.0) {
1645 mapGroup += Isis::PvlKeyword("Rotation", toString(p_rotation));
1646 }
1647
1648 // To handle new projections without the need to modify source code
1649 // we will construct a filename from the projection. The filename will
1650 // contain the projection specific translations from PDS to ISIS for each
1651 // projection
1652
1653 QString projSpecificFileName = "$ISISROOT/appdata/translations/pdsImport";
1654 projSpecificFileName += p_projection + ".trn";
1655 Isis::PvlToPvlTranslationManager specificXlater(p_pdsLabel, projSpecificFileName);
1656
1657 lab.addGroup(mapGroup);
1658 specificXlater.Auto(lab);
1659
1660 if (lab.findGroup("Mapping").hasKeyword("CenterLongitude")) {
1661 PvlKeyword &centerLon = lab.findGroup("Mapping")["CenterLongitude"];
1662 if (p_longitudeDomain == 180)
1663 centerLon = toString(TProjection::To180Domain((double)centerLon));
1664 else
1665 centerLon = toString(TProjection::To360Domain((double)centerLon));
1666 }
1667
1668 if (lab.findGroup("Mapping").hasKeyword("PoleLongitude")) {
1669 PvlKeyword &poleLon = lab.findGroup("Mapping")["PoleLongitude"];
1670 if (p_longitudeDomain == 180)
1671 poleLon = toString(TProjection::To180Domain((double)poleLon));
1672 else
1673 poleLon = toString(TProjection::To360Domain((double)poleLon));
1674 }
1675
1676 OutputCubes[0]->putGroup(lab.findGroup("Mapping"));
1677 }
1678}
Buffer for reading and writing cube data.
Definition Buffer.h:53
File name manipulation and expansion.
Definition FileName.h:100
bool fileExists() const
Returns true if the file exists; false otherwise.
Definition FileName.cpp:449
QString name() const
Returns the name of the file excluding the path and the attributes in the file name.
Definition FileName.cpp:162
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Definition FileName.cpp:196
Isis exception class.
Definition IException.h:91
@ Unknown
A type of error that cannot be classified as any of the other error types.
Definition IException.h:118
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Definition IException.h:126
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition IException.h:146
@ Io
A type of error that occurred when performing an actual I/O operation.
Definition IException.h:155
Adds specific functionality to C++ strings.
Definition IString.h:165
int ToInteger() const
Returns the object string as an integer.
Definition IString.cpp:718
This represents a cube in a project-based GUI interface.
Definition Image.h:107
Import a PDS table file with a label description.
Read and store original labels.
std::vector< Isis::Cube * > OutputCubes
A vector of pointers to allocated Cube objects.
Definition Process.h:191
virtual void Finalize()
Cleans up by closing cubes and freeing memory for owned cubes.
Definition Process.cpp:471
void SetVAXConvert(const bool vax_convert)
Sets the VAX flag of the input cube.
virtual void StartProcess()
Process the input file and write it to the output.
void SetPixelType(const Isis::PixelType type)
Sets the pixel type of the input file.
void SetFileHeaderBytes(const int bytes)
This method sets the number of bytes in the header of a file.
void SaveDataTrailer()
This method marks the data block trailers to be saved.
void SetOrganization(const ProcessImport::Interleave org)
Sets the organization of the input cube.
void SetDataPrefixBytes(const int bytes)
This method sets the number of bytes at the beginning of each data record of a file.
int DataTrailerBytes() const
This method returns the number of data trailer bytes.
void SetSpecialValues(const double null, const double lrs, const double lis, const double hrs, const double his)
Sets a mapping of input pixel values to output special pixel values.
void SetInputFile(const QString &file)
Sets the name of the input file to be read in the import StartProcess method and verifies its existan...
void SetMultiplier(const double mult)
Sets the core multiplier of the input cube.
void SetDataHeaderBytes(const int bytes)
This method sets the number of bytes in the header of each datablock of a file.
void SetDataTrailerBytes(const int bytes)
This method sets the number of bytes in the trailer of each datablock of a file.
void SetByteOrder(const Isis::ByteOrder order)
Sets the byte order of the input file.
@ BIL
Band Interleaved By Line Format (i.e.
@ BIP
Band Interleaved By Pixel Format (i.e.
@ JP2
Jpeg 2000 Format (always band sequential).
@ BSQ
Band Sequential Format (i.e.
void SetDataSuffixBytes(const int bytes)
This method sets the number of bytes at the end of each data record of a file.
void SetBase(const double base)
Sets the core base of the input cube.
void SetDimensions(const int ns, const int nl, const int nb)
Sets the physical size of the input cube.
EncodingType p_encodingType
The encoding type of the image data.
QString p_labelFile
The filename where the PDS label came from.
void GetProjectionOffsetMults(double &xoff, double &yoff, double &xmult, double &ymult)
Read mults and offsets from a def file in order to calculate the upper left x/y.
void TranslatePdsBandBin(Pvl &lab)
Fill as many of the Isis BandBin labels as possible.
double p_scaleFactor
The scale factor found in the PDS projection labels.
double p_minimumLongitude
Minimum longitude found in the PDS projection labels.
bool p_keepOriginalLabel
determines whether or not to keep the OriginalLabel blob.
void TranslateIsis2Labels(Pvl &lab)
Translate as many of the ISIS2 labels as possible.
void IdentifySource(Pvl &lab)
Identify the source of this file PDS or ISIS2.
std::vector< Table > p_tables
Vector of Isis Table objects that were imported from PDS and need to be added to the imported cube fi...
double p_minimumLatitude
Minimum latitude found in the PDS projection labels.
QString p_jp2File
The name of the file containing the encoded JP2 data.
QString p_transDir
Base data directory.
void SetPdsFile(const QString &pdsLabelFile, const QString &pdsDataFile, Pvl &pdsLabel, PdsFileType allowedTypes=All)
Set the input label file, data file and initialize a Pvl with the PDS labels.
QString p_longitudeDirection
Longitude direction found in the PDS projection labels.
double p_maximumLatitude
Maximum latitude found in the PDS projection labels.
double p_equatorialRadius
Equatorial radius found in the PDS projection labels.
void StartProcess()
This method will write the cube and table data to the output cube.
void OmitOriginalLabel()
Prevents the Original Label blob from being written out to the end of the cube.
void TranslateIsis2BandBin(Pvl &lab)
Fill as many of the Isis BandBin labels as possible.
Pvl p_pdsLabel
Internalized PDS label.
void ProcessDataFilePointer(PvlToPvlTranslationManager &pdsXlater, const bool &calcOffsetOnly)
Handles the DataFilePointer keyword, aka ^QUBE or ^IMAGE.
void TranslatePdsProjection(Pvl &lab)
Fills the passed in label with the projection information from the PDS label file.
void ProcessPixelBitandType(PvlToPvlTranslationManager &pdsXlater)
Handles PixelType and BitsPerPixel Calls SetPixelType with the correct values.
void ExtractPdsProjection(PvlToPvlTranslationManager &pdsXlater)
Extract all possible PDS projection parameters from the PDS label.
bool p_projectionOffsetChange
Whether the projection offsets were updated upon loading.
void TranslatePdsArchive(Pvl &lab)
Fill as many of the Isis BandBin labels as possible.
void ProcessSpecialPixels(PvlToPvlTranslationManager &pdsXlater, const bool &isQube)
Handles all special pixel setting, ultimately, calls SetSpecialValues.
double p_maximumLongitude
Maximum longitude found in the PDS projection labels.
bool GetProjectionOffsetChange()
Return whether the projection offsets have changed.
void ProcessPdsQubeLabel(const QString &pdsDataFile, const QString &transFile)
Process the PDS label of type QUBE or SPECTRALQUBE.
bool IsIsis2()
Return true if ISIS2 cube, else return false.
double p_polarRadius
The polar radius found in the PDS projection labels.
void ProcessPdsCombinedSpectrumLabel(const QString &pdsDataFile)
Process the PDS label of type CombinedSpectrum.
Table & ImportTable(QString pdsTableName)
This method will import the PDS table with the given name into an Isis Table object.
int p_longitudeDomain
Longitude domain found in the PDS projection labels.
void ProcessPdsImageLabel(const QString &pdsDataFile)
Process the PDS label of type IMAGE.
void TranslatePdsLabels(Pvl &lab)
Translate as many of the PDS labels as possible.
PvlGroup GetProjectionOffsetGroup()
Return the projection offsets.
void ProcessPdsM3Label(const QString &pdsDataFile, PdsFileType fileType)
Process Chandrayaan M3 PDS label.
QString p_projection
The name of the projection found in the PDS projection labels.
double p_rotation
The rotation found in the PDS labels.
void ProcessLabel(const QString &pdsDataFile, PdsFileType allowedTypes)
Load the PDS labels after determining what type of data file was provided.
PvlGroup p_projectionOffsetGroup
Log information for projection offsets.
double p_pixelResolution
Pixel resolution found in the PDS projection labels.
void TranslateIsis2Instrument(Pvl &lab)
Fill as many of the Isis instrument labels as possible.
void Finalize()
End the processing sequence and cleans up by closing cubes, freeing memory, etc.
QString p_latitudeType
The latitude type found in the PDS projection labels.
void setName(const QString &name)
Set the name of the container.
void addKeyword(const PvlKeyword &keyword, const InsertMode mode=Append)
Add a keyword to the container.
Contains multiple PvlContainers.
Definition PvlGroup.h:41
Container for cube-like labels.
Definition Pvl.h:119
A single keyword-value pair.
Definition PvlKeyword.h:87
Contains Pvl Groups and Pvl Objects.
Definition PvlObject.h:61
bool hasKeyword(const QString &kname, FindOptions opts) const
See if a keyword is in the current PvlObject, or deeper inside other PvlObjects and Pvlgroups within ...
PvlGroup & group(const int index)
Return the group at the specified index.
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes.
Definition PvlObject.h:276
@ Traverse
Search child objects.
Definition PvlObject.h:158
PvlKeyword & findKeyword(const QString &kname, FindOptions opts)
Finds a keyword in the current PvlObject, or deeper inside other PvlObjects and Pvlgroups within this...
Allows applications to translate simple text files.
static double To180Domain(const double lon)
This method converts a longitude into the -180 to 180 domain.
static double To360Domain(const double lon)
This method converts a longitude into the 0 to 360 domain.
Class for storing Table blobs information.
Definition Table.h:61
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
const double His
Value for an Isis High Instrument Saturation pixel.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition IString.cpp:211
const double Hrs
Value for an Isis High Representation Saturation pixel.
int toInt(const QString &string)
Global function to convert from a string to an integer.
Definition IString.cpp:93
const double Lrs
Value for an Isis Low Representation Saturation pixel.
const double Lis
Value for an Isis Low Instrument Saturation pixel.
double toDouble(const QString &string)
Global function to convert from a string to a double.
Definition IString.cpp:149
Namespace for the standard library.