Commit 04a16fd4 authored by Jordi Inglada's avatar Jordi Inglada

ENH: basic setup for PQXX

parent 11ac4e71
......@@ -360,6 +360,43 @@ IF(OTB_USE_MAPNIK)
ENDIF(OTB_USE_MAPNIK)
#-------------------------------
# Pqxx Library
#-------------------------------
OPTION(OTB_USE_PQXX "Use pqxx library (EXPERIMENTAL)." OFF)
MARK_AS_ADVANCED(OTB_USE_PQXX)
IF(OTB_USE_PQXX)
FIND_PATH(PQXX_INCLUDE_DIR pqxx/pqxx PATHS)
MARK_AS_ADVANCED(PQXX_INCLUDE_DIR)
IF (NOT PQXX_INCLUDE_DIR)
MESSAGE(FATAL_ERROR
"Cannot find PQXX include directory. Please set PQXX_INCLUDE_DIR or SET OTB_USE_PQXX OFF.")
ENDIF (NOT PQXX_INCLUDE_DIR)
FIND_LIBRARY(PQXX_LIBRARY pqxx )
MARK_AS_ADVANCED(PQXX_LIBRARY)
IF (NOT PQXX_LIBRARY)
MESSAGE(FATAL_ERROR
"Cannot find PQXX library. Please set PQXX_LIBRARY or SET OTB_USE_PQXX OFF.")
ENDIF (NOT PQXX_LIBRARY)
FIND_LIBRARY(PQ_LIBRARY pq )
MARK_AS_ADVANCED(PQ_LIBRARY)
IF (NOT PQ_LIBRARY)
MESSAGE(FATAL_ERROR
"Cannot find PQ library. Please set PQ_LIBRARY or SET OTB_USE_PQXX OFF.")
ENDIF (NOT PQ_LIBRARY)
# Add compiler option
ADD_DEFINITIONS(-DOTB_USE_PQXX)
INCLUDE_DIRECTORIES(${PQXX_INCLUDE_DIR})
ENDIF(OTB_USE_PQXX)
#-------------------------------
# Boost Library
......
......@@ -6,12 +6,22 @@ IF( NOT OTB_USE_MAPNIK )
LIST(REMOVE_ITEM OTBCommon_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/otbVectorDataStyle.cxx" )
ENDIF( NOT OTB_USE_MAPNIK )
IF( NOT OTB_USE_PQXX )
LIST(REMOVE_ITEM OTBCommon_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/otbGISConnection.cxx" )
ENDIF( NOT OTB_USE_PQXX )
ADD_LIBRARY(OTBCommon ${OTBCommon_SRCS})
TARGET_LINK_LIBRARIES (OTBCommon ITKAlgorithms ITKStatistics ITKCommon)
IF (OTB_USE_MAPNIK)
#TODO this line should be refined when we will like to have this capability with windows
TARGET_LINK_LIBRARIES(OTBCommon ${MAPNIK_LIBRARY}/libmapnik.so)
ENDIF(OTB_USE_MAPNIK)
IF (OTB_USE_PQXX)
#TODO this line should be refined when we will like to have this capability with windows
TARGET_LINK_LIBRARIES(OTBCommon pq pqxx)
ENDIF(OTB_USE_PQXX)
IF(OTB_LIBRARY_PROPERTIES)
SET_TARGET_PROPERTIES(OTBCommon PROPERTIES ${OTB_LIBRARY_PROPERTIES})
......
/*=========================================================================
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 __otbGISConnection_h
#define __otbGISConnection_h
#include <pqxx/pqxx>
namespace otb
{
/** \class GISConnection
* \brief this class represents a connection to a geospatial database (ie. PostGIS).
*
*
* \sa GISConnectionFileReader
* \sa GISConnectionFileWriter
*
*/
class GISConnection : public itk::DataObject
{
public:
/** Standard class typedefs */
typedef GISConnection Self;
typedef itk::DataObject Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Standard macros */
itkNewMacro(Self);
itkTypeMacro(GISConnection,DataObject);
/** Typedefs */
typedef pqxx::basic_connection<pqxx::connect_direct> BasicConnectionType;
/** Acessors */
protected:
/** Constructor */
GISConnection();
/** Destructor */
virtual ~GISConnection() {};
/** PrintSelf method */
void PrintSelf(std::ostream& os, itk::Indent indent) const;
private:
GISConnection(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
std::string m_TableName;
};
}// 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 __otbGISTable_h
#define __otbGISTable_h
#include "otbGISConnection.hxx"
namespace otb
{
/** \class GISTable
* \brief this class represents a table of a geospatial database (ie. PostGIS).
*
*
* \sa GISTableFileReader
* \sa GISTableFileWriter
*
*/
template <unsigned int VDimension =2>
class GISTable
: public itk::DataObject
{
public:
/** Standard class typedefs */
typedef GISTable Self;
typedef itk::DataObject Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Standard macros */
itkNewMacro(Self);
itkTypeMacro(GISTable,DataObject);
itkStaticConstMacro(Dimension, unsigned int, VDimension);
/** Typedefs */
typedef otb::GISConnection ConnectionType;
/** Acessors */
itkGetMacro(TableName, std::string);
itkSetMacro(TableName, std::string);
itkGetObjectMacro(Connection, ConnectionType);
itkSetObjectMacro(Connection, ConnectionType);
/** Clear the table contents */
virtual bool Clear();
protected:
/** Constructor */
GISTable();
/** Destructor */
virtual ~GISTable() {};
/** PrintSelf method */
void PrintSelf(std::ostream& os, itk::Indent indent) const;
private:
GISTable(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
std::string m_TableName;
ConnectionType m_Connection;
};
}// end namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbGISTable.txx"
#endif
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment