Commit aa1c15ea authored by Emmanuel Christophe's avatar Emmanuel Christophe

ENH: move TileMapModel out of ossim to ossimplugins, should be able to use the standard ossim now

parent 7807345b
......@@ -40,7 +40,7 @@
#include "otbTileMapImageIO.h" //FIXME find a better way
#include "otbGDALImageIO.h" //FIXME find a better way
#include "projection/ossimTileMapModel.h"
#include "ossimTileMapModel.h"
#include <itksys/SystemTools.hxx>
#include <fstream>
......@@ -427,7 +427,7 @@ ImageFileReader<TOutputImage>
typename TileMapImageIO::Pointer imageIO = dynamic_cast<TileMapImageIO*>(this->GetImageIO());
if (imageIO.IsNotNull())
{
dynamic_cast<ossimTileMapModel*>(projection)->setDepth(imageIO->GetDepth());
dynamic_cast<ossimplugins::ossimTileMapModel*>(projection)->setDepth(imageIO->GetDepth());
}
}
hasMetaData = projection->saveState(geom_kwl);
......
......@@ -30,7 +30,7 @@
#include "base/ossimEllipsoid.h"
#include "base/ossimEllipsoidFactory.h"
#include "base/ossimString.h"
#include "ossim/projection/ossimTileMapModel.h"
#include "ossimTileMapModel.h"
#include "otbMapProjection.h"
// The keyword "Try" is exported by OSSIM's headers but clashes with Boost
// Spirit. It needs to be undefined.
......@@ -60,7 +60,7 @@ public:
typedef itk::SmartPointer<const Self> ConstPointer;
typedef typename Superclass::ScalarType ScalarType;
typedef ossimTileMapModel OssimTileMapTransformType;
typedef ossimplugins::ossimTileMapModel OssimTileMapTransformType;
typedef itk::Point<ScalarType, NInputDimensions> InputPointType;
typedef itk::Point<ScalarType, NOutputDimensions> OutputPointType;
......
......@@ -59,7 +59,7 @@
#include "otbForwardSensorModel.h"
#include "otbExtractROI.h"
#include "otbImageFileWriter.h"
#include "ossim/projection/ossimTileMapModel.h"
#include "ossimTileMapModel.h"
#include "otbWorldFile.h"
// Software Guide : EndCodeSnippet
......@@ -141,7 +141,7 @@ int main(int argc, char* argv[])
ModelType::Pointer model = ModelType::New();
model->SetImageGeometry(readerTile->GetOutput()->GetImageKeywordlist());
dynamic_cast<ossimTileMapModel*>(model->GetOssimModel())->setDepth(depth);
dynamic_cast<ossimplugins::ossimTileMapModel*>(model->GetOssimModel())->setDepth(depth);
if (!model)
{
std::cerr << "Unable to create a model" << std::endl;
......@@ -214,7 +214,7 @@ int main(int argc, char* argv[])
ForwardModelType::Pointer modelForward = ForwardModelType::New();
modelForward->SetImageGeometry(readerTile->GetOutput()->GetImageKeywordlist());
dynamic_cast<ossimTileMapModel*>(modelForward->GetOssimModel())->setDepth(
dynamic_cast<ossimplugins::ossimTileMapModel*>(modelForward->GetOssimModel())->setDepth(
depth);
if (!modelForward)
{
......
......@@ -26,7 +26,7 @@
#include "otbInverseSensorModel.h"
#include "otbExtractROI.h"
#include "otbImageFileWriter.h"
#include "ossim/projection/ossimTileMapModel.h"
#include "ossimTileMapModel.h"
int otbTileMapImageIOTest(int argc, char* argv[])
{
......@@ -64,7 +64,7 @@ int otbTileMapImageIOTest(int argc, char* argv[])
ModelType::Pointer model = ModelType::New();
model->SetImageGeometry(readerTile->GetOutput()->GetImageKeywordlist());
dynamic_cast<ossimTileMapModel*>(model->GetOssimModel())->setDepth(depth);
dynamic_cast<ossimplugins::ossimTileMapModel*>(model->GetOssimModel())->setDepth(depth);
if (!model)
{
std::cerr << "Unable to create a model" << std::endl;
......
......@@ -5,7 +5,7 @@
#include <cstdlib>
#include "base/ossimString.h"
#include "projection/ossimTileMapModel.h"
#include "ossimTileMapModel.h"
#include <ossim/base/ossimGpt.h>
#include <ossim/base/ossimDpt.h>
......@@ -19,7 +19,7 @@ int ossimTileMapModelTest(int argc, char* argv[])
else
{
// Ossim containers and tileMapModel
ossimRefPtr<ossimTileMapModel> tileMapModel = new ossimTileMapModel;
ossimRefPtr<ossimplugins::ossimTileMapModel> tileMapModel = new ossimplugins::ossimTileMapModel;
ossimGpt gpt;
ossimDpt dpt;
......
......@@ -57,7 +57,6 @@ protected:
static ossimSensorModelFactory* theInstance;
bool isNitf(const ossimFilename& filename)const;
bool isLandsat(const ossimFilename& filename)const;
bool isTileMap(const ossimFilename& filename) const;
void findCoarseGrid(ossimFilename& result,
const ossimFilename& geomFile)const;
};
......
......@@ -22,7 +22,6 @@
#include <ossim/imaging/ossimGeneralRasterTileSource.h>
#include <ossim/imaging/ossimERSTileSource.h>
#include <ossim/imaging/ossimVpfTileSource.h>
#include <ossim/imaging/ossimTileMapTileSource.h>
#include <ossim/base/ossimTrace.h>
#include <ossim/base/ossimKeywordNames.h>
#include <ossim/imaging/ossimJpegTileSource.h>
......@@ -73,7 +72,7 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimFilename& fileName)
// for all of our imagehandlers the filename must exist.
// if we have any imagehandlers that require an encoded string and is contrlled in this factory then
// we need to move this.
// if (!copyFilename.exists()) break;
if (!copyFilename.exists()) break;
ossimString ext = copyFilename.ext().downcase();
if(ext == "gz")
......@@ -171,10 +170,6 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimFilename& fileName)
result = new ossimCcfTileSource();
if (result->open(copyFilename)) break;
if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying TileMap...";
result = new ossimTileMapTileSource();
if (result->open(copyFilename)) break;
result = 0;
break;
}
......@@ -273,10 +268,6 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimKeywordlist& kwl,
result = new ossimQbTileFilesHandler;
if (result->loadState(kwl, prefix)) break;
if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<< "Trying TileMap...";
result = new ossimTileMapTileSource();
if (result->loadState(kwl, prefix)) break;
result = 0;
break;
}
......@@ -494,10 +485,6 @@ ossimObject* ossimImageHandlerFactory::createObject(const ossimString& typeName)
{
return new ossimQbTileFilesHandler();
}
if(STATIC_TYPE_NAME(ossimTileMapTileSource) == typeName)
{
return new ossimTileMapTileSource();
}
return (ossimObject*)0;
}
......@@ -526,7 +513,6 @@ void ossimImageHandlerFactory::getSupportedExtensions(ossimImageHandlerFactoryBa
extensionList.push_back("nitf");
extensionList.push_back("ntf");
extensionList.push_back("til");
extensionList.push_back("otb");
}
void ossimImageHandlerFactory::getImageHandlersBySuffix(ossimImageHandlerFactoryBase::ImageHandlerList& result, const ossimString& ext)const
......@@ -644,12 +630,6 @@ void ossimImageHandlerFactory::getImageHandlersBySuffix(ossimImageHandlerFactory
result.push_back(new ossimQbTileFilesHandler);
return;
}
if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG)<<M<<"Testing OTB..."<<std::endl;
if (testExt == "otb")
{
result.push_back(new ossimTileMapTileSource);
return;
}
}
void ossimImageHandlerFactory::getImageHandlersByMimeType(ossimImageHandlerFactoryBase::ImageHandlerList& result, const ossimString& mimeType)const
......@@ -703,10 +683,6 @@ ossimObject* ossimImageHandlerFactory::createObject(const ossimKeywordlist& kwl,
}
}
}
if(ossimString(type).trim() == STATIC_TYPE_NAME(ossimTileMapTileSource))
{
return new ossimTileMapTileSource();
}
if(traceDebug())
{
......@@ -731,7 +707,6 @@ 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(ossimTileMapTileSource));
typeList.push_back(STATIC_TYPE_NAME(ossimQuickbirdNitfTileSource));
typeList.push_back(STATIC_TYPE_NAME(ossimQuickbirdTiffTileSource));
typeList.push_back(STATIC_TYPE_NAME(ossimQbTileFilesHandler));
......
......@@ -50,7 +50,6 @@ static ossimTrace traceDebug = ossimTrace("ossimSensorModelFactory:debug");
#include <ossim/projection/ossimApplanixEcefModel.h>
#include <ossim/support_data/ossimFfL7.h>
#include <ossim/support_data/ossimFfL5.h>
#include <ossim/projection/ossimTileMapModel.h>
//***
// ADD_MODEL: List names of all sensor models produced by this factory:
......@@ -189,10 +188,6 @@ ossimSensorModelFactory::createProjection(const ossimString &name) const
return new ossimSpot5Model;
}
if(name==STATIC_TYPE_NAME(ossimTileMapModel))
{
return new ossimTileMapModel;
}
if(name == STATIC_TYPE_NAME(ossimSarModel))
{
return new ossimSarModel;
......@@ -244,7 +239,6 @@ ossimSensorModelFactory::getTypeNameList(std::vector<ossimString>& typeList)
typeList.push_back(STATIC_TYPE_NAME(ossimFcsiModel));
typeList.push_back(STATIC_TYPE_NAME(ossimSpot5Model));
typeList.push_back(STATIC_TYPE_NAME(ossimSarModel));
typeList.push_back(STATIC_TYPE_NAME(ossimTileMapModel));
typeList.push_back(STATIC_TYPE_NAME(ossimBuckeyeSensor));
//***
// ADD_MODEL: Please leave this comment for the next programmer. Add above.
......@@ -480,24 +474,6 @@ ossimProjection* ossimSensorModelFactory::createProjection(
}
return model.release();
}
bool ossimSensorModelFactory::isTileMap(const ossimFilename& filename)const
{
ossimFilename temp(filename);
temp.downcase();
ossimString os = temp.beforePos(4);
if(temp.ext()=="otb")
{
return true;
}
else if(os == "http")
{
return true;
}
return false;
}
bool ossimSensorModelFactory::isNitf(const ossimFilename& filename)const
{
......
......@@ -22,6 +22,7 @@
#include "ossimErsSarModel.h"
#include "ossimAlosPalsarModel.h"
#include <ossim/base/ossimNotifyContext.h>
#include "ossimTileMapModel.h"
//***
// Define Trace flags for use within this file:
......@@ -210,6 +211,27 @@ ossimProjection* ossimPluginProjectionFactory::createProjection(
}
}
if(traceDebug())
{
ossimNotify(ossimNotifyLevel_DEBUG)
<< MODULE << " DEBUG: testing ossimTileMapModel" << std::endl;
}
if (!projection)
{
ossimRefPtr<ossimTileMapModel> model = new ossimTileMapModel();
if (model->open(filename))
{
projection = model.get();
}
else
{
model = 0;
}
}
return projection.release();
}
......@@ -256,6 +278,10 @@ ossimProjection* ossimPluginProjectionFactory::createProjection(
{
return new ossimFormosatModel;
}
else if (name == STATIC_TYPE_NAME(ossimTileMapModel))
{
return new ossimTileMapModel;
}
if(traceDebug())
{
......@@ -339,6 +365,15 @@ ossimProjection* ossimPluginProjectionFactory::createProjection(
result = 0;
}
}
else if (type == "ossimTileMapModel")
{
result = new ossimTileMapModel();
if ( !result->loadState(kwl, prefix) )
{
result = 0;
}
}
}
if(traceDebug())
......@@ -373,5 +408,26 @@ void ossimPluginProjectionFactory::getTypeNameList(std::vector<ossimString>& typ
typeList.push_back(STATIC_TYPE_NAME(ossimErsSarModel));
typeList.push_back(STATIC_TYPE_NAME(ossimAlosPalsarModel));
typeList.push_back(STATIC_TYPE_NAME(ossimFormosatModel));
typeList.push_back(STATIC_TYPE_NAME(ossimTileMapModel));
}
bool ossimPluginProjectionFactory::isTileMap(const ossimFilename& filename)const
{
ossimFilename temp(filename);
temp.downcase();
ossimString os = temp.beforePos(4);
if(temp.ext()=="otb")
{
return true;
}
else if(os == "http")
{
return true;
}
return false;
}
}
......@@ -52,7 +52,7 @@ public:
virtual void getTypeNameList(std::vector<ossimString>& typeList)const;
protected:
ossimPluginProjectionFactory(){}
bool isTileMap(const ossimFilename& filename) const;
};
}
......
......@@ -20,6 +20,7 @@
#include <ossim/imaging/ossimImageHandler.h>
#include <ossim/base/ossimTrace.h>
#include <ossim/base/ossimKeywordNames.h>
#include "ossimTileMapTileSource.h"
namespace ossimplugins
{
......@@ -129,7 +130,7 @@ ossimImageHandler* ossimPluginReaderFactory::open(const ossimKeywordlist& kwl,
<< "ossimPluginReaderFactory::open(kwl, prefix) DEBUG: leaving..."
<< std::endl;
}
return reader.release();
}
......@@ -145,6 +146,11 @@ ossimObject* ossimPluginReaderFactory::createObject(
{
result = new ossimTerraSarTiffReader;
}
if(typeName == "ossimTileMapTileSource")
{
result = new ossimTileMapTileSource;
}
return result.release();
}
......@@ -159,12 +165,14 @@ void ossimPluginReaderFactory::getTypeNameList(
{
typeList.push_back(ossimString("ossimRadarSat2TiffReader"));
typeList.push_back(ossimString("ossimTerraSarTiffReader"));
typeList.push_back(ossimString("ossimTileMapTileSource"));
}
void ossimPluginReaderFactory::getSupportedExtensions(
ossimImageHandlerFactoryBase::UniqueStringList& extensionList)const
{
extensionList.push_back(ossimString("xml"));
extensionList.push_back("otb");
}
ossimPluginReaderFactory::ossimPluginReaderFactory(){}
......
......@@ -12,14 +12,13 @@
//
//*****************************************************************************
#include <ossim/projection/ossimTileMapModel.h>
#include "ossimTileMapModel.h"
RTTI_DEF1(ossimTileMapModel, "ossimTileMapModel", ossimSensorModel);
#include <stdio.h>
#include <cstdlib>
#include <ossim/base/ossimKeywordlist.h>
#include <ossim/base/ossimKeywordNames.h>
#include <stdio.h>
#include <cstdlib>
//***
// Define Trace flags for use within this file:
......@@ -28,6 +27,10 @@ RTTI_DEF1(ossimTileMapModel, "ossimTileMapModel", ossimSensorModel);
static ossimTrace traceExec ("ossimTileMapModel:exec");
static ossimTrace traceDebug ("ossimTileMapModel:debug");
namespace ossimplugins
{
RTTI_DEF1(ossimTileMapModel, "ossimTileMapModel", ossimSensorModel);
//*****************************************************************************
// DEFAULT CONSTRUCTOR: ossimTileMapModel()
......@@ -49,6 +52,26 @@ ossimTileMapModel::ossimTileMapModel()
}
bool ossimTileMapModel::open(const ossimFilename& file)
{
static const char MODULE[] = "ossimTileMapModel::open";
ossimString os = file.beforePos(4);
if (traceDebug())
{
CLOG << " Entered..." << std::endl
<< " trying to open file " << file << std::endl;
}
if(os == "http" || file.ext() == "otb")
{
return true;
}
return false;
}
//*****************************************************************************
// CONSTRUCTOR: ossimTileMapModel(kwl)
//
......@@ -262,3 +285,4 @@ void ossimTileMapModel::writeGeomTemplate(ostream& os)
if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimTileMapModel::writeGeomTemplate: returning..." << std::endl;
return;
}
} // End: namespace ossimplugins
......@@ -23,6 +23,8 @@
class ossimMapProjection;
namespace ossimplugins
{
//******************************************************************************
//*
//* CLASS: ossimTileMapModel
......@@ -59,6 +61,10 @@ public:
*/
virtual std::ostream& print(std::ostream& out) const;
bool open(const ossimFilename& file);
/*!
* Fulfills ossimObject base-class pure virtuals. Loads and saves geometry
* KWL files. Returns true if successful.
......@@ -155,5 +161,5 @@ protected:
};
} // End: namespace ossimplugins
#endif
......@@ -11,20 +11,24 @@
//*******************************************************************
// $Id: ossimTileMapTileSource.cpp 10752 2007-04-23 16:50:08Z dburken $
#include <ossim/imaging/ossimTileMapTileSource.h>
#include "ossimTileMapTileSource.h"
#include "ossimTileMapModel.h"
#include <ossim/base/ossimDirectory.h>
#include <ossim/base/ossimTrace.h>
#include <ossim/base/ossimNotifyContext.h>
#include <ossim/base/ossimKeywordNames.h>
#include <ossim/imaging/ossimImageGeometryRegistry.h>
#include <ossim/projection/ossimTileMapModel.h>
RTTI_DEF1_INST(ossimTileMapTileSource,
"ossimTileMapTileSource",
ossimGeneralRasterTileSource)
static ossimTrace traceDebug("ossimTileMapTileSource:debug");
namespace ossimplugins
{
RTTI_DEF1_INST(ossimTileMapTileSource,
"ossimTileMapTileSource",
ossimGeneralRasterTileSource)
//*******************************************************************
// Public Constructor:
......@@ -141,5 +145,4 @@ ossimString ossimTileMapTileSource::className() const
return ossimString("ossimTileMapTileSource");
}
} // End: namespace ossimplugins
......@@ -22,6 +22,8 @@
class ossimFfL7;
namespace ossimplugins
{
class OSSIM_DLL ossimTileMapTileSource : public ossimGeneralRasterTileSource
{
public:
......@@ -58,5 +60,5 @@ private:
TYPE_DATA
};
} // End: namespace ossimplugins
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment