[Liblas-commits] hg: add rewritten las2txt. Keep las2txt-old around for those wh...

liblas-commits at liblas.org liblas-commits at liblas.org
Wed Nov 24 15:15:31 EST 2010


changeset 249e428e53cc in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=249e428e53cc
summary: add rewritten las2txt.  Keep las2txt-old around for those who still may be using it

diffstat:

 apps/CMakeLists.txt |   19 +-
 apps/las2txt.cpp    |  614 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 628 insertions(+), 5 deletions(-)

diffs (truncated from 676 to 300 lines):

diff -r 1c7248d4623e -r 249e428e53cc apps/CMakeLists.txt
--- a/apps/CMakeLists.txt	Tue Nov 23 14:25:43 2010 -0600
+++ b/apps/CMakeLists.txt	Wed Nov 24 14:15:17 2010 -0600
@@ -19,6 +19,7 @@
 set(LASMERGE lasmerge)
 set(LAS2LAS las2las)
 set(LAS2LAS_OLD las2las-old)
+set(LAS2TXT_OLD las2txt-old)
 set(LAS2TXT las2txt)
 set(TXT2LAS txt2las)
 set(TS2LAS ts2las)
@@ -47,8 +48,8 @@
 endif()
 
 set(LIBLAS_UTILITIES
-    ${LASINFO_OLD} ${LASINFO} ${LASMERGE} ${LAS2LAS} ${LAS2TXT} ${TXT2LAS} 
-    ${LAS2OGR}  ${LAS2OCI} ${LAS2LAS} ${LAS2LAS_OLD} ${LASBLOCK} ${TS2LAS})
+    ${LASINFO_OLD} ${LASINFO} ${LASMERGE} ${LAS2LAS} ${LAS2TXT_OLD} ${TXT2LAS} 
+    ${LAS2OGR}  ${LAS2OCI} ${LAS2LAS} ${LAS2LAS_OLD} ${LASBLOCK} ${TS2LAS}  ${LAS2TXT} )
 
 # TODO: Experimental and requires testing --mloskot
 # Generate user-specific settings for Visual Studio project
@@ -82,6 +83,8 @@
 
 link_directories(${Boost_LIBRARY_DIRS})
 
+#    add_executable(lasschematest lasschematest.cpp laskernel.cpp)
+#    target_link_libraries(lasschematest ${APPS_CPP_DEPENDENCIES} ${LIBXML2_LIBRARIES})
 
 # Build lasinfo
 if(LASINFO_OLD)
@@ -97,6 +100,7 @@
     target_link_libraries(${LAS2LAS_OLD} ${LIBLAS_C_LIB_NAME})
 endif()
 
+
 if(LAS2LAS)
     add_executable(${LAS2LAS} las2las.cpp laskernel.cpp)
     target_link_libraries(${LAS2LAS} ${APPS_CPP_DEPENDENCIES} )
@@ -108,10 +112,15 @@
 endif()
 
 # Build las2txt
+if(LAS2TXT_OLD)
+    set(LAS2TXT_OLD_SRC lascommon.c ${LAS2TXT}.c)
+    add_executable(${LAS2TXT_OLD} ${LAS2TXT_OLD_SRC})
+    target_link_libraries(${LAS2TXT_OLD} ${LIBLAS_C_LIB_NAME})
+endif()
+
 if(LAS2TXT)
-    set(LAS2TXT_SRC lascommon.c ${LAS2TXT}.c)
-    add_executable(${LAS2TXT} ${LAS2TXT_SRC})
-    target_link_libraries(${LAS2TXT} ${LIBLAS_C_LIB_NAME})
+    add_executable( ${LAS2TXT}  las2txt.cpp laskernel.cpp )
+    target_link_libraries(${LAS2TXT} ${APPS_CPP_DEPENDENCIES}  )
 endif()
  
 # Build txt2las
