Commit 8725d028 authored by Emmanuel Christophe's avatar Emmanuel Christophe
Browse files

work in progress

parent 48f9d095
//*******************************************************************
//
// License: See top level LICENSE.txt file.
//
// Author: Jordi Inglada
//
// Description:
//
// Contains class definition for the class "ossimNetworkedQuadTreeTileSource".
// ossimNetworkedQuadTreeTileSource is derived from ImageHandler which is derived from
// TileSource.
//
//*******************************************************************
// $Id: ossimNetworkedQuadTreeTileSource.h 10751 2007-04-23 16:49:08Z dburken $
#ifndef ossimNetworkedQuadTreeTileSource_HEADER
#define ossimNetworkedQuadTreeTileSource_HEADER
#include <ossim/imaging/ossimGeneralRasterTileSource.h>
#include <ossim/base/ossimDate.h>
class ossimFfL7;
class OSSIM_DLL ossimNetworkedQuadTreeTileSource : public ossimGeneralRasterTileSource
{
public:
ossimNetworkedQuadTreeTileSource();
ossimNetworkedQuadTreeTileSource(const ossimKeywordlist& kwl,
const char* prefix=0);
virtual ~ossimNetworkedQuadTreeTileSource();
virtual ossimString getShortName() const;
virtual ossimString getLongName() const;
virtual ossimString className() const;
virtual bool open();
virtual double getNullPixelValue(ossim_uint32 band=0)const;
virtual double getMinPixelValue(ossim_uint32 band=0)const;
virtual double getMaxPixelValue(ossim_uint32 band=0)const;
virtual ossimScalarType getOutputScalarType() const;
bool getAcquisitionDate(ossimDate& date)const;
ossimString getSatelliteName()const;
ossimFilename getBandFilename(ossim_uint32 idx)const;
bool isPan()const;
bool isVir()const;
bool isTm()const;
/*!
* Populates the keyword list with image geometry information. This
* method is used to relay projection/model information to users.
* Returns true if geometry info is present, false if not.
*/
virtual bool getImageGeometry(ossimKeywordlist& kwl,
const char* prefix=0);
virtual bool loadState(const ossimKeywordlist& kwl,
const char* prefix = NULL);
/**
* @brief Gets a property for matching name.
* @param name The name of the property to get.
* @return Returns property matching "name".
*/
virtual ossimRefPtr<ossimProperty> getProperty(const ossimString& name)const;
/**
* @brief Gets a list of property names available.
* @param propertyNames The list to push back names to.
*/
virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
private:
void openHeader(const ossimFilename& file);
ossimFfL7* theFfHdr;
TYPE_DATA
};
#endif
//*******************************************************************
//
// License: See top level LICENSE.txt file.
//
// DESCRIPTION: Contains declaration of NetworkedQuadTree sensor model class.
//
// SOFTWARE HISTORY:
// 23JAN2008 Jordi Inglada, CNES
// Initial coding.
//
//*****************************************************************************
// $Id: ossimNetworkedQuadTreeModel.h 10384 2007-01-26 20:32:12Z gpotts $
#ifndef ossimNetworkedQuadTreeModel_HEADER
#define ossimNetworkedQuadTreeModel_HEADER
#include <ossim/projection/ossimSensorModel.h>
#include <ossim/projection/ossimMapProjection.h>
#include <ossim/base/ossimIpt.h>
#include <ossim/base/ossimFilename.h>
#include <ossim/base/ossimGpt.h>
#include <ossim/base/ossimDpt.h>
#include <ossim/base/ossimEcefRay.h>
#include <ossim/base/ossimEcefPoint.h>
#include <ossim/base/ossimMatrix3x3.h>
#include <iostream>
class ossimFfL7;
class ossimString;
class ossimMapProjection;
//******************************************************************************
//*
//* CLASS: ossimNetworkedQuadTreeModel
//*
//*******************************************************************************
class OSSIMDLLEXPORT ossimNetworkedQuadTreeModel : public ossimSensorModel
{
public:
/*!
* CONSTRUCTORS:
*/
ossimNetworkedQuadTreeModel();
ossimNetworkedQuadTreeModel(const ossimFfL7& head);
ossimNetworkedQuadTreeModel(const ossimFilename& init_file);
ossimNetworkedQuadTreeModel(const ossimKeywordlist& geom_kwl);
ossimNetworkedQuadTreeModel(const ossimNetworkedQuadTreeModel& rhs);
virtual ~ossimNetworkedQuadTreeModel();
enum ProjectionType
{
UNKNOWN_PROJECTION = 0,
UTM_MAP,
UTM_ORBIT,
SOM_MAP,
SOM_ORBIT
};
enum AdjustParamIndex
{
INTRACK_OFFSET = 0,
CRTRACK_OFFSET,
LINE_GSD_CORR,
SAMP_GSD_CORR,
ROLL_OFFSET,
YAW_OFFSET,
YAW_RATE,
MAP_ROTATION,
NUM_ADJUSTABLE_PARAMS // not an index
};
/*!
* Returns pointer to a new instance, copy of this.
*/
virtual ossimObject* dup() const { return 0; } // TBR
/*!
* Extends base-class implementation. Dumps contents of object to ostream.
*/
virtual std::ostream& print(std::ostream& out) const;
/*!
* Fulfills ossimObject base-class pure virtuals. Loads and saves geometry
* KWL files. Returns true if successful.
*/
virtual bool saveState(ossimKeywordlist& kwl,
const char* prefix=0) const;
virtual bool loadState(const ossimKeywordlist& kwl,
const char* prefix=0);
/*!
* Writes a template of geom keywords processed by loadState and saveState
* to output stream.
*/
static void writeGeomTemplate(ostream& os);
//***
// Overrides base class pure virtual.
//***
virtual void worldToLineSample(const ossimGpt& ground_point,
ossimDpt& img_pt) const;
virtual void lineSampleHeightToWorld(const ossimDpt& image_point,
const double& heightEllipsoid,
ossimGpt& worldPoint) const;
virtual void lineSampleToWorld(const ossimDpt& image_point,
ossimGpt& worldPoint) const;
/*!
* Set/Get the depth of the quadtree decomposition
*
*/
void setDepth(unsigned char depth){
qDepth = depth;
}
unsigned char getDepth()
{
return qDepth;
}
/*!
* Given an image point, returns a ray originating at some arbitrarily high
* point (ideally at the sensor position) and pointing towards the target.
*/
virtual void imagingRay(const ossimDpt& image_point,
ossimEcefRay& image_ray) const;
/*!
* Following a change to the adjustable parameter set, this virtual
* is called to permit instances to compute derived quantities after
* parameter change.
*/
virtual void updateModel();
/*!
* ossimOptimizableProjection
*/
inline virtual bool useForward()const {return false;} //!image to ground faster
virtual bool setupOptimizer(const ossimString& init_file); //!uses file path to init model
protected:
/*!
* Initializes the model given a fast format header.
*/
void initFromHeader(const ossimFfL7& head);
virtual void initAdjustableParameters();
void initMapProjection();
//***
// Image constant parameters:
//***
double theIllumAzimuth;
double theIllumElevation;
double theOrbitAltitude;
double theOrbitInclination;
int theMapZone;
ossimDpt theMapOffset;
int theWrsPathNumber;
int theWrsRowNumber;
double theMeridianalAngle;
double thePositionError;
ProjectionType theProjectionType;
ossimRefPtr<ossimMapProjection> theMapProjection;
double theMapAzimAngle;
double theMapAzimCos;
double theMapAzimSin;
double theMap2IcRotAngle;
double theMap2IcRotCos;
double theMap2IcRotSin;
//***
// Adjustable parameters:
//***
double theIntrackOffset;
double theCrtrackOffset;
double theLineGsdCorr;
double theSampGsdCorr;
double theRollOffset;
double theYawOffset;
double theYawRate;
double theMapRotation;
//***
// Quantities derived from the adjustable parameters:
//***
NEWMAT::Matrix theRollRotMat;
TYPE_DATA
unsigned char qDepth;
};
#endif
......@@ -57,6 +57,7 @@ protected:
static ossimSensorModelFactory* theInstance;
bool isNitf(const ossimFilename& filename)const;
bool isLandsat(const ossimFilename& filename)const;
bool isNetworkedQuadTree(const ossimFilename& filename)const;
void findCoarseGrid(ossimFilename& result,
const ossimFilename& geomFile)const;
};
......
......@@ -20,6 +20,7 @@
#include <ossim/imaging/ossimGeneralRasterTileSource.h>
#include <ossim/imaging/ossimERSTileSource.h>
#include <ossim/imaging/ossimVpfTileSource.h>
#include <ossim/imaging/ossimNetworkedQuadTreeTileSource.h>
#include <ossim/base/ossimTrace.h>
#include <ossim/base/ossimKeywordNames.h>
#include <ossim/imaging/ossimJpegTileSource.h>
......@@ -114,6 +115,20 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimFilename& fileName)
delete result;
// test if NetworkedQuadTree
if(traceDebug())
{
ossimNotify(ossimNotifyLevel_DEBUG)
<< "trying NetworkedQuadTree"
<< std::endl;
}
result = new ossimNetworkedQuadTreeTileSource;
if(result->open(copyFilename))
{
return result;
}
delete result;
// this must be checked first before the TIFF handler
if(traceDebug())
{
......@@ -404,6 +419,21 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimKeywordlist& kwl,
}
delete result;
// NetworkedQuadTree
if(traceDebug())
{
ossimNotify(ossimNotifyLevel_DEBUG)
<< "trying NetworkedQuadTree"
<< std::endl;
}
result = new ossimNetworkedQuadTreeTileSource;
if(result->loadState(kwl, prefix))
{
return result;
}
delete result;
// Must be before tiff...
if(traceDebug())
{
......@@ -570,6 +600,11 @@ ossimObject* ossimImageHandlerFactory::createObject(const ossimString& typeName)
return new ossimGeneralRasterTileSource();
}
if(STATIC_TYPE_NAME(ossimNetworkedQuadTreeTileSource) == typeName)
{
return new ossimNetworkedQuadTreeTileSource();
}
return (ossimObject*)NULL;
}
......@@ -595,6 +630,7 @@ void ossimImageHandlerFactory::getSupportedExtensions(ossimImageHandlerFactoryBa
extensionList.push_back("nsf");
extensionList.push_back("nitf");
extensionList.push_back("ntf");
extensionList.push_back("otb");
}
ossimObject* ossimImageHandlerFactory::createObject(const ossimKeywordlist& kwl,
......@@ -657,6 +693,7 @@ void ossimImageHandlerFactory::getTypeNameList(std::vector<ossimString>& typeLis
typeList.push_back(STATIC_TYPE_NAME(ossimERSTileSource));
typeList.push_back(STATIC_TYPE_NAME(ossimSrtmTileSource));
typeList.push_back(STATIC_TYPE_NAME(ossimGeneralRasterTileSource));
typeList.push_back(STATIC_TYPE_NAME(ossimNetworkedQuadTreeTileSource));
typeList.push_back(STATIC_TYPE_NAME(ossimQuickbirdNitfTileSource));
typeList.push_back(STATIC_TYPE_NAME(ossimQuickbirdTiffTileSource));
}
//*******************************************************************
//
// License: See top level LICENSE.txt file.
//
// Author: Jordi Inglada
//
// Description:
//
// Contains class implementaiton for the class "ossim NetworkedQuadTreeTileSource".
//
//*******************************************************************
// $Id: ossimNetworkedQuadTreeTileSource.cpp 10752 2007-04-23 16:50:08Z dburken $
#include <ossim/imaging/ossimNetworkedQuadTreeTileSource.h>
#include <ossim/base/ossimDirectory.h>
#include <ossim/base/ossimTrace.h>
#include <ossim/base/ossimNotifyContext.h>
#include <ossim/base/ossimKeywordNames.h>
#include <ossim/support_data/ossimFfL7.h>
#include <ossim/support_data/ossimFfL5.h>
#include <ossim/projection/ossimNetworkedQuadTreeModel.h>
RTTI_DEF1_INST(ossimNetworkedQuadTreeTileSource,
"ossimNetworkedQuadTreeTileSource",
ossimGeneralRasterTileSource)
static ossimTrace traceDebug("ossimNetworkedQuadTreeTileSource:debug");
//*******************************************************************
// Public Constructor:
//*******************************************************************
ossimNetworkedQuadTreeTileSource::ossimNetworkedQuadTreeTileSource()
:
ossimGeneralRasterTileSource(),
theFfHdr(NULL)
{
}
//*******************************************************************
// Public Constructor:
//*******************************************************************
ossimNetworkedQuadTreeTileSource::ossimNetworkedQuadTreeTileSource(const ossimKeywordlist& kwl,
const char* prefix)
:
ossimGeneralRasterTileSource(),
theFfHdr(NULL)
{
if (loadState(kwl, prefix) == false)
{
theErrorStatus = ossimErrorCodes::OSSIM_ERROR;
}
}
//*******************************************************************
// Destructor:
//*******************************************************************
ossimNetworkedQuadTreeTileSource::~ossimNetworkedQuadTreeTileSource()
{
if (theFfHdr)
{
delete theFfHdr;
theFfHdr = NULL;
}
}
bool ossimNetworkedQuadTreeTileSource::open()
{
static const char MODULE[] = "ossimNetworkedQuadTreeTileSource::open";
if (traceDebug())
{
CLOG << " Entered..." << std::endl
<< " trying to open file " << theImageFile << std::endl;
}
if(theImageFile.ext() == "otb")
{
return true;
}
return false;
// ossimFilename tempFilename = theImageFile;
// // See if the file passed in is a header file.
// openHeader(theImageFile);
// if (!theFfHdr) return false;
// // Start building the keyword list for the general raster base class.
// ossimKeywordlist kwl;
// //***
// // There can be up to seven (six for L7) files that belong to the header.
// // Note that it seems the file names in the header are always upper case.
// // So test the file given to us to see if they should be downcased. This
// // is assuming that all files in the directory have the same case.
// //***
// vector<ossimFilename> fileList;
// for (ossim_uint32 i=0; i<theFfHdr->getBandCount(); ++i)
// {
// bool addFile = false;
// ossimFilename f1 = theFfHdr->getBandFilename(i);
// if (f1.trim() != "")
// {
// // Make the file name.
// ossimFilename f2 = theImageFile.path();
// f2 = f2.dirCat(f1);
// if (f2.exists())
// {
// addFile = true;
// }
// else
// {
// // Try it downcased...
// f2 = theImageFile.path();
// f1.downcase();
// f2 = f2.dirCat(f1);
// if (f2.exists())
// {
// addFile = true;
// }
// else
// {
// // Try is upcased...
// f2 = theImageFile.path();
// f1.upcase();
// f2 = f2.dirCat(f1);
// if (f2.exists())
// {
// addFile = true;
// }
// }
// }
// if (addFile)
// {
// if (traceDebug())
// {
// CLOG << "\nAdding file: " << f2 << std::endl;
// }
// fileList.push_back(f2);
// }
// else
// {
// if (traceDebug())
// {
// f2 = theImageFile.path();
// f1 = theFfHdr->getBandFilename(i);
// f1.trim();
// f2 = f2.dirCat(f1);
// CLOG << "\nCould not find: " << f2 << std::endl;
// }
// }
// }
// }
// if(fileList.size() == 0)
// {
// close();
// return false;
// }
// ossimGeneralRasterInfo generalRasterInfo(fileList,
// OSSIM_UINT8,
// OSSIM_BSQ_MULTI_FILE,
// fileList.size(),
// theFfHdr->getLinesPerBand(),
// theFfHdr->getPixelsPerLine(),
// 0,
// ossimGeneralRasterInfo::NONE,
// 0);
// if(fileList.size() == 1)
// {
// generalRasterInfo = ossimGeneralRasterInfo(fileList,
// OSSIM_UINT8,
// OSSIM_BSQ,
// fileList.size(),
// theFfHdr->getLinesPerBand(),
// theFfHdr->getPixelsPerLine(),
// 0,
// ossimGeneralRasterInfo::NONE,
// 0);
// }
// theMetaData.clear();
// theMetaData.setScalarType(OSSIM_UINT8);
// theMetaData.setNumberOfBands(fileList.size());
// theImageData = generalRasterInfo;
// if(initializeHandler())
// {
// theImageFile = tempFilename;
// completeOpen();
// }
// else
// {
// if (traceDebug()) CLOG << " Exited..." << std::endl;
// return false;
// }
// if (traceDebug()) CLOG << " Exited..." << std::endl;
// return true;
}
void ossimNetworkedQuadTreeTileSource::openHeader(const ossimFilename& file)
{
//***
// NetworkedQuadTree file name example: l71024031_03119990929_hpn.fst
// Three header header file type substrings:
// HPN = Pan
// HRF = VNIR/SWIR (visible near infrared/shortwave infrared)
// HTM = Thermal
//***
ossimFilename hdr = file.file();
hdr.downcase();
if ( hdr.contains("hpn") || hdr.contains("hrf") || hdr.contains("htm") )
{
theFfHdr = new ossimFfL7(file.c_str());