[Liblas-commits] hg: commit so Mat can see my latest changes

liblas-commits at liblas.org liblas-commits at liblas.org
Sun Sep 12 12:27:00 EDT 2010


changeset 0b74c96b407b in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=0b74c96b407b
summary: commit so Mat can see my latest changes

diffstat:

 include/liblas/laspoint.hpp  |  10 +++----
 include/liblas/lasreader.hpp |   2 +
 include/liblas/lasschema.hpp |  27 +++++++++++++++++++--
 src/lasheader.cpp            |  16 +++++++++++++
 src/laspoint.cpp             |  54 ++++++++++++++++++++++++++++++++++++++++++++
 src/lasreader.cpp            |  31 ++++++++++++++++++++++++-
 src/lasschema.cpp            |   8 +++++-
 7 files changed, 137 insertions(+), 11 deletions(-)

diffs (truncated from 308 to 300 lines):

diff -r 3426476509e8 -r 0b74c96b407b include/liblas/laspoint.hpp
--- a/include/liblas/laspoint.hpp	Fri Sep 10 09:15:40 2010 -0500
+++ b/include/liblas/laspoint.hpp	Sun Sep 12 11:26:50 2010 -0500
@@ -47,10 +47,12 @@
 #include <liblas/detail/pointrecord.hpp>
 #include <liblas/detail/fwd.hpp>
 #include <liblas/external/property_tree/ptree.hpp>
+#include <liblas/lasschema.hpp>
 // boost
 #include <boost/array.hpp>
 #include <boost/cstdint.hpp>
 #include <boost/shared_ptr.hpp>
+#include <boost/any.hpp>
 // std
 #include <stdexcept> // std::out_of_range
 #include <cstdlib> // std::size_t
@@ -196,6 +198,8 @@
     HeaderPtr GetHeaderPtr() const;
     
     property_tree::ptree GetPTree() const;
+    
+    boost::any GetValue(DimensionPtr d) const;
 
 private:
 
@@ -228,12 +232,6 @@
     return (!(lhs == rhs));
 }
 
