Skip to content

Commit

Permalink
more soci reader
Browse files Browse the repository at this point in the history
  • Loading branch information
hobu committed Oct 5, 2012
1 parent d01fc00 commit 377d0eb
Show file tree
Hide file tree
Showing 6 changed files with 369 additions and 309 deletions.
53 changes: 32 additions & 21 deletions include/pdal/drivers/soci/Reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class PDAL_DLL Reader : public pdal::Reader
}
QueryType describeQueryType(std::string const& query) const;

inline DatabaseType getDatabaseType() const { return m_database_type; }
pdal::Schema fetchSchema(std::string const& query) const;
pdal::SpatialReference fetchSpatialReference(std::string const& query) const;

Expand Down Expand Up @@ -124,6 +125,9 @@ namespace sequential
{


typedef boost::shared_ptr<PointBuffer> BufferPtr;
typedef std::map<int, BufferPtr> BufferMap;

class IteratorBase
{
public:
Expand All @@ -133,35 +137,42 @@ class IteratorBase
protected:
const pdal::drivers::soci::Reader& getReader() const;

// boost::uint32_t myReadBuffer(PointBuffer& data);
boost::uint32_t myReadBuffer(PointBuffer& data);
// boost::uint32_t unpackOracleData(PointBuffer& data);
//
// boost::uint32_t myReadClouds(PointBuffer& data);
// boost::uint32_t myReadBlocks(PointBuffer& data);
//
// BufferPtr fetchPointBuffer(Statement statment, sdo_pc* pc);
boost::uint32_t myReadClouds(PointBuffer& data);
boost::uint32_t myReadBlocks(PointBuffer& data, ::soci::statement& statement, ::soci::row& row);
//
// Statement m_block_statement;
// Statement m_initialQueryStatement;
// bool m_at_end;
// bool m_at_end_of_blocks;
// bool m_at_end_of_clouds;
// QueryType m_querytype;
// BlockPtr m_block;
// BlockPtr m_cloud_block;
// boost::int32_t m_active_cloud_id;
// BufferPtr m_oracle_buffer;
// BufferMap m_buffers;
// boost::uint32_t m_buffer_position;
BufferPtr fetchPointBuffer( boost::int32_t const& cloud_id,
std::string const& schema_xml);

bool m_at_end;

DatabaseType m_database_type;
QueryType m_query_type;

boost::int32_t m_active_cloud_id;
BufferPtr m_active_buffer;
BufferMap m_buffers;
boost::uint32_t m_buffer_position;



private:
const pdal::drivers::soci::Reader& m_reader;

// Statement getNextCloud(BlockPtr block, boost::int32_t& cloud_id);
// void readBlob(Statement statement,
// BlockPtr block,
// boost::uint32_t howMany);
#ifdef PDAL_HAVE_SOCI
::soci::session* m_session;
#else
void* m_session;
#endif


::soci::statement getNextCloud( std::string const& cloud_table_name,
boost::int32_t& cloud_id,
::soci::row& r);
void readBlob(::soci::row& block,
boost::uint32_t howMany);
// void fillUserBuffer(PointBuffer& user_buffer);
//
// void copyOracleData(PointBuffer& source,
Expand Down
40 changes: 40 additions & 0 deletions include/pdal/drivers/soci/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,22 @@ namespace soci
{}
};

class connection_failed : public soci_driver_error
{
public:
connection_failed(std::string const& msg)
: soci_driver_error(msg)
{}
};

class buffer_too_small : public soci_driver_error
{
public:
buffer_too_small(std::string const& msg)
: soci_driver_error(msg)
{}
};


enum DatabaseType
{
Expand Down Expand Up @@ -93,6 +109,30 @@ inline DatabaseType getDatabaseConnectionType(std::string const& connection_type

}

inline ::soci::session* connectToDataBase(std::string const& connection, DatabaseType dtype)
{
::soci::session* output(0);
if (dtype == DATABASE_UNKNOWN)
{
std::stringstream oss;
oss << "Database connection type '" << dtype << "' is unknown or not configured";
throw soci_driver_error(oss.str());
}

try
{
if (dtype == DATABASE_POSTGRESQL)
output = new ::soci::session(::soci::postgresql, connection);

} catch (::soci::soci_error const& e)
{
std::stringstream oss;
oss << "Unable to connect to database with error '" << e.what() << "'";
throw connection_failed(oss.str());
}

return output;
}

}
}
Expand Down
Loading

0 comments on commit 377d0eb

Please sign in to comment.