[Liblas-commits] hg: 5 new changesets

liblas-commits at liblas.org liblas-commits at liblas.org
Sat Oct 9 23:37:08 EDT 2010


changeset c3acfa1a75ec in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=c3acfa1a75ec
summary: rename m_format_data to m_data

changeset ebc2212ae196 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=ebc2212ae196
summary: cleanup, move term_progress to kernel for reuse

changeset 31b0383b2743 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=31b0383b2743
summary: cleanups

changeset 0e4a8bfc5206 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=0e4a8bfc5206
summary: inline methods, add some docs

changeset 1b4e0a36cdd8 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=1b4e0a36cdd8
summary: update SetHeaderPtr to do some accounting when the schema appears to change

diffstat:

 apps/las2las2.cpp               |   41 -----------
 apps/laskernel.cpp              |   30 ++++++++
 apps/laskernel.hpp              |    1 +
 include/liblas/lasdimension.hpp |   61 +++++++++-------
 include/liblas/laspoint.hpp     |    7 +-
 src/laspoint.cpp                |  145 +++++++++++++++++++++++++++------------
 src/lasschema.cpp               |   50 ++-----------
 7 files changed, 176 insertions(+), 159 deletions(-)

diffs (truncated from 752 to 300 lines):

diff -r 684912262acb -r 1b4e0a36cdd8 apps/las2las2.cpp
--- a/apps/las2las2.cpp	Sat Oct 09 21:36:25 2010 -0500
+++ b/apps/las2las2.cpp	Sat Oct 09 22:36:54 2010 -0500
@@ -15,52 +15,11 @@
 #include <boost/cstdint.hpp>
 #include <boost/foreach.hpp>
 
-
-typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
-
 namespace po = boost::program_options;
 
 using namespace liblas;
 using namespace std;
 
-#ifdef _WIN32
-#define compare_no_case(a,b,n)  _strnicmp( (a), (b), (n) )
-#else
-#define compare_no_case(a,b,n)  strncasecmp( (a), (b), (n) )
-#endif
-
-bool term_progress(std::ostream& os, double complete)
-{
-    static int lastTick = -1;
-    int tick = static_cast<int>(complete * 40.0);
-
-    tick = std::min(40, std::max(0, tick));
-
-    // Have we started a new progress run?  
-    if (tick < lastTick && lastTick >= 39)
-        lastTick = -1;
-
-    if (tick <= lastTick)
-        return true;
-
-    while (tick > lastTick)
-    {
-        lastTick++;
-        if (lastTick % 4 == 0)
-            os << (lastTick / 4) * 10;
-        else
-            os << ".";
-    }
-
-    if( tick == 40 )
-        os << " - done.\n";
-    else
-        os.flush();
-
-    return true;
-}
-
-
 liblas::Writer* start_writer(   std::ofstream* strm, 
                                 std::string const& output, 
                                 liblas::Header const& header)
diff -r 684912262acb -r 1b4e0a36cdd8 apps/laskernel.cpp
--- a/apps/laskernel.cpp	Sat Oct 09 21:36:25 2010 -0500
+++ b/apps/laskernel.cpp	Sat Oct 09 22:36:54 2010 -0500
@@ -56,6 +56,36 @@
     }
 }
 
+bool term_progress(std::ostream& os, double complete)
+{
+    static int lastTick = -1;
+    int tick = static_cast<int>(complete * 40.0);
+
+    tick = std::min(40, std::max(0, tick));
+
+    // Have we started a new progress run?  
+    if (tick < lastTick && lastTick >= 39)
+        lastTick = -1;
+
+    if (tick <= lastTick)
+        return true;
+
+    while (tick > lastTick)
+    {
+        lastTick++;
+        if (lastTick % 4 == 0)
+            os << (lastTick / 4) * 10;
+        else
+            os << ".";
+    }
+
+    if( tick == 40 )
+        os << " - done.\n";
+    else
+        os.flush();
+
+    return true;
+}
 
 
 bool IsDualRangeFilter(std::string parse_string) 
diff -r 684912262acb -r 1b4e0a36cdd8 apps/laskernel.hpp
--- a/apps/laskernel.hpp	Sat Oct 09 21:36:25 2010 -0500
+++ b/apps/laskernel.hpp	Sat Oct 09 22:36:54 2010 -0500
@@ -94,5 +94,6 @@
 std::istream* OpenInput(std::string filename, bool bEnd);
 std::string TryReadFileData(std::string filename);
 std::vector<char> TryReadRawFileData(std::string filename);
