[Liblas-commits] hg: 3 new changesets
liblas-commits at liblas.org
liblas-commits at liblas.org
Thu Nov 18 12:16:10 EST 2010
changeset 65a798a87d8b in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=65a798a87d8b
summary: make a GetStreamPrecision utility function isntead of copying same functionality all over the place
changeset 55b13d84e958 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=55b13d84e958
summary: merge
changeset 40ce9d65ecce in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=40ce9d65ecce
summary: whoops
diffstat:
include/liblas/lasindex.hpp | 6 +++---
include/liblas/utility.hpp | 2 ++
src/lasheader.cpp | 12 ++++--------
src/lasindex.cpp | 31 ++++++++++++++++++-------------
src/lastransform.cpp | 2 +-
src/utility.cpp | 22 +++++++++++++++-------
6 files changed, 43 insertions(+), 32 deletions(-)
diffs (161 lines):
diff -r 50d7bae327ba -r 40ce9d65ecce include/liblas/lasindex.hpp
--- a/include/liblas/lasindex.hpp Tue Nov 16 11:54:41 2010 -0600
+++ b/include/liblas/lasindex.hpp Thu Nov 18 11:16:00 2010 -0600
@@ -492,9 +492,9 @@
boost::uint8_t MinMinorVersion(void) {return(2);};
public:
- /// n=0 or n=1 gives next sequence with no gap, n>1 skips n-1 filter-compliant points, n<0 skips backwards
+ /// n=0 or n=1 gives next sequence with no gap, n>1 skips n-1 filter-compliant points, n<0 jumps backwards n compliant points
const std::vector<boost::uint32_t>& advance(boost::int32_t n);
- /// returns filter-compliant points beginning with the nth compliant point, 0 and 1 return first set of compliant points
+ /// returns filter-compliant points as though the first point returned is element n in a zero-based array
const std::vector<boost::uint32_t>& operator()(boost::int32_t n);
/// returns next set of filter-compliant points with no skipped points
inline const std::vector<boost::uint32_t>& operator++() {return (advance(1));}
@@ -512,7 +512,7 @@
inline const std::vector<boost::uint32_t>& operator-=(boost::int32_t n) {return (advance(-n));}
/// returns set of filter-compliant points beginning n points backwards from the end of the last set, for n<0 acts like +()
inline const std::vector<boost::uint32_t>& operator-(boost::int32_t n) {return (advance(-n));}
- /// returns filter-compliant points beginning with the nth compliant point, 0 and 1 return first set of compliant points
+ /// returns filter-compliant points as though the first point returned is element n in a zero-based array
inline const std::vector<boost::uint32_t>& operator[](boost::int32_t n) {return ((*this)(n));}
/// tests viability of index for filtering with iterator
bool ValidateIndexVersion(boost::uint8_t VersionMajor, boost::uint8_t VersionMinor) {return (VersionMajor > MinMajorVersion() || (VersionMajor == MinMajorVersion() && VersionMinor >= MinMinorVersion()));};
diff -r 50d7bae327ba -r 40ce9d65ecce include/liblas/utility.hpp
--- a/include/liblas/utility.hpp Tue Nov 16 11:54:41 2010 -0600
+++ b/include/liblas/utility.hpp Thu Nov 18 11:16:00 2010 -0600
@@ -91,6 +91,8 @@
LAS_DLL std::ostream& operator<<(std::ostream& os, liblas::Summary const& s);
+boost::uint32_t GetStreamPrecision(double scale);
+
} // namespace liblas
#endif // ndef LIBLAS_LASSUMMARY_HPP_INCLUDED
diff -r 50d7bae327ba -r 40ce9d65ecce src/lasheader.cpp
--- a/src/lasheader.cpp Tue Nov 16 11:54:41 2010 -0600
+++ b/src/lasheader.cpp Thu Nov 18 11:16:00 2010 -0600
@@ -45,6 +45,7 @@
#include <liblas/lasspatialreference.hpp>
#include <liblas/lasschema.hpp>
#include <liblas/detail/private_utility.hpp>
+#include <liblas/utility.hpp>
// boost
#include <boost/cstdint.hpp>
#include <boost/lambda/lambda.hpp>
@@ -831,15 +832,10 @@
boost::uint32_t x_precision = 6;
boost::uint32_t y_precision = 6;
boost::uint32_t z_precision = 6;
- double frac = 0;
- double integer = 0;
- frac = std::modf(x_scale, &integer);
- x_precision = static_cast<boost::uint32_t>(std::fabs(std::floor(std::log10(frac))));
- frac = std::modf(y_scale, &integer);
- y_precision = static_cast<boost::uint32_t>(std::fabs(std::floor(std::log10(frac))));
- frac = std::modf(z_scale, &integer);
- z_precision = static_cast<boost::uint32_t>(std::fabs(std::floor(std::log10(frac))));
+ x_precision = GetStreamPrecision(x_scale);
+ y_precision = GetStreamPrecision(y_scale);
+ z_precision = GetStreamPrecision(z_scale);
os << " Scale Factor X Y Z: ";
os.precision(x_precision);
diff -r 50d7bae327ba -r 40ce9d65ecce src/lasindex.cpp
--- a/src/lasindex.cpp Tue Nov 16 11:54:41 2010 -0600
+++ b/src/lasindex.cpp Thu Nov 18 11:16:00 2010 -0600
@@ -2127,24 +2127,29 @@
const std::vector<boost::uint32_t>& IndexIterator::operator()(boost::int32_t n)
{
- if (n < 0)
- n = 0;
- if ((boost::uint32_t)n <= m_conformingPtsFound)
+ if (n <= 0)
+ {
ResetPosition();
- n -= m_conformingPtsFound;
- return (advance(n));
+ m_advance = 1;
+ } // if
+ else if (n < m_conformingPtsFound)
+ {
+ ResetPosition();
+ m_advance = n + 1;
+ } // if
+ else
+ {
+ m_advance = n - m_conformingPtsFound + 1;
+ } // else
+ m_indexData.SetIterator(this);
+ return (m_index->Filter(m_indexData));
} // IndexIterator::operator++
const std::vector<boost::uint32_t>& IndexIterator::advance(boost::int32_t n)
{
- if (n < 0)
- {
- n = m_conformingPtsFound + n;
- return((*this)(n));
- } // if
- m_advance = n;
- m_indexData.SetIterator(this);
- return (m_index->Filter(m_indexData));
+ if (n > 0)
+ --n;
+ return ((*this)(m_conformingPtsFound + n));
} // IndexIterator::advance
} // namespace liblas
diff -r 50d7bae327ba -r 40ce9d65ecce src/lastransform.cpp
--- a/src/lastransform.cpp Tue Nov 16 11:54:41 2010 -0600
+++ b/src/lastransform.cpp Thu Nov 18 11:16:00 2010 -0600
@@ -129,7 +129,7 @@
msg << "Could not project point for ReprojectionTransform::" << CPLGetLastErrorMsg() << ret;
throw std::runtime_error(msg.str());
}
-
+
if (m_new_header.get())
{
point.SetHeaderPtr(m_new_header);
diff -r 50d7bae327ba -r 40ce9d65ecce src/utility.cpp
--- a/src/utility.cpp Tue Nov 16 11:54:41 2010 -0600
+++ b/src/utility.cpp Thu Nov 18 11:16:00 2010 -0600
@@ -312,13 +312,9 @@
double x_scale = tree.get<double>("summary.header.scale.x");
double y_scale = tree.get<double>("summary.header.scale.y");
double z_scale = tree.get<double>("summary.header.scale.z");
- frac = std::modf(x_scale, &integer);
- x_precision = static_cast<boost::uint32_t>(std::fabs(std::floor(std::log10(frac))));
- frac = std::modf(y_scale, &integer);
- y_precision = static_cast<boost::uint32_t>(std::fabs(std::floor(std::log10(frac))));
- frac = std::modf(z_scale, &integer);
- z_precision = static_cast<boost::uint32_t>(std::fabs(std::floor(std::log10(frac))));
-
+ x_precision = GetStreamPrecision(x_scale);
+ y_precision = GetStreamPrecision(y_scale);
+ z_precision = GetStreamPrecision(z_scale);
}
catch (liblas::property_tree::ptree_bad_path const& e) {
@@ -462,4 +458,16 @@
}
+
+boost::uint32_t GetStreamPrecision(double scale)
+{
+ double frac = 0;
+ double integer = 0;
+
+ frac = std::modf(scale, &integer);
+ double precision = std::fabs(std::floor(std::log10(frac)));
+
+ boost::uint32_t output = static_cast<boost::uint32_t>(precision);
+ return output;
+}
} // namespace liblas
More information about the Liblas-commits
mailing list