From 14f8877f3e0bd1a3c0cbc17ea425a94b7c3ca502 Mon Sep 17 00:00:00 2001 From: Rashad Kanavath <rashad.kanavath@c-s.fr> Date: Tue, 10 Nov 2015 10:28:31 +0100 Subject: [PATCH] COMP: remove deprecated class RPCProjectionAdapter --- .../include/otbRPCProjectionAdapter.h | 93 ---------- .../Adapters/OSSIMAdapters/src/CMakeLists.txt | 3 +- .../src/otbRPCProjectionAdapter.cxx | 161 ------------------ 3 files changed, 1 insertion(+), 256 deletions(-) delete mode 100644 Modules/Adapters/OSSIMAdapters/include/otbRPCProjectionAdapter.h delete mode 100644 Modules/Adapters/OSSIMAdapters/src/otbRPCProjectionAdapter.cxx diff --git a/Modules/Adapters/OSSIMAdapters/include/otbRPCProjectionAdapter.h b/Modules/Adapters/OSSIMAdapters/include/otbRPCProjectionAdapter.h deleted file mode 100644 index 084fc51a21..0000000000 --- a/Modules/Adapters/OSSIMAdapters/include/otbRPCProjectionAdapter.h +++ /dev/null @@ -1,93 +0,0 @@ -/*========================================================================= - - Program: ORFEO Toolbox - Language: C++ - Date: $Date$ - Version: $Revision$ - - - Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. - See OTBCopyright.txt for details. - - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ -#ifndef __otbRPCProjectionAdapter_h -#define __otbRPCProjectionAdapter_h - -#include "vcl_deprecated_header.h" - -#include <vector> - -#include "itkObject.h" -#include "itkObjectFactory.h" - -#include "itkPoint.h" -#include "itkSize.h" - - -class ossimRpcProjection; - -namespace otb { - -class ImageKeywordlist; - -/** \class RPCProjectionAdapter - * \brief Wrapper class for the ossim Rpc projection - * - * This class is used inside the GCPsToRPCSensorModelImageFilter and should not - * be used directly outside. - * - * \deprecated Please use the RpcSolverAdapter class static methods instead - * - * \sa GCPsToRPCSensorModelImageFilter - * - * \ingroup OTBOSSIMAdapters - **/ - -class RPCProjectionAdapter: public itk::Object -{ -public: - /** Standard class typedefs. */ - typedef RPCProjectionAdapter Self; - typedef itk::Object Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - typedef itk::Point<double, 2> Point2DType; - typedef itk::Point<double, 3> Point3DType; - typedef std::pair<Point2DType, Point3DType> GCPType; - typedef std::vector<GCPType> GCPsContainerType; - - /** Method for creation through the object factory. */ - itkNewMacro(Self); - - /** Run-time type information (and related methods). */ - itkTypeMacro(RPCProjectionAdapter, itk::Object); - - void Solve(const GCPsContainerType& gcpContainer, - double& rmsError, ImageKeywordlist& otb_kwl); - void TransformPoint(double x, double y, double z, - double& lon, double& lat, double& h) const; - - void AddGroundRect( ImageKeywordlist& otb_kwl, - itk::Point<double, 2> orig, itk::Size<2> size); - -protected: - RPCProjectionAdapter(); - virtual ~RPCProjectionAdapter(); - -private: - RPCProjectionAdapter(const Self &); //purposely not implemented - void operator =(const Self&); //purposely not implemented - - /** RPC Projection */ - ossimRpcProjection* m_RpcProjection; -}; - -} // namespace otb - -#endif diff --git a/Modules/Adapters/OSSIMAdapters/src/CMakeLists.txt b/Modules/Adapters/OSSIMAdapters/src/CMakeLists.txt index b7942a9ed5..257cc6352e 100644 --- a/Modules/Adapters/OSSIMAdapters/src/CMakeLists.txt +++ b/Modules/Adapters/OSSIMAdapters/src/CMakeLists.txt @@ -6,7 +6,6 @@ set(OTBOSSIMAdapters_SRC otbPlatformPositionAdapter.cxx otbDEMConvertAdapter.cxx otbRPCSolverAdapter.cxx - otbRPCProjectionAdapter.cxx otbDateTimeAdapter.cxx otbMapProjectionAdapter.cxx otbFilterFunctionValues.cxx @@ -15,7 +14,7 @@ set(OTBOSSIMAdapters_SRC ) add_library(OTBOSSIMAdapters ${OTBOSSIMAdapters_SRC}) -target_link_libraries(OTBOSSIMAdapters +target_link_libraries(OTBOSSIMAdapters ${OTBGDAL_LIBRARIES} ${OTBCommon_LIBRARIES} ${OTBOssim_LIBRARIES} diff --git a/Modules/Adapters/OSSIMAdapters/src/otbRPCProjectionAdapter.cxx b/Modules/Adapters/OSSIMAdapters/src/otbRPCProjectionAdapter.cxx deleted file mode 100644 index 61950e8db3..0000000000 --- a/Modules/Adapters/OSSIMAdapters/src/otbRPCProjectionAdapter.cxx +++ /dev/null @@ -1,161 +0,0 @@ -/*========================================================================= - - Program: ORFEO Toolbox - Language: C++ - Date: $Date$ - Version: $Revision$ - - - Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. - See OTBCopyright.txt for details. - - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - -=========================================================================*/ - -#include "otbRPCProjectionAdapter.h" -#include "otbImageKeywordlist.h" - -#include "ossim/projection/ossimRpcProjection.h" -#include "ossim/projection/ossimProjection.h" -#include "ossim/projection/ossimRpcSolver.h" -#include "ossim/imaging/ossimImageGeometry.h" - -namespace otb -{ - -RPCProjectionAdapter::RPCProjectionAdapter() -{ - // Create projection - m_RpcProjection = new ossimRpcProjection(); -} - -RPCProjectionAdapter::~RPCProjectionAdapter() -{ - if (m_RpcProjection != NULL) - { - delete m_RpcProjection; - } -} - -void -RPCProjectionAdapter::TransformPoint(double x, double y, double z, - double& lon, double& lat, double& h) const -{ - if (m_RpcProjection == NULL) - { - lon = 0.0; - lat = 0.0; - h = 0.0; - return; - } - ossimDpt spoint( internal::ConvertToOSSIMFrame(x), - internal::ConvertToOSSIMFrame(y)); - ossimGpt gpoint; - gpoint.hgt = z; - - m_RpcProjection->lineSampleToWorld(spoint, gpoint); - lon = gpoint.lon; - lat = gpoint.lat; - h = gpoint.hgt; -} - -void -RPCProjectionAdapter::Solve(const GCPsContainerType& gcpContainer, - double& rmsError, ImageKeywordlist& otb_kwl) -{ - // TODO: for now, this is a simple transfer of what was done in the - // GCPsToRPCSensorModelImageFilter. We might find some way to improve that. - - // The vector where geo and sensor points are stored - std::vector<ossimDpt> sensorPoints; - std::vector<ossimGpt> geoPoints; - - // Temporary points variable - ossimDpt sensorPoint; - ossimGpt geoPoint; - - // Retrieve the additional GCPs - GCPsContainerType::const_iterator gcpIt; - for (gcpIt = gcpContainer.begin(); gcpIt != gcpContainer.end(); ++gcpIt) - { - // Fill sensor point - sensorPoint = ossimDpt( internal::ConvertToOSSIMFrame(gcpIt->first[0]), - internal::ConvertToOSSIMFrame(gcpIt->first[1])); - - // Fill geo point (lat, lon, elev) - geoPoint = ossimGpt(gcpIt->second[1], gcpIt->second[0], gcpIt->second[2]); - - // Add the sensor point to the list - sensorPoints.push_back(sensorPoint); - - // Add the geo point to the list - geoPoints.push_back(geoPoint); - } - - // Build the ossim rpc solver - ossimRefPtr<ossimRpcSolver> rpcSolver = new ossimRpcSolver(true, false); - - // Call the solve method - rpcSolver->solveCoefficients(sensorPoints, geoPoints); - - rmsError = rpcSolver->getRmsError(); - - // Retrieve the output RPC projection - ossimRefPtr<ossimRpcModel> rpcModel = dynamic_cast<ossimRpcModel*>(rpcSolver->createRpcModel()->getProjection()); - - // Compute projection - m_RpcProjection = dynamic_cast<ossimRpcProjection*>( - rpcSolver->createRpcProjection()->getProjection()); - - // Add spacings - rpcModel->setMetersPerPixel( m_RpcProjection->getMetersPerPixel() ); - - // Export the sensor model in an ossimKeywordlist - ossimKeywordlist geom_kwl; - rpcModel->saveState(geom_kwl); - - ossimKeywordlist kwl; - m_RpcProjection->saveState(kwl); - - // Build an otb::ImageKeywordList - otb_kwl.SetKeywordlist(geom_kwl); -} - - -void -RPCProjectionAdapter -::AddGroundRect( ImageKeywordlist& otb_kwl, - itk::Point<double, 2> orig, itk::Size<2> size) -{ - ossimGpt ul, ll, ur, lr; - // Upper left - ossimDpt imagePoint( internal::ConvertToOSSIMFrame(orig[0]), - internal::ConvertToOSSIMFrame(orig[1])); - m_RpcProjection->lineSampleToWorld(imagePoint, ul); - // Upper right - imagePoint.x += static_cast<double>(size[0]) - 1.0; - m_RpcProjection->lineSampleToWorld(imagePoint, ur); - // Lower right - imagePoint.y += static_cast<double>(size[0]) - 1.0; - m_RpcProjection->lineSampleToWorld(imagePoint, lr); - // Lower left - imagePoint.x += - static_cast<double>(size[0]) + 1.0; - m_RpcProjection->lineSampleToWorld(imagePoint, ll); - - - ossimKeywordlist geom_kwl; - otb_kwl.convertToOSSIMKeywordlist(geom_kwl); - - ossimRefPtr<ossimRpcModel> rpcModel = new ossimRpcModel; - rpcModel->loadState( geom_kwl ); - rpcModel->setGroundRect(ul, ur, lr, ll); - rpcModel->saveState(geom_kwl); - otb_kwl.SetKeywordlist(geom_kwl); -} - - -} // namespace otb -- GitLab