+bool term_progress(std::ostream& os, double complete);
 
 #endif // LIBLAS_ITERATOR_HPP_INCLUDED
diff -r 684912262acb -r 1b4e0a36cdd8 include/liblas/lasdimension.hpp
--- a/include/liblas/lasdimension.hpp	Sat Oct 09 21:36:25 2010 -0500
+++ b/include/liblas/lasdimension.hpp	Sat Oct 09 22:36:54 2010 -0500
@@ -121,59 +121,68 @@
     }
 
     /// Is this dimension required by PointFormatName
-    bool IsRequired() const { return m_required; }
-    void IsRequired(bool v) { m_required = v; }
+    inline bool IsRequired() const { return m_required; }
+    inline void IsRequired(bool v) { m_required = v; }
 
     /// Is this dimension being used.  A dimension with 
     /// IsActive false may exist as a placeholder in PointFormatName-specified
     /// dimensions, but have their IsActive flag set to false.  In this 
     /// case, those values may be disregarded.
-    bool IsActive() const { return m_active; }
-    void IsActive(bool v) { m_active = v; }
+    inline bool IsActive() const { return m_active; }
+    inline void IsActive(bool v) { m_active = v; }
 
-    std::string GetDescription() const { return m_description; }
-    void SetDescription(std::string const& v) { m_description = v; }
+    inline std::string GetDescription() const { return m_description; }
+    inline void SetDescription(std::string const& v) { m_description = v; }
 
     /// Is this dimension a numeric dimension.  Dimensions with IsNumeric == false
     /// are considered generic bit/byte fields/
-    bool IsNumeric() const { return m_numeric ; }
-    void IsNumeric(bool v) { m_numeric = v; }
+    inline bool IsNumeric() const { return m_numeric ; }
+    inline void IsNumeric(bool v) { m_numeric = v; }
 
     /// Does this dimension have a sign?  Only applicable to dimensions with 
     /// IsNumeric == true.
-    bool IsSigned() const { return m_signed; }
-    void IsSigned(bool v) { m_signed = v; }
+    inline bool IsSigned() const { return m_signed; }
+    inline void IsSigned(bool v) { m_signed = v; }
 
     /// Does this dimension interpret to an integer?  Only applicable to dimensions 
     /// with IsNumeric == true.
-    bool IsInteger() const { return m_integer; }
-    void IsInteger(bool v) { m_integer = v; }
+    inline bool IsInteger() const { return m_integer; }
+    inline void IsInteger(bool v) { m_integer = v; }
 
     /// The minimum value of this dimension as a double
-    double GetMinimum() const { return m_min; }
-    void SetMinimum(double min) { m_min = min; }
+    inline double GetMinimum() const { return m_min; }
+    inline void SetMinimum(double min) { m_min = min; }
     
     /// The maximum value of this dimension as a double
-    double GetMaximum() const { return m_max; }
-    void SetMaximum(double max) { m_max = max; }
+    inline double GetMaximum() const { return m_max; }
+    inline void SetMaximum(double max) { m_max = max; }
     
-    boost::uint32_t GetPosition() const { return m_position; }
-    void SetPosition(boost::uint32_t v) { m_position = v; }
+    /// The index position of the index.  In a standard ePointFormat0 
+    /// data record, the X dimension would have a position of 0, while 
+    /// the Y dimension would have a position of 1, for example.
+    inline boost::uint32_t GetPosition() const { return m_position; }
+    inline void SetPosition(boost::uint32_t v) { m_position = v; }
     
-    double GetScale() const { return m_scale; }
-    void SetScale(double v) { m_scale = v; }
+    /// The scaling value for this dimension as a double.  This should 
+    /// be positive or negative powers of ten.
+    inline double GetScale() const { return m_scale; }
+    inline void SetScale(double v) { m_scale = v; }
     
-    double GetOffset() const { return m_offset; }
-    void SetOffset(double v) { m_offset = v; }
+    /// The offset value for this dimension.  Usually zero, but it 
+    /// can be set to any value in combination with the scale to 
+    /// allow for more expressive ranges.
+    inline double GetOffset() const { return m_offset; }
+    inline void SetOffset(double v) { m_offset = v; }
     
