[Liblas-commits] hg: 5 new changesets

liblas-commits at liblas.org liblas-commits at liblas.org
Sat Oct 9 19:17:54 EDT 2010


changeset 555da2e430b5 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=555da2e430b5
summary: rename EmptyHeader to DefaultHeader to more accurately reflect what it is

changeset 7b0859cc333c in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=7b0859cc333c
summary: use a random_access view on the multi_index for fetching byte offset sizes of fixed-position dimensions.  Move sizes stuff onto the dimension

changeset 38ebc1c8e1da in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=38ebc1c8e1da
summary: move byte offset sizes here for now

changeset 2930d5919a46 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=2930d5919a46
summary: remove GetDimensionPosition(name)

changeset 2fe4df7bda66 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=2fe4df7bda66
summary: use fixed (numerical) dimension positions to denote the index position of the PointFormatName-fixed dimensions.  Requires random_access view on the Schema's multi_index to work.  And fast too -- down to ~3 sec on a debug build from the previous ~ 15 sec

diffstat:

 include/liblas/lasdimension.hpp |   10 +
 include/liblas/lasheader.hpp    |   10 +-
 include/liblas/laspoint.hpp     |    3 +-
 include/liblas/lasschema.hpp    |    9 +-
 src/lasdimension.cpp            |    3 +
 src/laspoint.cpp                |  406 ++++++++++++++++++++++++++-------------
 src/lasschema.cpp               |   55 +----
 src/utility.cpp                 |    8 +
 8 files changed, 313 insertions(+), 191 deletions(-)

diffs (truncated from 870 to 300 lines):

diff -r 35180fc82d8b -r 2fe4df7bda66 include/liblas/lasdimension.hpp
--- a/include/liblas/lasdimension.hpp	Fri Oct 08 12:36:47 2010 -0500
+++ b/include/liblas/lasdimension.hpp	Sat Oct 09 18:17:39 2010 -0500
@@ -70,6 +70,7 @@
 
 namespace liblas {  
 
+typedef boost::array<std::size_t, 4> SizesArray;
 
 /// Dimension definition
 class Dimension
@@ -145,6 +146,13 @@
     {
         return m_position < dim.m_position;
     }
+    bool operator > (Dimension const& dim) const 
+    {
+        return m_position > dim.m_position;
+    }
+    
+    SizesArray const& GetSizes() const { return m_sizes; }
+    void SetSizes(SizesArray const& a) { m_sizes = a; }
 private:
         
     std::string m_name;
@@ -161,6 +169,8 @@
     double m_scale;
     bool m_precise;
     double m_offset;
+    SizesArray m_sizes;
+    
   
 };
 
diff -r 35180fc82d8b -r 2fe4df7bda66 include/liblas/lasheader.hpp
--- a/include/liblas/lasheader.hpp	Fri Oct 08 12:36:47 2010 -0500
+++ b/include/liblas/lasheader.hpp	Sat Oct 09 18:17:39 2010 -0500
@@ -408,10 +408,10 @@
 /// a reader creates the point, the HeaderPtr from the file that was 
 /// read will be used, but all stand-alone points will have EmptyHeader 
 /// as their base.
-class EmptyHeader
+class DefaultHeader
 {
 public:
-    virtual ~EmptyHeader() {};
+    virtual ~DefaultHeader() {};
     
     static Header const& get() 
     {
@@ -419,9 +419,9 @@
         return object;
     }
 protected:
-    EmptyHeader();
-    EmptyHeader( EmptyHeader const&);
-    EmptyHeader& operator=( EmptyHeader const&);
+    DefaultHeader();
+    DefaultHeader( DefaultHeader const&);
+    DefaultHeader& operator=( DefaultHeader const&);
     
 };
 
diff -r 35180fc82d8b -r 2fe4df7bda66 include/liblas/laspoint.hpp
--- a/include/liblas/laspoint.hpp	Fri Oct 08 12:36:47 2010 -0500
+++ b/include/liblas/laspoint.hpp	Sat Oct 09 18:17:39 2010 -0500
@@ -211,8 +211,7 @@
     detail::PointRecord m_record;
     std::vector<boost::uint8_t> m_format_data;
     
-    std::vector<boost::uint8_t>::size_type GetDimensionPosition(std::string const& name) const;
-
+    std::vector<boost::uint8_t>::size_type GetDimensionBytePosition(std::size_t dim_pos) const;
     HeaderPtr m_header;
     Header const& m_default_header;
 
