[Liblas-commits] hg: 5 new changesets

liblas-commits at liblas.org liblas-commits at liblas.org
Mon Oct 4 16:04:07 EDT 2010


changeset 37205527799d in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=37205527799d
summary: regularize GetHeaderPtr/SetHeaderPtr -- dummy up a PointFactory

changeset c091fce0c6c0 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=c091fce0c6c0
summary: use SetHeaderPtr instead of SetHeader

changeset 9fc12e4f25ef in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=9fc12e4f25ef
summary: update tests for schema changes and defaulting to pointformat3

changeset 714380d4bfe6 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=714380d4bfe6
summary: schema-enabled read/write for a number of liblas::Point attributes

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

diffstat:

 apps/lasblock.cpp            |   13 +-
 include/liblas/lasheader.hpp |   24 ++
 include/liblas/laspoint.hpp  |  140 ++++++--------
 include/liblas/lasschema.hpp |   45 +++-
 python/tests/Header.txt      |    8 +-
 python/tests/Schema.txt      |    6 +-
 src/detail/reader/point.cpp  |    2 +-
 src/laspoint.cpp             |  413 +++++++++++++++++++++++++++++++++---------
 src/lasschema.cpp            |  137 ++++++++++---
 test/unit/laspoint_test.cpp  |   12 +-
 10 files changed, 563 insertions(+), 237 deletions(-)

diffs (truncated from 1281 to 300 lines):

diff -r af0e4d93cbe5 -r a6e938ee4be8 apps/lasblock.cpp
--- a/apps/lasblock.cpp	Fri Oct 01 14:28:46 2010 -0500
+++ b/apps/lasblock.cpp	Mon Oct 04 15:03:54 2010 -0500
@@ -14,6 +14,15 @@
 // std
 #include <fstream>
 #include <vector>
+// boost
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable : 4512)
+#include <boost/program_options.hpp>
+#pragma warning(pop)
+#endif
+
+namespace po = boost::program_options;
 
 #ifdef _WIN32
 #define compare_no_case(a,b,n)  _strnicmp( (a), (b), (n) )
@@ -21,10 +30,6 @@
 #define compare_no_case(a,b,n)  strncasecmp( (a), (b), (n) )
 #endif
 
-#include <boost/program_options.hpp>
-
-namespace po = boost::program_options;
-
 bool term_progress(std::ostream& os, double complete)
 {
     static int lastTick = -1;
diff -r af0e4d93cbe5 -r a6e938ee4be8 include/liblas/lasheader.hpp
--- a/include/liblas/lasheader.hpp	Fri Oct 01 14:28:46 2010 -0500
+++ b/include/liblas/lasheader.hpp	Mon Oct 04 15:03:54 2010 -0500
@@ -404,6 +404,30 @@
 
 std::ostream& operator<<(std::ostream& os, liblas::Header const&);
 
+/// Singleton used for all empty points upon construction.  If 
+/// 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
+{
+public:
+    virtual ~EmptyHeader() {};
+    
+    static Header const& get() 
+    {
+        static Header object;
+        return object;
+    }
+protected:
+    EmptyHeader();
+    EmptyHeader( EmptyHeader const&);
+    EmptyHeader& operator=( EmptyHeader const&);
+    
+};
+
+
+
+
 } // namespace liblas
 
 #endif // LIBLAS_LASHEADER_HPP_INCLUDED
diff -r af0e4d93cbe5 -r a6e938ee4be8 include/liblas/laspoint.hpp
--- a/include/liblas/laspoint.hpp	Fri Oct 01 14:28:46 2010 -0500
+++ b/include/liblas/laspoint.hpp	Mon Oct 04 15:03:54 2010 -0500
@@ -63,49 +63,22 @@
 
 namespace liblas {
 
-// template <typename T>
-// class Scaled
-// {
-// 
-// public:
-//     Scaled(T value, double* scale, double* offset)
-//         : m_value(value), m_scale(scale), m_offset(offset) {};    
-// 
-//     Scaled(Scaled const& other)
-//         : m_value(other.m_value)
-//         , m_scale(other.m_scale)
-//         , m_offset(other.m_offset)
-//     {
-//     }
-// 
-//     Scaled& operator=(Scaled<T> const& rhs)
-//     {
-//         if (&rhs != this)
-//         {
-//             m_value = rhs.m_value;
-//             m_scale = rhs.m_scale;
-//             m_offset = rhs.m_scale;
-//         }
-//         return *this;
-//     }
-//     
-//     operator double() const 
-//     {
-//         double output = (m_value * *m_scale) + *m_offset;
-//             std::cout << "double(): " << output << " m_value: " << m_value << " m_scale: " << *m_scale << " m_offset: " << *m_offset << std::endl;
-//         return (m_value * *m_scale) + *m_offset;
-//     }
-//     
-//     operator T() const
-//     {
-//         return m_value;
-//     }
-//     
-// private:
-//     T m_value;
-//     double* m_scale;
-//     double* m_offset;
-// };
+class PointFactory
+{
+public:
+    PointFactory();
+    
+    static const PointFactory* getInstance();
+    
+    PointPtr createPoint() const;
+    PointPtr createPoint(HeaderPtr hdr) const;
+    
+    /// Destructor
+    virtual ~PointFactory();
+
+private:
+    HeaderPtr m_header;    
+};
 
 /// Point data record composed with X, Y, Z coordinates and attributes.
 class Point
@@ -244,7 +217,7 @@
     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;}
     
