[Liblas-commits] hg: 10 new changesets

liblas-commits at liblas.org liblas-commits at liblas.org
Wed Dec 1 13:05:28 EST 2010


changeset 611a00ee45ec in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=611a00ee45ec
summary: remove bogus method

changeset 7c95c0caf31e in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=7c95c0caf31e
summary: remove liblas::Reader::Summarize, which doesn't really belong

changeset 9224cafdf164 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=9224cafdf164
summary: Cache a reference to the ostream so we aren't going through function calls for each fetch of it

changeset 24a2aa4eb165 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=24a2aa4eb165
summary: remove commented cruft

changeset ad9d6c1cb963 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=ad9d6c1cb963
summary: remove stream fetching altogether and use protected data member of parent to find it

changeset a029d9316277 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=a029d9316277
summary: remove stream fetching altogether and use protected data member of parent to find it

changeset 2e69d3811b87 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=2e69d3811b87
summary: remove GetPointCount public method -- use protected data member

changeset 3cb664ce759d in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=3cb664ce759d
summary: Make liblas::Reader and liblas::Writer return pointers instead of references for GetStream()

changeset 0459a7c9645f in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=0459a7c9645f
summary: remove bogus, unused IsEOF method

changeset db809fe8d680 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=db809fe8d680
summary: thin down liblas::Reader and liblas::Writer by removing SRS-related stuff.  Use a TransformationI

diffstat:

 apps/las2las.cpp                      |    3 +-
 apps/laskernel.cpp                    |   22 ++++++
 apps/laskernel.hpp                    |    1 +
 include/liblas/detail/writer/base.hpp |   10 +-
 include/liblas/lasreader.hpp          |   29 +--------
 include/liblas/laswriter.hpp          |   14 +---
 src/detail/writer/base.cpp            |    4 +-
 src/detail/writer/header.cpp          |  113 ++++++++++++++++-----------------
 src/detail/writer/point.cpp           |   22 +------
 src/las_c_api.cpp                     |   16 ++--
 src/lasreader.cpp                     |  113 +---------------------------------
 src/laswriter.cpp                     |   69 +-------------------
 test/unit/lasreader_test.cpp          |    4 +-
 test/unit/laswriter_test.cpp          |    4 +-
 14 files changed, 110 insertions(+), 314 deletions(-)

diffs (truncated from 837 to 300 lines):

diff -r 4886121d806e -r db809fe8d680 apps/las2las.cpp
--- a/apps/las2las.cpp	Mon Nov 29 11:02:49 2010 -0600
+++ b/apps/las2las.cpp	Wed Dec 01 12:05:05 2010 -0600
@@ -68,7 +68,8 @@
     
     if (min_offset) 
     {
-        liblas::property_tree::ptree tree = reader.Summarize();
+        liblas::property_tree::ptree tree = SummarizeReader(reader);
+
         try
         {
             header.SetOffset(tree.get<double>("summary.points.minimum.x"),
diff -r 4886121d806e -r db809fe8d680 apps/laskernel.cpp
--- a/apps/laskernel.cpp	Mon Nov 29 11:02:49 2010 -0600
+++ b/apps/laskernel.cpp	Wed Dec 01 12:05:05 2010 -0600
@@ -1336,4 +1336,26 @@
     return transforms;
 }
 
+liblas::property_tree::ptree SummarizeReader(liblas::Reader& reader) 
+{
+    liblas::Summary s;
 
+    reader.Reset();
+    bool read = reader.ReadNextPoint();
+    if (!read)
+    {
+        throw std::runtime_error("Unable to read any points from file.");
+    }
+        
+    while (read) 
+    {
+        liblas::Point const& p = reader.GetPoint();
+        s.AddPoint(p);
+        read = reader.ReadNextPoint();
+    }
+
+    return s.GetPTree();
+
+
+}
+
diff -r 4886121d806e -r db809fe8d680 apps/laskernel.hpp
--- a/apps/laskernel.hpp	Mon Nov 29 11:02:49 2010 -0600
+++ b/apps/laskernel.hpp	Wed Dec 01 12:05:05 2010 -0600
@@ -102,5 +102,6 @@
 LAS_DLL liblas::Header FetchHeader(std::string const& filename);
 LAS_DLL void RewriteHeader(liblas::Header const& header, std::string const& filename);
 LAS_DLL void RepairHeader(liblas::Summary const& summary, liblas::Header& header);
+LAS_DLL liblas::property_tree::ptree SummarizeReader(liblas::Reader& reader) ;
 
 #endif // LIBLAS_ITERATOR_HPP_INCLUDED
diff -r 4886121d806e -r db809fe8d680 include/liblas/detail/writer/base.hpp
--- a/include/liblas/detail/writer/base.hpp	Mon Nov 29 11:02:49 2010 -0600
+++ b/include/liblas/detail/writer/base.hpp	Wed Dec 01 12:05:05 2010 -0600
@@ -58,10 +58,10 @@
 
     WriterBase(std::ostream& ofs, boost::uint32_t& count);
     ~WriterBase();
-    
-    std::ostream& GetStream() const { return m_ofs; }
-    boost::uint32_t& GetPointCount() const { return m_pointCount; }
-    void SetPointCount(boost::uint32_t& count) { m_pointCount = count; }
+
+protected:
+    std::ostream& m_ofs;
+    boost::uint32_t& m_pointCount;
     
 private:
 
@@ -69,8 +69,6 @@
     WriterBase(WriterBase const& other);
     WriterBase& operator=(WriterBase const& rhs);
 
-    boost::uint32_t& m_pointCount;
-    std::ostream& m_ofs;
 };
 
 }} // namespace liblas::detail
