Exemplo n.º 1
0
//*****************************************************************************
//  METHOD: ossimSensorModelFactory::create(kwl, prefix)
//*****************************************************************************
ossimProjection* ossimSensorModelFactory::createProjection(const ossimKeywordlist &keywordList,
                                                           const char *prefix) const
{
   ossimRefPtr<ossimProjection> result;

   //
   // Permit specification of geometry file name in lieu of type:
   //
   const char*  value = keywordList.find(prefix, ossimKeywordNames::GEOM_FILE_KW);
   if (value)
   {
      result = createProjection(ossimFilename(value), 0);
   }
   //
   // Search for occurence of "type" keyword:
   //
   else
   {
      value = keywordList.find(prefix, ossimKeywordNames::TYPE_KW);
      if(value)
      {
         result = createProjection(ossimString(value));
         if(result.valid())
         {
            if(!result->loadState(keywordList, prefix))
            {
               result = 0;
            }
        }
      }
   }
   
   return result.release();
}
//*************************************************************************************************
//! From keywordlist
//*************************************************************************************************
ossimProjection* ossimEpsgProjectionFactory::createProjection(const ossimKeywordlist &keywordList,
                                                             const char *prefix) const
{
    ossimProjection* proj = 0;

   // Look for a PCS (Projected Coordinate System) code entry and construct the basic projection.
   // This is the bootstrap for creating the fully-initialized proj:
   ossimString proj_spec = keywordList.find(prefix, ossimKeywordNames::PCS_CODE_KW);
   if(!proj_spec.empty())
      proj = createProjection(proj_spec);
  
   if (!proj)
   {
      // An alternate way of specifying an EPSG projection is by its database name:
      proj_spec = keywordList.find(prefix, ossimKeywordNames::PROJECTION_KW);
      proj = createProjection(proj_spec);
   }

   if (!proj)
      return NULL;

   // The tie points and perhaps other params might still be in the KWL, so pass the KWL on to the
   // new projection after it has been amended with the default proj info extracted from the 
   // EPSG code (i.e., sans tiepoints and gsd):
   ossimKeywordlist proj_kwl;
   proj->saveState(proj_kwl, prefix);
   proj_kwl.remove(prefix, ossimKeywordNames::PIXEL_SCALE_XY_KW);
   proj_kwl.remove(prefix, ossimKeywordNames::PIXEL_SCALE_UNITS_KW);
   proj_kwl.remove(prefix, ossimKeywordNames::TIE_POINT_XY_KW);
   proj_kwl.remove(prefix, ossimKeywordNames::TIE_POINT_UNITS_KW);
   proj_kwl.addList(keywordList, false); // false: do not override existing items
   proj->loadState(proj_kwl, prefix);
   
   return proj;
}
rspfProjection* rspfEpsgProjectionFactory::createProjection(const rspfKeywordlist &keywordList,
                                                             const char *prefix) const
{
    rspfProjection* proj = 0;
   rspfString proj_spec = keywordList.find(prefix, rspfKeywordNames::PCS_CODE_KW);
   if(!proj_spec.empty())
      proj = createProjection(proj_spec);
  
   if (!proj)
   {
      proj_spec = keywordList.find(prefix, rspfKeywordNames::PROJECTION_KW);
      proj = createProjection(proj_spec);
   }
   if (!proj)
      return NULL;
   rspfKeywordlist proj_kwl;
   proj->saveState(proj_kwl, prefix);
   proj_kwl.remove(prefix, rspfKeywordNames::PIXEL_SCALE_XY_KW);
   proj_kwl.remove(prefix, rspfKeywordNames::PIXEL_SCALE_UNITS_KW);
   proj_kwl.remove(prefix, rspfKeywordNames::TIE_POINT_XY_KW);
   proj_kwl.remove(prefix, rspfKeywordNames::TIE_POINT_UNITS_KW);
   proj_kwl.addList(keywordList, false); // false: do not override existing items
   proj->loadState(proj_kwl, prefix);
   
   return proj;
}
rspfProjection* rspfMapProjectionFactory::createProjection(const rspfKeywordlist &keywordList,
															 const char *prefix) const
{
   rspfProjection *result=NULL;
	
   const char *lookup = keywordList.find(prefix, rspfKeywordNames::TYPE_KW);
   const char *lookupSpaceImaging = keywordList.find(prefix, rspfSpaceImagingGeom::SIG_PRODUCER_KW);
   if(lookup)
   {
      result = createProjection(rspfString(lookup).trim());
      if(result)
      {
         result->loadState(keywordList, prefix);
      }
   }
   else
   {
      if(lookupSpaceImaging)
      {
		  rspfKeywordlist kwl;
		  rspfKeywordlist kwl2;
		  kwl.add(keywordList,
				  prefix,
				  true);
         
         rspfSpaceImagingGeom spaceImaging;
         
         spaceImaging.setGeometry(kwl);
         spaceImaging.exportToOssim(kwl2);
         result = rspfProjectionFactoryRegistry::instance()->createProjection(kwl2);
         if(result)
         {
            return result;
         }
      }
      lookup = keywordList.find(prefix, rspfKeywordNames::GEOM_FILE_KW);
      if(lookup)
      {
         rspfKeywordlist kwl;
         kwl.addFile(lookup);
         result = createProjection(kwl);
         
         if(!result)
         {
            result = createProjection(kwl, "projection.");
         }
      }      
   }
   return result;
}
rspfProjection*
rspfMapProjectionFactory::createProjection(const rspfFilename& filename,
                                            rspf_uint32 entryIdx)const
{
   if(!filename.exists())
   {
      return NULL;
   }
   rspfProjection* proj = createProjectionFromGeometryFile(filename,
                                                            entryIdx);
   if (proj)
   {
      return proj;
   }
   rspfFilename geomFile = filename;
   geomFile = geomFile.setExtension("geom");
   if(!geomFile.exists())
   {
      return NULL;
   }
   rspfKeywordlist kwl;
   if(kwl.addFile(geomFile))
   {
      return createProjection(kwl);
   }
   return NULL;
}
Exemplo n.º 6
0
    virtual bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa )
    {
        bool handled = false;

        switch( ea.getEventType() )
        {
        case osgGA::GUIEventAdapter::RESIZE:
        {
            unsigned int width = ( unsigned int )ea.getWindowWidth();
            unsigned int height = ( unsigned int )ea.getWindowHeight();

            const double aspect = (double) width / (double) height;
            _viewer.getCamera()->setProjectionMatrix( createProjection( aspect ) );
            _viewer.getCamera()->getViewport()->setViewport( 0, 0, width, height );

            if( ( width > _maxWidth ) || ( height > _maxHeight ) )
            {
                _maxWidth = osg::maximum< unsigned int >( width, _maxWidth );
                _maxHeight = osg::maximum< unsigned int >( height, _maxHeight );
                backdropFX::Manager::instance()->setTextureWidthHeight( _maxWidth, _maxHeight );
            }
        }
        }
        return( handled );
    }
