[Liblas-commits] hg: added -ouput-format option

liblas-commits at liblas.org liblas-commits at liblas.org
Tue Dec 28 10:33:09 EST 2010


details:   http://hg.liblas.orghg/rev/abf1a2eb8455
changeset: 2651:abf1a2eb8455
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Mon Dec 27 13:08:01 2010 -0700
description:
added -ouput-format option
Subject: hg: show compression status in dumps

details:   http://hg.liblas.orghg/rev/b002cf6403c8
changeset: 2652:b002cf6403c8
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Tue Dec 28 08:32:40 2010 -0700
description:
show compression status in dumps

diffstat:

 apps/las2las.cpp |  23 ++++++++++++++++++++++-
 src/header.cpp   |   6 +++---
 2 files changed, 25 insertions(+), 4 deletions(-)

diffs (73 lines):

diff -r cc96cb47b8eb -r b002cf6403c8 apps/las2las.cpp
--- a/apps/las2las.cpp	Mon Dec 27 12:44:33 2010 -0700
+++ b/apps/las2las.cpp	Tue Dec 28 08:32:40 2010 -0700
@@ -238,6 +238,7 @@
     boost::uint32_t split_pts = 0;
     std::string input;
     std::string output;
+    std::string output_format;
     
     bool verbose = false;
     bool bMinOffset = false;
@@ -264,6 +265,7 @@
             ("split-pts", po::value<boost::uint32_t>(&split_pts)->default_value(0), "Split file into multiple files with each being this many points or less. If this value is 0, no splitting is done")
             ("input,i", po::value< string >(), "input LAS file")
             ("output,o", po::value< string >(&output)->default_value("output.las"), "output LAS file")
+            ("output-format", po::value< string >(&output_format)->default_value(""), "output format type ('las' or 'laz')")
             ("verbose,v", po::value<bool>(&verbose)->zero_tokens(), "Verbose message output")
         ;
 
@@ -325,7 +327,26 @@
         // Transforms alter our header as well.  Setting scales, offsets, etc.
         transforms = GetTransforms(vm, verbose, header);
 
-        switch (WriterFactory::InferFileTypeFromExtension(output))
+        WriterFactory::FileType output_file_type = WriterFactory::FileType_Unknown;
+        if (output_format == "")
+        {
+            // use file extension
+            output_file_type = WriterFactory::InferFileTypeFromExtension(output);
+        }
+        else if (output_format == "las")
+        {
+            output_file_type = WriterFactory::FileType_LAS;
+        }
+        else if (output_format == "laz")
+        {
+            output_file_type = WriterFactory::FileType_LAZ;
+        }
+        else
+        {
+            output_file_type = WriterFactory::FileType_Unknown;
+        }
+
+        switch (output_file_type)
         {
         case WriterFactory::FileType_LAS:
             header.SetCompressed(false);
diff -r cc96cb47b8eb -r b002cf6403c8 src/header.cpp
--- a/src/header.cpp	Mon Dec 27 12:44:33 2010 -0700
+++ b/src/header.cpp	Tue Dec 28 08:32:40 2010 -0700
@@ -731,11 +731,11 @@
     pt.put("size", GetHeaderSize());
     pt.put("dataoffset", GetDataOffset());
 
-    
     pt.put("count", GetPointRecordsCount());
     pt.put("dataformatid", GetDataFormatId());
     pt.put("datarecordlength", GetDataRecordLength());
-    
+    pt.put("compressed", Compressed());
+
     ptree return_count;
     liblas::Header::RecordsByReturnArray returns = GetPointRecordsByReturnCount();
     for (boost::uint32_t i=0; i< 5; i++){
@@ -807,7 +807,7 @@
 
     os << "  Point Data Format:           " << tree.get<boost::uint32_t>("dataformatid") << std::endl;
     os << "  Number of Point Records:     " << tree.get<boost::uint32_t>("count") << std::endl;
-
+    os << "  Compressed:                  " << (tree.get<bool>("compressed")?"True":"False") << std::endl;
     std::ostringstream returns_oss;
     BOOST_FOREACH(ptree::value_type &v,
           tree.get_child("returns"))


More information about the Liblas-commits mailing list