Exemple #1
0
ossimRefPtr<ossimProperty> ossimNitfFileHeaderV2_1::getProperty(const ossimString& name)const
{
   ossimProperty* property = 0;
   ossimStringProperty* stringProperty = 0;
   ossimColorProperty* colorProperty = 0;

   if(name == CLEVEL_KW)
   {
      property = new ossimStringProperty(name, getComplexityLevel().trim());
   }
   else if(name == FSCLASY_KW)
   {
      property = new ossimStringProperty(name,
                                               getSecurityClassificationSys().trim());
   }
   else if(name == FSDCTP_KW)
   {
      property = new ossimStringProperty(name,
                                         getDeclassificationType().trim());
   }
   else if(name == FSDCDT_KW)
   {
      property = new ossimStringProperty(name,
                                         getDeclassificationDate().trim());
   }
   else if(name == FSDCXM_KW)
   {
      property = new ossimStringProperty(name,
                                         getDeclassificationExemption().trim());
   }
   else if(name == FSDG_KW)
   {
      stringProperty = new ossimStringProperty(name,
                                               getDowngrade().trim(),
                                               false);
      
      stringProperty->addConstraint("");
      stringProperty->addConstraint("S");
      stringProperty->addConstraint("C");
      stringProperty->addConstraint("R");

      property = stringProperty;
   }
   else if(name == FSDGDT_KW)
   {
      property = new ossimStringProperty(name,
                                         getDowngradingDate().trim());
   }
   else if(name == FSCLTX_KW)
   {
      property = new ossimStringProperty(name,
                                         getClassificationText().trim());
   }
   else if(name == FSCATP_KW)
   {
      stringProperty = new ossimStringProperty(name,
                                               getClassificationAuthorityType().trim(),
                                               false);
      
      stringProperty->addConstraint("");
      stringProperty->addConstraint("O");
      stringProperty->addConstraint("D");
      stringProperty->addConstraint("M");
      
      property = stringProperty;
   }
   else if(name == FSCRSN_KW)
   {
      stringProperty = new ossimStringProperty(name,
                                               getClassificationReason().trim(),
                                               false);
      
      stringProperty->addConstraint("");
      stringProperty->addConstraint("A");
      stringProperty->addConstraint("B");
      stringProperty->addConstraint("C");
      stringProperty->addConstraint("D");
      stringProperty->addConstraint("E");
      stringProperty->addConstraint("F");
      stringProperty->addConstraint("G");
      
      property = stringProperty;
   }
   else if(name == FSSRDT_KW)
   {
      property = new ossimStringProperty(name,
                                         getSecuritySourceDate().trim());
   }
   else if(name == FBKGC_KW)
   {
      ossim_uint8 r, g, b;
      getBackgroundColor(r, g, b);
      
      colorProperty = new ossimColorProperty(name,
                                             ossimRgbVector(r, g, b));

      property = colorProperty;
   }
   else if(name == ONAME_KW)
   {
      property = new ossimStringProperty(name, ossimString(theOriginatorsName).trim());
   }
   else if(name == OPHONE_KW)
   {
      property = new ossimStringProperty(name, ossimString(theOriginatorsPhone).trim());
   }
   else
   {
      return ossimNitfFileHeaderV2_X::getProperty(name);
   }
   return property;
}
bool ossimIndexToRgbLutFilter::initializeLut(const ossimKeywordlist* kwl, const char* prefix)
{
   theLut.clear();

   const ossimString entry_kw ("entry");
   ossimString keyword, base_keyword;
   ossimString indexStr, rgbStr;
   ossimString blank(" ");
   std::vector<ossimString> rgbList;
   double index;
   ossimRgbVector rgbVector (0,0,0);
   bool rtn_state = true;

   ossim_uint32 numEntries=0;
   while (true)
   {
      base_keyword = entry_kw + ossimString::toString(numEntries);
      if ((theMode == LITERAL) || (theMode == VERTICES))
      {
         // Index and color are subentries for this mode:
         keyword = base_keyword + ".index";
         indexStr = kwl->find(prefix, keyword.chars());
         if (indexStr.empty())
            break;

         index = indexStr.toDouble();
         keyword = base_keyword + ".color";
         rgbStr = kwl->find(prefix, keyword.chars());
      }
      else
      {
         // REGULAR mode: index is computed later to arrive at equally-spaced vertices. For now,
         // just store entry number as index:
         index = (double) numEntries;
         keyword = base_keyword;
         rgbStr = kwl->find(prefix, keyword.chars());
         if (rgbStr.empty())
         {
            // Perhaps old bloated form with separate keywords for R, G, B
            rgbStr = kwl->find(prefix, (keyword + ".r").chars());
            rgbStr += " ";
            rgbStr += kwl->find(prefix, (keyword + ".g").chars());
            rgbStr += " ";
            rgbStr += kwl->find(prefix, (keyword + ".b").chars());
            if (rgbStr.length() < 5)
               break;
         }
      }

      rgbStr.split(rgbList, blank, true);
      if (rgbList.size() != 3)
      {
         ossimNotify(ossimNotifyLevel_WARN)<<"ossimIndexToRgbLutFilter::initializeLut() -- "
               "Bad color specification in LUT KWL. LUT is not properly initialized."<<endl;
         return false;
      }

      rgbVector.setR(rgbList[0].toUInt8());
      rgbVector.setG(rgbList[1].toUInt8());
      rgbVector.setB(rgbList[2].toUInt8());
      theLut.insert(std::pair<double, ossimRgbVector>(index, rgbVector));
      rgbList.clear();
      ++numEntries;
   }

   // For REGULAR mode, need to adjust the indices to reflect a piecewise linear LUT with equally
   // spaced vertices:
   if (theMode == REGULAR)
   {
      std::map<double, ossimRgbVector> orig_lut = theLut;
      std::map<double, ossimRgbVector>::iterator iter =  orig_lut.begin();
      theLut.clear();

      if (numEntries == 1)
      {
         // Insert the implied start index at black and endpoint at specified color:
         theLut.insert(std::pair<double, ossimRgbVector>(theMinValue, ossimRgbVector (1, 1, 1)));
         theLut.insert(std::pair<double, ossimRgbVector>(theMaxValue, iter->second));
      }
      else
      {
         // Loop to create equally-spaced vertices between min and max index values:
         double interval = (theMaxValue - theMinValue) / (numEntries - 1);
         while (iter != orig_lut.end())
         {
            index = theMinValue + iter->first*interval;
            theLut.insert(std::pair<double, ossimRgbVector>(index, iter->second));
            ++iter;
         }
      }
   }

   return rtn_state;
}