Commit 7eda3fa2 authored by Julien Michel's avatar Julien Michel

REFAC: Remove unsunsed ossim-based classes

parent 11ba4594
/*
* Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES)
*
* This file is part of Orfeo Toolbox
*
* https://www.orfeo-toolbox.org/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef otbDEMConvertAdapter_h
#define otbDEMConvertAdapter_h
#include "itkObject.h"
#include "itkObjectFactory.h"
#include "OTBOSSIMAdaptersExport.h"
namespace otb
{
class OTBOSSIMAdapters_EXPORT DEMConvertAdapter: public itk::Object
{
public:
/** Standard class typedefs. */
typedef DEMConvertAdapter Self;
typedef itk::Object Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Run-time type information (and related methods). */
itkTypeMacro(EllipsoidAdapter, itk::Object);
int Convert(std::string tempFilename, std::string output);
protected:
DEMConvertAdapter();
~DEMConvertAdapter() override;
private:
DEMConvertAdapter(const Self &) = delete;
void operator =(const Self&) = delete;
};
} // namespace otb
#endif
/*
* Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES)
*
* This file is part of Orfeo Toolbox
*
* https://www.orfeo-toolbox.org/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef otbGeometricSarSensorModelAdapter_h
#define otbGeometricSarSensorModelAdapter_h
#include <vector>
#include "itkObject.h"
#include "itkObjectFactory.h"
#include "OTBOSSIMAdaptersExport.h"
namespace ossimplugins
{
class ossimGeometricSarSensorModel;
class JSDDateTime;
}
namespace otb
{
class ImageKeywordlist;
/**
* \class GeometricSarSensorModelAdapter
* \brief Wrapper class to access the platform Geometric Sar
* Sensor Modelposition from ossim.
*
* This class is intended to be used in an InSAR setting to get
* information relative to the baseline. If necessary, it could be
* extended to non SAR models, but the optical ossim classes would
* need to be modified.
*
* \ingroup OTBOSSIMAdapters
**/
class OTBOSSIMAdapters_EXPORT GeometricSarSensorModelAdapter: public itk::Object
{
public:
/** Standard class typedefs. */
typedef GeometricSarSensorModelAdapter Self;
typedef itk::Object Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Run-time type information (and related methods). */
itkTypeMacro(GeometricSarSensorModelAdapter, itk::Object);
void CreateSensorModel(const ImageKeywordlist& image_kwl);
/** Get the platform position and speed for a given line. */
void GetPlatformPositionAtLine(
double line, std::vector<double>& position, std::vector<double>& speed);
/** Get the platform time for a given line. */
ossimplugins::JSDDateTime getTime(double line);
protected:
GeometricSarSensorModelAdapter();
~GeometricSarSensorModelAdapter() override;
private:
GeometricSarSensorModelAdapter(const Self &) = delete;
void operator =(const Self&) = delete;
ossimplugins::ossimGeometricSarSensorModel* m_SensorModel;
};
} // namespace otb
#endif
/*
* Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES)
*
* This file is part of Orfeo Toolbox
*
* https://www.orfeo-toolbox.org/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef otbPlatformPositionAdapter_h
#define otbPlatformPositionAdapter_h
#include <vector>
#include "itkObject.h"
#include "itkObjectFactory.h"
#include "OTBOSSIMAdaptersExport.h"
namespace ossimplugins
{
class ossimGeometricSarSensorModel;
class JSDDateTime;
}
namespace otb
{
class ImageKeywordlist;
/**
* \class PlatformPositionAdapter
* \brief Wrapper class to access the platform position from ossim
*
* This class is intended to be used in an InSAR setting to get
* information relative to the baseline. If necessary, it could be
* extended to non SAR models, but the optical ossim classes would
* need to be modified.
*
* \ingroup OTBOSSIMAdapters
**/
class OTBOSSIMAdapters_EXPORT PlatformPositionAdapter: public itk::Object
{
public:
/** Standard class typedefs. */
typedef PlatformPositionAdapter Self;
typedef itk::Object Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Run-time type information (and related methods). */
itkTypeMacro(PlatformPositionAdapter, itk::Object);
void CreateSensorModel(const ImageKeywordlist& image_kwl);
/** Get the platform position and speed for a given line. */
void GetPlatformPosition(
double line, std::vector<double>& position, std::vector<double>& speed);
/** Get the platform position at a given date and time. */
void GetPlatformPositionAtTime(
ossimplugins::JSDDateTime time, std::vector<double>& position, std::vector<double>& speed);
protected:
PlatformPositionAdapter();
~PlatformPositionAdapter() override;
private:
PlatformPositionAdapter(const Self &) = delete;
void operator =(const Self&) = delete;
ossimplugins::ossimGeometricSarSensorModel* m_SensorModel;
};
} // namespace otb
#endif
......@@ -21,10 +21,7 @@
set(OTBOSSIMAdapters_SRC
otbDEMHandler.cxx
otbImageKeywordlist.cxx
otbGeometricSarSensorModelAdapter.cxx
otbSensorModelAdapter.cxx
otbPlatformPositionAdapter.cxx
otbDEMConvertAdapter.cxx
otbRPCSolverAdapter.cxx
otbDateTimeAdapter.cxx
otbMapProjectionAdapter.cxx
......
/*
* Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES)
*
* This file is part of Orfeo Toolbox
*
* https://www.orfeo-toolbox.org/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "otbDEMConvertAdapter.h"
#include "itkMacro.h"
// OSSIM include
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Woverloaded-virtual"
#pragma GCC diagnostic ignored "-Wshadow"
#include "ossim/base/ossimKeywordNames.h"
#include "ossim/base/ossimStdOutProgress.h"
#include "ossim/base/ossimFilename.h"
#include "ossim/base/ossimKeywordlist.h"
#include "ossim/imaging/ossimJpegWriter.h"
#include "ossim/imaging/ossimImageHandler.h"
#include "ossim/imaging/ossimImageSource.h"
#include "ossim/imaging/ossimImageHandlerRegistry.h"
#include "ossim/imaging/ossimImageWriterFactoryRegistry.h"
#include "ossim/imaging/ossimImageWriterFactory.h"
#include "ossim/imaging/ossimImageFileWriter.h"
#include "ossim/imaging/ossimCacheTileSource.h"
#include "ossim/imaging/ossimBandSelector.h"
#include "ossim/imaging/ossimCibCadrgTileSource.h"
#pragma GCC diagnostic pop
#else
#include "ossim/base/ossimKeywordNames.h"
#include "ossim/base/ossimStdOutProgress.h"
#include "ossim/base/ossimFilename.h"
#include "ossim/base/ossimKeywordlist.h"
#include "ossim/imaging/ossimJpegWriter.h"
#include "ossim/imaging/ossimImageHandler.h"
#include "ossim/imaging/ossimImageSource.h"
#include "ossim/imaging/ossimImageHandlerRegistry.h"
#include "ossim/imaging/ossimImageWriterFactoryRegistry.h"
#include "ossim/imaging/ossimImageWriterFactory.h"
#include "ossim/imaging/ossimImageFileWriter.h"
#include "ossim/imaging/ossimCacheTileSource.h"
#include "ossim/imaging/ossimBandSelector.h"
#include "ossim/imaging/ossimCibCadrgTileSource.h"
#endif
namespace otb
{
DEMConvertAdapter::DEMConvertAdapter()
{}
DEMConvertAdapter::~DEMConvertAdapter()
{}
int DEMConvertAdapter::Convert(std::string tempFilename, std::string output)
{
// Keyword list to initialize image writers with.
ossimKeywordlist kwl;
const char* PREFIX = "imagewriter.";
// Define the output file type
std::string output_type("general_raster_bsq_envi");
kwl.add(PREFIX, ossimKeywordNames::TYPE_KW, output_type.c_str(), true);
// Get an image handler for the input file.
ossimRefPtr<ossimImageHandler> ih = ossimImageHandlerRegistry::instance()->open(ossimString(tempFilename));
// Initialize the
if (ih->getErrorStatus() == ossimErrorCodes::OSSIM_ERROR)
{
itkExceptionMacro("Error reading image: " << tempFilename << "Exiting application...");
return EXIT_FAILURE;
}
ih->initialize();
ossimRefPtr<ossimImageSource> source = ih.get();
ossimRefPtr<ossimBandSelector> bs = nullptr;
// Get the image rectangle for the rrLevel selected.
ossimIrect output_rect;
output_rect = source->getBoundingRect(0);
ossimRefPtr<ossimImageFileWriter> writer =
ossimImageWriterFactoryRegistry::instance()->createWriter(kwl, PREFIX);
writer->connectMyInputTo(0, source.get());
writer->open(ossimFilename(output));
// Add a listener to get percent complete.
ossimStdOutProgress prog(0, true);
writer->addListener(&prog);
if (writer->getErrorStatus() == ossimErrorCodes::OSSIM_OK)
{
if( (ih->getOutputScalarType() != OSSIM_UCHAR) &&
(PTR_CAST(ossimJpegWriter, writer.get()) ) )
{
writer->setScaleToEightBitFlag(true);
}
ossimRefPtr<ossimCacheTileSource> cache = new ossimCacheTileSource;
ossimIpt tileWidthHeight(ih->getImageTileWidth(),
ih->getImageTileHeight());
// only use the cache if its stripped
if(static_cast<ossim_uint32>(tileWidthHeight.x) ==
ih->getBoundingRect().width())
{
cache->connectMyInputTo(0, source.get());
cache->setTileSize(tileWidthHeight);
writer->connectMyInputTo(0, cache.get());
}
else
{
writer->connectMyInputTo(0, source.get());
}
writer->initialize();
writer->setAreaOfInterest(output_rect); // Set the output rectangle.
try
{
writer->execute();
}
catch(std::exception& e)
{
std::cerr << "std::exception thrown:" << std::endl;
std::cerr << e.what() << std::endl;
itkExceptionMacro("Error occurs writing the output image...");
return EXIT_FAILURE;
}
}
else
{
itkExceptionMacro("Error detected in the image writer...");
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
} // namespace otb
/*
* Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES)
*
* This file is part of Orfeo Toolbox
*
* https://www.orfeo-toolbox.org/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "otbGeometricSarSensorModelAdapter.h"
#include "otbMacro.h"
#include "otbImageKeywordlist.h"
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Woverloaded-virtual"
#pragma GCC diagnostic ignored "-Wshadow"
#include "ossim/ossimGeometricSarSensorModel.h"
#include "ossim/projection/ossimProjection.h"
#include "ossim/ossimPluginProjectionFactory.h"
#include "ossim/otb/JSDDateTime.h"
#pragma GCC diagnostic pop
#else
#include "ossim/ossimGeometricSarSensorModel.h"
#include "ossim/projection/ossimProjection.h"
#include "ossim/ossimPluginProjectionFactory.h"
#include "ossim/otb/JSDDateTime.h"
#endif
namespace otb {
GeometricSarSensorModelAdapter::GeometricSarSensorModelAdapter():
m_SensorModel(nullptr)
{
}
GeometricSarSensorModelAdapter::~GeometricSarSensorModelAdapter()
{
if (m_SensorModel != nullptr)
{
delete m_SensorModel;
m_SensorModel = nullptr;
}
}
void GeometricSarSensorModelAdapter::CreateSensorModel(const ImageKeywordlist& image_kwl)
{
ossimKeywordlist geom;
image_kwl.convertToOSSIMKeywordlist(geom);
otbMsgDevMacro(<< "CreateSensorModel()");
otbMsgDevMacro(<< "* type: " << geom.find("type"));
ossimProjection* sensor = ossimplugins::ossimPluginProjectionFactory::instance()->createProjection(geom);
m_SensorModel = dynamic_cast<ossimplugins::ossimGeometricSarSensorModel*>(sensor);
if (!m_SensorModel)
{
otbMsgDevMacro(<< "CreateSensorModel() failed");
}
}
ossimplugins::JSDDateTime GeometricSarSensorModelAdapter::getTime(double line)
{
return m_SensorModel->getTime(line);
}
void GeometricSarSensorModelAdapter::GetPlatformPositionAtLine(
double line, std::vector<double>& position, std::vector<double>& speed)
{
m_SensorModel->getPlatformPositionAtLine(line, position, speed);
}
} // namespace otb
/*
* Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES)
*
* This file is part of Orfeo Toolbox
*
* https://www.orfeo-toolbox.org/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "otbPlatformPositionAdapter.h"
#include "otbMacro.h"
#include "otbImageKeywordlist.h"
#include "ossim/ossimGeometricSarSensorModel.h"
#include "ossim/otb/PlatformPosition.h"
#include "ossim/projection/ossimProjection.h"
#include "ossim/ossimPluginProjectionFactory.h"
namespace otb {
PlatformPositionAdapter::PlatformPositionAdapter():
m_SensorModel(nullptr)
{
}
PlatformPositionAdapter::~PlatformPositionAdapter()
{
if (m_SensorModel != nullptr)
{
delete m_SensorModel;
m_SensorModel = nullptr;
}
}
void PlatformPositionAdapter::CreateSensorModel(const ImageKeywordlist& image_kwl)
{
ossimKeywordlist geom;
image_kwl.convertToOSSIMKeywordlist(geom);
otbMsgDevMacro(<< "CreateSensorModel()");
otbMsgDevMacro(<< "* type: " << geom.find("type"));
ossimProjection* sensor = ossimplugins::ossimPluginProjectionFactory::instance()->createProjection(geom);
m_SensorModel = dynamic_cast<ossimplugins::ossimGeometricSarSensorModel*>(sensor);
if (!m_SensorModel)
{
otbMsgDevMacro(<< "CreateSensorModel() failed");
}
}
void PlatformPositionAdapter::GetPlatformPosition(
double line, std::vector<double>& position, std::vector<double>& speed)
{
m_SensorModel->getPlatformPositionAtLine(line, position, speed);
}
void PlatformPositionAdapter::GetPlatformPositionAtTime(
ossimplugins::JSDDateTime time, std::vector<double>& position, std::vector<double>& speed)
{
m_SensorModel->get_platformPosition()->getPlatformPositionAtTime(time, position, speed);
}
} // namespace otb
......@@ -27,8 +27,6 @@ otbOssimJpegFileResourceLeakTest.cxx
otbMapProjectionAdapterTest.cxx
otbOssimElevManagerTest2.cxx
otbOssimElevManagerTest4.cxx
otbGeometricSarSensorModelAdapter.cxx
otbPlatformPositionAdapter.cxx
otbDEMHandlerTest.cxx
otbRPCSolverAdapterTest.cxx
otbSarSensorModelAdapterTest.cxx
......@@ -176,23 +174,6 @@ otb_add_test(NAME prTvossimElevManagerTest4 COMMAND otbOSSIMAdaptersTestDriver
-1.8 52 0.02 -0.018 232 422
)
#commented below test. these are moved to dev_sar_tsx branch for further checks
# otb_add_test(NAME uaTvGeometricSarSensorModelAdapterTest COMMAND otbOSSIMAdaptersTestDriver
# --compare-ascii ${EPSILON_9}
# ${BASELINE_FILES}/uaTvGeometricSarSensorModelAdapterTest.txt
# ${TEMP}/uaTvGeometricSarSensorModelAdapterTest.txt
# otbGeometricSarSensorModelAdapterTest
# LARGEINPUT{TERRASARX/2008-03-10_GrandCanyon_SSC//TSX1_SAR__SSC______SM_S_SRA_20080310T133220_20080310T133228/TSX1_SAR__SSC______SM_S_SRA_20080310T133220_20080310T133228.xml}
# ${TEMP}/uaTvGeometricSarSensorModelAdapterTest.txt)
# otb_add_test(NAME uaTvPlatformPositionComputeBaselineTest COMMAND otbOSSIMAdaptersTestDriver
# --compare-ascii ${EPSILON_9}
# ${BASELINE_FILES}/uaTvPlatformPositionComputeBaselineTest.txt
# ${TEMP}/uaTvPlatformPositionComputeBaselineTest.txt
# otbPlatformPositionComputeBaselineTest
# LARGEINPUT{TERRASARX/2008-03-10_GrandCanyon_SSC//TSX1_SAR__SSC______SM_S_SRA_20080310T133220_20080310T133228/TSX1_SAR__SSC______SM_S_SRA_20080310T133220_20080310T133228.xml}
# ${TEMP}/uaTvPlatformPositionComputeBaselineTest.txt)
otb_add_test(NAME uaTvDEMHandler_AboveEllipsoid_NoSRTM_NoGeoid_NoData COMMAND otbOSSIMAdaptersTestDriver
otbDEMHandlerTest
no
......
/*
* Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES)
*
* This file is part of Orfeo Toolbox
*
* https://www.orfeo-toolbox.org/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <iomanip>
#include "otbImage.h"
#include "otbImageFileReader.h"
#include "otbGeometricSarSensorModelAdapter.h"
int otbGeometricSarSensorModelAdapterTest(int argc, char* argv[])
{
if (argc != 3)
{
std::cerr << "Usage: " << argv[0] << " imageFile output" << std::endl;
return EXIT_FAILURE;
}
typedef std::complex<double> PixelType;
typedef otb::Image<PixelType,2> ImageType;
typedef otb::ImageFileReader<ImageType> ReaderType;
ReaderType::Pointer image = ReaderType::New();
image->SetFileName(argv[1]);
image->UpdateOutputInformation();
typedef otb::GeometricSarSensorModelAdapter SarSensorModelType;
SarSensorModelType::Pointer imageSarModel = SarSensorModelType::New();
imageSarModel->CreateSensorModel(image->GetOutput()->GetImageKeywordlist());
std::vector<double> imagePosition;
std::vector<double> imageSpeed;
imagePosition.resize(3);
imageSpeed.resize(3);
imageSarModel->GetPlatformPositionAtLine(0, imagePosition, imageSpeed);
std::ofstream file;
file.open(argv[2]);
file << std::setprecision(15);
file << "Image:\n";
//file << "Start Time: " << masterSarModel->getTime(0)<< " m\n";
file << "Pos X: " << imagePosition[0] << " m\n";