diff -r 4886121d806e -r db809fe8d680 include/liblas/lasreader.hpp
--- a/include/liblas/lasreader.hpp	Mon Nov 29 11:02:49 2010 -0600
+++ b/include/liblas/lasreader.hpp	Wed Dec 01 12:05:05 2010 -0600
@@ -49,7 +49,6 @@
 #include <liblas/lasspatialreference.hpp>
 #include <liblas/lastransform.hpp>
 #include <liblas/lasfilter.hpp>
-#include <liblas/external/property_tree/ptree.hpp>
 #include <liblas/export.hpp>
 // boost
 #include <boost/cstdint.hpp>
@@ -100,10 +99,7 @@
 
     /// Allow fetching of the stream attached to the reader.
     /// @exception nothrow
-    std::istream& GetStream() const;
-
-    /// Checks if end-of-file has been reached.
-    bool IsEOF() const;
+    std::istream* GetStream() const;
 
     /// Fetches next point record in file.
     /// @exception may throw std::exception
@@ -121,21 +117,6 @@
     /// ReadNextPoint operations
     /// @exception may throw std::exception
     bool seek(std::size_t n);
-    
-    /// Reproject data as they are written if the Reader's reference is
-    /// different than the Header's.
-    /// @exception may throw std::exception
-    bool SetSRS(const SpatialReference& ref);
-    
-    /// Override the spatial reference of the Reader's Header for 
-    /// writing purposes.
-    /// @exception may throw std::exception
-    bool SetInputSRS(const SpatialReference& ref);
-
-    /// Override the spatial reference of the Reader's Header for 
-    /// writing purposes.
-    /// @exception may throw std::exception
-    bool SetOutputSRS(const SpatialReference& ref);
 
     /// Provides index-based access to point records.
     /// The operator is implemented in terms of ReadPointAt method
@@ -160,9 +141,7 @@
     /// the internal transform creation
     void SetTransforms(std::vector<liblas::TransformPtr> const& transforms) {m_transforms = transforms;}
 
-    /// Summarize the file represented by the reader in the form of a 
-    /// property_tree.  
-    liblas::property_tree::ptree Summarize();
+
 private:
 
     // Blocked copying operations, declared but not defined.
@@ -186,10 +165,6 @@
     std::vector<liblas::FilterPtr> m_filters;
     std::vector<liblas::TransformPtr> m_transforms;
 
-    TransformPtr m_reprojection_transform;
-
-    SpatialReference m_out_srs;
-    SpatialReference m_in_srs;  
 };
 
 } // namespace liblas
diff -r 4886121d806e -r db809fe8d680 include/liblas/laswriter.hpp
--- a/include/liblas/laswriter.hpp	Mon Nov 29 11:02:49 2010 -0600
+++ b/include/liblas/laswriter.hpp	Wed Dec 01 12:05:05 2010 -0600
@@ -83,17 +83,11 @@
     bool WritePoint(Point const& point);
 
     /// Allow fetching of the stream
-    std::ostream& GetStream() const;
+    std::ostream* GetStream() const;
     
     /// Allow in-place writing of header
     void WriteHeader(Header& header);
 
-    /// Reproject data as they are written if the Writer's reference is
-    /// different than the Header's
-    bool SetSRS(const SpatialReference& ref);
-    bool SetInputSRS(const SpatialReference& ref);
-    bool SetOutputSRS(const SpatialReference& ref);
-
     /// Sets filters that are used to determine wither or not to 
     /// keep a point that before we write it
     /// Filters are applied *before* transforms.
@@ -122,11 +116,7 @@
 
     std::vector<liblas::FilterI*>* m_filters;
     std::vector<liblas::TransformI*>* m_transforms;
-    
-    TransformPtr m_reprojection_transform;
-    
-    SpatialReference m_out_srs;
-    SpatialReference m_in_srs;
+
     
 };
 