-// inline void Point::SetCoordinates(double const& x, double const& y, double const& z)
-// {
-//     m_coords[0] = x;
-//     m_coords[1] = y;
-//     m_coords[2] = z;
-// }
 
 inline double Point::GetX() const
 {
diff -r 3426476509e8 -r 0b74c96b407b include/liblas/lasreader.hpp
--- a/include/liblas/lasreader.hpp	Fri Sep 10 09:15:40 2010 -0500
+++ b/include/liblas/lasreader.hpp	Sun Sep 12 11:26:50 2010 -0500
@@ -177,6 +177,8 @@
     Point* m_point;
     PointPtr m_empty_point;
     
+    void SummarizeSchema(liblas::property_tree::ptree& tree);
+    
     
     // Set if the user provides a header to override the header as 
     // read from the istream
diff -r 3426476509e8 -r 0b74c96b407b include/liblas/lasschema.hpp
--- a/include/liblas/lasschema.hpp	Fri Sep 10 09:15:40 2010 -0500
+++ b/include/liblas/lasschema.hpp	Sun Sep 12 11:26:50 2010 -0500
@@ -57,6 +57,7 @@
 #include <limits>
 #include <string>
 #include <vector>
+#include <algorithm>
 
 namespace liblas {  
 
@@ -90,12 +91,12 @@
     bool HasColor() const;
     bool HasTime() const; 
     
-    void AddDimension(boost::shared_ptr<Dimension> dim);
-    boost::shared_ptr<Dimension> GetDimension(std::string const& name) const;
+    void AddDimension(DimensionPtr dim);
+    DimensionPtr GetDimension(std::string const& name) const;
     void RemoveDimension(DimensionPtr dim);
     
     std::vector<std::string> GetDimensionNames() const;
-  
+    std::vector<DimensionPtr> GetDimensions() const { return m_dimensions; }
     liblas::property_tree::ptree GetPTree() const;
     
     bool IsCustom() const;
@@ -151,6 +152,13 @@
     /// bytes, physical/serialisation size of record
     std::size_t GetByteSize() const 
     {
+        if (m_bitsize % 8 != 0) {
+            std::ostringstream oss;
+            oss << m_name << "'s bit size, " << m_bitsize 
+                << ", is not a multiple of 8 and " 
+                << "cannot be expressed as a single byte value";
+            throw std::range_error(oss.str());
+        }
         return m_bitsize / 8;
     }    
     
@@ -194,6 +202,15 @@
     boost::uint32_t GetPosition() const { return m_position; }
     void SetPosition(boost::uint32_t v) { m_position = v; }
     
+    double GetScale() const { return m_scale; }
+    void SetScale(double v) { m_scale = v; }
+    
+    double GetOffset() const { return m_offset; }
+    void SetOffset(double v) { m_offset = v; }
+    
+    bool IsFinitePrecision() const { return m_precise; }
+    void IsFinitePrecision(bool v) { m_precise = v; }
+    
     bool operator < (Dimension const& dim) const 
     {
         return m_position < dim.m_position;
@@ -211,6 +228,10 @@
     bool m_signed;
     bool m_integer;
     boost::uint32_t m_position;
+    double m_scale;
+    bool m_precise;
+    double m_offset;
+    
 };
 
 std::ostream& operator<<(std::ostream& os, liblas::Schema const&);
diff -r 3426476509e8 -r 0b74c96b407b src/lasheader.cpp
--- a/src/lasheader.cpp	Fri Sep 10 09:15:40 2010 -0500
+++ b/src/lasheader.cpp	Sun Sep 12 11:26:50 2010 -0500
@@ -708,7 +708,23 @@
     // }
     
     m_schema = format;
+    
+    DimensionPtr x = m_schema.GetDimension("X");
+    x->SetScale(m_scales.x);
+    x->IsFinitePrecision(true);
+    x->SetOffset(m_offsets.x);
+    
+    DimensionPtr y = m_schema.GetDimension("Y");
+    y->SetScale(m_scales.y);
+    y->IsFinitePrecision(true);
+    y->SetOffset(m_offsets.y);
 
+    DimensionPtr z = m_schema.GetDimension("Z");
+    z->SetScale(m_scales.z);
+    z->IsFinitePrecision(true);
+    z->SetOffset(m_offsets.z);
+    
+    
 } 
 
 liblas::property_tree::ptree Header::GetPTree( ) const
diff -r 3426476509e8 -r 0b74c96b407b src/laspoint.cpp
--- a/src/laspoint.cpp	Fri Sep 10 09:15:40 2010 -0500
+++ b/src/laspoint.cpp	Sun Sep 12 11:26:50 2010 -0500
@@ -41,6 +41,7 @@
 
 #include <liblas/laspoint.hpp>
 #include <liblas/lasheader.hpp>
+#include <liblas/lasschema.hpp>
 #include <liblas/exception.hpp>
 #include <liblas/detail/pointrecord.hpp>
 // boost
@@ -54,6 +55,7 @@
 #include <string>
 #include <vector>
 #include <iosfwd>
+#include <algorithm>
 
 using namespace boost;
 
@@ -371,5 +373,57 @@
     throw std::out_of_range("coordinate subscript out of range");
 }
 
