[Liblas-commits] hg: remove DimensionPtr, update to use copyable liblas::Dimensio...

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Oct 7 14:55:55 EDT 2010


changeset ee84a773841d in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=ee84a773841d
summary: remove DimensionPtr, update to use copyable liblas::Dimension class

diffstat:

 include/liblas/lasdimension.hpp |    6 +-
 include/liblas/laspoint.hpp     |    2 +-
 include/liblas/lasschema.hpp    |   17 +-
 src/lasheader.cpp               |   24 +-
 src/laspoint.cpp                |    4 +-
 src/lasschema.cpp               |  252 +++++++++++++++++++++------------------
 test/unit/laspoint_test.cpp     |    7 +-
 7 files changed, 163 insertions(+), 149 deletions(-)

diffs (truncated from 637 to 300 lines):

diff -r 81c45bb49008 -r ee84a773841d include/liblas/lasdimension.hpp
--- a/include/liblas/lasdimension.hpp	Thu Oct 07 12:26:03 2010 -0500
+++ b/include/liblas/lasdimension.hpp	Thu Oct 07 13:55:46 2010 -0500
@@ -81,7 +81,7 @@
         
     virtual ~Dimension() {};
         
-    std::string const& GetName() { return m_name; }
+    std::string const& GetName() const { return m_name; }
     
     /// bits, logical size of point record
     std::size_t GetBitSize() const 
@@ -122,11 +122,11 @@
     void IsInteger(bool v) { m_integer = v; }
 
     /// The minimum value of this dimension as a double
-    double GetMinimum() { return m_min; }
+    double GetMinimum() const { return m_min; }
     void SetMinimum(double min) { m_min = min; }
     
     /// The maximum value of this dimension as a double
-    double GetMaximum() { return m_max; }
+    double GetMaximum() const { return m_max; }
     void SetMaximum(double max) { m_max = max; }
     
     boost::uint32_t GetPosition() const { return m_position; }
diff -r 81c45bb49008 -r ee84a773841d include/liblas/laspoint.hpp
--- a/include/liblas/laspoint.hpp	Thu Oct 07 12:26:03 2010 -0500
+++ b/include/liblas/laspoint.hpp	Thu Oct 07 13:55:46 2010 -0500
@@ -204,7 +204,7 @@
     
     property_tree::ptree GetPTree() const;
     
-    boost::any GetValue(DimensionPtr d) const;
+    boost::any GetValue(Dimension const& d) const;
 
 private:
 
diff -r 81c45bb49008 -r ee84a773841d include/liblas/lasschema.hpp
--- a/include/liblas/lasschema.hpp	Thu Oct 07 12:26:03 2010 -0500
+++ b/include/liblas/lasschema.hpp	Thu Oct 07 13:55:46 2010 -0500
@@ -72,9 +72,8 @@
 
 namespace liblas {  
 
-typedef boost::shared_ptr<Dimension> DimensionPtr;
-typedef boost::unordered_map<std::string, DimensionPtr> DimensionMap;
-typedef std::vector<DimensionPtr> DimensionArray;
+typedef boost::unordered_map<std::string, Dimension> DimensionMap;
+typedef std::vector<Dimension> DimensionArray;
 typedef boost::array<std::size_t, 4> SizesArray;
 typedef boost::unordered_map<std::string, SizesArray> SizesMap;
 
@@ -114,10 +113,12 @@
     PointFormatName GetDataFormatId() const { return m_data_format_id; }
     void SetDataFormatId(PointFormatName const& value);
     
-    void AddDimension(DimensionPtr dim);
-    DimensionPtr GetDimension(std::string const& name) const;
+    void AddDimension(Dimension const& dim);
+    Dimension const& GetDimension(std::string const& name) const;
+    Dimension& GetDimension(std::string const& name);
+    
     // DimensionPtr GetDimension(std::size_t index) const;
-    void RemoveDimension(DimensionPtr dim);
+    void RemoveDimension(Dimension const& dim);
     
     std::vector<std::string> GetDimensionNames() const;
     DimensionMap const& GetDimensions() const { return m_dimensions; }
@@ -153,9 +154,9 @@
 
 };
 
