[Liblas-commits] hg: start on schema writing -- broken just now, however

liblas-commits at liblas.org liblas-commits at liblas.org
Thu Sep 2 09:42:14 EDT 2010


changeset fe0c4ce5bb7d in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=fe0c4ce5bb7d
summary: start on schema writing -- broken just now, however

diffstat:

 apps/las2las2.cpp                       |  18 ++++++++--------
 include/liblas/detail/writer/header.hpp |   1 +
 include/liblas/lasschema.hpp            |   3 ++
 src/detail/writer/header.cpp            |   1 +
 src/lasschema.cpp                       |  37 +++++++++++++++++++++++++++++++++
 5 files changed, 51 insertions(+), 9 deletions(-)

diffs (129 lines):

diff -r b588f1f8db17 -r fe0c4ce5bb7d apps/las2las2.cpp
--- a/apps/las2las2.cpp	Wed Sep 01 22:26:50 2010 -0500
+++ b/apps/las2las2.cpp	Thu Sep 02 08:42:09 2010 -0500
@@ -211,7 +211,7 @@
     
     liblas::Header header;
 
-    try {
+    // try {
 
         po::options_description file_options("las2las2 options");
         po::options_description* filtering_options = GetFilteringOptions();
@@ -289,14 +289,14 @@
         
         delete filtering_options;
         delete transform_options;
-    }
-    catch(std::exception& e) {
-        std::cerr << "error: " << e.what() << "\n";
-        return 1;
-    }
-    catch(...) {
-        std::cerr << "Exception of unknown type!\n";
-    }
+    // }
+    // catch(std::exception& e) {
+    //     std::cerr << "error: " << e.what() << "\n";
+    //     return 1;
+    // }
+    // catch(...) {
+    //     std::cerr << "Exception of unknown type!\n";
+    // }
     
     return 0;
 
diff -r b588f1f8db17 -r fe0c4ce5bb7d include/liblas/detail/writer/header.hpp
--- a/include/liblas/detail/writer/header.hpp	Wed Sep 01 22:26:50 2010 -0500
+++ b/include/liblas/detail/writer/header.hpp	Thu Sep 02 08:42:09 2010 -0500
@@ -68,6 +68,7 @@
     
     boost::int32_t WriteVLRs();
     void WriteLAS10PadSignature();
+    
     liblas::Header m_header;
 };
 
diff -r b588f1f8db17 -r fe0c4ce5bb7d include/liblas/lasschema.hpp
--- a/include/liblas/lasschema.hpp	Wed Sep 01 22:26:50 2010 -0500
+++ b/include/liblas/lasschema.hpp	Thu Sep 02 08:42:09 2010 -0500
@@ -95,6 +95,9 @@
     std::vector<std::string> GetDimensionNames() const;
   
     liblas::property_tree::ptree GetPTree() const;
+    
+    bool IsCustom() const;
+    VariableRecord const& GetVLR() const;
 
 protected:
     
diff -r b588f1f8db17 -r fe0c4ce5bb7d src/detail/writer/header.cpp
--- a/src/detail/writer/header.cpp	Wed Sep 01 22:26:50 2010 -0500
+++ b/src/detail/writer/header.cpp	Thu Sep 02 08:42:09 2010 -0500
@@ -252,6 +252,7 @@
     // it returns is the number of bytes we must increase the header
     // by in order for it to contain the VLRs.
     
+    m_header.AddVLR(m_header.GetSchema().GetVLR());
     int32_t difference = WriteVLRs();
     if (difference < 0) {
         m_header.SetDataOffset(m_header.GetDataOffset() + abs(difference) );
diff -r b588f1f8db17 -r fe0c4ce5bb7d src/lasschema.cpp
--- a/src/lasschema.cpp	Wed Sep 01 22:26:50 2010 -0500
+++ b/src/lasschema.cpp	Thu Sep 02 08:42:09 2010 -0500
@@ -41,6 +41,7 @@
 
 #include <liblas/lasschema.hpp>
 #include <liblas/detail/utility.hpp>
+#include <liblas/external/property_tree/xml_parser.hpp>
 // boost
 #include <boost/cstdint.hpp>
 // std
@@ -376,6 +377,21 @@
     
 }
 
+bool Schema::IsCustom() const
+{
+    // A custom schema has no fields that are required by the PointFormatName
+    // This must mean a user has added them themselves.  We only write VLR 
+    // schema definitions to files that have custom schemas.
+    std::vector<DimensionPtr>::const_iterator i;
+
+    for (i = m_dimensions.begin(); i != m_dimensions.end(); ++i)
+    {
+        DimensionPtr t = *i;
+        if ( t->IsRequired() == false)
+            return true;
+    }
+    return false;
+}
 boost::uint32_t Schema::GetSize() const
 {
     std::vector<DimensionPtr>::const_iterator i;
@@ -563,4 +579,25 @@
     return pt;
 }
 
+VariableRecord const& Schema::GetVLR() const
+{
+    VariableRecord vlr;
+    std::vector<boost::uint8_t> data;
+    vlr.SetUserId("liblas");
+    vlr.SetRecordId(7);
+    
+    std::ostringstream oss;
+    liblas::property_tree::ptree tree = GetPTree();
+    liblas::property_tree::write_xml(oss, tree);
+    
+    std::string s(oss.str());
+    std::string::const_iterator i;
+    for (i = s.begin(); i != s.end(); ++i)
+    {
+        data.push_back(*i);
+    }
+    vlr.SetData(data);
+    vlr.SetRecordLength(data.size());
+    return vlr;
+}
 } // namespace liblas


More information about the Liblas-commits mailing list