From b4efcdcecb77f1d7dde720e6bee9b893d4febed1 Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@orfeo-toolbox.org> Date: Wed, 18 Dec 2013 10:57:33 +0100 Subject: [PATCH] CLEAN: remove dependency to pqxx and remove all related classes OTB does not support anymore classes which use pqxx in version 4.0: Classes removed in OTBv4 are: - PostGISConnectionImplementation - PostGISTable - GISTableFunction - PostGISCreateTableTransactor - PostGISFromStringTransactor - PostGISQueryTransactor - TransactorGISTableFunction You can still access to these classes, related tests and examples in OTB 3.20. --- CMake/FindPqxx.cmake | 34 -- CMake/ImportPqxx.cmake | 17 - CMake/OTBConfig.cmake.in | 1 - CMake/UseOTB.cmake.in | 5 - CMake/otbIncludeDirectories.cmake | 5 - CMakeLists.txt | 2 - Code/CMakeLists.txt | 4 - Code/Common/CMakeLists.txt | 8 - .../otbPostGISConnectionImplementation.cxx | 79 ----- .../otbPostGISConnectionImplementation.h | 103 ------ Code/Common/otbPostGISTable.h | 137 -------- Code/Common/otbPostGISTable.txx | 320 ------------------ Code/GeospatialAnalysis/CMakeLists.txt | 25 -- Code/GeospatialAnalysis/foo.cxx | 1 - Code/GeospatialAnalysis/otbGISTableFunction.h | 108 ------ .../otbGISTableFunction.txx | 67 ---- .../otbPostGISCreateTableTransactor.cxx | 158 --------- .../otbPostGISCreateTableTransactor.h | 91 ----- .../otbPostGISFromStringTransactor.cxx | 77 ----- .../otbPostGISFromStringTransactor.h | 74 ---- .../otbPostGISQueryTransactor.cxx | 132 -------- .../otbPostGISQueryTransactor.h | 76 ----- .../otbTransactorGISTableFunction.h | 94 ----- Code/OBIA/CMakeLists.txt | 4 - Examples/CMakeLists.txt | 8 - Examples/GeospatialAnalysis/CMakeLists.txt | 41 --- .../GeospatialAnalysis/PostGISCreateTable.cxx | 107 ------ .../otbGeospatialAnalysisExamplesTests.cxx | 32 -- Testing/Code/CMakeLists.txt | 4 - Testing/Code/Common/CMakeLists.txt | 106 ------ ...GISConnectionImplementationConnectToDB.cxx | 44 --- .../otbPostGISConnectionImplementationNew.cxx | 34 -- ...ectionImplementationPerformTransaction.cxx | 68 ---- .../Code/GeospatialAnalysis/CMakeLists.txt | 41 --- .../otbGeospatialAnalysisTests.cxx | 31 -- ...bPostGISCreateTableTransactorAccessors.cxx | 50 --- .../otbPostGISCreateTableTransactorCreate.cxx | 67 ---- .../otbPostGISCreateTableTransactorNew.cxx | 31 -- .../otbPostGISFromStringTransactorNew.cxx | 31 -- Testing/Code/IO/CMakeLists.txt | 17 - Testing/Code/OBIA/CMakeLists.txt | 33 -- 41 files changed, 2367 deletions(-) delete mode 100644 CMake/FindPqxx.cmake delete mode 100644 CMake/ImportPqxx.cmake delete mode 100644 Code/Common/otbPostGISConnectionImplementation.cxx delete mode 100644 Code/Common/otbPostGISConnectionImplementation.h delete mode 100644 Code/Common/otbPostGISTable.h delete mode 100644 Code/Common/otbPostGISTable.txx delete mode 100644 Code/GeospatialAnalysis/CMakeLists.txt delete mode 100644 Code/GeospatialAnalysis/foo.cxx delete mode 100644 Code/GeospatialAnalysis/otbGISTableFunction.h delete mode 100644 Code/GeospatialAnalysis/otbGISTableFunction.txx delete mode 100644 Code/GeospatialAnalysis/otbPostGISCreateTableTransactor.cxx delete mode 100644 Code/GeospatialAnalysis/otbPostGISCreateTableTransactor.h delete mode 100644 Code/GeospatialAnalysis/otbPostGISFromStringTransactor.cxx delete mode 100644 Code/GeospatialAnalysis/otbPostGISFromStringTransactor.h delete mode 100644 Code/GeospatialAnalysis/otbPostGISQueryTransactor.cxx delete mode 100644 Code/GeospatialAnalysis/otbPostGISQueryTransactor.h delete mode 100644 Code/GeospatialAnalysis/otbTransactorGISTableFunction.h delete mode 100644 Examples/GeospatialAnalysis/CMakeLists.txt delete mode 100644 Examples/GeospatialAnalysis/PostGISCreateTable.cxx delete mode 100644 Examples/GeospatialAnalysis/otbGeospatialAnalysisExamplesTests.cxx delete mode 100644 Testing/Code/Common/otbPostGISConnectionImplementationConnectToDB.cxx delete mode 100644 Testing/Code/Common/otbPostGISConnectionImplementationNew.cxx delete mode 100644 Testing/Code/Common/otbPostGISConnectionImplementationPerformTransaction.cxx delete mode 100644 Testing/Code/GeospatialAnalysis/CMakeLists.txt delete mode 100644 Testing/Code/GeospatialAnalysis/otbGeospatialAnalysisTests.cxx delete mode 100644 Testing/Code/GeospatialAnalysis/otbPostGISCreateTableTransactorAccessors.cxx delete mode 100644 Testing/Code/GeospatialAnalysis/otbPostGISCreateTableTransactorCreate.cxx delete mode 100644 Testing/Code/GeospatialAnalysis/otbPostGISCreateTableTransactorNew.cxx delete mode 100644 Testing/Code/GeospatialAnalysis/otbPostGISFromStringTransactorNew.cxx diff --git a/CMake/FindPqxx.cmake b/CMake/FindPqxx.cmake deleted file mode 100644 index 066053b998..0000000000 --- a/CMake/FindPqxx.cmake +++ /dev/null @@ -1,34 +0,0 @@ -# - Find PQXX -# Find the native PQXX includes and library -# -# PQXX_FOUND - True if PQXX found. -# PQXX_INCLUDE_DIRS - where to find tinyxml.h, etc. -# PQXX_LIBRARIES - List of libraries when using PQXX. -# - -if( PQXX_INCLUDE_DIR ) - # Already in cache, be silent - set( PQXX_FIND_QUIETLY TRUE ) -endif() - -find_path( PQXX_INCLUDE_DIR pqxx/pqxx ) - -find_library( PQXX_LIBRARY - NAMES pqxx - PATH_SUFFIXES pqxx ) - -# handle the QUIETLY and REQUIRED arguments and set PQXX_FOUND to TRUE if -# all listed variables are TRUE -include( FindPackageHandleStandardArgs ) -FIND_PACKAGE_HANDLE_STANDARD_ARGS( PQXX DEFAULT_MSG PQXX_LIBRARY PQXX_INCLUDE_DIR ) - -mark_as_advanced( PQXX_INCLUDE_DIR PQXX_LIBRARY ) - -if(PQXX_FOUND) - set(PQXX_INCLUDE_DIRS ${PQXX_INCLUDE_DIR}) - set(PQXX_LIBRARIES ${PQXX_LIBRARY}) -else() - set(PQXX_INCLUDE_DIRS) - set(PQXX_LIBRARIES) -endif() - diff --git a/CMake/ImportPqxx.cmake b/CMake/ImportPqxx.cmake deleted file mode 100644 index 089789cce0..0000000000 --- a/CMake/ImportPqxx.cmake +++ /dev/null @@ -1,17 +0,0 @@ -message(STATUS "Importing Pqxx...") - -option(OTB_USE_PQXX "Use pqxx library (EXPERIMENTAL)." OFF) -mark_as_advanced(OTB_USE_PQXX) - -if(OTB_USE_PQXX) - find_package(Pqxx) - if(PQXX_FOUND) - message(STATUS "Activating Pqxx support") - else() - # Generate an error if no external Pqxx is available - message(FATAL_ERROR "Pqxx required but not found. " - "Turn OTB_USE_PQXX to OFF") - endif() -else() - message(STATUS "Disabling Pqxx support") -endif() diff --git a/CMake/OTBConfig.cmake.in b/CMake/OTBConfig.cmake.in index 90cfc437e5..f04f4c8fa7 100644 --- a/CMake/OTBConfig.cmake.in +++ b/CMake/OTBConfig.cmake.in @@ -78,7 +78,6 @@ set(GETTEXT_MSGMERGE_EXECUTABLE "@GETTEXT_MSGMERGE_EXECUTABLE@") set(GETTEXT_INCLUDE_DIR "@GETTEXT_INCLUDE_DIR@") set(GETTEXT_LIBRARY "@GETTEXT_LIBRARY@") set(GETTEXT_INTL_LIBRARY "@GETTEXT_INTL_LIBRARY@") -set(OTB_USE_PQXX "@OTB_USE_PQXX@") set(OTB_USE_PATENTED "@OTB_USE_PATENTED@") set(OTB_USE_LIBLAS "@OTB_USE_LIBLAS@") set(OTB_USE_EXTERNAL_LIBLAS "@OTB_USE_EXTERNAL_LIBLAS@") diff --git a/CMake/UseOTB.cmake.in b/CMake/UseOTB.cmake.in index 063dffee7a..e895218784 100644 --- a/CMake/UseOTB.cmake.in +++ b/CMake/UseOTB.cmake.in @@ -106,11 +106,6 @@ if(OTB_USE_LIBLAS AND OTB_USE_EXTERNAL_LIBLAS) include_directories(${LIBLAS_INCLUDE_DIRS}) endif() -if(OTB_USE_PQXX) - find_package(Pqxx REQUIRED) - include_directories(${PQXX_INCLUDE_DIRS}) -endif() - if(OTB_USE_EXTERNAL_LIBKML) find_package(LibKML REQUIRED) include_directories(${LIBKML_INCLUDE_DIRS}) diff --git a/CMake/otbIncludeDirectories.cmake b/CMake/otbIncludeDirectories.cmake index a06790d1f2..ad59053a62 100644 --- a/CMake/otbIncludeDirectories.cmake +++ b/CMake/otbIncludeDirectories.cmake @@ -78,11 +78,6 @@ if(WIN32) ${OTB_SOURCE_DIR}/Utilities/otbmsinttypes ) endif() -if(OTB_USE_PQXX) - set(OTB_INCLUDE_DIRS_BUILD_TREE ${OTB_INCLUDE_DIRS_BUILD_TREE} - ${OTB_SOURCE_DIR}/Code/GeospatialAnalysis ${PQXX_INCLUDE_DIR}) -endif() - if(OTB_USE_SIFTFAST) set(OTB_INCLUDE_DIRS_BUILD_TREE ${OTB_INCLUDE_DIRS_BUILD_TREE} ${OTB_SOURCE_DIR}/Utilities/otbsiftfast) diff --git a/CMakeLists.txt b/CMakeLists.txt index 03699ec883..5659098e4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -210,7 +210,6 @@ include(ImportITK) include(ImportJPEG2000) include(ImportFLTK) # depends on ImportGdal include(ImportCurl) -include(ImportPqxx) include(ImportBoost) include(ImportMapnik) # depends on ImportBoost include(ImportOpenThreads) @@ -391,7 +390,6 @@ if(NOT OTB_INSTALL_NO_DEVELOPMENT) ${OTB_SOURCE_DIR}/CMake/FindMercurial.cmake ${OTB_SOURCE_DIR}/CMake/FindMuParser.cmake ${OTB_SOURCE_DIR}/CMake/FindOpenThreads.cmake - ${OTB_SOURCE_DIR}/CMake/FindPqxx.cmake ${OTB_SOURCE_DIR}/CMake/FindTinyXML.cmake DESTINATION ${OTB_INSTALL_CMAKEMODULE_DIR} COMPONENT Development) diff --git a/Code/CMakeLists.txt b/Code/CMakeLists.txt index e2cfcfc0a0..e816f3aca3 100644 --- a/Code/CMakeLists.txt +++ b/Code/CMakeLists.txt @@ -28,10 +28,6 @@ if(OTB_USE_VISU_GUI) add_subdirectory(Visualization) endif() -if(OTB_USE_PQXX) - add_subdirectory(GeospatialAnalysis) -endif() - if(BUILD_APPLICATIONS) add_subdirectory(ApplicationEngine) add_subdirectory(Wrappers) diff --git a/Code/Common/CMakeLists.txt b/Code/Common/CMakeLists.txt index 88c4596d1e..1a0e51747b 100644 --- a/Code/Common/CMakeLists.txt +++ b/Code/Common/CMakeLists.txt @@ -6,10 +6,6 @@ if( NOT OTB_USE_MAPNIK ) list(REMOVE_ITEM OTBCommon_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/otbVectorDataStyle.cxx" ) endif() -if( NOT OTB_USE_PQXX ) - list(REMOVE_ITEM OTBCommon_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/otbPostGISConnectionImplementation.cxx" ) -endif() - add_library(OTBCommon ${OTBCommon_SRCS}) #Apparently not supported by opensolaris at least #set_target_properties(OTBCommon @@ -21,10 +17,6 @@ if(OTB_USE_MAPNIK) target_link_libraries(OTBCommon ${MAPNIK_LIBRARY} ${ICUUC_LIBRARY}) endif() -if(OTB_USE_PQXX) - target_link_libraries(OTBCommon ${PQXX_LIBRARY}) -endif() - if(OTB_I18N) target_link_libraries(OTBCommon ${GETTEXT_LIBRARY}) if(APPLE OR WIN32) diff --git a/Code/Common/otbPostGISConnectionImplementation.cxx b/Code/Common/otbPostGISConnectionImplementation.cxx deleted file mode 100644 index 8d81de00f4..0000000000 --- a/Code/Common/otbPostGISConnectionImplementation.cxx +++ /dev/null @@ -1,79 +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 "otbPostGISConnectionImplementation.h" -#include <sstream> -#include <sstream> -#include <assert.h> - -namespace otb -{ -PostGISConnectionImplementation::PostGISConnectionImplementation() -{ - m_Host = "localhost"; - m_DBName = ""; - m_User = "postgres"; - m_Password = ""; - m_Port = "5432"; - m_Options = ""; - -} - -PostGISConnectionImplementation::~PostGISConnectionImplementation() -{ - -} - -void PostGISConnectionImplementation::ConnectToDB() -{ - std::stringstream connstring; - - connstring << "host=" << m_Host << " dbname=" << m_DBName << " user=" << m_User; - - if (m_Password != "") connstring << " password=" << m_Password; - - if (m_Port != "") connstring << " port=" << m_Port; - - if (m_Options != "") connstring << " options=" << m_Options; - - if (!m_PostGISConnection) delete m_PostGISConnection; - - m_PostGISConnection = new BasicConnectionType(connstring.str().c_str()); - -} - -void PostGISConnectionImplementation::PerformTransaction(const TransactorType& theTransaction) const -{ - //assert(0); //do not use this method yet - //m_PostGISConnection->perform( theTransaction ); -} - -PostGISConnectionImplementation::BasicConnectionType* PostGISConnectionImplementation::GetConnection() const -{ - return m_PostGISConnection; -} - -void PostGISConnectionImplementation::PrintSelf(std::ostream& os, itk::Indent indent) const -{ - Superclass::PrintSelf(os, indent); - os << std::endl; - - os << "DB name: " << m_DBName << std::endl; - -} - -} // end namespace otb diff --git a/Code/Common/otbPostGISConnectionImplementation.h b/Code/Common/otbPostGISConnectionImplementation.h deleted file mode 100644 index 43dce1156e..0000000000 --- a/Code/Common/otbPostGISConnectionImplementation.h +++ /dev/null @@ -1,103 +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 __otbPostGISConnectionImplementation_h -#define __otbPostGISConnectionImplementation_h - -#include "otbGISConnectionImplementation.h" -#include <pqxx/pqxx> - -namespace otb -{ -/** \class PostGISConnectionImplementation - * \brief this class represents a connection to a PostGIS data base. - * - * - * - */ - -class ITK_EXPORT PostGISConnectionImplementation - : public GISConnectionImplementation<pqxx::transactor<pqxx::nontransaction> > -{ -public: - /** Standard class typedefs */ - typedef PostGISConnectionImplementation Self; - typedef pqxx::transactor<pqxx::nontransaction> PQXXTransactorType; - typedef GISConnectionImplementation<PQXXTransactorType> Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - /** Standard macros */ - itkNewMacro(Self); - itkTypeMacro(PostGISConnectionImplementation, GISConnectionImplementation); - - /** Typedefs */ - typedef pqxx::basic_connection<pqxx::connect_direct> BasicConnectionType; - typedef PQXXTransactorType TransactorType; - - /** Acessors */ - itkGetMacro(Host, std::string); - itkSetMacro(Host, std::string); - - itkGetMacro(DBName, std::string); - itkSetMacro(DBName, std::string); - - itkGetMacro(User, std::string); - itkSetMacro(User, std::string); - - itkGetMacro(Password, std::string); - itkSetMacro(Password, std::string); - - itkGetMacro(Port, std::string); - itkSetMacro(Port, std::string); - - itkGetMacro(Options, std::string); - itkSetMacro(Options, std::string); - - /** Using the connection */ - - void ConnectToDB(); - - void PerformTransaction(const TransactorType& theTransaction) const; - - BasicConnectionType* GetConnection() const; - -protected: - /** Constructor */ - PostGISConnectionImplementation(); - /** Destructor */ - virtual ~PostGISConnectionImplementation(); - /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const; - -private: - PostGISConnectionImplementation(const Self &); //purposely not implemented - void operator =(const Self&); //purposely not implemented - - std::string m_Host; - std::string m_DBName; - std::string m_User; - std::string m_Password; - std::string m_Port; - std::string m_Options; - - BasicConnectionType* m_PostGISConnection; - -}; -} // end namespace otb - -#endif diff --git a/Code/Common/otbPostGISTable.h b/Code/Common/otbPostGISTable.h deleted file mode 100644 index 2654de0b92..0000000000 --- a/Code/Common/otbPostGISTable.h +++ /dev/null @@ -1,137 +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 __otbPostGISTable_h -#define __otbPostGISTable_h - -#include "otbGISTable.h" -#include "otbCorrectPolygonFunctor.h" - -namespace otb -{ -/** \class PostGISTable - * \brief this class represents a table of a geospatial database (PostGIS). - * - * - * \sa GISTableFileReader - * \sa GISTableFileWriter - * - */ -template <class TConnectionImplementation, class TPrecision = double, unsigned int TSpatialDimension = 2> -class ITK_EXPORT PostGISTable - : public GISTable <TConnectionImplementation, TPrecision, TSpatialDimension> -{ -public: - /** Standard class typedefs */ - typedef PostGISTable Self; - typedef GISTable <TConnectionImplementation, TPrecision, TSpatialDimension> Superclass; - typedef itk::SmartPointer<Self> Pointer; - typedef itk::SmartPointer<const Self> ConstPointer; - - /** Standard macros */ - itkNewMacro(Self); - itkTypeMacro(PostGISTable, GISTable); - itkStaticConstMacro(Dimension, unsigned int, TSpatialDimension); - - /** Some convenient typedefs */ - typedef TConnectionImplementation ConnectionType; - typedef typename ConnectionType::Pointer ConnectionPointerType; - typedef itk::Point<TPrecision, TSpatialDimension> PointType; - typedef PolyLineParametricPathWithValue <TPrecision, TSpatialDimension> LineType; - typedef typename LineType::Pointer LinePointerType; - typedef Polygon <TPrecision> PolygonType; - typedef typename PolygonType::Pointer PolygonPointerType; - typedef typename PolygonType::ConstPointer PolygonConstPointerType; - typedef ObjectList<PolygonType> PolygonListType; - typedef typename PolygonListType::Pointer PolygonListPointerType; - typedef typename PolygonListType::ConstPointer PolygonListConstPointerType; - - /** typedefs for correct polygon */ - typedef otb::CorrectPolygonFunctor<PolygonType> CorrectFunctorType; - - /** Acessors */ - - itkGetConstMacro(TableName, std::string); - itkSetMacro(TableName, std::string); - - //itkGetConstObjectMacro(Connection, ConnectionType); - itkGetObjectMacro(Connection, ConnectionType); - itkSetObjectMacro(Connection, ConnectionType); - - /** Clear the table not implemented yet*/ - bool Clear(); - - /** Get attributes of the Table*/ //TODO implement - - /** Get srid of the geometric column*/ //TODO implement - //virtual - /** Init basic SQL command*/ - void InsertBegin(std::stringstream& sqlCmd); - /** Add Point content to the GIS Table*/ - void InsertPoint(const PointType& pt, const std::string& attribute = 0); - //void InsertMultiPoint(); - /** Add Polygons to the GIS Table (exterior and interior ring)*/ - void InsertPolygons(PolygonConstPointerType polygonExtRing, - PolygonListConstPointerType polygonListInteriorRing = 0, - const std::string& attribute = 0); - /** Add Line to the GIS Table*/ - void InsertLineString(LinePointerType l, const std::string& attribute = 0); - - /** Execute the sqlCmd which add geometric rows to the gis table*/ - void InsertGeometries(const std::string& sqlCmd); - /** Clean up SQL command*/ - void EraseLastChar(std::stringstream& sqlCmd); - /** Effective Creation of the table*/ - void CreateTable(bool dropExistingGISTable); - /** Get geometry column type Not implemented yet in progress */ - void getGeometryType(); - - /** Get string connection usable by OGR library*/ - std::string GetOGRStrConnection() const; - - /** Get const string connection methos temp*/ - //ConnectionPointerType GetConstConnection() const; - - /** Add an alpha numeric column to the table */ -// const std::string AddVarCharColumn(unsigned int size); - - /** Insert Alpha Numeric Data in the Car char column */ -// void AddStrDataToVarCharColumn(std::string data); -protected: - - /** Constructor */ - PostGISTable(); - /** Destructor */ - virtual ~PostGISTable() {} - /** PrintSelf method */ - void PrintSelf(std::ostream& os, itk::Indent indent) const; - -private: - PostGISTable(const Self &); //purposely not implemented - void operator =(const Self&); //purposely not implemented - - std::string m_TableName; - ConnectionPointerType m_Connection; - -}; -} // end namespace otb - -#ifndef OTB_MANUAL_INSTANTIATION -#include "otbPostGISTable.txx" -#endif - -#endif diff --git a/Code/Common/otbPostGISTable.txx b/Code/Common/otbPostGISTable.txx deleted file mode 100644 index 247db098be..0000000000 --- a/Code/Common/otbPostGISTable.txx +++ /dev/null @@ -1,320 +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 __otbPostGISTable_txx -#define __otbPostGISTable_txx - -#include "otbPostGISTable.h" -#include "itkPreOrderTreeIterator.h" -#include "otbMetaDataKey.h" - -#include <iostream> -#include <sstream> -#include <string> - -#include "otbPostGISFromStringTransactor.h" -#include "otbPostGISConnectionImplementation.h" -#include "otbPostGISCreateTableTransactor.h" - -namespace otb -{ - -template <class TConnectionImplementation, class TPrecision, unsigned int TSpatialDimension> -PostGISTable<TConnectionImplementation, TPrecision, TSpatialDimension> -::PostGISTable() -{ - m_Connection = ConnectionType::New(); - this->SetSrid(-1); -} - -template <class TConnectionImplementation, class TPrecision, unsigned int TSpatialDimension> -void -PostGISTable<TConnectionImplementation, TPrecision, TSpatialDimension> -::PrintSelf(std::ostream& os, itk::Indent indent) const -{ - Superclass::PrintSelf(os, indent); - os << std::endl; - - os << "Table name: " << m_TableName << std::endl; - -} - -template <class TConnectionImplementation, class TPrecision, unsigned int TSpatialDimension> -bool -PostGISTable<TConnectionImplementation, TPrecision, TSpatialDimension> -::Clear() -{ //TODO implementation - return true; -} - -template <class TConnectionImplementation, class TPrecision, unsigned int TSpatialDimension> -void -PostGISTable<TConnectionImplementation, TPrecision, TSpatialDimension> -::InsertBegin(std::stringstream& sqlCmd) -{ - sqlCmd.str(""); - sqlCmd << "INSERT INTO \"" << this->GetTableName() << "\" ( \"the_geom\" , \"genre\" ) VALUES ("; - sqlCmd << "GeometryFromText('"; -} -template <class TConnectionImplementation, class TPrecision, unsigned int TSpatialDimension> -void -PostGISTable<TConnectionImplementation, TPrecision, TSpatialDimension> -::InsertPoint(const PointType& pt, const std::string& attribute) -{ - std::stringstream sqlCmd; - this->InsertBegin(sqlCmd); - sqlCmd << "POINT( "; - for (unsigned int i = 0; i < TSpatialDimension; ++i) - { - sqlCmd << pt[i] << " "; - } - - //int this->GetSrid()=-1; - sqlCmd << ")'," << this->GetSrid() << ") ,'" << attribute << "');" << std::endl; - - //Execute the query - this->InsertGeometries(sqlCmd.str()); -} - -template <class TConnectionImplementation, class TPrecision, unsigned int TSpatialDimension> -void -PostGISTable<TConnectionImplementation, TPrecision, TSpatialDimension> -::InsertLineString(LinePointerType l, const std::string& attribute) -{ - std::stringstream sqlCmd; - this->InsertBegin (sqlCmd); - sqlCmd << "LINESTRING( "; - - typedef typename LineType::VertexListConstIteratorType VertexIterator; - VertexIterator itVertex = l->GetVertexList()->Begin(); - while (itVertex != l->GetVertexList()->End()) - { - for (unsigned int i = 0; i < TSpatialDimension; ++i) - { - sqlCmd << itVertex.Value()[i] << " "; - ++itVertex; - } - sqlCmd << ","; - } - //Erase the last ',' - EraseLastChar (sqlCmd); - - //int this->GetSrid()=-1; - - sqlCmd << ")'," << this->GetSrid() << ") ,'" << attribute << "');" << std::endl; - //Execute the query - this->InsertGeometries(sqlCmd.str()); - - /* Invalid (MULTI)Linestring */ - -} - -template <class TConnectionImplementation, class TPrecision, unsigned int TSpatialDimension> -void -PostGISTable<TConnectionImplementation, TPrecision, TSpatialDimension> -::InsertPolygons(PolygonConstPointerType polygonExtRing, - PolygonListConstPointerType polygonListInteriorRing, - const std::string& attribute) -{ - - /** correct polygon exterior ring */ - CorrectFunctorType correct; - PolygonPointerType correctPolygonExtRing = correct(polygonExtRing); - - std::stringstream sqlCmd; - this->InsertBegin (sqlCmd); - sqlCmd << "POLYGON( ( "; - //std::cout << "sqlcmd: " << sqlCmd.str() << std::endl; - typedef typename PolygonType::VertexListConstIteratorType VertexIterator; - VertexIterator itVertex = correctPolygonExtRing->GetVertexList()->Begin(); - //std::cout << "sizeof ext poly: " << polygonExtRing->GetVertexList()->Size()<< std::endl; - while (itVertex != correctPolygonExtRing->GetVertexList()->End()) - { - //polygon->line_to(itVertex.Value()[0], m_SensorModelFlip*itVertex.Value()[1]); - //std::cout << "vertex: " << itVertex.Value()<< std::endl; - for (unsigned int i = 0; i < TSpatialDimension; ++i) - { - sqlCmd << itVertex.Value()[i] << " "; - //++itVertex; - } - sqlCmd << ","; - ++itVertex; - } - //Erase the last ',' - //std::cout << "avt erase : " << sqlCmd.str() << std::endl; - EraseLastChar (sqlCmd); - //std::cout << "apres arase " << sqlCmd.str() << std::endl; - sqlCmd << "),"; - //std::cout << "ext polygon: " << sqlCmd.str() << std::endl; - //Add interior polygons - if (!polygonListInteriorRing.IsNull()) - { - - //get holes - //sqlCmd << ","; - typedef typename PolygonListType::ConstIterator PolygonListConstIteratorType; - for (PolygonListConstIteratorType itPolygonList = polygonListInteriorRing->Begin(); - itPolygonList != polygonListInteriorRing->End(); - ++itPolygonList) - { - /** correct current polygon interior ring */ - CorrectFunctorType correctCurrentInt; - PolygonPointerType correctCurrentPolygonIntRing = correctCurrentInt(itPolygonList.Get()); - - sqlCmd << "("; - - itVertex = correctCurrentPolygonIntRing->GetVertexList()->Begin(); - while (itVertex != correctCurrentPolygonIntRing->GetVertexList()->End()) - { - //polygon->line_to(itVertex.Value()[0], m_SensorModelFlip*itVertex.Value()[1]); - for (unsigned int i = 0; i < TSpatialDimension; ++i) - { - sqlCmd << itVertex.Value()[i] << " "; - ++itVertex; - } - sqlCmd << ","; - ++itVertex; - } - //Erase the last ',' - EraseLastChar (sqlCmd); - - sqlCmd << "),"; - } - //std::cout << "int polygon: " << sqlCmd.str() << std::endl; - - } - //Erase the last ',' - EraseLastChar (sqlCmd); - - //int this->GetSrid()=-1; - - sqlCmd << ")'," << this->GetSrid() << ") ,'" << attribute << "');" << std::endl; - //std::cout << "sqlcmd polygon: " << sqlCmd.str() << std::endl; - //Insert the geometry - this->InsertGeometries(sqlCmd.str()); - //std::cout << "geometries!!" << std::endl; -} - -template <class TConnectionImplementation, class TPrecision, unsigned int TSpatialDimension> -void -PostGISTable<TConnectionImplementation, TPrecision, TSpatialDimension> -::InsertGeometries(const std::string& sqlCmd) -{ - typedef otb::PostGISFromStringTransactor TransactorType; - TransactorType myStringTransactor; - //std::cout << "transactor string" << sqlCmd<< std::endl; - myStringTransactor.SetTransactionString(sqlCmd); - //this->GetConnection()->ConnectToDB(); - this->GetConnection()->GetConnection()->perform(myStringTransactor); -// this->GetConnection()->PerformTransaction( myStringTransactor ); -//myStringTransactor ( *( this->GetConnection()->GetConnection() ) ); -} - -template <class TConnectionImplementation, class TPrecision, unsigned int TSpatialDimension> -void -PostGISTable<TConnectionImplementation, TPrecision, TSpatialDimension> -::EraseLastChar(std::stringstream& sqlCmd) -{ - std::string EraseCmd = sqlCmd.str(); - EraseCmd.erase(EraseCmd.length() - 1); - sqlCmd.str(""); - sqlCmd << EraseCmd; - -} - -template <class TConnectionImplementation, class TPrecision, unsigned int TSpatialDimension> -void -PostGISTable<TConnectionImplementation, TPrecision, TSpatialDimension> -::CreateTable(bool dropExistingGISTable) -{ - typedef otb::PostGISCreateTableTransactor TransactorType; - - //Instantiation - TransactorType myTransactor; - - myTransactor.SetDimension(TSpatialDimension); - - //std::string name = "mytable"; - myTransactor.SetTableName(this->GetTableName()); - - //int this->GetSrid() = -1; - myTransactor.SetSRID(this->GetSrid()); - - myTransactor.SetRemoveExistingTable(dropExistingGISTable); - - this->GetConnection()->GetConnection()->perform(myTransactor); -//this->GetConnection()->PerformTransaction( myTransactor ); -} - -template <class TConnectionImplementation, class TPrecision, unsigned int TSpatialDimension> -void -PostGISTable<TConnectionImplementation, TPrecision, TSpatialDimension> -::getGeometryType() -{ - //the geomtric column name is the_geom - std::string query = "SELECT DISTINCT geometrytype(\"the_geom\") " - "FROM \"" + this->GetTableName() + "\" WHERE NOT geometrytype(\"the_geom\") IS NULL"; - - typedef otb::PostGISFromStringTransactor TransactorType; - TransactorType myStringTransactor; - //std::cout << "transactor string" << sqlCmd<< std::endl; - myStringTransactor.SetTransactionString(query); - //this->GetConnection()->ConnectToDB(); - - //typedef pqxx::result ResultType; - //ResultType R = this->GetConnection()->GetConnection()->perform( myStringTransactor ); - -} - -template <class TConnectionImplementation, class TPrecision, unsigned int TSpatialDimension> -std::string -PostGISTable<TConnectionImplementation, TPrecision, TSpatialDimension> -::GetOGRStrConnection() const -{ - //std::cout << "getOGR: " << m_Connection << std::endl; - std::string connectionSTR = ""; - connectionSTR += "PG:"; - - connectionSTR += "dbname='"; - connectionSTR += m_Connection->GetDBName(); - connectionSTR += "' "; - connectionSTR += "host='"; - connectionSTR += m_Connection->GetHost(); - connectionSTR += "' "; - connectionSTR += "port='"; - connectionSTR += m_Connection->GetPort(); - connectionSTR += "' "; - connectionSTR += "user='"; - connectionSTR += m_Connection->GetUser(); - connectionSTR += "' "; - connectionSTR += "password='"; - connectionSTR += m_Connection->GetPassword(); - connectionSTR += "' "; - if (!m_TableName.empty()) - { - connectionSTR += "tables="; - connectionSTR += m_TableName; -// connectionSTR += "' "; - } - - otbGenericMsgDebugMacro(<< "OGR connection string " << connectionSTR); - - return connectionSTR; -} -} // end namespace otb - -#endif diff --git a/Code/GeospatialAnalysis/CMakeLists.txt b/Code/GeospatialAnalysis/CMakeLists.txt deleted file mode 100644 index b217c42413..0000000000 --- a/Code/GeospatialAnalysis/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -# Sources of non-templated classes. - -file(GLOB OTBGeospatialAnalysis_SRCS "*.cxx" ) - - -add_library(OTBGeospatialAnalysis ${OTBGeospatialAnalysis_SRCS}) -target_link_libraries(OTBGeospatialAnalysis OTBCommon ${PQXX_LIBRARY}) -if(OTB_LIBRARY_PROPERTIES) - set_target_properties(OTBGeospatialAnalysis PROPERTIES ${OTB_LIBRARY_PROPERTIES}) -endif() - -if(NOT OTB_INSTALL_NO_LIBRARIES) - install(TARGETS OTBGeospatialAnalysis - RUNTIME DESTINATION ${OTB_INSTALL_BIN_DIR} COMPONENT RuntimeLibraries - LIBRARY DESTINATION ${OTB_INSTALL_LIB_DIR} COMPONENT RuntimeLibraries - ARCHIVE DESTINATION ${OTB_INSTALL_LIB_DIR} COMPONENT Development) -endif() - -if(NOT OTB_INSTALL_NO_DEVELOPMENT) - file(GLOB __files1 "${CMAKE_CURRENT_SOURCE_DIR}/*.h") - file(GLOB __files2 "${CMAKE_CURRENT_SOURCE_DIR}/*.txx") - install(FILES ${__files1} ${__files2} - DESTINATION ${OTB_INSTALL_INCLUDE_DIR}/GeospatialAnalysis - COMPONENT Development) -endif() diff --git a/Code/GeospatialAnalysis/foo.cxx b/Code/GeospatialAnalysis/foo.cxx deleted file mode 100644 index 8b13789179..0000000000 --- a/Code/GeospatialAnalysis/foo.cxx +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Code/GeospatialAnalysis/otbGISTableFunction.h b/Code/GeospatialAnalysis/otbGISTableFunction.h deleted file mode 100644 index f8094ce8b2..0000000000 --- a/Code/GeospatialAnalysis/otbGISTableFunction.h +++ /dev/null @@ -1,108 +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 __otbGISTableFunction_h -#define __otbGISTableFunction_h - -#include "itkFunctionBase.h" -#include "otbGISTable.h" - -namespace otb -{ - -/** \class GISTableFunction - * \brief Evaluates a const transaction on a GISTable - * - * GISTableFunction is a baseclass for all objects that evaluate - * a const transaction on a GISTable. - * - * The input table is set via method SetInputTable(). - * - * - * \sa GISTable - * \sa GISConnection - * - * \ingroup GISTableFunctions - */ -template < - class TInputTable, - class TOutput - > -class ITK_EXPORT GISTableFunction : - public FunctionBase<TInputTable, - TOutput> -{ -public: - /** Dimension underlying input table. */ - itkStaticConstMacro(TableDimension, unsigned int, - TInputTable::TSpatialDimension); - - /** Standard class typedefs. */ - typedef GISTableFunction Self; - typedef FunctionBase< - TInputTable, - TOutput> Superclass; - typedef SmartPointer<Self> Pointer; - typedef SmartPointer<const Self> ConstPointer; - - /** Run-time type information (and related methods). */ - itkTypeMacro(GISTableFunction, FunctionBase); - - /** InputTableType typedef support. */ - typedef TInputTable InputTableType; - - /** Connection typedef support */ - typedef typename InputTableType::ConnectionType ConnectionType; - - /** InputTablePointer typedef support */ - typedef typename InputTableType::ConstPointer InputTableConstPointer; - - /** OutputType typedef support. */ - typedef TOutput OutputType; - - /** Set the input table. */ - virtual void SetInputTable(const InputTableType* ptr); - - /** Get the input Table. */ - const InputTableType * GetInputTable() const - { return m_Table.GetPointer(); } - - /** Evaluate the function. - * Subclasses must provide this method. */ - virtual TOutput Evaluate() const = 0; - -protected: - GISTableFunction(); - virtual ~GISTableFunction() {} - void PrintSelf(std::ostream& os, Indent indent) const; - - /** Const pointer to the input table. */ - InputTableConstPointer m_Table; - -private: - GISTableFunction(const Self &); //purposely not implemented - void operator =(const Self&); //purposely not implemented - -}; - -} // end namespace otb - -#if OTB_MANUAL_INSTANTIATION -# include "itkGISTableFunction.txx" -#endif - -#endif diff --git a/Code/GeospatialAnalysis/otbGISTableFunction.txx b/Code/GeospatialAnalysis/otbGISTableFunction.txx deleted file mode 100644 index d0e9764bfd..0000000000 --- a/Code/GeospatialAnalysis/otbGISTableFunction.txx +++ /dev/null @@ -1,67 +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 __otbGISTableFunction_txx -#define __otbGISTableFunction_txx - -#include "otbGISTableFunction.h" - -namespace otb -{ - -/** - * Constructor - */ -template <class TInputTable, class TOutput> -GISTableFunction<TInputTable, TOutput> -::GISTableFunction() -{ - m_Table = NULL; -} - -/** - * Standard "PrintSelf" method - */ -template <class TInputTable, class TOutput> -void -GISTableFunction<TInputTable, TOutput> -::PrintSelf( - std::ostream& os, - Indent indent) const -{ - Superclass::PrintSelf(os, indent); - os << indent << "InputTable: " << m_Table.GetPointer() << std::endl; - -} - -/** - * Initialize by setting the input table - */ -template <class TInputTable, class TOutput> -void -GISTableFunction<TInputTable, TOutput> -::SetInputTable( - const InputTableType* ptr) -{ - // set the input table - m_Table = ptr; - -} - -} // end namespace itk - -#endif diff --git a/Code/GeospatialAnalysis/otbPostGISCreateTableTransactor.cxx b/Code/GeospatialAnalysis/otbPostGISCreateTableTransactor.cxx deleted file mode 100644 index 7ccaa1955a..0000000000 --- a/Code/GeospatialAnalysis/otbPostGISCreateTableTransactor.cxx +++ /dev/null @@ -1,158 +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 "otbPostGISCreateTableTransactor.h" -#include <sstream> -#include <cassert> - -#include "otbMacro.h" - -namespace otb -{ - -PostGISCreateTableTransactor::PostGISCreateTableTransactor() : PostGISCreateTableTransactor::Superclass("CreateTable") -{ - m_RemoveExistingTable = false; -} - -PostGISCreateTableTransactor::PostGISCreateTableTransactor(const PostGISCreateTableTransactor& pgt) - : PostGISCreateTableTransactor::Superclass("CreateTable") -{ - m_TableName = pgt.GetTableName(); - m_SRID = pgt.GetSRID(); - m_Dimension = pgt.GetDimension(); - m_RemoveExistingTable = pgt.GetRemoveExistingTable(); -} - -PostGISCreateTableTransactor & PostGISCreateTableTransactor::operator =(const PostGISCreateTableTransactor& pgt) -throw() -{ - m_TableName = pgt.GetTableName(); - m_SRID = pgt.GetSRID(); - m_Dimension = pgt.GetDimension(); - m_RemoveExistingTable = pgt.GetRemoveExistingTable(); - return *this; -} - -void PostGISCreateTableTransactor::operator ()(pqxx::nontransaction& T) -{ - - if (m_RemoveExistingTable) - { - std::stringstream dropCommand; - - //dropCommand << "DROP TABLE " << m_TableName; - dropCommand << "DROP TABLE IF EXISTS " << m_TableName << " CASCADE"; - - otbGenericMsgDebugMacro(<< "Drop Command " << dropCommand.str()); - - m_Result = T.exec(dropCommand.str()); - } - - std::stringstream createCommand; - - createCommand << "CREATE TABLE " << m_TableName - << " (id serial PRIMARY KEY, genre TEXT);"; - - otbGenericMsgDebugMacro(<< "Create Command " << createCommand.str()); - m_Result = T.exec(createCommand.str()); - - std::stringstream addGeometryCommand; - - addGeometryCommand << "SELECT AddGeometryColumn( '" << m_TableName << - "', 'the_geom', " << m_SRID << ", 'GEOMETRY'," << m_Dimension << " );"; - - m_Result = T.exec(addGeometryCommand.str()); - - - /** creation index GIST */ - //FIXME not working yet -// std::stringstream addGISTIndexCommand; -// -// addGISTIndexCommand << "CREATE INDEX idx_" << m_TableName << "_the_geom ON " << m_TableName << -// " USING gist( the_geom );"; -// -// otbGenericMsgDebugMacro(<< "Create Command " << addGISTIndexCommand.str()); -// -// m_Result = T.exec(addGISTIndexCommand.str()); -} - -void PostGISCreateTableTransactor::on_commit() -{ - otbMsgDevMacro( "\t Table is created \t" ); - //T.exec -} - -std::string PostGISCreateTableTransactor::GetTableName() const -{ - return m_TableName; -} - -void PostGISCreateTableTransactor::SetTableName(const std::string& aName) -{ - m_TableName = aName; -} - -int PostGISCreateTableTransactor::GetSRID() const -{ - return m_SRID; -} - -void PostGISCreateTableTransactor::SetSRID(int aSRID) -{ - m_SRID = aSRID; -} - -unsigned short PostGISCreateTableTransactor::GetDimension() const -{ - return m_Dimension; -} - -void PostGISCreateTableTransactor::SetDimension(unsigned short aDim) -{ - m_Dimension = aDim; -} - -void PostGISCreateTableTransactor::SetRemoveExistingTable(bool val) -{ - m_RemoveExistingTable = val; -} - -bool PostGISCreateTableTransactor::GetRemoveExistingTable() const -{ - return m_RemoveExistingTable; -} - -PostGISCreateTableTransactor::ResultType PostGISCreateTableTransactor::GetResult() const -{ - return m_Result; -} - -void PostGISCreateTableTransactor::CreateGISTIndex(pqxx::nontransaction& T) -{ - /* - std::stringstream addGISTIndexCmd; - - addGISTIndexCmd << "CREATE INDEX idx_" << m_TableName << "_the_geom ON " << m_TableName << " USING gist( the_geom );"; - - otbGenericMsgDebugMacro(<<"Create Command " << addGISTIndexCmd.str()); - T.exec(addGISTIndexCmd.str()); - */ - assert(0); -} - -} // end namespace otb diff --git a/Code/GeospatialAnalysis/otbPostGISCreateTableTransactor.h b/Code/GeospatialAnalysis/otbPostGISCreateTableTransactor.h deleted file mode 100644 index 2010f383d6..0000000000 --- a/Code/GeospatialAnalysis/otbPostGISCreateTableTransactor.h +++ /dev/null @@ -1,91 +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 __otbPostGISCreateTableTransactor_h -#define __otbPostGISCreateTableTransactor_h - -#include <pqxx/pqxx> -#include <string> - -namespace otb -{ - -/** \class PostGISCreateTableTransactor - * \brief PQXX-based transactor for creating PostGIS tables - * - * - * The copy constructor and the "=" operator have to be defined for - * deep copy, so that libpqxx is able to get the values set for the - * class variables. - * - * - * \ingroup GISTransactors - */ - -class PostGISCreateTableTransactor : - public pqxx::transactor<pqxx::nontransaction> -{ - -public: - - typedef pqxx::result ResultType; - - typedef pqxx::transactor<pqxx::nontransaction> Superclass; - - PostGISCreateTableTransactor(); - - PostGISCreateTableTransactor(const PostGISCreateTableTransactor& pgt); - - PostGISCreateTableTransactor& operator =(const PostGISCreateTableTransactor& pgt) - throw(); - - void operator ()(pqxx::nontransaction& T); - - void on_commit(); - - std::string GetTableName() const; - - void SetTableName(const std::string& aName); - - int GetSRID() const; - - void SetSRID(int aSRID); - - unsigned short GetDimension() const; - - void SetDimension(unsigned short aDim); - - void SetRemoveExistingTable(bool val); - - bool GetRemoveExistingTable() const; - - ResultType GetResult() const; - - void CreateGISTIndex(pqxx::nontransaction& T); - -protected: - - ResultType m_Result; - std::string m_TableName; - int m_SRID; - unsigned short m_Dimension; - bool m_RemoveExistingTable; -}; - -} // end namespace otb - -#endif diff --git a/Code/GeospatialAnalysis/otbPostGISFromStringTransactor.cxx b/Code/GeospatialAnalysis/otbPostGISFromStringTransactor.cxx deleted file mode 100644 index 107357da64..0000000000 --- a/Code/GeospatialAnalysis/otbPostGISFromStringTransactor.cxx +++ /dev/null @@ -1,77 +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 "otbPostGISFromStringTransactor.h" -#include <sstream> -#include "otbMacro.h" - -namespace otb -{ - -PostGISFromStringTransactor::PostGISFromStringTransactor() : PostGISFromStringTransactor::Superclass( - "FromStringTransactor") -{ - m_TransactionString = ""; -} - -PostGISFromStringTransactor::PostGISFromStringTransactor(const PostGISFromStringTransactor& pgt) - : PostGISFromStringTransactor::Superclass("FromStringTransactor") -{ - m_TransactionString = pgt.GetTransactionString(); -} - -PostGISFromStringTransactor & PostGISFromStringTransactor::operator =(const PostGISFromStringTransactor& pgt) -throw() -{ - m_TransactionString = pgt.GetTransactionString(); - return *this; -} - -void PostGISFromStringTransactor::operator ()(pqxx::nontransaction& T) -{ - - if (m_TransactionString != "") - { - - otbGenericMsgDebugMacro(<< "Transaction Command " << m_TransactionString); - - m_Result = T.exec(m_TransactionString); - } - -} - -void PostGISFromStringTransactor::on_commit() -{ - otbMsgDevMacro( "\t Transaction \t\n\t" << m_TransactionString ); -} - -std::string PostGISFromStringTransactor::GetTransactionString() const -{ - return m_TransactionString; -} - -void PostGISFromStringTransactor::SetTransactionString(const std::string& aName) -{ - m_TransactionString = aName; -} - -PostGISFromStringTransactor::ResultType PostGISFromStringTransactor::GetResult() const -{ - return m_Result; -} - -} // end namespace otb diff --git a/Code/GeospatialAnalysis/otbPostGISFromStringTransactor.h b/Code/GeospatialAnalysis/otbPostGISFromStringTransactor.h deleted file mode 100644 index 06480e6c5a..0000000000 --- a/Code/GeospatialAnalysis/otbPostGISFromStringTransactor.h +++ /dev/null @@ -1,74 +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 __otbPostGISFromStringTransactor_h -#define __otbPostGISFromStringTransactor_h - -#include <pqxx/pqxx> -#include <string> - -namespace otb -{ - -/** \class PostGISFromStringTransactor - * \brief PQXX-based transactor for executing PostGIS queries. - * - * - * The copy constructor and the "=" operator have to be defined for - * deep copy, so that libpqxx is able to get the values set for the - * class variables. - * - * - * \ingroup GISTransactors - */ - -class PostGISFromStringTransactor : - public pqxx::transactor<pqxx::nontransaction> -{ - -public: - - typedef pqxx::result ResultType; - - typedef pqxx::transactor<pqxx::nontransaction> Superclass; - - PostGISFromStringTransactor(); - - PostGISFromStringTransactor(const PostGISFromStringTransactor& pgt); - - PostGISFromStringTransactor& operator =(const PostGISFromStringTransactor& pgt) - throw(); - - void operator ()(pqxx::nontransaction& T); - - void on_commit(); - - std::string GetTransactionString() const; - - void SetTransactionString(const std::string& trans); - - ResultType GetResult() const; - -protected: - - ResultType m_Result; - std::string m_TransactionString; -}; - -} // end namespace otb - -#endif diff --git a/Code/GeospatialAnalysis/otbPostGISQueryTransactor.cxx b/Code/GeospatialAnalysis/otbPostGISQueryTransactor.cxx deleted file mode 100644 index c6f964dedd..0000000000 --- a/Code/GeospatialAnalysis/otbPostGISQueryTransactor.cxx +++ /dev/null @@ -1,132 +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 "otbPostGISQueryTransactor.h" -#include <sstream> -#include "otbMacro.h" - -namespace otb -{ - -PostGISQueryTransactor::PostGISQueryTransactor() : PostGISQueryTransactor::Superclass() -{ - m_ViewName = "default_view"; -} - -PostGISQueryTransactor::PostGISQueryTransactor(const PostGISQueryTransactor& pgt) - : PostGISQueryTransactor::Superclass() -{ - m_TransactionString = pgt.GetTransactionString(); - m_ViewName = pgt.GetViewName(); -} - -PostGISQueryTransactor & PostGISQueryTransactor::operator =(const PostGISQueryTransactor& pgt) -throw() -{ - m_TransactionString = pgt.GetTransactionString(); - m_ViewName = pgt.GetViewName(); - return *this; -} - -void PostGISQueryTransactor::operator ()(pqxx::nontransaction& T) -{ - - if (m_RemoveExistingView) - { - std::stringstream dropCommand; - - //dropCommand << "DROP TABLE " << m_ViewName; - dropCommand << "DROP VIEW IF EXISTS " << m_ViewName; - - otbGenericMsgDebugMacro(<< "Drop Command " << dropCommand.str()); - - m_Result = T.exec(dropCommand.str()); - } - - std::stringstream createCommand; - - createCommand << "CREATE VIEW " << m_ViewName - << " AS " << m_TransactionString; - - otbGenericMsgDebugMacro(<< "Create Command " << createCommand.str()); - m_Result = T.exec(createCommand.str()); - -} - -/* -void PostGISQueryTransactor::on_commit() -{ - std::cout << "\t Transaction \t" << std::endl; - std::cout << "\t "<< m_TransactionString << std::endl; - -} - -std::string PostGISQueryTransactor::GetTransactionString() const -{ - return m_TransactionString; -} - -void PostGISQueryTransactor::SetTransactionString(const std::string& aName) -{ - m_TransactionString = aName; -} -*/ -std::string PostGISQueryTransactor::GetViewName() const -{ - return m_ViewName; -} - -void PostGISQueryTransactor::SetRemoveExistingView(bool val) -{ - m_RemoveExistingView = val; -} - -bool PostGISQueryTransactor::GetRemoveExistingView() const -{ - return m_RemoveExistingView; -} - -void PostGISQueryTransactor::SetViewName(const std::string& aName) -{ - m_ViewName = aName; -} -/* -void PostGISQueryTransactor::CreateView(pqxx::nontransaction &T) -{ - if(m_RemoveExistingView) - { - std::stringstream dropCommand; - - //dropCommand << "DROP TABLE " << m_ViewName; - dropCommand << "DROP VIEW IF EXISTS " << m_ViewName; - - otbGenericMsgDebugMacro(<<"Drop Command " << dropCommand.str()); - - m_Result = T.exec(dropCommand.str()); - } - - std::stringstream createCommand; - - createCommand << "CREATE VIEW "<< m_ViewName - <<" AS " << m_TransactionString; - - otbGenericMsgDebugMacro(<<"Create Command " << createCommand.str()); - m_Result = T.exec(createCommand.str()); - -} -*/ -} // end namespace otb diff --git a/Code/GeospatialAnalysis/otbPostGISQueryTransactor.h b/Code/GeospatialAnalysis/otbPostGISQueryTransactor.h deleted file mode 100644 index 4912104acd..0000000000 --- a/Code/GeospatialAnalysis/otbPostGISQueryTransactor.h +++ /dev/null @@ -1,76 +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 __otbPostGISQueryTransactor_h -#define __otbPostGISQueryTransactor_h - -//#include <pqxx/pqxx> -#include <string> - -#include "otbPostGISFromStringTransactor.h" - -namespace otb -{ - -/** \class PostGISQueryTransactor - * \brief PQXX-based transactor for executing PostGIS queries. - * - * - * The copy constructor and the "=" operator have to be defined for - * deep copy, so that libpqxx is able to get the values set for the - * class variables. - * - * - * \ingroup GISTransactors - */ - -class PostGISQueryTransactor : - public otb::PostGISFromStringTransactor -{ - -public: - - typedef PostGISFromStringTransactor Superclass; - //typedef pqxx::transactor<pqxx::nontransaction> Superclass; - //typedef pqxx::result ResultType; - PostGISQueryTransactor(); - - PostGISQueryTransactor(const PostGISQueryTransactor& pgt); - - PostGISQueryTransactor& operator =(const PostGISQueryTransactor& pgt) - throw(); - - void operator ()(pqxx::nontransaction& T); - - void SetRemoveExistingView(bool val); - - bool GetRemoveExistingView() const; - - void SetViewName(const std::string& aName); - - std::string GetViewName() const; - - //void CreateView(pqxx::nontransaction &T); - -protected: - std::string m_ViewName; - bool m_RemoveExistingView; -}; - -} // end namespace otb - -#endif diff --git a/Code/GeospatialAnalysis/otbTransactorGISTableFunction.h b/Code/GeospatialAnalysis/otbTransactorGISTableFunction.h deleted file mode 100644 index 7a4bbd4dd6..0000000000 --- a/Code/GeospatialAnalysis/otbTransactorGISTableFunction.h +++ /dev/null @@ -1,94 +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 __otbTransactorGISTableFunction_h -#define __otbTransactorGISTableFunction_h - -#include "otbGISTableFunction.h" - -namespace otb -{ - -/** \class TransactorGISTableFunction - * \brief Evaluates a const transaction on a GISTable using a transactor - * - * TransactorGISTableFunction is a baseclass for all objects that evaluate - * a const transaction on a GISTable using an external transactor. - * - * - * - * - * \ingroup TransactorGISTableFunctions - */ -template < - class TInputTable, - class TOutput, class TTransactor - > -class ITK_EXPORT TransactorGISTableFunction : - public GISTableFunction<TInputTable, - TOutput> -{ -public: - /** Dimension underlying input table. */ - itkStaticConstMacro(TableDimension, unsigned int, - TInputTable::TSpatialDimension); - - /** Standard class typedefs. */ - typedef TransactorGISTableFunction Self; - typedef GISTableFunction<TInputTable, TOutput> Superclass; - typedef SmartPointer<Self> Pointer; - typedef SmartPointer<const Self> ConstPointer; - - /** Run-time type information (and related methods). */ - itkTypeMacro(TransactorGISTableFunction, GISTableFunction); - - /** InputTableType typedef support. */ - typedef TInputTable InputTableType; - typedef TTransactor TransactorType; - - /** Connection typedef support */ - typedef typename InputTableType::ConnectionType ConnectionType; - - /** InputTablePointer typedef support */ - typedef typename InputTableType::ConstPointer InputTableConstPointer; - - /** OutputType typedef support. */ - typedef TOutput OutputType; - - /** Evaluate the function using the transactor. */ - virtual TOutput Evaluate() - { - m_Table->GetConnection()->PerformTransaction(TransactorType()); - } - -protected: - TransactorGISTableFunction(); - virtual ~TransactorGISTableFunction() {} - void PrintSelf(std::ostream& os, Indent indent) const; - - /** Const pointer to the input Table. */ - InputTableConstPointer m_Table; - -private: - TransactorGISTableFunction(const Self &); //purposely not implemented - void operator =(const Self&); //purposely not implemented - -}; - -} // end namespace otb - -#endif diff --git a/Code/OBIA/CMakeLists.txt b/Code/OBIA/CMakeLists.txt index f4df6d20ad..b4189d0e79 100644 --- a/Code/OBIA/CMakeLists.txt +++ b/Code/OBIA/CMakeLists.txt @@ -14,10 +14,6 @@ if(OTB_USE_MAPNIK) target_link_libraries(OTBOBIA ${MAPNIK_LIBRARY} ${ICUUC_LIBRARY}) endif() -if(OTB_USE_PQXX) - target_link_libraries(OTBOBIA ${PQXX_LIBRARY}) -endif() - if(OTB_I18N) target_link_libraries(OTBOBIA ${GETTEXT_LIBRARY}) if(APPLE OR WIN32) diff --git a/Examples/CMakeLists.txt b/Examples/CMakeLists.txt index d110519fc9..3090b7feb3 100644 --- a/Examples/CMakeLists.txt +++ b/Examples/CMakeLists.txt @@ -42,10 +42,6 @@ if(OTB_USE_PATENTED) add_subdirectory( Patented ) endif() -if(OTB_USE_PQXX) - add_subdirectory(GeospatialAnalysis) -endif() - #Recopie du fichier README.txt dans l'arborescence BINARY if( EXISTS ${OTB_BINARY_DIR}/Examples/README.txt ) else() @@ -107,10 +103,6 @@ else() if(OTB_USE_PATENTED) add_subdirectory(Patented) endif() - - if(OTB_USE_PQXX) - add_subdirectory(GeospatialAnalysis) - endif() else() message("OTB not found. Please set OTB_DIR") endif() diff --git a/Examples/GeospatialAnalysis/CMakeLists.txt b/Examples/GeospatialAnalysis/CMakeLists.txt deleted file mode 100644 index b3ee45c47c..0000000000 --- a/Examples/GeospatialAnalysis/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -project(GeospatialAnalysisExamples) -include_regular_expression("^.*$") - -add_executable(PostGISCreateTable PostGISCreateTable.cxx ) -target_link_libraries(PostGISCreateTable OTBCommon OTBIO OTBGeospatialAnalysis) - - - -if( NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING ) - -set(BASELINE ${OTB_DATA_ROOT}/Baseline/Examples/GeospatialAnalysis) - -set(INPUTDATA ${OTB_DATA_ROOT}/Examples) -#Remote sensing images (large images ) -if(OTB_DATA_USE_LARGEINPUT) - set(INPUTLARGEDATA ${OTB_DATA_LARGEINPUT_ROOT} ) -endif() - -set(TEMP ${OTB_BINARY_DIR}/Testing/Temporary) - -set(EXE_TESTS ${CXX_TEST_PATH}/otbGeospatialAnalysisExamplesTests) - -set(TOL 0.0) -set(EPS 0.001) - -add_test( trTeGeospatialAnalysisPostGISCreateTableTest ${EXE_TESTS} - - GeospatialAnalysisPostGISCreateTableTest - localhost - orfeotoolbox_test - orfeotoolbox_test_user - Bidfeud0 - ) - - - -include_directories(${OTB_SOURCE_DIR}/Testing/Code) -add_executable(otbGeospatialAnalysisExamplesTests otbGeospatialAnalysisExamplesTests.cxx) -target_link_libraries(otbGeospatialAnalysisExamplesTests OTBCommon OTBIO OTBGeospatialAnalysis OTBTesting) - -endif() diff --git a/Examples/GeospatialAnalysis/PostGISCreateTable.cxx b/Examples/GeospatialAnalysis/PostGISCreateTable.cxx deleted file mode 100644 index f88647018a..0000000000 --- a/Examples/GeospatialAnalysis/PostGISCreateTable.cxx +++ /dev/null @@ -1,107 +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. - -=========================================================================*/ - -// Software Guide : BeginLatex -// -// This example uses a transactor to create a table. The transactor -// needs to have a copy constructor, so the initialization is done -// correctly for the class variables which are set before the transaction. -// Let's look at the minimal code required to use this algorithm. First, the -// following header defining the \doxygen{otb}{PostGISCreateTableTransactor} class -// must be included. -// Software Guide : EndLatex - -#include "otbMacro.h" - -// Software Guide : BeginCodeSnippet -#include "otbPostGISCreateTableTransactor.h" -#include "otbPostGISConnectionImplementation.h" -// Software Guide : EndCodeSnippet - -int main(int argc, char * argv[]) -{ - - // Software Guide : BeginLatex - // - // We use a PostGIS (PQXX-based) transactor - // for creating PostGIS tables. - // Software Guide : EndLatex - - // Software Guide : BeginCodeSnippet - typedef otb::PostGISCreateTableTransactor TransactorType; - - TransactorType myTransactor; - // Software Guide : EndCodeSnippet - - // Software Guide : BeginLatex - // - // We set arguments of the transactor. - - // Software Guide : EndLatex - - // Software Guide : BeginCodeSnippet - unsigned short dimension = 2; - myTransactor.SetDimension(dimension); - - std::string name = "mytable"; - myTransactor.SetTableName(name); - - int srid = -1; - myTransactor.SetSRID(srid); - - myTransactor.SetRemoveExistingTable(true); - // Software Guide : EndCodeSnippet - - // Software Guide : BeginLatex - // - // After defining the transcator, we need to create the - // connection interface to the PostgreSQL database. - // This is done by the \doxygen{otb}{PostGISConnectionImplementation}. - // - // Software Guide : EndLatex - - // Software Guide : BeginCodeSnippet - const std::string hostName = argv[1]; - const std::string dbName = argv[2]; - const std::string userName = argv[3]; - const std::string userPassword = argv[4]; - - typedef otb::PostGISConnectionImplementation GISConnectionType; - - GISConnectionType::Pointer connection = GISConnectionType::New(); - - connection->SetHost(hostName); - connection->SetDBName(dbName); - connection->SetUser(userName); - connection->SetPassword(userPassword); - // Software Guide : EndCodeSnippet - - // Software Guide : BeginLatex - // - // Let's now connect to the database and perform the transaction - // with the method \code{PerformTransaction}. - // - // Software Guide : EndLatex - - // Software Guide : BeginCodeSnippet - connection->ConnectToDB(); - - connection->PerformTransaction(myTransactor); - // Software Guide : EndCodeSnippet - return EXIT_SUCCESS; -} diff --git a/Examples/GeospatialAnalysis/otbGeospatialAnalysisExamplesTests.cxx b/Examples/GeospatialAnalysis/otbGeospatialAnalysisExamplesTests.cxx deleted file mode 100644 index 64ed4826ad..0000000000 --- a/Examples/GeospatialAnalysis/otbGeospatialAnalysisExamplesTests.cxx +++ /dev/null @@ -1,32 +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. - -=========================================================================*/ - -// this file defines the otbMultiScaleTest for the test driver -// and all it expects is that you have a function called RegisterTests - -#include <iostream> -#include "otbTestMain.h" - -void RegisterTests() -{ - REGISTER_TEST(GeospatialAnalysisPostGISCreateTableTest); -} - -#undef main -#define main GeospatialAnalysisPostGISCreateTableTest -#include "PostGISCreateTable.cxx" diff --git a/Testing/Code/CMakeLists.txt b/Testing/Code/CMakeLists.txt index dc1e9ba032..34ce3abc06 100644 --- a/Testing/Code/CMakeLists.txt +++ b/Testing/Code/CMakeLists.txt @@ -30,10 +30,6 @@ if(OTB_USE_VISU_GUI) add_subdirectory(Visualization) endif() -if(OTB_USE_PQXX) - add_subdirectory(GeospatialAnalysis) -endif() - if(BUILD_APPLICATIONS) add_subdirectory(ApplicationEngine) add_subdirectory(Wrappers) diff --git a/Testing/Code/Common/CMakeLists.txt b/Testing/Code/Common/CMakeLists.txt index bd7d66caef..f49c57442a 100644 --- a/Testing/Code/Common/CMakeLists.txt +++ b/Testing/Code/Common/CMakeLists.txt @@ -12,9 +12,6 @@ set(COMMON_TESTS8 ${CXX_TEST_PATH}/otbCommonTests8) if(OTB_USE_MAPNIK) set(COMMON_TESTS9 ${CXX_TEST_PATH}/otbCommonTests9) endif() -if(OTB_USE_PQXX) - set(COMMON_TESTS10 ${CXX_TEST_PATH}/otbCommonTests10) -endif() set(COMMON_TESTS11 ${CXX_TEST_PATH}/otbCommonTests11) set(COMMON_TESTS12 ${CXX_TEST_PATH}/otbCommonTests12) set(COMMON_TESTS13 ${CXX_TEST_PATH}/otbCommonTests13) @@ -913,86 +910,6 @@ add_test(coTvVectorDataToMapFilterWorld ${COMMON_TESTS9} endif() - - -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ otbCommonTests10 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -# ---------------- PostGIS Interface ---------------------# -if(OTB_USE_PQXX) - -add_test(coTuPostGISConnectionImplementationNew ${COMMON_TESTS10} - otbPostGISConnectionImplementationNew -) - -#This test need a runing PostGIS server on the localhost with trusted potgres user and an ecisting testgis base -add_test(coTvPostGISConnectionImplementationConnectToDB ${COMMON_TESTS10} - otbPostGISConnectionImplementationConnectToDB - localhost - orfeotoolbox_test - orfeotoolbox_test_user - Bidfeud0 -) - -add_test(coTvPostGISConnectionImplementationPerformTransaction ${COMMON_TESTS10} - otbPostGISConnectionImplementationPerformTransaction - localhost - orfeotoolbox_test - orfeotoolbox_test_user - Bidfeud0 -) - - -add_test(coTuGISTableNew ${COMMON_TESTS10} - otbGISTableNew -) - -add_test(coTuPostGISTableNew ${COMMON_TESTS10} - otbPostGISTableNew -) - -add_test(coTuVectorDataToGISTableFilterNew ${COMMON_TESTS10} - otbVectorDataToGISTableFilterNew -) - - -# add_test(coTuVectorDataToGISTableFilter ${COMMON_TESTS10} -# otbVectorDataToGISTableFilter -# ${INPUTDATA}/ToulousePoints-examples.shp -# test -# postgres -# postgres -# ) - -add_test(coTuGISTableToGISTableFilterNew ${COMMON_TESTS10} - otbGISTableToGISTableFilterNew -) - - -add_test(coTuGISTableToVectorDataFilterNew ${COMMON_TESTS10} - otbGISTableToVectorDataFilterNew -) - -#need gdal 1.6 for POSTGIS tables connection via OGR string -add_test(coTvGISTableToVectorDataFilter ${COMMON_TESTS10} -otbGISTableToVectorDataFilter -${TEMP}/gistabletovectordatafilter.shp -orfeotoolbox_test -labelmaptogis_test_table -orfeotoolbox_test_user -Bidfeud0 -) - - -# ---------------- otbGISTableSource ---------------------# -add_test(coTuGISTableSourceNew ${COMMON_TESTS10} -otbGISTableSourceNew -) - - -endif() - # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ otbCommonTests11 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1408,24 +1325,6 @@ otbVectorDataToImageFilter.cxx ) endif() -if(OTB_USE_PQXX) -set(BasicCommon_SRCS10 -otbCommonTests10.cxx -otbPostGISConnectionImplementationNew.cxx -otbPostGISConnectionImplementationConnectToDB.cxx -otbPostGISConnectionImplementationPerformTransaction.cxx -otbGISTableNew.cxx -otbPostGISTableNew.cxx -otbVectorDataToGISTableFilterNew.cxx -# otbVectorDataToGISTableFilter.cxx -otbGISTableToGISTableFilterNew.cxx -otbGISTableToVectorDataFilterNew.cxx -otbGISTableToVectorDataFilter.cxx -otbGISTableSourceNew.cxx -) -endif() - - set(BasicCommon_SRCS11 otbUnaryFunctorWithIndexImageFilterNew.cxx otbUnaryFunctorWithIndexImageFilter.cxx @@ -1472,11 +1371,6 @@ OTB_ADD_EXECUTABLE(otbCommonTests8 "${BasicCommon_SRCS8}" "OTBIO;OTBTesting") if(OTB_USE_MAPNIK) OTB_ADD_EXECUTABLE(otbCommonTests9 "${BasicCommon_SRCS9}" "OTBIO;OTBTesting;${MAPNIK_LIBRARY};${ICUUC_LIBRARY}") endif() -if(OTB_USE_PQXX) - #TODO this line should be refined when we will like to have this capability with windows -OTB_ADD_EXECUTABLE(otbCommonTests10 "${BasicCommon_SRCS10}" "OTBIO;OTBTesting") -target_link_libraries(otbCommonTests10 OTBIO OTBTesting OTBGeospatialAnalysis pq pqxx) -endif() add_executable(otbCommonTests11 otbCommonTests11.cxx ${BasicCommon_SRCS11}) target_link_libraries(otbCommonTests11 OTBIO OTBTesting itkvcl) diff --git a/Testing/Code/Common/otbPostGISConnectionImplementationConnectToDB.cxx b/Testing/Code/Common/otbPostGISConnectionImplementationConnectToDB.cxx deleted file mode 100644 index 819ee0263d..0000000000 --- a/Testing/Code/Common/otbPostGISConnectionImplementationConnectToDB.cxx +++ /dev/null @@ -1,44 +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 "otbMacro.h" - -#include "otbPostGISConnectionImplementation.h" - -int otbPostGISConnectionImplementationConnectToDB(int argc, char * argv[]) -{ - - const std::string hostName = argv[1]; - const std::string dbName = argv[2]; - const std::string userName = argv[3]; - const std::string userPassword = argv[4]; - - typedef otb::PostGISConnectionImplementation GISConnectionType; - - //Instantiation - GISConnectionType::Pointer connection = GISConnectionType::New(); - - connection->SetHost(hostName); - connection->SetDBName(dbName); - connection->SetUser(userName); - connection->SetPassword(userPassword); - - connection->ConnectToDB(); - - return EXIT_SUCCESS; -} diff --git a/Testing/Code/Common/otbPostGISConnectionImplementationNew.cxx b/Testing/Code/Common/otbPostGISConnectionImplementationNew.cxx deleted file mode 100644 index 80bfbb3f81..0000000000 --- a/Testing/Code/Common/otbPostGISConnectionImplementationNew.cxx +++ /dev/null @@ -1,34 +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 "otbMacro.h" - -#include "otbPostGISConnectionImplementation.h" - -int otbPostGISConnectionImplementationNew(int argc, char * argv[]) -{ - - typedef otb::PostGISConnectionImplementation GISConnectionType; - - //Instantiation - GISConnectionType::Pointer data = GISConnectionType::New(); - - std::cout << data << std::endl; - - return EXIT_SUCCESS; -} diff --git a/Testing/Code/Common/otbPostGISConnectionImplementationPerformTransaction.cxx b/Testing/Code/Common/otbPostGISConnectionImplementationPerformTransaction.cxx deleted file mode 100644 index dfe6703d71..0000000000 --- a/Testing/Code/Common/otbPostGISConnectionImplementationPerformTransaction.cxx +++ /dev/null @@ -1,68 +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 "otbMacro.h" -#include "otbPostGISConnectionImplementation.h" - -class ReadTables : public pqxx::transactor<pqxx::nontransaction> -{ - pqxx::result m_Result; -public: - ReadTables() : pqxx::transactor<pqxx::nontransaction>("ReadTables") {} - - void operator ()(argument_type& T) - { - m_Result = T.exec("SELECT * FROM pg_tables"); - } - - void on_commit() - { - for (pqxx::result::const_iterator c = m_Result.begin(); c != m_Result.end(); ++c) - { - std::string N; - c[0].to(N); - - std::cout << '\t' << c.num() << '\t' << N << std::endl; - } - } -}; - -int otbPostGISConnectionImplementationPerformTransaction(int argc, char * argv[]) -{ - - const std::string hostName = argv[1]; - const std::string dbName = argv[2]; - const std::string userName = argv[3]; - const std::string userPassword = argv[4]; - - typedef otb::PostGISConnectionImplementation GISConnectionType; - - //Instantiation - GISConnectionType::Pointer connection = GISConnectionType::New(); - - connection->SetHost(hostName); - connection->SetDBName(dbName); - connection->SetUser(userName); - connection->SetPassword(userPassword); - - connection->ConnectToDB(); - - connection->GetConnection()->perform(ReadTables()); - - return EXIT_SUCCESS; -} diff --git a/Testing/Code/GeospatialAnalysis/CMakeLists.txt b/Testing/Code/GeospatialAnalysis/CMakeLists.txt deleted file mode 100644 index 49705ee76e..0000000000 --- a/Testing/Code/GeospatialAnalysis/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ - -if( NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING ) - - -set(GEOSPATIALANALYSIS_TESTS ${CXX_TEST_PATH}/otbGeospatialAnalysisTests) - -# ------------- Transactors ---------------------------- - -add_test(gfTuPostGISCreateTableTransactorNew ${GEOSPATIALANALYSIS_TESTS} - otbPostGISCreateTableTransactorNew - ) - -add_test(gfTuPostGISCreateTableTransactorAccessors ${GEOSPATIALANALYSIS_TESTS} - otbPostGISCreateTableTransactorAccessors - ) - -add_test(gfTuPostGISCreateTableTransactorCreate ${GEOSPATIALANALYSIS_TESTS} - otbPostGISCreateTableTransactorCreate - localhost - orfeotoolbox_test - orfeotoolbox_test_user - Bidfeud0 - ) - -add_test(gfTuPostGISFromStringTransactorNew ${GEOSPATIALANALYSIS_TESTS} - otbPostGISFromStringTransactorNew - ) - - -# ------- CXX source files ----------------------------------- -set(GEOSPATIALANALYSIS_SRCS -otbGeospatialAnalysisTests.cxx -otbPostGISCreateTableTransactorNew.cxx -otbPostGISCreateTableTransactorAccessors.cxx -otbPostGISCreateTableTransactorCreate.cxx -otbPostGISFromStringTransactorNew.cxx -) - -OTB_ADD_EXECUTABLE(otbGeospatialAnalysisTests "${GEOSPATIALANALYSIS_SRCS}" "OTBGeospatialAnalysis;OTBTesting;OTBCommon;pq;pqxx") - -endif() diff --git a/Testing/Code/GeospatialAnalysis/otbGeospatialAnalysisTests.cxx b/Testing/Code/GeospatialAnalysis/otbGeospatialAnalysisTests.cxx deleted file mode 100644 index 481dded3a3..0000000000 --- a/Testing/Code/GeospatialAnalysis/otbGeospatialAnalysisTests.cxx +++ /dev/null @@ -1,31 +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. - -=========================================================================*/ - -// this file defines the otbGISFiltersTest for the test driver -// and all it expects is that you have a function called RegisterTests - - -#include "otbTestMain.h" - -void RegisterTests() -{ - REGISTER_TEST(otbPostGISCreateTableTransactorNew); - REGISTER_TEST(otbPostGISCreateTableTransactorAccessors); - REGISTER_TEST(otbPostGISCreateTableTransactorCreate); - REGISTER_TEST(otbPostGISFromStringTransactorNew); -} diff --git a/Testing/Code/GeospatialAnalysis/otbPostGISCreateTableTransactorAccessors.cxx b/Testing/Code/GeospatialAnalysis/otbPostGISCreateTableTransactorAccessors.cxx deleted file mode 100644 index 88ce4f1225..0000000000 --- a/Testing/Code/GeospatialAnalysis/otbPostGISCreateTableTransactorAccessors.cxx +++ /dev/null @@ -1,50 +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 "otbMacro.h" - -#include "otbPostGISCreateTableTransactor.h" - -int otbPostGISCreateTableTransactorAccessors(int argc, char * argv[]) -{ - typedef otb::PostGISCreateTableTransactor TransactorType; - - //Instantiation - TransactorType myTransactor; - - unsigned short dimension = 2; - - myTransactor.SetDimension(dimension); - - if (dimension != myTransactor.GetDimension()) return EXIT_FAILURE; - - std::string name = "mytable"; - - myTransactor.SetTableName(name); - - if (name != myTransactor.GetTableName()) return EXIT_FAILURE; - - int srid = -1; - - myTransactor.SetSRID(srid); - - if (srid != myTransactor.GetSRID()) return EXIT_FAILURE; - - return EXIT_SUCCESS; -} diff --git a/Testing/Code/GeospatialAnalysis/otbPostGISCreateTableTransactorCreate.cxx b/Testing/Code/GeospatialAnalysis/otbPostGISCreateTableTransactorCreate.cxx deleted file mode 100644 index ea5a0a3552..0000000000 --- a/Testing/Code/GeospatialAnalysis/otbPostGISCreateTableTransactorCreate.cxx +++ /dev/null @@ -1,67 +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 "otbMacro.h" - -#include "otbPostGISCreateTableTransactor.h" -#include "otbPostGISConnectionImplementation.h" - -/** This test uses a transactor to create a table. The transactor -needs to have a copy constructor, so the initialization is done -correctly for the class variables which are set before the transaction -*/ - -int otbPostGISCreateTableTransactorCreate(int argc, char * argv[]) -{ - typedef otb::PostGISCreateTableTransactor TransactorType; - - //Instantiation - TransactorType myTransactor; - - unsigned short dimension = 2; - myTransactor.SetDimension(dimension); - - std::string name = "mytable"; - myTransactor.SetTableName(name); - - int srid = -1; - myTransactor.SetSRID(srid); - - myTransactor.SetRemoveExistingTable(true); - - const std::string hostName = argv[1]; - const std::string dbName = argv[2]; - const std::string userName = argv[3]; - const std::string userPassword = argv[4]; - - typedef otb::PostGISConnectionImplementation GISConnectionType; - - //Instantiation - GISConnectionType::Pointer connection = GISConnectionType::New(); - - connection->SetHost(hostName); - connection->SetDBName(dbName); - connection->SetUser(userName); - connection->SetPassword(userPassword); - - connection->ConnectToDB(); - - connection->PerformTransaction(myTransactor); - - return EXIT_SUCCESS; -} diff --git a/Testing/Code/GeospatialAnalysis/otbPostGISCreateTableTransactorNew.cxx b/Testing/Code/GeospatialAnalysis/otbPostGISCreateTableTransactorNew.cxx deleted file mode 100644 index e643bcd572..0000000000 --- a/Testing/Code/GeospatialAnalysis/otbPostGISCreateTableTransactorNew.cxx +++ /dev/null @@ -1,31 +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 "otbMacro.h" - -#include "otbPostGISCreateTableTransactor.h" - -int otbPostGISCreateTableTransactorNew(int argc, char * argv[]) -{ - typedef otb::PostGISCreateTableTransactor TransactorType; - - //Instantiation - TransactorType myTransactor(); - - return EXIT_SUCCESS; -} diff --git a/Testing/Code/GeospatialAnalysis/otbPostGISFromStringTransactorNew.cxx b/Testing/Code/GeospatialAnalysis/otbPostGISFromStringTransactorNew.cxx deleted file mode 100644 index 7fa5887c84..0000000000 --- a/Testing/Code/GeospatialAnalysis/otbPostGISFromStringTransactorNew.cxx +++ /dev/null @@ -1,31 +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 "otbMacro.h" - -#include "otbPostGISFromStringTransactor.h" - -int otbPostGISFromStringTransactorNew(int argc, char * argv[]) -{ - typedef otb::PostGISFromStringTransactor TransactorType; - - //Instantiation - TransactorType myTransactor(); - - return EXIT_SUCCESS; -} diff --git a/Testing/Code/IO/CMakeLists.txt b/Testing/Code/IO/CMakeLists.txt index fd51d4c809..7d079087d0 100644 --- a/Testing/Code/IO/CMakeLists.txt +++ b/Testing/Code/IO/CMakeLists.txt @@ -2566,16 +2566,6 @@ add_test(ioTuOGRVectorDataIOTestCanReadMapInfo ${IO_TESTS15} otbOGRVectorDataIOTestCanRead ${INPUTDATA}/LOCALITY_POLYGON.tab) -# CanRead OGR PostGIS() -if(OTB_USE_PQXX) -#The original string is PG:"dbname='orfeotoolbox_test' host='localhost' port='5432' user='orfeotoolbox_test_user' password='Bidfeud0'" -#but we need to work with cmake/ctest escaping -set(CONNSTRING "PG:dbname=orfeotoolbox_test\ host=localhost\ port=5432\ user=orfeotoolbox_test_user\ password=Bidfeud0") -add_test(ioTuOGRVectorDataIOTestCanReadPostGIS ${IO_TESTS15} - otbOGRVectorDataIOTestCanRead - ${CONNSTRING}) -endif() - # CanWrite OGR GML() add_test(ioTuOGRVectorDataIOCanWriteGML ${IO_TESTS15} otbOGRVectorDataIOCanWrite @@ -2586,13 +2576,6 @@ add_test(ioTuOGRVectorDataIOCanWriteMapInfo ${IO_TESTS15} otbOGRVectorDataIOCanWrite ${INPUTDATA}/LOCALITY_POLYGON.tab) -# Canwrite OGR PostGIS() -if(OTB_USE_PQXX) -add_test(ioTuOGRVectorDataIOCanWritePostGIS ${IO_TESTS15} - otbOGRVectorDataIOCanWrite - PG:"dbname='orfeotoolbox_test' host='localhost' port='5432' user='orfeotoolbox_test_user' password='Bidfeud0'") -endif() - add_test(ioTuKMLVectorDataIO ${IO_TESTS15} otbKMLVectorDataIONew ) diff --git a/Testing/Code/OBIA/CMakeLists.txt b/Testing/Code/OBIA/CMakeLists.txt index c21d648d1e..7f87493661 100644 --- a/Testing/Code/OBIA/CMakeLists.txt +++ b/Testing/Code/OBIA/CMakeLists.txt @@ -196,24 +196,6 @@ add_test(obTuLabelMapToAttributeImageFilterNew ${OBIA_TESTS1} otbLabelMapToAttributeImageFilterNew) -# OBIATests2 (need PQXX) -if(OTB_USE_PQXX) -add_test(obTuLabelMapToGISTableFilterNew ${OBIA_TESTS2} - otbLabelMapToGISTableFilterNew) - -add_test(obTuGISTableToLabelMapFilterNew ${OBIA_TESTS2} - otbGISTableToLabelMapFilterNew) - -add_test(obTvLabelMapToGISTableFilter ${OBIA_TESTS2} - otbLabelMapToGISTableFilter - ${INPUTDATA}/rcc8_mire1.png - orfeotoolbox_test - labelmaptogis_test_table - orfeotoolbox_test_user - Bidfeud0) -endif() - - # OBIATests3 (need Learning) add_test(obTuLabelMapSVMClassifierNew ${OBIA_TESTS3} otbLabelMapSVMClassifierNew) @@ -254,16 +236,6 @@ otbMeanShiftConnectedComponentSegmentationFilterTest.cxx otbLabelMapToAttributeImageFilterNew.cxx ) - - -if(OTB_USE_PQXX) -set(BasicOBIA_SRCS2 -otbLabelMapToGISTableFilterNew.cxx -otbGISTableToLabelMapFilterNew.cxx -otbLabelMapToGISTableFilter.cxx -) -endif() - set(BasicOBIA_SRCS3 otbLabelMapSVMClassifier.cxx otbLabelImageToLabelMapWithAdjacencyFilter.cxx @@ -272,11 +244,6 @@ otbLabelImageToLabelMapWithAdjacencyFilter.cxx add_executable(otbOBIATests1 otbOBIATests1.cxx ${BasicOBIA_SRCS1}) target_link_libraries(otbOBIATests1 OTBIO OTBOBIA OTBTesting OTBOGRAdapters) -if(OTB_USE_PQXX) -add_executable(otbOBIATests2 otbOBIATests2.cxx ${BasicOBIA_SRCS2}) -target_link_libraries(otbOBIATests2 OTBIO OTBOBIA OTBTesting OTBGeospatialAnalysis pq pqxx) -endif() - add_executable(otbOBIATests3 otbOBIATests3.cxx ${BasicOBIA_SRCS3}) target_link_libraries(otbOBIATests3 OTBIO OTBOBIA OTBLearning OTBTesting) -- GitLab