bool rspfVpfAnnotationSource::loadState(const rspfKeywordlist& kwl,
                                         const char* prefix)
{
  bool result = false;
  deleteAllLibraries();
  const char* filename    = kwl.find(prefix, rspfKeywordNames::FILENAME_KW);
  if(filename)
    {
      if(openDatabase(filename))
	{
	  int idx = 0;
	  rspfString regExpression =  rspfString("^(") + rspfString(prefix) + "library[0-9]+.)";
	  vector<rspfString> keys =
	    kwl.getSubstringKeyList( regExpression );
	  std::vector<int> theNumberList(keys.size());
	  int offset = (int)(rspfString(prefix)+"library").size();

	  for(idx = 0; idx < (int)theNumberList.size();++idx)
	    {
	      rspfString numberStr(keys[idx].begin() + offset,
				    keys[idx].end());
	      theNumberList[idx] = numberStr.toInt();
	    }
	  std::sort(theNumberList.begin(), theNumberList.end());

	  for(idx=0;idx < (int)keys.size();++idx)
	    {
	      rspfString newPrefix = rspfString(prefix);
	      newPrefix += rspfString("library");
	      newPrefix += rspfString::toString(theNumberList[idx]);
	      newPrefix += rspfString(".");

	      rspfVpfAnnotationLibraryInfo* info = new rspfVpfAnnotationLibraryInfo;
	      theLibraryInfo.push_back(info);
	      info->setDatabase(&theDatabase);
	      info->loadState(kwl,
			      newPrefix);
	      info->getAllFeatures(theFeatureList);
	    }
	  transformObjects();
	  result = true;
	}
    }
  
  return result;
}
bool rspfVpfAnnotationSource::open(const rspfFilename& file)
{
   if(traceDebug())
   {
      rspfNotify(rspfNotifyLevel_DEBUG) << "rspfVpfAnnotationSource::open DEBUG: entering..." << std::endl;
   }
   bool result = false;
   
   if(file.file().downcase() == "dht")
   {
      if(openDatabase(file))
      {
         vector<rspfString> libraryNames = theDatabase.getLibraryNames();
         if(traceDebug())
         {
            rspfNotify(rspfNotifyLevel_DEBUG) << "Library names list size = " << libraryNames.size() << std::endl;
         }
         
         for(int idx = 0; idx < (int)libraryNames.size();++idx)
         {
            rspfVpfAnnotationLibraryInfo* info = new rspfVpfAnnotationLibraryInfo;
            info->setName(libraryNames[idx]);
            theLibraryInfo.push_back(info);
            info->setDatabase(&theDatabase);
            if(traceDebug())
            {
               rspfNotify(rspfNotifyLevel_DEBUG) << "loading library " << libraryNames[idx] << std::endl;
            }
            info->buildLibrary();
            info->getAllFeatures(theFeatureList);
         }
         transformObjects();
         result = true;
      }
   }
   if(traceDebug())
   {
      rspfNotify(rspfNotifyLevel_DEBUG) << "rspfVpfAnnotationSource::open DEBUG: leaving..." << std::endl;
   }
   return result;
}
Beispiel #3
0
void ossimGeoAnnotationSource::setGeometry(ossimImageGeometry* geom)
{
    m_geometry = geom;
    transformObjects(m_geometry.get());
}