[Liblas-commits] hg-main-tree: add endianness field to
libpc::Dimension to denote...
liblas-commits at liblas.org
liblas-commits at liblas.org
Fri May 6 10:26:06 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/c3a25138e5ba
changeset: 698:c3a25138e5ba
user: Howard Butler <hobu.inc at gmail.com>
date: Fri May 06 09:25:22 2011 -0500
description:
add endianness field to libpc::Dimension to denote layout of the dimension
Subject: hg-main-tree: more schema writing
details: http://hg.libpc.orghg-main-tree/rev/5979df4ffecc
changeset: 699:5979df4ffecc
user: Howard Butler <hobu.inc at gmail.com>
date: Fri May 06 09:25:44 2011 -0500
description:
more schema writing
Subject: hg-main-tree: add scaffolding for QFIT reader
details: http://hg.libpc.orghg-main-tree/rev/b24b73d5636d
changeset: 700:b24b73d5636d
user: Howard Butler <hobu.inc at gmail.com>
date: Fri May 06 09:25:56 2011 -0500
description:
add scaffolding for QFIT reader
diffstat:
include/libpc/Dimension.hpp | 12 +
include/libpc/drivers/qfit/Reader.hpp | 90 ++++++++++++
include/libpc/types.hpp | 6 +
src/CMakeLists.txt | 21 ++
src/Dimension.cpp | 9 +
src/drivers/oci/Schema.cpp | 153 ++++++++++----------
src/drivers/qfit/Reader.cpp | 254 ++++++++++++++++++++++++++++++++++
test/unit/CMakeLists.txt | 1 +
test/unit/DimensionTest.cpp | 1 +
test/unit/QFITReaderTest.cpp | 79 ++++++++++
10 files changed, 550 insertions(+), 76 deletions(-)
diffs (truncated from 1013 to 300 lines):
diff -r a4ad96e13b27 -r b24b73d5636d include/libpc/Dimension.hpp
--- a/include/libpc/Dimension.hpp Sat Apr 30 08:31:52 2011 -0500
+++ b/include/libpc/Dimension.hpp Fri May 06 09:25:56 2011 -0500
@@ -254,11 +254,23 @@
m_precise = v;
}
+ /// The scaling value for this dimension as a double. This should
+ /// be positive or negative powers of ten.
+ inline EndianType getEndianness() const
+ {
+ return m_endian;
+ }
+ inline void setEndianness(EndianType v)
+ {
+ m_endian = v;
+ }
+
boost::property_tree::ptree GetPTree() const;
private:
DataType m_dataType;
Field m_field;
+ EndianType m_endian;
std::size_t m_byteSize;
std::string m_description;
double m_min;
diff -r a4ad96e13b27 -r b24b73d5636d include/libpc/drivers/qfit/Reader.hpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/include/libpc/drivers/qfit/Reader.hpp Fri May 06 09:25:56 2011 -0500
@@ -0,0 +1,90 @@
+/******************************************************************************
+* Copyright (c) 2011, Howard Butler, hobu.inc at gmail.com
+*
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following
+* conditions are met:
+*
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of Hobu, Inc. or Flaxen Geo Consulting nor the
+* names of its contributors may be used to endorse or promote
+* products derived from this software without specific prior
+* written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+* OF SUCH DAMAGE.
+****************************************************************************/
+
+#ifndef INCLUDED_LIBPC_DRIVER_QFIT_READER_HPP
+#define INCLUDED_LIBPC_DRIVER_QFIT_READER_HPP
+
+#include <libpc/libpc.hpp>
+
+#include <libpc/Stage.hpp>
+#include <libpc/Iterator.hpp>
+
+#include <boost/scoped_ptr.hpp>
+#include <boost/scoped_array.hpp>
+
+#include <vector>
+
+namespace libpc { namespace drivers { namespace qfit {
+
+
+
+class LIBPC_DLL Reader : public libpc::Stage
+{
+
+public:
+ Reader(Options& options);
+ ~Reader();
+
+ const std::string& getDescription() const;
+ const std::string& getName() const;
+
+ bool supportsIterator (StageIteratorType t) const
+ {
+ if (t == StageIterator_Sequential ) return true;
+ return false;
+ }
+
+ boost::uint64_t getNumPoints() { return 0; }
+
+ libpc::SequentialIterator* createSequentialIterator() const;
+
+ Options& getOptions() const { return m_options; }
+
+
+private:
+
+ Reader& operator=(const Reader&); // not implemented
+ Reader(const Reader&); // not implemented
+
+ Options& m_options;
+
+ void registerFields();
+
+
+};
+
+}}} // namespace libpc::driver::oci
+
+
+#endif // INCLUDED_LIBPC_DRIVER_OCI_READER_HPP
diff -r a4ad96e13b27 -r b24b73d5636d include/libpc/types.hpp
--- a/include/libpc/types.hpp Sat Apr 30 08:31:52 2011 -0500
+++ b/include/libpc/types.hpp Fri May 06 09:25:56 2011 -0500
@@ -39,6 +39,12 @@
namespace libpc {
+enum EndianType
+{
+ Endian_Little,
+ Endian_Big,
+ Endian_Unknown = 128
+};
enum PointCountType
{
diff -r a4ad96e13b27 -r b24b73d5636d src/CMakeLists.txt
--- a/src/CMakeLists.txt Sat Apr 30 08:31:52 2011 -0500
+++ b/src/CMakeLists.txt Fri May 06 09:25:56 2011 -0500
@@ -227,6 +227,27 @@
ENDFOREACH(file)
endif()
+
+#
+# drivers/qfit
+#
+set(LIBPC_DRIVERS_QFIT_HPP
+ ${LIBPC_HEADERS_DIR}/drivers/qfit/Reader.hpp
+)
+
+set (LIBPC_DRIVERS_QFIT_CPP
+ ./drivers/qfit/Reader.cpp
+)
+
+FOREACH(file ${LIBPC_DRIVERS_QFIT_HPP})
+ SET(LIBPC_HPP "${LIBPC_HPP};${file}" CACHE INTERNAL "source files for foo")
+ENDFOREACH(file)
+
+FOREACH(file ${LIBPC_DRIVERS_QFIT_CPP})
+ SET(LIBPC_CPP "${LIBPC_CPP};${file}" CACHE INTERNAL "source files for foo")
+ENDFOREACH(file)
+
+
#
# filters
#
diff -r a4ad96e13b27 -r b24b73d5636d src/Dimension.cpp
--- a/src/Dimension.cpp Sat Apr 30 08:31:52 2011 -0500
+++ b/src/Dimension.cpp Fri May 06 09:25:56 2011 -0500
@@ -54,6 +54,7 @@
Dimension::Dimension(Field field, DataType dataType)
: m_dataType(dataType)
, m_field(field)
+ , m_endian(libpc::Endian_Little)
, m_byteSize(0)
, m_description(std::string(""))
, m_min(0.0)
@@ -69,6 +70,7 @@
Dimension::Dimension(Dimension const& other)
: m_dataType(other.m_dataType)
, m_field(other.m_field)
+ , m_endian(other.m_endian)
, m_byteSize(other.m_byteSize)
, m_description(other.m_description)
, m_min(other.m_min)
@@ -86,6 +88,7 @@
{
m_dataType = rhs.m_dataType;
m_field = rhs.m_field;
+ m_endian = rhs.m_endian;
m_byteSize = rhs.m_byteSize;
m_description = rhs.m_description;
m_min = rhs.m_min;
@@ -103,6 +106,7 @@
{
if (m_dataType == other.m_dataType &&
m_field == other.m_field &&
+ m_endian == other.m_endian &&
m_byteSize == other.m_byteSize &&
m_description == other.m_description &&
Utils::compare_approx(m_min, other.m_min, (std::numeric_limits<double>::min)()) &&
@@ -135,6 +139,11 @@
dim.put("datatype", getDataTypeName(getDataType()));
dim.put("description", getDescription());
dim.put("bytesize", getByteSize());
+
+ std::string e("little");
+ if (getEndianness() == Endian_Big)
+ e = std::string("big");
+ dim.put("endianness", e);
if (isNumeric())
{
diff -r a4ad96e13b27 -r b24b73d5636d src/drivers/oci/Schema.cpp
--- a/src/drivers/oci/Schema.cpp Sat Apr 30 08:31:52 2011 -0500
+++ b/src/drivers/oci/Schema.cpp Fri May 06 09:25:56 2011 -0500
@@ -1,6 +1,5 @@
/******************************************************************************
-* Copyright (c) 2011, Howard Butler, hobu.inc at gmail.com
-*
+* Copyright (c) 2011, Howard Butler, hobu.inc at gmail.com *
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -100,13 +99,13 @@
namespace libpc { namespace drivers { namespace oci {
-void OCISchemaStructuredErrorHandler
+void OCISchemaStructuredErrorHandler
(void * userData, xmlErrorPtr error)
{
std::ostringstream oss;
-
+
oss << "XML error: '" << error->message <<"' ";
-
+
if (error->str1)
oss << " extra info1: '" << error->str1 << "' ";
if (error->str2)
@@ -114,41 +113,41 @@
if (error->str3)
oss << " extra info3: '" << error->str3 << "' ";
oss << "on line " << error->line;
-
+
if (error->ctxt)
{
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) error->ctxt;
xmlParserInputPtr input = ctxt->input;
-
+
xmlParserPrintFileContext(input);
}
throw schema_error(oss.str());
}
-void OCISchemaParserStructuredErrorHandler
+void OCISchemaParserStructuredErrorHandler
(void * userData, xmlErrorPtr error)
{
std::ostringstream oss;
-
+
oss << "Schema parsing error: '" << error->message <<"' ";
oss << "on line " << error->line;
throw schema_parsing_error(oss.str());
}
-void OCISchemaValidationStructuredErrorHandler
+void OCISchemaValidationStructuredErrorHandler
(void * userData, xmlErrorPtr error)
{
std::ostringstream oss;
-
+
oss << "Schema validation error: '" << error->message <<"' ";
oss << "on line " << error->line;
throw schema_validation_error(oss.str());
}
-void OCISchemaValidityError
+void OCISchemaValidityError
(void * ctx, const char* message, ... )
{
-
+
const int ERROR_MESSAGE_SIZE = 256;
char error[ERROR_MESSAGE_SIZE];
va_list arg_ptr;
@@ -157,18 +156,18 @@
vsnprintf(error, ERROR_MESSAGE_SIZE, message, arg_ptr);
va_end(arg_ptr);
-
+
std::ostringstream oss;
More information about the Liblas-commits
mailing list