[Liblas-commits] hg-main-tree: add a getStreamPrecision method to
take a scale va...
liblas-commits at liblas.org
liblas-commits at liblas.org
Mon Jun 6 17:58:16 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/4f69db54a850
changeset: 756:4f69db54a850
user: Howard Butler <hobu.inc at gmail.com>
date: Mon Jun 06 16:55:27 2011 -0500
description:
add a getStreamPrecision method to take a scale value and turn it into a fixed precision value for setting on a std::ostream
Subject: hg-main-tree: add offset and scale to the operator<< output
details: http://hg.libpc.orghg-main-tree/rev/01d79d07e035
changeset: 757:01d79d07e035
user: Howard Butler <hobu.inc at gmail.com>
date: Mon Jun 06 16:56:10 2011 -0500
description:
add offset and scale to the operator<< output
Subject: hg-main-tree: add scale, offset, endianness information from the XML schema to the libpc::Schema when reading
details: http://hg.libpc.orghg-main-tree/rev/5811f9e23923
changeset: 758:5811f9e23923
user: Howard Butler <hobu.inc at gmail.com>
date: Mon Jun 06 16:56:44 2011 -0500
description:
add scale, offset, endianness information from the XML schema to the libpc::Schema when reading
Subject: hg-main-tree: assert that the number of points we read is the number we've processed
details: http://hg.libpc.orghg-main-tree/rev/ae706fa241ff
changeset: 759:ae706fa241ff
user: Howard Butler <hobu.inc at gmail.com>
date: Mon Jun 06 16:57:37 2011 -0500
description:
assert that the number of points we read is the number we've processed
Subject: hg-main-tree: comment out debugging lint for a day when we have a real debugging system
details: http://hg.libpc.orghg-main-tree/rev/f25b3be0a0cd
changeset: 760:f25b3be0a0cd
user: Howard Butler <hobu.inc at gmail.com>
date: Mon Jun 06 16:58:08 2011 -0500
description:
comment out debugging lint for a day when we have a real debugging system
diffstat:
include/libpc/Utils.hpp | 5 +++
src/Dimension.cpp | 46 ++++++++++++++++++++++++++------
src/Utils.cpp | 14 +++++++++
src/XMLSchema.cpp | 48 +++++++++++++++++++++++++++++----
src/drivers/oci/Iterator.cpp | 18 ++++++------
src/drivers/oci/Reader.cpp | 9 ++---
src/drivers/oci/Writer.cpp | 8 ++--
src/filters/ByteSwapFilterIterator.cpp | 3 +-
8 files changed, 117 insertions(+), 34 deletions(-)
diffs (truncated from 345 to 300 lines):
diff -r 41bdc454e090 -r f25b3be0a0cd include/libpc/Utils.hpp
--- a/include/libpc/Utils.hpp Mon Jun 06 15:47:23 2011 -0500
+++ b/include/libpc/Utils.hpp Mon Jun 06 16:58:08 2011 -0500
@@ -161,6 +161,9 @@
static std::string trim(const std::string& str);
+ static boost::uint32_t getStreamPrecision(double scale);
+
+
private:
template<typename T>
static inline char* as_buffer(T& data)
@@ -199,6 +202,8 @@
throw std::runtime_error("fatal I/O error occured");
return true;
}
+
+
};
diff -r 41bdc454e090 -r f25b3be0a0cd src/Dimension.cpp
--- a/src/Dimension.cpp Mon Jun 06 15:47:23 2011 -0500
+++ b/src/Dimension.cpp Mon Jun 06 16:58:08 2011 -0500
@@ -145,16 +145,23 @@
e = std::string("big");
dim.put("endianness", e);
- if (isNumeric())
+
+ if (! (Utils::compare_distance(getMinimum(), getMaximum()) &&
+ Utils::compare_distance(0.0, getMaximum())))
{
- if (! (Utils::compare_distance(getMinimum(), getMaximum()) &&
- Utils::compare_distance(0.0, getMaximum())))
- {
- dim.put("minimum", getMinimum());
- dim.put("maximum", getMaximum());
- }
+ dim.put("minimum", getMinimum());
+ dim.put("maximum", getMaximum());
}
-
+ if (! (Utils::compare_distance(getNumericScale(), 0.0)))
+ {
+ dim.put("scale", getNumericScale());
+ }
+ if (! (Utils::compare_distance(getNumericOffset(), 0.0)))
+ {
+ dim.put("offset", getNumericOffset());
+ }
+
+ dim.put("scale", getNumericScale());
return dim;
}
@@ -171,13 +178,34 @@
std::ostringstream pad;
std::string const& cur = quoted_name.str();
std::string::size_type size = cur.size();
- std::string::size_type pad_size = 30 - size;
+ std::string::size_type pad_size = 24 - size;
for (std::string::size_type i=0; i != pad_size; i++ )
{
pad << " ";
}
os << quoted_name.str() << pad.str() <<" -- "<< " size: " << tree.get<boost::uint32_t>("bytesize");
+
+ try {
+ double value = tree.get<double>("scale");
+ boost::uint32_t precision = Utils::getStreamPrecision(value);
+ os.setf(std::ios_base::fixed, std::ios_base::floatfield);
+ os.precision(6);
+ os << " scale: " << value;
+ }
+ catch (boost::property_tree::ptree_bad_path const& ) {
+ }
+
+ try {
+ double value = tree.get<double>("offset");
+ boost::uint32_t precision = Utils::getStreamPrecision(value);
+ os.setf(std::ios_base::fixed, std::ios_base::floatfield);
+ os.precision(precision);
+ os << " offset: " << value;
+ }
+ catch (boost::property_tree::ptree_bad_path const& ) {
+ }
+
//os << " offset: " << tree.get<boost::uint32_t>("byteoffset");
os << std::endl;
diff -r 41bdc454e090 -r f25b3be0a0cd src/Utils.cpp
--- a/src/Utils.cpp Mon Jun 06 15:47:23 2011 -0500
+++ b/src/Utils.cpp Mon Jun 06 16:58:08 2011 -0500
@@ -225,5 +225,19 @@
return str.substr( startpos, endpos-startpos+1 );
}
+boost::uint32_t Utils::getStreamPrecision(double scale)
+{
+ double frac = 0;
+ double integer = 0;
+
+ frac = std::modf(scale, &integer);
+ double precision = std::fabs(std::floor(std::log10(frac)));
+
+ // FIXME: This should test that precision actually ends up being a
+ // whole number
+ boost::uint32_t output = static_cast<boost::uint32_t>(precision);
+ return output;
+}
+
} // namespace libpc
diff -r 41bdc454e090 -r f25b3be0a0cd src/XMLSchema.cpp
--- a/src/XMLSchema.cpp Mon Jun 06 15:47:23 2011 -0500
+++ b/src/XMLSchema.cpp Mon Jun 06 16:58:08 2011 -0500
@@ -386,14 +386,15 @@
xmlNode* properties = dimension->children;
std::string name;
- boost::uint32_t size;
+ boost::uint32_t size(0);
boost::uint32_t position(1);
std::string description;
std::string interpretation;
- double offset;
- double scale;
- double minimum;
- double maximum;
+ double offset(0.0);
+ double scale(0.0);
+ double minimum(0.0);
+ double maximum(0.0);
+ EndianType endianness = Endian_Little;
while(properties != NULL)
{
@@ -495,6 +496,19 @@
xmlFree(n);
// std::cout << "Dimension scale: " << scale << std::endl;
}
+ if (!compare_no_case((const char*)properties->name, "endianness"))
+ {
+ xmlChar* n = xmlNodeListGetString(doc, properties->children, 1);
+ if (!n) throw schema_loading_error("Unable to fetch endianness value!");
+
+ if (!compare_no_case((const char*) n, "big"))
+ endianness = Endian_Big;
+ else
+ endianness = Endian_Little;
+
+ xmlFree(n);
+ // std::cout << "Dimension endianness: " << endianness << std::endl;
+ }
// printf("property name: %s\n", properties->name);
properties = properties->next;
@@ -504,6 +518,29 @@
Dimension::Field f = GetDimensionField(name, position);
Dimension d(f, t);
+ if (! Utils::compare_distance(scale, 0.0))
+ {
+ d.setNumericScale(scale);
+ }
+ if (! Utils::compare_distance(offset, 0.0))
+ {
+ d.setNumericOffset(offset);
+ }
+ if (! Utils::compare_distance(minimum, 0.0))
+ {
+ d.setMinimum(minimum);
+ }
+ if (! Utils::compare_distance(maximum, 0.0))
+ {
+ d.setMaximum(maximum);
+ }
+
+ if (description.size())
+ {
+ d.setDescription(description);
+ }
+ d.setEndianness(endianness);
+
DimensionLayout l(d);
l.setPosition(position);
layouts.push_back(l);
@@ -519,7 +556,6 @@
m_schema.addDimension(i->getDimension());
}
- // m_schema.dump();
}
Dimension::DataType Reader::GetDimensionType(std::string const& interpretation)
diff -r 41bdc454e090 -r f25b3be0a0cd src/drivers/oci/Iterator.cpp
--- a/src/drivers/oci/Iterator.cpp Mon Jun 06 15:47:23 2011 -0500
+++ b/src/drivers/oci/Iterator.cpp Mon Jun 06 16:58:08 2011 -0500
@@ -219,7 +219,7 @@
bool bDidRead = false;
- std::cout << "m_block->num_points: " << m_block->num_points << std::endl;
+ // std::cout << "m_block->num_points: " << m_block->num_points << std::endl;
if (!m_block->num_points)
{
// We still have a block of data from the last readBuffer call
@@ -272,7 +272,7 @@
m_block->chunk->resize(blob_length);
}
- std::cout << "blob_length: " << blob_length << std::endl;
+ // std::cout << "blob_length: " << blob_length << std::endl;
bool read_all_data = m_statement->ReadBlob( m_block->locator,
(void*)(&(*m_block->chunk)[0]),
@@ -280,7 +280,7 @@
&nAmountRead);
if (!read_all_data) throw libpc_error("Did not read all blob data!");
- std::cout << "nAmountRead: " << nAmountRead << std::endl;
+ // std::cout << "nAmountRead: " << nAmountRead << std::endl;
data.setNumPoints(numPointsRead);
data.setAllData(&(*m_block->chunk)[0], m_block->chunk->size());
@@ -303,17 +303,17 @@
// m_statement->GetElement(&(m_block->blk_extent->sdo_elem_info), 1, &elem2);
// m_statement->GetElement(&(m_block->blk_extent->sdo_elem_info), 2, &elem3);
//
- boost::int32_t gtype, srid;
+ // boost::int32_t gtype, srid;
// gtype= m_statement->GetInteger(&(m_block->blk_extent->sdo_gtype));
// srid =m_statement->GetInteger(&(m_block->blk_extent->sdo_srid));
// See http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28400/sdo_objrelschema.htm#g1013735
- boost::uint32_t dimension = gtype / 1000;
- boost::uint32_t geom_type = gtype % 100;
- boost::uint32_t referencing= ((gtype % 1000) / 100);
- std::cout << "dimension: " << dimension << " geometry type: " << geom_type << " referencing " << referencing << std::endl;
+ // boost::uint32_t dimension = gtype / 1000;
+ // boost::uint32_t geom_type = gtype % 100;
+ // boost::uint32_t referencing= ((gtype % 1000) / 100);
+ // std::cout << "dimension: " << dimension << " geometry type: " << geom_type << " referencing " << referencing << std::endl;
libpc::Vector<double> mins;
libpc::Vector<double> maxs;
@@ -344,7 +344,7 @@
m_statement->GetElement(&(m_block->blk_extent->sdo_ordinates), 1, &y);
m_statement->GetElement(&(m_block->blk_extent->sdo_ordinates), 2, &z);
- std::cout << "x, y, z " << x << " " << y << " " << z << std::endl;
+ // std::cout << "x, y, z " << x << " " << y << " " << z << std::endl;
return numPointsRead;
diff -r 41bdc454e090 -r f25b3be0a0cd src/drivers/oci/Reader.cpp
--- a/src/drivers/oci/Reader.cpp Mon Jun 06 15:47:23 2011 -0500
+++ b/src/drivers/oci/Reader.cpp Mon Jun 06 16:58:08 2011 -0500
@@ -78,7 +78,6 @@
if (!bDidRead) throw libpc_error("Unable to fetch a point cloud entry entry!");
Schema& schema = getSchemaRef();
schema = fetchSchema(m_pc);
- std::cout << schema << std::endl;
}
else
@@ -121,8 +120,8 @@
Utils::putenv("CPL_DEBUG=ON");
}
- const char* gdal_debug2 = getenv("CPL_DEBUG");
- std::cout << "Setting GDAL debug handler CPL_DEBUG=" << gdal_debug2 << std::endl;
+ // const char* gdal_debug2 = getenv("CPL_DEBUG");
+ // std::cout << "Setting GDAL debug handler CPL_DEBUG=" << gdal_debug2 << std::endl;
CPLPushErrorHandler(OCIGDALDebugErrorHandler);
}
@@ -380,7 +379,7 @@
isPCObject = true;
if (compare_no_case(szTypeName, "SDO_PC_BLK_TYPE") == 0)
isBlockTableType = true;
- std::cout << "Field " << szFieldName << " is SQLT_NTY with type name " << szTypeName << std::endl;
+ // std::cout << "Field " << szFieldName << " is SQLT_NTY with type name " << szTypeName << std::endl;
}
iCol++;
@@ -506,7 +505,7 @@
if (compare_no_case(szFieldName, "POINTS") == 0)
{
- std::cout << "Defined POINTS as BLOB" << std::endl;
+ // std::cout << "Defined POINTS as BLOB" << std::endl;
m_statement->Define( &(block->locator) );
}
iCol++;
More information about the Liblas-commits
mailing list