[Liblas-commits] hg: 7 new changesets

liblas-commits at liblas.org liblas-commits at liblas.org
Tue Sep 21 14:12:35 EDT 2010


changeset 6889fb72b158 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=6889fb72b158
summary: dimension sorting, GetDimension prototype for a given index

changeset caef6366b93d in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=caef6366b93d
summary: bitsToInt and intToBits templates to handle working with the raw data vector for a point

changeset 05c5eab31942 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=05c5eab31942
summary: remove unused prototype

changeset d3c772ab671d in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=d3c772ab671d
summary: test getting raw data from points

changeset 80c2cf2c865b in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=80c2cf2c865b
summary: Points are now automatically scaled, we can't double-scale them

changeset 9ed8d7387335 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=9ed8d7387335
summary: XYZ data now coming/setting from raw data, not the m_coords array except in the case of a point with no header.  Add Point::GetValue which can take in a Dimension pointer and fetch a boost::any value for it

changeset 83a3b4024767 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=83a3b4024767
summary: merge with FrankW's vertical stuff

diffstat:

 include/liblas/detail/utility.hpp |   32 ++++
 include/liblas/laspoint.hpp       |  126 ++++++++++-------
 include/liblas/lasreader.hpp      |    2 -
 include/liblas/lasschema.hpp      |   18 ++-
 python/liblas/point.py            |   34 ++--
 python/tests/SRS-GDAL.txt         |    5 +-
 src/gt_wkt_srs.cpp                |   41 +++-
 src/laspoint.cpp                  |  275 +++++++++++++++++++++++++++++++++----
 src/lasschema.cpp                 |   22 ++-
 src/lasspatialreference.cpp       |    2 +-
 src/lastransform.cpp              |    4 +-
 test/unit/laspoint_test.cpp       |   56 +++++++-
 12 files changed, 484 insertions(+), 133 deletions(-)

diffs (truncated from 1011 to 300 lines):

diff -r 42ce4fbc4ef7 -r 83a3b4024767 include/liblas/detail/utility.hpp
--- a/include/liblas/detail/utility.hpp	Mon Sep 20 14:51:15 2010 -0500
+++ b/include/liblas/detail/utility.hpp	Tue Sep 21 13:12:19 2010 -0500
@@ -57,6 +57,7 @@
 #include <sstream>
 #include <stdexcept>
 #include <cmath>
+#include <vector>
 
 /// Defines utilities for internal use in libLAS.
 /// The liblas::detail elements do not belong to the public
@@ -368,6 +369,37 @@
     check_stream_state(src);
 }
 
+// adapted from http://www.cplusplus.com/forum/beginner/3076/
+template <typename IntegerType>
+inline IntegerType bitsToInt(   IntegerType& result, 
+                                std::vector<boost::uint8_t> const& data, 
+                                std::size_t index)
+{
+    result = 0;
+
+#if defined(LIBLAS_BIG_ENDIAN)
+        for (boost::uint32_t n = 0; n < sizeof( result ); n++)
+#else
+        for (boost::int32_t n = sizeof( result ); n >= 0; n--)
+#endif    
+            result = (result << 8) +data[ n + index ];
+        return result;
+}
+
+template <typename IntegerType>
+inline void intToBits(   IntegerType value, 
+                         std::vector<boost::uint8_t> & data, 
+                         std::size_t index )
+{
+#if defined(LIBLAS_BIG_ENDIAN)
+        for (boost::int32_t n = sizeof( value ); n >= 0; n--)
+#else
+        for (boost::uint32_t n = 0; n < sizeof( value ); n++)
+#endif   
+            data[index+n] = (boost::uint8_t) ((value >> n*8) & 0xFF);
+}
+
+
 template <typename T>
 inline void write_n(std::ostream& dest, T const& src, std::streamsize const& num)
 {
diff -r 42ce4fbc4ef7 -r 83a3b4024767 include/liblas/laspoint.hpp
--- a/include/liblas/laspoint.hpp	Mon Sep 20 14:51:15 2010 -0500
+++ b/include/liblas/laspoint.hpp	Tue Sep 21 13:12:19 2010 -0500
@@ -46,8 +46,10 @@
 #include <liblas/lascolor.hpp>
 #include <liblas/detail/pointrecord.hpp>
 #include <liblas/detail/fwd.hpp>
+#include <liblas/detail/utility.hpp>
 #include <liblas/external/property_tree/ptree.hpp>
 #include <liblas/lasschema.hpp>
+
 // boost
 #include <boost/array.hpp>
 #include <boost/cstdint.hpp>
@@ -61,6 +63,50 @@
 
 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;
+// };
+
 /// Point data record composed with X, Y, Z coordinates and attributes.
 class Point
 {
@@ -102,19 +148,28 @@
     };
 
     Point();
+    Point(HeaderPtr header);
     Point(Point const& other);
     Point& operator=(Point const& rhs);
 
     double GetX() const;
     double GetY() const;
     double GetZ() const;
+    
+    boost::int32_t GetRawX() const;
+    boost::int32_t GetRawY() const;
+    boost::int32_t GetRawZ() const;
+        
     void SetCoordinates(double const& x, double const& y, double const& z);
-    // void SetCoordinates(Header const& header, double x, double y, double z);
     
     void SetX(double const& value);
     void SetY(double const& value);
     void SetZ(double const& value);
 
+    void SetRawX(boost::int32_t const& value);
+    void SetRawY(boost::int32_t const& value);
+    void SetRawZ(boost::int32_t const& value);
+    
     boost::uint16_t GetIntensity() const;
     void SetIntensity(boost::uint16_t const& intensity);
 
@@ -172,15 +227,10 @@
     double GetTime() const;
     void SetTime(double const& time);
 
-    /// Index operator providing access to XYZ coordinates of point record.
-    /// Valid index values are 0, 1 or 2.
-    /// \exception std::out_of_range if requested index is out of range (> 2).
-    double& operator[](std::size_t const& index);
-
     /// Const version of index operator providing access to XYZ coordinates of point record.
     /// Valid index values are 0, 1 or 2.
     /// \exception std::out_of_range if requested index is out of range (> 2).
-    double const& operator[](std::size_t const& index) const;
+    double operator[](std::size_t const& index) const;
 
     /// \todo TODO: Should we compare other data members, but not only coordinates?
     bool equal(Point const& other) const;
@@ -206,7 +256,14 @@
     detail::PointRecord m_record;
     std::vector<boost::uint8_t> m_extra_data;
     std::vector<boost::uint8_t> m_format_data;
-    boost::array<double, 3> m_coords;
+
+    // If we don't have a header, we have no way to scale the data.
+    // We're going to cache the value until the user sets the header for the point
+    // This means that the raw data is *out of sync* with the real data
+    // until there is a header attached to the point and the writer 
+    // must account for this.    
+    boost::array<double, 3> m_double_coords_cache;
+    
     Color m_color;
     double m_gps_time;
     boost::uint16_t m_intensity;
@@ -232,37 +289,6 @@
     return (!(lhs == rhs));
 }
 
