diff --git a/Modules/Adapters/OSSIMAdapters/include/otbDEMHandler.h b/Modules/Adapters/OSSIMAdapters/include/otbDEMHandler.h deleted file mode 100644 index 6dd03da5d0bc670f14f90eec165182ba79ccdb31..0000000000000000000000000000000000000000 --- a/Modules/Adapters/OSSIMAdapters/include/otbDEMHandler.h +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (C) 2005-2020 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 otbDEMHandler_h -#define otbDEMHandler_h - -#include <cstdio> - -#include "itkIndent.h" -#include "itkObject.h" -#include "itkObjectFactory.h" -#include "itkPoint.h" - -#include "OTBOSSIMAdaptersExport.h" -#include <string> - -class ossimElevManager; - -namespace otb -{ -/** \class DEMHandler - * - * \brief Single access point for DEM data retrieval - * - * This class is the single configuration and access point for - * elevation handling in images projections and localization - * functions. Since this class is a singleton, there is no New() method. The - * DEMHandler::Instance() method should be used instead. - * - * Please be aware that a proper instantiation and parameter setting - * of this class is advised before any call to geometric filters or - * functionalities. Ossim internal accesses to elevation are also - * configured by this class and this will ensure consistency - * throughout the library. - * - * The class allows configuring a directory containing DEM tiles - * (DTED or SRTM supported) using the OpenDEMDirectory() method. The - * OpenGeoidFile() method allows inputting a geoid file as well. Last, - * a default height above ellipsoid can be set using the - * SetDefaultHeightAboveEllipsoid() method. - * - * The class allows retrieving either height above ellipsoid or - * height above Mean Sea Level (MSL). - * - * Here is the complete description of both methods output depending - * on the class configuration for the SRTM DEM (in the following, no - * SRTM means DEMDirectory not set, or no coverage for point, or - * srtm_value is no_data). - * - * GetHeightAboveEllipsoid(): - * - SRTM and geoid both available: srtm_value + geoid_offset - * - No SRTM but geoid available: geoid_offset - * - SRTM available, but no geoid: srtm_value - * - No SRTM and no geoid available: default height above ellipsoid - * - * GetHeightAboveMSL(): - * - SRTM and geoid both available: srtm_value - * - No SRTM but geoid available: 0 - * - SRTM available, but no geoid: srtm_value - * - No SRTM and no geoid available: 0 - * - * Please note that OSSIM internal calls for sensor modeling use the - * height above ellipsoid, and follow the same logic as the - * GetHeightAboveEllipsoid() method. - * - * DEM directory can either contain DTED or SRTM formats. - * \ingroup Images - * - * - * \ingroup OTBOSSIMAdapters - */ - -class OTBOSSIMAdapters_EXPORT DEMHandler : public itk::Object -{ -public: - /** Standard class typedefs. */ - typedef DEMHandler Self; - typedef itk::Object Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - typedef itk::Point<double, 2> PointType; - - /** Retrieve the singleton instance */ - static Pointer Instance(); - - /** Run-time type information (and related methods). */ - itkTypeMacro(DEMHandler, Object); - - /** Try to open the DEM directory. */ - virtual void OpenDEMDirectory(const char* DEMDirectory); - virtual void OpenDEMDirectory(const std::string& DEMDirectory); - - /** return true if the directory contain DEM */ - virtual bool IsValidDEMDirectory(const char* DEMDirectory); - - /** - * \brief Open geoid file given its filename or throw an exception - * if geoid-file could not be loaded. - * - * \param geoidFile The filename of the geoid-file. - * - * \return <code>true</code> if geoid file has been changed or - * <code>false</code> if geod-file have been set before and could - * not be changed. - */ - virtual bool OpenGeoidFile(const char* geoidFile); - - /** - * \brief Open geoid file given its filename or throw an exception - * if geoid-file could not be loaded. - * - * \param geoidFile The filename of the geoid-file. - * - * \return <code>true</code> if geoid file has been changed or - * <code>false</code> if geod-file have been set before and could - * not be changed. - */ - virtual bool OpenGeoidFile(const std::string& geoidFile); - - /** Compute the height above MSL(Mean Sea Level) of a geographic point. */ - virtual double GetHeightAboveMSL(double lon, double lat) const; - virtual double GetHeightAboveMSL(const PointType& geoPoint) const; - - /** Compute the height above ellipsoid of a geographic point. */ - virtual double GetHeightAboveEllipsoid(double lon, double lat) const; - virtual double GetHeightAboveEllipsoid(const PointType& geoPoint) const; - - /** Set the default height above ellipsoid in case no information is available*/ - virtual void SetDefaultHeightAboveEllipsoid(double h); - - /** Set the default height above ellipsoid in case no information is available*/ - double GetDefaultHeightAboveEllipsoid() const; - - /** - * \return The number of elevation databases in the - * <code>ossimElevManager</code>. - */ - unsigned int GetDEMCount() const; - - /** Get DEM directory */ - std::string GetDEMDirectory(unsigned int idx = 0) const; - - /** Get Goid file */ - std::string GetGeoidFile() const; - - /** - * \brief Remove all the ossimElevationDatabases from the - * <code>ossimElevManager</code>. - */ - void ClearDEMs(); - -protected: - DEMHandler(); - ~DEMHandler() override - { - } - - void PrintSelf(std::ostream& os, itk::Indent indent) const override; - - // Ossim does not allow retrieving the geoid file path - // We therefore must keep it on our side - std::string m_GeoidFile; - - // Ossim does not allow retrieving the default height above - // ellipsoid We therefore must keep it on our side - double m_DefaultHeightAboveEllipsoid; - - static Pointer m_Singleton; -}; - -} // namespace otb - -#endif diff --git a/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h b/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h index 344db4c6593a701952c2758bb06a40c8a2a6d50f..da09001d15f7b817bc7fc1fedc7d01e16985aa8e 100644 --- a/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h +++ b/Modules/Adapters/OSSIMAdapters/include/otbSarSensorModelAdapter.h @@ -23,7 +23,7 @@ #include <memory> -#include "otbDEMHandler.h" +#include "otbOssimDEMHandler.h" #include "itkPoint.h" namespace ossimplugins diff --git a/Modules/Adapters/OSSIMAdapters/include/otbSensorModelAdapter.h b/Modules/Adapters/OSSIMAdapters/include/otbSensorModelAdapter.h index aa4726d4d9bd519261b0da5d9436651a57d62273..bdea12467e930ae77b455efc7458e6a2010581b3 100644 --- a/Modules/Adapters/OSSIMAdapters/include/otbSensorModelAdapter.h +++ b/Modules/Adapters/OSSIMAdapters/include/otbSensorModelAdapter.h @@ -21,7 +21,7 @@ #ifndef otbSensorModelAdapter_h #define otbSensorModelAdapter_h -#include "otbDEMHandler.h" +#include "otbOssimDEMHandler.h" class ossimProjection; class ossimTieGptSet; @@ -118,7 +118,7 @@ private: InternalTiePointsContainerPointer m_TiePoints; /** Object that read and use DEM */ - DEMHandler::Pointer m_DEMHandler; + OssimDEMHandler::Pointer m_DEMHandler; }; } // namespace otb diff --git a/Modules/Adapters/OSSIMAdapters/otb-module.cmake b/Modules/Adapters/OSSIMAdapters/otb-module.cmake index 346059b6ae76af48c428a79580aaf415e12fcbab..12a161c538fe4b5928ff8b5534b6248b8ac4fccd 100644 --- a/Modules/Adapters/OSSIMAdapters/otb-module.cmake +++ b/Modules/Adapters/OSSIMAdapters/otb-module.cmake @@ -32,13 +32,14 @@ ENABLE_SHARED OTBGDAL OTBOssimPlugins OTBOssim - + TEST_DEPENDS OTBTestKernel OTBImageBase OTBImageIO OTBTransform OTBProjection + OTBIOGDAL DESCRIPTION "${DOCUMENTATION}" diff --git a/Modules/Adapters/OSSIMAdapters/src/CMakeLists.txt b/Modules/Adapters/OSSIMAdapters/src/CMakeLists.txt index a12d2b6efcbb6c3ad743d06b588433c511915533..cc6dadd6ecf65f8ad112359b0dd3d5ffc8b9e6b0 100644 --- a/Modules/Adapters/OSSIMAdapters/src/CMakeLists.txt +++ b/Modules/Adapters/OSSIMAdapters/src/CMakeLists.txt @@ -19,7 +19,7 @@ # set(OTBOSSIMAdapters_SRC - otbDEMHandler.cxx + otbOssimDEMHandler.cxx otbImageKeywordlist.cxx otbSensorModelAdapter.cxx otbRPCSolverAdapter.cxx diff --git a/Modules/Adapters/OSSIMAdapters/src/otbDEMHandler.cxx b/Modules/Adapters/OSSIMAdapters/src/otbDEMHandler.cxx deleted file mode 100644 index 92c9ce40b3f46d19dcd534e4d688a3bd6d3a4c04..0000000000000000000000000000000000000000 --- a/Modules/Adapters/OSSIMAdapters/src/otbDEMHandler.cxx +++ /dev/null @@ -1,275 +0,0 @@ -/* - * Copyright (C) 2005-2020 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 "otbDEMHandler.h" -#include "otbMacro.h" - -#include <cassert> - -#include "otb_ossim.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/elevation/ossimElevManager.h" -#include "ossim/base/ossimGeoidManager.h" -#include "ossim/base/ossimFilename.h" -#include "ossim/base/ossimDirectory.h" -#include "ossim/base/ossimGeoidEgm96.h" -#include "ossim/base/ossimRefPtr.h" -#include <ossim/elevation/ossimImageElevationDatabase.h> -#pragma GCC diagnostic pop -#else -#include "ossim/elevation/ossimElevManager.h" -#include "ossim/base/ossimGeoidManager.h" -#include "ossim/base/ossimFilename.h" -#include "ossim/base/ossimDirectory.h" -#include "ossim/base/ossimGeoidEgm96.h" -#include "ossim/base/ossimRefPtr.h" -#include <ossim/elevation/ossimImageElevationDatabase.h> -#endif - - -namespace otb -{ -/** Initialize the singleton */ -DEMHandler::Pointer DEMHandler::m_Singleton = nullptr; - -DEMHandler::Pointer DEMHandler::Instance() -{ - if (m_Singleton.GetPointer() == nullptr) - { - m_Singleton = itk::ObjectFactory<Self>::Create(); - - if (m_Singleton.GetPointer() == nullptr) - { - m_Singleton = new DEMHandler; - } - m_Singleton->UnRegister(); - } - - return m_Singleton; -} - -DEMHandler::DEMHandler() : m_GeoidFile(""), m_DefaultHeightAboveEllipsoid(0) -{ - assert(ossimElevManager::instance() != NULL); - - ossimElevManager::instance()->setDefaultHeightAboveEllipsoid(m_DefaultHeightAboveEllipsoid); - // Force geoid fallback - ossimElevManager::instance()->setUseGeoidIfNullFlag(true); -} - -void DEMHandler::OpenDEMDirectory(const char* DEMDirectory) -{ - assert(ossimElevManager::instance() != NULL); - - ossimFilename ossimDEMDir(DEMDirectory); - - if (!ossimElevManager::instance()->loadElevationPath(ossimDEMDir)) - { - // In ossim elevation database factory code, the - // ossimImageElevationDatabase is explicitly disabled by a #if 0 - // guard, because it causes problem when loading ossim related - // application. Therefore, we explicitly call - // ossimImageElevationDatabase here to allow for general elevation - // images support. - ossimRefPtr<ossimElevationDatabase> imageElevationDatabase = new ossimImageElevationDatabase; - - if (!imageElevationDatabase->open(DEMDirectory)) - { - itkExceptionMacro("Failed to open DEM Directory: " << ossimDEMDir); - } - else - { - otbMsgDevMacro(<< "DEM directory contains general elevation image files: " << ossimDEMDir); - ossimElevManager::instance()->addDatabase(imageElevationDatabase.get()); - } - } -} - - -void DEMHandler::ClearDEMs() -{ - assert(ossimElevManager::instance() != NULL); - - ossimElevManager::instance()->clear(); -} - - -void DEMHandler::OpenDEMDirectory(const std::string& DEMDirectory) -{ - OpenDEMDirectory(DEMDirectory.c_str()); -} - -bool DEMHandler::IsValidDEMDirectory(const char* DEMDirectory) -{ - assert(ossimElevManager::instance() != NULL); - - // Try to load elevation source - bool result = ossimElevManager::instance()->loadElevationPath(DEMDirectory); - - if (!result) - { - // we explicitly call ossimImageElevationDatabase here to allow for general elevation - // images support and test the open method to check if the directory . - ossimRefPtr<ossimElevationDatabase> imageElevationDatabase = new ossimImageElevationDatabase; - result = imageElevationDatabase->open(DEMDirectory); - } - return result; -} - -bool DEMHandler::OpenGeoidFile(const char* geoidFile) -{ - if ((ossimGeoidManager::instance()->findGeoidByShortName("geoid1996")) == nullptr) - { - otbMsgDevMacro(<< "Opening geoid: " << geoidFile); - ossimFilename geoid(geoidFile); - ossimRefPtr<ossimGeoid> geoidPtr = new ossimGeoidEgm96(geoid); - if (geoidPtr->getErrorStatus() == ossimErrorCodes::OSSIM_OK) - { - // Ossim does not allow retrieving the geoid file path - // We therefore must keep it on our side - m_GeoidFile = geoidFile; - otbMsgDevMacro(<< "Geoid successfully opened"); - ossimGeoidManager::instance()->addGeoid(geoidPtr); - geoidPtr.release(); - - // The previous flag will be ignored if - // defaultHeightAboveEllipsoid is not NaN - assert(ossimElevManager::instance() != NULL); - - ossimElevManager::instance()->setDefaultHeightAboveEllipsoid(ossim::nan()); - - return true; - } - else - { - otbMsgDevMacro(<< "Failure opening geoid"); - geoidPtr.release(); - - itkExceptionMacro(<< "Failed to open geoid file: '" << geoidFile << "'"); - - return false; - } - } - - return false; -} - -bool DEMHandler::OpenGeoidFile(const std::string& geoidFile) -{ - return OpenGeoidFile(geoidFile.c_str()); -} - -double DEMHandler::GetHeightAboveMSL(double lon, double lat) const -{ - double height; - ossimGpt ossimWorldPoint; - - ossimWorldPoint.lon = lon; - ossimWorldPoint.lat = lat; - - assert(ossimElevManager::instance() != NULL); - - height = ossimElevManager::instance()->getHeightAboveMSL(ossimWorldPoint); - - return height; -} - -double DEMHandler::GetHeightAboveMSL(const PointType& geoPoint) const -{ - return GetHeightAboveMSL(geoPoint[0], geoPoint[1]); -} - -double DEMHandler::GetHeightAboveEllipsoid(double lon, double lat) const -{ - double height; - ossimGpt ossimWorldPoint; - - ossimWorldPoint.lon = lon; - ossimWorldPoint.lat = lat; - - assert(ossimElevManager::instance() != NULL); - - height = ossimElevManager::instance()->getHeightAboveEllipsoid(ossimWorldPoint); - - return height; -} - -double DEMHandler::GetHeightAboveEllipsoid(const PointType& geoPoint) const -{ - return GetHeightAboveEllipsoid(geoPoint[0], geoPoint[1]); -} - -void DEMHandler::SetDefaultHeightAboveEllipsoid(double h) -{ - // Ossim does not allow retrieving the default height above - // ellipsoid We therefore must keep it on our side - m_DefaultHeightAboveEllipsoid = h; - - assert(ossimElevManager::instance() != NULL); - - ossimElevManager::instance()->setDefaultHeightAboveEllipsoid(h); -} - -double DEMHandler::GetDefaultHeightAboveEllipsoid() const -{ - // Ossim does not allow retrieving the default height above - // ellipsoid We therefore must keep it on our side - return m_DefaultHeightAboveEllipsoid; -} - -unsigned int DEMHandler::GetDEMCount() const -{ - assert(ossimElevManager::instance() != NULL); - - return ossimElevManager::instance()->getNumberOfElevationDatabases(); -} - -std::string DEMHandler::GetDEMDirectory(unsigned int idx) const -{ - std::string demDir = ""; - - if (ossimElevManager::instance()->getNumberOfElevationDatabases() > 0) - { - assert(ossimElevManager::instance() != NULL); - - demDir = ossimElevManager::instance()->getElevationDatabase(idx)->getConnectionString().string(); - } - return demDir; -} - -std::string DEMHandler::GetGeoidFile() const -{ - // Ossim does not allow retrieving the geoid file path - // We therefore must keep it on our side - return m_GeoidFile; -} - -void DEMHandler::PrintSelf(std::ostream& os, itk::Indent indent) const -{ - Superclass::PrintSelf(os, indent); - os << indent << "DEMHandler" << std::endl; -} - -} // namespace otb diff --git a/Modules/Adapters/OSSIMAdapters/src/otbSensorModelAdapter.cxx b/Modules/Adapters/OSSIMAdapters/src/otbSensorModelAdapter.cxx index 629cf6e6ffdc0910acab7a2aab502bbfc54996df..2bcfbfaf448407fafacaeb44224cccecd2de1e4a 100644 --- a/Modules/Adapters/OSSIMAdapters/src/otbSensorModelAdapter.cxx +++ b/Modules/Adapters/OSSIMAdapters/src/otbSensorModelAdapter.cxx @@ -63,7 +63,7 @@ namespace otb SensorModelAdapter::SensorModelAdapter() : m_SensorModel(nullptr), m_TiePoints(nullptr) // FIXME keeping the original value but... { - m_DEMHandler = DEMHandler::Instance(); + m_DEMHandler = OssimDEMHandler::Instance(); m_TiePoints = new ossimTieGptSet(); } diff --git a/Modules/Adapters/OSSIMAdapters/test/otbDEMHandlerTest.cxx b/Modules/Adapters/OSSIMAdapters/test/otbDEMHandlerTest.cxx index 7388ca058ccfd4ea48dd233945c4f4bc20282d2d..7f0a84aa5bc90cb33bcf4b6fff3bf12a7286e1e0 100644 --- a/Modules/Adapters/OSSIMAdapters/test/otbDEMHandlerTest.cxx +++ b/Modules/Adapters/OSSIMAdapters/test/otbDEMHandlerTest.cxx @@ -20,7 +20,7 @@ #include "itkMacro.h" -#include "otbDEMHandler.h" +#include "otbOssimDEMHandler.h" int otbDEMHandlerTest(int argc, char* argv[]) { @@ -40,7 +40,7 @@ int otbDEMHandlerTest(int argc, char* argv[]) double target = atof(argv[7]); double tolerance = atof(argv[8]); - otb::DEMHandler::Pointer demHandler = otb::DEMHandler::Instance(); + otb::OssimDEMHandler::Pointer demHandler = otb::OssimDEMHandler::Instance(); demHandler->SetDefaultHeightAboveEllipsoid(defaultHeight); bool fail = false; @@ -78,7 +78,7 @@ int otbDEMHandlerTest(int argc, char* argv[]) std::cout << "PrintSelf: " << demHandler << std::endl; - otb::DEMHandler::PointType point; + otb::OssimDEMHandler::PointType point; point[0] = longitude; point[1] = latitude; diff --git a/Modules/Adapters/OSSIMAdapters/test/otbRPCSolverAdapterTest.cxx b/Modules/Adapters/OSSIMAdapters/test/otbRPCSolverAdapterTest.cxx index 10f0514383e2e6b12ec7e8d14deb06250a698864..29a66c20241b323cdc9df36d693fe240d2efa3d3 100644 --- a/Modules/Adapters/OSSIMAdapters/test/otbRPCSolverAdapterTest.cxx +++ b/Modules/Adapters/OSSIMAdapters/test/otbRPCSolverAdapterTest.cxx @@ -62,7 +62,7 @@ int otbRPCSolverAdapterTest(int argc, char* argv[]) std::cout << "GeoTol: " << geoTol << " meters" << std::endl; std::cout << "ImgTol: " << imgTol << " pixels" << std::endl; - otb::DEMHandler::Pointer demHandler = otb::DEMHandler::Instance(); + otb::OssimDEMHandler::Pointer demHandler = otb::OssimDEMHandler::Instance(); demHandler->SetDefaultHeightAboveEllipsoid(0); if (demdir != "no") demHandler->OpenDEMDirectory(demdir); @@ -98,7 +98,7 @@ int otbRPCSolverAdapterTest(int argc, char* argv[]) currentWgs84Point = fwd2dTransform->TransformPoint(currentPoint); - double height = otb::DEMHandler::Instance()->GetHeightAboveEllipsoid(currentWgs84Point); + double height = otb::OssimDEMHandler::Instance()->GetHeightAboveEllipsoid(currentWgs84Point); Point3DType current3DWgs84Point; current3DWgs84Point[0] = currentWgs84Point[0]; diff --git a/Modules/Applications/AppProjection/app/otbGenerateRPCSensorModel.cxx b/Modules/Applications/AppProjection/app/otbGenerateRPCSensorModel.cxx index ae0432c400e2f195840c0ea3937b9960e4ef91b9..7442f33305c6b92e10132cc7e6cc98fa5d2f1d21 100644 --- a/Modules/Applications/AppProjection/app/otbGenerateRPCSensorModel.cxx +++ b/Modules/Applications/AppProjection/app/otbGenerateRPCSensorModel.cxx @@ -29,6 +29,7 @@ #include "otbGenericRSTransform.h" #include "otbOGRDataSourceWrapper.h" #include "ogrsf_frmts.h" +#include "otbDEMHandler.h" namespace otb { diff --git a/Modules/Applications/AppProjection/app/otbRefineSensorModel.cxx b/Modules/Applications/AppProjection/app/otbRefineSensorModel.cxx index 4796181cba08ef9e5bb1fd86d7f796271173eb50..befd7c3773eaaf320db1bf8fa78aaa4a0fe87db8 100644 --- a/Modules/Applications/AppProjection/app/otbRefineSensorModel.cxx +++ b/Modules/Applications/AppProjection/app/otbRefineSensorModel.cxx @@ -29,6 +29,7 @@ #include "otbGenericRSTransform.h" #include "otbOGRDataSourceWrapper.h" #include "ogrsf_frmts.h" +#include "otbDEMHandler.h" namespace otb { @@ -165,6 +166,7 @@ private: lat = atof(line.substr(pos, nextpos).c_str()); z = otb::DEMHandler::Instance()->GetHeightAboveEllipsoid(lon, lat); + std::cout << "diff " << z << " " << otb::OssimDEMHandler::Instance()->GetHeightAboveEllipsoid(lon, lat) << std::endl;; otbAppLogDEBUG("Adding tie point x=" << x << ", y=" << y << ", z=" << z << ", lon=" << lon << ", lat=" << lat); diff --git a/Modules/Filtering/ImageManipulation/otb-module.cmake b/Modules/Filtering/ImageManipulation/otb-module.cmake index 06d3a62ac64327463c4d2b6729b4c4cbc5835bcf..82fae997aad1b336e04e7155b58ed95c7284da90 100644 --- a/Modules/Filtering/ImageManipulation/otb-module.cmake +++ b/Modules/Filtering/ImageManipulation/otb-module.cmake @@ -36,6 +36,7 @@ otb_module(OTBImageManipulation OTBObjectList OTBStreaming OTBTransform + OTBIOGDAL TEST_DEPENDS OTBDensity diff --git a/Modules/Filtering/Projection/test/otbGenericRSResampleImageFilter.cxx b/Modules/Filtering/Projection/test/otbGenericRSResampleImageFilter.cxx index 13fbd123fc4f37b83940f13096a6cea1a59a8289..4b9cce7b18ec575cdf2c994277d4d3c5356b70ae 100644 --- a/Modules/Filtering/Projection/test/otbGenericRSResampleImageFilter.cxx +++ b/Modules/Filtering/Projection/test/otbGenericRSResampleImageFilter.cxx @@ -30,6 +30,8 @@ #include "itkUnaryFunctorImageFilter.h" #include "otbDEMHandler.h" +#include "otbOssimDEMHandler.h" + #include "otbUnaryImageFunctorWithVectorImageFilter.h" #include "otbGenericRSResampleImageFilter.h" #include "otbComplexToIntensityImageFilter.h" @@ -128,10 +130,12 @@ int otbGenericRSResampleImageFilter(int argc, char* argv[]) if (atoi(argv[12]) == 1) // mode = no DEM { otb::DEMHandler::Instance()->SetDefaultHeightAboveEllipsoid(135.8); + otb::OssimDEMHandler::Instance()->SetDefaultHeightAboveEllipsoid(135.8); } else if ((atoi(argv[12]) == 2) || (atoi(argv[12]) == 3)) // mode = DEM SRTM || DEM GTIFF { otb::DEMHandler::Instance()->OpenDEMDirectory(argv[13]); + otb::OssimDEMHandler::Instance()->OpenDEMDirectory(argv[13]); } writer->SetInput(orthoRectifFilter->GetOutput()); diff --git a/Modules/Filtering/Projection/test/otbGenericRSTransformGenericTest.cxx b/Modules/Filtering/Projection/test/otbGenericRSTransformGenericTest.cxx index 9f01ebb03aa828e38f604aeaeb2f179e3eb36651..1f57dd1c2825112bf18e4959ceeab46bf43e8942 100644 --- a/Modules/Filtering/Projection/test/otbGenericRSTransformGenericTest.cxx +++ b/Modules/Filtering/Projection/test/otbGenericRSTransformGenericTest.cxx @@ -25,6 +25,7 @@ #include "itkEuclideanDistanceMetric.h" #include "otbSpatialReference.h" #include "otbGeographicalDistance.h" +#include "otbDEMHandler.h" typedef otb::Image<unsigned short> ImageType; typedef otb::ImageFileReader<ImageType> ReaderType; diff --git a/Modules/Filtering/Projection/test/otbTileImageFilterRSTransformTest.cxx b/Modules/Filtering/Projection/test/otbTileImageFilterRSTransformTest.cxx index 24ece3588e42a48cfc7eabf63ea734941ca5381d..98ee1deee06ceec423e575484b83c78bece2d8b1 100644 --- a/Modules/Filtering/Projection/test/otbTileImageFilterRSTransformTest.cxx +++ b/Modules/Filtering/Projection/test/otbTileImageFilterRSTransformTest.cxx @@ -24,6 +24,7 @@ #include "otbGeographicalDistance.h" #include "otbGenericRSTransform.h" #include <iomanip> +#include "otbDEMHandler.h" typedef otb::Image<unsigned int> ImageType; typedef otb::TileImageFilter<ImageType> TileImageFilterType; diff --git a/Modules/IO/IOGDAL/src/CMakeLists.txt b/Modules/IO/IOGDAL/src/CMakeLists.txt index f8c9342fdfdbbda40d4158ebb9f4335152ef0516..e47a84978705c8cf43684e3022c5b69963cde38d 100644 --- a/Modules/IO/IOGDAL/src/CMakeLists.txt +++ b/Modules/IO/IOGDAL/src/CMakeLists.txt @@ -27,6 +27,7 @@ set(OTBIOGDAL_SRC otbOGRIOHelper.cxx otbOGRVectorDataIO.cxx otbOGRVectorDataIOFactory.cxx + otbDEMHandler.cxx ) add_library(OTBIOGDAL ${OTBIOGDAL_SRC}) @@ -39,6 +40,7 @@ target_link_libraries(OTBIOGDAL ${OTBGDAL_LIBRARIES} ${OTBBoost_LIBRARIES} ${OTBOSSIMAdapters_LIBRARIES} + ${Boost_LIBRARIES} ) otb_module_target(OTBIOGDAL) diff --git a/Modules/Registration/DisparityMap/test/otbDisparityMapToDEMFilter.cxx b/Modules/Registration/DisparityMap/test/otbDisparityMapToDEMFilter.cxx index 91c959f7bed1aaccbf8215fcda8a5e92048a303c..e9ec0b208b591419f54e313d4dc7acbbc92f1048 100644 --- a/Modules/Registration/DisparityMap/test/otbDisparityMapToDEMFilter.cxx +++ b/Modules/Registration/DisparityMap/test/otbDisparityMapToDEMFilter.cxx @@ -26,6 +26,7 @@ #include "otbImageList.h" #include "otbVectorImageToImageListFilter.h" +#include "otbDEMHandler.h" const unsigned int Dimension = 2; typedef float PixelType; diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperElevationParametersHandler.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperElevationParametersHandler.cxx index 94997bd5a916143b4f6e70208daf233dd9a13f16..1e8f319c849c1ac800bbd959c28bfdb12ee1e165 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperElevationParametersHandler.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperElevationParametersHandler.cxx @@ -20,6 +20,8 @@ #include "otbWrapperElevationParametersHandler.h" #include "otbDEMHandler.h" +#include "otbOssimDEMHandler.h" + namespace otb { @@ -100,6 +102,8 @@ void ElevationParametersHandler::SetupDEMHandlerFromElevationParameters(const Ap { // Set default elevation otb::DEMHandler::Instance()->SetDefaultHeightAboveEllipsoid(GetDefaultElevation(app, key)); + otb::OssimDEMHandler::Instance()->SetDefaultHeightAboveEllipsoid(GetDefaultElevation(app, key)); + std::ostringstream oss; oss << "Elevation management: setting default height above ellipsoid to " << GetDefaultElevation(app, key) << " meters" << std::endl; @@ -112,6 +116,8 @@ void ElevationParametersHandler::SetupDEMHandlerFromElevationParameters(const Ap oss.str(""); oss << "Elevation management: using geoid file (" << GetGeoidFile(app, key) << ")" << std::endl; otb::DEMHandler::Instance()->OpenGeoidFile(GetGeoidFile(app, key)); + otb::OssimDEMHandler::Instance()->OpenGeoidFile(GetGeoidFile(app, key)); + app->GetLogger()->Info(oss.str()); } @@ -124,6 +130,7 @@ void ElevationParametersHandler::SetupDEMHandlerFromElevationParameters(const Ap oss.str(""); oss << "Elevation management: using DEM directory (" << demDirectory << ")" << std::endl; otb::DEMHandler::Instance()->OpenDEMDirectory(demDirectory); + otb::OssimDEMHandler::Instance()->OpenDEMDirectory(demDirectory); app->GetLogger()->Info(oss.str()); } else