-    void SetHeader(HeaderPtr header);
+    void SetHeaderPtr(HeaderPtr header);
     HeaderPtr GetHeaderPtr() const;
     
     property_tree::ptree GetPTree() const;
@@ -264,6 +237,8 @@
     // must account for this.    
     boost::array<double, 3> m_double_coords_cache;
     
+    std::vector<boost::uint8_t>::size_type GetDimensionPosition(std::string const& name) const;
+    
     Color m_color;
     double m_gps_time;
     boost::uint16_t m_intensity;
@@ -273,6 +248,7 @@
     boost::int8_t m_angle_rank;
     Classification m_class;
     HeaderPtr m_header;
+    Header const& m_default_header;
 
     void throw_out_of_range() const;
 };
@@ -289,49 +265,49 @@
     return (!(lhs == rhs));
 }
 
-inline boost::uint16_t Point::GetIntensity() const
-{
-    return m_intensity;
-}
+// inline boost::uint16_t Point::GetIntensity() const
+// {
+//     return m_intensity;
+// }
+// 
+// inline void Point::SetIntensity(boost::uint16_t const& intensity)
+// {
+//     m_intensity = intensity;
+// }
 
-inline void Point::SetIntensity(boost::uint16_t const& intensity)
-{
-    m_intensity = intensity;
-}
+// inline boost::uint16_t Point::GetReturnNumber() const
+// {
+//     // Read bits 1,2,3 (first 3 bits)
+//     return (m_flags & 0x07);
+// }
 
-inline boost::uint16_t Point::GetReturnNumber() const
-{
-    // Read bits 1,2,3 (first 3 bits)
-    return (m_flags & 0x07);
-}
+// inline boost::uint16_t Point::GetNumberOfReturns() const
+// {
+//     // Read bits 4,5,6
+//     return ((m_flags >> 3) & 0x07);
+// }
 
-inline boost::uint16_t Point::GetNumberOfReturns() const
-{
-    // Read bits 4,5,6
-    return ((m_flags >> 3) & 0x07);
-}
+// inline boost::uint16_t Point::GetScanDirection() const
+// {
+//     // Read 7th bit
+//     return ((m_flags >> 6) & 0x01);
+// }
+// 
+// inline boost::uint16_t Point::GetFlightLineEdge() const
+// {
+//     // Read 8th bit
+//     return ((m_flags >> 7) & 0x01);
+// }
 
-inline boost::uint16_t Point::GetScanDirection() const
-{
-    // Read 7th bit
-    return ((m_flags >> 6) & 0x01);
-}
+// inline boost::uint8_t Point::GetScanFlags() const
+// {
+//     return m_flags;
+// }
 
-inline boost::uint16_t Point::GetFlightLineEdge() const
-{
-    // Read 8th bit
-    return ((m_flags >> 7) & 0x01);
-}
-
-inline boost::uint8_t Point::GetScanFlags() const
-{
-    return m_flags;
-}
-
-inline void Point::SetScanFlags(boost::uint8_t const& flags)
-{
-    m_flags = flags;
-}
+// inline void Point::SetScanFlags(boost::uint8_t const& flags)
+// {
+//     m_flags = flags;
+// }
 
 inline boost::int8_t Point::GetScanAngleRank() const
 {
diff -r af0e4d93cbe5 -r a6e938ee4be8 include/liblas/lasschema.hpp
--- a/include/liblas/lasschema.hpp	Fri Oct 01 14:28:46 2010 -0500
+++ b/include/liblas/lasschema.hpp	Mon Oct 04 15:03:54 2010 -0500
@@ -51,6 +51,7 @@
 #include <boost/any.hpp>
 #include <boost/shared_ptr.hpp>
 #include <boost/foreach.hpp>
+#include <boost/array.hpp>
 
 // std
 #include <iosfwd>
@@ -66,7 +67,10 @@
 typedef boost::shared_ptr<Dimension> DimensionPtr;
 typedef std::map<std::string, DimensionPtr> DimensionMap;
 
+typedef std::vector<DimensionPtr> DimensionArray;
 
+typedef boost::array<std::size_t, 4> SizesArray;
+typedef std::map<std::string, SizesArray > SizesMap;
 
 class Schema
 {
@@ -104,6 +108,7 @@
     std::vector<std::string> GetDimensionNames() const;
     DimensionMap const& GetDimensions() const { return m_dimensions; }
     liblas::property_tree::ptree GetPTree() const;
+    SizesArray GetSizes(std::string const& name) const;
     
     boost::uint16_t GetSchemaVersion() const { return m_schemaversion; }
     void SetSchemaVersion(boost::uint16_t v) { m_schemaversion = v; }
@@ -113,12 +118,12 @@
 
 protected:
     
-    boost::uint16_t m_size;
     PointFormatName m_data_format_id;
     boost::uint32_t m_nextpos;
     std::size_t m_bit_size;
     std::size_t m_base_bit_size;
     boost::uint16_t m_schemaversion;
+    SizesMap m_sizes;
     
 private:
 
@@ -172,15 +177,39 @@
     /// 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";


More information about the Liblas-commits mailing list