+boost::any Point::GetValue(DimensionPtr d) const
+{
+    typedef std::vector<DimensionPtr> Dimensions;
+    boost::any output;
+    
+    // If we don't have a header for the point, we can't return 
+    // anything because we don't have a schema to go along with it.
+    // Use the other method Point::GetValue(DimensionPtr d, liblas::Schema const& schema).
+    if (m_header.get() == 0) {
+        return output;
+    }
+    
+    liblas::Schema const& schema = m_header->GetSchema();
+
+    
+    if (m_format_data.size() + m_extra_data.size() != d->GetByteSize()) {
+        std::ostringstream oss;
+        oss << "The size of the required_data," << m_format_data.size()
+            << ", plus the size of the extra_data," << m_extra_data.size()
+            << ", does not equal the schema's byte size, " << d->GetByteSize();
+        throw std::runtime_error(oss.str());
+    }
+    
+    Dimensions dimensions = schema.GetDimensions();
+    
+    
+    std::vector<boost::uint32_t>::size_type i;
+    boost::uint32_t dim_pos = d->GetPosition();
+    boost::uint32_t byte_pos = 0;
+    
+    for (Dimensions::const_iterator i = dimensions.begin(); i != dimensions.end(); ++i)
+    {
+        DimensionPtr t = *i;
+        if (t->GetBitSize() == 0) {
+            std::ostringstream oss;
+            oss << "The bit size of the dimension is 0, the schema is invalid.";
+            throw std::runtime_error(oss.str());
+        }
+
+        // If it is already-byte aligned, we'll count that directly.  If it 
+        // is not, we will cumulate until we are byte aligned.  If we never 
+        // be come byte aligned, we're going to throw an error.
+        if (t->GetBitSize() % 8 == 0) 
+        {
+            
+        } else 
+        {
+            
+        }
+    }
+    return output;
+}
 
 } // namespace liblas
diff -r 3426476509e8 -r 0b74c96b407b src/lasreader.cpp
--- a/src/lasreader.cpp	Fri Sep 10 09:15:40 2010 -0500
+++ b/src/lasreader.cpp	Sun Sep 12 11:26:50 2010 -0500
@@ -476,7 +476,6 @@
     ptree pmin = min.GetPTree();
     ptree pmax = max.GetPTree();
     
-
      
     pt.add_child("minimum", pmin);
     pt.add_child("maximum", pmax);
@@ -524,6 +523,36 @@
     
     pt.put("count", count);
     
+    // Summarize the schema
+    liblas::Schema schema = m_header->GetSchema();
+    
+    // // if both min == max *and* min is 0, we're declaring this 
+    // // dimension inactive.
+    // if (detail::compare_distance(max.GetX(), min.GetX() ) && detail::compare_distance(0, min.GetX()))
+    // {
+    //     DimensionPtr d = schema.GetDimension("X");
+    //     d->IsActive(false);
+    // }
+    // 
+    // // if both min == max *and* min is 0, we're declaring this 
+    // // dimension inactive.
+    // if (detail::compare_distance(max.GetY(), min.GetY() ) && detail::compare_distance(0, min.GetY()))
+    // {
+    //     DimensionPtr d = schema.GetDimension("Y");
+    //     d->IsActive(false);
+    // }
+    // 
+    // // if both min == max *and* min is 0, we're declaring this 
+    // // dimension inactive.
+    // if (detail::compare_distance(max.GetZ(), min.GetZ() ) && detail::compare_distance(0, min.GetZ()))
+    // {
+    //     DimensionPtr d = schema.GetDimension("Z");
+    //     d->IsActive(false);
+    // }
+
+
+
+    
     return pt;
 }
 } // namespace liblas
diff -r 3426476509e8 -r 0b74c96b407b src/lasschema.cpp
--- a/src/lasschema.cpp	Fri Sep 10 09:15:40 2010 -0500
+++ b/src/lasschema.cpp	Sun Sep 12 11:26:50 2010 -0500
@@ -346,7 +346,7 @@
     m_nextpos(other.m_nextpos),
     m_dimensions(other.m_dimensions)
 {
-
+    std::sort(m_dimensions.begin(), m_dimensions.end());
 }
 // 
 // // assignment constructor
@@ -360,6 +360,7 @@
         m_dimensions = rhs.m_dimensions;
     }
     
+    std::sort(m_dimensions.begin(), m_dimensions.end());
     return *this;
 }
 
@@ -513,12 +514,17 @@
         os << "  Bit size is unaligned to byte boundaries" << std::endl;
     }
     
+    os << "  ";
     for (i = dims.begin(); i != dims.end(); ++i)
     {
+        std::string name = (*i).second.get<std::string>("name");
+        os << name << " ";
     }


More information about the Liblas-commits mailing list