Commit b4efcdce authored by Manuel Grizonnet's avatar Manuel Grizonnet

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.
parent 7f6ca50a
# - 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()
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()
......@@ -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@")
......
......@@ -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})
......
......@@ -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)
......
......@@ -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)
......
......@@ -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)
......
......@@ -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)
......
/*=========================================================================
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
/*=========================================================================
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
/*=========================================================================
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
This diff is collapsed.
# 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()
/*=========================================================================
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
/*=========================================================================
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;
}