-bool inline sort_dimensions(DimensionPtr i, DimensionPtr j) 
+bool inline sort_dimensions(Dimension i, Dimension j) 
 { 
-    return (*i) < (*j); 
+    return i < j; 
 }
 
 std::ostream& operator<<(std::ostream& os, liblas::Schema const&);
diff -r 81c45bb49008 -r ee84a773841d src/lasheader.cpp
--- a/src/lasheader.cpp	Thu Oct 07 12:26:03 2010 -0500
+++ b/src/lasheader.cpp	Thu Oct 07 13:55:46 2010 -0500
@@ -685,20 +685,20 @@
     
     m_schema = format;
     
-    DimensionPtr x = m_schema.GetDimension("X");
-    x->SetScale(m_scales.x);
-    x->IsFinitePrecision(true);
-    x->SetOffset(m_offsets.x);
+    Dimension& 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);
+    Dimension& 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);
+    Dimension& z = m_schema.GetDimension("Z");
+    z.SetScale(m_scales.z);
+    z.IsFinitePrecision(true);
+    z.SetOffset(m_offsets.z);
     
     
 } 
diff -r 81c45bb49008 -r ee84a773841d src/laspoint.cpp
--- a/src/laspoint.cpp	Thu Oct 07 12:26:03 2010 -0500
+++ b/src/laspoint.cpp	Thu Oct 07 13:55:46 2010 -0500
@@ -704,12 +704,12 @@
 }
 
 
