bool ossimRangeDomeTileSource::loadState(const ossimKeywordlist& kwl, const char* prefix)
{
   static const char MODULE[] = "ossimRangeDomeTileSource::loadState()";
   theDecimationFactors.clear();

   ossimImageHandler::loadState(kwl, prefix);
   if (kwl.getErrorStatus() == ossimErrorCodes::OSSIM_ERROR)
   {
      ossimNotify(ossimNotifyLevel_WARN)<< MODULE
            << "WARNING: error detected in keyword list!  State not load." << std::endl;
      return false;
   }

   ossimDpt gsd;
   ossimString value = kwl.find(prefix, ossimKeywordNames::METERS_PER_PIXEL_KW);
   if (!value.empty())
      gsd.x = value.toDouble();

   value = kwl.find(prefix, ossimKeywordNames::METERS_PER_PIXEL_Y_KW);
   if (!value.empty())
      setGSD(value.toDouble());

   // The rest of the state is established by opening the file:
   bool good_open = open();
   return good_open;
}
bool ossimRangeDomeTileSource::saveState(ossimKeywordlist& kwl, const char* prefix) const
{
   static const char MODULE[] = "ossimRangeDomeTileSource::saveState()";

   ossimImageHandler::saveState(kwl, prefix);
   if (kwl.getErrorStatus() == ossimErrorCodes::OSSIM_ERROR)
   {
      ossimNotify(ossimNotifyLevel_WARN) << MODULE
            << " ERROR detected in keyword list!  State not saved." << std::endl;
      return false;
   }

   kwl.add(prefix, ossimKeywordNames::METERS_PER_PIXEL_KW, m_gsd.x, true);

   return true;
}
bool ossimGeneralRasterInfo::loadState(const ossimKeywordlist& kwl, const char* prefix)
{
   static const char MODULE[] = "ossimGeneralRasterInfo::loadState";
   if ( traceDebug() )
   {
      CLOG << "DEBUG: entered..."
           << "\nprefix:  " << (prefix ? prefix : "")
           << "\nInput keyword list:\n"
           << kwl
           << std::endl;
   }   

   bool result = false;

   //---
   // Look for required and option keyword.  Break from loop if required
   // keyword is not found.
   //---
   while( 1 )
   {
      // Check for errors in the ossimKeywordlist.
      if(kwl.getErrorStatus() == ossimErrorCodes::OSSIM_ERROR)
      {
         ossimNotify(ossimNotifyLevel_WARN)
            << MODULE << " ERROR:\n"
            << "Detected an error in the keywordlist:  " << kwl
            << std::endl;
         break;
      }

      std::string key;
      ossimString value; // Use for keyword list lookups.
      ossim_int32 lines = 0;
      ossim_int32 samples = 0;

      // Lines (required):
      key = NUMBER_LINES;
      value.string() = kwl.findKey( key );  // Required to have this.
      if ( value.size() )
      {
         lines = value.toInt32();
         if ( !lines )
         {
            if (traceDebug())
            {
               ossimNotify(ossimNotifyLevel_WARN)
                  << " ERROR:\n"
                  << "Required number of lines is 0!" << std::endl;
            }
            break;
         } 
      }
      else
      {
         if (traceDebug())
         {
            ossimNotify(ossimNotifyLevel_WARN)
               << " ERROR:\n"
               << "Required keyword not found:  " << key << std::endl;
         }
         break;
      }

      // Samples (required):
      key = NUMBER_SAMPLES;
      value.string() = kwl.findKey( key );  // Required to have this.
      if ( value.size() )
      {
         samples = value.toInt32();
         if ( !samples )
         {
            if (traceDebug())
            {
               ossimNotify(ossimNotifyLevel_WARN)
                  << " ERROR:\n"
                  << "Required number of samples is 0!" << std::endl;
            }
            break;
         }          
      }
      else
      {
         if (traceDebug())
         {
            ossimNotify(ossimNotifyLevel_WARN)
               << " ERROR:\n"
               << "Required keyword not found:  " << key << std::endl;
         }
         break;
      }
      
      // Bands ossimImageMetaData::loadState checks for required bands:
      if(!theMetaData.loadState(kwl, prefix))
      {
         if (traceDebug())
         {
            ossimNotify(ossimNotifyLevel_WARN)
               << " Error loading meta data!\n" << std::endl;
         }
         break;
      }

      // If we get here assign the rectangles:
      theRawImageRect   = ossimIrect( 0, 0, samples - 1, lines - 1 );
      theValidImageRect = theRawImageRect;
      theImageRect      = theRawImageRect;

      int tmp = INTERLEAVE_TYPE_LUT.getEntryNumber(kwl);
      if (tmp == ossimLookUpTable::NOT_FOUND)
      {
         theInterleaveType = OSSIM_BIL;
      }
      else
      {
         theInterleaveType = static_cast<ossimInterleaveType>(tmp);
      }
      
      // Get the image files.
      if (theInterleaveType != OSSIM_BSQ_MULTI_FILE)
      {
         // Look for "filename" first, then deprecated "image_file".
         key = ossimKeywordNames::FILENAME_KW;
         value.string() = kwl.findKey( key );
         if ( value.empty() )
         {
            // deprecated keyword...
            key = ossimKeywordNames::IMAGE_FILE_KW;
            value.string() = kwl.findKey( key );
         }
         
         if ( value.size() )
         {
            //---
            // omd (ossim metadata) files can have just the base filename, e.g. image.ras,
            // in which case open will fail if not in the image dir.  So only put it in
            // the list if it doesn't exits.
            //---
            ossimFilename f = value;
            if ( f.exists() )
            {
               theImageFileList.clear();
               theImageFileList.push_back(ossimFilename(value));
            }
         }

         if ( theImageFileList.empty() )
         {
            if (traceDebug())
            {
               ossimNotify(ossimNotifyLevel_WARN)
                  << "ERROR:\n"
                  << "Required keyword not found:  "
                  << ossimKeywordNames::FILENAME_KW << std::endl;
            }
            break;
         }
      }
      else
      {
         // multiple file names.
         ossim_int32 count = 0;
         
         // look for image file key word with no number.
         // Required to have this.
         key = ossimKeywordNames::FILENAME_KW;
         value.string() = kwl.findKey( key );
         if ( value.empty() )
         {
            // deprecated keyword...
            key = ossimKeywordNames::IMAGE_FILE_KW;
            value.string() = kwl.findKey( key );
         }
         
         if ( value.size() )
         {
            theImageFileList.push_back(ossimFilename(value));
            ++count;
         }
         
         ossim_int32 i = 0;
         while ( (count < numberOfBands()) && (i < 1000) )
         {
            key = ossimKeywordNames::FILENAME_KW;
            key += ossimString::toString(i).string();
            value.string() = kwl.findKey( key );
            if ( value.empty() )
            {
               // Lookup for deprecated keyword.
               key = ossimKeywordNames::IMAGE_FILE_KW;
               key += ossimString::toString(i).string();
               value.string() = kwl.findKey( key );
            }
            
            if ( value.size() )
            {
               theImageFileList.push_back(ossimFilename(value));
               ++count;
            }
            ++i;
         }
         
         if (count != numberOfBands())  // Error, count should equal bands!
         {
            if (traceDebug())
            {
               ossimNotify(ossimNotifyLevel_WARN)
                  << " ERROR:\n"
                  << "Required keyword not found:  "
                  << ossimKeywordNames::FILENAME_KW
                  << "\nInterleave type is multi file; however,"
                  << " not enough were pick up!"  << std::endl;
            }
            break;
         }
      }

      key = VALID_START_LINE;
      value.string() = kwl.findKey( key ); // Default is zero.
      if ( value.size() )
      {
         theValidImageRect.set_uly( value.toInt32() );
      }

      key = VALID_STOP_LINE;
      value.string() = kwl.findKey( key ); // Default is last line.
      if ( value.size() )
      {
         theValidImageRect.set_lry( value.toInt32() );
      }
      
      if (theValidImageRect.lr().y < theValidImageRect.ul().y)
      {
         ossimNotify(ossimNotifyLevel_WARN)
            << " ERROR:"
            << "\nValid stop line < start line."
            << "\nValid start line:  " << theValidImageRect.ul().y
            << "\nValid stop line:   " << theValidImageRect.lr().y
            << "\nError status has been set.  Returning." << std::endl;
         break;
      }

      key = VALID_START_SAMPLE;
      value.string() = kwl.findKey( key ); // Default is zero.
      if ( value.size() )
      {
         theValidImageRect.set_ulx( value.toInt32() );
      }

      key = VALID_STOP_SAMPLE;
      value.string() = kwl.findKey( key ); // Default is last sample.
      if ( value.size() ) 
      {
         theValidImageRect.set_lrx( value.toInt32() );
      }
      
      if (theValidImageRect.lr().x < theValidImageRect.ul().x)
      {
         ossimNotify(ossimNotifyLevel_WARN)
            << " ERROR:"
            << "\nValid stop samp < start samp."
            << "\nValid start samp:  " << theValidImageRect.ul().x
            << "\nValid stop samp:   " << theValidImageRect.lr().x
            << "\nError status has been set.  Returning." << std::endl;
         break;
      }
      
      theImageRect.set_lry(theValidImageRect.lr().y -
                           theValidImageRect.ul().y);
      theImageRect.set_lrx(theValidImageRect.lr().x -
                           theValidImageRect.ul().x);
      
      key = SUB_IMAGE_OFFSET_LINE;
      value.string() = kwl.findKey( key ); // Default is zero.
      if ( value.size() )
      {
         theSubImageOffset.line = value.toInt32();
      }

      key = SUB_IMAGE_OFFSET_SAMP;
      value.string() = kwl.findKey( key ); // Default is zero.
      if ( value.size() )
      {
         theSubImageOffset.samp = atoi(value);
      }

      key = HEADER_SIZE;
      value.string() = kwl.findKey( key ); // Default is zero.
      if ( value.size() )
      {
         theHeaderSize = value.toInt32();
      }

      key = SET_NULLS;
      value.string() = kwl.findKey( key ); // Default is 2.
      if ( value.size() )
      {
         int tmp;
         tmp = atoi(value);
         if ((tmp < 3) && (tmp > -1))
         {
            theSetNullsMode = (ossimFillMode)tmp;
         }
         else
         {
            theSetNullsMode = ZEROES_TO_NULL_EDGES_ONLY;  // 2
            ossimNotify(ossimNotifyLevel_WARN)
               << " WARNING:"
               << "\nset_fill_to_nulls_mode value out of range."
               << "\nDefaulted to 2" << std::endl;
         }
      }

      key = PIXELS_TO_CHOP;
      value.string() = kwl.findKey( key ); // Default is zero.
      if ( value.size() )
      {
         thePixelsToChop = value.toInt32();
      }
      
      if (bytesPerPixel() > 1)
      {
         // get the byte order of the data.
         key = ossimKeywordNames::BYTE_ORDER_KW;
         value.string() = kwl.findKey( key );
         if ( value.size() )
         {
            ossimString s(value);
            if (s.trim() != "")  // Check for empty string.
            {
               s.downcase();
               if (s.contains("big"))
               {
                  theImageDataByteOrder = OSSIM_BIG_ENDIAN;
               }
               else if(s.contains("little"))
               {
                  theImageDataByteOrder = OSSIM_LITTLE_ENDIAN;
               }
            }
         }
      }

      // End of while forever loop.
      result = true;
      break;

   } // Matches: while (1)

   if ( traceDebug() )
   {
      ossimNotify(ossimNotifyLevel_DEBUG)
         << MODULE  << " Exit status: " << (result?"true":"false") << std::endl;
   }      
   
   return result;
   
} // End: bool ossimGeneralRasterInfo::loadState