diff -r 1c7248d4623e -r 249e428e53cc apps/las2txt.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/apps/las2txt.cpp	Wed Nov 24 14:15:17 2010 -0600
@@ -0,0 +1,614 @@
+/***************************************************************************
+ *
+ * Project: libLAS -- C/C++ read/write library for LAS LIDAR data
+ * Purpose: LAS translation to ASCII text with optional configuration
+ * Author:  Martin Isenburg isenburg at cs.unc.edu 
+ * Author:  Howard Butler, hobu.inc at gmail.com
+ ***************************************************************************
+ * Copyright (c) 2010, Howard Butler, hobu.inc at gmail.com 
+ *
+ * See LICENSE.txt in this source distribution for more information.
+ **************************************************************************/
+
+#include <liblas/liblas.hpp>
+#include "laskernel.hpp"
+#include <liblas/utility.hpp>
+
+#include <boost/cstdint.hpp>
+#include <boost/foreach.hpp>
+#include <boost/array.hpp>
+#include <boost/lexical_cast.hpp>
+
+#include <string>
+
+using namespace liblas;
+using namespace std;
+
+#ifdef _WIN32
+#define compare_no_case(a,b,n)  _strnicmp( (a), (b), (n) )
+#else
+#define compare_no_case(a,b,n)  strncasecmp( (a), (b), (n) )
+#endif
+
+
+std::string GetLabels(std::string const& parse_string,
+                    std::string const& delimiter)
+{
+    std::ostringstream output;
+    
+    boost::uint32_t i = 0;
+    for (;;)
+    {
+        
+        switch (parse_string[i])
+        {
+        /* // the x coordinate */      
+        case 'x':
+            output << "\"X\"";
+            break;
+        /* // the y coordinate */
+        case 'y':
+            output << "\"Y\"";
+            break;
+        /* // the z coordinate */ 
+        case 'z':
+            output << "\"Z\"";
+            break;
+        /* // the raw x coordinate */      
+        case 'X':
+            output << "\"Raw X\"";
+            break;
+        /* // the raw y coordinate */
+        case 'Y':
+            output << "\"Raw Y\"";
+            break;
+        /* // the raw z coordinate */ 
+        case 'Z':
+            output << "\"Raw Z\"";
+            break;
+        /* // the gps-time */
+        case 't': 
+            output << "\"Time\"";
+            break;
+        /* // the intensity */
+        case 'i':
+            output << "\"Intensity\"";
+            break;
+        /* the scan angle */
+        case 'a':
+            output << "\"Scan Angle\"";
+            break;
+        /* the number of the return */
+        case 'r': 
+            output << "\"Return Number\"";
+            break;
+        /* the classification */
+        case 'c':
+            output << "\"Classification\"";
+            break;
+        /* the classification name */
+        case 'C':
+            output << "\"Classification Name\"";
+            break;
+        /* the user data */
+        case 'u': 
+            output << "\"User Data\"";
+            break;
+        /* the number of returns of given pulse */
+        case 'n':
+            output << "\"Number of Returns\"";
+            break;
+        /* the red channel color */
+        case 'R':
+            output << "\"Red\"";
+            break;            
+        /* the green channel color */
+        case 'G': 
+            output << "\"Green\"";
+            break;            
+        /* the blue channel color */
+        case 'B': 
+            output << "\"Blue\"";
+            break;            
+        case 'M':
+            output << "\"ID\"";
+            break;
+        case 'p':
+            output << "\"Point Source ID\"";
+            break;
+        /* the edge of flight line flag */
+        case 'e': 
+            output << "\"Flight Line Edge\"";
+            break;
+        /* the direction of scan flag */
+        case 'd': 
+            output << "\"Scan Direction\"";
+            break;
+        }
+
+        i++;
+
+        if (parse_string[i])
+        {
+            output << delimiter;
+        }
+        else
+        {
+            output << std::endl;
+            break;
+        }
+
+    }
+    return output.str();
+}
+
+std::string GetPointString( std::string const& parse_string,
+                            std::string const& delimiter,
+                            liblas::Point const& p, 
+                            boost::array<boost::uint32_t, 4> precisions, 
+                            boost::uint32_t index)
+{
+    
+    std::ostringstream output;
+    
+
+    output.setf(std::ios_base::fixed, std::ios_base::floatfield);
+    
+
+    boost::uint32_t i = 0;
+    liblas::Color const& c = p.GetColor();
+    for (;;)
+    {
+        
+        switch (parse_string[i])
+        {
+        /* // the x coordinate */      
+        case 'x':
+            output.setf(std::ios_base::fixed, std::ios_base::floatfield);
+            output.precision(precisions[0]); //x precision
+            output << p.GetX();
+            // lidardouble2string(printstring, LASPoint_GetX(p)); fprintf(file_out, "%s", printstring);
+            break;
+        /* // the y coordinate */
+        case 'y':
+            output.setf(std::ios_base::fixed, std::ios_base::floatfield);
+            output.precision(precisions[1]); //y precision
+            output << p.GetY();
+            break;
+        /* // the z coordinate */ 
+        case 'z':
+            output.setf(std::ios_base::fixed, std::ios_base::floatfield);
+            output.precision(precisions[2]); //z precision
+            output << p.GetZ();
+            break;
+        /* // the raw x coordinate */      
+        case 'X':
+            output << p.GetRawX();
+            break;
+        /* // the raw y coordinate */
+        case 'Y':
+            output << p.GetRawY();
+            break;
+        /* // the raw z coordinate */ 
+        case 'Z':
+            output << p.GetRawZ();
+            break;
+        /* // the gps-time */
+        case 't': 
+            output.setf(std::ios_base::fixed, std::ios_base::floatfield);
+            output.precision(precisions[3]); //t precision
+            output << p.GetTime();
+            break;
+        /* // the intensity */
+        case 'i':
+            output << p.GetIntensity();
+            break;
+        /* the scan angle */
+        case 'a':
+            output << p.GetScanAngleRank();
+            break;
+        /* the number of the return */
+        case 'r': 
+            output << p.GetReturnNumber();
+            break;
+        /* the classification */
+        case 'c':
+            output << p.GetClassification().GetClass();
+            break;
+        /* the classification name */
+        case 'C':
+            output << p.GetClassification().GetClassName();
+            break;
+        /* the user data */
+        case 'u': 
+            output << p.GetUserData();
+            break;
+        /* the number of returns of given pulse */
+        case 'n':
+            output << p.GetNumberOfReturns();
+            break;
+        /* the red channel color */
+        case 'R':
+            output << c.GetRed();
+            break;            
+        /* the green channel color */
+        case 'G': 
+            output << c.GetGreen();
+            break;            
+        /* the blue channel color */


More information about the Liblas-commits mailing list