ossimProjection* ossimGdalProjectionFactory::createProjection(const ossimKeywordlist &keywordList,
                                                             const char *prefix) const
{
   const char *lookup = keywordList.find(prefix, ossimKeywordNames::TYPE_KW);
   if(lookup&&(!ossimString(lookup).empty()))
   {
      ossimProjection* proj = createProjection(ossimString(lookup));
      if(proj)
      {
         // make sure we restore any passed in tie points and meters per pixel information
         ossimKeywordlist tempKwl;
         ossimKeywordlist tempKwl2;
         proj->saveState(tempKwl);
         tempKwl2.add(keywordList, prefix, true);
         tempKwl.add(prefix, tempKwl2,  true);
         tempKwl.add(prefix, ossimKeywordNames::TYPE_KW, proj->getClassName(), true);
	 proj->loadState(tempKwl);
         if(traceDebug())
         {
            tempKwl.clear();
            proj->saveState(tempKwl);
            if(traceDebug())
            {
               ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimGdalProjectionFactory::createProjection Debug: resulting projection \n " << tempKwl << std::endl;
            }
         }

         return proj;
      }
   }
   return 0;
}
Exemplo n.º 8
0
void
viewerSetUp( osgViewer::Viewer& viewer, unsigned int width, unsigned int height, osg::Node* node )
{
    double aspect = (double)width / (double)height;

    viewer.setThreadingModel( osgViewer::ViewerBase::SingleThreaded );
    viewer.getCamera()->setComputeNearFarMode( osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR );
    viewer.getCamera()->setProjectionMatrix( createProjection( aspect ) );

    viewer.getCamera()->setClearMask( 0 );

    viewer.setSceneData( backdropFX::Manager::instance()->getManagedRoot() );

    // No longer needed, apparently. Seems like Viewer used to focus the
    // camera manipulator on the entire SkyDome, putting it too far away from
    // the scene. This code compensated for that.
    //osgGA::TrackballManipulator* tb = new osgGA::TrackballManipulator();
    //viewer.setCameraManipulator( tb );
    //tb->setNode( root.get() );
    //tb->home( 0 );

    viewer.addEventHandler( new osgViewer::StatsHandler );
    viewer.addEventHandler( new osgViewer::ThreadingHandler );
    viewer.addEventHandler( new ResizeHandler( viewer, width, height ) );

    osgGA::TrackballManipulator* tbm = new osgGA::TrackballManipulator;
    viewer.setCameraManipulator( tbm );
    tbm->setNode( node );
    tbm->home( 0 );
}
vector<unique_ptr<qopt::Projection>> ProjectionGenerator::createProjections(vector<pair<string, unique_ptr<harriet::Expression>>>& expressions) const
{
   vector<unique_ptr<qopt::Projection>> result;
   result.reserve(expressions.size());
   for(auto& expression : expressions)
      result.push_back(createProjection(move(expression)));
   return result;
}
Exemplo n.º 10
0
//*************************************************************************************************
// This is the principal factory method. It accepts a WKT string, e.g.
//
//    "Anguilla_1957_British_West_Indies_Grid",
//
//  or complete WKT, e.g.
//
//    PROJCS["Anguilla_1957_British_West_Indies_Grid", GEOGCS[...
//
// IMPORTANT NOTE: Image tie-points cannot be conveyed by a WKT projection string. The projection
// created here will not be fully initialized for use in rendering imagery.
//*************************************************************************************************
ossimProjection* ossimWktProjectionFactory::createProjection(const ossimString &spec) const
{
   ossimProjection* proj = 0;
   ossimWkt wkt;
   if (wkt.parse(spec))
   {
      proj = createProjection(wkt.getKwl());
   }
   return proj;
}
Exemplo n.º 11
0
ossimProjection* ossimNitfProjectionFactory::createProjection(ossimImageHandler* handler)const
{
   ossimNitfTileSource* nitfTileSource = dynamic_cast<ossimNitfTileSource*> (handler);
   ossimProjection* result = 0;
   if(nitfTileSource)
   {
      if(!result)
      {
         ossimNitfImageHeader* imageHeader = nitfTileSource->getCurrentImageHeader();
         if(imageHeader)
         {
            result = createProjectionFromHeaders(nitfTileSource->getFileHeader(),imageHeader);
         }
      }
   }
   else if(isNitf(handler->getFilename()))
   {
      result =  createProjection(handler->getFilename(), handler->getCurrentEntry());
   }
   return result;
}
Exemplo n.º 12
0
void
viewerSetUp( osgViewer::Viewer& viewer, unsigned int width, unsigned int height, osg::Node* node )
{
    double aspect = (double)width / (double)height;

    viewer.setThreadingModel( osgViewer::ViewerBase::SingleThreaded );
    viewer.getCamera()->setComputeNearFarMode( osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR );
    viewer.getCamera()->setProjectionMatrix( createProjection( aspect ) );

    viewer.getCamera()->setClearMask( 0 );

    viewer.setSceneData( backdropFX::Manager::instance()->getManagedRoot() );

    viewer.addEventHandler( new osgViewer::StatsHandler );
    viewer.addEventHandler( new osgViewer::ThreadingHandler );
    viewer.addEventHandler( new ResizeHandler( viewer, width, height ) );

    osgGA::TrackballManipulator* tbm = new osgGA::TrackballManipulator;
    viewer.setCameraManipulator( tbm );
    tbm->setNode( node );
    tbm->home( 0 );
}
Exemplo n.º 13
0
//Angepasste Version der virtuellen Funktion der Basisklasse VRCWBase
//Bearbeitung und Ueberpruefung der Eingaben im GUI
//
int VRCWProjectionDimPowerwall::processGuiInput(const int& index,
        const QList<VRCWBase*>& vrcwList)
{
    const int WARN_01 = 1;
    const int WARN_02 = 2;
    const int ERROR_01 = 301;
    const int ERROR_02 = 302;
    const int OK = 3;//same as in VRCWProjectionDimCave

    int success = DEF_ERROR;
    int awarning = DEF_WARN;

    //
    //doing some checks
    //

    //set variables
    QList<wallVal*> wallDims = getGuiPWallDim();
    int screenWidth = wallDims[0]->screenSize[0];
    int screenHeight = wallDims[0]->screenSize[1];
    int wallWidth = wallDims[0]->wallSize[0];
    int wallHeight = wallDims[0]->wallSize[1];

    if (screenWidth == 0 || screenHeight == 0)
    {
        awarning = WARN_01;
        success = DEF_ERROR;
    }
    else if (tiledData & (wallWidth == 0 || wallHeight == 0))
    {
        awarning = WARN_02;
        success = DEF_ERROR;
    }
    else
    {
        success = OK;
    }

    //
    //show warnings
    //
    switch (awarning)
    {
    case WARN_01:
    {
        QString message = tr("The screen size (width, height) is not set.\n\n"
                             "Please set the screen size properly.");
        QMessageBox::warning(this, tr("Configuration"), message,
                             QMessageBox::Ok);

        success = ERROR_01;
        break;
    }
    case WARN_02:
    {
        QString message = tr("The dimension of the whole wall "
                             "(width, height) is not set.\n\n"
                             "Please set the dimension of the whole wall properly.");
        QMessageBox::warning(this, tr("Configuration"), message,
                             QMessageBox::Ok);

        success = ERROR_02;
        break;
    }
    default:
    {
        qDebug() << "No warning appeared or warningCode can't be evaluated";
        break;
    }
    }


    //sobald keine Fehler in der Eingabe sind:
    //- wird die projection-Liste an VRCWHost und VRCWHostProjection uebergeben
    //- wird res, size, vPos, floor, typeProj, wallSize, overlap und frame
    //  an VRCWFinal uebergeben
    //
    if (success == OK)
    {
        int trackDimIndex = vrcwList.size() - 3;
        int finalIndex = vrcwList.size() - 2;

        VRCWHost* host = dynamic_cast<VRCWHost*> (vrcwList[index + 1]);
        VRCWHostProjection* hostProjection =
            dynamic_cast<VRCWHostProjection*> (vrcwList[index + 2]);
        VRCWTrackingDim* trackingDim =
            dynamic_cast<VRCWTrackingDim*> (vrcwList[trackDimIndex]);
        VRCWFinal* final = dynamic_cast<VRCWFinal*> (vrcwList[finalIndex]);

        QStringList projection = createProjection();
        host->setCalcNumHosts(projection);
        hostProjection->setGuiProjectionData(projection);

        QVector<int> vPos = projectionVposFloor->getGuiVPos();
        int floor = projectionVposFloor->getGuiFloor();

        trackingDim->setCHeadOffset(vPos);

        //pWallDim is set in createProjecton()
        final->setProjectDimPowerwall(vPos, floor, pWallDim);
Exemplo n.º 14
0
ossimObject*
ossimNitfProjectionFactory::createObject(const ossimKeywordlist& kwl,
                                         const char* prefix)const
{
   return createProjection(kwl, prefix);
}
Exemplo n.º 15
0
ossimObject*
ossimNitfProjectionFactory::createObject(const ossimString& typeName)const
{
   return (ossimObject*)createProjection(typeName);
}
rspfObject* rspfMapProjectionFactory::createObject(const rspfString& typeName)const
{
   return createProjection(typeName);
}
//*************************************************************************************************
ossimObject* ossimEpsgProjectionFactory::createObject(const ossimString& typeName)const
{
   return createProjection(typeName);
}
Exemplo n.º 18
0
//Angepasste Version der virtuellen Funktion der Basisklasse VRCWBase
//Bearbeitung und Ueberpruefung der Eingaben im GUI
//
int VRCWProjectionDimCave::processGuiInput(const int& index,
      const QList<VRCWBase*>& vrcwList)
{
   const int WARN_01 = 1;
   const int ERROR_01 = 301;
   const int OK = 3;//same as in VRCWProjectionDimPowerwall

   int success = DEF_ERROR;
   int awarning = DEF_WARN;

   //
   //doing some checks
   //

   //set variables
   int caveWidth = caveDim[0];
   int caveDepth = caveDim[1];
   int caveHeight = caveDim[2];

   if (caveWidth == 0 || caveDepth == 0 || caveHeight == 0)
   {
      awarning = WARN_01;
      success = DEF_ERROR;
   }
   else
   {
      success = OK;
   }

   //
   //show warnings
   //
   switch (awarning)
   {
      case WARN_01:
      {
         QString message = tr("Some of the CAVE dimensions "
               "(width, depth, height) are not set.\n\n"
               "Please set the CAVE dimensions and check on every "
               "configured wall that the specified screen size or "
               "the dimension of the whole wall are set properly.");
         QMessageBox::warning(this, tr("Configuration"), message,
               QMessageBox::Ok);

         success = ERROR_01;
         break;
      }
      default:
      {
         qDebug() << "No warning appeared or warningCode can't be evaluated";
         break;
      }
   }


   //sobald keine Fehler in der Eingabe sind:
   //- wird die projection-Liste an VRCWHost und VRCWHostProjection uebergeben
   //- wird vPos, floor, caveDim und caveWallDim an VRCWFinal uebergeben
   //
   if (success == OK)
   {
      int trackDimIndex = vrcwList.size() - 3;
      int finalIndex = vrcwList.size() - 2;

      VRCWHost* host = dynamic_cast<VRCWHost*> (vrcwList[index + 1]);
      VRCWHostProjection* hostProjection =
            dynamic_cast<VRCWHostProjection*> (vrcwList[index + 2]);
      VRCWTrackingDim* trackingDim =
                  dynamic_cast<VRCWTrackingDim*> (vrcwList[trackDimIndex]);
      VRCWFinal* final = dynamic_cast<VRCWFinal*> (vrcwList[finalIndex]);

      //get all values
      //
      QStringList projection = createProjection();
      host->setCalcNumHosts(projection);
      hostProjection->setGuiProjectionData(projection);

      zPoint zeroP = getGuiZeroPoint();
      QVector<int> vPos = generalPos->getGuiVPos();
      int floor = generalPos->getGuiFloor();
      caveDim = getGuiCaveDim();

      trackingDim->setCHeadOffset(vPos);

      //caveWallDim is set in createProjecton()
      final->setProjectDimCave(zeroP, vPos, floor, caveDim, caveWallDim);
rspfObject* rspfMapProjectionFactory::createObject(const rspfKeywordlist& kwl,
                                                     const char* prefix)const
{
   return createProjection(kwl, prefix);
}
Exemplo n.º 20
0
ossimProjection* ossimSensorModelFactory::createProjection(
   const ossimFilename& filename, ossim_uint32  entryIdx) const
{
   if(!filename.exists()) return 0;
   static const char MODULE[] = "ossimSensorModelFactory::createProjection";
   
   ossimKeywordlist kwl;
   ossimRefPtr<ossimProjection> model = 0;

   ossimFilename geomFile = filename;
   geomFile = geomFile.setExtension("geom");
   
   if(geomFile.exists()&&
      kwl.addFile(filename.c_str()))
   {
      ossimFilename coarseGrid;
      
      const char* type = kwl.find(ossimKeywordNames::TYPE_KW);
      if(type)
      {
         if(ossimString(type) ==
            ossimString(STATIC_TYPE_NAME(ossimCoarseGridModel)))
         {
            findCoarseGrid(coarseGrid, filename);
            
            if(coarseGrid.exists() &&(coarseGrid != ""))
            {
               kwl.add("grid_file_name",
                       coarseGrid.c_str(),
                       true);
               model = new ossimCoarseGridModel(kwl);
               if(!model->getErrorStatus())
               {
                  return model.release();
               }
               model = 0;
            }
         }
      }
      kwl.clear();
   }

   // See if there is an external geomtry.
   ossimRefPtr<ossimProjection> proj =
      createProjectionFromGeometryFile(filename, entryIdx);
   if (proj.valid())
   {
      return proj.release();
   }

   if(model.valid())
   {
      model = 0;
   }
   
   // first check for override
   //
   if(geomFile.exists()&&kwl.addFile(geomFile.c_str()))
   {
      model =  createProjection(kwl);
      if(model.valid())
      {
         return model.release();
      }
      model = 0;
   }

   if(traceDebug())
   {
      ossimNotify(ossimNotifyLevel_DEBUG)
         << MODULE << " DEBUG: Testing ossimCoarsGridModel" << std::endl;
   }
   
   ifstream input(geomFile.c_str());
   char ecgTest[4];
   input.read((char*)ecgTest, 3);
   ecgTest[3] = '\0';
   input.close();
   if(ossimString(ecgTest) == "eCG")
   {
      ossimKeywordlist kwlTemp;
      kwlTemp.add("type",
                  "ossimCoarseGridModel",
                  true);
      kwlTemp.add("geom_file",
                  geomFile.c_str(),
                  true);
      return createProjection(kwlTemp);
   }
   
   if(traceDebug())
   {
      ossimNotify(ossimNotifyLevel_DEBUG)
         << MODULE << " DEBUG: testing ossimRpcModel" << std::endl;
   }

   //---
   // Test for quick bird rpc.  Could be either a tiff or nitf so not wrapped
   // around "isNitf()" anymore.
   //---
   if(traceDebug())
   {
      ossimNotify(ossimNotifyLevel_DEBUG)
         << MODULE << " DEBUG: testing ossimQuickbirdRpcModel"
         << std::endl;
   }
   
   ossimRefPtr<ossimQuickbirdRpcModel> qbModel = new ossimQuickbirdRpcModel;
   if(qbModel->parseFile(filename))
   {
      if(traceDebug())
      {
         ossimNotify(ossimNotifyLevel_DEBUG)
            << MODULE << " DEBUG: returning ossimQuickbirdRpcModel"
            << std::endl;
      }
      model = qbModel.get();
      qbModel = 0;
      return model.release();
   }
   else
   {
      qbModel = 0;
   }
   
   //---
   // Test for ikonos rpc.  Could be tiff or nitf which is handled in
   // parseFile method.
   //---
   ossimRefPtr<ossimIkonosRpcModel> ikModel = new ossimIkonosRpcModel;
   if(ikModel->parseFile(filename))
   {
      if(traceDebug())
      {
         ossimNotify(ossimNotifyLevel_DEBUG)
            << MODULE << " DEBUG returning ossimQuickbirdRpcModel"
            << std::endl;
      }
      model = ikModel.get();
      ikModel = 0;
      return model.release();
   }
   else
   {
      ikModel = 0;
   }

   if(isNitf(filename))
   {
     if(traceDebug())
     {
        ossimNotify(ossimNotifyLevel_DEBUG)
           << MODULE << " DEBUG: testing ossimNitfRpcModel" << std::endl;
     }

     ossimRefPtr<ossimNitfRpcModel> rpcModel = new ossimNitfRpcModel();
     if ( rpcModel->parseFile(filename, entryIdx) ) // filename = NITF_file
     {
        model = rpcModel.get();
        rpcModel = 0;
        return model.release();
     }
     else
     {
        rpcModel = 0;
     }
     
     if(traceDebug())
     {
        ossimNotify(ossimNotifyLevel_DEBUG)
           << MODULE << " DEBUG: testing ossimIkinosRpcModel" << std::endl;
     }
     
     model = new ossimNitfMapModel(filename); // filename = NITF_file
     if(!model->getErrorStatus())
     {
        return model.release();
     }
     model = 0;
   }
   else if(isLandsat(filename))
   {
      model = new ossimLandSatModel(filename);
      if(!model->getErrorStatus())
      {
         return model.release();
      }
      model = 0;
   }
   
   model = new ossimRS1SarModel(filename);
   if(model->getErrorStatus()!= ossimErrorCodes::OSSIM_OK)
   {
      return model.release();
   }
   model = 0;

   // SPOT:
   ossimFilename spot5Test = geomFile;
   if(!spot5Test.exists())
   {
      spot5Test = geomFile.path();
      spot5Test = spot5Test.dirCat(ossimFilename("METADATA.DIM"));
      if (spot5Test.exists() == false)
      {
         spot5Test = geomFile.path();
         spot5Test = spot5Test.dirCat(ossimFilename("metadata.dim"));
      }
   }
   if(spot5Test.exists())
   {
      //---
      // Check the basename of the input file. So we don't create a projection
      // for ancillary files, icon.jpg amd preview.jpg.
      //---
      ossimFilename baseName = filename.file();
      baseName.downcase();

      if ( (baseName != "icon.jpg" ) && ( baseName != "preview.jpg" ) )
      {
         ossimRefPtr<ossimSpotDimapSupportData> meta =
            new ossimSpotDimapSupportData;
         if(meta->loadXmlFile(spot5Test))
         {
            model = new ossimSpot5Model(meta.get());
            if(!model->getErrorStatus())
            {
               return model.release();
            }
         }
      }
   }
   model = 0;
            
   ossimFilename ppjFilename = filename;
   ppjFilename = ppjFilename.setExtension("ppj");
   if(traceDebug())
   {
      ossimNotify(ossimNotifyLevel_DEBUG)
         << MODULE << " DEBUG: testing ossimPpjFrameSensor" << std::endl;
   }
   if(ppjFilename.exists())
   {
      ossimRefPtr<ossimPpjFrameSensorFile> ppjFile = new ossimPpjFrameSensorFile();

      if(ppjFile->readFile(ppjFilename))
      {
         ossimRefPtr<ossimPpjFrameSensor> sensor = new ossimPpjFrameSensor();
         ossimDpt imageSize = ppjFile->getImageSize();
         sensor->setFocalLength(ppjFile->getIntrinsic()[0][0], ppjFile->getIntrinsic()[1][1]);
         sensor->setPrincipalPoint(ppjFile->getPrincipalPoint());
         sensor->setecef2CamMatrix(ppjFile->getExtrinsic().SymSubMatrix(1,3));
         sensor->setCameraPosition(ppjFile->getPlatformPosition());
         sensor->setImageSize(imageSize);
         sensor->setImageRect(ossimDrect(0,0,imageSize.x-1, imageSize.y-1));
         sensor->setRefImgPt(ossimDpt(imageSize.x*.5, imageSize.y*.5));
         sensor->setAveragePrjectedHeight(ppjFile->getAverageProjectedHeight());
         sensor->updateModel();
         return sensor.release();         
      }
      ppjFile = 0;
   }
   
   ossimFilename hdrFilename = filename;
   hdrFilename = hdrFilename.setExtension("hdr"); // image.hdr
   if ( !hdrFilename.exists() )   
   {     
      hdrFilename = filename;
      hdrFilename.string() += ".hdr"; // image.ras.hdr
   }
   if(traceDebug())
   {
      ossimNotify(ossimNotifyLevel_DEBUG)
         << MODULE << " DEBUG: testing ossimAlphaSensor\nheader file: " << hdrFilename << std::endl;
   }
   if(hdrFilename.exists())
   {
      ossimRefPtr<ossimAlphaSensorSupportData> supData = new ossimAlphaSensorSupportData();
      if(supData->readSupportFiles(hdrFilename))
      {
         if (supData->isHSI())
         {
            if(traceDebug())
            {
               ossimNotify(ossimNotifyLevel_DEBUG)
                  << MODULE << " DEBUG: loading ossimAlphaSensorHSI" << std::endl;
            }
            ossimRefPtr<ossimAlphaSensorHSI> sensor = new ossimAlphaSensorHSI();
            if ( sensor->initialize( *(supData.get()) ) )
            {
               return (ossimProjection*)sensor.release();
            }
         }
         else
         {
            if(traceDebug())
            {
               ossimNotify(ossimNotifyLevel_DEBUG)
                  << MODULE << " DEBUG: loading ossimAlphaSensorHRI" << std::endl;
            }
            ossimRefPtr<ossimAlphaSensorHRI> sensor = new ossimAlphaSensorHRI();
            if ( sensor->initialize( *(supData.get()) ) )
            {
               return (ossimProjection*)sensor.release();
            }
         }
      }
      supData = 0;
   }

   model = new ossimCoarseGridModel(geomFile);
   if(model.valid())
   {
      if(!model->getErrorStatus())
      {
         return model.release();
      }
      model = 0;
   }

   return model.release();
}
Exemplo n.º 21
0
//*****************************************************************************
//  METHOD
//*****************************************************************************
ossimObject*
ossimSensorModelFactory::createObject(const ossimString& typeName)const
{
   return createProjection(typeName);
}
Exemplo n.º 22
0
//--------------------------------------------------------------
// render the planet
void Planet::render(
  int graphicsWidth,
  int graphicsHeight,
  double angle)
{
  // if shader didn't compile, nothing we can do
  if (m_planetShader == 0)
    return;

  double atmos = 20.0;
  double radius = 1200.0;

  double eyeDist = m_eyePt.length()/radius;
  double a = 1.0;
  if (eyeDist < a)
    return;  // below surface, nothing to do 
  double b = sqrt(eyeDist*eyeDist - a*a);
  double h = (a*b)/eyeDist;
  double m = (a*a)/eyeDist;

  h += atmos/radius;

  // x axis from planet center towards eye
  mgPoint3 xaxis(m_eyePt);
  xaxis.normalize();

  // build y axis
  mgPoint3 yaxis(xaxis);
  yaxis.cross(mgPoint3(0.0, 1.0, 0.0));
  yaxis.normalize();

  mgPoint3 zaxis(yaxis);
  zaxis.cross(xaxis);
  zaxis.normalize();

  mgMatrix4 transform;
  transform._11 = xaxis.x;
  transform._12 = xaxis.y;
  transform._13 = xaxis.z;
  transform._21 = yaxis.x;
  transform._22 = yaxis.y;
  transform._23 = yaxis.z;
  transform._31 = zaxis.x;
  transform._32 = zaxis.y;
  transform._33 = zaxis.z;
  
  VertexPlanet tl, tr, bl, br;

  mgPoint3 pt;
  transform.mapPt(m, -h, h, pt.x, pt.y, pt.z);
  tl.setPoint(radius*pt.x, radius*pt.y, radius*pt.z);

  transform.mapPt(m, h, h, pt.x, pt.y, pt.z);
  tr.setPoint(radius*pt.x, radius*pt.y, radius*pt.z);

  transform.mapPt(m, -h, -h, pt.x, pt.y, pt.z);
  bl.setPoint(radius*pt.x, radius*pt.y, radius*pt.z);

  transform.mapPt(m, h, -h, pt.x, pt.y, pt.z);
  br.setPoint(radius*pt.x, radius*pt.y, radius*pt.z);

  // inverse of world transform
  mgMatrix4 model;
  model.rotateYDeg(-angle);

  mgPoint3 lightDir(1.0, 0.25, 0.0);
  lightDir.normalize();

  mgPoint3 modelLightDir;
  model.mapPt(lightDir, modelLightDir);
  transform.multiply(model);

  mgPoint3 modelEye; 
  transform.mapPt(eyeDist, 0.0, 0.0, modelEye.x, modelEye.y, modelEye.z);

  transform.mapPt(m, -h, h, pt.x, pt.y, pt.z);
  tl.setModelPoint(pt.x, pt.y, pt.z);

  transform.mapPt(m, h, h, pt.x, pt.y, pt.z);
  tr.setModelPoint(pt.x, pt.y, pt.z);

  transform.mapPt(m, -h, -h, pt.x, pt.y, pt.z);
  bl.setModelPoint(pt.x, pt.y, pt.z);

  transform.mapPt(m, h, -h, pt.x, pt.y, pt.z);
  br.setModelPoint(pt.x, pt.y, pt.z);

  mgMatrix4 viewMatrix;
  viewMatrix.translate(-m_eyePt.x, -m_eyePt.y, -m_eyePt.z);
  viewMatrix.multiply(m_eyeMatrix);

  mgMatrix4 worldProjection;
  createProjection(worldProjection, graphicsWidth, graphicsHeight);

  mgMatrix4 mvpMatrix(viewMatrix);
  mvpMatrix.multiply(worldProjection);

  setupShader(mvpMatrix, modelEye, modelLightDir);

  glActiveTexture(GL_TEXTURE0);
  glBindTexture(GL_TEXTURE_CUBE_MAP, m_surfaceTexture); 
  glActiveTexture(GL_TEXTURE1);
  glBindTexture(GL_TEXTURE_CUBE_MAP, m_cloudsTexture); 

  glBindVertexArray(m_vertexArray);
  glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer);

  VertexPlanet data[6];
  data[0] = tl;
  data[1] = tr;
  data[2] = bl;
  data[3] = bl;
  data[4] = tr;
  data[5] = br;
  int vertexSize = sizeof(VertexPlanet);
  int count = 6;
  glBufferData(GL_ARRAY_BUFFER, vertexSize * count, data, GL_DYNAMIC_DRAW);

  glDrawArrays(GL_TRIANGLES, 0, count);

  glBindBuffer(GL_ARRAY_BUFFER, 0);
  glBindVertexArray(0);
  glActiveTexture(GL_TEXTURE0);
}