-    bool IsFinitePrecision() const { return m_precise; }
-    void IsFinitePrecision(bool v) { m_precise = v; }
+    /// If true, this dimension uses scale/offset values 
+    inline bool IsFinitePrecision() const { return m_precise; }
+    inline void IsFinitePrecision(bool v) { m_precise = v; }
     
-    bool operator < (Dimension const& dim) const 
+    inline bool operator < (Dimension const& dim) const 
     {
         return m_position < dim.m_position;
     }
-    bool operator > (Dimension const& dim) const 
+    inline bool operator > (Dimension const& dim) const 
     {
         return m_position > dim.m_position;
     }
diff -r 684912262acb -r 1b4e0a36cdd8 include/liblas/laspoint.hpp
--- a/include/liblas/laspoint.hpp	Sat Oct 09 21:36:25 2010 -0500
+++ b/include/liblas/laspoint.hpp	Sat Oct 09 22:36:54 2010 -0500
@@ -196,8 +196,8 @@
     bool IsValid() const;
 
 
-    std::vector<boost::uint8_t> const& GetData() const {return m_format_data; }
-    void SetData(std::vector<boost::uint8_t> const& v) { m_format_data = v;}
+    std::vector<boost::uint8_t> const& GetData() const {return m_data; }
+    void SetData(std::vector<boost::uint8_t> const& v) { m_data = v;}
     
     void SetHeaderPtr(HeaderPtr header);
     HeaderPtr GetHeaderPtr() const;
@@ -208,8 +208,7 @@
 
 private:
 
-    detail::PointRecord m_record;
-    std::vector<boost::uint8_t> m_format_data;
+    std::vector<boost::uint8_t> m_data;
     
     std::vector<boost::uint8_t>::size_type GetDimensionBytePosition(std::size_t dim_pos) const;
     HeaderPtr m_header;
diff -r 684912262acb -r 1b4e0a36cdd8 src/laspoint.cpp
--- a/src/laspoint.cpp	Sat Oct 09 21:36:25 2010 -0500
+++ b/src/laspoint.cpp	Sat Oct 09 22:36:54 2010 -0500
@@ -56,6 +56,7 @@
 #include <vector>
 #include <iosfwd>
 #include <algorithm>
+#include <numeric>
 
 using namespace boost;
 
@@ -65,20 +66,20 @@
     : m_header(HeaderPtr())
     , m_default_header(DefaultHeader::get())
 {
-    m_format_data.resize(ePointSize3);
-    m_format_data.assign(ePointSize3, 0);
+    m_data.resize(ePointSize3);
+    m_data.assign(ePointSize3, 0);
 }
 
 Point::Point(HeaderPtr hdr)
     : m_header(hdr)
     , m_default_header(DefaultHeader::get())
 {
-    m_format_data.resize(ePointSize3);
-    m_format_data.assign(ePointSize3, 0);
+    m_data.resize(ePointSize3);
+    m_data.assign(ePointSize3, 0);
 }
 
 Point::Point(Point const& other)
-    : m_format_data(other.m_format_data)
+    : m_data(other.m_data)
     , m_header(other.m_header)
     , m_default_header(DefaultHeader::get())
 {
@@ -88,7 +89,7 @@
 {
     if (&rhs != this)
     {
-        m_format_data = rhs.m_format_data;
+        m_data = rhs.m_data;
         m_header = rhs.m_header;
     }
     return *this;
@@ -189,6 +190,58 @@
 
 void Point::SetHeaderPtr(HeaderPtr header) 
 {
+    boost::uint16_t length;
+    if (m_header) 
+        length = m_header->GetDataRecordLength();
+    else
+        length = m_default_header.GetDataRecordLength();
+    
+    // This is hopefully faster than copying everything if we don't have 
+    // any data set and nothing to worry about.
+    boost::uint32_t sum = std::accumulate(m_data.begin(), m_data.end(), 0);
+
+    if (length != m_data.size() || sum != 0)
+    {
+        // Manually copy everything but the header ptr
+        // We can't just copy the raw data because its 
+        // layout is likely changing as a result of the 
+        // schema change.
+        Point p(*this);
+    
+        m_data.resize(length);
+        m_data.assign(length, 0);
+    
+        SetX(p.GetX());


More information about the Liblas-commits mailing list