[liblas] 01/02: Add patch from upstream to remove old LAStools utilities.

Bas Couwenberg sebastic at xs4all.nl
Mon Jul 28 21:28:33 UTC 2014


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

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

commit 931f4da2532874f8ea2aa6349aa727e0cce68060
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Tue Jun 10 23:54:17 2014 +0200

    Add patch from upstream to remove old LAStools utilities.
---
 debian/changelog                                   |    2 +
 ...ols-utilities-that-don-t-belong-in-liblas.patch | 2201 ++++++++++++++++++++
 debian/patches/series                              |    1 +
 3 files changed, 2204 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 674535a..49597f7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,6 +4,8 @@ liblas (1.7.0+dfsg-6) UNRELEASED; urgency=medium
   * Use dh_install --list-install.
   * Also include lasblock, ts2las, las2las-old, las2txt-old & lasinfo-old
     programs in liblas-bin.
+  * Add patch from upstream to remove old LAStools utilities.
+    (closes: #749403)
 
  -- Bas Couwenberg <sebastic at xs4all.nl>  Fri, 06 Jun 2014 13:56:59 +0200
 
diff --git a/debian/patches/0001-remove-old-LAStools-utilities-that-don-t-belong-in-liblas.patch b/debian/patches/0001-remove-old-LAStools-utilities-that-don-t-belong-in-liblas.patch
new file mode 100644
index 0000000..ad4c951
--- /dev/null
+++ b/debian/patches/0001-remove-old-LAStools-utilities-that-don-t-belong-in-liblas.patch
@@ -0,0 +1,2201 @@
+From 834f1ab517d6e93233fe10391a78ae390ceb200b Mon Sep 17 00:00:00 2001
+From: Howard Butler <hobu.inc at gmail.com>
+Date: Fri, 6 Jun 2014 16:42:36 -0500
+Subject: remove old LAStools utilities that don't belong in liblas #39
+Origin: https://github.com/libLAS/libLAS/commit/834f1ab517d6e93233fe10391a78ae390ceb200b
+
+
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -142,13 +142,13 @@ else()
+   # Recommended C++ compilation flags
+   # -Weffc++
+   set(LIBLAS_COMMON_CXX_FLAGS
+-	"-pedantic -ansi -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wfloat-equal -Wredundant-decls -Wno-long-long")
++	" -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wfloat-equal -Wredundant-decls -Wno-long-long")
+ 
+   if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
+ 
+     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBLAS_COMMON_CXX_FLAGS}")
+     if (CMAKE_COMPILER_IS_GNUCXX)
+-      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98")
++      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98 -ansi")
+     endif()
+ 
+   elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR "${CMAKE_CXX_COMPILER}" MATCHES "clang")
+--- a/apps/CMakeLists.txt
++++ b/apps/CMakeLists.txt
+@@ -14,12 +14,8 @@ include_directories(
+ ###############################################################################
+ # Collect programs to build
+ 
+-set(LASINFO_OLD lasinfo-old)
+ set(LASINFO lasinfo)
+-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)
+@@ -45,8 +41,8 @@ endif()
+ 
+ 
+ set(LIBLAS_UTILITIES
+-    ${LASINFO_OLD} ${LASINFO} ${LASMERGE} ${LAS2LAS} ${LAS2TXT_OLD} ${TXT2LAS} 
+-    ${LAS2OGR} ${LAS2LAS} ${LAS2LAS_OLD} ${LASBLOCK} ${TS2LAS}  ${LAS2TXT} )
++    ${LASINFO} ${LAS2LAS} ${TXT2LAS} 
++    ${LAS2OGR} ${LAS2LAS} ${LASBLOCK} ${TS2LAS}  ${LAS2TXT} )
+ 
+ # TODO: Experimental and requires testing --mloskot
+ # Generate user-specific settings for Visual Studio project
+@@ -84,20 +80,6 @@ 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)
+-    set(LASINFO_OLD_SRC lascommon.c ${LASINFO_OLD}.c)
+-    add_executable(${LASINFO_OLD} ${LASINFO_OLD_SRC})
+-    target_link_libraries(${LASINFO_OLD} ${LIBLAS_C_LIB_NAME})
+-endif()
+-
+-# Build las2las
+-if(LAS2LAS_OLD)
+-    set(LAS2LAS_OLD_SRC lascommon.c ${LAS2LAS_OLD}.c)
+-    add_executable(${LAS2LAS_OLD} ${LAS2LAS_OLD_SRC})
+-    target_link_libraries(${LAS2LAS_OLD} ${LIBLAS_C_LIB_NAME})
+-endif()
+-
+ 
+ if(LAS2LAS)
+     add_executable(${LAS2LAS} las2las.cpp laskernel.cpp)
+@@ -109,13 +91,6 @@ if(LASINFO)
+     target_link_libraries(${LASINFO} ${APPS_CPP_DEPENDENCIES}  )
+ 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)
+     add_executable( ${LAS2TXT}  las2txt.cpp laskernel.cpp )
+     target_link_libraries(${LAS2TXT} ${APPS_CPP_DEPENDENCIES}  )
+@@ -133,13 +108,6 @@ if(TS2LAS)
+     target_link_libraries(${TS2LAS} ${APPS_CPP_DEPENDENCIES} )
+ endif()
+ 
+-# Build lasmerge
+-if(LASMERGE)
+-    set(LASMERGE_SRC lascommon.c ${LASMERGE}.c)
+-    add_executable(${LASMERGE} ${LASMERGE_SRC})
+-    target_link_libraries(${LASMERGE} ${LIBLAS_C_LIB_NAME})
+-endif()
+-
+ # Build lasblock
+ if(LASBLOCK)
+     set(LASBLOCK_SRC lasblock.cpp laskernel.cpp)
+--- a/apps/las2las-old.c
++++ /dev/null
+@@ -1,1165 +0,0 @@
+-/***************************************************************************
+- * $Id$
+- * $Date$
+- *
+- * Project: libLAS -- C/C++ read/write library for LAS LIDAR data
+- * Purpose: LAS translation with optional configuration
+- * Author:  Martin Isenburg isenburg at cs.unc.edu 
+- ***************************************************************************
+- * Copyright (c) 2007, Martin Isenburg isenburg at cs.unc.edu 
+- *
+- * See LICENSE.txt in this source distribution for more information.
+- **************************************************************************/
+-
+-#include "liblas.h"
+-#include "lascommon.h"
+-
+-/* std */
+-#include <assert.h>
+-#include <time.h>
+-#include <stdio.h>
+-#include <stdlib.h>
+-#include <string.h>
+-
+-#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
+-
+-LASPointSummary* SummarizePoints(LASReaderH reader);
+-void print_point_summary(FILE *file, LASPointSummary* summary, LASHeaderH header);
+-void print_point(FILE *file, LASPointH point);
+-void print_header(FILE *file, LASHeaderH header, const char* file_name, int bSkipVLR);
+-void repair_header(FILE *file, LASHeaderH header, LASPointSummary* summary) ;
+-
+-#define LAS_FORMAT_10 0
+-#define LAS_FORMAT_11 1
+-#define LAS_FORMAT_12 2
+-
+-void do_bulk_copy(const char* infile, size_t in_start_point, const char* outfile)
+-{
+-    /* bulk copy assumes that the header has already been written to outfile 
+-       as it is supposed to be, and that we're just going to copy all of the 
+-       points in infile as they are.  
+-    */
+-    FILE* file_out = 0;
+-    FILE* file_in = 0;
+-    
+-    size_t read = 0;
+-    size_t written = 0;
+-    size_t size = 1000;
+-
+-    char *buffer = 0;
+-    
+-    buffer = (char*) malloc(size * sizeof(char));
+-    
+-    if (buffer == 0) {
+-        LASError_Print("unable to allocate buffer copy");
+-        exit(1);
+-    }
+-    file_in = fopen(infile, "rb");
+-    fseek(file_in, in_start_point, SEEK_SET);
+-    
+-    if (file_in == 0) {
+-        LASError_Print("input filename not valid for bulk copy");
+-        exit(1);
+-    }
+-    file_out = fopen(outfile, "ab+");
+-    if (file_out == 0) {
+-        LASError_Print("output filename not valid for bulk copy");
+-        exit(1);
+-    }
+-    
+-    while (feof(file_in) == 0) {
+-        read = fread(buffer, 1, size, file_in);
+-        written = fwrite(buffer, 1, read, file_out);
+-        
+-        if (read != written) {
+-            LASError_Print("unable to write data in bulk copy");
+-            exit(1);
+-        }
+-    }
+-    
+-    fclose(file_in);
+-    fclose(file_out);
+-    free(buffer);
+-}
+-
+-
+-void usage()
+-{
+-    fprintf(stderr,"----------------------------------------------------------\n");
+-    fprintf(stderr,"    las2las-old (version %s) usage:\n", LAS_GetFullVersion());
+-    fprintf(stderr,"----------------------------------------------------------\n");
+-    fprintf(stderr,"\n");
+-
+-    fprintf(stderr,"Clip las file to a bounding box, throwing out points that have invalid data:\n");
+-    fprintf(stderr,"  las2las-old -i in.las -clip 63000000 483450000 63050000 483500000 -o out.las --skip_invalid\n");
+-    fprintf(stderr,"\n");
+-
+-    fprintf(stderr,"Read from stdin, eliminate intensities below 2000, and write to stdout:\n");
+-    fprintf(stderr,"  las2las-old --eliminate_intensity_below 2000 --stdin --stdout < in.las > out.las \n");
+-    fprintf(stderr,"\n");
+-    
+-    fprintf(stderr,"Eliminate return number two:\n");
+-    fprintf(stderr,"  las2las-old -i in.las -eliminate_return 2 -o out.las\n");
+-    fprintf(stderr,"\n");
+-    
+-    fprintf(stderr,"Eliminate scan angles above 15:\n");
+-    fprintf(stderr,"  las2las-old -i in.las -eliminate_scan_angle_above 15 -o out.las\n");
+-    fprintf(stderr,"\n");
+-
+-    fprintf(stderr,"Eliminate intensities below 1000:\n");
+-    fprintf(stderr,"  las2las-old -i in.las -eliminate_intensity_below 1000 --stdout > out.las\n");
+-    fprintf(stderr,"\n");
+-
+-    fprintf(stderr,"Eliminate intensities below 1000 and classifications that equal 2 (ground):\n");
+-    fprintf(stderr,"  las2las-old -i in.las --eliminate_class 2 --out out.las\n");
+-    fprintf(stderr,"\n");
+-        
+-    fprintf(stderr,"Capture only first returns and clip to bounding box:\n");
+-    fprintf(stderr,"  las2las-old -i in.las -first_only -clip 63000000 483450000 63050000 483500000 -o out.las\n");
+-    fprintf(stderr,"\n");
+-
+-    fprintf(stderr,"Capture only last returns, eliminate intensities below 2000, and write to stdout:\n");
+-    fprintf(stderr,"  las2las-old --input in.las --last_only --eliminate_intensity_below 2000 --stdout > out.las\n");
+-    fprintf(stderr,"\n");
+-
+-    fprintf(stderr,"Reproject the data (requires GDAL support):\n");
+-    fprintf(stderr,"  las2las-old -v in.las output.las -xyz_offset 0 0 0 "
+-                   "-t_srs EPSG:4326 --xyz_scale 0.0000001 0.0000001 0.0000001"
+-                   "-s_srs EPSG:26915\n");
+-    fprintf(stderr,"\n");
+-
+-    fprintf(stderr, "\nFor more information, see the full documentation for las2las-old at:\n"
+-                    " http://liblas.org/utilities/las2las-old.html\n");
+-    fprintf(stderr,"----------------------------------------------------------\n");
+-
+-}
+-
+-void ptime(const char *const msg)
+-{
+-  float t= ((float)clock())/CLOCKS_PER_SEC;
+-  fprintf(stderr, "cumulative CPU time thru %s = %f\n", msg, t);
+-}
+-
+-int main(int argc, char *argv[])
+-{
+-    int i;
+-    int verbose = FALSE;
+-    int use_stdin = FALSE;
+-    int use_stdout = FALSE;
+-    char* file_name_in = 0;
+-    char* file_name_out = 0;
+-    char* proj4_text = NULL;
+-    double *clip_xy_min = NULL;
+-    double *clip_xy_max = NULL;
+-    int clip = FALSE;
+-    int remove_extra_header = FALSE;
+-    int elim_return = 0;
+-    int elim_scan_angle_above = 0;
+-    int elim_intensity_below = 0;
+-    int elim_class = 0;
+-    int clsidx = 0;
+-    int first_only = FALSE;
+-    int last_only = FALSE;
+-    int skip_invalid = FALSE;
+-    int format = LAS_FORMAT_12;
+-    int bulk_copy = FALSE;
+-    
+-    LASReaderH reader = NULL;
+-    LASHeaderH header = NULL;
+-    LASHeaderH surviving_header = NULL;
+-    LASPointH p = NULL;
+-    LASWriterH writer = NULL;
+-    
+-    LASSRSH in_srs = NULL;
+-    LASSRSH out_srs = NULL;
+-    int use_min_offset = FALSE;
+-    int do_reprojection = FALSE;
+-    int do_set_offset = FALSE;
+-    int do_set_scale = FALSE;
+-    int do_pad_header = FALSE;
+-    
+-    int header_pad = 0;
+-    
+-    int first_surviving_point = TRUE;
+-    unsigned int surviving_number_of_point_records = 0;
+-    unsigned int surviving_number_of_points_by_return[] = {0,0,0,0,0,0,0,0};
+-    LASPointH surviving_point_min = NULL;
+-    LASPointH surviving_point_max = NULL;
+-    double surviving_gps_time_min;
+-    double surviving_gps_time_max;
+-    int verticalCSType = -1, verticalDatum = -1, verticalUnits = 9001;
+-    const char *verticalCitation = "";
+-
+-    int clipped = 0;
+-    int eliminated_return = 0;
+-    int eliminated_scan_angle = 0;
+-    int eliminated_intensity = 0;
+-    int eliminated_class = 0;
+-    int eliminated_first_only = 0;
+-    int eliminated_last_only = 0; 
+-    int thinned = 0;
+-    
+-    int bThin = FALSE;
+-    int nThin = 0;
+-
+-    double xyz_scale[3] = {0.0, 0.0, 0.0};
+-    double xyz_offset[3] = {0.0, 0.0, 0.0};
+-    
+-    double minx, maxx, miny, maxy, minz, maxz;
+-    
+-    LASPointSummary* summary = NULL;
+-    
+-    int ret = 0;
+-    
+-    for (i = 1; i < argc; i++) {
+-        if (    strcmp(argv[i],"-h") == 0 ||
+-                strcmp(argv[i],"--help") == 0
+-            )
+-        {
+-            usage();
+-            exit(0);
+-        }
+-        else if (   strcmp(argv[i],"-v") == 0 ||
+-                    strcmp(argv[i],"--verbose") == 0
+-            )
+-        {
+-            verbose = TRUE;
+-        }
+-        else if (   strcmp(argv[i],"-s") == 0 ||
+-                    strcmp(argv[i],"--skip_invalid") == 0
+-            )
+-        {
+-            skip_invalid = TRUE;
+-        }
+-        else if (   strcmp(argv[i],"-b") == 0 ||
+-                    strcmp(argv[i],"--bulk") == 0
+-            )
+-        {
+-            bulk_copy = TRUE;
+-        }
+-        
+-        else if (   strcmp(argv[i],"--input") == 0  ||
+-                    strcmp(argv[i],"-input") == 0   ||
+-                    strcmp(argv[i],"-i") == 0       ||
+-                    strcmp(argv[i],"-in") == 0
+-                )
+-        {
+-            i++;
+-            file_name_in = argv[i];
+-        }
+-        else if (   strcmp(argv[i],"--output") == 0  ||
+-                    strcmp(argv[i],"--out") == 0     ||
+-                    strcmp(argv[i],"-out") == 0     ||
+-                    strcmp(argv[i],"-o") == 0       
+-                )
+-        {
+-            i++;
+-            file_name_out = argv[i];
+-        }
+-
+-        else if (   strcmp(argv[i],"--stdout") == 0  ||
+-                    strcmp(argv[i],"-olas") == 0    
+-                )
+-        {
+-            use_stdout = TRUE;
+-            file_name_out = "stdout";
+-        }
+-        else if (   strcmp(argv[i],"--clip") == 0   ||
+-                    strcmp(argv[i],"-clip") == 0    ||
+-                    strcmp(argv[i],"-clip_xy") == 0 
+-                )
+-        {
+-            clip_xy_min = (double*) malloc (2 * sizeof(double));
+-            clip_xy_max = (double*) malloc( 2 * sizeof(double));
+-            i++;
+-            clip_xy_min[0] = atof(argv[i]);
+-            i++;
+-            clip_xy_min[1] = atof(argv[i]);
+-            i++;
+-            clip_xy_max[0] = atof(argv[i]);
+-            i++;
+-            clip_xy_max[1] = atof(argv[i]);
+-            clip = TRUE;
+-        }
+-        else if (   strcmp(argv[i],"--format") == 0   ||
+-                    strcmp(argv[i],"-f") == 0    ||
+-                    strcmp(argv[i],"-format") == 0 
+-                )
+-        {
+-            i++;
+-            if (strcmp(argv[i], "1.0") == 0) {
+-                format = LAS_FORMAT_10;
+-            }
+-            else if (strcmp(argv[i], "1.1") == 0) {
+-                format = LAS_FORMAT_11;
+-            } 
+-            else if (strcmp(argv[i], "1.2") == 0) {
+-                format = LAS_FORMAT_12;
+-            }
+-            else {
+-                LASError_Print("Format must be specified as 1.0, 1.1, or 1.2");
+-            }
+-
+-        }
+-
+-        else if (   strcmp(argv[i],"--eliminate_return") == 0  ||
+-                    strcmp(argv[i],"-eliminate_return") == 0   ||
+-                    strcmp(argv[i],"-elim_return") == 0       ||
+-                    strcmp(argv[i],"-elim_ret") == 0
+-                )        
+-        {
+-            i++;
+-            elim_return |= (1 << atoi(argv[i]));
+-        }
+-        else if (   strcmp(argv[i],"--eliminate_scan_angle_above") == 0  ||
+-                    strcmp(argv[i],"-eliminate_scan_angle_above") == 0   ||
+-                    strcmp(argv[i],"-elim_scan_angle_above") == 0       ||
+-                    strcmp(argv[i],"--clip_scan_above") == 0
+-                )        
+-        {
+-            i++;
+-            elim_scan_angle_above = atoi(argv[i]);
+-        }
+-        else if (   strcmp(argv[i],"--eliminate_class") == 0  ||
+-                    strcmp(argv[i],"-eliminate_class") == 0   ||
+-                    strcmp(argv[i],"-elim_class") == 0       ||
+-                    strcmp(argv[i],"--class") == 0
+-                )        
+-        {
+-            i++;
+-            elim_class = atoi(argv[i]);
+-        }
+-        else if (   strcmp(argv[i],"--eliminate_intensity_below") == 0  ||
+-                    strcmp(argv[i],"-eliminate_intensity_below") == 0   ||
+-                    strcmp(argv[i],"-elim_intensity_below") == 0       ||
+-                    strcmp(argv[i],"--clip_intensity_below") == 0
+-                )        
+-        {
+-            i++;
+-            elim_intensity_below = atoi(argv[i]);
+-        }
+-        else if (   strcmp(argv[i], "--stdin") == 0 ||
+-                    strcmp(argv[i], "-ilas") == 0
+-                ) 
+-        {
+-            use_stdin = TRUE;
+-        }
+-        else if (   strcmp(argv[i], "--first_only") == 0 ||
+-                    strcmp(argv[i], "-first_only") == 0
+-                ) 
+-        {
+-            first_only = TRUE;
+-        }
+-        else if (   strcmp(argv[i], "--last_only") == 0 ||
+-                    strcmp(argv[i], "-last_only") == 0
+-                ) 
+-        {
+-            last_only = TRUE;
+-        }
+-        else if (   strcmp(argv[i], "--remove_extra_header") == 0 ||
+-                    strcmp(argv[i], "-remove_extra_header") == 0
+-                ) 
+-        {
+-            remove_extra_header = TRUE;
+-        }
+-        else if (   strcmp(argv[i],"--s_srs") == 0  ||
+-                    strcmp(argv[i],"-s_srs") == 0    
+-                )
+-        {
+-            ++i;
+-            if (LAS_IsGDALEnabled()) {
+-                in_srs = LASSRS_Create();
+-                ret = LASSRS_SetFromUserInput(in_srs, argv[i]);
+-                if (ret) {
+-                    LASError_Print("Unable to import assigned SRS");
+-                    exit(1);
+-                }
+-            }
+-        }
+-        else if (   strcmp(argv[i],"--t_srs") == 0  ||
+-                    strcmp(argv[i],"-t_srs") == 0    ||
+-                    strcmp(argv[i],"-t") == 0 
+-                )
+-        {
+-            ++i;
+-            if (LAS_IsGDALEnabled()) {
+-                out_srs = LASSRS_Create();
+-                ret = LASSRS_SetFromUserInput(out_srs, argv[i]);
+-                if (ret) {
+-                    LASError_Print("Unable to import output SRS");
+-                    exit(1);
+-                }
+-                do_reprojection = TRUE;
+-            }
+-        }
+-        else if (   strcmp(argv[i],"--a_srs") == 0  ||
+-                    strcmp(argv[i],"-a_srs") == 0 
+-                )
+-        {
+-            ++i;
+-            if (LAS_IsGDALEnabled()) {
+-                out_srs = LASSRS_Create();
+-                ret = LASSRS_SetFromUserInput(out_srs, argv[i]);
+-                if (ret) {
+-                    LASError_Print("Unable to import output SRS");
+-                    exit(1);
+-                }
+-            }
+-        }
+-        else if (   strcmp(argv[i],"--a_vertcs") == 0  ||
+-                    strcmp(argv[i],"-a_vertcs") == 0 
+-                )
+-        {
+-            ++i;
+-            verticalCSType = atoi(argv[i]);
+-            ++i;
+-            if( i < argc && argv[i][0] != '-' )
+-            {
+-                verticalCitation = argv[i];
+-                ++i;
+-
+-                if( i < argc && argv[i][0] != '-' )
+-                {
+-                    verticalDatum = atoi(argv[i]);
+-                    ++i;
+-                    if( i < argc && argv[i][0] != '-' )
+-                    {
+-                        verticalUnits = atoi(argv[i]);
+-                        ++i;
+-                    }
+-                }
+-            }
+-        }
+-        else if (   strcmp(argv[i],"--scale") == 0  ||
+-                    strcmp(argv[i],"-scale") == 0    
+-                )
+-        {
+-
+-            i++;
+-            sscanf(argv[i], "%lf", &(xyz_scale[2]));
+-            xyz_scale[0] = xyz_scale[1] = xyz_scale[2];
+-            do_set_scale = TRUE;
+-        }
+-        else if (   strcmp(argv[i],"--xyz_scale") == 0  ||
+-                    strcmp(argv[i],"-xyz_scale") == 0    
+-                )
+-
+-        {
+-            i++;
+-            sscanf(argv[i], "%lf", &(xyz_scale[0]));
+-            i++;
+-            sscanf(argv[i], "%lf", &(xyz_scale[1]));
+-            i++;
+-            sscanf(argv[i], "%lf", &(xyz_scale[2]));
+-            do_set_scale = TRUE;
+-        }
+-        else if (   strcmp(argv[i],"--xyz_offset") == 0  ||
+-                    strcmp(argv[i],"-xyz_offset") == 0    
+-                )
+-        {
+-            i++;
+-            if (!compare_no_case(argv[i], "min", 3)) {
+-                use_min_offset = TRUE;
+-                do_set_offset = TRUE;
+-            } else
+-            {
+-                sscanf(argv[i], "%lf", &(xyz_offset[0]));
+-                i++;
+-                sscanf(argv[i], "%lf", &(xyz_offset[1]));
+-                i++;
+-                sscanf(argv[i], "%lf", &(xyz_offset[2]));
+-                do_set_offset = TRUE;
+-            }
+-        }
+-        else if (   strcmp(argv[i],"--pad-header") == 0  ||
+-                    strcmp(argv[i],"-pad-header") == 0   ||
+-                    strcmp(argv[i],"-ph") == 0 
+-                )        
+-        {
+-            i++;
+-            do_pad_header = TRUE;
+-            header_pad = atoi(argv[i]);
+-        }
+-        else if (   strcmp(argv[i],"--thin") == 0  ||
+-                    strcmp(argv[i],"-y") == 0    
+-                )
+-        {
+-            i++;
+-            bThin = TRUE;
+-            nThin = atoi(argv[i]);
+-        }
+-        else if (file_name_in == NULL && file_name_out == NULL)
+-        {
+-            file_name_in = argv[i];
+-        }
+-        else if (file_name_in != NULL && file_name_out == NULL)
+-        {
+-            file_name_out = argv[i];
+-        }
+-        else 
+-        {
+-            fprintf(stderr, "ERROR: unknown argument '%s'\n",argv[i]);
+-            usage();
+-            exit(1);
+-        }
+-    }
+-
+-    if (use_stdin) file_name_in="stdin";
+-    if (file_name_in)
+-    {
+-        reader = LASReader_Create(file_name_in);
+-        if (!reader) { 
+-            LASError_Print("Could not open file to read");
+-            exit(1);
+-        }
+-    }
+-    else
+-    {
+-        LASError_Print("no input specified");
+-        usage();
+-        exit(1);
+-    }
+-
+-        
+-    header = LASReader_GetHeader(reader);
+-    if (!header) { 
+-        LASError_Print("Could not fetch header");
+-        exit(1);
+-    } 
+-
+-    if (verbose) {
+-        ptime("start.");
+-        fprintf(stderr, "first pass reading %d points ...\n", LASHeader_GetPointRecordsCount(header));
+-    }
+-
+-    p  = LASReader_GetNextPoint(reader);
+-
+-    if (!p) {
+-        if (LASError_GetLastErrorNum()) 
+-            LASError_Print("Not able to fetch a point.  LASReader is invalid");
+-        else
+-            LASError_Print("File does not contain any points to read.");
+-        exit(1);
+-    }
+-    
+-    i = 0;
+-    while (p)
+-    {
+-        if (bThin && ((i % nThin) != 0)) {
+-            thinned++;
+-            i++;
+-            p = LASReader_GetNextPoint(reader);
+-            continue;
+-        }
+-        if (last_only && LASPoint_GetReturnNumber(p) != LASPoint_GetNumberOfReturns(p))
+-        {
+-            eliminated_last_only++;
+-            p = LASReader_GetNextPoint(reader);
+-            continue;
+-        }
+-        if (first_only && LASPoint_GetReturnNumber(p) != 1)
+-        {
+-            eliminated_first_only++;
+-            p = LASReader_GetNextPoint(reader);
+-            continue;
+-        }
+-    
+-        if (clip && (LASPoint_GetX(p) < clip_xy_min[0] || LASPoint_GetY(p) < clip_xy_min[1]))
+-        {
+-            clipped++;
+-            p = LASReader_GetNextPoint(reader);
+-            continue;
+-        }
+-        if (clip && (LASPoint_GetX(p) > clip_xy_max[0] || LASPoint_GetY(p) > clip_xy_max[1]))
+-        {
+-            clipped++;
+-            p = LASReader_GetNextPoint(reader);
+-            continue;
+-        } 
+-        if (elim_return && (elim_return & (1 << LASPoint_GetReturnNumber(p))))
+-        {
+-            eliminated_return++;
+-            p = LASReader_GetNextPoint(reader);
+-            continue;
+-        }
+-        if (elim_scan_angle_above && (LASPoint_GetScanAngleRank(p) > elim_scan_angle_above || LASPoint_GetScanAngleRank(p) < -elim_scan_angle_above))
+-        {
+-            eliminated_scan_angle++;
+-            p = LASReader_GetNextPoint(reader);
+-            continue;
+-        }
+-
+-        clsidx = LASPoint_GetClassification(p);
+-        clsidx = (clsidx & 31); /* 31 is max index in classification lookup table */
+-        assert(clsidx <= 31);
+-        if (elim_class && (elim_class == clsidx))
+-        {
+-            eliminated_class++;
+-            p = LASReader_GetNextPoint(reader);
+-            continue;
+-        }
+-
+-        if (elim_intensity_below && LASPoint_GetIntensity(p) < elim_intensity_below)
+-        {
+-            eliminated_intensity++;
+-            p = LASReader_GetNextPoint(reader);
+-            continue;
+-        }
+-        surviving_number_of_point_records++;
+-
+-        if (LASPoint_GetReturnNumber(p))
+-            surviving_number_of_points_by_return[LASPoint_GetReturnNumber(p)-1]++;
+-        else
+-            surviving_number_of_points_by_return[LASPoint_GetReturnNumber(p)]++;        
+-
+-        if (first_surviving_point)
+-        {
+-            surviving_point_min = LASPoint_Copy(p);
+-            surviving_point_max = LASPoint_Copy(p);
+-            surviving_gps_time_min = LASPoint_GetTime(p);
+-            surviving_gps_time_max = LASPoint_GetTime(p);
+-            first_surviving_point = FALSE;
+-        }
+-        else
+-        {
+-            if (LASPoint_GetX(p) < LASPoint_GetX(surviving_point_min))
+-                LASPoint_SetX(surviving_point_min,LASPoint_GetX(p));
+-            else if (LASPoint_GetX(p) > LASPoint_GetX(surviving_point_max)) 
+-                LASPoint_SetX(surviving_point_max,LASPoint_GetX(p));
+-
+-            if (LASPoint_GetY(p) < LASPoint_GetY(surviving_point_min)) 
+-                LASPoint_SetY(surviving_point_min,LASPoint_GetY(p));
+-            else if (LASPoint_GetY(p) > LASPoint_GetY(surviving_point_max)) 
+-                LASPoint_SetY(surviving_point_max,LASPoint_GetY(p));
+-
+-            if (LASPoint_GetZ(p) < LASPoint_GetZ(surviving_point_min))
+-                LASPoint_SetZ(surviving_point_min,LASPoint_GetZ(p));
+-            else if (LASPoint_GetZ(p) > LASPoint_GetZ(surviving_point_max))   
+-                LASPoint_SetZ(surviving_point_max,LASPoint_GetZ(p));
+-
+-            if (LASPoint_GetIntensity(p) < LASPoint_GetIntensity(surviving_point_min)) 
+-                LASPoint_SetIntensity(surviving_point_min,LASPoint_GetIntensity(p));
+-            else if (LASPoint_GetIntensity(p) > LASPoint_GetIntensity(surviving_point_max)) 
+-                LASPoint_SetIntensity(surviving_point_max,LASPoint_GetIntensity(p));
+-
+-            if (LASPoint_GetFlightLineEdge(p) < LASPoint_GetFlightLineEdge(surviving_point_min)) 
+-                LASPoint_SetFlightLineEdge(surviving_point_min,LASPoint_GetFlightLineEdge(p));
+-            else if (LASPoint_GetFlightLineEdge(p) > LASPoint_GetFlightLineEdge(surviving_point_max)) 
+-                LASPoint_SetFlightLineEdge(surviving_point_max,LASPoint_GetFlightLineEdge(p));
+-
+-            if (LASPoint_GetScanDirection(p) < LASPoint_GetScanDirection(surviving_point_min)) 
+-                LASPoint_SetScanDirection(surviving_point_min,LASPoint_GetScanDirection(p));
+-            else if (LASPoint_GetScanDirection(p) > LASPoint_GetScanDirection(surviving_point_max)) 
+-                LASPoint_SetScanDirection(surviving_point_max,LASPoint_GetScanDirection(p));
+-
+-            if (LASPoint_GetNumberOfReturns(p) < LASPoint_GetNumberOfReturns(surviving_point_min)) 
+-                LASPoint_SetNumberOfReturns(surviving_point_min,LASPoint_GetNumberOfReturns(p));
+-            else if (LASPoint_GetNumberOfReturns(p) > LASPoint_GetNumberOfReturns(surviving_point_max)) 
+-                LASPoint_SetNumberOfReturns(surviving_point_max,LASPoint_GetNumberOfReturns(p));
+-
+-            if (LASPoint_GetReturnNumber(p) < LASPoint_GetReturnNumber(surviving_point_min)) 
+-                LASPoint_SetReturnNumber(surviving_point_min,LASPoint_GetReturnNumber(p));
+-            else if (LASPoint_GetReturnNumber(p) > LASPoint_GetReturnNumber(surviving_point_max)) 
+-                LASPoint_SetReturnNumber(surviving_point_max,LASPoint_GetReturnNumber(p));
+-
+-            if (LASPoint_GetClassification(p) < LASPoint_GetClassification(surviving_point_min)) 
+-                LASPoint_SetClassification(surviving_point_min,LASPoint_GetClassification(p));
+-            else if (LASPoint_GetReturnNumber(p) > LASPoint_GetClassification(surviving_point_max)) 
+-                LASPoint_SetClassification(surviving_point_max,LASPoint_GetClassification(p));
+-
+-            if (LASPoint_GetScanAngleRank(p) < LASPoint_GetScanAngleRank(surviving_point_min)) 
+-                LASPoint_SetScanAngleRank(surviving_point_min,LASPoint_GetScanAngleRank(p));
+-            else if (LASPoint_GetScanAngleRank(p) > LASPoint_GetScanAngleRank(surviving_point_max)) 
+-                LASPoint_SetScanAngleRank(surviving_point_max,LASPoint_GetScanAngleRank(p));
+-
+-            if (LASPoint_GetUserData(p) < LASPoint_GetUserData(surviving_point_min)) 
+-                LASPoint_SetUserData(surviving_point_min,LASPoint_GetUserData(p));
+-            else if (LASPoint_GetUserData(p) > LASPoint_GetUserData(surviving_point_max)) 
+-                LASPoint_SetUserData(surviving_point_max,LASPoint_GetUserData(p));
+-
+-            if (LASPoint_GetTime(p) < LASPoint_GetTime(surviving_point_min)) 
+-                LASPoint_SetTime(surviving_point_min,LASPoint_GetTime(p));
+-            else if (LASPoint_GetTime(p) > LASPoint_GetTime(surviving_point_max)) 
+-                LASPoint_SetTime(surviving_point_max,LASPoint_GetTime(p));
+-
+-        }
+-  
+-        p  = LASReader_GetNextPoint(reader);
+-        i++;
+-    }
+-
+-    if (eliminated_first_only) 
+-        fprintf(stderr, 
+-                "eliminated based on first returns only: %d\n",
+-                eliminated_first_only);
+-    if (eliminated_last_only) 
+-        fprintf(stderr, 
+-                "eliminated based on last returns only: %d\n", 
+-                eliminated_last_only);
+-    if (eliminated_class) 
+-        fprintf(stderr, 
+-                "eliminated classification: %d\n", 
+-                eliminated_class);
+-    if (clipped) 
+-        fprintf(stderr, 
+-                "clipped: %d\n", 
+-                clipped);
+-    if (eliminated_return) 
+-        fprintf(stderr, 
+-                "eliminated based on return number: %d\n", 
+-                eliminated_return);
+-    if (eliminated_scan_angle) 
+-        fprintf(stderr, 
+-                "eliminated based on scan angle: %d\n", 
+-                eliminated_scan_angle);
+-    if (eliminated_intensity) 
+-        fprintf(stderr, 
+-        "eliminated based on intensity: %d\n", 
+-        eliminated_intensity);
+-
+-    if (bThin) 
+-        fprintf(stderr, 
+-        "thinned: %d\n", 
+-        thinned);
+-    
+-    if (surviving_number_of_point_records == 0) {
+-        fprintf(stderr, "All points were eliminated!\n");
+-        exit(0);
+-    }
+-    
+-    LASReader_Destroy(reader);
+-    LASHeader_Destroy(header);
+-  
+-    if (verbose)
+-    {
+-        fprintf(stderr, 
+-                "x %.3f %.3f %.3f\n",
+-                LASPoint_GetX(surviving_point_min), 
+-                LASPoint_GetX(surviving_point_max), 
+-                LASPoint_GetX(surviving_point_max) - LASPoint_GetX(surviving_point_min)
+-                );
+-        fprintf(stderr, 
+-                "y %.3f %.3f %.3f\n",
+-                LASPoint_GetY(surviving_point_min), 
+-                LASPoint_GetY(surviving_point_max), 
+-                LASPoint_GetY(surviving_point_max) - LASPoint_GetY(surviving_point_min)
+-                );
+-        fprintf(stderr, 
+-                "z %.3f %.3f %.3f\n",
+-                LASPoint_GetZ(surviving_point_min), 
+-                LASPoint_GetZ(surviving_point_max), 
+-                LASPoint_GetZ(surviving_point_max) - LASPoint_GetZ(surviving_point_min)
+-                );
+-        fprintf(stderr, 
+-                "intensity %d %d %d\n",
+-                LASPoint_GetIntensity(surviving_point_min), 
+-                LASPoint_GetIntensity(surviving_point_max), 
+-                LASPoint_GetIntensity(surviving_point_max) - LASPoint_GetIntensity(surviving_point_min)
+-                );
+-        fprintf(stderr, 
+-                "edge_of_flight_line %d %d %d\n",
+-                LASPoint_GetFlightLineEdge(surviving_point_min), 
+-                LASPoint_GetFlightLineEdge(surviving_point_max), 
+-                LASPoint_GetFlightLineEdge(surviving_point_max) - LASPoint_GetFlightLineEdge(surviving_point_min)
+-                );
+-        fprintf(stderr, 
+-                "scan_direction_flag %d %d %d\n",
+-                LASPoint_GetScanDirection(surviving_point_min), 
+-                LASPoint_GetScanDirection(surviving_point_max), 
+-                LASPoint_GetScanDirection(surviving_point_max) - LASPoint_GetScanDirection(surviving_point_min)
+-                );
+-        fprintf(stderr, 
+-                "number_of_returns_of_given_pulse %d %d %d\n",
+-                LASPoint_GetNumberOfReturns(surviving_point_min), 
+-                LASPoint_GetNumberOfReturns(surviving_point_max), 
+-                LASPoint_GetNumberOfReturns(surviving_point_max) - LASPoint_GetNumberOfReturns(surviving_point_min)
+-                );
+-        fprintf(stderr, 
+-                "return_number %d %d %d\n",
+-                LASPoint_GetReturnNumber(surviving_point_min), 
+-                LASPoint_GetReturnNumber(surviving_point_max), 
+-                LASPoint_GetReturnNumber(surviving_point_max) - LASPoint_GetReturnNumber(surviving_point_min)
+-                );
+-        fprintf(stderr, 
+-                "classification %d %d %d\n",
+-                LASPoint_GetClassification(surviving_point_min), 
+-                LASPoint_GetClassification(surviving_point_max), 
+-                LASPoint_GetClassification(surviving_point_max) - LASPoint_GetClassification(surviving_point_min)
+-                );
+-        fprintf(stderr, 
+-                "scan_angle_rank %d %d %d\n",
+-                LASPoint_GetScanAngleRank(surviving_point_min), 
+-                LASPoint_GetScanAngleRank(surviving_point_max), 
+-                LASPoint_GetScanAngleRank(surviving_point_max) - LASPoint_GetScanAngleRank(surviving_point_min)
+-                );
+-        fprintf(stderr, 
+-                "user_data %d %d %d\n",
+-                LASPoint_GetUserData(surviving_point_min), 
+-                LASPoint_GetUserData(surviving_point_max), 
+-                LASPoint_GetUserData(surviving_point_max) - LASPoint_GetUserData(surviving_point_min)
+-                );
+-        fprintf(stderr, 
+-                "gps_time %.8f %.8f %.8f\n",
+-                LASPoint_GetTime(surviving_point_min), 
+-                LASPoint_GetTime(surviving_point_max), 
+-                LASPoint_GetTime(surviving_point_max) - LASPoint_GetTime(surviving_point_min)
+-                );
+-
+-    }
+-
+-    if (file_name_out == NULL && !use_stdout)
+-    {
+-        LASError_Print("no output specified. exiting...");
+-        exit(1);
+-    }
+-
+-
+-    fprintf(stderr, "Creating another reader...\n");
+-    if (file_name_in)
+-    {
+-        reader = LASReader_Create(file_name_in);
+-      if (!reader) { 
+-          LASError_Print("Could not open file to read");
+-          exit(1);
+-      } 
+-    }
+-    else
+-    {
+-        LASError_Print("no input specified");
+-        usage();
+-        exit(1);
+-    }
+-
+-    
+-    header = LASReader_GetHeader(reader);
+-    if (!header) { 
+-        LASError_Print("Could not read header");
+-        exit(1);
+-    } 
+-
+-
+-    surviving_header = LASHeader_Copy(header);
+-
+-    LASHeader_SetPointRecordsCount(surviving_header, surviving_number_of_point_records);
+-    LASHeader_SetSystemId(surviving_header, "MODIFICATION");
+-
+-    for (i = 0; i < 5; i++) LASHeader_SetPointRecordsByReturnCount(surviving_header, i, surviving_number_of_points_by_return[i]);
+-
+-    minx =  LASPoint_GetX(surviving_point_min) * \
+-            LASHeader_GetScaleX(surviving_header) + \
+-            LASHeader_GetOffsetX(surviving_header);
+-            
+-    maxx = LASPoint_GetX(surviving_point_max) * LASHeader_GetScaleX(surviving_header) + LASHeader_GetOffsetX(surviving_header);
+-
+-    miny = LASPoint_GetY(surviving_point_min) * LASHeader_GetScaleY(surviving_header) + LASHeader_GetOffsetY(surviving_header);
+-    maxy = LASPoint_GetY(surviving_point_max) * LASHeader_GetScaleY(surviving_header) + LASHeader_GetOffsetY(surviving_header);
+-
+-    minz = LASPoint_GetZ(surviving_point_min) * LASHeader_GetScaleZ(surviving_header) + LASHeader_GetOffsetZ(surviving_header);
+-    maxz = LASPoint_GetZ(surviving_point_max) * LASHeader_GetScaleZ(surviving_header) + LASHeader_GetOffsetZ(surviving_header);
+-    
+-    if (format == LAS_FORMAT_10) {
+-        LASHeader_SetVersionMinor(surviving_header, 0);
+-    } else if (format == LAS_FORMAT_11){
+-        LASHeader_SetVersionMinor(surviving_header, 1);
+-    } else if (format == LAS_FORMAT_12) {
+-        LASHeader_SetVersionMinor(surviving_header, 2);
+-    }
+-
+-    if (do_set_offset) {
+-        if (use_min_offset) {
+-            if (verbose) {
+-                fprintf(stderr, 
+-                    "Setting xyz offset to minimums...\n");
+-            }
+-            LASHeader_SetOffset(surviving_header, 
+-                                LASPoint_GetX(surviving_point_min), 
+-                                LASPoint_GetY(surviving_point_min), 
+-                                LASPoint_GetZ(surviving_point_min));
+-        } else {
+-            if (verbose) {
+-                fprintf(stderr, 
+-                    "Setting xyz offset to %.8f %.8f %.8f...\n", xyz_offset[0], xyz_offset[1], xyz_offset[2]);
+-            }
+-            LASHeader_SetOffset(surviving_header,
+-                                xyz_offset[0],
+-                                xyz_offset[1],
+-                                xyz_offset[2]);
+-        }
+-    }
+-
+-    if (do_set_scale) {
+-        if (verbose) {
+-            fprintf(stderr, 
+-                "Setting xyz scale to %.8f %.8f %.8f...\n", xyz_scale[0], xyz_scale[1], xyz_scale[2]);
+-        }
+-        LASHeader_SetScale( surviving_header, 
+-                            xyz_scale[0],
+-                            xyz_scale[1],
+-                            xyz_scale[2]);
+-    }
+-    
+-    if (do_pad_header){
+-        if (verbose) {
+-            fprintf(stderr, 
+-                "Padding header by %d bytes. New header will be %d bytes long instead of %d bytes ...\n", 
+-                header_pad, 
+-                LASHeader_GetDataOffset(surviving_header)+abs(header_pad), 
+-                LASHeader_GetDataOffset(surviving_header));
+-        }
+-        
+-        LASHeader_SetDataOffset(surviving_header, LASHeader_GetDataOffset(surviving_header)+abs(header_pad));
+-    }
+-    
+-    /* Do we have vertical cs info to set? */
+-    if( verticalCSType > 0 )
+-    {
+-        if( out_srs == NULL )
+-            out_srs = LASHeader_GetSRS(surviving_header);
+-
+-        if( out_srs == NULL )
+-            out_srs = LASSRS_Create();
+-
+-        LASSRS_SetVerticalCS( out_srs,
+-                              verticalCSType, 
+-                              verticalCitation, 
+-                              verticalDatum, 
+-                              verticalUnits );
+-    }
+-
+-    if (do_reprojection) {
+-        if (verbose) {
+-            proj4_text =  LASSRS_GetProj4(out_srs);
+-            fprintf(stderr,
+-                "Setting new coordinate system to %s", proj4_text);
+-            LASString_Free(proj4_text);
+-        }
+-        
+-        /* keep around the header's SRS if we don't have one set by the user */
+-        if (in_srs == NULL) {
+-            in_srs = LASHeader_GetSRS(surviving_header);
+-        }
+-        
+-        LASHeader_SetSRS(surviving_header, out_srs);
+-    }
+-
+-    /* Are we just assigning an override SRS? (-a_srs) */
+-    else if( out_srs != NULL )
+-    {
+-        LASHeader_SetSRS(surviving_header, out_srs);
+-    }
+-
+-    if (verbose) {
+-        fprintf(stderr, 
+-                "second pass reading %d and writing %d points ...\n", 
+-                LASHeader_GetPointRecordsCount(surviving_header), 
+-                surviving_number_of_point_records);
+-    }
+-    
+-    
+-    if (use_stdout) file_name_out = "stdout";
+-    
+-    writer = LASWriter_Create(  file_name_out, 
+-                                surviving_header, 
+-                                LAS_MODE_WRITE);
+-    if (!writer) { 
+-        LASError_Print("Could not open file to write");
+-        exit(1);
+-    }  
+-
+-    if (do_reprojection) {
+-        if (in_srs != NULL) {
+-            char* in_wkt = LASSRS_GetWKT(in_srs);
+-            if (strlen(in_wkt) == 0) {
+-                LASString_Free(in_wkt);
+-                LASError_Print("Input SRS is empty, please specify with -s_srs");
+-                exit(1);
+-            }
+-            LASString_Free(in_wkt);
+-            LASWriter_SetInputSRS(writer, in_srs);
+-        } else {
+-            
+-        }
+-    
+-        if (out_srs != NULL) {
+-            if (verbose) {
+-                fprintf(stderr,
+-                    "Setting LASWriter_SetOutputSRS to %s", LASSRS_GetProj4(out_srs));
+-            }
+-            LASWriter_SetOutputSRS(writer, out_srs);
+-        }
+-    }
+-/*
+-
+-  if (!remove_extra_header)
+-  {
+-    for (unsigned int u = lasreader->header.header_size; u < lasreader->header.offset_to_point_data; u++)
+-    {
+-      fputc(fgetc(file_in),file_out);
+-    }
+-  }
+-*/
+-
+-    
+-    LASReader_Destroy(reader);
+-    reader = NULL;
+-    if (file_name_in)
+-    {
+-        reader = LASReader_Create(file_name_in);
+-        if (!reader) { 
+-            LASError_Print("Could not open file to read");
+-            exit(1);
+-        } 
+-    }
+-    else
+-    {
+-        LASError_Print("no input specified");
+-        usage();
+-        exit(1);
+-    }
+-
+-    
+-    p = LASReader_GetNextPoint(reader);
+-    if (!p) {
+-        if (LASError_GetLastErrorNum()) 
+-            LASError_Print("Not able to fetch a point.  LASReader is invalid");
+-        else
+-            LASError_Print("File does not contain any points to read.");
+-        exit(1);
+-    }
+-    
+-    i = 0;
+-    while (p) {
+-
+-        if (bThin && ((i % nThin) != 0)) {
+-            i++;
+-            p = LASReader_GetNextPoint(reader);
+-            continue;
+-        }
+-        
+-        if (skip_invalid && !LASPoint_IsValid(p)) {
+-            p = LASReader_GetNextPoint(reader);
+-            continue;
+-        }
+-        if (last_only && LASPoint_GetReturnNumber(p) != LASPoint_GetNumberOfReturns(p))
+-        {
+-            p = LASReader_GetNextPoint(reader);
+-            continue;
+-        }
+-        if (first_only && LASPoint_GetReturnNumber(p) != 1)
+-        {
+-            p = LASReader_GetNextPoint(reader);
+-            continue;
+-
+-        }
+-        if (clip_xy_min && (LASPoint_GetX(p) < clip_xy_min[0] || LASPoint_GetY(p) < clip_xy_min[1]))
+-        {
+-            p = LASReader_GetNextPoint(reader);
+-            continue;
+-        }
+-        if (clip_xy_max && (LASPoint_GetX(p) > clip_xy_max[0] || LASPoint_GetY(p) > clip_xy_max[1]))
+-        {
+-            p = LASReader_GetNextPoint(reader);
+-            continue;
+-        }
+-        if (elim_return && (elim_return & (1 << LASPoint_GetReturnNumber(p))))
+-        {
+-            p = LASReader_GetNextPoint(reader);
+-            continue;
+-        }
+-        if (elim_scan_angle_above && (LASPoint_GetScanAngleRank(p) > elim_scan_angle_above || LASPoint_GetScanAngleRank(p) < -elim_scan_angle_above))
+-        {
+-            p = LASReader_GetNextPoint(reader);
+-            continue;
+-        }
+-        if (elim_intensity_below && LASPoint_GetIntensity(p) < elim_intensity_below)
+-        {
+-            p = LASReader_GetNextPoint(reader);
+-            continue;
+-        }
+-
+-        clsidx = LASPoint_GetClassification(p);
+-        clsidx = (clsidx & 31); /* 31 is max index in classification lookup table */
+-        assert(clsidx <= 31);
+-        if (elim_class && (elim_class == clsidx))
+-        {
+-            p = LASReader_GetNextPoint(reader);
+-            continue;
+-        }
+-        ret = LASWriter_WritePoint(writer,p);
+-        
+-        if (ret == LE_Warning) {
+-            LASError_Print("Unable to write invalid point.  Use --skip_invalid to avoid this problem (you will lose data in the translation)");
+-            exit(1);
+-        }
+-        p  = LASReader_GetNextPoint(reader);
+-        i++;
+-    }
+-
+-    LASWriter_Destroy(writer);
+-    LASReader_Destroy(reader);
+-    LASHeader_Destroy(header);
+-    LASHeader_Destroy(surviving_header);
+-
+-    if (surviving_point_max != NULL)
+-        LASPoint_Destroy(surviving_point_max);
+-    if (surviving_point_min != NULL)
+-        LASPoint_Destroy(surviving_point_min);
+-
+-    reader = LASReader_Create(file_name_out);
+-    if (!reader) { 
+-        LASError_Print("Could not open file to read");
+-        exit(1);
+-    }
+-
+-    header = LASReader_GetHeader(reader);
+-    if (!header) { 
+-        LASError_Print("Could not read header");
+-        exit(1);
+-    }
+-
+-    
+-    summary = SummarizePoints(reader);
+-    if (verbose) {
+-        print_point_summary(stderr, summary, header);
+-    }
+-    repair_header(stderr, header, summary) ;
+-
+-    if (summary != NULL) {
+-        if (summary->pmin != NULL)
+-            LASPoint_Destroy(summary->pmin);
+-        if (summary->pmax != NULL)
+-            LASPoint_Destroy(summary->pmax);
+-        free(summary);
+-    }
+-
+-    if (reader != NULL) {
+-        LASReader_Destroy(reader);
+-        reader = NULL;
+-    }
+-    
+-    writer = LASWriter_Create(file_name_out, header, LAS_MODE_APPEND);
+-    if (!writer) {
+-        LASError_Print("Problem creating LASWriterH object for append");
+-        LASHeader_Destroy(header);
+-        header = NULL;
+-        exit(1);
+-    }
+-    LASWriter_Destroy(writer);
+-    writer = NULL;
+-    LASHeader_Destroy(header);
+-    header = NULL;
+-    
+-    if (out_srs != NULL)
+-        LASSRS_Destroy(out_srs);
+-    
+-    if (in_srs != NULL)
+-        LASSRS_Destroy(in_srs);
+-
+-    if (verbose) ptime("done.");
+-
+-    return 0;
+-}
+--- a/apps/lasinfo-old.c
++++ /dev/null
+@@ -1,420 +0,0 @@
+-/***************************************************************************
+-* $Id$
+-* $Date$
+-*
+-* Project: libLAS -- C/C++ read/write library for LAS LIDAR data
+-* Purpose: LAS information reporting and setting
+-* Author:  Martin Isenburg isenburg at cs.unc.edu 
+-***************************************************************************
+-* Copyright (c) 2007, Martin Isenburg isenburg at cs.unc.edu 
+-*
+-* See LICENSE.txt in this source distribution for more information.
+-**************************************************************************/
+-
+-/* TODO: Remove before releasing */
+-#if defined(_MSC_VER) && defined(USE_VLD)
+-#include <vld.h>
+-#endif
+-
+-/* liblas */
+-#include <liblas.h>
+-/* std */
+-#include <stdio.h>
+-#include <stdlib.h>
+-#include <string.h>
+-
+-#ifdef HAVE_GDAL
+-#include <cpl_multiproc.h>
+-#include <cpl_string.h>
+-#endif
+-
+-#include "lascommon.h"
+-
+-LASPointSummary* SummarizePoints(LASReaderH reader);
+-void print_point_summary(FILE *file, LASPointSummary* summary, LASHeaderH header);
+-void print_header(FILE *file, LASHeaderH header, const char* file_name, int bSkipVLR, int bWKT);
+-
+-void usage()
+-{
+-    char* version = LAS_GetFullVersion();
+-    fprintf(stderr,"----------------------------------------------------------\n");
+-    fprintf(stderr,"    lasinfo-old (version %s) usage:\n", version);
+-    fprintf(stderr,"----------------------------------------------------------\n");
+-    fprintf(stderr,"\n");
+-    LASString_Free(version);
+-    version = NULL;
+-
+-    fprintf(stderr,"Printing simple header info:\n");
+-    fprintf(stderr,"  lasinfo-old lidar.las\n");
+-    fprintf(stderr,"\n");
+-
+-    fprintf(stderr,"Checking point information:\n");
+-    fprintf(stderr,"  lasinfo-old --input lidar.las --check\n");
+-    fprintf(stderr,"\n");
+-
+-    fprintf(stderr,"Print header info and point summary and redirect output to a file:\n");
+-    fprintf(stderr,"  lasinfo-old --check --input lidar.las 2> output.txt\n");
+-    fprintf(stderr,"\n");
+-
+-    fprintf(stderr,"Read from stdin, scan the points, and skip printing VLR info:\n");
+-    fprintf(stderr,"  lasinfo-old --stdin --check --skip_vlr < lidar.las\n");
+-    fprintf(stderr,"\n");
+-
+-    fprintf(stderr,"Repairing header info to reflect point data:\n");
+-    fprintf(stderr,"  lasinfo-old -i lidar.las --repair\n");
+-    fprintf(stderr,"\n");
+-
+-    fprintf(stderr,"Altering header info:\n");
+-    fprintf(stderr, "  lasinfo-old -i lidar.las --system_identifier \"hello world!\" "
+-                    "--generating_software \"this is a test (-:\"  --file_creation 8 2007\n");
+-    fprintf(stderr,"\n");
+-
+-    fprintf(stderr,"Print this output:\n");
+-    fprintf(stderr, "  lasinfo-old --help\n");
+-    fprintf(stderr,"\n");
+-
+-    fprintf(stderr, "\nFor more information, see the full documentation for lasinfo-old at:\n"
+-                    " http://liblas.org/utilities/lasinfo-old.html\n");
+-    fprintf(stderr,"----------------------------------------------------------\n");
+-}
+-
+-int main(int argc, char *argv[])
+-{
+-    int i = 0;
+-    char* file_name = NULL;
+-
+-    LASReaderH reader = NULL;
+-    LASHeaderH header = NULL;
+-    LASWriterH writer = NULL;
+-
+-    int check_points = FALSE;
+-    int repair_header = FALSE;
+-    int change_header = FALSE;
+-    int repair_bounding_box = FALSE;
+-    int use_stdin = FALSE;
+-    int update_return_counts = FALSE;
+-    int skip_vlr = FALSE;
+-    int wkt = FALSE;
+-
+-    char *system_identifier = NULL;
+-    char *generating_software = NULL;
+-    unsigned char file_creation_day = 0;
+-    unsigned char file_creation_year = 0;
+-
+-    int err = 0;
+-
+-    LASPointSummary* summary = NULL;
+-
+-    for (i = 1; i < argc; i++)
+-    {
+-        if (strcmp(argv[i],"-v") == 0 || strcmp(argv[i],"--version") == 0)
+-        {
+-            char* ver = LAS_GetFullVersion();
+-            fprintf(stderr,"%s", ver);
+-            LASString_Free(ver);
+-            exit(0);
+-        }
+-        else if (strcmp(argv[i],"-h") == 0 || strcmp(argv[i],"--help") == 0)
+-        {
+-            usage();
+-            exit(0);
+-        }
+-        else if (strcmp(argv[i],"--input") == 0
+-              || strcmp(argv[i],"-input") == 0
+-              || strcmp(argv[i],"-i") == 0
+-              || strcmp(argv[i],"-in") == 0)
+-        {
+-            i++;
+-            file_name = argv[i];
+-        }
+-        else if (strcmp(argv[i], "--points") == 0
+-              || strcmp(argv[i], "--check") == 0
+-              || strcmp(argv[i], "--check_points") == 0
+-              || strcmp(argv[i], "-c") == 0
+-              || strcmp(argv[i], "-points") == 0
+-              || strcmp(argv[i], "-check") == 0
+-              || strcmp(argv[i], "-check_points") == 0)
+-        {
+-            check_points = TRUE;
+-        }
+-        else if (strcmp(argv[i], "--nocheck") == 0
+-              || strcmp(argv[i], "-nocheck") == 0)
+-        {
+-            check_points = FALSE;
+-        }
+-        else if (strcmp(argv[i], "--stdin") == 0
+-              || strcmp(argv[i], "-ilas") == 0) 
+-        {
+-            use_stdin = TRUE;
+-        }
+-        else if (strcmp(argv[i], "--repair") == 0
+-              || strcmp(argv[i], "-r") == 0
+-              || strcmp(argv[i], "-repair_header") == 0
+-              || strcmp(argv[i], "-repair") == 0) 
+-        {
+-            repair_header = TRUE;
+-            check_points = TRUE;
+-        }
+-        else if (strcmp(argv[i], "--repair_bb") == 0
+-              || strcmp(argv[i], "--repair_bounding_box") == 0
+-              || strcmp(argv[i], "--repair_boundingbox") == 0
+-              || strcmp(argv[i], "-repair_bb") == 0
+-              || strcmp(argv[i], "-repair_bounding_box") == 0
+-              || strcmp(argv[i], "-repair_boundingbox") == 0
+-              || strcmp(argv[i], "-repair") == 0
+-              || strcmp(argv[i], "-rb") == 0) 
+-        {
+-            repair_bounding_box = TRUE;
+-            check_points = TRUE;
+-        }
+-
+-        else if (strcmp(argv[i],"--system_identifier") == 0
+-              || strcmp(argv[i],"-system_identifier") == 0
+-              || strcmp(argv[i],"-s") == 0
+-              || strcmp(argv[i],"-sys_id") == 0)
+-        {
+-            i++;
+-            system_identifier = (char*) malloc(31 * sizeof(char));
+-            strcpy(system_identifier, argv[i]);
+-            change_header = TRUE;
+-        }
+-
+-        else if (strcmp(argv[i],"--generating_software") == 0
+-              || strcmp(argv[i],"-generating_software") == 0
+-              || strcmp(argv[i],"-g") == 0
+-              || strcmp(argv[i],"-gen_soft") == 0)
+-        {
+-            i++;
+-            generating_software = (char*) malloc(31*sizeof(char));
+-            strcpy(generating_software, argv[i]);
+-            change_header = TRUE;
+-        }
+-        else if (strcmp(argv[i],"--file_creation") == 0
+-              || strcmp(argv[i],"-file_creation") == 0)
+-        {
+-            /* XXX - mloskot: Consider replacing atoi with strtol,
+-            see http://www.iso-9899.info/wiki/Converting */
+-            i++;
+-            file_creation_day = (unsigned char)atoi(argv[i]);
+-            i++;
+-            file_creation_year = (unsigned char)atoi(argv[i]);
+-            change_header = TRUE;
+-        }
+-        else if (strcmp(argv[i],"--skip_vlr") == 0 || strcmp(argv[i],"--no_vlr") == 0)
+-        {
+-            skip_vlr = TRUE;
+-        }
+-        else if (strcmp(argv[i],"--wkt") == 0)
+-        {
+-            wkt = TRUE;
+-        }    
+-        else if (file_name == NULL)
+-        {
+-            file_name = argv[i];
+-        } 
+-        else
+-        {
+-            usage();
+-            fprintf(stderr, "ERROR: unknown argument '%s'\n",argv[i]);
+-            exit(1);
+-        }
+-    }
+-
+-    if (use_stdin) {
+-        file_name = "stdin";
+-    }
+-
+-    if (!file_name) {
+-        LASError_Print("No filename was provided to be opened");
+-        usage();
+-        exit(1);
+-    }
+-
+-    reader = LASReader_Create(file_name);
+-    if (!reader) { 
+-        LASError_Print("Could not open file ");
+-        exit(1);
+-    } 
+-
+-    header = LASReader_GetHeader(reader);
+-    if (!header) { 
+-        LASError_Print("Could not get LASHeader ");
+-        exit(1);
+-    } 
+-
+-    print_header(stdout, header, file_name, skip_vlr, wkt);
+-
+-    if (change_header) {
+-        if (system_identifier) {
+-            err = LASHeader_SetSystemId (header, system_identifier);
+-            if (err) LASError_Print("Could not set SystemId");
+-        }
+-        if (generating_software) {
+-            err = LASHeader_SetSoftwareId(header, generating_software);
+-            if (err) LASError_Print("Could not set SoftwareId");
+-        }
+-        if ( file_creation_day || file_creation_year) {
+-            err = LASHeader_SetCreationDOY(header, file_creation_day);
+-            if (err) LASError_Print("Could not set file creation day");
+-            err = LASHeader_SetCreationYear(header, file_creation_year);
+-            if (err) LASError_Print("Could not set file creation year");
+-        }
+-
+-        /* We need to wipe out the reader and make a writer. */
+-        if (reader) {
+-            LASReader_Destroy(reader);
+-            reader = NULL;
+-        }
+-
+-        writer = LASWriter_Create(file_name, header, LAS_MODE_APPEND);
+-        if (!writer) {
+-            LASError_Print("Problem creating LASWriterH object");
+-            LASHeader_Destroy(header);
+-            header = NULL;
+-            exit(1);
+-        }
+-
+-        if (writer) LASWriter_Destroy(writer);
+-        writer = NULL;
+-        if (header) LASHeader_Destroy(header);
+-        header = NULL;
+-    }
+-
+-    if (check_points)
+-    {
+-        if (!reader) {
+-            reader = LASReader_Create(file_name);
+-            if (!reader) { 
+-                LASError_Print("Could not open file ");
+-                exit(1);
+-            } 
+-        }
+-
+-        if (! header) {
+-            header = LASReader_GetHeader(reader);
+-            if (!header) { 
+-                LASError_Print("Could not get LASHeader ");
+-                exit(1);
+-            } 
+-        } 
+-
+-        if (!summary)
+-            summary = SummarizePoints(reader);
+-        print_point_summary(stdout, summary, header);
+-
+-        if (repair_header) {
+-            fprintf(stdout, "\n---------------------------------------------------------\n");
+-            fprintf(stdout, "  Repair Summary\n");
+-            fprintf(stdout, "---------------------------------------------------------\n");
+-
+-            if (use_stdin) {
+-                LASError_Print("Cannot update header information on piped input!");
+-                exit(1);
+-            }
+-
+-            if (! header) {
+-                header = LASReader_GetHeader(reader);
+-                if (!header) { 
+-                    LASError_Print("Could not get LASHeader ");
+-                    exit(1);
+-                }
+-            } 
+-
+-            if (! repair_bounding_box) {
+-                if ( LASHeader_GetMinX(header) != LASPoint_GetX(summary->pmin) )
+-                    repair_bounding_box = TRUE;
+-                if ( LASHeader_GetMinY(header) != LASPoint_GetY(summary->pmin) )
+-                    repair_bounding_box = TRUE;
+-                if ( LASHeader_GetMinZ(header) != LASPoint_GetZ(summary->pmin) )
+-                    repair_bounding_box = TRUE;
+-
+-                if ( LASHeader_GetMaxX(header) != LASPoint_GetX(summary->pmax) )
+-                    repair_bounding_box = TRUE;
+-                if ( LASHeader_GetMaxY(header) != LASPoint_GetY(summary->pmax) )
+-                    repair_bounding_box = TRUE;
+-                if ( LASHeader_GetMaxZ(header) != LASPoint_GetZ(summary->pmax) )
+-                    repair_bounding_box = TRUE;
+-            }
+-
+-            if (repair_bounding_box) {
+-                fprintf(stdout, "  Reparing Bounding Box...\n");
+-                err = LASHeader_SetMin( header, 
+-                    LASPoint_GetX(summary->pmin), 
+-                    LASPoint_GetY(summary->pmin), 
+-                    LASPoint_GetZ(summary->pmin)
+-                    );
+-                if (err) {
+-                    LASError_Print("Could not set minimum for header ");
+-                    exit(1);
+-                }
+-                err = LASHeader_SetMax( header, 
+-                    LASPoint_GetX(summary->pmax), 
+-                    LASPoint_GetY(summary->pmax), 
+-                    LASPoint_GetZ(summary->pmax)
+-                    );
+-                if (err) {
+-                    LASError_Print("Could not set minimum for header ");
+-                    exit(1);
+-                }
+-            }
+-
+-            for (i = 0; i < 5; i++) {
+-
+-                if (LASHeader_GetPointRecordsByReturnCount(header, i) != 
+-                    summary->number_of_points_by_return[i]) 
+-                {
+-                    update_return_counts = TRUE;
+-                    break;
+-                }
+-            }
+-
+-            if (update_return_counts) {
+-                fprintf(stdout, "  Reparing Point Count by Return...\n");
+-                for (i = 0; i < 5; i++) {
+-                    LASHeader_SetPointRecordsByReturnCount( header,  
+-                        i, 
+-                        summary->number_of_points_by_return[i]);
+-                }                
+-            }
+-
+-            if (reader) {
+-                LASReader_Destroy(reader);
+-                reader = NULL;
+-            }
+-
+-            writer = LASWriter_Create(file_name, header, LAS_MODE_APPEND);
+-            if (!writer) {
+-                LASError_Print("Problem creating LASWriterH object for append");
+-                LASHeader_Destroy(header);
+-                header = NULL;
+-                exit(1);
+-            }
+-            LASWriter_Destroy(writer);
+-            writer = NULL;
+-            LASHeader_Destroy(header);
+-            header = NULL;            
+-        }
+-
+-        if (summary) {
+-            LASPoint_Destroy(summary->pmin);
+-            LASPoint_Destroy(summary->pmax);
+-            free(summary);
+-
+-        }
+-    }   
+-
+-    if (reader) LASReader_Destroy(reader);
+-    if (header) LASHeader_Destroy(header);
+-
+-#ifdef HAVE_GDAL
+-    /* Various GDAL related cleanups */
+-#ifdef OSRCleanup
+-    OSRCleanup();
+-#endif
+-    CPLFinderClean();
+-    CPLFreeConfig();
+-    CPLCleanupTLS();
+-#endif
+-
+-    return 0;
+-}
+--- a/apps/lasmerge.c
++++ /dev/null
+@@ -1,507 +0,0 @@
+-/***************************************************************************
+- * $Id$
+- * $Date$
+- *
+- * Project: libLAS -- C/C++ read/write library for LAS LIDAR data
+- * Purpose: LAS file merging
+- * Author:  Martin Isenburg isenburg at cs.unc.edu 
+- ***************************************************************************
+- * Copyright (c) 2007, Martin Isenburg isenburg at cs.unc.edu 
+- *
+- * See LICENSE.txt in this source distribution for more information.
+- **************************************************************************/
+-
+-
+-#include <time.h>
+-#include <stdio.h>
+-#include <stdlib.h>
+-#include <string.h>
+-
+-#include "liblas.h"
+-#include "lascommon.h"
+-
+-LASPointSummary* SummarizePoints(LASReaderH reader);
+-void print_point_summary(FILE *file, LASPointSummary* summary, LASHeaderH header);
+-void print_header(FILE *file, LASHeaderH header, const char* file_name, int bSkipVLR);
+-
+-void usage()
+-{
+-
+-    fprintf(stderr,"----------------------------------------------------------\n");
+-    fprintf(stderr,"    lasmerge (version %s) usage:\n", LAS_GetFullVersion());
+-    fprintf(stderr,"----------------------------------------------------------\n");
+-    fprintf(stderr,"\n");
+-
+-    fprintf(stderr,"Merge using a list of files:\n");
+-    fprintf(stderr,"  lasmerge -i lasfiles.txt -o out.las\n");
+-    fprintf(stderr,"\n");
+-
+-    fprintf(stderr,"Manually list files to merge:\n");
+-    fprintf(stderr,"  lasmerge -i file1.las -i file2.las -i file3.las -o out.las\n");
+-    fprintf(stderr,"\n");
+-
+-    fprintf(stderr,"Merge to stdout:\n");
+-    fprintf(stderr,"  lasmerge -i file1.las -i file2.las --stdout\n");
+-    fprintf(stderr,"\n");
+-
+-    fprintf(stderr,"Merge and set scale:\n");
+-    fprintf(stderr, "  lasmerge --input lasfiles.txt --scale 0.01 --output out.las\n");
+-    fprintf(stderr,"\n");
+-
+-    fprintf(stderr,"Merge and set scale individually:\n");
+-    fprintf(stderr, "  lasmerge --input lasfiles.txt --xyz_scale 0.01 0.01 0.1 --output out.las\n");
+-    fprintf(stderr,"\n");
+-
+-    fprintf(stderr,"Merge and set offset individually:\n");
+-    fprintf(stderr, "  lasmerge --input lasfiles.txt --xyz_offset 0.01 0.01 0.1 --output out.las\n");
+-    fprintf(stderr,"\n");
+-
+-    fprintf(stderr,"Print this output:\n");
+-    fprintf(stderr, "  lasmerge --help\n");
+-    fprintf(stderr,"\n");
+-    
+-    fprintf(stderr, "For more information, see the full documentation for lasmerge at:\n"
+-                    " http://liblas.org/utilities/lasmerge.html\n");
+-    fprintf(stderr,"----------------------------------------------------------\n");
+-
+-}
+-
+-void ptime(const char *const msg)
+-{
+-    float t= ((float)clock())/CLOCKS_PER_SEC;
+-    fprintf(stderr, "cumulative CPU time thru %s = %f\n", msg, t);
+-}
+-
+-int main(int argc, char *argv[])
+-{
+-    int i;
+-    int verbose = FALSE;
+-    int skip_vlr = FALSE;
+-    int num_file_name_in = 0;
+-    int alloced_file_name_in = 32;
+-    char** file_names_in = (char**)malloc(sizeof(char*)*alloced_file_name_in);
+-    char* file_name_out = 0;
+-    int use_stdout = FALSE;
+-    double xyz_scale[3] = {0.0, 0.0, 0.0};
+-    double xyz_offset[3] = {0.0, 0.0, 0.0};
+-
+-    double minx, miny, maxx, maxy, minz, maxz;
+-    double x_scale_factor, y_scale_factor, z_scale_factor;
+-
+-  
+-    LASHeaderH merged_header=NULL;
+-    LASHeaderH header = NULL;
+-    LASReaderH reader = NULL;
+-    LASWriterH writer = NULL;
+-    LASPointH p = NULL;
+-  
+-    FILE* file = NULL;
+-
+-    int smallest_int = (1<<31)+10;
+-    int largest_int = smallest_int-1-20;
+-
+-    int same = TRUE;
+-    LASPointSummary* summary = NULL;
+-
+-    for (i = 1; i < argc; i++)
+-    {
+-        if (    strcmp(argv[i],"-h") == 0 ||
+-                strcmp(argv[i],"--help") == 0
+-            )
+-        {
+-            usage();
+-            exit(0);
+-        }
+-        else if (   strcmp(argv[i],"-v") == 0 ||
+-                    strcmp(argv[i],"--verbose") == 0
+-            )
+-        {
+-            verbose = TRUE;
+-        }        
+-        else if (   strcmp(argv[i],"--input") == 0  ||
+-                    strcmp(argv[i],"-input") == 0   ||
+-                    strcmp(argv[i],"-i") == 0       ||
+-                    strcmp(argv[i],"-in") == 0
+-                )
+-        {
+-            i++;
+-            if (num_file_name_in == alloced_file_name_in)
+-            {
+-                alloced_file_name_in *= 2;
+-                file_names_in = (char**)realloc(file_names_in,sizeof(char*)*alloced_file_name_in);
+-            }
+-            file_names_in[num_file_name_in] = argv[i];
+-            num_file_name_in++;
+-        }
+-        else if (   strcmp(argv[i],"--output") == 0  ||
+-                    strcmp(argv[i],"--out") == 0     ||
+-                    strcmp(argv[i],"-out") == 0     ||
+-                    strcmp(argv[i],"-o") == 0       
+-                )
+-        {
+-            i++;
+-            file_name_out = argv[i];
+-        }
+-        else if (   strcmp(argv[i],"--scale") == 0  ||
+-                    strcmp(argv[i],"-scale") == 0     ||
+-                    strcmp(argv[i],"-s") == 0       
+-                )
+-        {
+-
+-            i++;
+-            sscanf(argv[i], "%lf", &(xyz_scale[2]));
+-            xyz_scale[0] = xyz_scale[1] = xyz_scale[2];
+-        }
+-        else if (   strcmp(argv[i],"--xyz_scale") == 0  ||
+-                    strcmp(argv[i],"-xyz_scale") == 0    
+-                )
+-
+-        {
+-            i++;
+-            sscanf(argv[i], "%lf", &(xyz_scale[0]));
+-            i++;
+-            sscanf(argv[i], "%lf", &(xyz_scale[1]));
+-            i++;
+-            sscanf(argv[i], "%lf", &(xyz_scale[2]));
+-        }
+-        else if (   strcmp(argv[i],"--xyz_offset") == 0  ||
+-                    strcmp(argv[i],"-xyz_offset") == 0    
+-                )
+-        {
+-            i++;
+-            sscanf(argv[i], "%lf", &(xyz_offset[0]));
+-            i++;
+-            sscanf(argv[i], "%lf", &(xyz_offset[1]));
+-            i++;
+-            sscanf(argv[i], "%lf", &(xyz_offset[2]));
+-        }
+-        else if (   strcmp(argv[i],"--stdout") == 0  ||
+-                    strcmp(argv[i],"-olas") == 0    
+-                )
+-        {
+-            use_stdout = TRUE;
+-            file_name_out = "stdout";
+-        }
+-        else if (   strcmp(argv[i],"--skip_vlr") == 0   ||
+-                    strcmp(argv[i],"--no_vlr") == 0)
+-        {
+-            skip_vlr = TRUE;
+-        } 
+-        else if (i == argc - 2 && num_file_name_in == 0 && file_name_out == 0)
+-        {
+-            file_names_in[0] = argv[i];
+-            num_file_name_in = 1;
+-        }
+-        else if (i == argc - 1 && num_file_name_in == 0 && file_name_out == 0)
+-        {
+-            file_names_in[0] = argv[i];
+-            num_file_name_in = 1;
+-        }
+-        else if (i == argc - 1 && num_file_name_in != 0 && file_name_out == 0)
+-        {
+-            file_name_out = argv[i];
+-        }
+-        else 
+-        {
+-            fprintf(stderr, "ERROR: unknown argument '%s'\n",argv[i]);
+-            usage();
+-            exit(1);
+-        }
+-    }
+-
+-    if (num_file_name_in == 0)
+-    {
+-        fprintf(stderr, "ERROR: no input specified\n");
+-        usage();
+-        exit(1);
+-    }
+-
+-    if (    num_file_name_in == 1 && 
+-            strstr(file_names_in[0],".las") == 0 && 
+-            strstr(file_names_in[0],".LAS") == 0
+-       )
+-    {
+-        char line[512];
+-
+-        num_file_name_in = 0;
+-        file = fopen(file_names_in[0], "r");
+-        while (fgets(line, sizeof(char) * 512, file))
+-            {
+-                if (strstr(line,".las") || strstr(line,".LAS") )
+-                {
+-                    if (num_file_name_in == alloced_file_name_in)
+-                    {
+-                        alloced_file_name_in *= 2;
+-                        file_names_in = (char**)realloc(file_names_in,sizeof(char*)*alloced_file_name_in);
+-                    }
+-                    file_names_in[num_file_name_in] = LASCopyString(line);
+-                    i = (int)strlen(file_names_in[num_file_name_in]) - 1;
+-                    while ( i && 
+-                            file_names_in[num_file_name_in][i] != 's' && 
+-                            file_names_in[num_file_name_in][i] != 'S' && 
+-                            file_names_in[num_file_name_in][i] != 'z' && 
+-                            file_names_in[num_file_name_in][i] != 'Z') 
+-                    i--;
+-                    if (i)
+-                    {
+-                        file_names_in[num_file_name_in][i+1] = '\0';
+-                        num_file_name_in++;
+-                    }
+-                    else
+-                    {
+-                        fprintf(stderr, "WARNING: cannot parse line '%s'\n",line);
+-                    }
+-                }
+-                else
+-                {
+-                    fprintf(stderr, "WARNING: no a valid LAS file name '%s'\n",line);
+-                }
+-            }
+-    }
+-
+-
+-    if (verbose) ptime("starting first pass.");
+-    fprintf(stderr, "first pass ... reading headers of %d LAS files...\n", num_file_name_in);
+-
+-    for (i = 0; i < num_file_name_in; i++)
+-    {
+-        reader = LASReader_Create(file_names_in[i]);
+-        if (!reader) { 
+-                LASError_Print("Could not get LASReader "); 
+-                exit(1);
+-            } 
+-      
+-            header = LASReader_GetHeader(reader);
+-            if (!header) { 
+-                LASError_Print("Could not get LASHeader "); 
+-                exit(1);
+-            } 
+-
+-
+-        if (i == 0)
+-        {
+-            merged_header = LASReader_GetHeader(reader);
+-        }
+-        else
+-        {
+-            LASHeader_SetPointRecordsCount( merged_header, 
+-                                            LASHeader_GetPointRecordsCount(merged_header) + 
+-                                            LASHeader_GetPointRecordsCount(header));
+-            LASHeader_SetPointRecordsByReturnCount( merged_header, 
+-                                                    0, 
+-                                                    LASHeader_GetPointRecordsByReturnCount(merged_header,0) + 
+-                                                    LASHeader_GetPointRecordsByReturnCount(header,0));
+-            LASHeader_SetPointRecordsByReturnCount( merged_header, 
+-                                                    1, 
+-                                                    LASHeader_GetPointRecordsByReturnCount(merged_header,1) + 
+-                                                    LASHeader_GetPointRecordsByReturnCount(header,1));
+-            LASHeader_SetPointRecordsByReturnCount( merged_header, 
+-                                                    2, 
+-                                                    LASHeader_GetPointRecordsByReturnCount(merged_header,2) + 
+-                                                    LASHeader_GetPointRecordsByReturnCount(header,2));
+-            LASHeader_SetPointRecordsByReturnCount( merged_header, 
+-                                                    3, 
+-                                                    LASHeader_GetPointRecordsByReturnCount(merged_header,3) + 
+-                                                    LASHeader_GetPointRecordsByReturnCount(header,3));
+-            LASHeader_SetPointRecordsByReturnCount( merged_header, 
+-                                                    4, 
+-                                                    LASHeader_GetPointRecordsByReturnCount(merged_header,4) + 
+-                                                    LASHeader_GetPointRecordsByReturnCount(header,4));
+-
+-            LASHeader_SetSystemId(merged_header, "MERGED");
+-
+-            minx = LASHeader_GetMinX(merged_header);
+-            maxx = LASHeader_GetMaxX(merged_header);
+-            miny = LASHeader_GetMinY(merged_header);
+-            maxy = LASHeader_GetMaxY(merged_header);
+-            minz = LASHeader_GetMinZ(merged_header);
+-            maxz = LASHeader_GetMaxZ(merged_header);
+-        
+-            if (minx > LASHeader_GetMinX(header)) minx = LASHeader_GetMinX(header);
+-            if (maxx < LASHeader_GetMaxX(header)) maxx = LASHeader_GetMaxX(header);
+-            if (miny > LASHeader_GetMinY(header)) miny = LASHeader_GetMinY(header);
+-            if (maxy < LASHeader_GetMaxY(header)) maxy = LASHeader_GetMaxY(header);
+-            if (minz > LASHeader_GetMinZ(header)) minz = LASHeader_GetMinZ(header);
+-            if (maxz < LASHeader_GetMaxZ(header)) maxz = LASHeader_GetMaxZ(header);
+-        
+-            LASHeader_SetMin(merged_header, minx, miny, minz);
+-            LASHeader_SetMax(merged_header, maxx, maxy, maxz);
+-        }
+-        
+-        LASHeader_Destroy(header);
+-        LASReader_Destroy(reader);
+-    }
+-
+-    if (verbose)
+-    {
+-        fprintf(stderr, "  number_of_point_records %d\n", 
+-                LASHeader_GetPointRecordsCount(merged_header));
+-        fprintf(stderr, "  number of points by return %d %d %d %d %d\n", 
+-                        LASHeader_GetPointRecordsByReturnCount(merged_header, 0),
+-                        LASHeader_GetPointRecordsByReturnCount(merged_header, 1), 
+-                        LASHeader_GetPointRecordsByReturnCount(merged_header, 2), 
+-                        LASHeader_GetPointRecordsByReturnCount(merged_header, 3), 
+-                        LASHeader_GetPointRecordsByReturnCount(merged_header, 4));
+-        fprintf(stderr, "  min x y z                  %.6f %.6f %.6f\n", 
+-                        LASHeader_GetMinX(merged_header), 
+-                        LASHeader_GetMinY(merged_header), 
+-                        LASHeader_GetMinZ(merged_header));
+-        fprintf(stderr, "  max x y z                  %.6f %.6f %.6f\n", 
+-                        LASHeader_GetMaxX(merged_header), 
+-                        LASHeader_GetMaxY(merged_header), 
+-                        LASHeader_GetMaxZ(merged_header));
+-    }
+-
+-    LASHeader_SetScale( merged_header, 
+-                        xyz_scale[0], 
+-                        xyz_scale[1], 
+-                        xyz_scale[2]);
+-
+-    LASHeader_SetOffset(merged_header, 
+-                        xyz_offset[0], 
+-                        xyz_offset[1], 
+-                        xyz_offset[2] );
+-
+-    x_scale_factor = LASHeader_GetScaleX(merged_header);
+-    if (((LASHeader_GetMaxX(merged_header) - LASHeader_GetOffsetX(merged_header)) / LASHeader_GetScaleX(merged_header)) > largest_int ||
+-        ((LASHeader_GetMinX(merged_header) - LASHeader_GetOffsetX(merged_header)) / LASHeader_GetScaleX(merged_header)) < smallest_int )
+-    {
+-        x_scale_factor = 0.0000001;
+-        while (((LASHeader_GetMaxX(merged_header) - LASHeader_GetOffsetX(merged_header)) / x_scale_factor) > largest_int ||
+-            ((LASHeader_GetMinX(merged_header) - LASHeader_GetOffsetX(merged_header)) / x_scale_factor) < smallest_int )
+-        {
+-            x_scale_factor *= 10;
+-        }
+-        fprintf(stderr, "x_scale_factor of merged_header changed to %g\n", x_scale_factor);
+-    }
+-
+-    y_scale_factor = LASHeader_GetScaleY(merged_header);
+-    if (((LASHeader_GetMaxY(merged_header) - LASHeader_GetOffsetY(merged_header)) / y_scale_factor) > largest_int ||
+-        ((LASHeader_GetMinY(merged_header) - LASHeader_GetOffsetY(merged_header)) / y_scale_factor) < smallest_int )
+-    {
+-        y_scale_factor = 0.0000001;
+-        while (((LASHeader_GetMaxY(merged_header) - LASHeader_GetOffsetY(merged_header)) / y_scale_factor) > largest_int ||
+-            ((LASHeader_GetMinY(merged_header) - LASHeader_GetOffsetY(merged_header)) / y_scale_factor) < smallest_int )
+-        {
+-            y_scale_factor *= 10;
+-        }
+-        fprintf(stderr, "y_scale_factor of merged_header changed to %g\n", y_scale_factor);
+-    }
+-  
+-    z_scale_factor = LASHeader_GetScaleZ(merged_header);
+-    if (((LASHeader_GetMaxZ(merged_header) - LASHeader_GetOffsetZ(merged_header)) / z_scale_factor) > largest_int ||
+-        ((LASHeader_GetMinZ(merged_header) - LASHeader_GetOffsetZ(merged_header)) / z_scale_factor) < smallest_int )
+-    {
+-        z_scale_factor = 0.0000001;
+-        while (((LASHeader_GetMaxZ(merged_header) - LASHeader_GetOffsetZ(merged_header)) / z_scale_factor) > largest_int ||
+-            ((LASHeader_GetMinZ(merged_header) - LASHeader_GetOffsetZ(merged_header)) / z_scale_factor) < smallest_int )\
+-        {
+-            z_scale_factor *= 10;
+-        }
+-        fprintf(stderr, "z_scale_factor of merged_header changed to %g\n", z_scale_factor);
+-    }
+-  
+-    LASHeader_SetScale( merged_header, 
+-                        x_scale_factor, 
+-                        y_scale_factor, 
+-                        z_scale_factor);
+-
+-    if (file_name_out == NULL && !use_stdout)
+-    {
+-        LASError_Print("no output was specified "); 
+-        exit(1);
+-    }
+-
+-    writer = LASWriter_Create(file_name_out, merged_header, LAS_MODE_WRITE);
+-    if (!writer) { 
+-        LASError_Print("Could not create LASWriter "); 
+-        exit(1);
+-    } 
+-
+-    if (verbose) ptime("starting second pass.");
+-    fprintf(stderr, "second pass ... merge %d LAS files into one ...\n", num_file_name_in);
+-
+-    for (i = 0; i < num_file_name_in; i++)
+-    {
+-        reader = LASReader_Create(file_names_in[i]);
+-        if (!reader) { 
+-            LASError_Print("Could not get LASReader ");
+-            exit(1);
+-        } 
+-        header = LASReader_GetHeader(reader);
+-        if (!header) { 
+-            LASError_Print("Could not get LASHeader ");
+-            exit(1);
+-        } 
+-
+-        same = TRUE;
+-        if (LASHeader_GetOffsetX(merged_header) != LASHeader_GetOffsetX(header)) same = FALSE;
+-        if (LASHeader_GetOffsetY(merged_header) != LASHeader_GetOffsetY(header)) same = FALSE;
+-        if (LASHeader_GetOffsetZ(merged_header) != LASHeader_GetOffsetZ(header)) same = FALSE;
+-
+-        if (LASHeader_GetScaleX(merged_header) != LASHeader_GetScaleX(header)) same = FALSE;
+-        if (LASHeader_GetScaleY(merged_header) != LASHeader_GetScaleY(header)) same = FALSE;
+-        if (LASHeader_GetScaleZ(merged_header) != LASHeader_GetScaleZ(header)) same = FALSE;
+-    
+-
+-        if (same)
+-        {
+-            p = LASReader_GetNextPoint(reader);
+-            while (p)
+-            {
+-                LASWriter_WritePoint(writer, p);
+-                p = LASReader_GetNextPoint(reader);
+-            }
+-        }
+-        else
+-        {
+-            p = LASReader_GetNextPoint(reader);
+-            while (p)
+-            {
+-                LASPoint_SetX(p,(0.5 + (LASPoint_GetX(p) - LASHeader_GetOffsetX(merged_header)) / LASHeader_GetScaleX(merged_header)));
+-                LASPoint_SetY(p,(0.5 + (LASPoint_GetY(p) - LASHeader_GetOffsetY(merged_header)) / LASHeader_GetScaleY(merged_header)));
+-                LASPoint_SetZ(p,(0.5 + (LASPoint_GetZ(p) - LASHeader_GetOffsetZ(merged_header)) / LASHeader_GetScaleZ(merged_header)));
+-                LASWriter_WritePoint(writer, p);
+-                p = LASReader_GetNextPoint(reader);
+-            }
+-        }
+-
+-        LASHeader_Destroy(header);
+-        LASReader_Destroy(reader);
+-        reader = NULL;
+-    }
+-    
+-    LASHeader_Destroy(merged_header);
+-    LASWriter_Destroy(writer);
+-
+-    if (verbose) ptime("done.");
+-
+-    if (verbose) {
+-        reader = LASReader_Create(file_name_out);
+-        if (!reader) { 
+-            LASError_Print("Could not open file ");
+-            exit(1);
+-        } 
+-      
+-        header = LASReader_GetHeader(reader);
+-        if (!header) { 
+-            LASError_Print("Could not get LASHeader ");
+-            exit(1);
+-        } 
+-
+-        print_header(stderr, header, file_name_out, skip_vlr);        
+-        summary = SummarizePoints(reader);
+-        print_point_summary(stderr, summary, header);
+-        
+-        LASHeader_Destroy(header);
+-        header = NULL;            
+-        LASReader_Destroy(reader);
+-        reader = NULL;
+-        
+-        LASPoint_Destroy(summary->pmin);
+-        LASPoint_Destroy(summary->pmax);
+-        free(summary);
+-    }
+-    
+-    return 0;
+-}
diff --git a/debian/patches/series b/debian/patches/series
index f58753b..adda01a 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -2,3 +2,4 @@ boost
 soversion
 fix_library_search
 separator-typo
+0001-remove-old-LAStools-utilities-that-don-t-belong-in-liblas.patch

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



More information about the Pkg-grass-devel mailing list