[Liblas-commits] hg-main-tree: add more schema stuff
liblas-commits at liblas.org
liblas-commits at liblas.org
Fri Apr 15 17:21:39 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/307852e07825
changeset: 575:307852e07825
user: Howard Butler <hobu.inc at gmail.com>
date: Fri Apr 15 16:20:11 2011 -0500
description:
add more schema stuff
Subject: hg-main-tree: start adding Cloud object definition
details: http://hg.libpc.orghg-main-tree/rev/f7f09599e595
changeset: 576:f7f09599e595
user: Howard Butler <hobu.inc at gmail.com>
date: Fri Apr 15 16:20:35 2011 -0500
description:
start adding Cloud object definition
Subject: hg-main-tree: start adding Cloud object definition
details: http://hg.libpc.orghg-main-tree/rev/c78348feab7e
changeset: 577:c78348feab7e
user: Howard Butler <hobu.inc at gmail.com>
date: Fri Apr 15 16:21:04 2011 -0500
description:
start adding Cloud object definition
Subject: hg-main-tree: turn off table creation/deletion for now
details: http://hg.libpc.orghg-main-tree/rev/19627e75c829
changeset: 578:19627e75c829
user: Howard Butler <hobu.inc at gmail.com>
date: Fri Apr 15 16:21:21 2011 -0500
description:
turn off table creation/deletion for now
Subject: hg-main-tree: merge
details: http://hg.libpc.orghg-main-tree/rev/1db3464d27dd
changeset: 579:1db3464d27dd
user: Howard Butler <hobu.inc at gmail.com>
date: Fri Apr 15 16:21:31 2011 -0500
description:
merge
diffstat:
include/libpc/drivers/oci/Common.hpp | 11 +-
include/libpc/drivers/oci/Schema.hpp | 13 ++-
src/drivers/oci/Reader.cpp | 30 +++++-
src/drivers/oci/Schema.cpp | 29 +++++-
src/drivers/oci/common.cpp | 20 +++
test/unit/CMakeLists.txt | 45 +++++++-
test/unit/ChipperTest.cpp | 4 +-
test/unit/LiblasReaderTest.cpp | 143 ++++++---------------------
test/unit/LiblasWriterTest.cpp | 12 +-
test/unit/OCITest.cpp | 58 ++++++----
test/unit/Support.cpp | 181 +++++++++++++++++++++++++++++++++++
test/unit/Support.hpp | 80 +++++++++++++++
test/unit/TestConfig.cpp | 54 ++++++++++
test/unit/TestConfig.hpp | 48 +++++++++
test/unit/main.cpp | 7 +-
test/unit/support.cpp | 106 --------------------
test/unit/support.hpp | 58 -----------
17 files changed, 577 insertions(+), 322 deletions(-)
diffs (truncated from 1396 to 300 lines):
diff -r f16753970cbd -r 1db3464d27dd include/libpc/drivers/oci/Common.hpp
--- a/include/libpc/drivers/oci/Common.hpp Fri Apr 15 15:37:04 2011 -0500
+++ b/include/libpc/drivers/oci/Common.hpp Fri Apr 15 16:21:31 2011 -0500
@@ -60,7 +60,7 @@
typedef boost::shared_ptr<OWStatement> Statement ;
-// use this for code still under development
+
class connection_failed : public libpc_error
{
public:
@@ -69,7 +69,6 @@
{}
};
-// use this for code still under development
class buffer_too_small : public libpc_error
{
public:
@@ -78,6 +77,14 @@
{}
};
+class schema_error : public libpc_error
+{
+public:
+ schema_error(std::string const& msg)
+ : libpc_error(msg)
+ {}
+};
+
#ifdef LIBPC_COMPILER_MSVC
#define compare_no_case(a,b,n) _strnicmp( (a), (b), (n) )
diff -r f16753970cbd -r 1db3464d27dd include/libpc/drivers/oci/Schema.hpp
--- a/include/libpc/drivers/oci/Schema.hpp Fri Apr 15 15:37:04 2011 -0500
+++ b/include/libpc/drivers/oci/Schema.hpp Fri Apr 15 16:21:31 2011 -0500
@@ -45,15 +45,21 @@
#include <libxml/parser.h>
#include <libxml/xmlschemas.h>
-
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <libxml/xinclude.h>
+#include <libxml/xmlIO.h>
namespace libpc { namespace drivers { namespace oci {
+void OCISchemaGenericErrorHandler (void * userData, xmlErrorPtr error);
+void OCISchemaStructuredErrorHandler (void * userData, xmlErrorPtr error);
+
class Schema
{
public:
- Schema();
+ Schema(std::string xml, std::string xmlschema);
~Schema();
@@ -62,6 +68,9 @@
Schema& operator=(const Schema&); // not implemented
Schema(const Schema&); // not implemented;
+ xmlDocPtr m_doc;
+ xmlDocPtr m_schema;
+
};
diff -r f16753970cbd -r 1db3464d27dd src/drivers/oci/Reader.cpp
--- a/src/drivers/oci/Reader.cpp Fri Apr 15 15:37:04 2011 -0500
+++ b/src/drivers/oci/Reader.cpp Fri Apr 15 16:21:31 2011 -0500
@@ -63,7 +63,19 @@
m_querytype = describeQueryType();
- m_block = defineBlock();
+ if (m_querytype == QUERY_SDO_PC_BLK)
+ m_block = defineBlock();
+ else if (m_querytype == QUERY_SDO_PC)
+ {
+ m_cloud = defineCloud();
+ throw libpc_error("not yet implemented");
+ }
+
+ else
+ throw libpc_error("SQL statement does not define a SDO_PC or CLIP_CP block");
+
+
+
registerFields();
@@ -345,6 +357,22 @@
return block;
}
+CloudPtr Reader::defineCloud()
+{
+
+
+ CloudPtr cloud = CloudPtr(new Cloud(m_connection));
+
+ m_connection->CreateType(&m_pc);
+
+ m_statement->Define(&(m_pc));
+
+ bool bDidRead = m_statement->Fetch();
+
+ std::cout << "block_table_name: " << m_statement->GetString(m_pc->blk_table);
+
+ return cloud;
+}
libpc::SequentialIterator* Reader::createSequentialIterator() const
{
diff -r f16753970cbd -r 1db3464d27dd src/drivers/oci/Schema.cpp
--- a/src/drivers/oci/Schema.cpp Fri Apr 15 15:37:04 2011 -0500
+++ b/src/drivers/oci/Schema.cpp Fri Apr 15 16:21:31 2011 -0500
@@ -37,17 +37,40 @@
#include <libpc/Utils.hpp>
#include <sstream>
-#include <map>
-#include <algorithm>
+
namespace libpc { namespace drivers { namespace oci {
-Schema::Schema()
+
+void OCISchemaGenericErrorHandler
+ (void * userData, xmlErrorPtr error)
+{
+ std::ostringstream oss;
+
+ oss << "Generic XML error: '" << error->message <<"' ";
+ oss << "on line " << error->line;
+ throw schema_error(oss.str());
+}
+
+
+Schema::Schema(std::string xml, std::string xmlschema)
{
LIBXML_TEST_VERSION
+
+
+
+
+ // No network access
+ // http://xmlsoft.org/html/libxml-parser.html#xmlParserOption
+ m_doc = xmlReadMemory(&(xml[0]), xml.size(), "noname.xml", NULL, XML_PARSE_NONET);
+ if (m_doc == NULL) {
+ throw schema_error("Failed to parse document");
+ }
+
+
return;
}
diff -r f16753970cbd -r 1db3464d27dd src/drivers/oci/common.cpp
--- a/src/drivers/oci/common.cpp Fri Apr 15 15:37:04 2011 -0500
+++ b/src/drivers/oci/common.cpp Fri Apr 15 16:21:31 2011 -0500
@@ -154,6 +154,26 @@
// causes a segfault
// m_connection->DestroyType(&blk_extent);
}
+
+Cloud::Cloud(Connection connection)
+ : schema(new std::vector<boost::uint8_t>)
+ , m_connection(connection)
+{
+ m_connection->CreateType(&pc_geometry);
+ m_connection->CreateType(&pc_geometry->sdo_ordinates, m_connection->GetOrdinateType());
+ m_connection->CreateType(&pc_geometry->sdo_elem_info, m_connection->GetElemInfoType());
+ m_connection->CreateType(&pc_domain);
+}
+
+Cloud::~Cloud()
+{
+
+ // FIXME: For some reason having the dtor destroy this
+ // causes a segfault
+ // m_connection->DestroyType(&blk_extent);
+}
+
+
std::string to_upper(const std::string& input)
{
std::string inp = std::string(input);
diff -r f16753970cbd -r 1db3464d27dd test/unit/CMakeLists.txt
--- a/test/unit/CMakeLists.txt Fri Apr 15 15:37:04 2011 -0500
+++ b/test/unit/CMakeLists.txt Fri Apr 15 16:21:31 2011 -0500
@@ -7,7 +7,7 @@
###############################################################################
SET(LIBPC_UNIT_TEST libpc_test)
-SET(LIBPC_UNIT_TEST_SRC
+SET(LIBPC_UNITTEST_TEST_SRC
BoundsTest.cpp
CacheFilterTest.cpp
ChipperTest.cpp
@@ -31,27 +31,60 @@
SignallerTest.cpp
UtilsTest.cpp
VectorTest.cpp
- support.cpp
- support.hpp
- main.cpp)
+ )
+
+SET(LIBPC_UNITTEST_TEST_INC
+ )
+
+SET(LIBPC_UNITTEST_CONFIG_SRC
+ Support.cpp
+ TestConfig.cpp
+ main.cpp
+ )
+
+SET(LIBPC_UNITTEST_CONFIG_INC
+ Support.hpp
+ TestConfig.hpp
+ )
+
if (WITH_ORACLE)
set(LIBPC_OCI_TEST_CPP OCITest.cpp)
FOREACH(file ${LIBPC_OCI_TEST_CPP})
- SET(LIBPC_UNIT_TEST_SRC "${LIBPC_UNIT_TEST_SRC};${file}" CACHE INTERNAL "source files for test")
+ SET(LIBPC_UNITTEST_TEST_SRC "${LIBPC_UNITTEST_TEST_SRC};${file}" CACHE INTERNAL "source files for test")
ENDFOREACH(file)
endif (WITH_ORACLE)
+set(LIBPC_UNITTEST_SOURCES "")
+FOREACH(file ${LIBPC_UNITTEST_TEST_SRC})
+ SET(LIBPC_UNITTEST_SOURCES "${LIBPC_UNITTEST_SOURCES};${file}" CACHE INTERNAL "source files for test")
+ENDFOREACH(file)
+FOREACH(file ${LIBPC_UNITTEST_TEST_INC})
+ SET(LIBPC_UNITTEST_SOURCES "${LIBPC_UNITTEST_SOURCES};${file}" CACHE INTERNAL "source files for test")
+ENDFOREACH(file)
+FOREACH(file ${LIBPC_UNITTEST_CONFIG_SRC})
+ SET(LIBPC_UNITTEST_SOURCES "${LIBPC_UNITTEST_SOURCES};${file}" CACHE INTERNAL "source files for test")
+ENDFOREACH(file)
+FOREACH(file ${LIBPC_UNITTEST_CONFIG_INC})
+ SET(LIBPC_UNITTEST_SOURCES "${LIBPC_UNITTEST_SOURCES};${file}" CACHE INTERNAL "source files for test")
+ENDFOREACH(file)
+
+source_group("Header Files" FILES ${LIBPC_UNITTEST_TEST_INC})
+source_group("Header Files\\config" FILES ${LIBPC_UNITTEST_CONFIG_INC})
+source_group("Source Files" FILES ${LIBPC_UNITTEST_TEST_SRC})
+source_group("Source Files\\config" FILES ${LIBPC_UNITTEST_CONFIG_SRC})
+
+
INCLUDE_DIRECTORIES(
.
../../include
${GDAL_INCLUDE_DIR}
${GEOTIFF_INCLUDE_DIR})
-ADD_EXECUTABLE(${LIBPC_UNIT_TEST} ${LIBPC_UNIT_TEST_SRC} )
+ADD_EXECUTABLE(${LIBPC_UNIT_TEST} ${LIBPC_UNITTEST_SOURCES})
set_target_properties(${LIBPC_UNIT_TEST} PROPERTIES COMPILE_DEFINITIONS LIBPC_DLL_IMPORT)
diff -r f16753970cbd -r 1db3464d27dd test/unit/ChipperTest.cpp
--- a/test/unit/ChipperTest.cpp Fri Apr 15 15:37:04 2011 -0500
+++ b/test/unit/ChipperTest.cpp Fri Apr 15 16:21:31 2011 -0500
@@ -39,7 +39,7 @@
#include <libpc/drivers/liblas/Writer.hpp>
#include <libpc/drivers/liblas/Reader.hpp>
-#include "support.hpp"
+#include "Support.hpp"
using namespace libpc;
using namespace libpc::drivers::liblas;
@@ -49,7 +49,7 @@
BOOST_AUTO_TEST_CASE(test_construction)
{
- LiblasReader reader(TestConfig::g_data_path + "1.2-with-color.las");
+ LiblasReader reader(Support::datapath("1.2-with-color.las"));
{
const boost::uint64_t num_points = reader.getNumPoints();
diff -r f16753970cbd -r 1db3464d27dd test/unit/LiblasReaderTest.cpp
--- a/test/unit/LiblasReaderTest.cpp Fri Apr 15 15:37:04 2011 -0500
+++ b/test/unit/LiblasReaderTest.cpp Fri Apr 15 16:21:31 2011 -0500
@@ -40,7 +40,7 @@
#include <libpc/SchemaLayout.hpp>
More information about the Liblas-commits
mailing list