diff -r 35180fc82d8b -r 2fe4df7bda66 include/liblas/lasschema.hpp
--- a/include/liblas/lasschema.hpp	Fri Oct 08 12:36:47 2010 -0500
+++ b/include/liblas/lasschema.hpp	Sat Oct 09 18:17:39 2010 -0500
@@ -61,6 +61,7 @@
 #include <boost/multi_index/hashed_index.hpp>
 #include <boost/multi_index/sequenced_index.hpp>
 #include <boost/multi_index/mem_fun.hpp>
+#include <boost/multi_index/random_access_index.hpp>
 
 
 // std
@@ -81,7 +82,7 @@
 
 struct name{};
 struct position{};
-
+struct index{};
 
 
 typedef multi_index_container<
@@ -90,6 +91,8 @@
     // sort by Dimension::operator<
     ordered_unique<tag<position>, identity<Dimension> >,
     
+    // Random access
+    random_access<tag<index> >,
     // sort by less<string> on GetName
     hashed_unique<tag<name>, const_mem_fun<Dimension,std::string const&,&Dimension::GetName> >
     
@@ -99,6 +102,8 @@
 
 typedef IndexMap::index<name>::type index_by_name;
 typedef IndexMap::index<position>::type index_by_position;
+typedef IndexMap::index<index>::type index_by_index;
+
 
 /// Schema definition
 class Schema
@@ -138,6 +143,7 @@
     IndexMap const& GetDimensions() const { return m_index; }
     liblas::property_tree::ptree GetPTree() const;
     SizesArray const& GetSizes(std::string const& n) const;
+    SizesArray const& GetSizes(std::size_t pos) const;
     
     boost::uint16_t GetSchemaVersion() const { return m_schemaversion; }
     void SetSchemaVersion(boost::uint16_t v) { m_schemaversion = v; }
@@ -152,7 +158,6 @@
     std::size_t m_bit_size;
     std::size_t m_base_bit_size;
     boost::uint16_t m_schemaversion;
-    SizesMap m_sizes;
     
 private:
 
diff -r 35180fc82d8b -r 2fe4df7bda66 src/lasdimension.cpp
--- a/src/lasdimension.cpp	Fri Oct 08 12:36:47 2010 -0500
+++ b/src/lasdimension.cpp	Sat Oct 09 18:17:39 2010 -0500
@@ -80,6 +80,7 @@
         oss << "The bit size of the dimension is 0, the dimension is invalid.";
         throw std::runtime_error(oss.str());
     }
+    m_sizes.assign(0);
 };
 
 /// copy constructor
@@ -95,6 +96,7 @@
     , m_signed(other.m_signed)
     , m_integer(other.m_integer)
     , m_position(other.m_position)
+    , m_sizes(other.m_sizes)
 {
 }
 // 
@@ -114,6 +116,7 @@
         m_signed = rhs.m_signed;
         m_integer = rhs.m_integer;
         m_position = rhs.m_position;
+        m_sizes = rhs.m_sizes;
     }
     
     return *this;
diff -r 35180fc82d8b -r 2fe4df7bda66 src/laspoint.cpp
--- a/src/laspoint.cpp	Fri Oct 08 12:36:47 2010 -0500
+++ b/src/laspoint.cpp	Sat Oct 09 18:17:39 2010 -0500
@@ -63,7 +63,7 @@
 
 Point::Point()
     : m_header(HeaderPtr())
