[Liblas-commits] hg: 6 new changesets

liblas-commits at liblas.org liblas-commits at liblas.org
Fri Oct 29 23:17:56 EDT 2010


changeset 202ed62dcb81 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=202ed62dcb81
summary: header stuff must be set before transforms like reprojection so that reprojection can use current header information

changeset ab8f50dfe8d3 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=ab8f50dfe8d3
summary: typo

changeset 7a77ccef6316 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=7a77ccef6316
summary: use boost types instead of standard compiler types for function specification

changeset fd4b3237d7ce in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=fd4b3237d7ce
summary: provide the ability to supply a header with scaling information that will override the existing point's header as part of the ReprojectionTransform

changeset eb3b6fe033fa in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=eb3b6fe033fa
summary: start porting over the reprojection tests from the python test suite

changeset 44a7566492b5 in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=44a7566492b5
summary: merge

diffstat:

 apps/lasinfo.cpp                       |    2 +-
 apps/laskernel.cpp                     |  648 ++++++++++++++++----------------
 include/liblas/detail/reader/point.hpp |    3 -
 include/liblas/lasreader.hpp           |    9 +-
 include/liblas/lasspatialreference.hpp |    6 +-
 include/liblas/lastransform.hpp        |    4 +
 src/detail/reader/point.cpp            |   18 +-
 src/laspoint.cpp                       |   73 ++-
 src/lasreader.cpp                      |  105 ++--
 src/lasspatialreference.cpp            |    8 +-
 src/lastransform.cpp                   |   41 +-
 src/utility.cpp                        |   34 +-
 test/unit/lasspatialreference_test.cpp |  163 ++++++++-
 13 files changed, 671 insertions(+), 443 deletions(-)

diffs (truncated from 1512 to 300 lines):

diff -r a18904ebcf06 -r 44a7566492b5 apps/lasinfo.cpp
--- a/apps/lasinfo.cpp	Fri Oct 29 09:29:38 2010 -0500
+++ b/apps/lasinfo.cpp	Fri Oct 29 22:17:43 2010 -0500
@@ -131,7 +131,7 @@
             ("no-vlrs", po::value<bool>(&show_vlrs)->zero_tokens()->implicit_value(false), "Don't show VLRs")
             ("no-schema", po::value<bool>(&show_schema)->zero_tokens()->implicit_value(false), "Don't show schema")
             ("no-check", po::value<bool>(&check)->zero_tokens()->implicit_value(false), "Don't scan points")
-            ("xml", po::value<bool>(&output_xml)->zero_tokens()->implicit_value(true), "Output summary as XML")
+            ("xml", po::value<bool>(&output_xml)->zero_tokens()->implicit_value(true), "Output as XML")
             ("point,p", po::value<boost::uint32_t>(&point), "Display a point with a given id.  --point 44")
 
             // ("json", po::value<bool>(&output_json)->zero_tokens()->implicit_value(true), "Output summary as JSON")
