[pktools] 242/375: support laz files in pklas2img

Bas Couwenberg sebastic at xs4all.nl
Wed Dec 3 21:54:18 UTC 2014


This is an automated email from the git hooks/post-receive script.

sebastic-guest pushed a commit to branch upstream-master
in repository pktools.

commit 94c4eef7b02cac77f4875df5726e08cd38ef717b
Author: Pieter Kempeneers <kempenep at gmail.com>
Date:   Thu Apr 17 19:42:52 2014 +0200

    support laz files in pklas2img
---
 ChangeLog                       |  3 ++-
 src/apps/pklas2img.cc           | 15 +++++++++++----
 src/lasclasses/FileReaderLas.cc |  6 ++++--
 3 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 49ee4c7..7650758 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -285,4 +285,5 @@ version 2.5.2
 	thanks to suggestion of Francesco Paolo Lovergine
  - subdirectory pktools for include headers
 	thanks to suggestion of Francesco Paolo Lovergine
- -
+ - pklas2img
+	support for compressed point cloud (LAZ) files
diff --git a/src/apps/pklas2img.cc b/src/apps/pklas2img.cc
index 48dc13d..29df82b 100644
--- a/src/apps/pklas2img.cc
+++ b/src/apps/pklas2img.cc
@@ -140,7 +140,7 @@ int main(int argc,char **argv) {
   unsigned long int nPoints=0;
   unsigned long int ipoint=0;
   for(int iinput=0;iinput<input_opt.size();++iinput){
-    assert(input_opt[iinput].find(".las")!=string::npos);
+    // assert(input_opt[iinput].find(".las")!=string::npos);
     FileReaderLas lasReader;
     try{
       lasReader.open(input_opt[iinput]);
@@ -149,6 +149,9 @@ int main(int argc,char **argv) {
       cout << errorString << endl;
       exit(1);
     }
+    catch(...){
+      exit(2);
+    }
     nPoints=lasReader.getPointCount();
     totalPoints+=nPoints;
 
@@ -230,11 +233,9 @@ int main(int argc,char **argv) {
     for(int icol=0;icol<ncol;++icol)
       outputData[irow][icol]=0;
 
-  cout << "Reading " << input_opt.size() << " las files" << endl;
+  cout << "Reading " << input_opt.size() << " point cloud files" << endl;
   pfnProgress(progress,pszMessage,pProgressArg);
   for(int iinput=0;iinput<input_opt.size();++iinput){
-    if(verbose_opt[0])
-      cout << "opening input LAS file " << input_opt[iinput] << endl;
     FileReaderLas lasReader;
     try{
       lasReader.open(input_opt[iinput]);
@@ -243,6 +244,12 @@ int main(int argc,char **argv) {
       cout << errorString << endl;
       exit(1);
     }
+    if(verbose_opt[0]){
+      if(lasReader.isCompressed())
+	cout << "Reading compressed point cloud " << input_opt[iinput]<< endl;
+      else
+	cout << "Reading uncompressed point cloud " << input_opt[iinput] << endl;
+    }
     //set bounding filter
     // lasReader.addBoundsFilter(minULX,maxULY,maxLRX,minLRY);
     //set returns filter
diff --git a/src/lasclasses/FileReaderLas.cc b/src/lasclasses/FileReaderLas.cc
index aceaac1..f6873c0 100644
--- a/src/lasclasses/FileReaderLas.cc
+++ b/src/lasclasses/FileReaderLas.cc
@@ -83,9 +83,11 @@ void FileReaderLas::close(void)
 void FileReaderLas::setCodec(const std::string& filename){
   m_ifstream = new(std::ifstream);
   m_ifstream->open(m_filename.c_str(),std::ios::in|std::ios::binary);
-  m_reader = new liblas::Reader(*m_ifstream);
+  liblas::ReaderFactory f;
+  liblas::Reader reader = f.CreateWithStream(*m_ifstream);
+  m_reader=new liblas::Reader(reader);
+  // m_reader = new liblas::Reader(*m_ifstream);
   //Note: It is possible to use the basic liblas::Reader constructor that takes in a std::istream, but it will not be able to account for the fact that the file might be compressed. Using the ReaderFactory will take care of all of this for you.
-  // liblas::ReaderFactory rfactory;
   // m_reader=&rfactory.CreateWithStream(ifs);
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/pktools.git



More information about the Pkg-grass-devel mailing list