USGS

Isis 3.0 Object Programmers' Reference

Home

ProcessImportPds.cpp
Go to the documentation of this file.
1 
22 #include "ProcessImportPds.h"
23 
24 #include <QString>
25 
26 #include <iostream>
27 #include <QString>
28 #include <sstream>
29 
30 #include "IException.h"
31 #include "ImportPdsTable.h"
32 #include "IString.h"
33 #include "LineManager.h"
34 #include "OriginalLabel.h"
35 #include "PixelType.h"
36 #include "Preference.h"
37 #include "Projection.h"
38 #include "TProjection.h"
39 #include "Pvl.h"
40 #include "PvlKeyword.h"
41 #include "PvlGroup.h"
42 #include "PvlObject.h"
43 #include "PvlTokenizer.h"
44 #include "PvlTranslationManager.h"
45 #include "SpecialPixel.h"
46 #include "Table.h"
47 #include "UserInterface.h"
48 
49 using namespace std;
50 namespace Isis {
51 
55  ProcessImportPds::ProcessImportPds() {
56  p_keepOriginalLabel = true;
57  p_encodingType = NONE;
58  p_jp2File.clear();
59 
60  // Set up a translater for PDS file of type IMAGE
61  Isis::PvlGroup &dataDir = Isis::Preference::Preferences().findGroup("DataDirectory");
62  p_transDir = (QString) dataDir["Base"];
63  }
64 
65 
66  ProcessImportPds::~ProcessImportPds() {
67  }
68 
69 
84  void ProcessImportPds::SetPdsFile(const Isis::Pvl &pdsLabelPvl,
85  const QString &pdsDataFile,
86  PdsFileType allowedTypes) {
87 
88  // Save the label and file for future use
89  p_pdsLabel = pdsLabelPvl;
90  p_labelFile = pdsDataFile;
91  ProcessLabel(pdsDataFile, allowedTypes);
92  }
93 
94 
112  void ProcessImportPds::SetPdsFile(const QString &pdsLabelFile,
113  const QString &pdsDataFile,
114  Isis::Pvl &pdsLabel,
115  PdsFileType allowedTypes) {
116 
117  // Internalize the PDS label in the PVL that was passed in
118  try {
119  pdsLabel.read(pdsLabelFile);
120  }
121  catch (IException &e) {
122  throw IException(e, IException::User,
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 "
125  "image."), _FILEINFO_);
126  }
127 
128  // Save the label and file for future use
129  p_pdsLabel = pdsLabel;
130  p_labelFile = pdsLabelFile;
131  ProcessLabel(pdsDataFile, allowedTypes);
132  }
133 
134 
150  void ProcessImportPds::ProcessLabel(const QString &pdsDataFile, PdsFileType allowedTypes) {
151  // Create a temporary Isis::PvlTranslationManager so we can find out what
152  // type of PDS file this is (i.e., Qube or Image or SpectralQube)
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 = PdsTypeL0" << endl;
161  trnsStrm << " InputPosition = L0_FILE" << endl;
162  trnsStrm << " InputKey = ^L0_IMAGE" << endl;
163  trnsStrm << "EndGroup" << endl;
164  trnsStrm << "Group = PdsTypeRdn" << endl;
165  trnsStrm << " InputPosition = RDN_FILE" << endl;
166  trnsStrm << " InputKey = ^RDN_IMAGE" << endl;
167  trnsStrm << "EndGroup" << endl;
168  trnsStrm << "Group = PdsTypeLoc" << endl;
169  trnsStrm << " InputPosition = LOC_FILE" << endl;
170  trnsStrm << " InputKey = ^LOC_IMAGE" << endl;
171  trnsStrm << "EndGroup" << endl;
172  trnsStrm << "Group = PdsTypeObs" << endl;
173  trnsStrm << " InputPosition = OBS_FILE" << endl;
174  trnsStrm << " InputKey = ^OBS_IMAGE" << endl;
175  trnsStrm << "EndGroup" << endl;
176  trnsStrm << "Group = PdsTypeQube" << endl;
177  trnsStrm << " InputKey = ^QUBE" << endl;
178  trnsStrm << "EndGroup" << endl;
179  trnsStrm << "Group = PdsTypeSpectralQube" << endl;
180  trnsStrm << " InputKey = ^SPECTRAL_QUBE" << endl;
181  trnsStrm << "EndGroup" << endl;
182  trnsStrm << "Group = PdsEncodingType" << endl;
183  trnsStrm << " InputPosition = COMPRESSED_FILE" << endl;
184  trnsStrm << " InputKey = ENCODING_TYPE" << endl;
185  trnsStrm << " Translation = (*,*)" << endl;
186  trnsStrm << "EndGroup" << endl;
187  trnsStrm << "Group = PdsCompressedFile" << endl;
188  trnsStrm << " InputPosition = COMPRESSED_FILE" << endl;
189  trnsStrm << " InputKey = FILE_NAME" << endl;
190  trnsStrm << " Translation = (*,*)" << endl;
191  trnsStrm << "EndGroup" << endl;
192  trnsStrm << "END";
193 
194 
195  //tjw
196  //Determine if we are processing a QUBE whose
197  //core data type is VAX_REAL
198 
199  try{
200 
201  PvlObject obj = p_pdsLabel.findObject("QUBE");
202  PvlKeyword coreKey = obj.findKeyword("CORE_ITEM_TYPE");
203  PvlKeyword suffixKey = obj.findKeyword("BAND_SUFFIX_ITEM_TYPE");
204  //if ( (coreKey[0] == "VAX_REAL") && (suffixKey[0] =="VAX_REAL") )
205 
206  if (coreKey[0] == "VAX_REAL") {
207 
208  ProcessImport::SetVAXConvert(true);
209  }
210 
211  }
212  catch(IException &e){
213 
214 
215  }
216 
217 
218 
219  Isis::PvlTranslationManager pdsXlater(p_pdsLabel, trnsStrm);
220 
221 
222  // Check to see if we are dealing with a JPEG2000 file
223  QString str;
224  if (pdsXlater.InputHasKeyword("PdsEncodingType")) {
225  str = pdsXlater.Translate("PdsEncodingType");
226  if (str == "JP2") {
227  p_encodingType = JP2;
228  str = pdsXlater.Translate("PdsCompressedFile");
229  if (pdsDataFile.isEmpty()) {
230  Isis::FileName lfile(p_labelFile);
231  Isis::FileName ifile(lfile.path() + "/" + str);
232  if (ifile.fileExists()) {
233  p_jp2File = ifile.expanded();
234  }
235  else {
236  QString tmp = ifile.expanded();
237  str = str.toLower();
238  ifile = lfile.path() + "/" + str;
239  if (ifile.fileExists()) {
240  p_jp2File = ifile.expanded();
241  }
242  else {
243  QString msg = "Unable to find input file [" + tmp + "] or [" +
244  ifile.expanded() + "]";
245  throw IException(IException::Io, msg, _FILEINFO_);
246  }
247  }
248  }
249  }
250  else {
251  QString msg = "Unsupported encoding type in [" + p_labelFile + "]";
252  throw IException(IException::Io, msg, _FILEINFO_);
253  }
254  }
255 
256 
257 
258 
259  // Call the correct label processing
260  if ((allowedTypes & Image) == Image && pdsXlater.InputHasKeyword("PdsTypeImage")) {
261 
262  ProcessPdsImageLabel(pdsDataFile);
263  }
264  else if ((allowedTypes & Qube) == Qube && pdsXlater.InputHasKeyword("PdsTypeQube")) {
265 
266  ProcessPdsQubeLabel(pdsDataFile, "pdsQube.trn");
267  }
268  else if ((allowedTypes & SpectralQube) == SpectralQube &&
269  pdsXlater.InputHasKeyword("PdsTypeSpectralQube")) {
270 
271  ProcessPdsQubeLabel(pdsDataFile, "pdsSpectralQube.trn");
272  }
273  else if ((allowedTypes & L0) == L0 && pdsXlater.InputHasKeyword("PdsTypeL0")) {
274 
275  ProcessPdsM3Label(pdsDataFile, L0);
276  }
277  else if ((allowedTypes & Rdn) == Rdn && pdsXlater.InputHasKeyword("PdsTypeRdn")) {
278 
279  ProcessPdsM3Label(pdsDataFile, Rdn);
280  }
281  else if ((allowedTypes & Loc) == Loc && pdsXlater.InputHasKeyword("PdsTypeLoc")) {
282 
283  ProcessPdsM3Label(pdsDataFile, Loc);
284  }
285  else if ((allowedTypes & Obs) == Obs && pdsXlater.InputHasKeyword("PdsTypeObs")) {
286 
287  ProcessPdsM3Label(pdsDataFile, Obs);
288  }
289  else {
290  QString msg = "Unknown label type in [" + p_labelFile + "]";
291  throw IException(IException::Io, msg, _FILEINFO_);
292  }
293 
294 
295 
296  // Find out if this is a PDS file or an ISIS2 file
297  IdentifySource(p_pdsLabel);
298 
299 
300 
301 
302  return;
303  }
304 
305 
312  void ProcessImportPds::ProcessDataFilePointer(Isis::PvlTranslationManager & pdsXlater,
313  const bool & calcOffsetOnly) {
314 
315  const PvlKeyword & dataFilePointer = pdsXlater.InputKeyword("DataFilePointer");
316 
317  QString dataFileName;
318  QString units;
319  QString str;
320  int offset = -1;
321 
322  // If only size 1, we either have a file name or an offset
323  // Either way, when we're done with these two ifs, variables offset and
324  // dataFileName will be set.
325  if (dataFilePointer.size() == 1) {
326  try {
327  str = pdsXlater.Translate("DataFilePointer");
328  offset = toInt(str);
329  units = dataFilePointer.unit();
330  // Successful? we have an offset, means current, p_labelFile
331  // is the location of the data as well
332  dataFileName = FileName(p_labelFile).name();
333  }
334  catch(IException &e) {
335  // Failed to parse to an int, means we have a file name
336  // No offset given, so we use 1, offsets are 1 based
337  offset = 1;
338  units = "BYTES";
339  dataFileName = str;
340  }
341  }
342  // We must have a filename and an offset, in that order
343  // Expection ("filname", <offset>)
344  else if (dataFilePointer.size() == 2) {
345  dataFileName = pdsXlater.Translate("DataFilePointer", 0);
346  offset = IString(pdsXlater.Translate("DataFilePointer", 1)).ToInteger();
347  units = dataFilePointer.unit(1);
348  }
349  // Error, no value
350  else if (dataFilePointer.size() == 0) {
351  QString msg = "Data file pointer ^IMAGE or ^QUBE has no value, must"
352  "have either file name or offset or both, in [" +
353  p_labelFile + "]";
354  throw IException(IException::Unknown, msg, _FILEINFO_);
355  }
356  // Error, more than two values
357  else {
358  QString msg = "Improperly formatted data file pointer keyword ^IMAGE or "
359  "^QUBE, in [" + p_labelFile + "], must contain filename "
360  " or offset or both";
361  throw IException(IException::Unknown, msg, _FILEINFO_);
362  }
363 
364  // Now, to handle the values we found
365  // the filename first, only do so if calcOffsetOnly is false
366  if (!calcOffsetOnly) {
367  Isis::FileName labelFile(p_labelFile);
368 
369  // If dataFileName isn't empty, and does start at the root, use it
370  Isis::FileName dataFile;
371  if (dataFileName.size() != 0 && dataFileName.at(0) == '/')
372  dataFile = FileName(dataFileName);
373  // Otherwise, use the path to it and its name
374  else
375  dataFile = FileName(labelFile.path() + "/" + dataFileName);
376 
377  // If it exists, use it
378  if (dataFile.fileExists()) {
379  SetInputFile(dataFile.expanded());
380  }
381  // Retry with downcased name, if still no luck, fail
382  else {
383  QString tmp = dataFile.expanded();
384  dataFileName = dataFileName.toLower();
385  dataFile = FileName(labelFile.path() + "/" + dataFileName);
386  if (dataFile.fileExists()) {
387  SetInputFile(dataFile.expanded());
388  }
389  else {
390  QString msg = "Unable to find input file [" + tmp + "] or [" +
391  dataFile.expanded() + "]";
392  throw IException(IException::Io, msg, _FILEINFO_);
393  }
394  }
395  }
396 
397  // Now, to handle the offset
398  units = units.trimmed();
399  if (units == "BYTES" || units == "B") {
400  SetFileHeaderBytes(offset - 1);
401  }
402  else {
403  QString recSize = pdsXlater.Translate("DataFileRecordBytes");
404  SetFileHeaderBytes((offset - 1) * toInt(recSize));
405  }
406  }
407 
408 
413  void ProcessImportPds::ProcessPixelBitandType(Isis::PvlTranslationManager & pdsXlater) {
414  QString str;
415  str = pdsXlater.Translate("CoreBitsPerPixel");
416  int bitsPerPixel = toInt(str);
417  str = pdsXlater.Translate("CorePixelType");
418 
419  if ((str == "Real") && (bitsPerPixel == 64)) {
420 
421  SetPixelType(Isis::Double);
422  }
423  else if ((str == "Real") && (bitsPerPixel == 32)) {
424  SetPixelType(Isis::Real);
425  }
426  else if ((str == "Integer") && (bitsPerPixel == 8)) {
427  SetPixelType(Isis::UnsignedByte);
428  }
429  else if ((str == "Integer") && (bitsPerPixel == 16)) {
430  SetPixelType(Isis::SignedWord);
431  }
432  else if ((str == "Integer") && (bitsPerPixel == 32)) {
433  SetPixelType(Isis::SignedInteger);
434  }
435  else if ((str == "Natural") && (bitsPerPixel == 8)) {
436  SetPixelType(Isis::UnsignedByte);
437  }
438  else if ((str == "Natural") && (bitsPerPixel == 16)) {
439  SetPixelType(Isis::UnsignedWord);
440  }
441  else if ((str == "Natural") && (bitsPerPixel == 16)) {
442  SetPixelType(Isis::SignedWord);
443  }
444  else if ((str == "Natural") && (bitsPerPixel == 32)) {
445  SetPixelType(Isis::UnsignedInteger);
446  }
447 
448 
449  else {
450  QString msg = "Invalid PixelType and BitsPerPixel combination [" + str +
451  ", " + toString(bitsPerPixel) + "]";
452  throw IException(IException::Io, msg, _FILEINFO_);
453  }
454  }
455 
456 
460  void ProcessImportPds::ProcessSpecialPixels(Isis::PvlTranslationManager & pdsXlater, const bool & isQube) {
461  QString str;
462  // Set any special pixel values
463  double pdsNull = Isis::NULL8;
464  if (pdsXlater.InputHasKeyword("CoreNull")) {
465  str = pdsXlater.Translate("CoreNull");
466  if (str != "NULL") {
467  pdsNull = toDouble(str);
468  }
469  }
470  else if (!isQube && pdsXlater.InputHasKeyword("CoreNull2")) {
471  str = pdsXlater.Translate("CoreNull2");
472  if (str != "NULL") {
473  pdsNull = toDouble(str);
474  }
475  }
476 
477  double pdsLrs = Isis::Lrs;
478  if (pdsXlater.InputHasKeyword("CoreLrs")) {
479  str = pdsXlater.Translate("CoreLrs");
480  if (str != "NULL") {
481  pdsLrs = toDouble(str);
482  }
483  }
484  else if (!isQube && pdsXlater.InputHasKeyword("CoreLrs2")) {
485  str = pdsXlater.Translate("CoreLrs2");
486  if (str != "NULL") {
487  pdsLrs = toDouble(str);
488  }
489  }
490 
491  double pdsLis = Isis::Lis;
492  if (pdsXlater.InputHasKeyword("CoreLis")) {
493  str = pdsXlater.Translate("CoreLis");
494  if (str != "NULL") {
495  pdsLis = toDouble(str);
496  }
497  }
498  else if (!isQube && pdsXlater.InputHasKeyword("CoreLis2")) {
499  str = pdsXlater.Translate("CoreLis2");
500  if (str != "NULL") {
501  pdsLis = toDouble(str);
502  }
503  }
504 
505  double pdsHrs = Isis::Hrs;
506  if (pdsXlater.InputHasKeyword("CoreHrs")) {
507  str = pdsXlater.Translate("CoreHrs");
508  if (str != "NULL") {
509  pdsHrs = toDouble(str);
510  }
511  }
512  else if (!isQube && pdsXlater.InputHasKeyword("CoreHrs2")) {
513  str = pdsXlater.Translate("CoreHrs2");
514  if (str != "NULL") {
515  pdsHrs = toDouble(str);
516  }
517  }
518 
519  double pdsHis = Isis::His;
520  if (pdsXlater.InputHasKeyword("CoreHis")) {
521  str = pdsXlater.Translate("CoreHis");
522  if (str != "NULL") {
523  pdsHis = toDouble(str);
524  }
525  }
526  else if (!isQube && pdsXlater.InputHasKeyword("CoreHis2")) {
527  str = pdsXlater.Translate("CoreHis2");
528  if (str != "NULL") {
529  pdsHis = toDouble(str);
530  }
531  }
532 
533  SetSpecialValues(pdsNull, pdsLrs, pdsLis, pdsHrs, pdsHis);
534  }
535 
536 
548  void ProcessImportPds::ProcessPdsImageLabel(const QString &pdsDataFile) {
549  Isis::FileName transFile(p_transDir + "/translations/pdsImage.trn");
550  Isis::PvlTranslationManager pdsXlater(p_pdsLabel, transFile.expanded());
551 
552  QString str;
553 
554  str = pdsXlater.Translate("CoreLinePrefixBytes");
555  SetDataPrefixBytes(toInt(str));
556 
557  str = pdsXlater.Translate("CoreLineSuffixBytes");
558  SetDataSuffixBytes(toInt(str));
559 
560  ProcessPixelBitandType(pdsXlater);
561 
562  str = pdsXlater.Translate("CoreByteOrder");
563  SetByteOrder(Isis::ByteOrderEnumeration(str));
564 
565  str = pdsXlater.Translate("CoreSamples");
566  int ns = toInt(str);
567  str = pdsXlater.Translate("CoreLines");
568  int nl = toInt(str);
569  str = pdsXlater.Translate("CoreBands");
570  int nb = toInt(str);
571 
572  SetDimensions(ns, nl, nb);
573 
574  // Set any special pixel values, not qube, so use false
575  ProcessSpecialPixels(pdsXlater, false);
576 
577  //-----------------------------------------------------------------
578  // Find the data filename it may be the same as the label file
579  // OR the label file may contain a pointer to the data
580  //-----------------------------------------------------------------
581 
582  // Use the name supplied by the application if it is there
583  if (pdsDataFile.length() > 0) {
584  SetInputFile(pdsDataFile);
585  ProcessDataFilePointer(pdsXlater, true);
586  }
587  // If the data is in JPEG 2000 format, then use the name of the file
588  // from the label
589  else if (p_jp2File.length() > 0) {
590  SetInputFile(p_jp2File);
591  ProcessDataFilePointer(pdsXlater, true);
592  }
593  // Use the "^IMAGE or ^QUBE" label to get the filename for the image data
594  // Get the path portion from user entered label file spec
595  else {
596  // Handle filename and offset
597  ProcessDataFilePointer(pdsXlater, false);
598  }
599 
600  //------------------------------------------------------------
601  // Find the image data base and multiplier
602  //------------------------------------------------------------
603  str = pdsXlater.Translate("CoreBase");
604  SetBase(toDouble(str));
605  str = pdsXlater.Translate("CoreMultiplier");
606  SetMultiplier(toDouble(str));
607 
608  // Find the organization of the image data
609  str = pdsXlater.Translate("CoreOrganization");
610 
611  if (p_encodingType == JP2) {
612  SetOrganization(ProcessImport::JP2);
613  }
614  else if (str == "BSQ") {
615  SetOrganization(ProcessImport::BSQ);
616  }
617  else if (str == "BIP") {
618  SetOrganization(ProcessImport::BIP);
619  }
620  else if (str == "BIL") {
621  SetOrganization(ProcessImport::BIL);
622  }
623  else {
624  QString msg = "Unsupported axis order [" + str + "]";
625  throw IException(IException::Programmer, msg, _FILEINFO_);
626  }
627  }
628 
629 
646  void ProcessImportPds::ProcessPdsQubeLabel(const QString &pdsDataFile,
647  const QString &transFile) {
648 
649 
650  Isis::FileName tFile(p_transDir + "/translations/" + transFile);
651 
652  Isis::PvlTranslationManager pdsXlater(p_pdsLabel, tFile.expanded());
653 
654  QString str;
655 
656 
657  // Find the organization of the image data
658  // Save off which axis the samples, lines and bands are on
659  int linePos = 0;
660  int samplePos = 0;
661  int bandPos = 0;
662  int val = pdsXlater.InputKeyword("CoreOrganization").size();
663  QString tmp = "";
664  for(int i = 0; i < val; i++) {
665  str = pdsXlater.Translate("CoreOrganization", i);
666  tmp += str;
667  if (str == "SAMPLE") {
668  samplePos = i;
669  }
670  else if (str == "LINE") {
671  linePos = i;
672  }
673  else if (str == "BAND") {
674  bandPos = i;
675  }
676  else {
677  QString message = "Unknown file axis name [" + str + "]";
678  throw IException(IException::User, message, _FILEINFO_);
679  }
680  }
681 
682  if (p_encodingType == JP2) {
683  SetOrganization(ProcessImport::JP2);
684  }
685  else if (tmp == "SAMPLELINEBAND") {
686  SetOrganization(ProcessImport::BSQ);
687  }
688  else if (tmp == "BANDSAMPLELINE") {
689  SetOrganization(ProcessImport::BIP);
690  }
691  else if (tmp == "SAMPLEBANDLINE") {
692  SetOrganization(ProcessImport::BIL);
693  }
694  else {
695  PvlKeyword pdsCoreOrg = p_pdsLabel.findKeyword(pdsXlater.
696  InputKeywordName("CoreOrganization"), Pvl::Traverse);
697 
698  stringstream pdsCoreOrgStream;
699  pdsCoreOrgStream << pdsCoreOrg;
700 
701  QString msg = "Unsupported axis order [" + QString(pdsCoreOrgStream.str().c_str()) + "]";
702  throw IException(IException::Programmer, msg, _FILEINFO_);
703  }
704 
705 
706  // Set the number of byte preceding the second dimension (left side plane)
707  // There are no capabilities in a PDS QUBE for this
708  SetDataPrefixBytes(0);
709 
710  // Set the number of bytes following the second dimension (right side plane)
711  str = pdsXlater.Translate("SuffixItemSize");
712  int suffix = toInt(str);
713  str = pdsXlater.Translate("AxisSuffixCount", 0);
714  suffix *= toInt(str);
715  SetDataSuffixBytes(suffix);
716 
717  str = pdsXlater.Translate("SuffixItemSize");
718  int trailer = toInt(str);
719  str = pdsXlater.Translate("AxisSuffixCount", 1);
720  trailer *= toInt(str);
721  str = pdsXlater.Translate("CoreSamples", samplePos);
722  trailer *= toInt(str);
723  trailer += suffix;
724  SetDataTrailerBytes(trailer);
725 
726  ProcessPixelBitandType(pdsXlater);
727 
728  // Set the byte order
729 
730  //tjw:
731  str = pdsXlater.Translate("CoreByteOrder");
732 
733  SetByteOrder(Isis::ByteOrderEnumeration(str));
734 
735  //if(str == "LSB" || str == "MSB")
736  // SetByteOrder(Isis::ByteOrderEnumeration(str));
737  //else {
738  // QString msg = "Unrecognized byte order ["+str+"]";
739  // throw IException(IException::Programmer,msg,_FILEINFO_);
740  //}
741 
742 
743 
744  // Set the number of samples, lines and bands
745  str = pdsXlater.Translate("CoreSamples", samplePos);
746  int ns = toInt(str);
747  str = pdsXlater.Translate("CoreLines", linePos);
748  int nl = toInt(str);
749  str = pdsXlater.Translate("CoreBands", bandPos);
750  int nb = toInt(str);
751  SetDimensions(ns, nl, nb);
752 
753 
754  // Set any special pixels values, qube, so use true
755  ProcessSpecialPixels(pdsXlater, true);
756 
757  //---------------------------------------------------------------
758  // Find the data filename, it may be the same as the label file
759  // Or the label file may contain a pointer to the data
760  //---------------------------------------------------------------
761 
762  // Use the name supplied by the application if it is there
763  if (pdsDataFile.length() > 0) {
764  SetInputFile(pdsDataFile);
765  ProcessDataFilePointer(pdsXlater, true);
766  }
767  // If the data is in JPEG 2000 format, then use the name of the file
768  // from the label
769  else if (p_jp2File.length() > 0) {
770  SetInputFile(p_jp2File);
771  ProcessDataFilePointer(pdsXlater, true);
772  }
773  else {
774  // Handle filename and offset
775  ProcessDataFilePointer(pdsXlater, false);
776  }
777 
778 
779  //------------------------------------------------------------
780  // Find the image data base and multiplier
781  //------------------------------------------------------------
782  // First see if there are base and multiplier in the band bin group
783  if ((pdsXlater.InputHasKeyword("BandBase")) &&
784  (pdsXlater.InputHasKeyword("BandMultiplier"))) {
785  vector<double> bases;
786  vector<double> mults;
787  for(int i = 0; i < pdsXlater.InputKeyword("BandBase").size(); i++) {
788  str = pdsXlater.Translate("BandBase", i);
789  bases.push_back(toDouble(str));
790  str = pdsXlater.Translate("BandMultiplier", i);
791  mults.push_back(toDouble(str));
792  }
793  SetBase(bases);
794  SetMultiplier(mults);
795  }
796  else {
797  str = pdsXlater.Translate("CoreBase");
798  SetBase(toDouble(str));
799  str = pdsXlater.Translate("CoreMultiplier");
800  SetMultiplier(toDouble(str));
801  }
802  }
803 
804 
816  void ProcessImportPds::ProcessPdsM3Label(const QString &pdsDataFile, PdsFileType fileType) {
817  Isis::FileName transFile;
818  if (fileType == L0) {
819  transFile = p_transDir + "/translations/pdsL0.trn";
820  }
821  else if (fileType == Rdn) {
822  transFile = p_transDir + "/translations/pdsRdn.trn";
823  }
824  else if (fileType == Loc) {
825  transFile = p_transDir + "/translations/pdsLoc.trn";
826  }
827  else if (fileType == Obs) {
828  transFile = p_transDir + "/translations/pdsObs.trn";
829  }
830  else {
831  throw IException(IException::Programmer, "ProcessImportPds::ProcessPdsM3Label can only be "
832  "called with file type of L0, Rdn, Loc or Obs.", _FILEINFO_);
833  }
834  Isis::PvlTranslationManager pdsXlater(p_pdsLabel, transFile.expanded());
835 
836  QString str;
837 
838  // L1B (Rdn) products do not have an prefix or suffix data. L0 have 1280 bytes at the
839  // beginning of each line of the BIL formatted file.
840  str = pdsXlater.Translate("CoreLinePrefixBytes");
841  SetDataHeaderBytes(toInt(str));
842 
843  str = pdsXlater.Translate("CoreLineSuffixBytes");
844  SetDataSuffixBytes(toInt(str));
845 
846  ProcessPixelBitandType(pdsXlater);
847 
848  str = pdsXlater.Translate("CoreByteOrder");
849  SetByteOrder(Isis::ByteOrderEnumeration(str));
850 
851  str = pdsXlater.Translate("CoreSamples");
852  int ns = toInt(str);
853  str = pdsXlater.Translate("CoreLines");
854  int nl = toInt(str);
855  str = pdsXlater.Translate("CoreBands");
856  int nb = toInt(str);
857  SetDimensions(ns, nl, nb);
858 
859  // Set any special pixel values, not qube, so use false
860  ProcessSpecialPixels(pdsXlater, false);
861 
862  //-----------------------------------------------------------------
863  // Find the data filename it may be the same as the label file
864  // OR the label file may contain a pointer to the data
865  //-----------------------------------------------------------------
866 
867  // Use the name supplied by the application if it is there
868  if (pdsDataFile.length() > 0) {
869  SetInputFile(pdsDataFile);
870  ProcessDataFilePointer(pdsXlater, true);
871  }
872  // If the data is in JPEG 2000 format, then use the name of the file
873  // from the label
874  else if (p_jp2File.length() > 0) {
875  SetInputFile(p_jp2File);
876  ProcessDataFilePointer(pdsXlater, true);
877  }
878  // Use the "^IMAGE or ^QUBE" label to get the filename for the image data
879  // Get the path portion from user entered label file spec
880  else {
881  // Handle filename and offset
882  ProcessDataFilePointer(pdsXlater, false);
883  }
884 
885  //------------------------------------------------------------
886  // Find the image data base and multiplier
887  //------------------------------------------------------------
888  str = pdsXlater.Translate("CoreBase");
889  SetBase(toDouble(str));
890  str = pdsXlater.Translate("CoreMultiplier");
891  SetMultiplier(toDouble(str));
892 
893  // Find the organization of the image data
894  str = pdsXlater.Translate("CoreOrganization");
895 
896  if (p_encodingType == JP2) {
897  SetOrganization(ProcessImport::JP2);
898  }
899  else if (str == "BSQ") {
900  SetOrganization(ProcessImport::BSQ);
901  }
902  else if (str == "BIP") {
903  SetOrganization(ProcessImport::BIP);
904  }
905  else if (str == "BIL") {
906  SetOrganization(ProcessImport::BIL);
907  }
908  else {
909  QString msg = "Unsupported axis order [" + str + "]";
910  throw IException(IException::Programmer, msg, _FILEINFO_);
911  }
912  }
913 
914 
926  void ProcessImportPds::TranslatePdsProjection(Isis::Pvl &lab) {
927 
928  // Create a temporary Isis::PvlTranslationManager so we can find out what
929  // type of projection labels exist
930  stringstream trnsStrm;
931  trnsStrm << "Group = PdsProjectionTypeImage" << endl;
932  trnsStrm << " InputPosition = IMAGE_MAP_PROJECTION" << endl;
933  trnsStrm << " InputPosition = IMAGE_MAP_PROJECTION_CATALOG" << endl;
934  trnsStrm << " InputKey = MAP_PROJECTION_TYPE" << endl;
935  trnsStrm << "EndGroup" << endl;
936  trnsStrm << "Group = PdsProjectionTypeQube" << endl;
937  trnsStrm << " InputPosition = (QUBE,IMAGE_MAP_PROJECTION)" << endl;
938  trnsStrm << " InputKey = MAP_PROJECTION_TYPE" << endl;
939  trnsStrm << "EndGroup" << endl;
940  trnsStrm << "Group = PdsProjectionTypeSpectralQube" << endl;
941  trnsStrm << " InputPosition = (SPECTRAL_QUBE,IMAGE_MAP_PROJECTION)" << endl;
942  trnsStrm << " InputKey = MAP_PROJECTION_TYPE" << endl;
943  trnsStrm << "EndGroup" << endl;
944  trnsStrm << "END";
945 
946  Isis::PvlTranslationManager projType(p_pdsLabel, trnsStrm);
947 
948  // Set up the correct projection translation table for this label
949  Isis::PvlGroup &dataDir = Isis::Preference::Preferences().findGroup("DataDirectory");
950  QString transDir = (QString) dataDir["Base"];
951 
952  Isis::FileName transFile;
953  if (projType.InputHasKeyword("PdsProjectionTypeImage")) {
954  transFile = transDir + "/" + "translations/pdsImageProjection.trn";
955  }
956  else if (projType.InputHasKeyword("PdsProjectionTypeQube")) {
957  transFile = transDir + "/" + "translations/pdsQubeProjection.trn";
958  }
959  else if (projType.InputHasKeyword("PdsProjectionTypeSpectralQube")) {
960  transFile = transDir + "/" + "translations/pdsSpectralQubeProjection.trn";
961  }
962  else {
963  return;
964  }
965 
966  Isis::PvlTranslationManager pdsXlater(p_pdsLabel, transFile.expanded());
967 
968  ExtractPdsProjection(pdsXlater);
969 
970  Isis::PvlGroup mapGroup("Mapping");
971  mapGroup += Isis::PvlKeyword("ProjectionName", p_projection);
972  mapGroup += Isis::PvlKeyword("TargetName", p_targetName);
973  mapGroup += Isis::PvlKeyword("EquatorialRadius", toString(p_equatorialRadius), "meters");
974  mapGroup += Isis::PvlKeyword("PolarRadius", toString(p_polarRadius), "meters");
975  mapGroup += Isis::PvlKeyword("LongitudeDirection", p_longitudeDirection);
976  mapGroup += Isis::PvlKeyword("LongitudeDomain", toString(p_longitudeDomain));
977  mapGroup += Isis::PvlKeyword("LatitudeType", p_latitudeType);
978  if (p_minimumLatitude != Isis::NULL8) {
979  mapGroup += Isis::PvlKeyword("MinimumLatitude", toString(p_minimumLatitude));
980  }
981  if (p_maximumLatitude != Isis::NULL8) {
982  mapGroup += Isis::PvlKeyword("MaximumLatitude", toString(p_maximumLatitude));
983  }
984  if (p_minimumLongitude != Isis::NULL8) {
985  mapGroup += Isis::PvlKeyword("MinimumLongitude", toString(p_minimumLongitude));
986  }
987  if (p_maximumLongitude != Isis::NULL8) {
988  mapGroup += Isis::PvlKeyword("MaximumLongitude", toString(p_maximumLongitude));
989  }
990 
991  // if both longitudes exist, verify they are ordered correctly
992  if (p_minimumLongitude != Isis::NULL8 && p_maximumLongitude != Isis::NULL8) {
993  if (p_maximumLongitude <= p_minimumLongitude) {
994  if (p_longitudeDomain == 180) {
995  mapGroup["MinimumLongitude"] = toString(-180);
996  mapGroup["MaximumLongitude"] = toString(180);
997  }
998  else {
999  mapGroup["MinimumLongitude"] = toString(0);
1000  mapGroup["MaximumLongitude"] = toString(360);
1001  }
1002  }
1003  }
1004 
1005  mapGroup += Isis::PvlKeyword("PixelResolution", toString(p_pixelResolution), "meters/pixel");
1006  mapGroup += Isis::PvlKeyword("Scale", toString(p_scaleFactor), "pixels/degree");
1007  mapGroup += Isis::PvlKeyword("UpperLeftCornerX", toString(p_upperLeftX), "meters");
1008  mapGroup += Isis::PvlKeyword("UpperLeftCornerY", toString(p_upperLeftY), "meters");
1009  if (p_rotation != 0.0) {
1010  mapGroup += Isis::PvlKeyword("Rotation", toString(p_rotation));
1011  }
1012 
1013  // To handle new projections without the need to modify source code
1014  // we will construct a filename from the projection. The filename will
1015  // contain the projection specific translations from PDS to ISIS for each
1016  // projection
1017 
1018  QString projSpecificFileName = "$base/translations/pdsImport";
1019  projSpecificFileName += p_projection + ".trn";
1020  Isis::PvlTranslationManager specificXlater(p_pdsLabel, projSpecificFileName);
1021 
1022  lab.addGroup(mapGroup);
1023  specificXlater.Auto(lab);
1024 
1025  if (lab.findGroup("Mapping").hasKeyword("CenterLongitude")) {
1026  PvlKeyword &centerLon = lab.findGroup("Mapping")["CenterLongitude"];
1027  if (p_longitudeDomain == 180)
1028  centerLon = toString(TProjection::To180Domain((double)centerLon));
1029  else
1030  centerLon = toString(TProjection::To360Domain((double)centerLon));
1031  }
1032 
1033  if (lab.findGroup("Mapping").hasKeyword("PoleLongitude")) {
1034  PvlKeyword &poleLon = lab.findGroup("Mapping")["PoleLongitude"];
1035  if (p_longitudeDomain == 180)
1036  poleLon = toString(TProjection::To180Domain((double)poleLon));
1037  else
1038  poleLon = toString(TProjection::To360Domain((double)poleLon));
1039  }
1040 
1041  OutputCubes[0]->putGroup(lab.findGroup("Mapping"));
1042  }
1043 
1044 
1069  void ProcessImportPds::ExtractPdsProjection(Isis::PvlTranslationManager &pdsXlater) {
1070 
1071  QString str;
1072 
1073  if (pdsXlater.InputHasKeyword("ProjectionName")) {
1074  p_projection = pdsXlater.Translate("ProjectionName");
1075  }
1076  else {
1077  QString message = "No projection name in labels";
1078  throw IException(IException::Unknown, message, _FILEINFO_);
1079  }
1080 
1081  if (pdsXlater.InputHasKeyword("TargetName")) {
1082  p_targetName = pdsXlater.Translate("TargetName");
1083  }
1084  else {
1085  QString message = "No target name in labels";
1086  throw IException(IException::Unknown, message, _FILEINFO_);
1087  }
1088 
1089  if (pdsXlater.InputHasKeyword("EquatorialRadius")) {
1090  str = pdsXlater.Translate("EquatorialRadius");
1091  p_equatorialRadius = toDouble(str) * 1000.0;
1092  }
1093  else {
1094  QString message = "No equatorial radius name in labels";
1095  throw IException(IException::User, message, _FILEINFO_);
1096  }
1097 
1098  if (pdsXlater.InputHasKeyword("PolarRadius")) {
1099  str = pdsXlater.Translate("PolarRadius");
1100  p_polarRadius = toDouble(str) * 1000.0;
1101  }
1102  else {
1103  QString message = "No polar radius in labels";
1104  throw IException(IException::User, message, _FILEINFO_);
1105  }
1106 
1107  if (pdsXlater.InputHasKeyword("LongitudeDirection")) {
1108  p_longitudeDirection = pdsXlater.Translate("LongitudeDirection");
1109  }
1110  else {
1111  p_longitudeDirection = pdsXlater.Translate("LongitudeDirection2");
1112  }
1113 
1114  if (p_polarRadius == p_equatorialRadius) {
1115  p_latitudeType = "Planetocentric";
1116  }
1117  else if (pdsXlater.InputHasKeyword("LatitudeType2")) {
1118  p_latitudeType = pdsXlater.Translate("LatitudeType2");
1119  }
1120  else {
1121  p_latitudeType = pdsXlater.Translate("LatitudeType");
1122  }
1123 
1124  if (pdsXlater.InputHasKeyword("MinimumLatitude")) {
1125  str = pdsXlater.Translate("MinimumLatitude");
1126  try {
1127  p_minimumLatitude = toDouble(str);
1128  }
1129  catch(IException &e) {
1130  p_minimumLatitude = Isis::NULL8;
1131  }
1132  }
1133  else {
1134  p_minimumLatitude = Isis::NULL8;
1135  }
1136 
1137  if (pdsXlater.InputHasKeyword("MaximumLatitude")) {
1138  str = pdsXlater.Translate("MaximumLatitude");
1139  try {
1140  p_maximumLatitude = toDouble(str);
1141  }
1142  catch(IException &e) {
1143  p_maximumLatitude = Isis::NULL8;
1144  }
1145  }
1146  else {
1147  p_maximumLatitude = Isis::NULL8;
1148  }
1149 
1150  // This variable represents if the longitudes were read in as
1151  // positive west
1152  bool positiveWest = false;
1153  if (pdsXlater.InputHasKeyword("MinimumLongitude")) {
1154  str = pdsXlater.Translate("MinimumLongitude");
1155  try {
1156  positiveWest = true;
1157  p_minimumLongitude = toDouble(str);
1158  }
1159  catch(IException &e) {
1160  p_minimumLongitude = Isis::NULL8;
1161  }
1162  }
1163  else if (pdsXlater.InputHasKeyword("MinimumLongitude2")) {
1164  str = pdsXlater.Translate("MinimumLongitude2");
1165  try {
1166  p_minimumLongitude = toDouble(str);
1167  }
1168  catch(IException &e) {
1169  p_minimumLongitude = Isis::NULL8;
1170  }
1171  }
1172  else {
1173  p_minimumLongitude = Isis::NULL8;
1174  }
1175 
1176  if (pdsXlater.InputHasKeyword("MaximumLongitude")) {
1177  str = pdsXlater.Translate("MaximumLongitude");
1178  try {
1179  positiveWest = true;
1180  p_maximumLongitude = toDouble(str);
1181  }
1182  catch(IException &e) {
1183  p_maximumLongitude = Isis::NULL8;
1184  }
1185  }
1186  else if (pdsXlater.InputHasKeyword("MaximumLongitude2")) {
1187  str = pdsXlater.Translate("MaximumLongitude2");
1188  try {
1189  p_maximumLongitude = toDouble(str);
1190  }
1191  catch(IException &e) {
1192  p_maximumLongitude = Isis::NULL8;
1193  }
1194  }
1195  else {
1196  p_maximumLongitude = Isis::NULL8;
1197  }
1198 
1199  str = pdsXlater.Translate("LongitudeDomain");
1200  p_longitudeDomain = toInt(str);
1201 
1220  if (positiveWest && (p_longitudeDirection.compare("PositiveEast") == 0)) {
1221  double tmp = p_minimumLongitude;
1222  p_minimumLongitude = p_maximumLongitude;
1223  p_maximumLongitude = tmp;
1224  }
1225 
1226  if (p_minimumLongitude > p_maximumLongitude) {
1227  // Force the change to 180
1228  p_longitudeDomain = 180;
1229  p_minimumLongitude = Isis::TProjection::To180Domain(p_minimumLongitude);
1230  }
1231 
1232  // If either the minimumLongitude or maximumLongitude are < 0, change
1233  // longitude Domain to 180.
1234  if (p_minimumLongitude < 0 || p_maximumLongitude < 0) {
1235  p_longitudeDomain = 180;
1236  }
1237 
1238  str = pdsXlater.Translate("PixelResolution");
1239  p_pixelResolution = toDouble(str);
1240  str = pdsXlater.InputKeyword("PixelResolution").unit().toUpper();
1241  // Assume KM/PIXEL if the unit doesn't exist or is not METERS/PIXEL
1242  if ((str != "METERS/PIXEL") && (str != "M/PIXEL") && (str != "M/PIX")) {
1243  p_pixelResolution *= 1000.0;
1244  }
1245 
1246  str = pdsXlater.Translate("Scale");
1247  p_scaleFactor = toDouble(str);
1248 
1249  try {
1250  str = pdsXlater.Translate("Rotation");
1251  p_rotation = toDouble(str);
1252  }
1253  catch(IException &) {
1254  // assume no rotation if the value isn't a number
1255  p_rotation = 0.0;
1256  }
1257 
1258  // Look for projection offsets/mults to convert between line/samp and x/y
1259  double xoff, yoff, xmult, ymult;
1260  GetProjectionOffsetMults(xoff, yoff, xmult, ymult);
1261 
1262  if (pdsXlater.InputHasKeyword("LineProjectionOffset")) {
1263  str = pdsXlater.Translate("LineProjectionOffset");
1264  }
1265  else {
1266  str = pdsXlater.Translate("LineProjectionOffset2");
1267  }
1268  p_lineProjectionOffset = toDouble(str);
1269  p_upperLeftY = ymult * (p_lineProjectionOffset + yoff) * p_pixelResolution;
1270 
1271  if (pdsXlater.InputHasKeyword("SampleProjectionOffset")) {
1272  str = pdsXlater.Translate("SampleProjectionOffset");
1273  }
1274  else {
1275  str = pdsXlater.Translate("SampleProjectionOffset2");
1276  }
1277  p_sampleProjectionOffset = toDouble(str);
1278  p_upperLeftX = xmult * (p_sampleProjectionOffset + xoff) * p_pixelResolution;
1279 
1280 
1281  }
1282 
1283 
1287  void ProcessImportPds::EndProcess() {
1288  ProcessImportPds::Finalize();
1289  }
1290 
1291 
1297  void ProcessImportPds::Finalize() {
1298  if (p_keepOriginalLabel) {
1299  OriginalLabel ol(p_pdsLabel);
1300  for (unsigned int i = 0; i < OutputCubes.size(); i++) {
1301  OutputCubes[i]->write(ol);
1302  }
1303  }
1304  Process::Finalize();
1305  }
1306 
1307 
1312  void ProcessImportPds::OmitOriginalLabel() {
1313  p_keepOriginalLabel = false;
1314  }
1315 
1316 
1323  void ProcessImportPds::IdentifySource(Isis::Pvl &inputLabel) {
1324 
1325  // Create a temporary Isis::PvlTranslationManager so we can find out what
1326  // type of input file we have
1327  stringstream trnsStrm;
1328  trnsStrm << "Group = PdsFile" << endl;
1329  trnsStrm << " InputPosition = ROOT" << endl;
1330  trnsStrm << " InputKey = PDS_VERSION_ID" << endl;
1331  trnsStrm << "EndGroup" << endl;
1332  trnsStrm << "Group = Isis2File" << endl;
1333  trnsStrm << " InputPosition = ROOT" << endl;
1334  trnsStrm << " InputKey = CCSD3ZF0000100000001NJPL3IF0PDS200000001" << endl;
1335  trnsStrm << "EndGroup" << endl;
1336  trnsStrm << "END";
1337 
1338  Isis::PvlTranslationManager sourceXlater(inputLabel, trnsStrm);
1339 
1340  if (sourceXlater.InputHasKeyword("PdsFile")) {
1341  p_source = PDS;
1342  }
1343  else if (sourceXlater.InputHasKeyword("Isis2File")) {
1344  p_source = ISIS2;
1345  }
1346  else {
1347  p_source = NOSOURCE;
1348  }
1349 
1350  }
1351 
1352 
1361  bool ProcessImportPds::IsIsis2() {
1362 
1363  if (p_source == ISIS2) {
1364 
1365  return true;
1366  }
1367  else {
1368  return false;
1369  }
1370 
1371 
1372  }
1373 
1374 
1382  void ProcessImportPds::TranslateIsis2Labels(Isis::Pvl &lab) {
1383  TranslateIsis2BandBin(lab);
1384  TranslateIsis2Instrument(lab);
1385  }
1386 
1387 
1395  void ProcessImportPds::TranslatePdsLabels(Isis::Pvl &lab) {
1396  TranslatePdsBandBin(lab);
1397  TranslatePdsArchive(lab);
1398  }
1399 
1400 
1407  void ProcessImportPds::TranslateIsis2BandBin(Isis::Pvl &lab) {
1408  // Set up a translater for Isis2 labels
1409  Isis::PvlGroup &dataDir = Isis::Preference::Preferences().findGroup("DataDirectory");
1410  QString transDir = (QString) dataDir["Base"];
1411 
1412  Isis::FileName transFile(transDir + "/" + "translations/isis2bandbin.trn");
1413  Isis::PvlTranslationManager isis2Xlater(p_pdsLabel, transFile.expanded());
1414 
1415  // Add all the Isis2 keywords that can be translated to the requested label
1416  isis2Xlater.Auto(lab);
1417  }
1418 
1419 
1426  void ProcessImportPds::TranslateIsis2Instrument(Isis::Pvl &lab) {
1427  // Set up a translater for Isis2 labels
1428  Isis::PvlGroup &dataDir = Isis::Preference::Preferences().findGroup("DataDirectory");
1429  QString transDir = (QString) dataDir["Base"];
1430  Isis::FileName transFile(transDir + "/" + "translations/isis2instrument.trn");
1431  Isis::PvlTranslationManager isis2Xlater(p_pdsLabel, transFile.expanded());
1432 
1433  // Add all the Isis2 keywords that can be translated to the requested label
1434  isis2Xlater.Auto(lab);
1435 
1436  //Check StartTime for appended 'z' (Zulu time) and remove
1437  Isis::PvlGroup &inst = lab.findGroup("Instrument");
1438 
1439  if (inst.hasKeyword("StartTime")) {
1440  Isis::PvlKeyword &stkey = inst["StartTime"];
1441  QString stime = stkey[0];
1442  stime = stime.remove(QRegExp("[Zz]$"));
1443  stkey = stime;
1444  }
1445  }
1446 
1447 
1454  void ProcessImportPds::TranslatePdsBandBin(Isis::Pvl &lab) {
1455  // Set up a translater for PDS labels
1456  Isis::FileName transFile(p_transDir + "/" + "translations/pdsImageBandBin.trn");
1457  Isis::PvlTranslationManager isis2Xlater(p_pdsLabel, transFile.expanded());
1458 
1459  // Add all the Isis2 keywords that can be translated to the requested label
1460  isis2Xlater.Auto(lab);
1461  }
1462 
1463 
1470  void ProcessImportPds::TranslatePdsArchive(Isis::Pvl &lab) {
1471  // Set up a translater for PDS labels
1472  Isis::FileName transFile(p_transDir + "/" + "translations/pdsImageArchive.trn");
1473  Isis::PvlTranslationManager isis2Xlater(p_pdsLabel, transFile.expanded());
1474 
1475  // Add all the Isis2 keywords that can be translated to the requested label
1476  isis2Xlater.Auto(lab);
1477  }
1478 
1479 
1492  void ProcessImportPds::GetProjectionOffsetMults(double &xoff, double &yoff,
1493  double &xmult, double &ymult) {
1494 
1495  xmult = -1.0;
1496  ymult = 1.0;
1497  xoff = -0.5;
1498  yoff = -0.5;
1499 
1500  // Open projectionOffsetMults file
1501  Isis::Pvl p(p_transDir + "/" + "translations/pdsProjectionLineSampToXY.def");
1502 
1503  Isis::PvlObject &projDef = p.findObject("ProjectionOffsetMults",
1504  Pvl::Traverse);
1505 
1506  for(int g = 0; g < projDef.groups(); g++) {
1507  QString key = projDef.group(g)["Keyword"];
1508  if (p_pdsLabel.hasKeyword(key)) {
1509  QString value = p_pdsLabel[key];
1510  QString pattern = projDef.group(g)["Pattern"];
1511  // If value contains pattern, then set the mults to what is in translation file
1512  if (value.contains(pattern)) {
1513  xmult = projDef.group(g)["xMult"];
1514  ymult = projDef.group(g)["yMult"];
1515  xoff = projDef.group(g)["xOff"];
1516  yoff = projDef.group(g)["yOff"];
1517  return;
1518  }
1519  }
1520  }
1521  }
1522 
1523 
1531  Table &ProcessImportPds::ImportTable(QString pdsTableName) {
1532  // No table file given, let ImportPdsTable find it.
1533  ImportPdsTable pdsTable(p_labelFile, "", pdsTableName);
1534  // reformat the table name. If the name ends with the word "Table", remove
1535  // it. (So, for example, INSTRUMENT_POINTING_TABLE gets formatted to
1536  // InstrumentPointingTable and then to InstrumentPointing)
1537  QString isisTableName = pdsTable.getFormattedName(pdsTableName);
1538  int found = isisTableName.lastIndexOf("Table");
1539  if (found == isisTableName.length() - 5) {
1540  isisTableName.remove(found, 5);
1541  }
1542 
1543  Table isisTable = pdsTable.importTable(isisTableName);
1544  p_tables.push_back(isisTable);
1545 
1546  return p_tables.at(p_tables.size() - 1);
1547  }
1548 
1549 
1553  void ProcessImportPds::StartProcess() {
1554  ProcessImport::StartProcess();
1555  for (unsigned int i = 0; i < p_tables.size(); i++) {
1556  OutputCubes[0]->write(p_tables[i]);
1557  }
1558  return;
1559  }
1560 
1561 
1572  void ProcessImportPds::StartProcess(void funct(Isis::Buffer &out)) {
1573  ProcessImport::StartProcess(funct);
1574  return;
1575  }
1576 }
1577 
1578