55 ProcessImportPds::ProcessImportPds() {
56 p_keepOriginalLabel =
true;
57 p_encodingType = NONE;
62 p_transDir = (QString) dataDir[
"Base"];
66 ProcessImportPds::~ProcessImportPds() {
84 void ProcessImportPds::SetPdsFile(
const Isis::Pvl &pdsLabelPvl,
85 const QString &pdsDataFile,
86 PdsFileType allowedTypes) {
89 p_pdsLabel = pdsLabelPvl;
90 p_labelFile = pdsDataFile;
91 ProcessLabel(pdsDataFile, allowedTypes);
112 void ProcessImportPds::SetPdsFile(
const QString &pdsLabelFile,
113 const QString &pdsDataFile,
115 PdsFileType allowedTypes) {
119 pdsLabel.
read(pdsLabelFile);
123 QObject::tr(
"This image does not contain a pds label. You will need an "
124 "image with a PDS label or a detached PDS label for this "
129 p_pdsLabel = pdsLabel;
130 p_labelFile = pdsLabelFile;
131 ProcessLabel(pdsDataFile, allowedTypes);
150 void ProcessImportPds::ProcessLabel(
const QString &pdsDataFile, PdsFileType allowedTypes) {
153 stringstream trnsStrm;
154 trnsStrm <<
"Group = PdsTypeImage" << endl;
155 trnsStrm <<
" InputPosition = ROOT" << endl;
156 trnsStrm <<
" InputPosition = FILE" << endl;
157 trnsStrm <<
" InputPosition = UNCOMPRESSED_FILE" << endl;
158 trnsStrm <<
" InputKey = ^IMAGE" << endl;
159 trnsStrm <<
"EndGroup" << endl;
160 trnsStrm <<
"Group = PdsCombinedSpectrum" << endl;
161 trnsStrm <<
" InputPosition = ROOT" << endl;
162 trnsStrm <<
" InputPosition = FILE" << endl;
163 trnsStrm <<
" InputPosition = UNCOMPRESSED_FILE" << endl;
164 trnsStrm <<
" InputKey = ^COMBINED_SPECTRUM" << endl;
165 trnsStrm <<
"EndGroup" << endl;
166 trnsStrm <<
"Group = PdsTypeL0" << endl;
167 trnsStrm <<
" InputPosition = L0_FILE" << endl;
168 trnsStrm <<
" InputKey = ^L0_IMAGE" << endl;
169 trnsStrm <<
"EndGroup" << endl;
170 trnsStrm <<
"Group = PdsTypeRdn" << endl;
171 trnsStrm <<
" InputPosition = RDN_FILE" << endl;
172 trnsStrm <<
" InputKey = ^RDN_IMAGE" << endl;
173 trnsStrm <<
"EndGroup" << endl;
174 trnsStrm <<
"Group = PdsTypeLoc" << endl;
175 trnsStrm <<
" InputPosition = LOC_FILE" << endl;
176 trnsStrm <<
" InputKey = ^LOC_IMAGE" << endl;
177 trnsStrm <<
"EndGroup" << endl;
178 trnsStrm <<
"Group = PdsTypeObs" << endl;
179 trnsStrm <<
" InputPosition = OBS_FILE" << endl;
180 trnsStrm <<
" InputKey = ^OBS_IMAGE" << endl;
181 trnsStrm <<
"EndGroup" << endl;
182 trnsStrm <<
"Group = PdsTypeQube" << endl;
183 trnsStrm <<
" InputKey = ^QUBE" << endl;
184 trnsStrm <<
"EndGroup" << endl;
185 trnsStrm <<
"Group = PdsTypeSpectralQube" << endl;
186 trnsStrm <<
" InputKey = ^SPECTRAL_QUBE" << endl;
187 trnsStrm <<
"EndGroup" << endl;
188 trnsStrm <<
"Group = PdsEncodingType" << endl;
189 trnsStrm <<
" InputPosition = COMPRESSED_FILE" << endl;
190 trnsStrm <<
" InputKey = ENCODING_TYPE" << endl;
191 trnsStrm <<
" Translation = (*,*)" << endl;
192 trnsStrm <<
"EndGroup" << endl;
193 trnsStrm <<
"Group = PdsCompressedFile" << endl;
194 trnsStrm <<
" InputPosition = COMPRESSED_FILE" << endl;
195 trnsStrm <<
" InputKey = FILE_NAME" << endl;
196 trnsStrm <<
" Translation = (*,*)" << endl;
197 trnsStrm <<
"EndGroup" << endl;
212 if (coreKey[0] ==
"VAX_REAL") {
214 ProcessImport::SetVAXConvert(
true);
231 str = pdsXlater.
Translate(
"PdsEncodingType");
233 p_encodingType = JP2;
234 str = pdsXlater.
Translate(
"PdsCompressedFile");
235 if (pdsDataFile.isEmpty()) {
238 if (ifile.fileExists()) {
239 p_jp2File = ifile.expanded();
242 QString tmp = ifile.expanded();
244 ifile = lfile.
path() +
"/" + str;
245 if (ifile.fileExists()) {
246 p_jp2File = ifile.expanded();
249 QString msg =
"Unable to find input file [" + tmp +
"] or [" +
250 ifile.expanded() +
"]";
257 QString msg =
"Unsupported encoding type in [" + p_labelFile +
"]";
268 ProcessPdsImageLabel(pdsDataFile);
270 else if ((allowedTypes & Qube) == Qube && pdsXlater.
InputHasKeyword(
"PdsTypeQube")) {
272 ProcessPdsQubeLabel(pdsDataFile,
"pdsQube.trn");
274 else if ((allowedTypes & SpectralQube) == SpectralQube &&
277 ProcessPdsQubeLabel(pdsDataFile,
"pdsSpectralQube.trn");
279 else if ((allowedTypes & L0) == L0 && pdsXlater.
InputHasKeyword(
"PdsTypeL0")) {
281 ProcessPdsM3Label(pdsDataFile, L0);
283 else if ((allowedTypes & Rdn) == Rdn && pdsXlater.
InputHasKeyword(
"PdsTypeRdn")) {
285 ProcessPdsM3Label(pdsDataFile, Rdn);
287 else if ((allowedTypes & Loc) == Loc && pdsXlater.
InputHasKeyword(
"PdsTypeLoc")) {
289 ProcessPdsM3Label(pdsDataFile, Loc);
291 else if ((allowedTypes & Obs) == Obs && pdsXlater.
InputHasKeyword(
"PdsTypeObs")) {
293 ProcessPdsM3Label(pdsDataFile, Obs);
295 else if ((allowedTypes & CombinedSpectrum) == CombinedSpectrum &&
298 ProcessPdsCombinedSpectrumLabel(pdsDataFile);
301 QString msg =
"Unknown label type in [" + p_labelFile +
"]";
308 IdentifySource(p_pdsLabel);
324 const bool & calcOffsetOnly) {
328 QString dataFileName;
336 if (dataFilePointer.
size() == 1) {
338 str = pdsXlater.
Translate(
"DataFilePointer");
340 units = dataFilePointer.
unit();
343 dataFileName =
FileName(p_labelFile).name();
355 else if (dataFilePointer.
size() == 2) {
356 dataFileName = pdsXlater.
Translate(
"DataFilePointer", 0);
358 units = dataFilePointer.
unit(1);
361 else if (dataFilePointer.
size() == 0) {
362 QString msg =
"Data file pointer ^IMAGE or ^QUBE has no value, must"
363 "have either file name or offset or both, in [" +
369 QString msg =
"Improperly formatted data file pointer keyword ^IMAGE or "
370 "^QUBE, in [" + p_labelFile +
"], must contain filename "
371 " or offset or both";
377 if (!calcOffsetOnly) {
382 if (dataFileName.size() != 0 && dataFileName.at(0) ==
'/')
386 dataFile =
FileName(labelFile.
path() +
"/" + dataFileName);
389 if (dataFile.fileExists()) {
390 SetInputFile(dataFile.expanded());
394 QString tmp = dataFile.expanded();
395 dataFileName = dataFileName.toLower();
396 dataFile =
FileName(labelFile.
path() +
"/" + dataFileName);
397 if (dataFile.fileExists()) {
398 SetInputFile(dataFile.expanded());
401 QString msg =
"Unable to find input file [" + tmp +
"] or [" +
402 dataFile.expanded() +
"]";
409 units = units.trimmed();
410 if (units ==
"BYTES" || units ==
"B") {
411 SetFileHeaderBytes(offset - 1);
414 QString recSize = pdsXlater.
Translate(
"DataFileRecordBytes");
415 SetFileHeaderBytes((offset - 1) *
toInt(recSize));
426 str = pdsXlater.
Translate(
"CoreBitsPerPixel");
427 int bitsPerPixel =
toInt(str);
428 str = pdsXlater.
Translate(
"CorePixelType");
430 if ((str ==
"Real") && (bitsPerPixel == 64)) {
432 SetPixelType(Isis::Double);
434 else if ((str ==
"Real") && (bitsPerPixel == 32)) {
435 SetPixelType(Isis::Real);
437 else if ((str ==
"Integer") && (bitsPerPixel == 8)) {
438 SetPixelType(Isis::UnsignedByte);
440 else if ((str ==
"Integer") && (bitsPerPixel == 16)) {
441 SetPixelType(Isis::SignedWord);
443 else if ((str ==
"Integer") && (bitsPerPixel == 32)) {
444 SetPixelType(Isis::SignedInteger);
446 else if ((str ==
"Natural") && (bitsPerPixel == 8)) {
447 SetPixelType(Isis::UnsignedByte);
449 else if ((str ==
"Natural") && (bitsPerPixel == 16)) {
450 SetPixelType(Isis::UnsignedWord);
452 else if ((str ==
"Natural") && (bitsPerPixel == 16)) {
453 SetPixelType(Isis::SignedWord);
455 else if ((str ==
"Natural") && (bitsPerPixel == 32)) {
456 SetPixelType(Isis::UnsignedInteger);
461 QString msg =
"Invalid PixelType and BitsPerPixel combination [" + str +
462 ", " +
toString(bitsPerPixel) +
"]";
474 double pdsNull = Isis::NULL8;
544 SetSpecialValues(pdsNull, pdsLrs, pdsLis, pdsHrs, pdsHis);
559 void ProcessImportPds::ProcessPdsImageLabel(
const QString &pdsDataFile) {
560 Isis::FileName transFile(p_transDir +
"/translations/pdsImage.trn");
565 str = pdsXlater.
Translate(
"CoreLinePrefixBytes");
566 SetDataPrefixBytes(
toInt(str));
568 str = pdsXlater.Translate(
"CoreLineSuffixBytes");
569 SetDataSuffixBytes(
toInt(str));
571 ProcessPixelBitandType(pdsXlater);
573 str = pdsXlater.Translate(
"CoreByteOrder");
574 SetByteOrder(Isis::ByteOrderEnumeration(str));
576 str = pdsXlater.Translate(
"CoreSamples");
578 str = pdsXlater.Translate(
"CoreLines");
580 str = pdsXlater.Translate(
"CoreBands");
583 SetDimensions(ns, nl, nb);
586 ProcessSpecialPixels(pdsXlater,
false);
594 if (pdsDataFile.length() > 0) {
595 SetInputFile(pdsDataFile);
596 ProcessDataFilePointer(pdsXlater,
true);
600 else if (p_jp2File.length() > 0) {
601 SetInputFile(p_jp2File);
602 ProcessDataFilePointer(pdsXlater,
true);
608 ProcessDataFilePointer(pdsXlater,
false);
614 str = pdsXlater.Translate(
"CoreBase");
616 str = pdsXlater.Translate(
"CoreMultiplier");
620 str = pdsXlater.Translate(
"CoreOrganization");
622 if (p_encodingType == JP2) {
623 SetOrganization(ProcessImport::JP2);
625 else if (str ==
"BSQ") {
626 SetOrganization(ProcessImport::BSQ);
628 else if (str ==
"BIP") {
629 SetOrganization(ProcessImport::BIP);
631 else if (str ==
"BIL") {
632 SetOrganization(ProcessImport::BIL);
635 QString msg =
"Unsupported axis order [" + str +
"]";
657 void ProcessImportPds::ProcessPdsQubeLabel(
const QString &pdsDataFile,
658 const QString &transFile) {
675 for(
int i = 0; i < val; i++) {
676 str = pdsXlater.Translate(
"CoreOrganization", i);
678 if (str ==
"SAMPLE") {
681 else if (str ==
"LINE") {
684 else if (str ==
"BAND") {
688 QString message =
"Unknown file axis name [" + str +
"]";
693 if (p_encodingType == JP2) {
694 SetOrganization(ProcessImport::JP2);
696 else if (tmp ==
"SAMPLELINEBAND") {
697 SetOrganization(ProcessImport::BSQ);
699 else if (tmp ==
"BANDSAMPLELINE") {
700 SetOrganization(ProcessImport::BIP);
702 else if (tmp ==
"SAMPLEBANDLINE") {
703 SetOrganization(ProcessImport::BIL);
706 PvlKeyword pdsCoreOrg = p_pdsLabel.findKeyword(pdsXlater.
707 InputKeywordName(
"CoreOrganization"), Pvl::Traverse);
709 stringstream pdsCoreOrgStream;
710 pdsCoreOrgStream << pdsCoreOrg;
712 QString msg =
"Unsupported axis order [" + QString(pdsCoreOrgStream.str().c_str()) +
"]";
719 SetDataPrefixBytes(0);
722 str = pdsXlater.Translate(
"SuffixItemSize");
723 int suffix =
toInt(str);
724 str = pdsXlater.Translate(
"AxisSuffixCount", 0);
725 suffix *=
toInt(str);
726 SetDataSuffixBytes(suffix);
728 str = pdsXlater.Translate(
"SuffixItemSize");
729 int trailer =
toInt(str);
730 str = pdsXlater.Translate(
"AxisSuffixCount", 1);
731 trailer *=
toInt(str);
732 str = pdsXlater.Translate(
"CoreSamples", samplePos);
733 trailer *=
toInt(str);
735 SetDataTrailerBytes(trailer);
737 ProcessPixelBitandType(pdsXlater);
742 str = pdsXlater.Translate(
"CoreByteOrder");
744 SetByteOrder(Isis::ByteOrderEnumeration(str));
756 str = pdsXlater.Translate(
"CoreSamples", samplePos);
758 str = pdsXlater.Translate(
"CoreLines", linePos);
760 str = pdsXlater.Translate(
"CoreBands", bandPos);
762 SetDimensions(ns, nl, nb);
766 ProcessSpecialPixels(pdsXlater,
true);
774 if (pdsDataFile.length() > 0) {
775 SetInputFile(pdsDataFile);
776 ProcessDataFilePointer(pdsXlater,
true);
780 else if (p_jp2File.length() > 0) {
781 SetInputFile(p_jp2File);
782 ProcessDataFilePointer(pdsXlater,
true);
786 ProcessDataFilePointer(pdsXlater,
false);
794 if ((pdsXlater.InputHasKeyword(
"BandBase")) &&
795 (pdsXlater.InputHasKeyword(
"BandMultiplier"))) {
796 vector<double> bases;
797 vector<double> mults;
798 for(
int i = 0; i < pdsXlater.InputKeyword(
"BandBase").size(); i++) {
799 str = pdsXlater.Translate(
"BandBase", i);
801 str = pdsXlater.Translate(
"BandMultiplier", i);
805 SetMultiplier(mults);
808 str = pdsXlater.Translate(
"CoreBase");
810 str = pdsXlater.Translate(
"CoreMultiplier");
827 void ProcessImportPds::ProcessPdsM3Label(
const QString &pdsDataFile, PdsFileType fileType) {
829 if (fileType == L0) {
830 transFile = p_transDir +
"/translations/pdsL0.trn";
832 else if (fileType == Rdn) {
833 transFile = p_transDir +
"/translations/pdsRdn.trn";
835 else if (fileType == Loc) {
836 transFile = p_transDir +
"/translations/pdsLoc.trn";
838 else if (fileType == Obs) {
839 transFile = p_transDir +
"/translations/pdsObs.trn";
842 throw IException(IException::Programmer,
"ProcessImportPds::ProcessPdsM3Label can only be "
843 "called with file type of L0, Rdn, Loc or Obs.",
_FILEINFO_);
851 str = pdsXlater.
Translate(
"CoreLinePrefixBytes");
852 SetDataHeaderBytes(
toInt(str));
854 str = pdsXlater.Translate(
"CoreLineSuffixBytes");
855 SetDataSuffixBytes(
toInt(str));
857 ProcessPixelBitandType(pdsXlater);
859 str = pdsXlater.Translate(
"CoreByteOrder");
860 SetByteOrder(Isis::ByteOrderEnumeration(str));
862 str = pdsXlater.Translate(
"CoreSamples");
864 str = pdsXlater.Translate(
"CoreLines");
866 str = pdsXlater.Translate(
"CoreBands");
868 SetDimensions(ns, nl, nb);
871 ProcessSpecialPixels(pdsXlater,
false);
879 if (pdsDataFile.length() > 0) {
880 SetInputFile(pdsDataFile);
881 ProcessDataFilePointer(pdsXlater,
true);
885 else if (p_jp2File.length() > 0) {
886 SetInputFile(p_jp2File);
887 ProcessDataFilePointer(pdsXlater,
true);
893 ProcessDataFilePointer(pdsXlater,
false);
899 str = pdsXlater.Translate(
"CoreBase");
901 str = pdsXlater.Translate(
"CoreMultiplier");
905 str = pdsXlater.Translate(
"CoreOrganization");
907 if (p_encodingType == JP2) {
908 SetOrganization(ProcessImport::JP2);
910 else if (str ==
"BSQ") {
911 SetOrganization(ProcessImport::BSQ);
913 else if (str ==
"BIP") {
914 SetOrganization(ProcessImport::BIP);
916 else if (str ==
"BIL") {
917 SetOrganization(ProcessImport::BIL);
920 QString msg =
"Unsupported axis order [" + str +
"]";
937 void ProcessImportPds::ProcessPdsCombinedSpectrumLabel(
const QString &pdsDataFile) {
938 Isis::FileName transFile(p_transDir +
"/translations/pdsCombinedSpectrum.trn");
943 str = pdsXlater.
Translate(
"CoreLinePrefixBytes");
944 SetDataPrefixBytes(
toInt(str));
946 str = pdsXlater.Translate(
"CoreLineSuffixBytes");
947 SetDataSuffixBytes(
toInt(str));
949 ProcessPixelBitandType(pdsXlater);
951 str = pdsXlater.Translate(
"CoreByteOrder");
952 SetByteOrder(Isis::ByteOrderEnumeration(str));
954 str = pdsXlater.Translate(
"CoreSamples");
956 str = pdsXlater.Translate(
"CoreLines");
958 str = pdsXlater.Translate(
"CoreBands");
961 SetDimensions(ns, nl, nb);
969 if (pdsDataFile.length() > 0) {
970 SetInputFile(pdsDataFile);
971 ProcessDataFilePointer(pdsXlater,
true);
975 else if (p_jp2File.length() > 0) {
976 SetInputFile(p_jp2File);
977 ProcessDataFilePointer(pdsXlater,
true);
983 ProcessDataFilePointer(pdsXlater,
false);
989 str = pdsXlater.Translate(
"CoreBase");
991 str = pdsXlater.Translate(
"CoreMultiplier");
995 str = pdsXlater.Translate(
"CoreOrganization");
997 if (p_encodingType == JP2) {
998 SetOrganization(ProcessImport::JP2);
1000 else if (str ==
"BSQ") {
1001 SetOrganization(ProcessImport::BSQ);
1003 else if (str ==
"BIP") {
1004 SetOrganization(ProcessImport::BIP);
1006 else if (str ==
"BIL") {
1007 SetOrganization(ProcessImport::BIL);
1010 QString msg =
"Unsupported axis order [" + str +
"]";
1027 void ProcessImportPds::TranslatePdsProjection(
Isis::Pvl &lab) {
1031 stringstream trnsStrm;
1032 trnsStrm <<
"Group = PdsProjectionTypeImage" << endl;
1033 trnsStrm <<
" InputPosition = IMAGE_MAP_PROJECTION" << endl;
1034 trnsStrm <<
" InputPosition = IMAGE_MAP_PROJECTION_CATALOG" << endl;
1035 trnsStrm <<
" InputKey = MAP_PROJECTION_TYPE" << endl;
1036 trnsStrm <<
"EndGroup" << endl;
1037 trnsStrm <<
"Group = PdsProjectionTypeQube" << endl;
1038 trnsStrm <<
" InputPosition = (QUBE,IMAGE_MAP_PROJECTION)" << endl;
1039 trnsStrm <<
" InputKey = MAP_PROJECTION_TYPE" << endl;
1040 trnsStrm <<
"EndGroup" << endl;
1041 trnsStrm <<
"Group = PdsProjectionTypeSpectralQube" << endl;
1042 trnsStrm <<
" InputPosition = (SPECTRAL_QUBE,IMAGE_MAP_PROJECTION)" << endl;
1043 trnsStrm <<
" InputKey = MAP_PROJECTION_TYPE" << endl;
1044 trnsStrm <<
"EndGroup" << endl;
1051 QString transDir = (QString) dataDir[
"Base"];
1055 transFile = transDir +
"/" +
"translations/pdsImageProjection.trn";
1058 transFile = transDir +
"/" +
"translations/pdsQubeProjection.trn";
1061 transFile = transDir +
"/" +
"translations/pdsSpectralQubeProjection.trn";
1069 ExtractPdsProjection(pdsXlater);
1079 if (p_minimumLatitude != Isis::NULL8) {
1082 if (p_maximumLatitude != Isis::NULL8) {
1085 if (p_minimumLongitude != Isis::NULL8) {
1088 if (p_maximumLongitude != Isis::NULL8) {
1093 if (p_minimumLongitude != Isis::NULL8 && p_maximumLongitude != Isis::NULL8) {
1094 if (p_maximumLongitude <= p_minimumLongitude) {
1095 if (p_longitudeDomain == 180) {
1096 mapGroup[
"MinimumLongitude"] =
toString(-180);
1097 mapGroup[
"MaximumLongitude"] =
toString(180);
1100 mapGroup[
"MinimumLongitude"] =
toString(0);
1101 mapGroup[
"MaximumLongitude"] =
toString(360);
1110 if (p_rotation != 0.0) {
1119 QString projSpecificFileName =
"$base/translations/pdsImport";
1120 projSpecificFileName += p_projection +
".trn";
1124 specificXlater.Auto(lab);
1126 if (lab.
findGroup(
"Mapping").hasKeyword(
"CenterLongitude")) {
1128 if (p_longitudeDomain == 180)
1129 centerLon =
toString(TProjection::To180Domain((
double)centerLon));
1131 centerLon =
toString(TProjection::To360Domain((
double)centerLon));
1134 if (lab.
findGroup(
"Mapping").hasKeyword(
"PoleLongitude")) {
1136 if (p_longitudeDomain == 180)
1137 poleLon =
toString(TProjection::To180Domain((
double)poleLon));
1139 poleLon =
toString(TProjection::To360Domain((
double)poleLon));
1142 OutputCubes[0]->putGroup(lab.
findGroup(
"Mapping"));
1175 p_projection = pdsXlater.
Translate(
"ProjectionName");
1178 QString message =
"No projection name in labels";
1183 p_targetName = pdsXlater.
Translate(
"TargetName");
1186 QString message =
"No target name in labels";
1191 str = pdsXlater.
Translate(
"EquatorialRadius");
1192 p_equatorialRadius =
toDouble(str) * 1000.0;
1195 QString message =
"No equatorial radius name in labels";
1200 str = pdsXlater.
Translate(
"PolarRadius");
1201 p_polarRadius =
toDouble(str) * 1000.0;
1204 QString message =
"No polar radius in labels";
1209 p_longitudeDirection = pdsXlater.
Translate(
"LongitudeDirection");
1212 p_longitudeDirection = pdsXlater.
Translate(
"LongitudeDirection2");
1215 if (p_polarRadius == p_equatorialRadius) {
1216 p_latitudeType =
"Planetocentric";
1219 p_latitudeType = pdsXlater.
Translate(
"LatitudeType2");
1222 p_latitudeType = pdsXlater.
Translate(
"LatitudeType");
1226 str = pdsXlater.
Translate(
"MinimumLatitude");
1231 p_minimumLatitude = Isis::NULL8;
1235 p_minimumLatitude = Isis::NULL8;
1239 str = pdsXlater.
Translate(
"MaximumLatitude");
1244 p_maximumLatitude = Isis::NULL8;
1248 p_maximumLatitude = Isis::NULL8;
1253 bool positiveWest =
false;
1255 str = pdsXlater.
Translate(
"MinimumLongitude");
1257 positiveWest =
true;
1258 p_minimumLongitude =
toDouble(str);
1261 p_minimumLongitude = Isis::NULL8;
1265 str = pdsXlater.
Translate(
"MinimumLongitude2");
1267 p_minimumLongitude =
toDouble(str);
1270 p_minimumLongitude = Isis::NULL8;
1274 p_minimumLongitude = Isis::NULL8;
1278 str = pdsXlater.
Translate(
"MaximumLongitude");
1280 positiveWest =
true;
1281 p_maximumLongitude =
toDouble(str);
1284 p_maximumLongitude = Isis::NULL8;
1288 str = pdsXlater.
Translate(
"MaximumLongitude2");
1290 p_maximumLongitude =
toDouble(str);
1293 p_maximumLongitude = Isis::NULL8;
1297 p_maximumLongitude = Isis::NULL8;
1300 str = pdsXlater.
Translate(
"LongitudeDomain");
1301 p_longitudeDomain =
toInt(str);
1321 if (positiveWest && (p_longitudeDirection.compare(
"PositiveEast") == 0)) {
1322 double tmp = p_minimumLongitude;
1323 p_minimumLongitude = p_maximumLongitude;
1324 p_maximumLongitude = tmp;
1327 if (p_minimumLongitude > p_maximumLongitude) {
1329 p_longitudeDomain = 180;
1335 if (p_minimumLongitude < 0 || p_maximumLongitude < 0) {
1336 p_longitudeDomain = 180;
1339 str = pdsXlater.
Translate(
"PixelResolution");
1343 if ((str !=
"METERS/PIXEL") && (str !=
"M/PIXEL") && (str !=
"M/PIX")) {
1344 p_pixelResolution *= 1000.0;
1360 double xoff, yoff, xmult, ymult;
1361 GetProjectionOffsetMults(xoff, yoff, xmult, ymult);
1364 str = pdsXlater.
Translate(
"LineProjectionOffset");
1367 str = pdsXlater.
Translate(
"LineProjectionOffset2");
1369 p_lineProjectionOffset =
toDouble(str);
1370 p_upperLeftY = ymult * (p_lineProjectionOffset + yoff) * p_pixelResolution;
1373 str = pdsXlater.
Translate(
"SampleProjectionOffset");
1376 str = pdsXlater.
Translate(
"SampleProjectionOffset2");
1378 p_sampleProjectionOffset =
toDouble(str);
1379 p_upperLeftX = xmult * (p_sampleProjectionOffset + xoff) * p_pixelResolution;
1388 void ProcessImportPds::EndProcess() {
1389 ProcessImportPds::Finalize();
1398 void ProcessImportPds::Finalize() {
1399 if (p_keepOriginalLabel) {
1401 for (
unsigned int i = 0; i < OutputCubes.size(); i++) {
1402 OutputCubes[i]->write(ol);
1405 Process::Finalize();
1413 void ProcessImportPds::OmitOriginalLabel() {
1414 p_keepOriginalLabel =
false;
1424 void ProcessImportPds::IdentifySource(
Isis::Pvl &inputLabel) {
1428 stringstream trnsStrm;
1429 trnsStrm <<
"Group = PdsFile" << endl;
1430 trnsStrm <<
" InputPosition = ROOT" << endl;
1431 trnsStrm <<
" InputKey = PDS_VERSION_ID" << endl;
1432 trnsStrm <<
"EndGroup" << endl;
1433 trnsStrm <<
"Group = Isis2File" << endl;
1434 trnsStrm <<
" InputPosition = ROOT" << endl;
1435 trnsStrm <<
" InputKey = CCSD3ZF0000100000001NJPL3IF0PDS200000001" << endl;
1436 trnsStrm <<
"EndGroup" << endl;
1448 p_source = NOSOURCE;
1462 bool ProcessImportPds::IsIsis2() {
1464 if (p_source == ISIS2) {
1483 void ProcessImportPds::TranslateIsis2Labels(
Isis::Pvl &lab) {
1484 TranslateIsis2BandBin(lab);
1485 TranslateIsis2Instrument(lab);
1497 TranslatePdsBandBin(lab);
1498 TranslatePdsArchive(lab);
1508 void ProcessImportPds::TranslateIsis2BandBin(
Isis::Pvl &lab) {
1511 QString transDir = (QString) dataDir[
"Base"];
1513 Isis::FileName transFile(transDir +
"/" +
"translations/isis2bandbin.trn");
1517 isis2Xlater.Auto(lab);
1527 void ProcessImportPds::TranslateIsis2Instrument(
Isis::Pvl &lab) {
1530 QString transDir = (QString) dataDir[
"Base"];
1531 Isis::FileName transFile(transDir +
"/" +
"translations/isis2instrument.trn");
1535 isis2Xlater.Auto(lab);
1542 QString stime = stkey[0];
1543 stime = stime.remove(QRegExp(
"[Zz]$"));
1555 void ProcessImportPds::TranslatePdsBandBin(
Isis::Pvl &lab) {
1557 Isis::FileName transFile(p_transDir +
"/" +
"translations/pdsImageBandBin.trn");
1561 isis2Xlater.Auto(lab);
1571 void ProcessImportPds::TranslatePdsArchive(
Isis::Pvl &lab) {
1573 Isis::FileName transFile(p_transDir +
"/" +
"translations/pdsImageArchive.trn");
1577 isis2Xlater.Auto(lab);
1593 void ProcessImportPds::GetProjectionOffsetMults(
double &xoff,
double &yoff,
1594 double &xmult,
double &ymult) {
1602 Isis::Pvl p(p_transDir +
"/" +
"translations/pdsProjectionLineSampToXY.def");
1607 for(
int g = 0; g < projDef.
groups(); g++) {
1608 QString key = projDef.
group(g)[
"Keyword"];
1609 if (p_pdsLabel.hasKeyword(key)) {
1610 QString value = p_pdsLabel[key];
1611 QString pattern = projDef.
group(g)[
"Pattern"];
1613 if (value.contains(pattern)) {
1614 xmult = projDef.
group(g)[
"xMult"];
1615 ymult = projDef.
group(g)[
"yMult"];
1616 xoff = projDef.
group(g)[
"xOff"];
1617 yoff = projDef.
group(g)[
"yOff"];
1632 Table &ProcessImportPds::ImportTable(QString pdsTableName) {
1639 int found = isisTableName.lastIndexOf(
"Table");
1640 if (found == isisTableName.length() - 5) {
1641 isisTableName.remove(found, 5);
1645 p_tables.push_back(isisTable);
1647 return p_tables.at(p_tables.size() - 1);
1654 void ProcessImportPds::StartProcess() {
1655 ProcessImport::StartProcess();
1656 for (
unsigned int i = 0; i < p_tables.size(); i++) {
1657 OutputCubes[0]->write(p_tables[i]);
1674 ProcessImport::StartProcess(funct);
Buffer for reading and writing cube data.
Read and store original labels.
int size() const
Returns the number of values stored in this keyword.
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
File name manipulation and expansion.
Table importTable(const QString &isisTableName)
Populate a Table object with the PDS table and return it.
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes.
void addGroup(const Isis::PvlGroup &group)
Add a group to the object.
int toInt(const QString &string)
Global function to convert from a string to an integer.
QString getFormattedName(const QString &colname) const
Converts a column name to a camel-case after it has been cleansed.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
bool InputHasKeyword(const QString nName)
Indicates if the input keyword corresponding to the output name exists in the label.
double toDouble(const QString &string)
Global function to convert from a string to a double.
const double Lis
Value for an Isis Low Instrument Saturation pixel.
Allows applications to translate simple text files.
static double To180Domain(const double lon)
This method converts a longitude into the -180 to 180 domain.
PvlKeyword & findKeyword(const QString &kname, FindOptions opts)
Finds a keyword in the current PvlObject, or deeper inside other PvlObjects and Pvlgroups within this...
Contains multiple PvlContainers.
const PvlKeyword & InputKeyword(const QString nName) const
Returns the ith input value assiciated with the output name argument.
#define _FILEINFO_
Macro for the filename and line number.
A single keyword-value pair.
QString unit(const int index=0) const
Returns the units of measurement of the element of the array of values for the object at the specifie...
This represents a cube in a project-based GUI interface.
QString Translate(QString nName, int findex=0)
Returns a translated value.
Container for cube-like labels.
int groups() const
Returns the number of groups contained.
PvlGroup & group(const int index)
Return the group at the specified index.
Class for storing Table blobs information.
Adds specific functionality to C++ strings.
const double Lrs
Value for an Isis Low Representation Saturation pixel.
Contains Pvl Groups and Pvl Objects.
void read(const QString &file)
Loads PVL information from a stream.
QString path() const
Returns the path.
Import a PDS table file with a label description.
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
const double His
Value for an Isis High Instrument Saturation pixel.
const double Hrs
Value for an Isis High Representation Saturation pixel.