diff -r a18904ebcf06 -r 44a7566492b5 apps/laskernel.cpp
--- a/apps/laskernel.cpp	Fri Oct 29 09:29:38 2010 -0500
+++ b/apps/laskernel.cpp	Fri Oct 29 22:17:43 2010 -0500
@@ -689,6 +689,327 @@
 {
     std::vector<liblas::TransformPtr> transforms;
 
+    if (vm.count("offset")) 
+    {
+
+        std::vector<double> offsets = vm["offset"].as< std::vector<double> >();
+        if (offsets.size() != 3) {
+            ostringstream oss;
+            oss << "Three arguments must be given to offset. "
+                << "--offset x y z";
+
+            throw std::runtime_error(oss.str());
+        }
+
+        
+        if (verbose)
+        {
+            ostringstream oss;
+            for (std::vector<double>::const_iterator i = offsets.begin();
+                 i != offsets.end();
+                 i++) 
+                {
+                    oss << *i << " ";
+                }
+                std::cout << "Setting offsets to: " << oss.str() << std::endl;
+        }
+
+        header.SetOffset(offsets[0], offsets[1], offsets[2]);
+    }
+
+    if (vm.count("scale")) 
+    {
+        std::vector<double> scales = vm["scale"].as< std::vector<double> >();
+
+        if (scales.size() != 3) {
+            ostringstream oss;
+            oss << "Three arguments must be given to scale. "
+                << "--scale x y z";
+
+            throw std::runtime_error(oss.str());
+        }
+
+        
+        if (verbose)
+        {
+            ostringstream oss;
+            for (std::vector<double>::const_iterator i = scales.begin();
+                 i != scales.end();
+                 i++) 
+                {
+                    oss << *i << " ";
+                }
+                std::cout << "Setting scales to: " << oss.str() << std::endl;
+        }
+
+
+        header.SetScale(scales[0], scales[1], scales[2]);
+    }
+    
+    if (vm.count("format")) 
+    {
+        std::string format_string = vm["format"].as< string >();
+        if (verbose)
+            std::cout << "Setting format to: " << format_string << std::endl;
+            
+        boost::char_separator<char> sep(".");
+        std::vector<int> versions;
+        tokenizer tokens(format_string, sep);
+        for (tokenizer::iterator t = tokens.begin(); t != tokens.end(); ++t) {
+            const char* v =(*t).c_str();
+            int i = atoi(v);
+            versions.push_back(i);
+        }
+        if (versions.size() < 2)
+        {
+            ostringstream oss;
+            oss << "Format version must dotted -- ie, '1.0' or '1.2', not " << format_string;
+            throw std::runtime_error(oss.str());
+        }
+        
+        int minor = versions[1];
+        if (minor > 2){
+            ostringstream oss;
+            oss << "Format version must dotted -- ie, '1.0' or '1.2', not " << format_string;
+            throw std::runtime_error(oss.str());
+        }
+        header.SetVersionMinor(static_cast<boost::uint8_t>(minor)); 
+    }
+    if (vm.count("pad-header")) 
+    {
+        std::string header_pad = vm["pad-header"].as< string >();
+        if (verbose)
+            std::cout << "Increasing header pad to: " << header_pad << std::endl;
+
+        boost::uint32_t offset = header.GetDataOffset();
+        if (atoi(header_pad.c_str()) == 0) {
+            ostringstream oss;
+            oss << "Header pad was 0.  It must be greater than "<<offset<< " bytes";
+            throw std::runtime_error(oss.str());
+            
+        }
+        header.SetDataOffset(atoi(header_pad.c_str()));
+    }
+
+    if (vm.count("file-creation"))
+    {
+        std::vector<std::string> creation = vm["file-creation"].as< std::vector<std::string> >();
+
+        if (verbose)
+        {
+            ostringstream oss;
+            for (std::vector<std::string>::const_iterator i = creation.begin();
+                 i != creation.end();
+                 i++) 
+                {
+                    oss << *i << " ";
+                }
+                std::cout << "Setting file creation to " << oss.str() << std::endl;
+        }
+            
+        std::string m("now");
+        bool now = false;
+        if (creation.size() == 1 ) 
+        {
+            if (!(creation[0].compare(m))) 
+            {
+                now = true;
+            }            
+        }
+        
+        boost::int32_t day = 0;
+        boost::int32_t year = 0;
+        
+        
+        if (creation.size() == 2) 
+        {
+            day = atoi(creation[0].c_str());
+            year = atoi(creation[1].c_str());
+            
+            if (day < 0 || day > 366) {
+                ostringstream oss;
+                oss << "Day must be between 1-366, not " << day;
+                throw std::runtime_error(oss.str());
+            }
+            if (year < 0)
+            {
+                ostringstream oss;
+                oss << "Year must be greater than 0, not " << year;
+                throw std::runtime_error(oss.str());
+            }
+            
+        }
+        
+        if (now == true) 
+        {
+            liblas::Header h;
+            header.SetCreationDOY(h.GetCreationDOY());
+            header.SetCreationYear(h.GetCreationYear());
+        } else {
+            header.SetCreationDOY(static_cast<boost::uint16_t>(day));
+            header.SetCreationYear(static_cast<boost::uint16_t>(year));
+            
+        }
+    }
+
+    if (vm.count("add-schema")) 
+    {
+        liblas::VariableRecord vlr = header.GetSchema().GetVLR();
+        header.AddVLR(vlr);
+    }
+
+    if (vm.count("delete-vlr")) 
+    {
+        std::vector<std::string> vlrs = vm["delete-vlr"].as< std::vector<std::string> >();
+        
+        
+        if (vlrs.size() % 2 != 0) {
+            ostringstream err;
+            err << "VLR descriptions must be in pairs of 2 -- A name and an ID";
+            throw std::runtime_error(err.str());
+        }
+        ostringstream oss;
+        
+        for (std::vector<std::string>::const_iterator i = vlrs.begin();
+             i != vlrs.end();
+             i++) 
+            {
+                oss << *i << " ";
+            }
+        if (verbose)
+        {
+
+                std::cout << "Deleting VLRs with the values: " << oss.str() << std::endl;
+        }
+        
+        for (std::vector<std::string>::size_type i = 0; i < vlrs.size(); i=i+2)
+        {
+            boost::int32_t id = atoi(vlrs[i+1].c_str());
+            if (id < 0)
+            {
+                throw std::runtime_error("VLR ID must be > 0");
+            }
+            if (id > std::numeric_limits<boost::uint16_t>::max()) {
+                ostringstream oss;
+                oss << "ID must be less than "<< std::numeric_limits<boost::uint16_t>::max() <<", not " << id;
+                throw std::runtime_error(oss.str());
+            }
+            header.DeleteVLRs(vlrs[i], static_cast<boost::uint16_t>(id));
+        }
+    }
+
+    if (vm.count("add-vlr")) 
+    {
+        std::vector<std::string> vlrs = vm["add-vlr"].as< std::vector<std::string> >();
+        
+        
+        if (vlrs.size() < 3) {
+            ostringstream err;
+            err << "VLR additions must be at least 3 arguments -- --add-vlr NAME 42 \"filename.ext\"";
+            throw std::runtime_error(err.str());
+        }
+        if (vlrs.size() > 4)
+            throw std::runtime_error("Only one VLR may be added at a time");
+
+        ostringstream oss;
+        
+        for (std::vector<std::string>::const_iterator i = vlrs.begin();
+             i != vlrs.end();
+             i++) 
+            {
+                oss << *i << " ";
+            }
+
+        
+        liblas::VariableRecord v;
+        v.SetUserId(vlrs[0]);
+
+        boost::int32_t id = atoi(vlrs[1].c_str());
+        if (id < 0)
+        {
+            throw std::runtime_error("VLR ID must be > 0");
+        }
+        if (id > std::numeric_limits<boost::uint16_t>::max()) {
+            ostringstream oss;
+            oss << "ID must be less than "<< std::numeric_limits<boost::uint16_t>::max() <<", not " << id;
+            throw std::runtime_error(oss.str());
+        }
+
+        v.SetRecordId(static_cast<boost::uint16_t>(id));
+        
+        std::vector<boost::uint8_t> data;
+        
+        std::string data_or_filename;
+        if (vlrs.size() == 4){
+
+            v.SetDescription(vlrs[2]);
+            data_or_filename = vlrs[3];
+        } else {
+            data_or_filename = vlrs[2];
+        } 
+
+        try {
+            std::vector<char> d;
+            d = TryReadRawFileData(data_or_filename);
+            for (std::vector<char>::const_iterator i = d.begin(); i != d.end(); ++i) 
+            {
+                data.push_back(*i);
+            }
+            
+        } catch (std::runtime_error const& ) {
+            std::string::const_iterator i;
+            for (i = data_or_filename.begin(); i != data_or_filename.end(); ++i)
+            {
+                data.push_back(*i);
+            }
+        }    
+
+        if (data.size() > std::numeric_limits<boost::uint16_t>::max()) {
+            std::ostringstream oss;
+            oss << "This VLR with length " << data.size() << " does" 
+                << " not fit within the maximum VLR size of " 
+                << std::numeric_limits<boost::uint16_t>::max();
+            throw std::runtime_error(oss.str());


More information about the Liblas-commits mailing list