-
-inline double Point::GetX() const
-{
-    return m_coords[0];
-}
-
-inline void Point::SetX( double const& value ) 
-{
-    m_coords[0] = value;
-}
-
-inline double Point::GetY() const
-{
-    return m_coords[1];
-}
-
-inline void Point::SetY( double const& value ) 
-{
-    m_coords[1] = value;
-}
-
-inline double Point::GetZ() const
-{
-    return m_coords[2];
-}
-
-inline void Point::SetZ( double const& value ) 
-{
-    m_coords[2] = value;
-}
-
 inline boost::uint16_t Point::GetIntensity() const
 {
     return m_intensity;
@@ -348,20 +374,18 @@
     m_color = value;
 }
 
-inline double& Point::operator[](std::size_t const& index)
+inline double Point::operator[](std::size_t const& index) const
 {
-    if (index > m_coords.size() - 1)
-        throw_out_of_range();
+    
+    if (index == 0) 
+        return GetX();
+    if (index == 1) 
+        return GetY();
+    if (index == 2)
+        return GetZ();
 
-    return m_coords[index];
-}
-
-inline double const& Point::operator[](std::size_t const& index) const
-{
-    if (index > m_coords.size() - 1)
-        throw_out_of_range();
-
-    return m_coords[index];
+    throw_out_of_range();
+    
 }
 
 
diff -r 42ce4fbc4ef7 -r 83a3b4024767 include/liblas/lasreader.hpp
--- a/include/liblas/lasreader.hpp	Mon Sep 20 14:51:15 2010 -0500
+++ b/include/liblas/lasreader.hpp	Tue Sep 21 13:12:19 2010 -0500
@@ -177,8 +177,6 @@
     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 42ce4fbc4ef7 -r 83a3b4024767 include/liblas/lasschema.hpp
--- a/include/liblas/lasschema.hpp	Mon Sep 20 14:51:15 2010 -0500
+++ b/include/liblas/lasschema.hpp	Tue Sep 21 13:12:19 2010 -0500
@@ -64,6 +64,8 @@
 class Dimension;
 typedef boost::shared_ptr<Dimension> DimensionPtr;
 
+
+
 class Schema
 {
 public:
@@ -93,6 +95,7 @@
     
     void AddDimension(DimensionPtr dim);
     DimensionPtr GetDimension(std::string const& name) const;
+    DimensionPtr GetDimension(std::size_t index) const;
     void RemoveDimension(DimensionPtr dim);
     
     std::vector<std::string> GetDimensionNames() const;
@@ -122,6 +125,7 @@
 };
 
 
+
 class Dimension
 {
 public:
@@ -137,7 +141,13 @@
         m_signed(false),
         m_integer(false),
         m_position(0)
-    {};
+    {
+         if (size_in_bits == 0) {
+            std::ostringstream oss;
+            oss << "The bit size of the dimension is 0, the dimension is invalid.";
+            throw std::runtime_error(oss.str());
+        }
+    };
     
     virtual ~Dimension() {};


More information about the Liblas-commits mailing list