7 #include "ProcessImportPds.h"
15 #include "IException.h"
16 #include "ImportPdsTable.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"
25 #include "PvlKeyword.h"
27 #include "PvlObject.h"
28 #include "PvlTokenizer.h"
29 #include "PvlToPvlTranslationManager.h"
30 #include "SpecialPixel.h"
32 #include "UserInterface.h"
40 ProcessImportPds::ProcessImportPds() {
41 p_keepOriginalLabel =
true;
42 p_encodingType = NONE;
44 p_projectionOffsetChange =
false;
45 p_projectionOffsetGroup.setName(
"ProjectionOffsets");
48 p_transDir =
"$ISISROOT/appdata";
52 ProcessImportPds::~ProcessImportPds() {
59 void ProcessImportPds::EndProcess() {
60 ProcessImportPds::Finalize();
93 p_projection = pdsXlater.
Translate(
"ProjectionName");
96 QString message =
"No projection name in labels";
97 throw IException(IException::Unknown, message, _FILEINFO_);
101 p_targetName = pdsXlater.
Translate(
"TargetName");
104 QString message =
"No target name in labels";
105 throw IException(IException::Unknown, message, _FILEINFO_);
109 str = pdsXlater.
Translate(
"EquatorialRadius");
110 p_equatorialRadius =
toDouble(str) * 1000.0;
113 QString message =
"No equatorial radius name in labels";
114 throw IException(IException::User, message, _FILEINFO_);
118 str = pdsXlater.
Translate(
"PolarRadius");
119 p_polarRadius =
toDouble(str) * 1000.0;
122 QString message =
"No polar radius in labels";
123 throw IException(IException::User, message, _FILEINFO_);
127 p_longitudeDirection = pdsXlater.
Translate(
"LongitudeDirection");
130 p_longitudeDirection = pdsXlater.
Translate(
"LongitudeDirection2");
133 if (p_polarRadius == p_equatorialRadius) {
134 p_latitudeType =
"Planetocentric";
137 p_latitudeType = pdsXlater.
Translate(
"LatitudeType2");
140 p_latitudeType = pdsXlater.
Translate(
"LatitudeType");
144 str = pdsXlater.
Translate(
"MinimumLatitude");
149 p_minimumLatitude = Isis::NULL8;
153 p_minimumLatitude = Isis::NULL8;
157 str = pdsXlater.
Translate(
"MaximumLatitude");
162 p_maximumLatitude = Isis::NULL8;
166 p_maximumLatitude = Isis::NULL8;
171 bool positiveWest =
false;
173 str = pdsXlater.
Translate(
"MinimumLongitude");
179 p_minimumLongitude = Isis::NULL8;
183 str = pdsXlater.
Translate(
"MinimumLongitude2");
188 p_minimumLongitude = Isis::NULL8;
192 p_minimumLongitude = Isis::NULL8;
196 str = pdsXlater.
Translate(
"MaximumLongitude");
202 p_maximumLongitude = Isis::NULL8;
206 str = pdsXlater.
Translate(
"MaximumLongitude2");
211 p_maximumLongitude = Isis::NULL8;
215 p_maximumLongitude = Isis::NULL8;
218 str = pdsXlater.
Translate(
"LongitudeDomain");
219 p_longitudeDomain =
toInt(str);
239 if (positiveWest && (p_longitudeDirection.compare(
"PositiveEast") == 0)) {
240 double tmp = p_minimumLongitude;
241 p_minimumLongitude = p_maximumLongitude;
242 p_maximumLongitude = tmp;
245 if (p_minimumLongitude > p_maximumLongitude) {
247 p_longitudeDomain = 180;
253 if (p_minimumLongitude < 0 || p_maximumLongitude < 0) {
254 p_longitudeDomain = 180;
257 str = pdsXlater.
Translate(
"PixelResolution");
261 if ((str !=
"METERS/PIXEL") && (str !=
"M/PIXEL") && (str !=
"M/PIX")) {
262 p_pixelResolution *= 1000.0;
278 double xoff, yoff, xmult, ymult;
279 GetProjectionOffsetMults(xoff, yoff, xmult, ymult);
282 str = pdsXlater.
Translate(
"LineProjectionOffset");
285 str = pdsXlater.
Translate(
"LineProjectionOffset2");
287 p_lineProjectionOffset =
toDouble(str);
288 p_upperLeftY = ymult * (p_lineProjectionOffset + yoff) * p_pixelResolution;
291 str = pdsXlater.
Translate(
"SampleProjectionOffset");
294 str = pdsXlater.
Translate(
"SampleProjectionOffset2");
296 p_sampleProjectionOffset =
toDouble(str);
297 p_upperLeftX = xmult * (p_sampleProjectionOffset + xoff) * p_pixelResolution;
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)));
312 void ProcessImportPds::Finalize() {
313 if (p_keepOriginalLabel) {
315 for (
unsigned int i = 0; i < OutputCubes.size(); i++) {
316 OutputCubes[i]->write(ol);
326 bool ProcessImportPds::GetProjectionOffsetChange() {
327 return p_projectionOffsetChange;
334 PvlGroup ProcessImportPds::GetProjectionOffsetGroup() {
335 return p_projectionOffsetGroup;
351 void ProcessImportPds::GetProjectionOffsetMults(
double &xoff,
double &yoff,
352 double &xmult,
double &ymult) {
360 Isis::Pvl p(p_transDir +
"/" +
"translations/pdsProjectionLineSampToXY.def");
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"];
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"];
377 p_projectionOffsetChange =
true;
391 void ProcessImportPds::IdentifySource(
Isis::Pvl &inputLabel) {
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;
428 Table &ProcessImportPds::ImportTable(QString pdsTableName) {
435 int found = isisTableName.lastIndexOf(
"Table");
436 if (found == isisTableName.length() - 5) {
437 isisTableName.remove(found, 5);
441 p_tables.push_back(isisTable);
443 return p_tables.at(p_tables.size() - 1);
455 bool ProcessImportPds::IsIsis2() {
457 if (p_source == ISIS2) {
472 void ProcessImportPds::OmitOriginalLabel() {
473 p_keepOriginalLabel =
false;
484 const bool & calcOffsetOnly) {
488 QString dataFileName;
496 if (dataFilePointer.
size() == 1) {
498 str = pdsXlater.
Translate(
"DataFilePointer");
500 units = dataFilePointer.
unit();
515 else if (dataFilePointer.
size() == 2) {
516 dataFileName = pdsXlater.
Translate(
"DataFilePointer", 0);
518 units = dataFilePointer.
unit(1);
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 [" +
525 throw IException(IException::Unknown, msg, _FILEINFO_);
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_);
537 if (!calcOffsetOnly) {
542 if (dataFileName.size() != 0 && dataFileName.at(0) ==
'/')
546 dataFile =
FileName(labelFile.
path() +
"/" + dataFileName);
555 dataFileName = dataFileName.toLower();
556 dataFile =
FileName(labelFile.
path() +
"/" + dataFileName);
561 QString msg =
"Unable to find input file [" + tmp +
"] or [" +
563 throw IException(IException::Io, msg, _FILEINFO_);
569 units = units.trimmed();
570 if (units ==
"BYTES" || units ==
"B") {
571 SetFileHeaderBytes(offset - 1);
574 QString recSize = pdsXlater.
Translate(
"DataFileRecordBytes");
575 SetFileHeaderBytes((offset - 1) *
toInt(recSize));
595 void ProcessImportPds::ProcessLabel(
const QString &pdsDataFile, PdsFileType allowedTypes) {
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;
656 if (coreKey[0] ==
"VAX_REAL") {
657 ProcessImport::SetVAXConvert(
true);
668 str = pdsXlater.
Translate(
"PdsEncodingType");
670 p_encodingType = JP2;
671 str = pdsXlater.
Translate(
"PdsCompressedFile");
672 if (pdsDataFile.isEmpty()) {
681 ifile = lfile.
path() +
"/" + str;
686 QString msg =
"Unable to find input file [" + tmp +
"] or [" +
688 throw IException(IException::Io, msg, _FILEINFO_);
694 QString msg =
"Unsupported encoding type in [" + p_labelFile +
"]";
695 throw IException(IException::Io, msg, _FILEINFO_);
703 ProcessPdsImageLabel(pdsDataFile);
705 else if ((allowedTypes & Qube) == Qube && pdsXlater.
InputHasKeyword(
"PdsTypeQube")) {
707 ProcessPdsQubeLabel(pdsDataFile,
"pdsQube.trn");
709 else if ((allowedTypes & SpectralQube) == SpectralQube &&
712 ProcessPdsQubeLabel(pdsDataFile,
"pdsSpectralQube.trn");
714 else if ((allowedTypes & L0) == L0 && pdsXlater.
InputHasKeyword(
"PdsTypeL0")) {
716 ProcessPdsM3Label(pdsDataFile, L0);
718 else if ((allowedTypes & Rdn) == Rdn && pdsXlater.
InputHasKeyword(
"PdsTypeRdn")) {
720 ProcessPdsM3Label(pdsDataFile, Rdn);
722 else if ((allowedTypes & Loc) == Loc && pdsXlater.
InputHasKeyword(
"PdsTypeLoc")) {
724 ProcessPdsM3Label(pdsDataFile, Loc);
726 else if ((allowedTypes & Obs) == Obs && pdsXlater.
InputHasKeyword(
"PdsTypeObs")) {
728 ProcessPdsM3Label(pdsDataFile, Obs);
730 else if ((allowedTypes & CombinedSpectrum) == CombinedSpectrum &&
733 ProcessPdsCombinedSpectrumLabel(pdsDataFile);
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_);
743 IdentifySource(p_pdsLabel);
761 void ProcessImportPds::ProcessPdsCombinedSpectrumLabel(
const QString &pdsDataFile) {
762 Isis::FileName transFile(p_transDir +
"/translations/pdsCombinedSpectrum.trn");
767 str = pdsXlater.
Translate(
"CoreLinePrefixBytes");
768 SetDataPrefixBytes(
toInt(str));
770 str = pdsXlater.
Translate(
"CoreLineSuffixBytes");
771 SetDataSuffixBytes(
toInt(str));
773 ProcessPixelBitandType(pdsXlater);
775 str = pdsXlater.
Translate(
"CoreByteOrder");
776 SetByteOrder(Isis::ByteOrderEnumeration(str));
778 str = pdsXlater.
Translate(
"CoreSamples");
785 SetDimensions(ns, nl, nb);
793 if (pdsDataFile.length() > 0) {
794 ProcessDataFilePointer(pdsXlater,
false);
798 else if (p_jp2File.length() > 0) {
799 SetInputFile(p_jp2File);
800 ProcessDataFilePointer(pdsXlater,
true);
806 ProcessDataFilePointer(pdsXlater,
false);
814 str = pdsXlater.
Translate(
"CoreMultiplier");
818 str = pdsXlater.
Translate(
"CoreOrganization");
820 if (p_encodingType == JP2) {
821 SetOrganization(ProcessImport::JP2);
823 else if (str ==
"BSQ") {
824 SetOrganization(ProcessImport::BSQ);
826 else if (str ==
"BIP") {
827 SetOrganization(ProcessImport::BIP);
829 else if (str ==
"BIL") {
830 SetOrganization(ProcessImport::BIL);
833 QString msg =
"Unsupported axis order [" + str +
"]";
834 throw IException(IException::Programmer, msg, _FILEINFO_);
855 void ProcessImportPds::ProcessPdsQubeLabel(
const QString &pdsDataFile,
856 const QString &transFile) {
873 for(
int i = 0; i < val; i++) {
874 str = pdsXlater.
Translate(
"CoreOrganization", i);
876 if (str ==
"SAMPLE") {
879 else if (str ==
"LINE") {
882 else if (str ==
"BAND") {
886 QString message =
"Unknown file axis name [" + str +
"]";
887 throw IException(IException::User, message, _FILEINFO_);
891 if (p_encodingType == JP2) {
892 SetOrganization(ProcessImport::JP2);
894 else if (tmp ==
"SAMPLELINEBAND") {
895 SetOrganization(ProcessImport::BSQ);
897 else if (tmp ==
"BANDSAMPLELINE") {
898 SetOrganization(ProcessImport::BIP);
900 else if (tmp ==
"SAMPLEBANDLINE") {
901 SetOrganization(ProcessImport::BIL);
904 PvlKeyword pdsCoreOrg = p_pdsLabel.findKeyword(pdsXlater.
905 InputKeywordName(
"CoreOrganization"), Pvl::Traverse);
907 stringstream pdsCoreOrgStream;
908 pdsCoreOrgStream << pdsCoreOrg;
910 QString msg =
"Unsupported axis order [" + QString(pdsCoreOrgStream.str().c_str()) +
"]";
911 throw IException(IException::Programmer, msg, _FILEINFO_);
917 SetDataPrefixBytes(0);
920 str = pdsXlater.
Translate(
"SuffixItemSize");
921 int suffix =
toInt(str);
922 str = pdsXlater.
Translate(
"AxisSuffixCount", 0);
923 suffix *=
toInt(str);
924 SetDataSuffixBytes(suffix);
926 str = pdsXlater.
Translate(
"SuffixItemSize");
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);
936 SetDataTrailerBytes(trailer);
940 if (DataTrailerBytes() != 0) {
944 ProcessPixelBitandType(pdsXlater);
949 str = pdsXlater.
Translate(
"CoreByteOrder");
951 SetByteOrder(Isis::ByteOrderEnumeration(str));
963 str = pdsXlater.
Translate(
"CoreSamples", samplePos);
965 str = pdsXlater.
Translate(
"CoreLines", linePos);
967 str = pdsXlater.
Translate(
"CoreBands", bandPos);
969 SetDimensions(ns, nl, nb);
973 ProcessSpecialPixels(pdsXlater,
true);
981 if (pdsDataFile.length() > 0) {
982 SetInputFile(pdsDataFile);
983 ProcessDataFilePointer(pdsXlater,
true);
987 else if (p_jp2File.length() > 0) {
988 SetInputFile(p_jp2File);
989 ProcessDataFilePointer(pdsXlater,
true);
993 ProcessDataFilePointer(pdsXlater,
false);
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);
1008 str = pdsXlater.
Translate(
"BandMultiplier", i);
1012 SetMultiplier(mults);
1017 str = pdsXlater.
Translate(
"CoreMultiplier");
1034 void ProcessImportPds::ProcessPdsImageLabel(
const QString &pdsDataFile) {
1035 Isis::FileName transFile(p_transDir +
"/translations/pdsImage.trn");
1040 str = pdsXlater.
Translate(
"CoreLinePrefixBytes");
1041 SetDataPrefixBytes(
toInt(str));
1043 str = pdsXlater.
Translate(
"CoreLineSuffixBytes");
1044 SetDataSuffixBytes(
toInt(str));
1046 ProcessPixelBitandType(pdsXlater);
1048 str = pdsXlater.
Translate(
"CoreByteOrder");
1049 SetByteOrder(Isis::ByteOrderEnumeration(str));
1051 str = pdsXlater.
Translate(
"CoreSamples");
1052 int ns =
toInt(str);
1054 int nl =
toInt(str);
1056 int nb =
toInt(str);
1058 SetDimensions(ns, nl, nb);
1061 ProcessSpecialPixels(pdsXlater,
false);
1069 if (pdsDataFile.length() > 0) {
1070 SetInputFile(pdsDataFile);
1071 ProcessDataFilePointer(pdsXlater,
true);
1075 else if (p_jp2File.length() > 0) {
1076 SetInputFile(p_jp2File);
1077 ProcessDataFilePointer(pdsXlater,
true);
1083 ProcessDataFilePointer(pdsXlater,
false);
1091 str = pdsXlater.
Translate(
"CoreMultiplier");
1095 str = pdsXlater.
Translate(
"CoreOrganization");
1097 if (p_encodingType == JP2) {
1098 SetOrganization(ProcessImport::JP2);
1100 else if (str ==
"BSQ") {
1101 SetOrganization(ProcessImport::BSQ);
1103 else if (str ==
"BIP") {
1104 SetOrganization(ProcessImport::BIP);
1106 else if (str ==
"BIL") {
1107 SetOrganization(ProcessImport::BIL);
1110 QString msg =
"Unsupported axis order [" + str +
"]";
1111 throw IException(IException::Programmer, msg, _FILEINFO_);
1122 str = pdsXlater.
Translate(
"CoreBitsPerPixel");
1123 int bitsPerPixel =
toInt(str);
1124 str = pdsXlater.
Translate(
"CorePixelType");
1126 if ((str ==
"Real") && (bitsPerPixel == 64)) {
1128 SetPixelType(Isis::Double);
1130 else if ((str ==
"Real") && (bitsPerPixel == 32)) {
1131 SetPixelType(Isis::Real);
1133 else if ((str ==
"Integer") && (bitsPerPixel == 8)) {
1134 SetPixelType(Isis::UnsignedByte);
1136 else if ((str ==
"Integer") && (bitsPerPixel == 16)) {
1137 SetPixelType(Isis::SignedWord);
1139 else if ((str ==
"Integer") && (bitsPerPixel == 32)) {
1140 SetPixelType(Isis::SignedInteger);
1142 else if ((str ==
"Natural") && (bitsPerPixel == 8)) {
1143 SetPixelType(Isis::UnsignedByte);
1145 else if ((str ==
"Natural") && (bitsPerPixel == 16)) {
1146 SetPixelType(Isis::UnsignedWord);
1148 else if ((str ==
"Natural") && (bitsPerPixel == 16)) {
1149 SetPixelType(Isis::SignedWord);
1151 else if ((str ==
"Natural") && (bitsPerPixel == 32)) {
1152 SetPixelType(Isis::UnsignedInteger);
1156 QString msg =
"Invalid PixelType and BitsPerPixel combination [" + str +
1157 ", " +
toString(bitsPerPixel) +
"]";
1158 throw IException(IException::Io, msg, _FILEINFO_);
1174 void ProcessImportPds::ProcessPdsM3Label(
const QString &pdsDataFile, PdsFileType fileType) {
1176 if (fileType == L0) {
1177 transFile = p_transDir +
"/translations/pdsL0.trn";
1179 else if (fileType == Rdn) {
1180 transFile = p_transDir +
"/translations/pdsRdn.trn";
1182 else if (fileType == Loc) {
1183 transFile = p_transDir +
"/translations/pdsLoc.trn";
1185 else if (fileType == Obs) {
1186 transFile = p_transDir +
"/translations/pdsObs.trn";
1189 throw IException(IException::Programmer,
"ProcessImportPds::ProcessPdsM3Label can only be "
1190 "called with file type of L0, Rdn, Loc or Obs.", _FILEINFO_);
1198 str = pdsXlater.
Translate(
"CoreLinePrefixBytes");
1199 SetDataHeaderBytes(
toInt(str));
1201 str = pdsXlater.
Translate(
"CoreLineSuffixBytes");
1202 SetDataSuffixBytes(
toInt(str));
1204 ProcessPixelBitandType(pdsXlater);
1206 str = pdsXlater.
Translate(
"CoreByteOrder");
1207 SetByteOrder(Isis::ByteOrderEnumeration(str));
1209 str = pdsXlater.
Translate(
"CoreSamples");
1210 int ns =
toInt(str);
1212 int nl =
toInt(str);
1214 int nb =
toInt(str);
1215 SetDimensions(ns, nl, nb);
1218 ProcessSpecialPixels(pdsXlater,
false);
1226 if (pdsDataFile.length() > 0) {
1227 SetInputFile(pdsDataFile);
1228 ProcessDataFilePointer(pdsXlater,
true);
1232 else if (p_jp2File.length() > 0) {
1233 SetInputFile(p_jp2File);
1234 ProcessDataFilePointer(pdsXlater,
true);
1240 ProcessDataFilePointer(pdsXlater,
false);
1248 str = pdsXlater.
Translate(
"CoreMultiplier");
1252 str = pdsXlater.
Translate(
"CoreOrganization");
1254 if (p_encodingType == JP2) {
1255 SetOrganization(ProcessImport::JP2);
1257 else if (str ==
"BSQ") {
1258 SetOrganization(ProcessImport::BSQ);
1260 else if (str ==
"BIP") {
1261 SetOrganization(ProcessImport::BIP);
1263 else if (str ==
"BIL") {
1264 SetOrganization(ProcessImport::BIL);
1267 QString msg =
"Unsupported axis order [" + str +
"]";
1268 throw IException(IException::Programmer, msg, _FILEINFO_);
1279 double pdsNull = Isis::NULL8;
1282 if (str !=
"NULL") {
1288 if (str !=
"NULL") {
1296 if (str !=
"NULL") {
1302 if (str !=
"NULL") {
1310 if (str !=
"NULL") {
1316 if (str !=
"NULL") {
1324 if (str !=
"NULL") {
1330 if (str !=
"NULL") {
1338 if (str !=
"NULL") {
1344 if (str !=
"NULL") {
1349 SetSpecialValues(pdsNull, pdsLrs, pdsLis, pdsHrs, pdsHis);
1367 void ProcessImportPds::SetPdsFile(
const Isis::Pvl &pdsLabelPvl,
1368 const QString &pdsDataFile,
1369 PdsFileType allowedTypes) {
1372 p_pdsLabel = pdsLabelPvl;
1373 p_labelFile = pdsDataFile;
1374 ProcessLabel(pdsDataFile, allowedTypes);
1395 void ProcessImportPds::SetPdsFile(
const QString &pdsLabelFile,
1396 const QString &pdsDataFile,
1398 PdsFileType allowedTypes) {
1402 pdsLabel.
read(pdsLabelFile);
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_);
1412 p_pdsLabel = pdsLabel;
1413 p_labelFile = pdsLabelFile;
1414 ProcessLabel(pdsDataFile, allowedTypes);
1421 void ProcessImportPds::StartProcess() {
1422 ProcessImport::StartProcess();
1423 for (
unsigned int i = 0; i < p_tables.size(); i++) {
1424 OutputCubes[0]->write(p_tables[i]);
1441 ProcessImport::StartProcess(funct);
1453 void ProcessImportPds::TranslateIsis2BandBin(
Isis::Pvl &lab) {
1455 QString transDir =
"$ISISROOT/appdata";
1457 Isis::FileName transFile(transDir +
"/" +
"translations/isis2bandbin.trn");
1461 isis2Xlater.
Auto(lab);
1471 void ProcessImportPds::TranslateIsis2Instrument(
Isis::Pvl &lab) {
1473 QString transDir =
"$ISISROOT/appdata";
1475 Isis::FileName transFile(transDir +
"/" +
"translations/isis2instrument.trn");
1479 isis2Xlater.
Auto(lab);
1486 QString stime = stkey[0];
1487 stime = stime.remove(QRegExp(
"[Zz]$"));
1500 void ProcessImportPds::TranslateIsis2Labels(
Isis::Pvl &lab) {
1501 TranslateIsis2BandBin(lab);
1502 TranslateIsis2Instrument(lab);
1512 void ProcessImportPds::TranslatePdsArchive(
Isis::Pvl &lab) {
1514 Isis::FileName transFile(p_transDir +
"/" +
"translations/pdsImageArchive.trn");
1518 isis2Xlater.
Auto(lab);
1528 void ProcessImportPds::TranslatePdsBandBin(
Isis::Pvl &lab) {
1530 Isis::FileName transFile(p_transDir +
"/" +
"translations/pdsImageBandBin.trn");
1534 isis2Xlater.
Auto(lab);
1546 TranslatePdsBandBin(lab);
1547 TranslatePdsArchive(lab);
1562 void ProcessImportPds::TranslatePdsProjection(
Isis::Pvl &lab) {
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;
1585 QString transDir =
"$ISISROOT/appdata";
1589 transFile = transDir +
"/" +
"translations/pdsImageProjection.trn";
1592 transFile = transDir +
"/" +
"translations/pdsQubeProjection.trn";
1595 transFile = transDir +
"/" +
"translations/pdsSpectralQubeProjection.trn";
1603 ExtractPdsProjection(pdsXlater);
1613 if (p_minimumLatitude != Isis::NULL8) {
1616 if (p_maximumLatitude != Isis::NULL8) {
1619 if (p_minimumLongitude != Isis::NULL8) {
1622 if (p_maximumLongitude != Isis::NULL8) {
1627 if (p_minimumLongitude != Isis::NULL8 && p_maximumLongitude != Isis::NULL8) {
1628 if (p_maximumLongitude <= p_minimumLongitude) {
1629 if (p_longitudeDomain == 180) {
1630 mapGroup[
"MinimumLongitude"] =
toString(-180);
1631 mapGroup[
"MaximumLongitude"] =
toString(180);
1634 mapGroup[
"MinimumLongitude"] =
toString(0);
1635 mapGroup[
"MaximumLongitude"] =
toString(360);
1644 if (p_rotation != 0.0) {
1653 QString projSpecificFileName =
"$ISISROOT/appdata/translations/pdsImport";
1654 projSpecificFileName += p_projection +
".trn";
1658 specificXlater.
Auto(lab);
1660 if (lab.
findGroup(
"Mapping").hasKeyword(
"CenterLongitude")) {
1662 if (p_longitudeDomain == 180)
1663 centerLon =
toString(TProjection::To180Domain((
double)centerLon));
1665 centerLon =
toString(TProjection::To360Domain((
double)centerLon));
1668 if (lab.
findGroup(
"Mapping").hasKeyword(
"PoleLongitude")) {
1670 if (p_longitudeDomain == 180)
1671 poleLon =
toString(TProjection::To180Domain((
double)poleLon));
1673 poleLon =
toString(TProjection::To360Domain((
double)poleLon));
1676 OutputCubes[0]->putGroup(lab.
findGroup(
"Mapping"));