diff -r 4886121d806e -r db809fe8d680 src/detail/writer/base.cpp
--- a/src/detail/writer/base.cpp	Mon Nov 29 11:02:49 2010 -0600
+++ b/src/detail/writer/base.cpp	Wed Dec 01 12:05:05 2010 -0600
@@ -48,8 +48,8 @@
 namespace liblas { namespace detail {
 
 WriterBase::WriterBase(std::ostream& ofs, boost::uint32_t& count)
-    : m_pointCount(count)
-    , m_ofs(ofs)
+    : m_ofs(ofs)
+    , m_pointCount(count)
 {
 }
 
diff -r 4886121d806e -r db809fe8d680 src/detail/writer/header.cpp
--- a/src/detail/writer/header.cpp	Mon Nov 29 11:02:49 2010 -0600
+++ b/src/detail/writer/header.cpp	Wed Dec 01 12:05:05 2010 -0600
@@ -75,8 +75,7 @@
     uint8_t n1 = 0;
     uint16_t n2 = 0;
     uint32_t n4 = 0;
-
-
+    
     // Figure out how many points we already have.  
     // Figure out if we're in append mode.  If we are, we can't rewrite 
     // any of the VLRs including the Schema and SpatialReference ones.
@@ -86,12 +85,12 @@
     // std::ios::in *and* std::ios::out
 
     // Seek to the beginning
-    GetStream().seekp(0, ios::beg);
-    ios::pos_type begin = GetStream().tellp();
+    m_ofs.seekp(0, ios::beg);
+    ios::pos_type begin = m_ofs.tellp();
 
     // Seek to the end
-    GetStream().seekp(0, ios::end);
-    ios::pos_type end = GetStream().tellp();
+    m_ofs.seekp(0, ios::end);
+    ios::pos_type end = m_ofs.tellp();
     if ((begin != end) && (end != static_cast<ios::pos_type>(0))) {
         bAppendMode = true;
     }
@@ -113,12 +112,10 @@
             throw std::runtime_error(oss.str());
         }
 
-        uint32_t& cnt =  GetPointCount();
-        cnt = static_cast<uint32_t>(count);
-        SetPointCount(cnt);
+        m_pointCount = static_cast<uint32_t>(count);
 
         // Position to the beginning of the file to start writing the header
-        GetStream().seekp(0, ios::beg);
+        m_ofs.seekp(0, ios::beg);
 
     } 
     else 
@@ -157,18 +154,18 @@
     // 1. File Signature
     std::string const filesig(m_header.GetFileSignature());
     assert(filesig.size() == 4);
-    detail::write_n(GetStream(), filesig, 4);
+    detail::write_n(m_ofs, filesig, 4);
     
     
     // 2. File SourceId / Reserved
     if (m_header.GetVersionMinor()  ==  0) {
         n4 = m_header.GetReserved();
-        detail::write_n(GetStream(), n4, sizeof(n4));         
+        detail::write_n(m_ofs, n4, sizeof(n4));         
     } else if (m_header.GetVersionMinor()  >  0) {
         n2 = m_header.GetFileSourceId();
-        detail::write_n(GetStream(), n2, sizeof(n2));                
+        detail::write_n(m_ofs, n2, sizeof(n2));                
         n2 = m_header.GetReserved();
-        detail::write_n(GetStream(), n2, sizeof(n2));        
+        detail::write_n(m_ofs, n2, sizeof(n2));        
     } 
 
     // 3-6. GUID data
@@ -178,63 +175,63 @@
     uint8_t d4[8] = { 0 };
     liblas::guid g = m_header.GetProjectId();
     g.output_data(d1, d2, d3, d4);
-    detail::write_n(GetStream(), d1, sizeof(d1));
-    detail::write_n(GetStream(), d2, sizeof(d2));
-    detail::write_n(GetStream(), d3, sizeof(d3));
-    detail::write_n(GetStream(), d4, sizeof(d4));
+    detail::write_n(m_ofs, d1, sizeof(d1));
+    detail::write_n(m_ofs, d2, sizeof(d2));
+    detail::write_n(m_ofs, d3, sizeof(d3));
+    detail::write_n(m_ofs, d4, sizeof(d4));
     
     // 7. Version major
     n1 = m_header.GetVersionMajor();
     assert(1 == n1);
-    detail::write_n(GetStream(), n1, sizeof(n1));
+    detail::write_n(m_ofs, n1, sizeof(n1));
     
     // 8. Version minor
     n1 = m_header.GetVersionMinor();
-    detail::write_n(GetStream(), n1, sizeof(n1));
+    detail::write_n(m_ofs, n1, sizeof(n1));
 
     // 9. System ID
     std::string sysid(m_header.GetSystemId(true));
     assert(sysid.size() == 32);
-    detail::write_n(GetStream(), sysid, 32);
+    detail::write_n(m_ofs, sysid, 32);
     
     // 10. Generating Software ID
     std::string softid(m_header.GetSoftwareId(true));
     assert(softid.size() == 32);
-    detail::write_n(GetStream(), softid, 32);
+    detail::write_n(m_ofs, softid, 32);
 


More information about the Liblas-commits mailing list