-boost::any Point::GetValue(DimensionPtr d) const
+boost::any Point::GetValue(Dimension const& d) const
 {
 
     boost::any output;
 
-    GetDimensionPosition(d->GetName());
+    GetDimensionPosition(d.GetName());
  
     
     return output;
diff -r 81c45bb49008 -r ee84a773841d src/lasschema.cpp
--- a/src/lasschema.cpp	Thu Oct 07 12:26:03 2010 -0500
+++ b/src/lasschema.cpp	Thu Oct 07 13:55:46 2010 -0500
@@ -77,99 +77,99 @@
 {
     std::ostringstream text;
     
-    DimensionPtr x(new Dimension("X", 32));
+    Dimension x("X", 32);
     text << "x coordinate as a long integer.  You must use the scale and "
          << "offset information of the header to determine the double value.";
-    x->SetDescription(text.str()); 
-    x->IsInteger(true);
-    x->IsNumeric(true);
-    x->IsSigned(true);
+    x.SetDescription(text.str()); 
+    x.IsInteger(true);
+    x.IsNumeric(true);
+    x.IsSigned(true);
 
     AddDimension(x);
     text.str("");
 
-    DimensionPtr y(new Dimension("Y", 32));
+    Dimension y("Y", 32);
     text << "y coordinate as a long integer.  You must use the scale and "
          << "offset information of the header to determine the double value.";
-    y->SetDescription(text.str()); 
-    y->IsInteger(true);
-    y->IsNumeric(true);
-    y->IsSigned(true);
+    y.SetDescription(text.str()); 
+    y.IsInteger(true);
+    y.IsNumeric(true);
+    y.IsSigned(true);
 
     AddDimension(y);
     text.str("");
     
-    DimensionPtr z(new Dimension("Z", 32));
+    Dimension z("Z", 32);
     text << "z coordinate as a long integer.  You must use the scale and "
          << "offset information of the header to determine the double value.";
-    z->SetDescription(text.str()); 
-    z->IsInteger(true);
-    z->IsNumeric(true);
-    z->IsSigned(true);
+    z.SetDescription(text.str()); 
+    z.IsInteger(true);
+    z.IsNumeric(true);
+    z.IsSigned(true);
     AddDimension(z);
     text.str("");
 
-    DimensionPtr intensity(new Dimension("Intensity", 16));
+    Dimension intensity("Intensity", 16);
     text << "The intensity value is the integer representation of the pulse " 
             "return magnitude. This value is optional and system specific. "
             "However, it should always be included if available.";
-    intensity->SetDescription(text.str());
-    intensity->IsInteger(true);
-    intensity->IsNumeric(true);
+    intensity.SetDescription(text.str());
+    intensity.IsInteger(true);
+    intensity.IsNumeric(true);
 
     AddDimension(intensity);
     text.str("");
 
-    DimensionPtr return_no(new Dimension("Return Number", 3));
+    Dimension return_no("Return Number", 3);
     text << "Return Number: The Return Number is the pulse return number for "
             "a given output pulse. A given output laser pulse can have many "
             "returns, and they must be marked in sequence of return. The first "
             "return will have a Return Number of one, the second a Return "
             "Number of two, and so on up to five returns.";
-    return_no->SetDescription(text.str());
-    return_no->IsNumeric(true);
-    return_no->IsInteger(true);
+    return_no.SetDescription(text.str());
+    return_no.IsNumeric(true);
+    return_no.IsInteger(true);
 
     AddDimension(return_no);
     text.str("");
     
-    DimensionPtr no_returns(new Dimension("Number of Returns", 3));
+    Dimension no_returns("Number of Returns", 3);
     text << "Number of Returns (for this emitted pulse): The Number of Returns "
             "is the total number of returns for a given pulse. For example, "
             "a laser data point may be return two (Return Number) within a "
             "total number of five returns.";
-    no_returns->SetDescription(text.str());
-    no_returns->IsNumeric(true);
-    no_returns->IsInteger(true);
+    no_returns.SetDescription(text.str());
+    no_returns.IsNumeric(true);
+    no_returns.IsInteger(true);
     AddDimension(no_returns);
     text.str("");
     
-    DimensionPtr scan_dir(new Dimension("Scan Direction", 1));
+    Dimension scan_dir("Scan Direction", 1);
     text << "The Scan Direction Flag denotes the direction at which the "
             "scanner mirror was traveling at the time of the output pulse. "
             "A bit value of 1 is a positive scan direction, and a bit value "
             "of 0 is a negative scan direction (where positive scan direction "
             "is a scan moving from the left side of the in-track direction to "
             "the right side and negative the opposite). ";
-    scan_dir->SetDescription(text.str());
-    scan_dir->IsNumeric(true);
-    scan_dir->IsInteger(true);
+    scan_dir.SetDescription(text.str());
+    scan_dir.IsNumeric(true);
+    scan_dir.IsInteger(true);
 
     AddDimension(scan_dir);
     text.str("");
     
-    DimensionPtr edge(new Dimension("Flightline Edge", 1));
+    Dimension edge("Flightline Edge", 1);
     text << "The Edge of Flight Line data bit has a value of 1 only when "
             "the point is at the end of a scan. It is the last point on "
             "a given scan line before it changes direction.";
-    edge->SetDescription(text.str());
-    edge->IsNumeric(true);
-    edge->IsInteger(true);
+    edge.SetDescription(text.str());
+    edge.IsNumeric(true);
+    edge.IsInteger(true);
 
     AddDimension(edge);
     text.str("");
 
-    DimensionPtr classification(new Dimension("Classification", 8));
+    Dimension classification("Classification", 8);
     text << "Classification in LAS 1.0 was essentially user defined and optional. "
             "LAS 1.1 defines a standard set of ASPRS classifications. In addition, "
             "the field is now mandatory. If a point has never been classified, this "
@@ -178,12 +178,12 @@
             "user defined operations. Note that the format for classification is a "
             "bit encoded field with the lower five bits used for class and the "
             "three high bits used for flags.";
-    classification->SetDescription(text.str());
+    classification.SetDescription(text.str());
 
     AddDimension(classification);
     text.str("");
     
-    DimensionPtr scan_angle(new Dimension("Scan Angle Rank", 8));
+    Dimension scan_angle("Scan Angle Rank", 8);
     text << "The Scan Angle Rank is a signed one-byte number with a "
             "valid range from -90 to +90. The Scan Angle Rank is the "
             "angle (rounded to the nearest integer in the absolute "
@@ -193,22 +193,22 @@
             "The scan angle is an angle based on 0 degrees being nadir, "
             "and –90 degrees to the left side of the aircraft in the "
             "direction of flight.";
-    scan_angle->SetDescription(text.str());
-    scan_angle->IsSigned(true);
-    scan_angle->IsInteger(true);
-    scan_angle->IsNumeric(true);
+    scan_angle.SetDescription(text.str());
+    scan_angle.IsSigned(true);
+    scan_angle.IsInteger(true);


More information about the Liblas-commits mailing list