-    , m_default_header(EmptyHeader::get())
+    , m_default_header(DefaultHeader::get())
 {
     m_format_data.resize(ePointSize3);
     m_format_data.assign(ePointSize3, 0);
@@ -71,7 +71,7 @@
 
 Point::Point(HeaderPtr hdr)
     : m_header(hdr)
-    , m_default_header(EmptyHeader::get())
+    , m_default_header(DefaultHeader::get())
 {
     m_format_data.resize(ePointSize3);
     m_format_data.assign(ePointSize3, 0);
@@ -80,7 +80,7 @@
 Point::Point(Point const& other)
     : m_format_data(other.m_format_data)
     , m_header(other.m_header)
-    , m_default_header(EmptyHeader::get())
+    , m_default_header(DefaultHeader::get())
 {
 }
 
@@ -388,7 +388,8 @@
 
 boost::int32_t Point::GetRawX() const
 {
-    std::vector<boost::uint8_t>::size_type pos = GetDimensionPosition("X");
+    // std::vector<boost::uint8_t>::size_type pos = GetDimensionPosition("X");
+    std::vector<boost::uint8_t>::size_type pos = GetDimensionBytePosition(0);
     boost::int32_t output = liblas::detail::bitsToInt<boost::int32_t>(output, m_format_data, pos);
 
     return output;
@@ -396,7 +397,8 @@
 
 boost::int32_t Point::GetRawY() const
 {
-    std::vector<boost::uint8_t>::size_type pos = GetDimensionPosition("Y");
+    // std::vector<boost::uint8_t>::size_type pos = GetDimensionPosition("Y");
+    std::vector<boost::uint8_t>::size_type pos = GetDimensionBytePosition(1);    
     boost::int32_t output = liblas::detail::bitsToInt<boost::int32_t>(output, m_format_data, pos);
 
     return output;
@@ -405,7 +407,8 @@
 boost::int32_t Point::GetRawZ() const
 {
     boost::int32_t output;
-    std::vector<boost::uint8_t>::size_type pos = GetDimensionPosition("Z");
+    // std::vector<boost::uint8_t>::size_type pos = GetDimensionPosition("Z");
+    std::vector<boost::uint8_t>::size_type pos = GetDimensionBytePosition(2);
     output = liblas::detail::bitsToInt<boost::int32_t>(output, m_format_data, pos);
 
     return output;
@@ -413,27 +416,32 @@
 
 void Point::SetRawX( boost::int32_t const& value)
 {
-    std::vector<boost::uint8_t>::size_type pos = GetDimensionPosition("X");
+    // std::vector<boost::uint8_t>::size_type pos = GetDimensionPosition("X");
+    std::vector<boost::uint8_t>::size_type pos = GetDimensionBytePosition(0);    
     liblas::detail::intToBits<boost::int32_t>(value, m_format_data, pos);
 }
 
 void Point::SetRawY( boost::int32_t const& value)
 {
-    std::vector<boost::uint8_t>::size_type pos = GetDimensionPosition("Y");
+    // std::vector<boost::uint8_t>::size_type pos = GetDimensionPosition("Y");
+    std::vector<boost::uint8_t>::size_type pos = GetDimensionBytePosition(1);
     liblas::detail::intToBits<boost::int32_t>(value, m_format_data, pos);
 }
 
 void Point::SetRawZ( boost::int32_t const& value)
 {
-    std::vector<boost::uint8_t>::size_type pos = GetDimensionPosition("Z");
+    // std::vector<boost::uint8_t>::size_type pos = GetDimensionPosition("Z");
+    std::vector<boost::uint8_t>::size_type pos = GetDimensionBytePosition(2);    
     liblas::detail::intToBits<boost::int32_t>(value, m_format_data, pos);
 }
 
 boost::uint16_t Point::GetIntensity() const
 {
+    // Intensity's position is always the 4th dimension
+    std::vector<boost::uint8_t>::size_type pos = GetDimensionBytePosition(3);
     boost::uint16_t output = 
         liblas::detail::bitsToInt<boost::uint16_t>(
-            output, m_format_data, GetDimensionPosition("Intensity"));
+            output, m_format_data, pos);
 
     return output;
 }
@@ -441,24 +449,35 @@
 
 void Point::SetIntensity(boost::uint16_t const& intensity)
 {
+    // Intensity's position is always the 4th dimension
+    std::vector<boost::uint8_t>::size_type pos = GetDimensionBytePosition(3);    
     liblas::detail::intToBits<boost::uint16_t>(intensity, 
                                                m_format_data, 
-                                               GetDimensionPosition("Intensity"));
+                                               pos);
 }
 
 boost::uint8_t Point::GetScanFlags() const
 {
-    return m_format_data[GetDimensionPosition("Return Number")];
+    // Scan Flag's position is always the 5th dimension 
+    // (the entire byte composed of "Return Number", "Number of Returns", 
+    // "Scan Direction", and "Flightline Edge")
+    std::vector<boost::uint8_t>::size_type pos = GetDimensionBytePosition(4);    
+    return m_format_data[pos];
 }
 
 void Point::SetScanFlags(boost::uint8_t const& flags)
 {
-    m_format_data[GetDimensionPosition("Return Number")] = flags;
+    // Scan Flag's position is always the 5th dimension 
+    // (the entire byte composed of "Return Number", "Number of Returns", 
+    // "Scan Direction", and "Flightline Edge")
+    std::vector<boost::uint8_t>::size_type pos = GetDimensionBytePosition(4);       
+    m_format_data[pos] = flags;
 }
 
 boost::uint16_t Point::GetReturnNumber() const
 {
-    std::vector<boost::uint8_t>::size_type pos = GetDimensionPosition("Return Number");
+    // "Return Number" is always the 5th dimension
+    std::vector<boost::uint8_t>::size_type pos = GetDimensionBytePosition(4);  
     boost::uint8_t flags = m_format_data[pos];
     
     // Read bits 1,2,3 (first 3 bits)
@@ -467,8 +486,9 @@
 
 void Point::SetReturnNumber(uint16_t const& num)
 {
-    std::vector<boost::uint8_t>::size_type pos = GetDimensionPosition("Return Number");
-    


More information about the Liblas-commits mailing list