[Liblas-commits] hg-main-tree: flips the modes around for
createFile and openFile
liblas-commits at liblas.org
liblas-commits at liblas.org
Fri Apr 15 18:14:19 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/05d6d7cc1030
changeset: 581:05d6d7cc1030
user: Howard Butler <hobu.inc at gmail.com>
date: Fri Apr 15 17:13:15 2011 -0500
description:
flips the modes around for createFile and openFile
Subject: hg-main-tree: remove redundant call, we throw exceptions now
details: http://hg.libpc.orghg-main-tree/rev/f7aa9c5ce6f2
changeset: 582:f7aa9c5ce6f2
user: Howard Butler <hobu.inc at gmail.com>
date: Fri Apr 15 17:13:49 2011 -0500
description:
remove redundant call, we throw exceptions now
Subject: hg-main-tree: start on an OCI-Schema test
details: http://hg.libpc.orghg-main-tree/rev/72fbd814e89b
changeset: 583:72fbd814e89b
user: Howard Butler <hobu.inc at gmail.com>
date: Fri Apr 15 17:14:12 2011 -0500
description:
start on an OCI-Schema test
diffstat:
src/Utils.cpp | 4 +-
src/drivers/oci/Schema.cpp | 8 +-
test/unit/OCITest.cpp | 150 +++++++++++++++++++++++++++++---------------
3 files changed, 102 insertions(+), 60 deletions(-)
diffs (234 lines):
diff -r 07bcedc54f8e -r 72fbd814e89b src/Utils.cpp
--- a/src/Utils.cpp Fri Apr 15 16:40:36 2011 -0500
+++ b/src/Utils.cpp Fri Apr 15 17:14:12 2011 -0500
@@ -79,7 +79,7 @@
if (!Utils::fileExists(filename))
throw libpc_error("File not found: " + filename);
- std::ios::openmode mode = std::ios::out;
+ std::ios::openmode mode = std::ios::in;
if (asBinary)
mode |= std::ios::binary;
@@ -93,7 +93,7 @@
std::ostream* Utils::createFile(std::string const& filename, bool asBinary)
{
- std::ios::openmode mode = std::ios::in;
+ std::ios::openmode mode = std::ios::out;
if (asBinary)
mode |= std::ios::binary;
diff -r 07bcedc54f8e -r 72fbd814e89b src/drivers/oci/Schema.cpp
--- a/src/drivers/oci/Schema.cpp Fri Apr 15 16:40:36 2011 -0500
+++ b/src/drivers/oci/Schema.cpp Fri Apr 15 17:14:12 2011 -0500
@@ -68,7 +68,7 @@
std::ostringstream oss;
- oss << "XML error: '" << error <<"' ";
+ oss << "Generic error: '" << error <<"' ";
throw schema_error(oss.str());
}
@@ -87,10 +87,8 @@
// 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");
- }
+ m_doc = xmlReadMemory(xml.c_str(), xml.size(), "noname.xml", NULL, XML_PARSE_NONET);
+
return;
diff -r 07bcedc54f8e -r 72fbd814e89b test/unit/OCITest.cpp
--- a/test/unit/OCITest.cpp Fri Apr 15 16:40:36 2011 -0500
+++ b/test/unit/OCITest.cpp Fri Apr 15 17:14:12 2011 -0500
@@ -39,6 +39,7 @@
#include <libpc/drivers/oci/Reader.hpp>
#include <libpc/drivers/oci/Writer.hpp>
#include <libpc/drivers/oci/Common.hpp>
+#include <libpc/drivers/oci/Schema.hpp>
#include <libpc/drivers/liblas/Reader.hpp>
@@ -50,6 +51,7 @@
#include <libpc/drivers/liblas/Writer.hpp>
#include <libpc/Iterator.hpp>
+#include <libpc/Utils.hpp>
#include "Support.hpp"
#include "TestConfig.hpp"
@@ -83,6 +85,35 @@
return options;
}
+std::string ReadXML(std::string filename)
+{
+
+ std::istream* infile = Utils::openFile(filename, true);
+ std::ifstream::pos_type size;
+ // char* data;
+ std::vector<char> data;
+ if (infile->good()){
+ size = infile->tellg();
+ data.resize(static_cast<std::vector<char>::size_type>(size));
+ // data = new char [size];
+ infile->seekg (0, std::ios::beg);
+ infile->read (&data.front(), size);
+ // infile->close();
+
+ // delete[] data;
+ delete infile;
+ return std::string(&data[0], data.size());
+ // return data;
+ }
+ else
+ {
+ delete infile;
+ return std::string("");
+ // return data;
+ }
+
+}
+
void RunSQL(Connection connection, std::string sql)
{
Statement statement = Statement(connection->CreateStatement(sql.c_str()));
@@ -94,66 +125,79 @@
-BOOST_AUTO_TEST_CASE(initialize)
-{
- if (!ShouldRunTest()) return;
-
- Options options = GetOptions();
-
- Connection connection = Connect(options);
-
- std::string base_table_name = options.GetPTree().get<std::string>("base_table_name");
- std::string create_pc_table("CREATE TABLE " + base_table_name +" (id number, CLOUD SDO_PC, DESCRIPTION VARCHAR2(20), HEADER BLOB, BOUNDARY SDO_GEOMETRY)");
- RunSQL(connection, create_pc_table);
-
- std::string block_table_name = options.GetPTree().get<std::string>("block_table_name");
- std::string create_block_table = "CREATE TABLE " + block_table_name + " AS SELECT * FROM MDSYS.SDO_PC_BLK_TABLE";
- RunSQL(connection, create_block_table);
-}
+// BOOST_AUTO_TEST_CASE(initialize)
+// {
+// if (!ShouldRunTest()) return;
+//
+// Options options = GetOptions();
+//
+// Connection connection = Connect(options);
+//
+// std::string base_table_name = options.GetPTree().get<std::string>("base_table_name");
+// std::string create_pc_table("CREATE TABLE " + base_table_name +" (id number, CLOUD SDO_PC, DESCRIPTION VARCHAR2(20), HEADER BLOB, BOUNDARY SDO_GEOMETRY)");
+// RunSQL(connection, create_pc_table);
+//
+// std::string block_table_name = options.GetPTree().get<std::string>("block_table_name");
+// std::string create_block_table = "CREATE TABLE " + block_table_name + " AS SELECT * FROM MDSYS.SDO_PC_BLK_TABLE";
+// RunSQL(connection, create_block_table);
+// }
+//
+//
+// BOOST_AUTO_TEST_CASE(test_writer)
+// {
+// if (!ShouldRunTest()) return;
+//
+// Options options = GetOptions();
+// libpc::drivers::liblas::LiblasReader reader(Support::datapath("1.2-with-color.las"));
+//
+// boost::uint32_t capacity = GetOptions().GetPTree().get<boost::uint32_t>("capacity");
+// libpc::filters::CacheFilter cache(reader, 1, 1024);
+// libpc::filters::Chipper chipper(cache, capacity);
+// libpc::drivers::oci::Writer writer(chipper, options);
+//
+// BOOST_CHECK_MESSAGE(writer.getConnection().get(), "Unable to connect to Oracle" );
+//
+// writer.write(0);
+//
+// }
+//
+// BOOST_AUTO_TEST_CASE(test_reader)
+// {
+// if (!ShouldRunTest()) return;
+//
+// Options options = GetOptions();
+//
+// libpc::drivers::oci::Reader reader(options);
+// const boost::uint64_t numPoints = reader.getNumPoints();
+// BOOST_CHECK_EQUAL(numPoints, 0);
+//
+// boost::scoped_ptr<SequentialIterator> iter(reader.createSequentialIterator());
+//
+// PointBuffer buffer(reader.getSchema(), 1065);
+//
+// const boost::uint32_t numPointsReadThisChunk = iter->read(buffer);
+//
+// BOOST_CHECK_EQUAL(numPointsReadThisChunk, 1065);
+// // std::ostream* ofs = Utils::createFile("temp.las");
+// //
+// // libpc::drivers::liblas::LiblasWriter writer(reader, *ofs);
+// // writer.write(0);
+// //
+// // Utils::closeFile(ofs);
+//
+//
+// }
-
-BOOST_AUTO_TEST_CASE(test_writer)
+BOOST_AUTO_TEST_CASE(test_schema)
{
if (!ShouldRunTest()) return;
- Options options = GetOptions();
- libpc::drivers::liblas::LiblasReader reader(Support::datapath("1.2-with-color.las"));
-
- boost::uint32_t capacity = GetOptions().GetPTree().get<boost::uint32_t>("capacity");
- libpc::filters::CacheFilter cache(reader, 1, 1024);
- libpc::filters::Chipper chipper(cache, capacity);
- libpc::drivers::oci::Writer writer(chipper, options);
- BOOST_CHECK_MESSAGE(writer.getConnection().get(), "Unable to connect to Oracle" );
+ std::string xml = ReadXML("/Users/hobu/hg/liblas/schemas/las.xml");
+ std::string xsd = ReadXML("/Users/hobu/hg/liblas/schemas/LAS.xsd");
- writer.write(0);
+ libpc::drivers::oci::Schema schema(xml, xsd);
-}
-
-BOOST_AUTO_TEST_CASE(test_reader)
-{
- if (!ShouldRunTest()) return;
-
- Options options = GetOptions();
-
- libpc::drivers::oci::Reader reader(options);
- const boost::uint64_t numPoints = reader.getNumPoints();
- BOOST_CHECK_EQUAL(numPoints, 0);
-
- boost::scoped_ptr<SequentialIterator> iter(reader.createSequentialIterator());
-
- PointBuffer buffer(reader.getSchema(), 1065);
-
- const boost::uint32_t numPointsReadThisChunk = iter->read(buffer);
-
- BOOST_CHECK_EQUAL(numPointsReadThisChunk, 1065);
- // std::ostream* ofs = Utils::createFile("temp.las");
- //
- // libpc::drivers::liblas::LiblasWriter writer(reader, *ofs);
- // writer.write(0);
- //
- // Utils::closeFile(ofs);
-
}
More information about the Liblas-commits
mailing list