From 91106948b0dda1b3e304927f8f5bca6bc3fac3e2 Mon Sep 17 00:00:00 2001 From: Jean-Romain Date: Mon, 15 Feb 2021 17:05:49 -0500 Subject: [PATCH 01/20] Update LASLib --- inst/include/LICENSE.txt | 96 - inst/include/README.txt | 19 - inst/include/lasunzipper.hpp | 77 - inst/include/laszipper.hpp | 77 - src/LASlib/.gitignore | 6 + src/LASlib/LICENSE.txt | 96 - src/LASlib/README.txt | 19 - src/LASlib/fopen_compressed.cpp | 77 +- .../include => src/LASlib}/lasdefinitions.hpp | 84 +- src/LASlib/lasfilter.cpp | 1230 ++-- {inst/include => src/LASlib}/lasfilter.hpp | 0 src/LASlib/lasignore.cpp | 402 ++ src/LASlib/lasignore.hpp | 75 + src/LASlib/laskdtree.cpp | 357 ++ src/LASlib/laskdtree.hpp | 98 + src/LASlib/laslib-config.cmake | 6 + src/LASlib/lasreader.cpp | 1686 ++++-- {inst/include => src/LASlib}/lasreader.hpp | 78 +- src/LASlib/lasreader_asc.cpp | 148 +- .../include => src/LASlib}/lasreader_asc.hpp | 7 +- src/LASlib/lasreader_bil.cpp | 198 +- .../include => src/LASlib}/lasreader_bil.hpp | 7 +- src/LASlib/lasreader_bin.cpp | 24 +- .../include => src/LASlib}/lasreader_bin.hpp | 0 src/LASlib/lasreader_dtm.cpp | 172 +- .../include => src/LASlib}/lasreader_dtm.hpp | 7 +- src/LASlib/lasreader_las.cpp | 380 +- .../include => src/LASlib}/lasreader_las.hpp | 1 + src/LASlib/lasreader_ply.cpp | 272 +- .../include => src/LASlib}/lasreader_ply.hpp | 1 + src/LASlib/lasreader_qfit.cpp | 28 +- .../include => src/LASlib}/lasreader_qfit.hpp | 0 src/LASlib/lasreader_shp.cpp | 62 +- .../include => src/LASlib}/lasreader_shp.hpp | 0 src/LASlib/lasreader_txt.cpp | 358 +- .../include => src/LASlib}/lasreader_txt.hpp | 0 src/LASlib/lasreaderbuffered.cpp | 32 +- .../LASlib}/lasreaderbuffered.hpp | 0 src/LASlib/lasreadermerged.cpp | 279 +- .../LASlib}/lasreadermerged.hpp | 5 +- src/LASlib/lasreaderpipeon.cpp | 30 +- .../LASlib}/lasreaderpipeon.hpp | 0 src/LASlib/lasreaderstored.cpp | 18 +- .../LASlib}/lasreaderstored.hpp | 0 src/LASlib/lastransform.cpp | 4061 +++++++++++--- {inst/include => src/LASlib}/lastransform.hpp | 26 +- src/LASlib/lasutility.cpp | 202 +- {inst/include => src/LASlib}/lasutility.hpp | 27 +- src/LASlib/lasvlr.cpp | 41 + src/LASlib/lasvlr.hpp | 76 + src/LASlib/lasvlrpayload.hpp | 275 + src/LASlib/laswaveform13reader.cpp | 40 +- .../LASlib}/laswaveform13reader.hpp | 2 +- src/LASlib/laswaveform13writer.cpp | 38 +- .../LASlib}/laswaveform13writer.hpp | 2 +- src/LASlib/laswriter.cpp | 101 +- {inst/include => src/LASlib}/laswriter.hpp | 2 + src/LASlib/laswriter_bin.cpp | 40 +- .../include => src/LASlib}/laswriter_bin.hpp | 0 src/LASlib/laswriter_las.cpp | 323 +- .../include => src/LASlib}/laswriter_las.hpp | 0 src/LASlib/laswriter_qfit.cpp | 28 +- .../include => src/LASlib}/laswriter_qfit.hpp | 0 src/LASlib/laswriter_txt.cpp | 102 +- .../include => src/LASlib}/laswriter_txt.hpp | 0 src/LASlib/laswriter_wrl.cpp | 8 +- .../include => src/LASlib}/laswriter_wrl.hpp | 0 src/LASlib/laswritercompatible.cpp | 36 +- .../LASlib}/laswritercompatible.hpp | 4 +- src/LASzip/LICENSE.txt | 96 - src/LASzip/README.txt | 10 +- .../LASzip}/arithmeticdecoder.hpp | 0 .../LASzip}/arithmeticencoder.hpp | 0 .../LASzip}/arithmeticmodel.hpp | 0 {inst/include => src/LASzip}/bytestreamin.hpp | 0 .../LASzip}/bytestreamin_array.hpp | 0 .../LASzip}/bytestreamin_file.hpp | 0 .../LASzip}/bytestreamin_istream.hpp | 0 .../LASzip}/bytestreaminout.hpp | 0 .../LASzip}/bytestreaminout_file.hpp | 0 .../include => src/LASzip}/bytestreamout.hpp | 0 .../LASzip}/bytestreamout_array.hpp | 0 .../LASzip}/bytestreamout_file.hpp | 12 +- .../LASzip}/bytestreamout_nil.hpp | 0 .../LASzip}/bytestreamout_ostream.hpp | 0 src/LASzip/demzip_dll.cpp | 4949 +++++++++++++++++ src/LASzip/integercompressor.cpp | 4 +- .../LASzip}/integercompressor.hpp | 0 .../include => src/LASzip}/lasattributer.hpp | 25 +- src/LASzip/lasindex.cpp | 122 +- {inst/include => src/LASzip}/lasindex.hpp | 2 +- src/LASzip/lasinterval.cpp | 59 +- {inst/include => src/LASzip}/lasinterval.hpp | 0 {inst/include => src/LASzip}/laspoint.hpp | 77 +- src/LASzip/lasquadtree.cpp | 107 +- {inst/include => src/LASzip}/lasquadtree.hpp | 2 +- {inst/include => src/LASzip}/lasquantizer.hpp | 6 +- {inst/include => src/LASzip}/lasreaditem.hpp | 0 .../LASzip}/lasreaditemcompressed_v1.hpp | 0 .../LASzip}/lasreaditemcompressed_v2.hpp | 0 src/LASzip/lasreaditemcompressed_v3.cpp | 11 +- .../LASzip}/lasreaditemcompressed_v3.hpp | 0 src/LASzip/lasreaditemcompressed_v4.cpp | 11 +- .../LASzip}/lasreaditemcompressed_v4.hpp | 0 .../include => src/LASzip}/lasreaditemraw.hpp | 0 src/LASzip/lasreadpoint.cpp | 52 +- {inst/include => src/LASzip}/lasreadpoint.hpp | 3 +- src/LASzip/lasunzipper.cpp | 139 - {inst/include => src/LASzip}/laswriteitem.hpp | 0 .../LASzip}/laswriteitemcompressed_v1.hpp | 0 .../LASzip}/laswriteitemcompressed_v2.hpp | 0 src/LASzip/laswriteitemcompressed_v3.cpp | 66 +- .../LASzip}/laswriteitemcompressed_v3.hpp | 0 src/LASzip/laswriteitemcompressed_v4.cpp | 64 +- .../LASzip}/laswriteitemcompressed_v4.hpp | 0 .../LASzip}/laswriteitemraw.hpp | 0 .../include => src/LASzip}/laswritepoint.hpp | 0 src/LASzip/laszip.cpp | 7 +- {inst/include => src/LASzip}/laszip.hpp | 7 +- .../LASzip}/laszip_common_v1.hpp | 0 .../LASzip}/laszip_common_v2.hpp | 0 .../LASzip}/laszip_common_v3.hpp | 0 .../laszip_decompress_selective_v3.hpp | 0 src/LASzip/laszipper.cpp | 133 - src/LASzip/mydefs.cpp | 46 + {inst/include => src/LASzip}/mydefs.hpp | 43 +- src/Makevars | 6 +- src/Makevars.win | 6 +- .../rlasextrabytesattributes.h | 0 {inst/include => src}/rlasstreamer.h | 0 130 files changed, 13665 insertions(+), 4346 deletions(-) delete mode 100644 inst/include/LICENSE.txt delete mode 100644 inst/include/README.txt delete mode 100644 inst/include/lasunzipper.hpp delete mode 100644 inst/include/laszipper.hpp create mode 100644 src/LASlib/.gitignore delete mode 100644 src/LASlib/LICENSE.txt delete mode 100644 src/LASlib/README.txt rename {inst/include => src/LASlib}/lasdefinitions.hpp (94%) rename {inst/include => src/LASlib}/lasfilter.hpp (100%) create mode 100644 src/LASlib/lasignore.cpp create mode 100644 src/LASlib/lasignore.hpp create mode 100644 src/LASlib/laskdtree.cpp create mode 100644 src/LASlib/laskdtree.hpp create mode 100644 src/LASlib/laslib-config.cmake rename {inst/include => src/LASlib}/lasreader.hpp (77%) rename {inst/include => src/LASlib}/lasreader_asc.hpp (89%) rename {inst/include => src/LASlib}/lasreader_bil.hpp (89%) rename {inst/include => src/LASlib}/lasreader_bin.hpp (100%) rename {inst/include => src/LASlib}/lasreader_dtm.hpp (88%) rename {inst/include => src/LASlib}/lasreader_las.hpp (99%) rename {inst/include => src/LASlib}/lasreader_ply.hpp (98%) rename {inst/include => src/LASlib}/lasreader_qfit.hpp (100%) rename {inst/include => src/LASlib}/lasreader_shp.hpp (100%) rename {inst/include => src/LASlib}/lasreader_txt.hpp (100%) rename {inst/include => src/LASlib}/lasreaderbuffered.hpp (100%) rename {inst/include => src/LASlib}/lasreadermerged.hpp (94%) rename {inst/include => src/LASlib}/lasreaderpipeon.hpp (100%) rename {inst/include => src/LASlib}/lasreaderstored.hpp (100%) rename {inst/include => src/LASlib}/lastransform.hpp (74%) rename {inst/include => src/LASlib}/lasutility.hpp (90%) create mode 100644 src/LASlib/lasvlr.cpp create mode 100644 src/LASlib/lasvlr.hpp create mode 100644 src/LASlib/lasvlrpayload.hpp rename {inst/include => src/LASlib}/laswaveform13reader.hpp (98%) rename {inst/include => src/LASlib}/laswaveform13writer.hpp (97%) rename {inst/include => src/LASlib}/laswriter.hpp (99%) rename {inst/include => src/LASlib}/laswriter_bin.hpp (100%) rename {inst/include => src/LASlib}/laswriter_las.hpp (100%) rename {inst/include => src/LASlib}/laswriter_qfit.hpp (100%) rename {inst/include => src/LASlib}/laswriter_txt.hpp (100%) rename {inst/include => src/LASlib}/laswriter_wrl.hpp (100%) rename {inst/include => src/LASlib}/laswritercompatible.hpp (95%) delete mode 100644 src/LASzip/LICENSE.txt rename {inst/include => src/LASzip}/arithmeticdecoder.hpp (100%) rename {inst/include => src/LASzip}/arithmeticencoder.hpp (100%) rename {inst/include => src/LASzip}/arithmeticmodel.hpp (100%) rename {inst/include => src/LASzip}/bytestreamin.hpp (100%) rename {inst/include => src/LASzip}/bytestreamin_array.hpp (100%) rename {inst/include => src/LASzip}/bytestreamin_file.hpp (100%) rename {inst/include => src/LASzip}/bytestreamin_istream.hpp (100%) rename {inst/include => src/LASzip}/bytestreaminout.hpp (100%) rename {inst/include => src/LASzip}/bytestreaminout_file.hpp (100%) rename {inst/include => src/LASzip}/bytestreamout.hpp (100%) rename {inst/include => src/LASzip}/bytestreamout_array.hpp (100%) rename {inst/include => src/LASzip}/bytestreamout_file.hpp (99%) rename {inst/include => src/LASzip}/bytestreamout_nil.hpp (100%) rename {inst/include => src/LASzip}/bytestreamout_ostream.hpp (100%) create mode 100644 src/LASzip/demzip_dll.cpp rename {inst/include => src/LASzip}/integercompressor.hpp (100%) rename {inst/include => src/LASzip}/lasattributer.hpp (98%) rename {inst/include => src/LASzip}/lasindex.hpp (99%) rename {inst/include => src/LASzip}/lasinterval.hpp (100%) rename {inst/include => src/LASzip}/laspoint.hpp (93%) rename {inst/include => src/LASzip}/lasquadtree.hpp (99%) rename {inst/include => src/LASzip}/lasquantizer.hpp (81%) rename {inst/include => src/LASzip}/lasreaditem.hpp (100%) rename {inst/include => src/LASzip}/lasreaditemcompressed_v1.hpp (100%) rename {inst/include => src/LASzip}/lasreaditemcompressed_v2.hpp (100%) rename {inst/include => src/LASzip}/lasreaditemcompressed_v3.hpp (100%) rename {inst/include => src/LASzip}/lasreaditemcompressed_v4.hpp (100%) rename {inst/include => src/LASzip}/lasreaditemraw.hpp (100%) rename {inst/include => src/LASzip}/lasreadpoint.hpp (95%) delete mode 100644 src/LASzip/lasunzipper.cpp rename {inst/include => src/LASzip}/laswriteitem.hpp (100%) rename {inst/include => src/LASzip}/laswriteitemcompressed_v1.hpp (100%) rename {inst/include => src/LASzip}/laswriteitemcompressed_v2.hpp (100%) rename {inst/include => src/LASzip}/laswriteitemcompressed_v3.hpp (100%) rename {inst/include => src/LASzip}/laswriteitemcompressed_v4.hpp (100%) rename {inst/include => src/LASzip}/laswriteitemraw.hpp (100%) rename {inst/include => src/LASzip}/laswritepoint.hpp (100%) rename {inst/include => src/LASzip}/laszip.hpp (97%) rename {inst/include => src/LASzip}/laszip_common_v1.hpp (100%) rename {inst/include => src/LASzip}/laszip_common_v2.hpp (100%) rename {inst/include => src/LASzip}/laszip_common_v3.hpp (100%) rename {inst/include => src/LASzip}/laszip_decompress_selective_v3.hpp (100%) delete mode 100644 src/LASzip/laszipper.cpp create mode 100644 src/LASzip/mydefs.cpp rename {inst/include => src/LASzip}/mydefs.hpp (90%) rename {inst/include => src}/rlasextrabytesattributes.h (100%) rename {inst/include => src}/rlasstreamer.h (100%) diff --git a/inst/include/LICENSE.txt b/inst/include/LICENSE.txt deleted file mode 100644 index cadd322..0000000 --- a/inst/include/LICENSE.txt +++ /dev/null @@ -1,96 +0,0 @@ --------------------------------------------------------------------------- - - LICENSE AGREEMENT: - - This software is distributed WITHOUT ANY WARRANTY and without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - --------------------------------------------------------------------------- - - There are TWO parts to LAStools. One part is OPEN source (LGPL 2.1). The - other part is CLOSED source and requires licensing for most commercial - or government use. If you're unsure please email 'martin@rapidlasso.com' - before using LAStools. For education and evaluation purposes you can use - and test LAStools as much as you need to ... (-: - - Personal note: The creator of LAStools and LASzip is currently not able - to attend LiDAR conferences or other scientific meetings in the US over - a somewhat unfortunate, kind of silly, and in many ways absurdly funny - incident involving "laser chickens" and a US Nuclear Weapons Lab. If you - have enough "pull" to rectify this ridiculous situation we would like to - hear from you ... (-; - --------------------------------------------------------------------------- - - This part of LAStools is "free" open-source LGPL (see COPYING.txt). To - purchase a different licensing model contact 'license@rapidlasso.com'. - - * laszip - * lasindex - * lasvalidate - * lasliberate - * lasinfo - * las2las - * lasdiff - * lasmerge - * las2txt & txt2las - * lasprecision - * LASzip (with static linking exception) - * LASlib (with LASzip) - the API used by LAStools. - - These two are also "free" to use but not available in open source. - - * lasview - * laspublish - --------------------------------------------------------------------------- - - The following LAStools require licensing for any commercial, government, - or production use. However, they may be used "freely" for all non-profit - personal, non-military educational, or non-profit humanitarian purposes. - Note that the output of the unlicensed version can be slightly distorted - after certain point limits are exceeded. Control output in the console - (aka "the black window") informs the user whenever this happens. - - * blast2dem - * blast2iso - - * lasground & lasground_new - * lasheight & lastrack - * lasclassify - * lasgrid & lascanopy - * lasboundary - * lascontrol - * lasoverlap - * lasoverage - * lasduplicate - * lassplit - * lasreturn - * las2tin - * las2iso - * las2dem - * lasthin & lasnoise - * lassort - * lastile - * lasplanes - * lascolor - * lasclip - * las2shp & shp2las. - --------------------------------------------------------------------------- - - If you want to use LAStools please contact us for licensing. You can - - (a) license the existing executables for production - (b) license the existing executables for inclusion in your software - - You can also contract with rapidlasso GmbH to create LAStools tailored - to your particular needs. - --------------------------------------------------------------------------- - - COPYRIGHT: - - (c) 2007-2015, rapidlasso GmbH, GERMANY - fast tools to catch reality - --------------------------------------------------------------------------- diff --git a/inst/include/README.txt b/inst/include/README.txt deleted file mode 100644 index 327d4f1..0000000 --- a/inst/include/README.txt +++ /dev/null @@ -1,19 +0,0 @@ - CONTENT: - - This folder contains the source code of LASzip developped by Martin Isenburg - and used in the lidR package. - - PROGRAMMERS: - - martin.isenburg@rapidlasso.com - http://rapidlasso.com - - COPYRIGHT: - - (c) 2003-2012, martin isenburg, rapidlasso - fast tools to catch reality - - This is free software; you can redistribute and/or modify it under the - terms of the GNU Lesser General Licence as published by the Free Software - Foundation. See the LICENSE.txt file for more information. - - This software is distributed WITHOUT ANY WARRANTY and without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. diff --git a/inst/include/lasunzipper.hpp b/inst/include/lasunzipper.hpp deleted file mode 100644 index 29ca04e..0000000 --- a/inst/include/lasunzipper.hpp +++ /dev/null @@ -1,77 +0,0 @@ -/* -=============================================================================== - - FILE: lasunzipper.hpp - - CONTENTS: - - Reads (optionally compressed) LIDAR points to LAS formats 1.0 - 1.3. This - particular class is only used for adding LASzip to libLAS (not to LASlib). - - PROGRAMMERS: - - martin.isenburg@rapidlasso.com - http://rapidlasso.com - - COPYRIGHT: - - (c) 2007-2013, martin isenburg, rapidlasso - fast tools to catch reality - - This is free software; you can redistribute and/or modify it under the - terms of the GNU Lesser General Licence as published by the Free Software - Foundation. See the COPYING file for more information. - - This software is distributed WITHOUT ANY WARRANTY and without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - - CHANGE HISTORY: - - 23 April 2011 -- changed interface for easier future compressor support - 10 January 2011 -- licensing change for LGPL release and liblas integration - 12 December 2010 -- created from LASwriter/LASreader after Howard got pushy (-; - -=============================================================================== -*/ -#ifndef LAS_UNZIPPER_HPP -#define LAS_UNZIPPER_HPP - -#include - -#include "laszip.hpp" - -#ifdef LZ_WIN32_VC6 -#include -#else -#include -#include -using namespace std; -#endif - -class ByteStreamIn; -class LASreadPoint; - -class LASunzipper -{ -public: - bool open(FILE* file, const LASzip* laszip); - bool open(istream& stream, const LASzip* laszip); - - unsigned int tell() const; - bool seek(const unsigned int position); - bool read(unsigned char * const * point); - bool close(); - - LASunzipper(); - ~LASunzipper(); - - // in case a function returns false this string describes the problem - const char* get_error() const; - -private: - unsigned int count; - ByteStreamIn* stream; - LASreadPoint* reader; - bool return_error(const char* err); - char* error_string; -}; - -#endif diff --git a/inst/include/laszipper.hpp b/inst/include/laszipper.hpp deleted file mode 100644 index 3ee3c69..0000000 --- a/inst/include/laszipper.hpp +++ /dev/null @@ -1,77 +0,0 @@ -/* -=============================================================================== - - FILE: laszipper.hpp - - CONTENTS: - - Writes (optionally compressed) LIDAR points to LAS formats 1.0 - 1.3. This - particular class is only used for adding LASzip to libLAS (not to LASlib). - - PROGRAMMERS: - - martin.isenburg@rapidlasso.com - http://rapidlasso.com - - COPYRIGHT: - - (c) 2007-2013, martin isenburg, rapidlasso - fast tools to catch reality - - This is free software; you can redistribute and/or modify it under the - terms of the GNU Lesser General Licence as published by the Free Software - Foundation. See the COPYING file for more information. - - This software is distributed WITHOUT ANY WARRANTY and without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - - CHANGE HISTORY: - - 8 May 2011 -- added an option for variable chunking via chunk() - 23 April 2011 -- changed interface for simplicity and chunking support - 10 January 2011 -- licensing change for LGPL release and liblas integration - 12 December 2010 -- created from LASwriter/LASreader after Howard got pushy (-; - -=============================================================================== -*/ -#ifndef LAS_ZIPPER_HPP -#define LAS_ZIPPER_HPP - -#include - -#include "laszip.hpp" - -#ifdef LZ_WIN32_VC6 -#include -#else -#include -#include -using namespace std; -#endif - -class ByteStreamOut; -class LASwritePoint; - -class LASzipper -{ -public: - bool open(FILE* outfile, const LASzip* laszip); - bool open(ostream& outstream, const LASzip* laszip); - - bool write(const unsigned char* const * point); - bool chunk(); - bool close(); - - LASzipper(); - ~LASzipper(); - - // in case a function returns false this string describes the problem - const char* get_error() const; - -private: - unsigned int count; - ByteStreamOut* stream; - LASwritePoint* writer; - bool return_error(const char* err); - char* error_string; -}; - -#endif diff --git a/src/LASlib/.gitignore b/src/LASlib/.gitignore new file mode 100644 index 0000000..3fcf036 --- /dev/null +++ b/src/LASlib/.gitignore @@ -0,0 +1,6 @@ +Release +Debug +LASlib.ncb +LASlib.opt +LASlib.plg +*~ diff --git a/src/LASlib/LICENSE.txt b/src/LASlib/LICENSE.txt deleted file mode 100644 index cadd322..0000000 --- a/src/LASlib/LICENSE.txt +++ /dev/null @@ -1,96 +0,0 @@ --------------------------------------------------------------------------- - - LICENSE AGREEMENT: - - This software is distributed WITHOUT ANY WARRANTY and without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - --------------------------------------------------------------------------- - - There are TWO parts to LAStools. One part is OPEN source (LGPL 2.1). The - other part is CLOSED source and requires licensing for most commercial - or government use. If you're unsure please email 'martin@rapidlasso.com' - before using LAStools. For education and evaluation purposes you can use - and test LAStools as much as you need to ... (-: - - Personal note: The creator of LAStools and LASzip is currently not able - to attend LiDAR conferences or other scientific meetings in the US over - a somewhat unfortunate, kind of silly, and in many ways absurdly funny - incident involving "laser chickens" and a US Nuclear Weapons Lab. If you - have enough "pull" to rectify this ridiculous situation we would like to - hear from you ... (-; - --------------------------------------------------------------------------- - - This part of LAStools is "free" open-source LGPL (see COPYING.txt). To - purchase a different licensing model contact 'license@rapidlasso.com'. - - * laszip - * lasindex - * lasvalidate - * lasliberate - * lasinfo - * las2las - * lasdiff - * lasmerge - * las2txt & txt2las - * lasprecision - * LASzip (with static linking exception) - * LASlib (with LASzip) - the API used by LAStools. - - These two are also "free" to use but not available in open source. - - * lasview - * laspublish - --------------------------------------------------------------------------- - - The following LAStools require licensing for any commercial, government, - or production use. However, they may be used "freely" for all non-profit - personal, non-military educational, or non-profit humanitarian purposes. - Note that the output of the unlicensed version can be slightly distorted - after certain point limits are exceeded. Control output in the console - (aka "the black window") informs the user whenever this happens. - - * blast2dem - * blast2iso - - * lasground & lasground_new - * lasheight & lastrack - * lasclassify - * lasgrid & lascanopy - * lasboundary - * lascontrol - * lasoverlap - * lasoverage - * lasduplicate - * lassplit - * lasreturn - * las2tin - * las2iso - * las2dem - * lasthin & lasnoise - * lassort - * lastile - * lasplanes - * lascolor - * lasclip - * las2shp & shp2las. - --------------------------------------------------------------------------- - - If you want to use LAStools please contact us for licensing. You can - - (a) license the existing executables for production - (b) license the existing executables for inclusion in your software - - You can also contract with rapidlasso GmbH to create LAStools tailored - to your particular needs. - --------------------------------------------------------------------------- - - COPYRIGHT: - - (c) 2007-2015, rapidlasso GmbH, GERMANY - fast tools to catch reality - --------------------------------------------------------------------------- diff --git a/src/LASlib/README.txt b/src/LASlib/README.txt deleted file mode 100644 index 50b404e..0000000 --- a/src/LASlib/README.txt +++ /dev/null @@ -1,19 +0,0 @@ - CONTENT: - - This folder contains the source code of LASlib developped by Martin Isenburg - and used in the 'rlas' package. - - PROGRAMMERS: - - martin.isenburg@rapidlasso.com - http://rapidlasso.com - - COPYRIGHT: - - (c) 2003-2012, martin isenburg, rapidlasso - fast tools to catch reality - - This is free software; you can redistribute and/or modify it under the - terms of the GNU Lesser General Licence as published by the Free Software - Foundation. See the LICENSE.txt file for more information. - - This software is distributed WITHOUT ANY WARRANTY and without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. \ No newline at end of file diff --git a/src/LASlib/fopen_compressed.cpp b/src/LASlib/fopen_compressed.cpp index 274aa7b..b1941fd 100644 --- a/src/LASlib/fopen_compressed.cpp +++ b/src/LASlib/fopen_compressed.cpp @@ -2,13 +2,13 @@ =============================================================================== FILE: fopen_compressed.cpp - + CONTENTS: - + PROGRAMMERS: - + martin.isenburg@rapidlasso.com - http://rapidlasso.com - + COPYRIGHT: (c) 2003-2018, martin isenburg, rapidlasso - fast tools to catch reality @@ -19,13 +19,13 @@ This software is distributed WITHOUT ANY WARRANTY and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - + CHANGE HISTORY: - + 27 December 2018 -- only act if the extension really is a file extension 20 March 2011 -- added capability for *.zip, *.rar, and *.7z on Windows 12 December 2003 -- adapted from Stefan Gumhold's SIGGRAPH submission hack - + =============================================================================== */ @@ -39,9 +39,6 @@ #include #endif -#define STRICT_R_HEADERS -#include - enum PIPES { READ_HANDLE, WRITE_HANDLE }; /* Constants 0 and 1 for READ and WRITE */ // open a 7zipped/ZIPped/gzipped/rarzipped file as if they were regular a file @@ -56,7 +53,7 @@ static FILE* fopen7zipped(const char* filename, const char* mode) int hPipe[2]; if (_pipe(hPipe, 2048, ((mode[1] =='b') ? _O_BINARY : _O_TEXT) | _O_NOINHERIT) == -1) { - REprintf( "could not create pipe\n"); + fprintf(stderr, "could not create pipe\n"); return NULL; } @@ -66,14 +63,14 @@ static FILE* fopen7zipped(const char* filename, const char* mode) // make the write end of pipe go to stdout if (_dup2(hPipe[WRITE_HANDLE], _fileno(stdout)) != 0) { - REprintf( "could not set pipe output\n"); + fprintf(stderr, "could not set pipe output\n"); return NULL; } // redirect read end of pipe to input file if (_dup2(hPipe[READ_HANDLE], _fileno(stdin)) != 0) { - REprintf( "could not redirect input file\n"); + fprintf(stderr, "could not redirect input file\n"); return NULL; } @@ -86,11 +83,11 @@ static FILE* fopen7zipped(const char* filename, const char* mode) // redirect stdout back into stdout if (_dup2(hStdOut, _fileno(stdout)) != 0) { - REprintf( "could not reconstruct stdout\n"); + fprintf(stderr, "could not reconstruct stdout\n"); return NULL; } - // return redirected stdin + // return redirected stdin return stdin; } else @@ -108,7 +105,7 @@ static FILE* fopenZIPped(const char* filename, const char* mode) int hPipe[2]; if (_pipe(hPipe, 2048, ((mode[1] =='b') ? _O_BINARY : _O_TEXT) | _O_NOINHERIT) == -1) { - REprintf( "could not create pipe\n"); + fprintf(stderr, "could not create pipe\n"); return NULL; } @@ -118,14 +115,14 @@ static FILE* fopenZIPped(const char* filename, const char* mode) // make the write end of pipe go to stdout if (_dup2(hPipe[WRITE_HANDLE], _fileno(stdout)) != 0) { - REprintf( "could not set pipe output\n"); + fprintf(stderr, "could not set pipe output\n"); return NULL; } // redirect read end of pipe to input file if (_dup2(hPipe[READ_HANDLE], _fileno(stdin)) != 0) { - REprintf( "could not redirect input file\n"); + fprintf(stderr, "could not redirect input file\n"); return NULL; } @@ -138,11 +135,11 @@ static FILE* fopenZIPped(const char* filename, const char* mode) // redirect stdout back into stdout if (_dup2(hStdOut, _fileno(stdout)) != 0) { - REprintf( "could not reconstruct stdout\n"); + fprintf(stderr, "could not reconstruct stdout\n"); return NULL; } - // return redirected stdin + // return redirected stdin return stdin; } else @@ -164,7 +161,7 @@ static FILE* fopenGzipped(const char* filename, const char* mode) int hPipe[2]; if (_pipe(hPipe, 2048, ((mode[1] =='b') ? _O_BINARY : _O_TEXT) | _O_NOINHERIT) == -1) { - REprintf( "could not create pipe\n"); + fprintf(stderr, "could not create pipe\n"); return NULL; } @@ -173,7 +170,7 @@ static FILE* fopenGzipped(const char* filename, const char* mode) // redirect stdin to input file if (_dup2(_fileno(gzipInput), _fileno(stdin)) != 0) { - REprintf( "could not redirect stdin\n"); + fprintf(stderr, "could not redirect stdin\n"); return NULL; } @@ -182,7 +179,7 @@ static FILE* fopenGzipped(const char* filename, const char* mode) // redirect stdout to write end of pipe if (_dup2(hPipe[WRITE_HANDLE], _fileno(stdout)) != 0) { - REprintf( "could not set pipe output\n"); + fprintf(stderr, "could not set pipe output\n"); return NULL; } @@ -192,7 +189,7 @@ static FILE* fopenGzipped(const char* filename, const char* mode) // redirect read end of pipe to input file if (_dup2(hPipe[READ_HANDLE], _fileno(gzipInput)) != 0) { - REprintf( "could not redirect input file\n"); + fprintf(stderr, "could not redirect input file\n"); return NULL; } @@ -205,14 +202,14 @@ static FILE* fopenGzipped(const char* filename, const char* mode) // redirect stdin back into stdin if (_dup2(hStdIn, _fileno(stdin)) != 0) { - REprintf( "could not reconstruct stdin\n"); + fprintf(stderr, "could not reconstruct stdin\n"); return NULL; } // redirect stdout back into stdout if (_dup2(hStdOut, _fileno(stdout)) != 0) { - REprintf( "could not reconstruct stdout\n"); + fprintf(stderr, "could not reconstruct stdout\n"); return NULL; } @@ -234,7 +231,7 @@ static FILE* fopenGzippedNew(const char* filename, const char* mode) int hPipe[2]; if (_pipe(hPipe, 2048, ((mode[1] =='b') ? _O_BINARY : _O_TEXT) | _O_NOINHERIT) == -1) { - REprintf( "could not create pipe\n"); + fprintf(stderr, "could not create pipe\n"); return NULL; } @@ -244,14 +241,14 @@ static FILE* fopenGzippedNew(const char* filename, const char* mode) // make the write end of pipe go to stdout if (_dup2(hPipe[WRITE_HANDLE], _fileno(stdout)) != 0) { - REprintf( "could not set pipe output\n"); + fprintf(stderr, "could not set pipe output\n"); return NULL; } // redirect read end of pipe to input file if (_dup2(hPipe[READ_HANDLE], _fileno(stdin)) != 0) { - REprintf( "could not redirect input file\n"); + fprintf(stderr, "could not redirect input file\n"); return NULL; } @@ -264,11 +261,11 @@ static FILE* fopenGzippedNew(const char* filename, const char* mode) // redirect stdout back into stdout if (_dup2(hStdOut, _fileno(stdout)) != 0) { - REprintf( "could not reconstruct stdout\n"); + fprintf(stderr, "could not reconstruct stdout\n"); return NULL; } - // return redirected stdin + // return redirected stdin return stdin; } else @@ -286,7 +283,7 @@ static FILE* fopenRARed(const char* filename, const char* mode) int hPipe[2]; if (_pipe(hPipe, 2048, ((mode[1] =='b') ? _O_BINARY : _O_TEXT) | _O_NOINHERIT) == -1) { - REprintf( "could not create pipe\n"); + fprintf(stderr, "could not create pipe\n"); return NULL; } @@ -296,14 +293,14 @@ static FILE* fopenRARed(const char* filename, const char* mode) // make the write end of pipe go to stdout if (_dup2(hPipe[WRITE_HANDLE], _fileno(stdout)) != 0) { - REprintf( "could not set pipe output\n"); + fprintf(stderr, "could not set pipe output\n"); return NULL; } // redirect read end of pipe to input file if (_dup2(hPipe[READ_HANDLE], _fileno(stdin)) != 0) { - REprintf( "could not redirect input file\n"); + fprintf(stderr, "could not redirect input file\n"); return NULL; } @@ -316,11 +313,11 @@ static FILE* fopenRARed(const char* filename, const char* mode) // redirect stdout back into stdout if (_dup2(hStdOut, _fileno(stdout)) != 0) { - REprintf( "could not reconstruct stdout\n"); + fprintf(stderr, "could not reconstruct stdout\n"); return NULL; } - // return redirected stdin + // return redirected stdin return stdin; } else @@ -344,7 +341,7 @@ FILE* fopen_compressed(const char* filename, const char* mode, bool* piped) file = fopenGzipped(filename, mode); if (piped) *piped = true; #else - REprintf( "ERROR: no support for gzipped input\n"); + fprintf(stderr, "ERROR: no support for gzipped input\n"); return 0; #endif } @@ -354,7 +351,7 @@ FILE* fopen_compressed(const char* filename, const char* mode, bool* piped) file = fopenZIPped(filename, mode); if (piped) *piped = true; #else - REprintf( "ERROR: no support for ZIPped input\n"); + fprintf(stderr, "ERROR: no support for ZIPped input\n"); return 0; #endif } @@ -364,7 +361,7 @@ FILE* fopen_compressed(const char* filename, const char* mode, bool* piped) file = fopen7zipped(filename, mode); if (piped) *piped = true; #else - REprintf( "ERROR: no support for 7zipped input\n"); + fprintf(stderr, "ERROR: no support for 7zipped input\n"); return 0; #endif } @@ -374,7 +371,7 @@ FILE* fopen_compressed(const char* filename, const char* mode, bool* piped) file = fopenRARed(filename, mode); if (piped) *piped = true; #else - REprintf( "ERROR: no support for RARed input\n"); + fprintf(stderr, "ERROR: no support for RARed input\n"); return 0; #endif } diff --git a/inst/include/lasdefinitions.hpp b/src/LASlib/lasdefinitions.hpp similarity index 94% rename from inst/include/lasdefinitions.hpp rename to src/LASlib/lasdefinitions.hpp index 13be84a..d188e19 100644 --- a/inst/include/lasdefinitions.hpp +++ b/src/LASlib/lasdefinitions.hpp @@ -2,9 +2,9 @@ =============================================================================== FILE: lasdefinitions.hpp - + CONTENTS: - + Contains the Header and Point classes for reading and writing LiDAR points in the LAS format @@ -28,28 +28,28 @@ This software is distributed WITHOUT ANY WARRANTY and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - + CHANGE HISTORY: - - 19 April 2017 -- support for selective decompression for new LAS 1.4 points + + 19 April 2017 -- support for selective decompression for new LAS 1.4 points 1 February 2017 -- better support for OGC WKT strings in VLRs or EVLRs 22 June 2016 -- set default of VLR header "reserved" to 0 instead of 0xAABB 1 August 2015 -- moving LASpoint, LASquantizer, and LASattributer to LASzip 9 December 2013 -- bug fix and improved writing of new LAS 1.4 point types - 21 December 2011 -- (limited) support for LAS 1.4 and attributed extra bytes + 21 December 2011 -- (limited) support for LAS 1.4 and attributed extra bytes 10 January 2011 -- licensing change for LGPL release and liblas integration 16 December 2010 -- updated to support generic LASitem point formats 3 December 2010 -- updated to (somewhat) support LAS format 1.3 - 7 September 2008 -- updated to support LAS format 1.2 + 7 September 2008 -- updated to support LAS format 1.2 11 June 2007 -- number of return / scan direction bitfield order was wrong 18 February 2007 -- created after repairing 2 vacuum cleaners in the garden - + =============================================================================== */ #ifndef LAS_DEFINITIONS_HPP #define LAS_DEFINITIONS_HPP -#define LAS_TOOLS_VERSION 190404 +#define LAS_TOOLS_VERSION 210117 #include #include @@ -57,6 +57,7 @@ #include #include "mydefs.hpp" +#include "lasvlr.hpp" #include "laszip.hpp" #include "laspoint.hpp" @@ -87,7 +88,7 @@ class LASvlr { public: U16 reserved; - CHAR user_id[16]; + CHAR user_id[16]; U16 record_id; U16 record_length_after_header; CHAR description[32]; @@ -99,7 +100,7 @@ class LASevlr { public: U16 reserved; - CHAR user_id[16]; + CHAR user_id[16]; U16 record_id; I64 record_length_after_header; CHAR description[32]; @@ -153,33 +154,6 @@ class LASvlr_wave_packet_descr U8 data[26]; }; -class LASvlr_lastiling -{ -public: - U32 level; - U32 level_index; - U32 implicit_levels : 30; - U32 buffer : 1; - U32 reversible : 1; - F32 min_x; - F32 max_x; - F32 min_y; - F32 max_y; -}; - -class LASvlr_lasoriginal -{ -public: - I64 number_of_point_records; - I64 number_of_points_by_return[15]; - F64 max_x; - F64 min_x; - F64 max_y; - F64 min_y; - F64 max_z; - F64 min_z; -}; - class LASheader : public LASquantizer, public LASattributer { public: @@ -460,40 +434,40 @@ class LASheader : public LASquantizer, public LASattributer { if (strncmp(file_signature, "LASF", 4) != 0) { - REprintf("ERROR: wrong file signature '%4s'\n", file_signature); + fprintf(stderr,"ERROR: wrong file signature '%4s'\n", file_signature); return FALSE; } if ((version_major != 1) || (version_minor > 4)) { - REprintf("WARNING: unknown version %d.%d (should be 1.0 or 1.1 or 1.2 or 1.3 or 1.4)\n", version_major, version_minor); + fprintf(stderr,"WARNING: unknown version %d.%d (should be 1.0 or 1.1 or 1.2 or 1.3 or 1.4)\n", version_major, version_minor); } if (header_size < 227) { - REprintf("ERROR: header size is %d but should be at least 227\n", header_size); + fprintf(stderr,"ERROR: header size is %d but should be at least 227\n", header_size); return FALSE; } if (offset_to_point_data < header_size) { - REprintf("ERROR: offset to point data %d is smaller than header size %d\n", offset_to_point_data, header_size); + fprintf(stderr,"ERROR: offset to point data %d is smaller than header size %d\n", offset_to_point_data, header_size); return FALSE; } if (x_scale_factor == 0) { - REprintf("WARNING: x scale factor is zero.\n"); + fprintf(stderr,"WARNING: x scale factor is zero.\n"); } if (y_scale_factor == 0) { - REprintf("WARNING: y scale factor is zero.\n"); + fprintf(stderr,"WARNING: y scale factor is zero.\n"); } if (z_scale_factor == 0) { - REprintf("WARNING: z scale factor is zero.\n"); + fprintf(stderr,"WARNING: z scale factor is zero.\n"); } if (max_x < min_x || max_y < min_y || max_z < min_z) { if (number_of_point_records || extended_number_of_point_records) { - REprintf("WARNING: invalid bounding box [ %g %g %g / %g %g %g ]\n", min_x, min_y, min_z, max_x, max_y, max_z); + fprintf(stderr,"WARNING: invalid bounding box [ %g %g %g / %g %g %g ]\n", min_x, min_y, min_z, max_x, max_y, max_z); } } return TRUE; @@ -526,7 +500,7 @@ class LASheader : public LASquantizer, public LASattributer }; // note that data needs to be allocated with new [] and not malloc and that LASheader - // will become the owner over this and manage its deallocation + // will become the owner over this and manage its deallocation BOOL add_vlr(const CHAR* user_id, const U16 record_id, const U16 record_length_after_header, U8* data, const BOOL keep_description=FALSE, const CHAR* description=0, const BOOL keep_existing=FALSE) { U32 i = 0; @@ -567,11 +541,9 @@ class LASheader : public LASquantizer, public LASattributer offset_to_point_data += 54; vlrs = (LASvlr*)malloc(sizeof(LASvlr)); } - memset((void*)&(vlrs[i]), 0, sizeof(LASvlr)); + memset(&(vlrs[i]), 0, sizeof(LASvlr)); vlrs[i].reserved = 0; // used to be 0xAABB - //strncpy(vlrs[i].user_id, user_id, 16); - int len = 0 ; while(*(user_id+len) != '\0' && len < 16) len++; - memcpy(vlrs[i].user_id, user_id, len); + strncpy(vlrs[i].user_id, user_id, 16); vlrs[i].record_id = record_id; vlrs[i].record_length_after_header = record_length_after_header; if (keep_description && found_description) @@ -657,7 +629,7 @@ class LASheader : public LASquantizer, public LASattributer }; // note that data needs to be allocated with new [] and not malloc and that LASheader - // will become the owner over this and manage its deallocation + // will become the owner over this and manage its deallocation void add_evlr(const CHAR* user_id, const U16 record_id, const I64 record_length_after_header, U8* data, const BOOL keep_description=FALSE, const CHAR* description=0, const BOOL keep_existing=FALSE) { U32 i = 0; @@ -696,9 +668,7 @@ class LASheader : public LASquantizer, public LASattributer evlrs = (LASevlr*)malloc(sizeof(LASevlr)*number_of_extended_variable_length_records); } evlrs[i].reserved = 0; // used to be 0xAABB - //strncpy(evlrs[i].user_id, user_id, 16); - int len = 0 ; while(*(user_id+len) != '\0' && len < 16) len++; - memcpy(evlrs[i].user_id, user_id, len); + strncpy(evlrs[i].user_id, user_id, 16); evlrs[i].record_id = record_id; evlrs[i].record_length_after_header = record_length_after_header; if (keep_description && found_description) @@ -897,9 +867,9 @@ class LASheader : public LASquantizer, public LASattributer void del_geo_double_params() { + remove_vlr("LASF_Projection", 34736); if (vlr_geo_double_params) { - remove_vlr("LASF_Projection", 34736); vlr_geo_double_params = 0; } } @@ -917,9 +887,9 @@ class LASheader : public LASquantizer, public LASattributer void del_geo_ascii_params() { + remove_vlr("LASF_Projection", 34737); if (vlr_geo_ascii_params) { - remove_vlr("LASF_Projection", 34737); vlr_geo_ascii_params = 0; } } diff --git a/src/LASlib/lasfilter.cpp b/src/LASlib/lasfilter.cpp index a92243b..4e9dddb 100644 --- a/src/LASlib/lasfilter.cpp +++ b/src/LASlib/lasfilter.cpp @@ -2,11 +2,11 @@ =============================================================================== FILE: lasfilter.cpp - + CONTENTS: - + see corresponding header file - + PROGRAMMERS: martin.isenburg@rapidlasso.com - http://rapidlasso.com @@ -21,15 +21,13 @@ This software is distributed WITHOUT ANY WARRANTY and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - + CHANGE HISTORY: - + see corresponding header file - + =============================================================================== */ -#include - #include "lasfilter.hpp" #include @@ -38,7 +36,6 @@ #include #include -#include using namespace std; typedef multimap my_I64_F64_map; @@ -524,7 +521,7 @@ class LAScriterionKeepReturns : public LAScriterion { public: inline const CHAR* name() const { return "keep_return_mask"; }; - inline I32 get_command(CHAR* string) const { + inline I32 get_command(CHAR* string) const { U32 i; U32 n = sprintf(string, "-keep_return "); U16 keep_return_mask = ~drop_return_mask; @@ -542,7 +539,7 @@ class LAScriterionDropReturns : public LAScriterion { public: inline const CHAR* name() const { return "drop_return_mask"; }; - inline I32 get_command(CHAR* string) const { + inline I32 get_command(CHAR* string) const { U32 i; U32 n = sprintf(string, "-drop_return "); for (i = 0; i < 16; i++) if ((1 << i) & drop_return_mask) n += sprintf(string + n, "%u ", i); @@ -645,6 +642,18 @@ class LAScriterionKeepRGB : public LAScriterion I32 below_RGB, above_RGB, channel; }; +class LAScriterionKeepRGBgreenness : public LAScriterion +{ +public: + inline const CHAR* name() const { return "keep_RGB_greenness"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d %d ", name(), below_RGB, above_RGB); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_RGB; }; + inline BOOL filter(const LASpoint* point) { I32 greenness = 2 * point->get_G() - point->get_R() - point->get_B(); return ((greenness < below_RGB) || (above_RGB < greenness)); }; + LAScriterionKeepRGBgreenness(I32 below_RGB, I32 above_RGB) { if (above_RGB < below_RGB) { this->below_RGB = above_RGB; this->above_RGB = below_RGB; } else { this->below_RGB = below_RGB; this->above_RGB = above_RGB; }; }; +private: + I32 below_RGB, above_RGB; +}; + class LAScriterionDropRGB : public LAScriterion { public: @@ -664,7 +673,7 @@ class LAScriterionKeepNDVI : public LAScriterion inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s%s %g %g ", name(), (NIR == 3 ? "" : (NIR == 1 ? "_green_is_NIR" : "_blue_is_NIR")), below_NDVI, above_NDVI); }; inline U32 get_decompress_selective() const { if (NIR == 3) return LASZIP_DECOMPRESS_SELECTIVE_RGB | LASZIP_DECOMPRESS_SELECTIVE_NIR; else return LASZIP_DECOMPRESS_SELECTIVE_RGB; }; inline BOOL filter(const LASpoint* point) - { + { F32 NDVI = ((F32)(point->rgb[NIR] - point->get_R())) / ((F32)(point->rgb[NIR] + point->get_R())); return (NDVI < below_NDVI) || (above_NDVI < NDVI); }; @@ -681,7 +690,7 @@ class LAScriterionKeepNDVIfromCIR : public LAScriterion inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %g %g ", name(), below_NDVI, above_NDVI); }; inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_RGB; }; inline BOOL filter(const LASpoint* point) - { + { F32 NDVI = ((F32)(point->get_R() - point->get_G())) / ((F32)(point->get_R() + point->get_G())); return (NDVI < below_NDVI) || (above_NDVI < NDVI); }; @@ -697,7 +706,7 @@ class LAScriterionKeepNDVIintensityIsNIR : public LAScriterion inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %g %g ", name(), below_NDVI, above_NDVI); }; inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_RGB | LASZIP_DECOMPRESS_SELECTIVE_INTENSITY; }; inline BOOL filter(const LASpoint* point) - { + { F32 NDVI = ((F32)(point->get_intensity() - point->get_R())) / ((F32)(point->get_intensity() + point->get_R())); return (NDVI < below_NDVI) || (above_NDVI < NDVI); }; @@ -830,7 +839,7 @@ class LAScriterionKeepClassifications : public LAScriterion { public: inline const CHAR* name() const { return "keep_classification_mask"; }; - inline I32 get_command(CHAR* string) const { + inline I32 get_command(CHAR* string) const { U32 i; U32 n = sprintf(string, "-keep_class "); U32 keep_classification_mask = ~drop_classification_mask; @@ -849,7 +858,7 @@ class LAScriterionDropClassifications : public LAScriterion { public: inline const CHAR* name() const { return "drop_classification_mask"; }; - inline I32 get_command(CHAR* string) const { + inline I32 get_command(CHAR* string) const { U32 i; U32 n = sprintf(string, "-drop_class "); for (i = 0; i < 32; i++) if ((1 << i) & drop_classification_mask) n += sprintf(string + n, "%u ", i); @@ -1298,9 +1307,8 @@ class LAScriterionKeepRandomFraction : public LAScriterion inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %g ", name(), fraction); }; inline BOOL filter(const LASpoint* point) { - //srand(seed); - //seed = rand(); - seed = R::runif(0, RAND_MAX); + srand(seed); + seed = rand(); return ((F32)seed/(F32)RAND_MAX) > fraction; }; void reset() { seed = requested_seed; }; @@ -1318,7 +1326,7 @@ class LAScriterionThinWithGrid : public LAScriterion inline const CHAR* name() const { return "thin_with_grid"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %g ", name(), (grid_spacing > 0 ? grid_spacing : -grid_spacing)); }; inline BOOL filter(const LASpoint* point) - { + { if (grid_spacing < 0) { grid_spacing = -grid_spacing; @@ -1523,56 +1531,6 @@ class LAScriterionThinWithGrid : public LAScriterion U16* plus_plus_sizes; }; -class LAScriterionThinWithVoxel : public LAScriterion -{ - typedef std::array Array; - -public: - inline const CHAR* name() const { return "thin_with_voxel"; }; - inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s ", name()); }; - inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_CHANNEL_RETURNS_XY | LASZIP_DECOMPRESS_SELECTIVE_Z; }; - inline BOOL filter(const LASpoint* point) - { - if(voxel_spacing < 0) - { - xoffset = point->get_x(); - yoffset = point->get_y(); - zoffset = point->get_z(); - voxel_spacing = -voxel_spacing; - } - - I32 nx = I32_FLOOR((point->get_x() - xoffset) / voxel_spacing); - I32 ny = I32_FLOOR((point->get_y() - yoffset) / voxel_spacing); - I32 nz = I32_FLOOR((point->get_z() - zoffset) / voxel_spacing); - Array key = {nx, ny, nz}; - - return !dynamic_registry.insert(key).second; - }; - void reset() - { - voxel_spacing = -voxel_spacing; - xoffset = 0; - yoffset = 0; - zoffset = 0; - dynamic_registry.clear(); - }; - LAScriterionThinWithVoxel(F32 voxel_spacing) - { - this->voxel_spacing = voxel_spacing < 0 ? voxel_spacing : -voxel_spacing; - xoffset = 0; - yoffset = 0; - zoffset = 0; - }; - ~LAScriterionThinWithVoxel(){ reset(); }; - -private: - double voxel_spacing; - double xoffset; - double yoffset; - double zoffset; - std::unordered_set > dynamic_registry; -}; - class LAScriterionThinPulsesWithTime : public LAScriterion { public: @@ -1580,7 +1538,7 @@ class LAScriterionThinPulsesWithTime : public LAScriterion inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %lf ", name(), (time_spacing > 0 ? time_spacing : -time_spacing)); }; inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_GPS_TIME; }; inline BOOL filter(const LASpoint* point) - { + { I64 pos_t = I64_FLOOR(point->get_gps_time() / time_spacing); my_I64_F64_map::iterator map_element = times.find(pos_t); if (map_element == times.end()) @@ -1618,7 +1576,7 @@ class LAScriterionThinPointsWithTime : public LAScriterion inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %lf ", name(), (time_spacing > 0 ? time_spacing : -time_spacing)); }; inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_GPS_TIME; }; inline BOOL filter(const LASpoint* point) - { + { I64 pos_t = I64_FLOOR(point->get_gps_time() / time_spacing); my_I64_set::iterator map_element = times.find(pos_t); if (map_element == times.end()) @@ -1662,111 +1620,111 @@ void LASfilter::clean() void LASfilter::usage() const { - REprintf("Filter points based on their coordinates.\n"); - REprintf(" -keep_tile 631000 4834000 1000 (ll_x ll_y size)\n"); - REprintf(" -keep_circle 630250.00 4834750.00 100 (x y radius)\n"); - REprintf(" -keep_xy 630000 4834000 631000 4836000 (min_x min_y max_x max_y)\n"); - REprintf(" -drop_xy 630000 4834000 631000 4836000 (min_x min_y max_x max_y)\n"); - REprintf(" -keep_x 631500.50 631501.00 (min_x max_x)\n"); - REprintf(" -drop_x 631500.50 631501.00 (min_x max_x)\n"); - REprintf(" -drop_x_below 630000.50 (min_x)\n"); - REprintf(" -drop_x_above 630500.50 (max_x)\n"); - REprintf(" -keep_y 4834500.25 4834550.25 (min_y max_y)\n"); - REprintf(" -drop_y 4834500.25 4834550.25 (min_y max_y)\n"); - REprintf(" -drop_y_below 4834500.25 (min_y)\n"); - REprintf(" -drop_y_above 4836000.75 (max_y)\n"); - REprintf(" -keep_z 11.125 130.725 (min_z max_z)\n"); - REprintf(" -drop_z 11.125 130.725 (min_z max_z)\n"); - REprintf(" -drop_z_below 11.125 (min_z)\n"); - REprintf(" -drop_z_above 130.725 (max_z)\n"); - REprintf(" -keep_xyz 620000 4830000 100 621000 4831000 200 (min_x min_y min_z max_x max_y max_z)\n"); - REprintf(" -drop_xyz 620000 4830000 100 621000 4831000 200 (min_x min_y min_z max_x max_y max_z)\n"); - REprintf("Filter points based on their return numbering.\n"); - REprintf(" -keep_first -first_only -drop_first\n"); - REprintf(" -keep_last -last_only -drop_last\n"); - REprintf(" -keep_second_last -drop_second_last\n"); - REprintf(" -keep_first_of_many -keep_last_of_many\n"); - REprintf(" -drop_first_of_many -drop_last_of_many\n"); - REprintf(" -keep_middle -drop_middle\n"); - REprintf(" -keep_return 1 2 3\n"); - REprintf(" -drop_return 3 4\n"); - REprintf(" -keep_single -drop_single\n"); - REprintf(" -keep_double -drop_double\n"); - REprintf(" -keep_triple -drop_triple\n"); - REprintf(" -keep_quadruple -drop_quadruple\n"); - REprintf(" -keep_number_of_returns 5\n"); - REprintf(" -drop_number_of_returns 0\n"); - REprintf("Filter points based on the scanline flags.\n"); - REprintf(" -drop_scan_direction 0\n"); - REprintf(" -keep_scan_direction_change\n"); - REprintf(" -keep_edge_of_flight_line\n"); - REprintf("Filter points based on their intensity.\n"); - REprintf(" -keep_intensity 20 380\n"); - REprintf(" -drop_intensity_below 20\n"); - REprintf(" -drop_intensity_above 380\n"); - REprintf(" -drop_intensity_between 4000 5000\n"); - REprintf("Filter points based on classifications or flags.\n"); - REprintf(" -keep_class 1 3 7\n"); - REprintf(" -drop_class 4 2\n"); - REprintf(" -keep_extended_class 43\n"); - REprintf(" -drop_extended_class 129 135\n"); - REprintf(" -drop_synthetic -keep_synthetic\n"); - REprintf(" -drop_keypoint -keep_keypoint\n"); - REprintf(" -drop_withheld -keep_withheld\n"); - REprintf(" -drop_overlap -keep_overlap\n"); - REprintf("Filter points based on their user data.\n"); - REprintf(" -keep_user_data 1\n"); - REprintf(" -drop_user_data 255\n"); - REprintf(" -keep_user_data_below 50\n"); - REprintf(" -keep_user_data_above 150\n"); - REprintf(" -keep_user_data_between 10 20\n"); - REprintf(" -drop_user_data_below 1\n"); - REprintf(" -drop_user_data_above 100\n"); - REprintf(" -drop_user_data_between 10 40\n"); - REprintf("Filter points based on their point source ID.\n"); - REprintf(" -keep_point_source 3\n"); - REprintf(" -keep_point_source_between 2 6\n"); - REprintf(" -drop_point_source 27\n"); - REprintf(" -drop_point_source_below 6\n"); - REprintf(" -drop_point_source_above 15\n"); - REprintf(" -drop_point_source_between 17 21\n"); - REprintf("Filter points based on their scan angle.\n"); - REprintf(" -keep_scan_angle -15 15\n"); - REprintf(" -drop_abs_scan_angle_above 15\n"); - REprintf(" -drop_abs_scan_angle_below 1\n"); - REprintf(" -drop_scan_angle_below -15\n"); - REprintf(" -drop_scan_angle_above 15\n"); - REprintf(" -drop_scan_angle_between -25 -23\n"); - REprintf("Filter points based on their gps time.\n"); - REprintf(" -keep_gps_time 11.125 130.725\n"); - REprintf(" -drop_gps_time_below 11.125\n"); - REprintf(" -drop_gps_time_above 130.725\n"); - REprintf(" -drop_gps_time_between 22.0 48.0\n"); - REprintf("Filter points based on their RGB/CIR/NIR channels.\n"); - REprintf(" -keep_RGB_red 1 1\n"); - REprintf(" -drop_RGB_red 5000 20000\n"); - REprintf(" -keep_RGB_green 30 100\n"); - REprintf(" -drop_RGB_green 2000 10000\n"); - REprintf(" -keep_RGB_blue 0 0\n"); - REprintf(" -keep_RGB_nir 64 127\n"); - REprintf(" -keep_NDVI 0.2 0.7 -keep_NDVI_from_CIR -0.1 0.5\n"); - REprintf(" -keep_NDVI_intensity_is_NIR 0.4 0.8 -keep_NDVI_green_is_NIR -0.2 0.2\n"); - REprintf("Filter points based on their wavepacket.\n"); - REprintf(" -keep_wavepacket 0\n"); - REprintf(" -drop_wavepacket 3\n"); - REprintf("Filter points based on extra attributes.\n"); - REprintf(" -keep_attribute_above 0 5.0\n"); - REprintf(" -drop_attribute_below 1 1.5\n"); - REprintf("Filter points with simple thinning.\n"); - REprintf(" -keep_every_nth 2 -drop_every_nth 3\n"); - REprintf(" -keep_random_fraction 0.1\n"); - REprintf(" -keep_random_fraction 0.1 4711\n"); - REprintf(" -thin_with_grid 1.0\n"); - REprintf(" -thin_with_voxel 0.1\n"); - REprintf(" -thin_pulses_with_time 0.0001\n"); - REprintf(" -thin_points_with_time 0.000001\n"); - REprintf("Boolean combination of filters.\n"); - REprintf(" -filter_and\n"); + fprintf(stderr,"Filter points based on their coordinates.\n"); + fprintf(stderr," -keep_tile 631000 4834000 1000 (ll_x ll_y size)\n"); + fprintf(stderr," -keep_circle 630250.00 4834750.00 100 (x y radius)\n"); + fprintf(stderr," -keep_xy 630000 4834000 631000 4836000 (min_x min_y max_x max_y)\n"); + fprintf(stderr," -drop_xy 630000 4834000 631000 4836000 (min_x min_y max_x max_y)\n"); + fprintf(stderr," -keep_x 631500.50 631501.00 (min_x max_x)\n"); + fprintf(stderr," -drop_x 631500.50 631501.00 (min_x max_x)\n"); + fprintf(stderr," -drop_x_below 630000.50 (min_x)\n"); + fprintf(stderr," -drop_x_above 630500.50 (max_x)\n"); + fprintf(stderr," -keep_y 4834500.25 4834550.25 (min_y max_y)\n"); + fprintf(stderr," -drop_y 4834500.25 4834550.25 (min_y max_y)\n"); + fprintf(stderr," -drop_y_below 4834500.25 (min_y)\n"); + fprintf(stderr," -drop_y_above 4836000.75 (max_y)\n"); + fprintf(stderr," -keep_z 11.125 130.725 (min_z max_z)\n"); + fprintf(stderr," -drop_z 11.125 130.725 (min_z max_z)\n"); + fprintf(stderr," -drop_z_below 11.125 (min_z)\n"); + fprintf(stderr," -drop_z_above 130.725 (max_z)\n"); + fprintf(stderr," -keep_xyz 620000 4830000 100 621000 4831000 200 (min_x min_y min_z max_x max_y max_z)\n"); + fprintf(stderr," -drop_xyz 620000 4830000 100 621000 4831000 200 (min_x min_y min_z max_x max_y max_z)\n"); + fprintf(stderr,"Filter points based on their return numbering.\n"); + fprintf(stderr," -keep_first -first_only -drop_first\n"); + fprintf(stderr," -keep_last -last_only -drop_last\n"); + fprintf(stderr," -keep_second_last -drop_second_last\n"); + fprintf(stderr," -keep_first_of_many -keep_last_of_many\n"); + fprintf(stderr," -drop_first_of_many -drop_last_of_many\n"); + fprintf(stderr," -keep_middle -drop_middle\n"); + fprintf(stderr," -keep_return 1 2 3\n"); + fprintf(stderr," -drop_return 3 4\n"); + fprintf(stderr," -keep_single -drop_single\n"); + fprintf(stderr," -keep_double -drop_double\n"); + fprintf(stderr," -keep_triple -drop_triple\n"); + fprintf(stderr," -keep_quadruple -drop_quadruple\n"); + fprintf(stderr," -keep_number_of_returns 5\n"); + fprintf(stderr," -drop_number_of_returns 0\n"); + fprintf(stderr,"Filter points based on the scanline flags.\n"); + fprintf(stderr," -drop_scan_direction 0\n"); + fprintf(stderr," -keep_scan_direction_change\n"); + fprintf(stderr," -keep_edge_of_flight_line\n"); + fprintf(stderr,"Filter points based on their intensity.\n"); + fprintf(stderr," -keep_intensity 20 380\n"); + fprintf(stderr," -drop_intensity_below 20\n"); + fprintf(stderr," -drop_intensity_above 380\n"); + fprintf(stderr," -drop_intensity_between 4000 5000\n"); + fprintf(stderr,"Filter points based on classifications or flags.\n"); + fprintf(stderr," -keep_class 1 3 7\n"); + fprintf(stderr," -drop_class 4 2\n"); + fprintf(stderr," -keep_extended_class 43\n"); + fprintf(stderr," -drop_extended_class 129 135\n"); + fprintf(stderr," -drop_synthetic -keep_synthetic\n"); + fprintf(stderr," -drop_keypoint -keep_keypoint\n"); + fprintf(stderr," -drop_withheld -keep_withheld\n"); + fprintf(stderr," -drop_overlap -keep_overlap\n"); + fprintf(stderr,"Filter points based on their user data.\n"); + fprintf(stderr," -keep_user_data 1\n"); + fprintf(stderr," -drop_user_data 255\n"); + fprintf(stderr," -keep_user_data_below 50\n"); + fprintf(stderr," -keep_user_data_above 150\n"); + fprintf(stderr," -keep_user_data_between 10 20\n"); + fprintf(stderr," -drop_user_data_below 1\n"); + fprintf(stderr," -drop_user_data_above 100\n"); + fprintf(stderr," -drop_user_data_between 10 40\n"); + fprintf(stderr,"Filter points based on their point source ID.\n"); + fprintf(stderr," -keep_point_source 3\n"); + fprintf(stderr," -keep_point_source_between 2 6\n"); + fprintf(stderr," -drop_point_source 27\n"); + fprintf(stderr," -drop_point_source_below 6\n"); + fprintf(stderr," -drop_point_source_above 15\n"); + fprintf(stderr," -drop_point_source_between 17 21\n"); + fprintf(stderr,"Filter points based on their scan angle.\n"); + fprintf(stderr," -keep_scan_angle -15 15\n"); + fprintf(stderr," -drop_abs_scan_angle_above 15\n"); + fprintf(stderr," -drop_abs_scan_angle_below 1\n"); + fprintf(stderr," -drop_scan_angle_below -15\n"); + fprintf(stderr," -drop_scan_angle_above 15\n"); + fprintf(stderr," -drop_scan_angle_between -25 -23\n"); + fprintf(stderr,"Filter points based on their gps time.\n"); + fprintf(stderr," -keep_gps_time 11.125 130.725\n"); + fprintf(stderr," -drop_gps_time_below 11.125\n"); + fprintf(stderr," -drop_gps_time_above 130.725\n"); + fprintf(stderr," -drop_gps_time_between 22.0 48.0\n"); + fprintf(stderr,"Filter points based on their RGB/CIR/NIR channels.\n"); + fprintf(stderr," -keep_RGB_red 1 1\n"); + fprintf(stderr," -drop_RGB_red 5000 20000\n"); + fprintf(stderr," -keep_RGB_green 30 100\n"); + fprintf(stderr," -drop_RGB_green 2000 10000\n"); + fprintf(stderr," -keep_RGB_blue 0 0\n"); + fprintf(stderr," -keep_RGB_nir 64 127\n"); + fprintf(stderr," -keep_RGB_greenness 200 65535\n"); + fprintf(stderr," -keep_NDVI 0.2 0.7 -keep_NDVI_from_CIR -0.1 0.5\n"); + fprintf(stderr," -keep_NDVI_intensity_is_NIR 0.4 0.8 -keep_NDVI_green_is_NIR -0.2 0.2\n"); + fprintf(stderr,"Filter points based on their wavepacket.\n"); + fprintf(stderr," -keep_wavepacket 0\n"); + fprintf(stderr," -drop_wavepacket 3\n"); + fprintf(stderr,"Filter points based on extra attributes.\n"); + fprintf(stderr," -keep_attribute_above 0 5.0\n"); + fprintf(stderr," -drop_attribute_below 1 1.5\n"); + fprintf(stderr,"Filter points with simple thinning.\n"); + fprintf(stderr," -keep_every_nth 2 -drop_every_nth 3\n"); + fprintf(stderr," -keep_random_fraction 0.1\n"); + fprintf(stderr," -keep_random_fraction 0.1 4711\n"); + fprintf(stderr," -thin_with_grid 1.0\n"); + fprintf(stderr," -thin_pulses_with_time 0.0001\n"); + fprintf(stderr," -thin_points_with_time 0.000001\n"); + fprintf(stderr,"Boolean combination of filters.\n"); + fprintf(stderr," -filter_and\n"); } BOOL LASfilter::parse(int argc, char* argv[]) @@ -1787,53 +1745,6 @@ BOOL LASfilter::parse(int argc, char* argv[]) usage(); return TRUE; } - else if (strncmp(argv[i],"-clip_", 6) == 0) - { - if (strcmp(argv[i], "-clip_z_below") == 0) - { - REprintf("WARNING: '%s' will not be supported in the future. check documentation with '-h'.\n", argv[i]); - REprintf(" rename '-clip_z_below' to '-drop_z_below'.\n"); - REprintf(" rename '-clip_z_above' to '-drop_z_above'.\n"); - REprintf(" rename '-clip_z_between' to '-drop_z'.\n"); - REprintf(" rename '-clip' to '-keep_xy'.\n"); - REprintf(" rename '-clip_tile' to '-keep_tile'.\n"); - if ((i+1) >= argc) - { - REprintf("ERROR: '%s' needs 1 argument: max_z\n", argv[i]); - return FALSE; - } - add_criterion(new LAScriterionDropzBelow(atof(argv[i+1]))); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; - } - else if (strcmp(argv[i], "-clip_z_above") == 0) - { - REprintf("WARNING: '%s' will not be supported in the future. check documentation with '-h'.\n", argv[i]); - REprintf(" rename '-clip_z_below' to '-drop_z_below'.\n"); - REprintf(" rename '-clip_z_above' to '-drop_z_above'.\n"); - REprintf(" rename '-clip_z_between' to '-drop_z'.\n"); - REprintf(" rename '-clip' to '-keep_xy'.\n"); - REprintf(" rename '-clip_tile' to '-keep_tile'.\n"); - if ((i+1) >= argc) - { - REprintf("ERROR: '%s' needs 1 argument: max_z\n", argv[i]); - return FALSE; - } - add_criterion(new LAScriterionDropzAbove(atof(argv[i+1]))); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; - } - else if ((strcmp(argv[i], "-clip_to_bounding_box") != 0) && (strcmp(argv[i],"-clip_to_bb") != 0)) - { - REprintf("ERROR: '%s' is no longer recognized. check documentation with '-h'.\n", argv[i]); - REprintf(" rename '-clip' to '-keep_xy'.\n"); - REprintf(" rename '-clip_box' to '-keep_xyz'.\n"); - REprintf(" rename '-clip_tile' to '-keep_tile'.\n"); - REprintf(" rename '-clip_z_below' to '-drop_z_below'.\n"); - REprintf(" rename '-clip_z_above' to '-drop_z_above'.\n"); - REprintf(" rename '-clip_z_between' to '-drop_z'.\n"); - REprintf(" etc ...\n"); - return FALSE; - } - } else if (strncmp(argv[i],"-keep_", 6) == 0) { if (strncmp(argv[i],"-keep_first", 11) == 0) @@ -1878,9 +1789,10 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs at least 1 argument: classification\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs at least 1 argument: classification\n", argv[i]); return FALSE; } + int i_in = i; *argv[i]='\0'; i+=1; U32 classification; @@ -1889,12 +1801,12 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if (sscanf(argv[i], "%u", &classification) != 1) { - REprintf("ERROR: '-keep_classification' needs at least 1 argument: classification but '%s' is no valid classification\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs at least 1 argument: classification but '%s' is no valid classification\n", argv[i_in], argv[i]); return FALSE; } if (classification > 31) { - REprintf("ERROR: cannot keep classification %u because it is larger than 31\n", classification); + fprintf(stderr,"ERROR: '%s' needs arguments between 0 and 31 but '%u' is out of range\n", argv[i_in], classification); return FALSE; } keep_classification_mask |= (1u << classification); @@ -1916,13 +1828,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: mask\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: mask\n", argv[i]); return FALSE; } U32 keep_classification_mask; if (sscanf(argv[i+1], "%u", &keep_classification_mask) != 1) { - REprintf("ERROR: '%s' needs at least 1 argument: mask but '%s' is no valid mask\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs at least 1 argument: mask but '%s' is no valid mask\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionKeepClassifications(keep_classification_mask)); @@ -1935,7 +1847,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs at least a argument: classification\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs at least a argument: classification\n", argv[i]); return FALSE; } *argv[i]='\0'; @@ -1945,12 +1857,12 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if (sscanf(argv[i], "%u", &extended_classification) != 1) { - REprintf("ERROR: '-keep_extended_classification' needs at least 1 argument: classification but '%s' is no valid classification\n", argv[i]); + fprintf(stderr,"ERROR: '-keep_extended_classification' needs at least 1 argument: classification but '%s' is no valid classification\n", argv[i]); return FALSE; } if (extended_classification > 255) { - REprintf("ERROR: cannot keep extended classification %u because it is larger than 255\n", extended_classification); + fprintf(stderr,"ERROR: cannot keep extended classification %u because it is larger than 255\n", extended_classification); return FALSE; } keep_extended_classification_mask[extended_classification/32] |= (1u << (extended_classification%32)); @@ -1966,99 +1878,99 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+4) >= argc) { - REprintf("ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y\n", argv[i]); return FALSE; } F64 min_x; if (sscanf(argv[i+1], "%lf", &min_x) != 1) { - REprintf("ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid min_x\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid min_x\n", argv[i], argv[i+1]); return FALSE; } F64 min_y; if (sscanf(argv[i+2], "%lf", &min_y) != 1) { - REprintf("ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid min_y\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid min_y\n", argv[i], argv[i+2]); return FALSE; } F64 max_x; if (sscanf(argv[i+3], "%lf", &max_x) != 1) { - REprintf("ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid max_x\n", argv[i], argv[i+3]); + fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid max_x\n", argv[i], argv[i+3]); return FALSE; } F64 max_y; if (sscanf(argv[i+4], "%lf", &max_y) != 1) { - REprintf("ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid max_y\n", argv[i], argv[i+4]); + fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid max_y\n", argv[i], argv[i+4]); return FALSE; } add_criterion(new LAScriterionKeepxy(min_x, min_y, max_x, max_y)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; i+=4; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; i+=4; } else if (strcmp(argv[i],"-keep_xyz") == 0) { if ((i+6) >= argc) { - REprintf("ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z\n", argv[i]); return FALSE; } F64 min_x; if (sscanf(argv[i+1], "%lf", &min_x) != 1) { - REprintf("ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid min_x\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid min_x\n", argv[i], argv[i+1]); return FALSE; } F64 min_y; if (sscanf(argv[i+2], "%lf", &min_y) != 1) { - REprintf("ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid min_y\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid min_y\n", argv[i], argv[i+2]); return FALSE; } F64 min_z; if (sscanf(argv[i+3], "%lf", &min_z) != 1) { - REprintf("ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid min_z\n", argv[i], argv[i+3]); + fprintf(stderr,"ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid min_z\n", argv[i], argv[i+3]); return FALSE; } F64 max_x; if (sscanf(argv[i+4], "%lf", &max_x) != 1) { - REprintf("ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid max_x\n", argv[i], argv[i+4]); + fprintf(stderr,"ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid max_x\n", argv[i], argv[i+4]); return FALSE; } F64 max_y; if (sscanf(argv[i+5], "%lf", &max_y) != 1) { - REprintf("ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid max_y\n", argv[i], argv[i+5]); + fprintf(stderr,"ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid max_y\n", argv[i], argv[i+5]); return FALSE; } F64 max_z; if (sscanf(argv[i+6], "%lf", &max_z) != 1) { - REprintf("ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid max_z\n", argv[i], argv[i+6]); + fprintf(stderr,"ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid max_z\n", argv[i], argv[i+6]); return FALSE; } add_criterion(new LAScriterionKeepxyz(min_x, min_y, min_z, max_x, max_y, max_z)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; *argv[i+5]='\0'; *argv[i+6]='\0'; i+=6; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; *argv[i+5]='\0'; *argv[i+6]='\0'; i+=6; } else if (strcmp(argv[i],"-keep_x") == 0) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: min_x max_x\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_x max_x\n", argv[i]); return FALSE; } F64 min_x; if (sscanf(argv[i+1], "%lf", &min_x) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min_x max_x but '%s' is no valid min_x\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_x max_x but '%s' is no valid min_x\n", argv[i], argv[i+1]); return FALSE; } F64 max_x; if (sscanf(argv[i+2], "%lf", &max_x) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min_x max_x but '%s' is no valid max_x\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_x max_x but '%s' is no valid max_x\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionKeepx(min_x, max_x)); @@ -2069,19 +1981,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: min_y max_y\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_y max_y\n", argv[i]); return FALSE; } F64 min_y; if (sscanf(argv[i+1], "%lf", &min_y) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min_y max_y but '%s' is no valid min_y\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_y max_y but '%s' is no valid min_y\n", argv[i], argv[i+1]); return FALSE; } F64 max_y; if (sscanf(argv[i+2], "%lf", &max_y) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min_y max_y but '%s' is no valid max_y\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_y max_y but '%s' is no valid max_y\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionKeepy(min_y, max_y)); @@ -2093,19 +2005,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: min_z max_z\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_z max_z\n", argv[i]); return FALSE; } F64 min_z; if (sscanf(argv[i+1], "%lf", &min_z) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min_z max_z but '%s' is no valid min_z\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_z max_z but '%s' is no valid min_z\n", argv[i], argv[i+1]); return FALSE; } F64 max_z; if (sscanf(argv[i+2], "%lf", &max_z) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min_z max_z but '%s' is no valid max_z\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_z max_z but '%s' is no valid max_z\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionKeepz(min_z, max_z)); @@ -2115,13 +2027,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: min_z\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: min_z\n", argv[i]); return FALSE; } F64 min_z; if (sscanf(argv[i+1], "%lf", &min_z) != 1) { - REprintf("ERROR: '%s' needs 1 argument: min_z but '%s' is no valid min_z\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: min_z but '%s' is no valid min_z\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropzBelow(min_z)); @@ -2131,13 +2043,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: max_z\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: max_z\n", argv[i]); return FALSE; } F64 max_z; if (sscanf(argv[i+1], "%lf", &max_z) != 1) { - REprintf("ERROR: '%s' needs 1 argument: max_z but '%s' is no valid max_z\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: max_z but '%s' is no valid max_z\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropzAbove(max_z)); @@ -2150,80 +2062,80 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+4) >= argc) { - REprintf("ERROR: '%s' needs 4 arguments: min_X min_Y max_X max_Y\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_X min_Y max_X max_Y\n", argv[i]); return FALSE; } I32 min_X; if (sscanf(argv[i+1], "%d", &min_X) != 1) { - REprintf("ERROR: '%s' needs 4 arguments: min_X min_Y max_X max_Y but '%s' is no valid min_X\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_X min_Y max_X max_Y but '%s' is no valid min_X\n", argv[i], argv[i+1]); return FALSE; } I32 min_Y; if (sscanf(argv[i+2], "%d", &min_Y) != 1) { - REprintf("ERROR: '%s' needs 4 arguments: min_X min_Y max_X max_Y but '%s' is no valid min_Y\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_X min_Y max_X max_Y but '%s' is no valid min_Y\n", argv[i], argv[i+2]); return FALSE; } I32 max_X; if (sscanf(argv[i+3], "%d", &max_X) != 1) { - REprintf("ERROR: '%s' needs 4 arguments: min_X min_Y max_X max_Y but '%s' is no valid max_X\n", argv[i], argv[i+3]); + fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_X min_Y max_X max_Y but '%s' is no valid max_X\n", argv[i], argv[i+3]); return FALSE; } I32 max_Y; if (sscanf(argv[i+4], "%d", &max_Y) != 1) { - REprintf("ERROR: '%s' needs 4 arguments: min_X min_Y max_X max_Y but '%s' is no valid max_Y\n", argv[i], argv[i+4]); + fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_X min_Y max_X max_Y but '%s' is no valid max_Y\n", argv[i], argv[i+4]); return FALSE; } add_criterion(new LAScriterionKeepXY(min_X, min_Y, max_X, max_Y)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; i+=4; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; i+=4; } else if (strcmp(argv[i],"-keep_X") == 0) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: min_X max_X\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_X max_X\n", argv[i]); return FALSE; } I32 min_X; if (sscanf(argv[i+1], "%d", &min_X) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min_X max_X but '%s' is no valid min_X\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_X max_X but '%s' is no valid min_X\n", argv[i], argv[i+1]); return FALSE; } I32 max_X; if (sscanf(argv[i+2], "%d", &max_X) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min_X max_X but '%s' is no valid max_X\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_X max_X but '%s' is no valid max_X\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionKeepX(min_X, max_X)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } } else if (strcmp(argv[i],"-keep_Y") == 0) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: min_Y max_Y\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_Y max_Y\n", argv[i]); return FALSE; } I32 min_Y; if (sscanf(argv[i+1], "%d", &min_Y) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min_Y max_Y but '%s' is no valid min_Y\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_Y max_Y but '%s' is no valid min_Y\n", argv[i], argv[i+1]); return FALSE; } I32 max_Y; if (sscanf(argv[i+2], "%d", &max_Y) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min_Y max_Y but '%s' is no valid max_Y\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_Y max_Y but '%s' is no valid max_Y\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionKeepY(min_Y, max_Y)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strncmp(argv[i],"-keep_Z", 7) == 0) { @@ -2231,35 +2143,35 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: min_Z max_Z\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_Z max_Z\n", argv[i]); return FALSE; } I32 min_Z; if (sscanf(argv[i+1], "%d", &min_Z) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min_Z max_Z but '%s' is no valid min_Z\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_Z max_Z but '%s' is no valid min_Z\n", argv[i], argv[i+1]); return FALSE; } I32 max_Z; if (sscanf(argv[i+2], "%d", &max_Z) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min_Z max_Z but '%s' is no valid max_Z\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_Z max_Z but '%s' is no valid max_Z\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionKeepZ(min_Z, max_Z)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-keep_Z_above") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: min_Z\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: min_Z\n", argv[i]); return FALSE; } I32 min_Z; if (sscanf(argv[i+1], "%d", &min_Z) != 1) { - REprintf("ERROR: '%s' needs 1 argument: min_Z but '%s' is no valid min_Z\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: min_Z but '%s' is no valid min_Z\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropZBelow(min_Z)); @@ -2269,13 +2181,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: max_Z\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: max_Z\n", argv[i]); return FALSE; } I32 max_Z; if (sscanf(argv[i+1], "%d", &max_Z) != 1) { - REprintf("ERROR: '%s' needs 1 argument: max_Z but '%s' is no valid max_Z\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: max_Z but '%s' is no valid max_Z\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropZAbove(max_Z)); @@ -2286,53 +2198,53 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+3) >= argc) { - REprintf("ERROR: '%s' needs 3 arguments: llx lly size\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: llx lly size\n", argv[i]); return FALSE; } F32 llx; if (sscanf(argv[i+1], "%f", &llx) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: llx lly size but '%s' is no valid llx\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: llx lly size but '%s' is no valid llx\n", argv[i], argv[i+1]); return FALSE; } F32 lly; if (sscanf(argv[i+2], "%f", &lly) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: llx lly size but '%s' is no valid lly\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: llx lly size but '%s' is no valid lly\n", argv[i], argv[i+2]); return FALSE; } F32 size; if (sscanf(argv[i+3], "%f", &size) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: llx lly size but '%s' is no valid size\n", argv[i], argv[i+3]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: llx lly size but '%s' is no valid size\n", argv[i], argv[i+3]); return FALSE; } add_criterion(new LAScriterionKeepTile(llx, lly, size)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } else if (strcmp(argv[i],"-keep_circle") == 0) { if ((i+3) >= argc) { - REprintf("ERROR: '%s' needs 3 arguments: center_x center_y radius\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: center_x center_y radius\n", argv[i]); return FALSE; } F64 center_x; if (sscanf(argv[i+1], "%lf", ¢er_x) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: center_x center_y radius but '%s' is no valid center_x\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: center_x center_y radius but '%s' is no valid center_x\n", argv[i], argv[i+1]); return FALSE; } F64 center_y; if (sscanf(argv[i+2], "%lf", ¢er_y) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: center_x center_y radius but '%s' is no valid center_y\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: center_x center_y radius but '%s' is no valid center_y\n", argv[i], argv[i+2]); return FALSE; } F64 radius; if (sscanf(argv[i+3], "%lf", &radius) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: center_x center_y radius but '%s' is no valid radius\n", argv[i], argv[i+3]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: center_x center_y radius but '%s' is no valid radius\n", argv[i], argv[i+3]); return FALSE; } add_criterion(new LAScriterionKeepCircle(center_x, center_y, radius)); @@ -2344,7 +2256,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs at least 1 argument: return_number\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs at least 1 argument: return_number\n", argv[i]); return FALSE; } *argv[i]='\0'; @@ -2355,12 +2267,12 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if (sscanf(argv[i], "%u", &return_number) != 1) { - REprintf("ERROR: '-keep_return' needs at least 1 argument: return_number but '%s' is no valid return_number\n", argv[i]); + fprintf(stderr,"ERROR: '-keep_return' needs at least 1 argument: return_number but '%s' is no valid return_number\n", argv[i]); return FALSE; } if (return_number > 15) { - REprintf("ERROR: cannot keep return_number %u because it is larger than 15\n", return_number); + fprintf(stderr,"ERROR: cannot keep return_number %u because it is larger than 15\n", return_number); return FALSE; } keep_return_mask |= (1u << return_number); @@ -2382,18 +2294,18 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: return_mask\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: return_mask\n", argv[i]); return FALSE; } U32 keep_return_mask; if (sscanf(argv[i+1], "%u", &keep_return_mask) != 1) { - REprintf("ERROR: '%s' needs 1 argument: return_mask but '%s' is no valid return_mask\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: return_mask but '%s' is no valid return_mask\n", argv[i], argv[i+1]); return FALSE; } if (keep_return_mask > U16_MAX) { - REprintf("ERROR: '%s' needs a return_mask between 0 and %u but return_mask is %u\n", argv[i], U16_MAX, keep_return_mask); + fprintf(stderr,"ERROR: '%s' needs a return_mask between 0 and %u but return_mask is %u\n", argv[i], U16_MAX, keep_return_mask); return FALSE; } add_criterion(new LAScriterionKeepReturns((U16)keep_return_mask)); @@ -2404,13 +2316,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: number_of_returns\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: number_of_returns\n", argv[i]); return FALSE; } U32 number_of_returns; if (sscanf(argv[i+1], "%u", &number_of_returns) != 1) { - REprintf("ERROR: '%s' needs 1 argument: number_of_returns but '%s' is no valid number_of_returns\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: number_of_returns but '%s' is no valid number_of_returns\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionKeepSpecificNumberOfReturns(number_of_returns)); @@ -2447,29 +2359,29 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: min max\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max\n", argv[i]); return FALSE; } U32 min; if (sscanf(argv[i+1], "%u", &min) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); return FALSE; } U32 max; if (sscanf(argv[i+2], "%u", &max) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); return FALSE; } if (min > U16_MAX) { - REprintf("ERROR: cannot keep intensity because min of %u is larger than %u\n", min, U16_MAX); + fprintf(stderr,"ERROR: cannot keep intensity because min of %u is larger than %u\n", min, U16_MAX); return FALSE; } if (max > U16_MAX) { - REprintf("ERROR: cannot keep intensity because max of %u is larger than %u\n", max, U16_MAX); + fprintf(stderr,"ERROR: cannot keep intensity because max of %u is larger than %u\n", max, U16_MAX); return FALSE; } add_criterion(new LAScriterionKeepIntensity((U16)min, (U16)max)); @@ -2479,18 +2391,18 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: max\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: max\n", argv[i]); return FALSE; } U32 max; if (sscanf(argv[i+1], "%u", &max) != 1) { - REprintf("ERROR: '%s' needs 1 argument: max but '%s' is no valid max\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: max but '%s' is no valid max\n", argv[i], argv[i+1]); return FALSE; } if (max > U16_MAX) { - REprintf("ERROR: cannot keep intensity above max of %u because it is larger than %u\n", max, U16_MAX); + fprintf(stderr,"ERROR: cannot keep intensity above max of %u because it is larger than %u\n", max, U16_MAX); return FALSE; } add_criterion(new LAScriterionKeepIntensityAbove((U16)max)); @@ -2500,18 +2412,18 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: min\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: min\n", argv[i]); return FALSE; } U32 min; if (sscanf(argv[i+1], "%u", &min) != 1) { - REprintf("ERROR: '%s' needs 1 argument: min but '%s' is no valid min\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: min but '%s' is no valid min\n", argv[i], argv[i+1]); return FALSE; } if (min > U16_MAX) { - REprintf("ERROR: cannot keep intensity below min of %u because it is larger than %u\n", min, U16_MAX); + fprintf(stderr,"ERROR: cannot keep intensity below min of %u because it is larger than %u\n", min, U16_MAX); return FALSE; } add_criterion(new LAScriterionKeepIntensityBelow((U16)min)); @@ -2522,19 +2434,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: min max\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max\n", argv[i]); return FALSE; } I32 min; if (sscanf(argv[i+1], "%d", &min) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); return FALSE; } I32 max; if (sscanf(argv[i+2], "%d", &max) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); return FALSE; } if (strcmp(argv[i]+10,"red") == 0) @@ -2557,24 +2469,29 @@ BOOL LASfilter::parse(int argc, char* argv[]) add_criterion(new LAScriterionKeepRGB(min, max, 3)); *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } + else if (strcmp(argv[i]+10,"greenness") == 0) + { + add_criterion(new LAScriterionKeepRGBgreenness(min, max)); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + } } else if (strncmp(argv[i],"-keep_NDVI", 10) == 0) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: min max\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max\n", argv[i]); return FALSE; } F32 min; if (sscanf(argv[i+1], "%f", &min) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); return FALSE; } F32 max; if (sscanf(argv[i+2], "%f", &max) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); return FALSE; } if (strcmp(argv[i]+10,"") == 0) @@ -2609,19 +2526,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: min max\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max\n", argv[i]); return FALSE; } I32 min; if (sscanf(argv[i+1], "%d", &min) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); return FALSE; } I32 max; if (sscanf(argv[i+2], "%d", &max) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionKeepScanAngle(min, max)); @@ -2652,7 +2569,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: index\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: index\n", argv[i]); return FALSE; } *argv[i]='\0'; @@ -2666,13 +2583,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: value\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: value\n", argv[i]); return FALSE; } I32 value; if (sscanf(argv[i+1], "%d", &value) != 1) { - REprintf("ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionKeepUserData(value)); @@ -2682,13 +2599,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: value\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: value\n", argv[i]); return FALSE; } I32 value; if (sscanf(argv[i+1], "%d", &value) != 1) { - REprintf("ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionKeepUserDataBelow(value)); @@ -2698,13 +2615,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: value\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: value\n", argv[i]); return FALSE; } I32 value; if (sscanf(argv[i+1], "%d", &value) != 1) { - REprintf("ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionKeepUserDataAbove(value)); @@ -2714,19 +2631,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: min max\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max\n", argv[i]); return FALSE; } I32 min; if (sscanf(argv[i+1], "%d", &min) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); return FALSE; } I32 max; if (sscanf(argv[i+2], "%d", &max) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionKeepUserDataBetween(min, max)); @@ -2739,32 +2656,32 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs at least 1 argument: ID\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs at least 1 argument: ID\n", argv[i]); return FALSE; } U32 ID; if (sscanf(argv[i+1], "%u", &ID) != 1) { - REprintf("ERROR: '%s' needs at least 1 argument: ID but '%s' is no valid ID\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs at least 1 argument: ID but '%s' is no valid ID\n", argv[i], argv[i+1]); return FALSE; } if (ID > U16_MAX) { - REprintf("ERROR: cannot keep_point_source ID %u because it is larger than %u\n", ID, U16_MAX); + fprintf(stderr,"ERROR: cannot keep_point_source ID %u because it is larger than %u\n", ID, U16_MAX); return FALSE; } add_criterion(new LAScriterionKeepPointSource(ID)); while (((i+2) < argc) && ('0' <= argv[i+2][0]) && (argv[i+2][0] <= '9')) { *argv[i]='\0'; - if (sscanf(argv[i+2], "%u", &ID) != 1) + if (sscanf(argv[i+2], "%d", &ID) != 1) { - REprintf("ERROR: '-keep_point_source' takes one or more IDs but '%s' is no valid ID\n", argv[i+2]); + fprintf(stderr,"ERROR: '-keep_point_source' takes one or more IDs but '%s' is no valid ID\n", argv[i+2]); return FALSE; } if (ID > U16_MAX) { - REprintf("ERROR: cannot keep_point_source ID %u because it is larger than %u\n", ID, U16_MAX); + fprintf(stderr,"ERROR: cannot keep_point_source ID %u because it is larger than %u\n", ID, U16_MAX); return FALSE; } add_criterion(new LAScriterionKeepPointSource(ID)); @@ -2775,36 +2692,36 @@ BOOL LASfilter::parse(int argc, char* argv[]) criteria[num_criteria] = 0; add_criterion(filter_criterion); i+=1; - } + } *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-keep_point_source_between") == 0) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: min_ID max_ID\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_ID max_ID\n", argv[i]); return FALSE; } U32 min_ID; if (sscanf(argv[i+1], "%u", &min_ID) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min_ID max_ID but '%s' is no valid min_ID\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_ID max_ID but '%s' is no valid min_ID\n", argv[i], argv[i+1]); return FALSE; } U32 max_ID; if (sscanf(argv[i+2], "%u", &max_ID) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min_ID max_ID but '%s' is no valid max_ID\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_ID max_ID but '%s' is no valid max_ID\n", argv[i], argv[i+2]); return FALSE; } if (min_ID > U16_MAX) { - REprintf("ERROR: cannot keep point source because min_ID of %u is larger than %u\n", min_ID, U16_MAX); + fprintf(stderr,"ERROR: cannot keep point source because min_ID of %u is larger than %u\n", min_ID, U16_MAX); return FALSE; } if (max_ID > U16_MAX) { - REprintf("ERROR: cannot keep point source because max_ID of %u is larger than %u\n", max_ID, U16_MAX); + fprintf(stderr,"ERROR: cannot keep point source because max_ID of %u is larger than %u\n", max_ID, U16_MAX); return FALSE; } add_criterion(new LAScriterionKeepPointSourceBetween((U16)min_ID, (U16)max_ID)); @@ -2817,19 +2734,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: start end\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: start end\n", argv[i]); return FALSE; } F64 start = 0.0; if (sscanf(argv[i+1], "%lf", &start) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: start end but '%s' is no valid start\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: start end but '%s' is no valid start\n", argv[i], argv[i+1]); return FALSE; } F64 end = 0.0; if (sscanf(argv[i+2], "%lf", &end) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: start end but '%s' is no valid end\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: start end but '%s' is no valid end\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionKeepGpsTime(start, end)); @@ -2839,13 +2756,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: time\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: time\n", argv[i]); return FALSE; } F64 time = 0.0; if (sscanf(argv[i+1], "%lf", &time) != 1) { - REprintf("ERROR: '%s' needs 1 argument: time but '%s' is no valid time\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: time but '%s' is no valid time\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropGpsTimeBelow(time)); @@ -2855,13 +2772,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: time\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: time\n", argv[i]); return FALSE; } F64 time = 0.0; if (sscanf(argv[i+1], "%lf", &time) != 1) { - REprintf("ERROR: '%s' needs 1 argument: time but '%s' is no valid time\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: time but '%s' is no valid time\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropGpsTimeAbove(time)); @@ -2874,19 +2791,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: index value\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value\n", argv[i]); return FALSE; } I32 index; if (sscanf(argv[i+1], "%d", &index) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: index value but '%s' is no valid index\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } F64 value; if (sscanf(argv[i+2], "%lf", &value) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid value\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid value\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionKeepAttributeBelow(index, value)); @@ -2896,19 +2813,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: index value\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value\n", argv[i]); return FALSE; } I32 index; if (sscanf(argv[i+1], "%d", &index) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: index value but '%s' is no valid index\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } F64 value; if (sscanf(argv[i+2], "%lf", &value) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid value\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid value\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionKeepAttributeAbove(index, value)); @@ -2918,25 +2835,25 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+3) >= argc) { - REprintf("ERROR: '%s' needs 3 arguments: index min max\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: index min max\n", argv[i]); return FALSE; } I32 index; if (sscanf(argv[i+1], "%d", &index) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: index min max but '%s' is no valid index\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: index min max but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } F64 min; if (sscanf(argv[i+2], "%lf", &min) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: index min max but '%s' is no valid min\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: index min max but '%s' is no valid min\n", argv[i], argv[i+2]); return FALSE; } F64 max; if (sscanf(argv[i+3], "%lf", &max) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: index min max but '%s' is no valid max\n", argv[i], argv[i+3]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: index min max but '%s' is no valid max\n", argv[i], argv[i+3]); return FALSE; } add_criterion(new LAScriterionKeepAttributeBetween(index, min, max)); @@ -2947,18 +2864,18 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: nth\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: nth\n", argv[i]); return FALSE; } U32 nth; if (sscanf(argv[i+1], "%u", &nth) != 1) { - REprintf("ERROR: '%s' needs 1 argument: nth but '%s' is no valid nth\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: nth but '%s' is no valid nth\n", argv[i], argv[i+1]); return FALSE; } if (nth == 0) { - REprintf("ERROR: %u is no valid nth for '%s'\n", nth, argv[i]); + fprintf(stderr,"ERROR: %u is no valid nth for '%s'\n", nth, argv[i]); return FALSE; } add_criterion(new LAScriterionKeepEveryNth(nth)); @@ -2968,13 +2885,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: fraction\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: fraction\n", argv[i]); return FALSE; } F32 fraction; if (sscanf(argv[i+1], "%f", &fraction) != 1) { - REprintf("ERROR: '%s' needs at least 1 argument: fraction [seed] but '%s' is no valid fraction\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs at least 1 argument: fraction [seed] but '%s' is no valid fraction\n", argv[i], argv[i+1]); return FALSE; } if (((i+2) < argc) && ('0' <= argv[i+2][0]) && (argv[i+2][0] <= '9')) // maybe a seed was specified @@ -2982,7 +2899,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) U32 seed; if (sscanf(argv[i+2], "%u", &seed) != 1) { - REprintf("ERROR: '%s' takes seed as second argument but '%s' is no valid seed\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' takes seed as second argument but '%s' is no valid seed\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionKeepRandomFraction(seed, fraction)); @@ -3008,18 +2925,18 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: number\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: number\n", argv[i]); return FALSE; } I32 number; if (sscanf(argv[i+1], "%d", &number) != 1) { - REprintf("ERROR: '%s' needs 1 argument: number but '%s' is no valid number\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: number but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } if ((number < 0) || (number > 3)) { - REprintf("ERROR: '%s' needs 1 argument: number between 0 and 3 so '%s' is not valid\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: number between 0 and 3 so '%s' is not valid\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionKeepScannerChannel(number)); @@ -3070,7 +2987,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs at least 1 argument: classification\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs at least 1 argument: classification\n", argv[i]); return FALSE; } *argv[i]='\0'; @@ -3081,12 +2998,12 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if (sscanf(argv[i], "%u", &classification) != 1) { - REprintf("ERROR: '-drop_classification' needs at least 1 argument: classification but '%s' is no valid classification\n", argv[i]); + fprintf(stderr,"ERROR: '-drop_classification' needs at least 1 argument: classification but '%s' is no valid classification\n", argv[i]); return FALSE; } if (classification > 31) { - REprintf("ERROR: cannot drop classification %u because it is larger than 31\n", classification); + fprintf(stderr,"ERROR: cannot drop classification %u because it is larger than 31\n", classification); return FALSE; } drop_classification_mask |= (1u << classification); @@ -3108,13 +3025,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: mask\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: mask\n", argv[i]); return FALSE; } U32 drop_classification_mask; if (sscanf(argv[i+1], "%u", &drop_classification_mask) != 1) { - REprintf("ERROR: '%s' needs at least 1 argument: mask but '%s' is no valid mask\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs at least 1 argument: mask but '%s' is no valid mask\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropClassifications(drop_classification_mask)); @@ -3127,7 +3044,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs at least 1 argument: classification\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs at least 1 argument: classification\n", argv[i]); return FALSE; } *argv[i]='\0'; @@ -3137,12 +3054,12 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if (sscanf(argv[i], "%u", &extended_classification) != 1) { - REprintf("ERROR: '-drop_extended_classification' needs at least 1 argument: classification but '%s' is no valid classification\n", argv[i]); + fprintf(stderr,"ERROR: '-drop_extended_classification' needs at least 1 argument: classification but '%s' is no valid classification\n", argv[i]); return FALSE; } if (extended_classification > 255) { - REprintf("ERROR: cannot drop extended classification %u because it is larger than 255\n", extended_classification); + fprintf(stderr,"ERROR: cannot drop extended classification %u because it is larger than 255\n", extended_classification); return FALSE; } drop_extended_classification_mask[extended_classification/32] |= (1u << (extended_classification%32)); @@ -3155,17 +3072,57 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+8) >= argc) { - REprintf("ERROR: '%s' needs 8 arguments: mask7 mask6 mask5 mask4 mask3 mask2 mask1 mask0\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 8 arguments: mask7 mask6 mask5 mask4 mask3 mask2 mask1 mask0\n", argv[i]); + return FALSE; + } + if (sscanf(argv[i+1], "%u", &(drop_extended_classification_mask[7])) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 8 arguments: mask7 mask6 mask5 mask4 mask3 mask2 mask1 mask0\n", argv[i]); + fprintf(stderr," but '%s' is a bad argument for mask7\n", argv[i+1]); + return FALSE; + } + if (sscanf(argv[i+2], "%u", &(drop_extended_classification_mask[6])) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 8 arguments: mask7 mask6 mask5 mask4 mask3 mask2 mask1 mask0\n", argv[i]); + fprintf(stderr," but '%s' is a bad argument for mask6\n", argv[i+2]); + return FALSE; + } + if (sscanf(argv[i+3], "%u", &(drop_extended_classification_mask[5])) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 8 arguments: mask7 mask6 mask5 mask4 mask3 mask2 mask1 mask0\n", argv[i]); + fprintf(stderr," but '%s' is a bad argument for mask5\n", argv[i+3]); + return FALSE; + } + if (sscanf(argv[i+4], "%u", &(drop_extended_classification_mask[4])) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 8 arguments: mask7 mask6 mask5 mask4 mask3 mask2 mask1 mask0\n", argv[i]); + fprintf(stderr," but '%s' is a bad argument for mask4\n", argv[i+4]); + return FALSE; + } + if (sscanf(argv[i+5], "%u", &(drop_extended_classification_mask[3])) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 8 arguments: mask7 mask6 mask5 mask4 mask3 mask2 mask1 mask0\n", argv[i]); + fprintf(stderr," but '%s' is a bad argument for mask3\n", argv[i+5]); + return FALSE; + } + if (sscanf(argv[i+6], "%u", &(drop_extended_classification_mask[2])) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 8 arguments: mask7 mask6 mask5 mask4 mask3 mask2 mask1 mask0\n", argv[i]); + fprintf(stderr," but '%s' is a bad argument for mask2\n", argv[i+6]); + return FALSE; + } + if (sscanf(argv[i+7], "%u", &(drop_extended_classification_mask[1])) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 8 arguments: mask7 mask6 mask5 mask4 mask3 mask2 mask1 mask0\n", argv[i]); + fprintf(stderr," but '%s' is a bad argument for mask1\n", argv[i+7]); + return FALSE; + } + if (sscanf(argv[i+8], "%u", &(drop_extended_classification_mask[0])) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 8 arguments: mask7 mask6 mask5 mask4 mask3 mask2 mask1 mask0\n", argv[i]); + fprintf(stderr," but '%s' is a bad argument for mask0\n", argv[i+8]); return FALSE; } - drop_extended_classification_mask[7] = atoi(argv[i+1]); - drop_extended_classification_mask[6] = atoi(argv[i+2]); - drop_extended_classification_mask[5] = atoi(argv[i+3]); - drop_extended_classification_mask[4] = atoi(argv[i+4]); - drop_extended_classification_mask[3] = atoi(argv[i+5]); - drop_extended_classification_mask[2] = atoi(argv[i+6]); - drop_extended_classification_mask[1] = atoi(argv[i+7]); - drop_extended_classification_mask[0] = atoi(argv[i+8]); *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; *argv[i+5]='\0'; *argv[i+6]='\0'; *argv[i+7]='\0'; *argv[i+8]='\0'; i+=8; } } @@ -3175,99 +3132,99 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+4) >= argc) { - REprintf("ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y\n", argv[i]); return FALSE; } F64 min_x; if (sscanf(argv[i+1], "%lf", &min_x) != 1) { - REprintf("ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid min_x\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid min_x\n", argv[i], argv[i+1]); return FALSE; } F64 min_y; if (sscanf(argv[i+2], "%lf", &min_y) != 1) { - REprintf("ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid min_y\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid min_y\n", argv[i], argv[i+2]); return FALSE; } F64 max_x; if (sscanf(argv[i+3], "%lf", &max_x) != 1) { - REprintf("ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid max_x\n", argv[i], argv[i+3]); + fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid max_x\n", argv[i], argv[i+3]); return FALSE; } F64 max_y; if (sscanf(argv[i+4], "%lf", &max_y) != 1) { - REprintf("ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid max_y\n", argv[i], argv[i+4]); + fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid max_y\n", argv[i], argv[i+4]); return FALSE; } add_criterion(new LAScriterionDropxy(min_x, min_y, max_x, max_y)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; i+=4; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; i+=4; } else if (strcmp(argv[i],"-drop_xyz") == 0) { if ((i+6) >= argc) { - REprintf("ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z\n", argv[i]); return FALSE; } F64 min_x; if (sscanf(argv[i+1], "%lf", &min_x) != 1) { - REprintf("ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid min_x\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid min_x\n", argv[i], argv[i+1]); return FALSE; } F64 min_y; if (sscanf(argv[i+2], "%lf", &min_y) != 1) { - REprintf("ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid min_y\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid min_y\n", argv[i], argv[i+2]); return FALSE; } F64 min_z; if (sscanf(argv[i+3], "%lf", &min_z) != 1) { - REprintf("ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid min_z\n", argv[i], argv[i+3]); + fprintf(stderr,"ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid min_z\n", argv[i], argv[i+3]); return FALSE; } F64 max_x; if (sscanf(argv[i+4], "%lf", &max_x) != 1) { - REprintf("ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid max_x\n", argv[i], argv[i+4]); + fprintf(stderr,"ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid max_x\n", argv[i], argv[i+4]); return FALSE; } F64 max_y; if (sscanf(argv[i+5], "%lf", &max_y) != 1) { - REprintf("ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid max_y\n", argv[i], argv[i+5]); + fprintf(stderr,"ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid max_y\n", argv[i], argv[i+5]); return FALSE; } F64 max_z; if (sscanf(argv[i+6], "%lf", &max_z) != 1) { - REprintf("ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid max_z\n", argv[i], argv[i+6]); + fprintf(stderr,"ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid max_z\n", argv[i], argv[i+6]); return FALSE; } add_criterion(new LAScriterionDropxyz(min_x, min_y, min_z, max_x, max_y, max_z)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; *argv[i+5]='\0'; *argv[i+6]='\0'; i+=6; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; *argv[i+5]='\0'; *argv[i+6]='\0'; i+=6; } else if (strcmp(argv[i],"-drop_x") == 0) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: min_x max_x\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_x max_x\n", argv[i]); return FALSE; } F64 min_x; if (sscanf(argv[i+1], "%lf", &min_x) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min_x max_x but '%s' is no valid min_x\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_x max_x but '%s' is no valid min_x\n", argv[i], argv[i+1]); return FALSE; } F64 max_x; if (sscanf(argv[i+2], "%lf", &max_x) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min_x max_x but '%s' is no valid max_x\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_x max_x but '%s' is no valid max_x\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionDropx(min_x, max_x)); @@ -3277,13 +3234,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: min_x\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: min_x\n", argv[i]); return FALSE; } F64 min_x; if (sscanf(argv[i+1], "%lf", &min_x) != 1) { - REprintf("ERROR: '%s' needs 1 argument: min_x but '%s' is no valid min_x\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: min_x but '%s' is no valid min_x\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropxBelow(min_x)); @@ -3293,13 +3250,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: max_x\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: max_x\n", argv[i]); return FALSE; } F64 max_x; if (sscanf(argv[i+1], "%lf", &max_x) != 1) { - REprintf("ERROR: '%s' needs 1 argument: max_x but '%s' is no valid max_x\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: max_x but '%s' is no valid max_x\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropxAbove(max_x)); @@ -3312,19 +3269,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: min_y max_y\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_y max_y\n", argv[i]); return FALSE; } F64 min_y; if (sscanf(argv[i+1], "%lf", &min_y) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min_y max_y but '%s' is no valid min_y\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_y max_y but '%s' is no valid min_y\n", argv[i], argv[i+1]); return FALSE; } F64 max_y; if (sscanf(argv[i+2], "%lf", &max_y) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min_y max_y but '%s' is no valid max_y\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_y max_y but '%s' is no valid max_y\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionDropy(min_y, max_y)); @@ -3334,13 +3291,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: min_y\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: min_y\n", argv[i]); return FALSE; } F64 min_y; if (sscanf(argv[i+1], "%lf", &min_y) != 1) { - REprintf("ERROR: '%s' needs 1 argument: min_y but '%s' is no valid min_y\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: min_y but '%s' is no valid min_y\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropyBelow(min_y)); @@ -3350,13 +3307,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: max_y\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: max_y\n", argv[i]); return FALSE; } F64 max_y; if (sscanf(argv[i+1], "%lf", &max_y) != 1) { - REprintf("ERROR: '%s' needs 1 argument: max_y but '%s' is no valid max_y\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: max_y but '%s' is no valid max_y\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropyAbove(max_y)); @@ -3369,19 +3326,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: min_z max_z\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_z max_z\n", argv[i]); return FALSE; } F64 min_z; if (sscanf(argv[i+1], "%lf", &min_z) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min_z max_z but '%s' is no valid min_z\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_z max_z but '%s' is no valid min_z\n", argv[i], argv[i+1]); return FALSE; } F64 max_z; if (sscanf(argv[i+2], "%lf", &max_z) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min_z max_z but '%s' is no valid max_z\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_z max_z but '%s' is no valid max_z\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionDropz(min_z, max_z)); @@ -3391,13 +3348,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: min_z\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: min_z\n", argv[i]); return FALSE; } F64 min_z; if (sscanf(argv[i+1], "%lf", &min_z) != 1) { - REprintf("ERROR: '%s' needs 1 argument: min_z but '%s' is no valid min_z\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: min_z but '%s' is no valid min_z\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropzBelow(min_z)); @@ -3407,13 +3364,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: max_z\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: max_z\n", argv[i]); return FALSE; } F64 max_z; if (sscanf(argv[i+1], "%lf", &max_z) != 1) { - REprintf("ERROR: '%s' needs 1 argument: max_z but '%s' is no valid max_z\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: max_z but '%s' is no valid max_z\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropzAbove(max_z)); @@ -3426,30 +3383,54 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: min_X max_X\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_X max_X\n", argv[i]); + return FALSE; + } + I32 min; + if (sscanf(argv[i+1], "%d", &min) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_X max_X but '%s' is no valid min_X\n", argv[i], argv[i+1]); return FALSE; } - add_criterion(new LAScriterionDropX(atoi(argv[i+1]), atoi(argv[i+2]))); + I32 max; + if (sscanf(argv[i+2], "%d", &max) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_X max_X but '%s' is no valid max_X\n", argv[i], argv[i+2]); + return FALSE; + } + add_criterion(new LAScriterionDropX(min, max)); *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-drop_X_below") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: min_X\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: min_X\n", argv[i]); + return FALSE; + } + I32 min; + if (sscanf(argv[i+1], "%d", &min) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: min_X but '%s' is no valid min_X\n", argv[i], argv[i+1]); return FALSE; } - add_criterion(new LAScriterionDropXBelow(atoi(argv[i+1]))); + add_criterion(new LAScriterionDropXBelow(min)); *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-drop_X_above") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: max_X\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: max_X\n", argv[i]); + return FALSE; + } + I32 max; + if (sscanf(argv[i+1], "%d", &max) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: max_X but '%s' is no valid max_X\n", argv[i], argv[i+1]); return FALSE; } - add_criterion(new LAScriterionDropXAbove(atoi(argv[i+1]))); + add_criterion(new LAScriterionDropXAbove(max)); *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } } @@ -3459,30 +3440,54 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: min_Y max_Y\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_Y max_Y\n", argv[i]); + return FALSE; + } + I32 min; + if (sscanf(argv[i+1], "%d", &min) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_Y max_Y but '%s' is no valid min_Y\n", argv[i], argv[i+1]); + return FALSE; + } + I32 max; + if (sscanf(argv[i+2], "%d", &max) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_Y max_Y but '%s' is no valid max_Y\n", argv[i], argv[i+2]); return FALSE; } - add_criterion(new LAScriterionDropY(atoi(argv[i+1]), atoi(argv[i+2]))); + add_criterion(new LAScriterionDropY(min, max)); *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-drop_Y_below") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: min_Y\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: min_Y\n", argv[i]); + return FALSE; + } + I32 min; + if (sscanf(argv[i+1], "%d", &min) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: min_Y but '%s' is no valid min_Y\n", argv[i], argv[i+1]); return FALSE; } - add_criterion(new LAScriterionDropYBelow(atoi(argv[i+1]))); + add_criterion(new LAScriterionDropYBelow(min)); *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-drop_Y_above") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: max_Y\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: max_Y\n", argv[i]); return FALSE; } - add_criterion(new LAScriterionDropYAbove(atoi(argv[i+1]))); + I32 max; + if (sscanf(argv[i+1], "%d", &max) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: max_Y but '%s' is no valid max_Y\n", argv[i], argv[i+1]); + return FALSE; + } + add_criterion(new LAScriterionDropYAbove(max)); *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } } @@ -3492,30 +3497,54 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: min_Z max_Z\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_Z max_Z\n", argv[i]); + return FALSE; + } + I32 min; + if (sscanf(argv[i+1], "%d", &min) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_Z max_Z but '%s' is no valid min_Z\n", argv[i], argv[i+1]); return FALSE; } - add_criterion(new LAScriterionDropZ(atoi(argv[i+1]), atoi(argv[i+2]))); + I32 max; + if (sscanf(argv[i+2], "%d", &max) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_Z max_Z but '%s' is no valid max_Z\n", argv[i], argv[i+2]); + return FALSE; + } + add_criterion(new LAScriterionDropZ(min, max)); *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-drop_Z_below") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: min_Z\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: min_Z\n", argv[i]); + return FALSE; + } + I32 min; + if (sscanf(argv[i+1], "%d", &min) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: min_Z but '%s' is no valid min_Z\n", argv[i], argv[i+1]); return FALSE; } - add_criterion(new LAScriterionDropZBelow(atoi(argv[i+1]))); + add_criterion(new LAScriterionDropZBelow(min)); *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-drop_Z_above") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: max_Z\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: max_Z\n", argv[i]); + return FALSE; + } + I32 max; + if (sscanf(argv[i+1], "%d", &max) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: max_Z but '%s' is no valid max_Z\n", argv[i], argv[i+1]); return FALSE; } - add_criterion(new LAScriterionDropZAbove(atoi(argv[i+1]))); + add_criterion(new LAScriterionDropZAbove(max)); *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } } @@ -3525,7 +3554,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs at least 1 argument: return_number\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs at least 1 argument: return_number\n", argv[i]); return FALSE; } *argv[i]='\0'; @@ -3536,12 +3565,12 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if (sscanf(argv[i], "%u", &return_number) != 1) { - REprintf("ERROR: '-drop_return' needs at least 1 argument: return_number but '%s' is no valid return_number\n", argv[i]); + fprintf(stderr,"ERROR: '-drop_return' needs at least 1 argument: return_number but '%s' is no valid return_number\n", argv[i]); return FALSE; } if (return_number > 15) { - REprintf("ERROR: cannot drop return_number %u because it is larger than 15\n", return_number); + fprintf(stderr,"ERROR: cannot drop return_number %u because it is larger than 15\n", return_number); return FALSE; } drop_return_mask |= (1u << return_number); @@ -3563,18 +3592,18 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: return_mask\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: return_mask\n", argv[i]); return FALSE; } U32 drop_return_mask; if (sscanf(argv[i+1], "%u", &drop_return_mask) != 1) { - REprintf("ERROR: '%s' needs 1 argument: return_mask but '%s' is no valid return_mask\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: return_mask but '%s' is no valid return_mask\n", argv[i], argv[i+1]); return FALSE; } if (drop_return_mask > U16_MAX) { - REprintf("ERROR: '%s' needs a return_mask between 0 and %u but return_mask is %u\n", argv[i], U16_MAX, drop_return_mask); + fprintf(stderr,"ERROR: '%s' needs a return_mask between 0 and %u but return_mask is %u\n", argv[i], U16_MAX, drop_return_mask); return FALSE; } add_criterion(new LAScriterionDropReturns((U16)drop_return_mask)); @@ -3585,10 +3614,21 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: number of returns\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: number of returns\n", argv[i]); + return FALSE; + } + U32 number_of_returns; + if (sscanf(argv[i+1], "%u", &number_of_returns) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: number of returns but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } - add_criterion(new LAScriterionDropSpecificNumberOfReturns(atoi(argv[i+1]))); + if (number_of_returns > 15) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: number of returns but '%u' is no valid value\n", argv[i], number_of_returns); + return FALSE; + } + add_criterion(new LAScriterionDropSpecificNumberOfReturns(number_of_returns)); *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-drop_single") == 0) @@ -3618,7 +3658,23 @@ BOOL LASfilter::parse(int argc, char* argv[]) } else if (strcmp(argv[i],"-drop_scan_direction") == 0) { - add_criterion(new LAScriterionDropScanDirection(atoi(argv[i+1]))); + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: scan direction\n", argv[i]); + return FALSE; + } + U32 scan_direction; + if (sscanf(argv[i+1], "%u", &scan_direction) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: scan direction but '%s' is no valid value\n", argv[i], argv[i+1]); + return FALSE; + } + if (scan_direction > 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: scan direction but '%u' is no valid value\n", argv[i], scan_direction); + return FALSE; + } + add_criterion(new LAScriterionDropScanDirection(scan_direction)); *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strncmp(argv[i],"-drop_intensity",15) == 0) @@ -3627,13 +3683,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: max\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: max\n", argv[i]); return FALSE; } I32 max; if (sscanf(argv[i+1], "%d", &max) != 1) { - REprintf("ERROR: '%s' needs 1 argument: max but '%s' is no valid max\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: max but '%s' is no valid max\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropIntensityAbove(max)); @@ -3643,13 +3699,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: min\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: min\n", argv[i]); return FALSE; } I32 min; if (sscanf(argv[i+1], "%d", &min) != 1) { - REprintf("ERROR: '%s' needs 1 argument: min but '%s' is no valid min\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: min but '%s' is no valid min\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropIntensityBelow(min)); @@ -3659,19 +3715,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: min max\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max\n", argv[i]); return FALSE; } I32 min; if (sscanf(argv[i+1], "%d", &min) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); return FALSE; } I32 max; if (sscanf(argv[i+2], "%d", &max) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionDropIntensityBetween(min, max)); @@ -3682,19 +3738,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: min max\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max\n", argv[i]); return FALSE; } I32 min; if (sscanf(argv[i+1], "%d", &min) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); return FALSE; } I32 max; if (sscanf(argv[i+2], "%d", &max) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); return FALSE; } if (strcmp(argv[i]+10,"red") == 0) @@ -3724,13 +3780,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: max\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: max\n", argv[i]); return FALSE; } I32 max; if (sscanf(argv[i+1], "%d", &max) != 1) { - REprintf("ERROR: '%s' needs 1 argument: max but '%s' is no valid max\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: max but '%s' is no valid max\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionKeepScanAngle(-max, max)); @@ -3740,13 +3796,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: min\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: min\n", argv[i]); return FALSE; } I32 min; if (sscanf(argv[i+1], "%d", &min) != 1) { - REprintf("ERROR: '%s' needs 1 argument: min but '%s' is no valid min\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: min but '%s' is no valid min\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropScanAngleBetween(-min+1, min-1)); @@ -3759,13 +3815,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: max\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: max\n", argv[i]); return FALSE; } I32 max; if (sscanf(argv[i+1], "%d", &max) != 1) { - REprintf("ERROR: '%s' needs 1 argument: max but '%s' is no valid max\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: max but '%s' is no valid max\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropScanAngleAbove(max)); @@ -3775,35 +3831,35 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: min\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: min\n", argv[i]); return FALSE; } I32 min; if (sscanf(argv[i+1], "%d", &min) != 1) { - REprintf("ERROR: '%s' needs 1 argument: min but '%s' is no valid min\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: min but '%s' is no valid min\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropScanAngleBelow(min)); *argv[i]='\0'; *argv[i+1]='\0'; i+=1; - } + } else if (strcmp(argv[i],"-drop_scan_angle_between") == 0) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: min max\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max\n", argv[i]); return FALSE; } I32 min; if (sscanf(argv[i+1], "%d", &min) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); return FALSE; } I32 max; if (sscanf(argv[i+2], "%d", &max) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionDropScanAngleBetween(min, max)); @@ -3834,7 +3890,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: index\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: index\n", argv[i]); return FALSE; } *argv[i]='\0'; @@ -3848,14 +3904,25 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs at least 1 argument: value\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs at least 1 argument: value\n", argv[i]); return FALSE; } *argv[i]='\0'; i+=1; do { - add_criterion(new LAScriterionDropUserData(atoi(argv[i]))); + U32 user_data; + if (sscanf(argv[i], "%u", &user_data) != 1) + { + fprintf(stderr,"ERROR: '-drop_user_data' needs at least 1 argument: value but '%s' is no valid value\n", argv[i]); + return FALSE; + } + if (user_data > 255) + { + fprintf(stderr,"ERROR: cannot drop user data %u because it is larger than 255\n", user_data); + return FALSE; + } + add_criterion(new LAScriterionDropUserData(user_data)); *argv[i]='\0'; i+=1; } while ((i < argc) && ('0' <= *argv[i]) && (*argv[i] <= '9')); @@ -3865,13 +3932,18 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: min\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: below\n", argv[i]); return FALSE; } - I32 min; - if (sscanf(argv[i+1], "%d", &min) != 1) + U32 min; + if (sscanf(argv[i+1], "%u", &min) != 1) { - REprintf("ERROR: '%s' needs 1 argument: min but '%s' is no valid min\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: below but '%s' is no valid value\n", argv[i], argv[i+1]); + return FALSE; + } + if (min > 255) + { + fprintf(stderr,"ERROR: cannot drop user data below %u because it is larger than 255\n", min); return FALSE; } add_criterion(new LAScriterionDropUserDataBelow(min)); @@ -3881,13 +3953,18 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: max\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: above\n", argv[i]); return FALSE; } - I32 max; - if (sscanf(argv[i+1], "%d", &max) != 1) + U32 max; + if (sscanf(argv[i+1], "%u", &max) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: above but '%s' is no valid value\n", argv[i], argv[i+1]); + return FALSE; + } + if (max > 255) { - REprintf("ERROR: '%s' needs 1 argument: max but '%s' is no valid max\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: cannot drop user data above %u because it is larger than 255\n", max); return FALSE; } add_criterion(new LAScriterionDropUserDataAbove(max)); @@ -3897,19 +3974,29 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: min max\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max\n", argv[i]); return FALSE; } - I32 min; - if (sscanf(argv[i+1], "%d", &min) != 1) + U32 min; + if (sscanf(argv[i+1], "%u", &min) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); return FALSE; } - I32 max; - if (sscanf(argv[i+2], "%d", &max) != 1) + if (min > 255) + { + fprintf(stderr,"ERROR: cannot drop user data between min and max because min of %u is larger than 255\n", min); + return FALSE; + } + U32 max; + if (sscanf(argv[i+2], "%u", &max) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); + return FALSE; + } + if (max > 255) { - REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: cannot drop user data between min and max because max of %u is larger than 255\n", max); return FALSE; } add_criterion(new LAScriterionDropUserDataBetween(min, max)); @@ -3922,7 +4009,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs at least 1 argument: ID\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs at least 1 argument: ID\n", argv[i]); return FALSE; } *argv[i]='\0'; @@ -3932,12 +4019,12 @@ BOOL LASfilter::parse(int argc, char* argv[]) U32 ID; if (sscanf(argv[i], "%u", &ID) != 1) { - REprintf("ERROR: '-drop_point_source' needs at least 1 argument: ID but '%s' is no valid ID\n", argv[i]); + fprintf(stderr,"ERROR: '-drop_point_source' needs at least 1 argument: ID but '%s' is no valid ID\n", argv[i]); return FALSE; } if (ID > U16_MAX) { - REprintf("ERROR: cannot drop_point_source ID %u because it is larger than %u\n", ID, U16_MAX); + fprintf(stderr,"ERROR: cannot drop_point_source ID %u because it is larger than %u\n", ID, U16_MAX); return FALSE; } add_criterion(new LAScriterionDropPointSource(ID)); @@ -3950,18 +4037,18 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: min_ID\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: min_ID\n", argv[i]); return FALSE; } U32 min_ID; if (sscanf(argv[i+1], "%u", &min_ID) != 1) { - REprintf("ERROR: '%s' needs 1 argument: min_ID max_ID but '%s' is no valid min_ID\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: min_ID max_ID but '%s' is no valid min_ID\n", argv[i], argv[i+1]); return FALSE; } if (min_ID > U16_MAX) { - REprintf("ERROR: cannot drop point source below min_ID of %u because it is larger than %u\n", min_ID, U16_MAX); + fprintf(stderr,"ERROR: cannot drop point source below min_ID of %u because it is larger than %u\n", min_ID, U16_MAX); return FALSE; } add_criterion(new LAScriterionDropPointSourceBelow((U16)min_ID)); @@ -3971,18 +4058,18 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: max_ID\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: max_ID\n", argv[i]); return FALSE; } U32 max_ID; if (sscanf(argv[i+1], "%u", &max_ID) != 1) { - REprintf("ERROR: '%s' needs 1 argument: max_ID but '%s' is no valid max_ID\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: max_ID but '%s' is no valid max_ID\n", argv[i], argv[i+1]); return FALSE; } if (max_ID > U16_MAX) { - REprintf("ERROR: cannot drop point source above max_ID of %u because it is larger than %u\n", max_ID, U16_MAX); + fprintf(stderr,"ERROR: cannot drop point source above max_ID of %u because it is larger than %u\n", max_ID, U16_MAX); return FALSE; } add_criterion(new LAScriterionDropPointSourceAbove((U16)max_ID)); @@ -3992,29 +4079,29 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: min_ID max_ID\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_ID max_ID\n", argv[i]); return FALSE; } U32 min_ID; if (sscanf(argv[i+1], "%u", &min_ID) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min_ID max_ID but '%s' is no valid min_ID\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_ID max_ID but '%s' is no valid min_ID\n", argv[i], argv[i+1]); return FALSE; } U32 max_ID; - if (sscanf(argv[i+2], "%u", &max_ID) != 1) + if (sscanf(argv[i+2], "%d", &max_ID) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min_ID max_ID but '%s' is no valid max_ID\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_ID max_ID but '%s' is no valid max_ID\n", argv[i], argv[i+2]); return FALSE; } if (min_ID > U16_MAX) { - REprintf("ERROR: cannot drop point source because min_ID of %u is larger than %u\n", min_ID, U16_MAX); + fprintf(stderr,"ERROR: cannot drop point source because min_ID of %u is larger than %u\n", min_ID, U16_MAX); return FALSE; } if (max_ID > U16_MAX) { - REprintf("ERROR: cannot drop point source because max_ID of %u is larger than %u\n", max_ID, U16_MAX); + fprintf(stderr,"ERROR: cannot drop point source because max_ID of %u is larger than %u\n", max_ID, U16_MAX); return FALSE; } add_criterion(new LAScriterionDropPointSourceBetween((U16)min_ID, (U16)max_ID)); @@ -4027,13 +4114,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: max_gps_time\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: max_gps_time\n", argv[i]); return FALSE; } F64 max_gps_time; if (sscanf(argv[i+1], "%lf", &max_gps_time) != 1) { - REprintf("ERROR: '%s' needs 1 argument: max_gps_time but '%s' is no valid max_gps_time\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: max_gps_time but '%s' is no valid max_gps_time\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropGpsTimeAbove(max_gps_time)); @@ -4043,13 +4130,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: min_gps_time\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: min_gps_time\n", argv[i]); return FALSE; } F64 min_gps_time; if (sscanf(argv[i+1], "%lf", &min_gps_time) != 1) { - REprintf("ERROR: '%s' needs 1 argument: min_gps_time but '%s' is no valid min_gps_time\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: min_gps_time but '%s' is no valid min_gps_time\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropGpsTimeBelow(min_gps_time)); @@ -4059,19 +4146,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: min max\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max\n", argv[i]); return FALSE; } F64 min; if (sscanf(argv[i+1], "%lf", &min) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); return FALSE; } F64 max; if (sscanf(argv[i+2], "%lf", &max) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionDropGpsTimeBetween(min, max)); @@ -4084,45 +4171,69 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: index value\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + F64 value; + if (sscanf(argv[i+2], "%lf", &value) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value '%s' is no valid value\n", argv[i], argv[i+2]); return FALSE; } - add_criterion(new LAScriterionDropAttributeBelow(atoi(argv[i+1]), atof(argv[i+2]))); + add_criterion(new LAScriterionDropAttributeBelow(index, value)); *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-drop_attribute_above") == 0) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: index value\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } - add_criterion(new LAScriterionDropAttributeAbove(atoi(argv[i+1]), atof(argv[i+2]))); + F64 value; + if (sscanf(argv[i+2], "%lf", &value) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value '%s' is no valid value\n", argv[i], argv[i+2]); + return FALSE; + } + add_criterion(new LAScriterionDropAttributeAbove(index, value)); *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-drop_attribute_between") == 0) { if ((i+3) >= argc) { - REprintf("ERROR: '%s' needs 3 arguments: index below above\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: index below above\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: index below above but '%s' is no valid index\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: index below above but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } F64 below; if (sscanf(argv[i+2], "%lf", &below) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: index below above but '%s' is no valid below\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: index below above but '%s' is no valid below\n", argv[i], argv[i+2]); return FALSE; } F64 above; if (sscanf(argv[i+3], "%lf", &above) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: index below above but '%s' is no valid above\n", argv[i], argv[i+3]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: index below above but '%s' is no valid above\n", argv[i], argv[i+3]); return FALSE; } add_criterion(new LAScriterionDropAttributeBetween(index, below, above)); @@ -4133,32 +4244,42 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: nth\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: nth\n", argv[i]); return FALSE; } U32 nth; if (sscanf(argv[i+1], "%u", &nth) != 1) { - REprintf("ERROR: '%s' needs 1 argument nth but '%s' is no valid nth\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument nth but '%s' is no valid nth\n", argv[i], argv[i+1]); return FALSE; } if (nth == 0) { - REprintf("ERROR: %u is no valid nth for '%s'\n", nth, argv[i]); + fprintf(stderr,"ERROR: %u is no valid nth for '%s'\n", nth, argv[i]); return FALSE; } add_criterion(new LAScriterionDropEveryNth(nth)); *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } - else if (strcmp(argv[i],"-drop_scanner_channel") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: number\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: number\n", argv[i]); + return FALSE; + } + U32 scanner_channel; + if (sscanf(argv[i+1], "%u", &scanner_channel) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument channel but '%s' is no valid value\n", argv[i], argv[i+1]); + return FALSE; + } + if (scanner_channel > 3) + { + fprintf(stderr,"ERROR: %u is no valid value for '%s'\n", scanner_channel, argv[i]); return FALSE; } - add_criterion(new LAScriterionDropScannerChannel((I32)atof(argv[i+1]))); + add_criterion(new LAScriterionDropScannerChannel(scanner_channel)); *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } } @@ -4178,40 +4299,63 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: grid_spacing\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: grid spacing\n", argv[i]); return FALSE; } - add_criterion(new LAScriterionThinWithGrid((F32)atof(argv[i+1]))); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; - } - else if (strcmp(argv[i],"-thin_with_voxel") == 0) - { - if ((i+1) >= argc) + F32 step; + if (sscanf(argv[i+1], "%f", &step) != 1) { - REprintf("ERROR: '%s' needs 1 argument: voxel_side_length\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: grid spacing but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } - add_criterion(new LAScriterionThinWithVoxel((F32)atof(argv[i+1]))); + if (step <= 0.0f) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: grid spacing but '%g' is no valid value\n", argv[i], step); + return FALSE; + } + add_criterion(new LAScriterionThinWithGrid(step)); *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-thin_pulses_with_time") == 0 || strcmp(argv[i],"-thin_with_time") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: time_spacing\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: time spacing\n", argv[i]); return FALSE; } - add_criterion(new LAScriterionThinPulsesWithTime(atof(argv[i+1]))); + F64 step; + if (sscanf(argv[i+1], "%lf", &step) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: time spacing but '%s' is no valid value\n", argv[i], argv[i+1]); + return FALSE; + } + if (step <= 0.0) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: time spacing but '%g' is no valid value\n", argv[i], step); + return FALSE; + } + add_criterion(new LAScriterionThinPulsesWithTime(step)); *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-thin_points_with_time") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: time_spacing\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: time spacing\n", argv[i]); + return FALSE; + } + F64 step; + if (sscanf(argv[i+1], "%lf", &step) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: time spacing but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } - add_criterion(new LAScriterionThinPointsWithTime(atof(argv[i+1]))); + if (step <= 0.0) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: time spacing but '%g' is no valid value\n", argv[i], step); + return FALSE; + } + add_criterion(new LAScriterionThinPointsWithTime(step)); *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } } @@ -4221,7 +4365,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if (num_criteria < 2) { - REprintf("ERROR: '%s' needs to be preceeded by at least two filters\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs to be preceeded by at least two filters\n", argv[i]); return FALSE; } LAScriterion* filter_criterion = new LAScriterionAnd(criteria[num_criteria-2], criteria[num_criteria-1]); @@ -4236,7 +4380,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if (num_criteria < 2) { - REprintf("ERROR: '%s' needs to be preceeded by at least two filters\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs to be preceeded by at least two filters\n", argv[i]); return FALSE; } LAScriterion* filter_criterion = new LAScriterionOr(criteria[num_criteria-2], criteria[num_criteria-1]); @@ -4248,13 +4392,25 @@ BOOL LASfilter::parse(int argc, char* argv[]) *argv[i]='\0'; } } + else if (strncmp(argv[i],"-clip_", 6) == 0) + { + fprintf(stderr,"ERROR: '%s' is no longer recognized. check documentation with '-h'.\n", argv[i]); + fprintf(stderr," rename '-clip' to '-keep_xy'.\n"); + fprintf(stderr," rename '-clip_box' to '-keep_xyz'.\n"); + fprintf(stderr," rename '-clip_tile' to '-keep_tile'.\n"); + fprintf(stderr," rename '-clip_z_below' to '-drop_z_below'.\n"); + fprintf(stderr," rename '-clip_z_above' to '-drop_z_above'.\n"); + fprintf(stderr," rename '-clip_z_between' to '-drop_z'.\n"); + fprintf(stderr," etc ...\n"); + return FALSE; + } } if (keep_extended_classification_mask[0] || keep_extended_classification_mask[1] || keep_extended_classification_mask[2] || keep_extended_classification_mask[3] || keep_extended_classification_mask[4] || keep_extended_classification_mask[5] || keep_extended_classification_mask[6] || keep_extended_classification_mask[7]) { if (drop_extended_classification_mask[0] || drop_extended_classification_mask[1] || drop_extended_classification_mask[2] || drop_extended_classification_mask[3] || drop_extended_classification_mask[4] || drop_extended_classification_mask[5] || drop_extended_classification_mask[6] || drop_extended_classification_mask[7]) { - REprintf("ERROR: cannot use '-drop_extended_class' and '-keep_extended_class' simultaneously\n"); + fprintf(stderr,"ERROR: cannot use '-drop_extended_class' and '-keep_extended_class' simultaneously\n"); return FALSE; } else diff --git a/inst/include/lasfilter.hpp b/src/LASlib/lasfilter.hpp similarity index 100% rename from inst/include/lasfilter.hpp rename to src/LASlib/lasfilter.hpp diff --git a/src/LASlib/lasignore.cpp b/src/LASlib/lasignore.cpp new file mode 100644 index 0000000..30fff8b --- /dev/null +++ b/src/LASlib/lasignore.cpp @@ -0,0 +1,402 @@ +/* +=============================================================================== + + FILE: lasignore.cpp + + CONTENTS: + + see corresponding header file + + PROGRAMMERS: + + martin.isenburg@rapidlasso.com - http://rapidlasso.com + + COPYRIGHT: + + (c) 2007-2019, martin isenburg, rapidlasso - fast tools to catch reality + + This is free software; you can redistribute and/or modify it under the + terms of the GNU Lesser General Licence as published by the Free Software + Foundation. See the LICENSE.txt file for more information. + + This software is distributed WITHOUT ANY WARRANTY and without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + CHANGE HISTORY: + + see corresponding header file + +=============================================================================== +*/ +#include "lasignore.hpp" + +#include "laszip_decompress_selective_v3.hpp" + +void LASignore::usage() const +{ + fprintf(stderr,"Ignore points based on classifications.\n"); + fprintf(stderr," -ignore_class 7\n"); + fprintf(stderr," -ignore_class 0 1 7 33\n"); + fprintf(stderr,"Ignore points based on return type.\n"); + fprintf(stderr," -ignore_first -ignore_first_of_many\n"); + fprintf(stderr," -ignore_last -ignore_last_of_many\n"); + fprintf(stderr," -ignore_intermediate\n"); + fprintf(stderr," -ignore_single\n"); + fprintf(stderr,"Ignore points based on flags.\n"); + fprintf(stderr," -ignore_synthetic -ignore_keypoint\n"); + fprintf(stderr," -ignore_withheld -ignore_overlap\n"); +} + +void LASignore::ignore_class(U8 classification) +{ + U32 byte = classification >> 5; + U32 rest = classification & 31; + ignore_classification_mask[byte] |= (1u << rest); + ignore_mask |= (1u << byte); +} + +void LASignore::dont_ignore_class(U8 classification) +{ + U32 byte = classification >> 5; + U32 rest = classification & 31; + ignore_classification_mask[byte] &= ~(1u << rest); + if (ignore_classification_mask[byte] == 0) + { + ignore_mask &= ~(1u << byte); + } +} + +BOOL LASignore::parse(int& i, int argc, char *argv[]) +{ + if ((strcmp(argv[i],"-ignore_class") == 0) || (strcmp(argv[i],"-ignore_extended_class") == 0)) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 at least argument: classification\n", argv[i]); + return FALSE; + } + int i_in = i; + *argv[i]='\0'; + i+=1; + do + { + U32 classification; + if (sscanf(argv[i], "%u", &classification) != 1) + { + fprintf(stderr,"ERROR: '%s' needs arguments between 0 and 255 but '%s' is no valid code\n", argv[i_in], argv[i]); + return FALSE; + } + if (classification > 255) + { + fprintf(stderr,"ERROR: '%s' needs arguments between 0 and 255 but '%u' is out of range\n", argv[i_in], classification); + return FALSE; + } + ignore_mask |= (1u << (classification >> 5)); + ignore_classification_mask[(classification >> 5)] |= (1u << (classification & 31)); + *argv[i]='\0'; + i+=1; + } while ((i < argc) && ('0' <= *argv[i]) && (*argv[i] <= '9')); + i-=1; + } + else if (strcmp(argv[i],"-ignore_class_mask") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: mask\n", argv[i]); + return FALSE; + } + U32 classification_mask; + if (sscanf(argv[i+1], "%u", &classification_mask) != 1) + { + fprintf(stderr,"ERROR: '%s' needs argument between 0x00000000 and 0xFFFFFFFF but '%s' is no valid mask\n", argv[i], argv[i+1]); + return FALSE; + } + if (classification_mask == 0x00000000) + { + fprintf(stderr,"ERROR: '%s' needs argument between 0x00000000 and 0xFFFFFFFF but %u makes no sense\n", argv[i], classification_mask); + return FALSE; + } + if (classification_mask == 0xFFFFFFFF) + { + fprintf(stderr,"ERROR: '%s' needs argument between 0x00000000 and 0xFFFFFFFF but %u makes no sense\n", argv[i], classification_mask); + return FALSE; + } + ignore_mask |= 1; + ignore_classification_mask[0] = classification_mask; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i],"-ignore_first_of_many") == 0) + { + ignore_mask |= LASIGNORE_FIRST_OF_MANY; + *argv[i]='\0'; + } + else if (strcmp(argv[i],"-ignore_last_of_many") == 0) + { + ignore_mask |= LASIGNORE_LAST_OF_MANY; + *argv[i]='\0'; + } + else if (strcmp(argv[i],"-ignore_intermediate") == 0) + { + ignore_mask |= LASIGNORE_INTERMEDIATE; + *argv[i]='\0'; + } + else if (strcmp(argv[i],"-ignore_single") == 0) + { + ignore_mask |= LASIGNORE_SINGLE; + *argv[i]='\0'; + } + else if (strcmp(argv[i],"-ignore_first") == 0) + { + ignore_mask |= LASIGNORE_FIRST_OF_MANY; + ignore_mask |= LASIGNORE_SINGLE; + *argv[i]='\0'; + } + else if (strcmp(argv[i],"-ignore_last") == 0) + { + ignore_mask |= LASIGNORE_LAST_OF_MANY; + ignore_mask |= LASIGNORE_SINGLE; + *argv[i]='\0'; + } + else if (strcmp(argv[i],"-ignore_synthetic") == 0) + { + ignore_mask |= LASIGNORE_SYNTHETIC; + *argv[i]='\0'; + } + else if (strcmp(argv[i],"-ignore_keypoint") == 0) + { + ignore_mask |= LASIGNORE_KEYPOINT; + *argv[i]='\0'; + } + else if (strcmp(argv[i],"-ignore_withheld") == 0) + { + ignore_mask |= LASIGNORE_WITHHELD; + *argv[i]='\0'; + } + else if (strcmp(argv[i],"-ignore_overlap") == 0) + { + ignore_mask |= LASIGNORE_OVERLAP; + *argv[i]='\0'; + } + else + { + fprintf(stderr, "ERROR: cannot understand argument '%s'\n", argv[i]); + return FALSE; + } + return TRUE; +} + +I32 LASignore::unparse(CHAR* string) const +{ + I32 n = 0; + if (ignore_mask) + { + if (ignore_mask & LASIGNORE_CLASSIFICATIONS) + { + n += sprintf(&string[n], "-ignore_class "); + for (int i = 0; i < 8; i++) + { + if (ignore_mask & (1u << i)) + { + for (int j = 0; j < 32; j++) + { + if (ignore_classification_mask[i] & (1u << j)) + { + n += sprintf(&string[n], "%d ", 32*i + j); + } + } + } + } + } + if (ignore_mask & LASIGNORE_RETURNS) + { + if (ignore_mask & LASIGNORE_SINGLE) + { + if (ignore_mask & (LASIGNORE_FIRST_OF_MANY | LASIGNORE_LAST_OF_MANY)) + { + if (ignore_mask & LASIGNORE_FIRST_OF_MANY) + { + n += sprintf(&string[n], "-ignore_first "); + } + if (ignore_mask & LASIGNORE_LAST_OF_MANY) + { + n += sprintf(&string[n], "-ignore_last "); + } + } + else + { + n += sprintf(&string[n], "-ignore_single "); + } + } + else + { + if (ignore_mask & LASIGNORE_FIRST_OF_MANY) + { + n += sprintf(&string[n], "-ignore_first_of_many "); + } + if (ignore_mask & LASIGNORE_LAST_OF_MANY) + { + n += sprintf(&string[n], "-ignore_last_of_many "); + } + } + if (ignore_mask & LASIGNORE_INTERMEDIATE) + { + n += sprintf(&string[n], "-ignore_intermediate "); + } + } + if (ignore_mask & LASIGNORE_FLAGS) + { + if (ignore_mask & LASIGNORE_SYNTHETIC) + { + n += sprintf(&string[n], "-ignore_snthetic "); + } + if (ignore_mask & LASIGNORE_KEYPOINT) + { + n += sprintf(&string[n], "-ignore_keypoint "); + } + if (ignore_mask & LASIGNORE_WITHHELD) + { + n += sprintf(&string[n], "-ignore_withheld "); + } + if (ignore_mask & LASIGNORE_OVERLAP) + { + n += sprintf(&string[n], "-ignore_overlap "); + } + } + } + return n; +} + +U32 LASignore::get_decompress_selective() const +{ + U32 decompress_selective = LASZIP_DECOMPRESS_SELECTIVE_CHANNEL_RETURNS_XY; + if (ignore_mask & LASIGNORE_CLASSIFICATIONS) + { + decompress_selective |= LASZIP_DECOMPRESS_SELECTIVE_CLASSIFICATION; + } + if (ignore_mask & LASIGNORE_FLAGS) + { + decompress_selective |= LASZIP_DECOMPRESS_SELECTIVE_FLAGS; + } + return decompress_selective; +} + +BOOL LASignore::parse(U32 curr_parameter, const U32 num_parameters, const F64* parameters) +{ + if (curr_parameter == num_parameters) + { + return TRUE; // nothing to ignore + } + else if (curr_parameter > num_parameters) // sanity check + { + return FALSE; // invalid state + } + if ((parameters[curr_parameter] < U32_MIN) || (U32_MAX < parameters[curr_parameter])) // sanity check + { + return FALSE; // invalid state + } + ignore_mask = (U32)parameters[curr_parameter]; + curr_parameter++; + if (ignore_mask & LASIGNORE_CLASSIFICATIONS) + { + for (int i = 0; i < 8; i++) + { + if (ignore_mask & (1u << i)) + { + if (curr_parameter == num_parameters) // sanity check + { + return FALSE; // invalid state + } + ignore_classification_mask[i] = (U32)(parameters[curr_parameter]); + curr_parameter++; + } + } + } + return TRUE; +} + +void LASignore::unparse(U32& num_parameters, F64* parameters) const +{ + if (ignore_mask) + { + parameters[num_parameters] = ignore_mask; + num_parameters++; + + if (ignore_mask & LASIGNORE_CLASSIFICATIONS) + { + for (int i = 0; i < 8; i++) + { + if (ignore_mask & (1u << i)) + { + parameters[num_parameters] = ignore_classification_mask[i]; + num_parameters++; + } + } + } + } +} + +BOOL LASignore::ignore(const LASpoint* point) const +{ + if (ignore_mask) + { + if (ignore_mask & LASIGNORE_CLASSIFICATIONS) + { + U32 classification = point->get_classification(); + U32 byte = classification >> 5; + U32 rest = classification & 31; + if (ignore_classification_mask[byte] & (1u << rest)) + { + return TRUE; + } + } + if (ignore_mask & LASIGNORE_RETURNS) + { + if ((ignore_mask & LASIGNORE_SINGLE) && point->is_single()) + { + return TRUE; + } + if ((ignore_mask & LASIGNORE_FIRST_OF_MANY) && point->is_first_of_many()) + { + return TRUE; + } + if ((ignore_mask & LASIGNORE_LAST_OF_MANY) && point->is_last_of_many()) + { + return TRUE; + } + if ((ignore_mask & LASIGNORE_INTERMEDIATE) && point->is_intermediate()) + { + return TRUE; + } + } + if (ignore_mask & LASIGNORE_FLAGS) + { + if ((ignore_mask & LASIGNORE_SYNTHETIC) && point->get_synthetic_flag()) + { + return TRUE; + } + if ((ignore_mask & LASIGNORE_KEYPOINT) && point->get_keypoint_flag()) + { + return TRUE; + } + if ((ignore_mask & LASIGNORE_WITHHELD) && point->get_withheld_flag()) + { + return TRUE; + } + if ((ignore_mask & LASIGNORE_OVERLAP) && point->get_extended_overlap_flag()) + { + return TRUE; + } + } + } + return FALSE; +} + +LASignore::LASignore() +{ + ignore_mask = 0; + ignore_classification_mask[0] = ignore_classification_mask[1] = ignore_classification_mask[2] = ignore_classification_mask[3] = ignore_classification_mask[4] = ignore_classification_mask[5] = ignore_classification_mask[6] = ignore_classification_mask[7] = 0; +} + +LASignore::~LASignore() +{ +} diff --git a/src/LASlib/lasignore.hpp b/src/LASlib/lasignore.hpp new file mode 100644 index 0000000..9b74bee --- /dev/null +++ b/src/LASlib/lasignore.hpp @@ -0,0 +1,75 @@ +/* +=============================================================================== + + FILE: lasignore.hpp + + CONTENTS: + + Implements the various rules for ignoring points when processing LiDAR. + + PROGRAMMERS: + + martin.isenburg@rapidlasso.com - http://rapidlasso.com + + COPYRIGHT: + + (c) 2007-2019, martin isenburg, rapidlasso - fast tools to catch reality + + This is free software; you can redistribute and/or modify it under the + terms of the GNU Lesser General Licence as published by the Free Software + Foundation. See the LICENSE.txt file for more information. + + This software is distributed WITHOUT ANY WARRANTY and without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + CHANGE HISTORY: + + 18 August 2019 -- created after Memoy's cousine stole USD 300 and EUR 100 + +=============================================================================== +*/ +#ifndef LAS_IGNORE_HPP +#define LAS_IGNORE_HPP + +#include "lasdefinitions.hpp" + +#define LASIGNORE_CLASSIFICATIONS 0x000000FF +#define LASIGNORE_RETURNS 0x00000F00 +#define LASIGNORE_FLAGS 0x0000F000 + +#define LASIGNORE_FIRST_OF_MANY 0x00000100 +#define LASIGNORE_LAST_OF_MANY 0x00000200 +#define LASIGNORE_INTERMEDIATE 0x00000400 +#define LASIGNORE_SINGLE 0x00000800 + +#define LASIGNORE_SYNTHETIC 0x00001000 +#define LASIGNORE_KEYPOINT 0x00002000 +#define LASIGNORE_WITHHELD 0x00004000 +#define LASIGNORE_OVERLAP 0x00008000 + +class LASignore +{ +public: + void usage() const; + + void ignore_class(U8 classification); + void dont_ignore_class(U8 classification); + + BOOL parse(int& i, int argc, char *argv[]); + I32 unparse(CHAR* string) const; + + BOOL parse(U32 curr_parameter, const U32 num_parameters, const F64* parameters); + void unparse(U32& num_parameters, F64* parameters) const; + + U32 get_decompress_selective() const; + + BOOL ignore(const LASpoint* point) const; + + LASignore(); + ~LASignore(); +protected: + U32 ignore_mask; + U32 ignore_classification_mask[8]; +}; + +#endif diff --git a/src/LASlib/laskdtree.cpp b/src/LASlib/laskdtree.cpp new file mode 100644 index 0000000..c2a8642 --- /dev/null +++ b/src/LASlib/laskdtree.cpp @@ -0,0 +1,357 @@ +/* +=============================================================================== + + FILE: laskdtree.cpp + + CONTENTS: + + see corresponding header file + + PROGRAMMERS: + + martin.isenburg@rapidlasso.com - http://rapidlasso.com + + COPYRIGHT: + + (c) 2007-2019, martin isenburg, rapidlasso - fast tools to catch reality + + This is free software; you can redistribute and/or modify it under the + terms of the GNU Lesser General Licence as published by the Free Software + Foundation. See the LICENSE.txt file for more information. + + This software is distributed WITHOUT ANY WARRANTY and without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + CHANGE HISTORY: + + see corresponding header file + +=============================================================================== +*/ + +#include "laskdtree.hpp" + +#include + +BOOL LASkdtreeRectangle::overlap(const LASkdtreeRectangle &rectangle) const +{ + if (max[0] < rectangle.min[0]) return FALSE; + if (max[1] < rectangle.min[1]) return FALSE; + if (rectangle.max[0] < min[0]) return FALSE; + if (rectangle.max[1] < min[1]) return FALSE; + return TRUE; +} + +LASkdtreeRectangle::LASkdtreeRectangle(F64 min_x, F64 min_y, F64 max_x, F64 max_y, U32 index) +{ + min[0] = min_x; + min[1] = min_y; + max[0] = max_x; + max[1] = max_y; + idx = index; +} + +LASkdtreeRectangle::LASkdtreeRectangle(F64 min_x, F64 min_y, F64 max_x, F64 max_y) +{ + min[0] = min_x; + min[1] = min_y; + max[0] = max_x; + max[1] = max_y; + idx = 0; +} + +LASkdtreeRectangle::LASkdtreeRectangle() +{ + min[0] = 0; + min[1] = 0; + max[0] = 0; + max[1] = 0; + idx = 0; +} + +LASkdtreeRectanglesNode::LASkdtreeRectanglesNode() +{ + left = 0; + right = 0; + list = 0; +} + +LASkdtreeRectanglesNode::~LASkdtreeRectanglesNode() +{ + if (left) delete left; + if (right) delete right; + if (list) delete list; +} + +BOOL LASkdtreeRectangles::init() +{ + bb.min[0] = F64_MAX; + bb.min[1] = F64_MAX; + bb.max[0] = F64_MIN; + bb.max[1] = F64_MIN; + if (rectangle_list) delete rectangle_list; + rectangle_list = new my_rectangle_list; + if (rectangle_list == 0) + { + return FALSE; + } + if (root) delete root; + root = 0; + if (overlap_set) delete overlap_set; + overlap_set = 0; + return TRUE; +} + +void LASkdtreeRectangles::add(F64 min_x, F64 min_y, F64 max_x, F64 max_y) +{ + // update bounding box + + if (min_x < bb.min[0]) bb.min[0] = min_x; + if (min_y < bb.min[1]) bb.min[1] = min_y; + if (max_x > bb.max[0]) bb.max[0] = max_x; + if (min_y > bb.max[1]) bb.max[1] = max_y; + + // create rectangle + + LASkdtreeRectangle rectangle(min_x, min_y, max_x, max_y, (U32)rectangle_list->size()); + + // add rectangle to list + + rectangle_list->push_back(rectangle); +} + +BOOL LASkdtreeRectangles::build() +{ + if (root) delete root; + root = new LASkdtreeRectanglesNode(); + if (root == 0) + { + return FALSE; + } + + build_recursive(root, 0, bb, rectangle_list, 0); + rectangle_list = 0; + + overlap_set = new my_index_set; + if (overlap_set == 0) + { + return FALSE; + } + return TRUE; +} + +BOOL LASkdtreeRectangles::was_built() const +{ + if (root && overlap_set) + { + return TRUE; + } + else + { + return FALSE; + } +} + +BOOL LASkdtreeRectangles::overlap(F64 min_x, F64 min_y, F64 max_x, F64 max_y) +{ + if (overlap_set == 0) + { + return FALSE; + } + overlap_set->clear(); + LASkdtreeRectangle rectangle(min_x, min_y, max_x, max_y); + overlap_rectangles(root, 0, rectangle, overlap_set); + return TRUE; +} + +BOOL LASkdtreeRectangles::has_overlaps() +{ + if (overlap_set && overlap_set->size()) + { + set_element = overlap_set->begin(); + return TRUE; + } + return FALSE; +} + +BOOL LASkdtreeRectangles::get_overlap(U32& index) +{ + if (overlap_set) + { + if (set_element == overlap_set->end()) + { + return FALSE; + } + index = (*set_element); + set_element++; + return TRUE; + } + return FALSE; +} + +void LASkdtreeRectangles::build_recursive(LASkdtreeRectanglesNode* node, I32 plane, LASkdtreeRectangle curr_bb, my_rectangle_list* insertion_list, I32 unchanged) +{ + // is list small enough? + if (insertion_list->size() <= 4) + { + node->list = insertion_list; + return; + } + + // did last 4 recursions not make list smaller? + if (unchanged >= 4) + { + node->list = insertion_list; + return; + } + + F64 split = (curr_bb.min[plane] + curr_bb.max[plane]) / 2; + + my_rectangle_list* list_left = new my_rectangle_list; + my_rectangle_list* list_right = new my_rectangle_list; + + my_rectangle_list::iterator list_element = insertion_list->begin(); + + U32 total = 0; + U32 total_left = 0; + U32 total_right = 0; + + while (TRUE) + { + if (list_element == insertion_list->end()) + { + break; + } + + LASkdtreeRectangle rectangle = (*list_element); + + total++; + + if (rectangle.min[plane] < split) + { + list_left->push_back(rectangle); + total_left++; + } + if (split <= rectangle.max[plane]) + { + list_right->push_back(rectangle); + total_right++; + } + + list_element++; + } + + // input list was divided into two output lists and no longer useful + + delete insertion_list; + + // split the bounding box + + LASkdtreeRectangle bb_left = curr_bb; + bb_left.max[plane] = split; + + LASkdtreeRectangle bb_right = curr_bb; + bb_right.min[plane] = split; + + // create the child nodes + + LASkdtreeRectanglesNode* left = new LASkdtreeRectanglesNode(); + LASkdtreeRectanglesNode* right = new LASkdtreeRectanglesNode(); + + // start recursive calls + + if (total_left < total) + { + build_recursive(left, (plane + 1) % 2, bb_left, list_left, 0); + } + else + { + build_recursive(left, (plane + 1) % 2, bb_left, list_left, unchanged+1); + } + + if (total_right < total) + { + build_recursive(right, (plane + 1) % 2, bb_right, list_right, 0); + } + else + { + build_recursive(right, (plane + 1) % 2, bb_right, list_right, unchanged+1); + } + + // attach children to their parent + + node->split = split; + node->left = left; + node->right = right; +} + +void LASkdtreeRectangles::overlap_rectangles(LASkdtreeRectanglesNode* node, I32 plane, LASkdtreeRectangle rectangle, my_index_set* overlap_set) +{ + if (node->list) + { + my_rectangle_list::iterator list_element = node->list->begin(); + while (TRUE) + { + if (list_element == node->list->end()) + { + break; + } + + LASkdtreeRectangle overlap_candidate = (*list_element); + + if (rectangle.overlap(overlap_candidate)) + { + overlap_set->insert(overlap_candidate.idx); + } + list_element++; + } + } + else + { + // maybe recurse left + + if (rectangle.min[plane] < node->split) + { + overlap_rectangles(node->left, (plane + 1) % 2, rectangle, overlap_set); + } + + // maybe recurse right + + if (node->split <= rectangle.max[plane]) + { + overlap_rectangles(node->right, (plane + 1) % 2, rectangle, overlap_set); + } + } +} + +void LASkdtreeRectangles::print_overlap() +{ + fprintf(stderr, "overlap elements: %u\n", (U32)overlap_set->size()); + my_index_set::iterator set_element = overlap_set->begin(); + while (TRUE) + { + if (set_element == overlap_set->end()) + { + break; + } + + U32 idx = (*set_element); + + fprintf(stderr, "overlap %u\n", idx); + + set_element++; + } +} + +LASkdtreeRectangles::LASkdtreeRectangles() +{ + rectangle_list = 0; + overlap_set = 0; + root = 0; +} + +LASkdtreeRectangles::~LASkdtreeRectangles() +{ + if (rectangle_list) delete rectangle_list; + if (root) delete root; +} diff --git a/src/LASlib/laskdtree.hpp b/src/LASlib/laskdtree.hpp new file mode 100644 index 0000000..c31a218 --- /dev/null +++ b/src/LASlib/laskdtree.hpp @@ -0,0 +1,98 @@ +/* +=============================================================================== + + FILE: laskdtree.hpp + + CONTENTS: + + Tree structure for fast overlap checks of rectangles with list of rectangles + + PROGRAMMERS: + + martin.isenburg@rapidlasso.com - http://rapidlasso.com + + COPYRIGHT: + + (c) 2007-2019, martin isenburg, rapidlasso - fast tools to catch reality + + This is free software; you can redistribute and/or modify it under the + terms of the GNU Lesser General Licence as published by the Free Software + Foundation. See the LICENSE.txt file for more information. + + This software is distributed WITHOUT ANY WARRANTY and without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + CHANGE HISTORY: + + 26 October 2019 -- created at LoCoworking after three days of rain in Samara + +=============================================================================== +*/ +#ifndef LAS_KD_TREE_HPP +#define LAS_KD_TREE_HPP + +#include "mydefs.hpp" + +#include +#include + +#include +#include +using namespace std; + +typedef set my_index_set; + +class LASkdtreeRectangle +{ +public: + F64 min[2]; + F64 max[2]; + U32 idx; + + BOOL overlap(const LASkdtreeRectangle &rectangle) const; + + LASkdtreeRectangle(); + LASkdtreeRectangle(F64 min_x, F64 min_y, F64 max_x, F64 max_y); + LASkdtreeRectangle(F64 min_x, F64 min_y, F64 max_x, F64 max_y, U32 index); +}; + +typedef list my_rectangle_list; + +class LASkdtreeRectanglesNode +{ +public: + F64 split; + LASkdtreeRectanglesNode* left; + LASkdtreeRectanglesNode* right; + my_rectangle_list* list; + + LASkdtreeRectanglesNode(); + ~LASkdtreeRectanglesNode(); +}; + +class LASkdtreeRectangles +{ +public: + BOOL init(); + void add(F64 min_x, F64 min_y, F64 max_x, F64 max_y); + BOOL build(); + BOOL was_built() const; + BOOL overlap(F64 min_x, F64 min_y, F64 max_x, F64 max_y); + void print_overlap(); + BOOL has_overlaps(); + BOOL get_overlap(U32& index); + + LASkdtreeRectangles(); + ~LASkdtreeRectangles(); +private: + LASkdtreeRectangle bb; + my_rectangle_list* rectangle_list; + LASkdtreeRectanglesNode* root; + my_index_set* overlap_set; + my_index_set::iterator set_element; + + void build_recursive(LASkdtreeRectanglesNode* node, I32 plane, LASkdtreeRectangle bb, my_rectangle_list* insertion_list, I32 unchanged); + void overlap_rectangles(LASkdtreeRectanglesNode* node, I32 plane, LASkdtreeRectangle rectangle, my_index_set* overlap_set); +}; + +#endif diff --git a/src/LASlib/laslib-config.cmake b/src/LASlib/laslib-config.cmake new file mode 100644 index 0000000..b959a64 --- /dev/null +++ b/src/LASlib/laslib-config.cmake @@ -0,0 +1,6 @@ +get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +include(${SELF_DIR}/laslib-targets.cmake) +get_filename_component(LASlib_INCLUDE_DIRS "${SELF_DIR}/../../../include/LASlib" ABSOLUTE) +set_property(TARGET LASlib PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${LASlib_INCLUDE_DIRS}) + +set(LASlib_FOUND true) diff --git a/src/LASlib/lasreader.cpp b/src/LASlib/lasreader.cpp index 4ea99c4..c5db8d9 100644 --- a/src/LASlib/lasreader.cpp +++ b/src/LASlib/lasreader.cpp @@ -13,7 +13,7 @@ COPYRIGHT: - (c) 2005-2013, martin isenburg, rapidlasso - fast tools to catch reality + (c) 2005-2019, martin isenburg, rapidlasso - fast tools to catch reality This is free software; you can redistribute and/or modify it under the terms of the GNU Lesser General Licence as published by the Free Software @@ -34,6 +34,8 @@ #include "lasfilter.hpp" #include "lastransform.hpp" +#include "laskdtree.hpp" + #include "lasreader_las.hpp" #include "lasreader_bin.hpp" #include "lasreader_shp.hpp" @@ -60,6 +62,7 @@ LASreader::LASreader() index = 0; filter = 0; transform = 0; + ignore = 0; inside = 0; t_ll_x = 0; t_ll_y = 0; @@ -83,6 +86,12 @@ LASreader::LASreader() LASreader::~LASreader() { if (index) delete index; + if (transform) transform->check_for_overflow(); +} + +void LASreader::dealloc() +{ + delete this; } void LASreader::set_index(LASindex* index) @@ -135,6 +144,11 @@ void LASreader::set_transform(LAStransform* transform) read_complex = &LASreader::read_point_default; } +void LASreader::set_ignore(LASignore* ignore) +{ + this->ignore = ignore; +} + BOOL LASreader::inside_none() { if (filter || transform) @@ -365,9 +379,15 @@ BOOL LASreader::read_point_inside_rectangle() BOOL LASreader::read_point_inside_rectangle_indexed() { + bool inrect; while (index->seek_next((LASreader*)this)) { - if (read_point_default() && point.inside_rectangle(r_min_x, r_min_y, r_max_x, r_max_y)) return TRUE; + inrect = point.get_x() >= r_min_x && point.get_x() <= r_max_x && point.get_y() >= r_min_y && point.get_y() <= r_max_y; + + if (read_point_default() && point.inside_rectangle(r_min_x, r_min_y, r_max_x, r_max_y)) + { + return TRUE; + } } return FALSE; } @@ -489,7 +509,7 @@ I32 LASreadOpener::unparse(CHAR* string) const } if (io_ibuffer_size != LAS_TOOLS_IO_IBUFFER_SIZE) { - n += sprintf(string + n, "-io_ibuffer %d ", io_ibuffer_size); + n += sprintf(string + n, "-io_ibuffer %u ", io_ibuffer_size); } if (temp_file_base) { @@ -523,7 +543,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth { use_stdin = FALSE; if (file_name_current == file_name_number && other_file_name == 0) return 0; - if ((file_name_number > 1) && merged) + if ((other_file_name == 0) && ((file_name_number > 1) || (file_names_ID)) && merged) { LASreaderMerged* lasreadermerged = new LASreaderMerged(); lasreadermerged->set_scale_factor(scale_factor); @@ -537,10 +557,17 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth lasreadermerged->set_translate_scan_angle(translate_scan_angle); lasreadermerged->set_scale_scan_angle(scale_scan_angle); lasreadermerged->set_io_ibuffer_size(io_ibuffer_size); - for (file_name_current = 0; file_name_current < file_name_number; file_name_current++) lasreadermerged->add_file_name(file_names[file_name_current]); + if (file_names_ID) + { + for (file_name_current = 0; file_name_current < file_name_number; file_name_current++) lasreadermerged->add_file_name(file_names[file_name_current], file_names_ID[file_name_current]); + } + else + { + for (file_name_current = 0; file_name_current < file_name_number; file_name_current++) lasreadermerged->add_file_name(file_names[file_name_current]); + } if (!lasreadermerged->open()) { - REprintf("ERROR: cannot open lasreadermerged with %d file names\n", file_name_number); + fprintf(stderr,"ERROR: cannot open lasreadermerged with %d file names\n", file_name_number); delete lasreadermerged; return 0; } @@ -548,6 +575,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth if (apply_file_source_ID) lasreadermerged->set_apply_file_source_ID(TRUE); if (filter) lasreadermerged->set_filter(filter); if (transform) lasreadermerged->set_transform(transform); + if (ignore) lasreadermerged->set_ignore(ignore); if (inside_tile) lasreadermerged->inside_tile(inside_tile[0], inside_tile[1], inside_tile[2]); if (inside_circle) lasreadermerged->inside_circle(inside_circle[0], inside_circle[1], inside_circle[2]); if (inside_rectangle) lasreadermerged->inside_rectangle(inside_rectangle[0], inside_rectangle[1], inside_rectangle[2], inside_rectangle[3]); @@ -557,7 +585,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderStored* lasreaderstored = new LASreaderStored(); if (!lasreaderstored->open(lasreadermerged)) { - REprintf( "ERROR: could not open lasreaderstored with lasreadermerged\n"); + fprintf(stderr, "ERROR: could not open lasreaderstored with lasreadermerged\n"); delete lasreaderstored; return 0; } @@ -572,7 +600,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderPipeOn* lasreaderpipeon = new LASreaderPipeOn(); if (!lasreaderpipeon->open(lasreader)) { - REprintf("ERROR: cannot open lasreaderpipeon with lasreadermerged\n"); + fprintf(stderr,"ERROR: cannot open lasreaderpipeon with lasreadermerged\n"); delete lasreaderpipeon; return 0; } @@ -586,19 +614,6 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth else if ((buffer_size > 0) && ((file_name_number > 1) || (neighbor_file_name_number > 0))) { U32 i; - if (other_file_name) - { - file_name = other_file_name; - if (reset_after_other) - { - file_name_current = 0; - } - } - else - { - file_name = file_names[file_name_current]; - file_name_current++; - } LASreaderBuffered* lasreaderbuffered = new LASreaderBuffered(); lasreaderbuffered->set_buffer_size(buffer_size); lasreaderbuffered->set_scale_factor(scale_factor); @@ -610,26 +625,105 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth lasreaderbuffered->set_scale_intensity(scale_intensity); lasreaderbuffered->set_translate_scan_angle(translate_scan_angle); lasreaderbuffered->set_scale_scan_angle(scale_scan_angle); - lasreaderbuffered->set_file_name(file_name); - for (i = 0; i < file_name_number; i++) + if (other_file_name) // special case when other file name was specified { - if (file_name != file_names[i]) + file_name = other_file_name; + lasreaderbuffered->set_file_name(other_file_name); + if (reset_after_other) { - lasreaderbuffered->add_neighbor_file_name(file_names[i]); + file_name_current = 0; + } + for (i = 0; i < file_name_number; i++) + { + if (strcmp(other_file_name, file_names[i])) + { + lasreaderbuffered->add_neighbor_file_name(file_names[i]); + } + } + if (neighbor_file_name_number) + { + for (i = 0; i < neighbor_file_name_number; i++) + { + if (strcmp(other_file_name, neighbor_file_names[i])) + { + lasreaderbuffered->add_neighbor_file_name(neighbor_file_names[i]); + } + } } } - for (i = 0; i < neighbor_file_name_number; i++) + else // usual case for processing on-the-fly buffered files { - if (strcmp(file_name, neighbor_file_names[i])) + file_name = file_names[file_name_current]; + lasreaderbuffered->set_file_name(file_name); + if (kdtree_rectangles) + { + if (!kdtree_rectangles->was_built()) + { + kdtree_rectangles->build(); + } + kdtree_rectangles->overlap(file_names_min_x[file_name_current]-buffer_size, file_names_min_y[file_name_current]-buffer_size, file_names_max_x[file_name_current]+buffer_size, file_names_max_y[file_name_current]+buffer_size); + if (kdtree_rectangles->has_overlaps()) + { + U32 index; + while (kdtree_rectangles->get_overlap(index)) + { + if (file_name != file_names[index]) + { + lasreaderbuffered->add_neighbor_file_name(file_names[index]); + } + } + } + } + else + { + for (i = 0; i < file_name_number; i++) + { + if (file_name != file_names[i]) + { + lasreaderbuffered->add_neighbor_file_name(file_names[i]); + } + } + } + if (neighbor_file_name_number) { - lasreaderbuffered->add_neighbor_file_name(neighbor_file_names[i]); + if (neighbor_kdtree_rectangles) + { + if (!neighbor_kdtree_rectangles->was_built()) + { + neighbor_kdtree_rectangles->build(); + } + neighbor_kdtree_rectangles->overlap(file_names_min_x[file_name_current]-buffer_size, file_names_min_y[file_name_current]-buffer_size, file_names_max_x[file_name_current]+buffer_size, file_names_max_y[file_name_current]+buffer_size); + if (neighbor_kdtree_rectangles->has_overlaps()) + { + U32 index; + while (neighbor_kdtree_rectangles->get_overlap(index)) + { + if (strcmp(file_name, neighbor_file_names[index])) + { + lasreaderbuffered->add_neighbor_file_name(neighbor_file_names[index]); + } + } + } + } + else + { + for (i = 0; i < neighbor_file_name_number; i++) + { + if (strcmp(file_name, neighbor_file_names[i])) + { + lasreaderbuffered->add_neighbor_file_name(neighbor_file_names[i]); + } + } + } } + file_name_current++; } if (filter) lasreaderbuffered->set_filter(filter); if (transform) lasreaderbuffered->set_transform(transform); + if (ignore) lasreaderbuffered->set_ignore(ignore); if (!lasreaderbuffered->open()) { - REprintf("ERROR: cannot open lasreaderbuffered with %d file names\n", file_name_number+neighbor_file_name_number); + fprintf(stderr,"ERROR: cannot open lasreaderbuffered with %d file names\n", file_name_number+neighbor_file_name_number); delete lasreaderbuffered; return 0; } @@ -642,7 +736,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderStored* lasreaderstored = new LASreaderStored(); if (!lasreaderstored->open(lasreaderbuffered)) { - REprintf( "ERROR: could not open lasreaderstored with lasreaderbuffered\n"); + fprintf(stderr, "ERROR: could not open lasreaderstored with lasreaderbuffered\n"); delete lasreaderstored; return 0; } @@ -657,7 +751,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderPipeOn* lasreaderpipeon = new LASreaderPipeOn(); if (!lasreaderpipeon->open(lasreader)) { - REprintf("ERROR: cannot open lasreaderpipeon with lasreaderbuffered\n"); + fprintf(stderr,"ERROR: cannot open lasreaderpipeon with lasreaderbuffered\n"); delete lasreaderpipeon; return 0; } @@ -710,7 +804,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth lasreaderlas = new LASreaderLASrescalereoffset(scale_factor[0], scale_factor[1], scale_factor[2], offset[0], offset[1], offset[2]); if (!lasreaderlas->open(file_name, io_ibuffer_size, FALSE, decompress_selective)) { - REprintf("ERROR: cannot open lasreaderlas with file name '%s'\n", file_name); + fprintf(stderr,"ERROR: cannot open lasreaderlas with file name '%s'\n", file_name); delete lasreaderlas; return 0; } @@ -729,6 +823,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth } if (filter) lasreaderlas->set_filter(filter); if (transform) lasreaderlas->set_transform(transform); + if (ignore) lasreaderlas->set_ignore(ignore); if (inside_rectangle) lasreaderlas->inside_rectangle(inside_rectangle[0], inside_rectangle[1], inside_rectangle[2], inside_rectangle[3]); else if (inside_tile) lasreaderlas->inside_tile(inside_tile[0], inside_tile[1], inside_tile[2]); else if (inside_circle) lasreaderlas->inside_circle(inside_circle[0], inside_circle[1], inside_circle[2]); @@ -738,7 +833,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderStored* lasreaderstored = new LASreaderStored(); if (!lasreaderstored->open(lasreaderlas)) { - REprintf( "ERROR: could not open lasreaderstored with lasreaderlas\n"); + fprintf(stderr, "ERROR: could not open lasreaderstored with lasreaderlas\n"); delete lasreaderstored; return 0; } @@ -753,7 +848,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderPipeOn* lasreaderpipeon = new LASreaderPipeOn(); if (!lasreaderpipeon->open(lasreader)) { - REprintf("ERROR: cannot open lasreaderpipeon with lasreaderlas\n"); + fprintf(stderr,"ERROR: cannot open lasreaderpipeon with lasreaderlas\n"); delete lasreaderpipeon; return 0; } @@ -777,7 +872,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth lasreaderbin = new LASreaderBINrescalereoffset(scale_factor[0], scale_factor[1], scale_factor[2], offset[0], offset[1], offset[2]); if (!lasreaderbin->open(file_name)) { - REprintf("ERROR: cannot open lasreaderbin with file name '%s'\n", file_name); + fprintf(stderr,"ERROR: cannot open lasreaderbin with file name '%s'\n", file_name); delete lasreaderbin; return 0; } @@ -789,6 +884,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth if (files_are_flightlines) lasreaderbin->header.file_source_ID = file_name_current + files_are_flightlines + files_are_flightlines_index; if (filter) lasreaderbin->set_filter(filter); if (transform) lasreaderbin->set_transform(transform); + if (ignore) lasreaderbin->set_ignore(ignore); if (inside_tile) lasreaderbin->inside_tile(inside_tile[0], inside_tile[1], inside_tile[2]); if (inside_circle) lasreaderbin->inside_circle(inside_circle[0], inside_circle[1], inside_circle[2]); if (inside_rectangle) lasreaderbin->inside_rectangle(inside_rectangle[0], inside_rectangle[1], inside_rectangle[2], inside_rectangle[3]); @@ -798,7 +894,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderStored* lasreaderstored = new LASreaderStored(); if (!lasreaderstored->open(lasreaderbin)) { - REprintf( "ERROR: could not open lasreaderstored with lasreaderbin\n"); + fprintf(stderr, "ERROR: could not open lasreaderstored with lasreaderbin\n"); delete lasreaderstored; return 0; } @@ -813,7 +909,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderPipeOn* lasreaderpipeon = new LASreaderPipeOn(); if (!lasreaderpipeon->open(lasreader)) { - REprintf("ERROR: cannot open lasreaderpipeon with lasreaderbin\n"); + fprintf(stderr,"ERROR: cannot open lasreaderpipeon with lasreaderbin\n"); delete lasreaderpipeon; return 0; } @@ -837,13 +933,14 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth lasreadershp = new LASreaderSHPrescalereoffset(scale_factor[0], scale_factor[1], scale_factor[2], offset[0], offset[1], offset[2]); if (!lasreadershp->open(file_name)) { - REprintf("ERROR: cannot open lasreadershp with file name '%s'\n", file_name); + fprintf(stderr,"ERROR: cannot open lasreadershp with file name '%s'\n", file_name); delete lasreadershp; return 0; } if (files_are_flightlines) lasreadershp->header.file_source_ID = file_name_current + files_are_flightlines + files_are_flightlines_index; if (filter) lasreadershp->set_filter(filter); if (transform) lasreadershp->set_transform(transform); + if (ignore) lasreadershp->set_ignore(ignore); if (inside_tile) lasreadershp->inside_tile(inside_tile[0], inside_tile[1], inside_tile[2]); if (inside_circle) lasreadershp->inside_circle(inside_circle[0], inside_circle[1], inside_circle[2]); if (inside_rectangle) lasreadershp->inside_rectangle(inside_rectangle[0], inside_rectangle[1], inside_rectangle[2], inside_rectangle[3]); @@ -853,7 +950,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderStored* lasreaderstored = new LASreaderStored(); if (!lasreaderstored->open(lasreadershp)) { - REprintf( "ERROR: could not open lasreaderstored with lasreadershp\n"); + fprintf(stderr, "ERROR: could not open lasreaderstored with lasreadershp\n"); delete lasreaderstored; return 0; } @@ -868,7 +965,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderPipeOn* lasreaderpipeon = new LASreaderPipeOn(); if (!lasreaderpipeon->open(lasreader)) { - REprintf("ERROR: cannot open lasreaderpipeon with lasreadershp\n"); + fprintf(stderr,"ERROR: cannot open lasreaderpipeon with lasreadershp\n"); delete lasreaderpipeon; return 0; } @@ -892,13 +989,14 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth lasreaderasc = new LASreaderASCrescalereoffset(scale_factor[0], scale_factor[1], scale_factor[2], offset[0], offset[1], offset[2]); if (!lasreaderasc->open(file_name, comma_not_point)) { - REprintf("ERROR: cannot open lasreaderasc with file name '%s'\n", file_name); + fprintf(stderr,"ERROR: cannot open lasreaderasc with file name '%s'\n", file_name); delete lasreaderasc; return 0; } if (files_are_flightlines) lasreaderasc->header.file_source_ID = file_name_current + files_are_flightlines + files_are_flightlines_index; if (filter) lasreaderasc->set_filter(filter); if (transform) lasreaderasc->set_transform(transform); + if (ignore) lasreaderasc->set_ignore(ignore); if (inside_tile) lasreaderasc->inside_tile(inside_tile[0], inside_tile[1], inside_tile[2]); if (inside_circle) lasreaderasc->inside_circle(inside_circle[0], inside_circle[1], inside_circle[2]); if (inside_rectangle) lasreaderasc->inside_rectangle(inside_rectangle[0], inside_rectangle[1], inside_rectangle[2], inside_rectangle[3]); @@ -908,7 +1006,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderStored* lasreaderstored = new LASreaderStored(); if (!lasreaderstored->open(lasreaderasc)) { - REprintf( "ERROR: could not open lasreaderstored with lasreaderasc\n"); + fprintf(stderr, "ERROR: could not open lasreaderstored with lasreaderasc\n"); delete lasreaderstored; return 0; } @@ -923,7 +1021,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderPipeOn* lasreaderpipeon = new LASreaderPipeOn(); if (!lasreaderpipeon->open(lasreader)) { - REprintf("ERROR: cannot open lasreaderpipeon with lasreaderasc\n"); + fprintf(stderr,"ERROR: cannot open lasreaderpipeon with lasreaderasc\n"); delete lasreaderpipeon; return 0; } @@ -947,13 +1045,14 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth lasreaderbil = new LASreaderBILrescalereoffset(scale_factor[0], scale_factor[1], scale_factor[2], offset[0], offset[1], offset[2]); if (!lasreaderbil->open(file_name)) { - REprintf("ERROR: cannot open lasreaderbil with file name '%s'\n", file_name); + fprintf(stderr,"ERROR: cannot open lasreaderbil with file name '%s'\n", file_name); delete lasreaderbil; return 0; } if (files_are_flightlines) lasreaderbil->header.file_source_ID = file_name_current + files_are_flightlines + files_are_flightlines_index; if (filter) lasreaderbil->set_filter(filter); if (transform) lasreaderbil->set_transform(transform); + if (ignore) lasreaderbil->set_ignore(ignore); if (inside_tile) lasreaderbil->inside_tile(inside_tile[0], inside_tile[1], inside_tile[2]); if (inside_circle) lasreaderbil->inside_circle(inside_circle[0], inside_circle[1], inside_circle[2]); if (inside_rectangle) lasreaderbil->inside_rectangle(inside_rectangle[0], inside_rectangle[1], inside_rectangle[2], inside_rectangle[3]); @@ -963,7 +1062,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderStored* lasreaderstored = new LASreaderStored(); if (!lasreaderstored->open(lasreaderbil)) { - REprintf( "ERROR: could not open lasreaderstored with lasreaderbil\n"); + fprintf(stderr, "ERROR: could not open lasreaderstored with lasreaderbil\n"); delete lasreaderstored; return 0; } @@ -978,7 +1077,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderPipeOn* lasreaderpipeon = new LASreaderPipeOn(); if (!lasreaderpipeon->open(lasreader)) { - REprintf("ERROR: cannot open lasreaderpipeon with lasreaderbil\n"); + fprintf(stderr,"ERROR: cannot open lasreaderpipeon with lasreaderbil\n"); delete lasreaderpipeon; return 0; } @@ -1002,13 +1101,14 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth lasreaderdtm = new LASreaderDTMrescalereoffset(scale_factor[0], scale_factor[1], scale_factor[2], offset[0], offset[1], offset[2]); if (!lasreaderdtm->open(file_name)) { - REprintf("ERROR: cannot open lasreaderdtm with file name '%s'\n", file_name); + fprintf(stderr,"ERROR: cannot open lasreaderdtm with file name '%s'\n", file_name); delete lasreaderdtm; return 0; } if (files_are_flightlines) lasreaderdtm->header.file_source_ID = file_name_current + files_are_flightlines + files_are_flightlines_index; if (filter) lasreaderdtm->set_filter(filter); if (transform) lasreaderdtm->set_transform(transform); + if (ignore) lasreaderdtm->set_ignore(ignore); if (inside_tile) lasreaderdtm->inside_tile(inside_tile[0], inside_tile[1], inside_tile[2]); if (inside_circle) lasreaderdtm->inside_circle(inside_circle[0], inside_circle[1], inside_circle[2]); if (inside_rectangle) lasreaderdtm->inside_rectangle(inside_rectangle[0], inside_rectangle[1], inside_rectangle[2], inside_rectangle[3]); @@ -1018,7 +1118,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderStored* lasreaderstored = new LASreaderStored(); if (!lasreaderstored->open(lasreaderdtm)) { - REprintf( "ERROR: could not open lasreaderstored with lasreaderdtm\n"); + fprintf(stderr, "ERROR: could not open lasreaderstored with lasreaderdtm\n"); delete lasreaderstored; return 0; } @@ -1033,7 +1133,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderPipeOn* lasreaderpipeon = new LASreaderPipeOn(); if (!lasreaderpipeon->open(lasreader)) { - REprintf("ERROR: cannot open lasreaderpipeon with lasreaderdtm\n"); + fprintf(stderr,"ERROR: cannot open lasreaderpipeon with lasreaderdtm\n"); delete lasreaderpipeon; return 0; } @@ -1053,13 +1153,14 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth lasreaderply->set_offset(offset); if (!lasreaderply->open(file_name, point_type, populate_header)) { - REprintf("ERROR: cannot open lasreaderply with file name '%s'\n", file_name); + fprintf(stderr,"ERROR: cannot open lasreaderply with file name '%s'\n", file_name); delete lasreaderply; return 0; } if (files_are_flightlines) lasreaderply->header.file_source_ID = file_name_current + files_are_flightlines + files_are_flightlines_index; if (filter) lasreaderply->set_filter(filter); if (transform) lasreaderply->set_transform(transform); + if (ignore) lasreaderply->set_ignore(ignore); if (inside_tile) lasreaderply->inside_tile(inside_tile[0], inside_tile[1], inside_tile[2]); if (inside_circle) lasreaderply->inside_circle(inside_circle[0], inside_circle[1], inside_circle[2]); if (inside_rectangle) lasreaderply->inside_rectangle(inside_rectangle[0], inside_rectangle[1], inside_rectangle[2], inside_rectangle[3]); @@ -1069,7 +1170,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderStored* lasreaderstored = new LASreaderStored(); if (!lasreaderstored->open(lasreaderply)) { - REprintf( "ERROR: could not open lasreaderstored with lasreaderply\n"); + fprintf(stderr, "ERROR: could not open lasreaderstored with lasreaderply\n"); delete lasreaderstored; return 0; } @@ -1084,7 +1185,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderPipeOn* lasreaderpipeon = new LASreaderPipeOn(); if (!lasreaderpipeon->open(lasreader)) { - REprintf("ERROR: cannot open lasreaderpipeon with lasreaderply\n"); + fprintf(stderr,"ERROR: cannot open lasreaderpipeon with lasreaderply\n"); delete lasreaderpipeon; return 0; } @@ -1108,7 +1209,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth lasreaderqfit = new LASreaderQFITrescalereoffset(scale_factor[0], scale_factor[1], scale_factor[2], offset[0], offset[1], offset[2]); if (!lasreaderqfit->open(file_name)) { - REprintf("ERROR: cannot open lasreaderqfit with file name '%s'\n", file_name); + fprintf(stderr,"ERROR: cannot open lasreaderqfit with file name '%s'\n", file_name); delete lasreaderqfit; return 0; } @@ -1120,6 +1221,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth if (files_are_flightlines) lasreaderqfit->header.file_source_ID = file_name_current + files_are_flightlines + files_are_flightlines_index; if (filter) lasreaderqfit->set_filter(filter); if (transform) lasreaderqfit->set_transform(transform); + if (ignore) lasreaderqfit->set_ignore(ignore); if (inside_tile) lasreaderqfit->inside_tile(inside_tile[0], inside_tile[1], inside_tile[2]); if (inside_circle) lasreaderqfit->inside_circle(inside_circle[0], inside_circle[1], inside_circle[2]); if (inside_rectangle) lasreaderqfit->inside_rectangle(inside_rectangle[0], inside_rectangle[1], inside_rectangle[2], inside_rectangle[3]); @@ -1129,7 +1231,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderStored* lasreaderstored = new LASreaderStored(); if (!lasreaderstored->open(lasreaderqfit)) { - REprintf( "ERROR: could not open lasreaderstored with lasreaderqfit\n"); + fprintf(stderr, "ERROR: could not open lasreaderstored with lasreaderqfit\n"); delete lasreaderstored; return 0; } @@ -1144,7 +1246,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderPipeOn* lasreaderpipeon = new LASreaderPipeOn(); if (!lasreaderpipeon->open(lasreader)) { - REprintf("ERROR: cannot open lasreaderpipeon with lasreaderqfit\n"); + fprintf(stderr,"ERROR: cannot open lasreaderpipeon with lasreaderqfit\n"); delete lasreaderpipeon; return 0; } @@ -1175,13 +1277,14 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth } if (!lasreadertxt->open(file_name, point_type, parse_string, skip_lines, populate_header)) { - REprintf("ERROR: cannot open lasreadertxt with file name '%s'\n", file_name); + fprintf(stderr,"ERROR: cannot open lasreadertxt with file name '%s'\n", file_name); delete lasreadertxt; return 0; } if (files_are_flightlines) lasreadertxt->header.file_source_ID = file_name_current + files_are_flightlines + files_are_flightlines_index; if (filter) lasreadertxt->set_filter(filter); if (transform) lasreadertxt->set_transform(transform); + if (ignore) lasreadertxt->set_ignore(ignore); if (inside_tile) lasreadertxt->inside_tile(inside_tile[0], inside_tile[1], inside_tile[2]); if (inside_circle) lasreadertxt->inside_circle(inside_circle[0], inside_circle[1], inside_circle[2]); if (inside_rectangle) lasreadertxt->inside_rectangle(inside_rectangle[0], inside_rectangle[1], inside_rectangle[2], inside_rectangle[3]); @@ -1191,7 +1294,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderStored* lasreaderstored = new LASreaderStored(); if (!lasreaderstored->open(lasreadertxt)) { - REprintf( "ERROR: could not open lasreaderstored with lasreadertxt\n"); + fprintf(stderr, "ERROR: could not open lasreaderstored with lasreadertxt\n"); delete lasreaderstored; return 0; } @@ -1206,7 +1309,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderPipeOn* lasreaderpipeon = new LASreaderPipeOn(); if (!lasreaderpipeon->open(lasreader)) { - REprintf("ERROR: cannot open lasreaderpipeon with lasreadertxt\n"); + fprintf(stderr,"ERROR: cannot open lasreaderpipeon with lasreadertxt\n"); delete lasreaderpipeon; return 0; } @@ -1242,13 +1345,14 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth } if (!lasreadertxt->open(stdin, 0, point_type, parse_string, skip_lines, FALSE)) { - REprintf("ERROR: cannot open lasreadertxt with file name '%s'\n", file_name); + fprintf(stderr,"ERROR: cannot open lasreadertxt with file name '%s'\n", file_name); delete lasreadertxt; return 0; } if (files_are_flightlines) lasreadertxt->header.file_source_ID = file_name_current + files_are_flightlines + files_are_flightlines_index; if (filter) lasreadertxt->set_filter(filter); if (transform) lasreadertxt->set_transform(transform); + if (ignore) lasreadertxt->set_ignore(ignore); if (inside_tile) lasreadertxt->inside_tile(inside_tile[0], inside_tile[1], inside_tile[2]); if (inside_circle) lasreadertxt->inside_circle(inside_circle[0], inside_circle[1], inside_circle[2]); if (inside_rectangle) lasreadertxt->inside_rectangle(inside_rectangle[0], inside_rectangle[1], inside_rectangle[2], inside_rectangle[3]); @@ -1258,7 +1362,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderStored* lasreaderstored = new LASreaderStored(); if (!lasreaderstored->open(lasreadertxt)) { - REprintf( "ERROR: could not open lasreaderstored with lasreadertxt\n"); + fprintf(stderr, "ERROR: could not open lasreaderstored with lasreadertxt\n"); delete lasreaderstored; return 0; } @@ -1273,7 +1377,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderPipeOn* lasreaderpipeon = new LASreaderPipeOn(); if (!lasreaderpipeon->open(lasreader)) { - REprintf("ERROR: cannot open lasreaderpipeon with lasreadertxt\n"); + fprintf(stderr,"ERROR: cannot open lasreaderpipeon with lasreadertxt\n"); delete lasreaderpipeon; return 0; } @@ -1297,12 +1401,13 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth lasreaderlas = new LASreaderLASrescalereoffset(scale_factor[0], scale_factor[1], scale_factor[2], offset[0], offset[1], offset[2]); if (!lasreaderlas->open(stdin)) { - REprintf("ERROR: cannot open lasreaderlas from stdin \n"); + fprintf(stderr,"ERROR: cannot open lasreaderlas from stdin \n"); delete lasreaderlas; return 0; } if (filter) lasreaderlas->set_filter(filter); if (transform) lasreaderlas->set_transform(transform); + if (ignore) lasreaderlas->set_ignore(ignore); if (inside_tile) lasreaderlas->inside_tile(inside_tile[0], inside_tile[1], inside_tile[2]); if (inside_circle) lasreaderlas->inside_circle(inside_circle[0], inside_circle[1], inside_circle[2]); if (inside_rectangle) lasreaderlas->inside_rectangle(inside_rectangle[0], inside_rectangle[1], inside_rectangle[2], inside_rectangle[3]); @@ -1312,7 +1417,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderStored* lasreaderstored = new LASreaderStored(); if (!lasreaderstored->open(lasreaderlas)) { - REprintf( "ERROR: could not open lasreaderstored with lasreaderlas\n"); + fprintf(stderr, "ERROR: could not open lasreaderstored with lasreaderlas\n"); delete lasreaderstored; return 0; } @@ -1327,7 +1432,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderPipeOn* lasreaderpipeon = new LASreaderPipeOn(); if (!lasreaderpipeon->open(lasreader)) { - REprintf("ERROR: cannot open lasreaderpipeon with lasreaderlas from stdin\n"); + fprintf(stderr,"ERROR: cannot open lasreaderpipeon with lasreaderlas from stdin\n"); delete lasreaderpipeon; return 0; } @@ -1349,7 +1454,7 @@ BOOL LASreadOpener::reopen(LASreader* lasreader, BOOL remain_buffered) { if (lasreader == 0) { - REprintf("ERROR: pointer to LASreader is NULL\n"); + fprintf(stderr,"ERROR: pointer to LASreader is NULL\n"); } // make sure the LASreader was closed @@ -1371,7 +1476,7 @@ BOOL LASreadOpener::reopen(LASreader* lasreader, BOOL remain_buffered) LASreaderStored* lasreaderstored = (LASreaderStored*)lasreader; if (!lasreaderstored->reopen()) { - REprintf( "ERROR: could not reopen lasreaderstored for stored input\n"); + fprintf(stderr, "ERROR: could not reopen lasreaderstored for stored input\n"); return FALSE; } return TRUE; @@ -1383,7 +1488,7 @@ BOOL LASreadOpener::reopen(LASreader* lasreader, BOOL remain_buffered) LASreaderMerged* lasreadermerged = (LASreaderMerged*)lasreader; if (!lasreadermerged->reopen()) { - REprintf("ERROR: cannot reopen lasreadermerged\n"); + fprintf(stderr,"ERROR: cannot reopen lasreadermerged\n"); return FALSE; } if (inside_rectangle || inside_tile || inside_circle) @@ -1400,7 +1505,7 @@ BOOL LASreadOpener::reopen(LASreader* lasreader, BOOL remain_buffered) LASreaderBuffered* lasreaderbuffered = (LASreaderBuffered*)lasreader; if (!lasreaderbuffered->reopen()) { - REprintf("ERROR: cannot reopen lasreaderbuffered\n"); + fprintf(stderr,"ERROR: cannot reopen lasreaderbuffered\n"); return FALSE; } if (inside_rectangle || inside_tile || inside_circle) @@ -1421,7 +1526,7 @@ BOOL LASreadOpener::reopen(LASreader* lasreader, BOOL remain_buffered) LASreaderLAS* lasreaderlas = (LASreaderLAS*)lasreader; if (!lasreaderlas->open(file_name, io_ibuffer_size, FALSE, decompress_selective)) { - REprintf("ERROR: cannot reopen lasreaderlas with file name '%s'\n", file_name); + fprintf(stderr,"ERROR: cannot reopen lasreaderlas with file name '%s'\n", file_name); return FALSE; } if (inside_rectangle || inside_tile || inside_circle) @@ -1438,7 +1543,7 @@ BOOL LASreadOpener::reopen(LASreader* lasreader, BOOL remain_buffered) LASreaderBIN* lasreaderbin = (LASreaderBIN*)lasreader; if (!lasreaderbin->open(file_name)) { - REprintf("ERROR: cannot reopen lasreaderbin with file name '%s'\n", file_name); + fprintf(stderr,"ERROR: cannot reopen lasreaderbin with file name '%s'\n", file_name); return FALSE; } if (inside_rectangle || inside_tile || inside_circle) @@ -1455,7 +1560,7 @@ BOOL LASreadOpener::reopen(LASreader* lasreader, BOOL remain_buffered) LASreaderSHP* lasreadershp = (LASreaderSHP*)lasreader; if (!lasreadershp->reopen(file_name)) { - REprintf("ERROR: cannot reopen lasreadershp with file name '%s'\n", file_name); + fprintf(stderr,"ERROR: cannot reopen lasreadershp with file name '%s'\n", file_name); return FALSE; } if (inside_rectangle || inside_tile || inside_circle) @@ -1472,7 +1577,7 @@ BOOL LASreadOpener::reopen(LASreader* lasreader, BOOL remain_buffered) LASreaderQFIT* lasreaderqfit = (LASreaderQFIT*)lasreader; if (!lasreaderqfit->reopen(file_name)) { - REprintf("ERROR: cannot reopen lasreaderqfit with file name '%s'\n", file_name); + fprintf(stderr,"ERROR: cannot reopen lasreaderqfit with file name '%s'\n", file_name); return FALSE; } if (inside_rectangle || inside_tile || inside_circle) @@ -1489,7 +1594,7 @@ BOOL LASreadOpener::reopen(LASreader* lasreader, BOOL remain_buffered) LASreaderASC* lasreaderasc = (LASreaderASC*)lasreader; if (!lasreaderasc->reopen(file_name)) { - REprintf("ERROR: cannot reopen lasreaderasc with file name '%s'\n", file_name); + fprintf(stderr,"ERROR: cannot reopen lasreaderasc with file name '%s'\n", file_name); return FALSE; } if (inside_rectangle || inside_tile || inside_circle) @@ -1506,7 +1611,7 @@ BOOL LASreadOpener::reopen(LASreader* lasreader, BOOL remain_buffered) LASreaderBIL* lasreaderbil = (LASreaderBIL*)lasreader; if (!lasreaderbil->reopen(file_name)) { - REprintf("ERROR: cannot reopen lasreaderbil with file name '%s'\n", file_name); + fprintf(stderr,"ERROR: cannot reopen lasreaderbil with file name '%s'\n", file_name); return FALSE; } if (inside_rectangle || inside_tile || inside_circle) @@ -1523,7 +1628,7 @@ BOOL LASreadOpener::reopen(LASreader* lasreader, BOOL remain_buffered) LASreaderDTM* lasreaderdtm = (LASreaderDTM*)lasreader; if (!lasreaderdtm->reopen(file_name)) { - REprintf("ERROR: cannot reopen lasreaderdtm with file name '%s'\n", file_name); + fprintf(stderr,"ERROR: cannot reopen lasreaderdtm with file name '%s'\n", file_name); return FALSE; } if (inside_rectangle || inside_tile || inside_circle) @@ -1540,7 +1645,7 @@ BOOL LASreadOpener::reopen(LASreader* lasreader, BOOL remain_buffered) LASreaderTXT* lasreadertxt = (LASreaderTXT*)lasreader; if (!lasreadertxt->reopen(file_name)) { - REprintf("ERROR: cannot reopen lasreadertxt with file name '%s'\n", file_name); + fprintf(stderr,"ERROR: cannot reopen lasreadertxt with file name '%s'\n", file_name); return FALSE; } if (inside_rectangle || inside_tile || inside_circle) @@ -1556,7 +1661,7 @@ BOOL LASreadOpener::reopen(LASreader* lasreader, BOOL remain_buffered) } else { - REprintf("ERROR: no lasreader input specified\n"); + fprintf(stderr,"ERROR: no lasreader input specified\n"); return FALSE; } } @@ -1588,30 +1693,30 @@ LASwaveform13reader* LASreadOpener::open_waveform13(const LASheader* lasheader) void LASreadOpener::usage() const { - REprintf("Supported LAS Inputs\n"); - REprintf(" -i lidar.las\n"); - REprintf(" -i lidar.laz\n"); - REprintf(" -i lidar1.las lidar2.las lidar3.las -merged\n"); - REprintf(" -i *.las - merged\n"); - REprintf(" -i flight0??.laz flight1??.laz\n"); - REprintf(" -i terrasolid.bin\n"); - REprintf(" -i esri.shp\n"); - REprintf(" -i nasa.qi\n"); - REprintf(" -i lidar.txt -iparse xyzti -iskip 2 (on-the-fly from ASCII)\n"); - REprintf(" -i lidar.txt -iparse xyzi -itranslate_intensity 1024\n"); - REprintf(" -lof file_list.txt\n"); - REprintf(" -stdin (pipe from stdin)\n"); - REprintf(" -rescale 0.01 0.01 0.001\n"); - REprintf(" -rescale_xy 0.01 0.01\n"); - REprintf(" -rescale_z 0.01\n"); - REprintf(" -reoffset 600000 4000000 0\n"); - REprintf("Fast AOI Queries for LAS/LAZ with spatial indexing LAX files\n"); - REprintf(" -inside min_x min_y max_x max_y\n"); - REprintf(" -inside_tile ll_x ll_y size\n"); - REprintf(" -inside_circle center_x center_y radius\n"); -} - -BOOL LASreadOpener::parse(int argc, char* argv[]) + fprintf(stderr,"Supported LAS Inputs\n"); + fprintf(stderr," -i lidar.las\n"); + fprintf(stderr," -i lidar.laz\n"); + fprintf(stderr," -i lidar1.las lidar2.las lidar3.las -merged\n"); + fprintf(stderr," -i *.las - merged\n"); + fprintf(stderr," -i flight0??.laz flight1??.laz\n"); + fprintf(stderr," -i terrasolid.bin\n"); + fprintf(stderr," -i esri.shp\n"); + fprintf(stderr," -i nasa.qi\n"); + fprintf(stderr," -i lidar.txt -iparse xyzti -iskip 2 (on-the-fly from ASCII)\n"); + fprintf(stderr," -i lidar.txt -iparse xyzi -itranslate_intensity 1024\n"); + fprintf(stderr," -lof file_list.txt\n"); + fprintf(stderr," -stdin (pipe from stdin)\n"); + fprintf(stderr," -rescale 0.01 0.01 0.001\n"); + fprintf(stderr," -rescale_xy 0.01 0.01\n"); + fprintf(stderr," -rescale_z 0.01\n"); + fprintf(stderr," -reoffset 600000 4000000 0\n"); + fprintf(stderr,"Fast AOI Queries for LAS/LAZ with spatial indexing LAX files\n"); + fprintf(stderr," -inside min_x min_y max_x max_y\n"); + fprintf(stderr," -inside_tile ll_x ll_y size\n"); + fprintf(stderr," -inside_circle center_x center_y radius\n"); +} + +BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) { int i; for (i = 1; i < argc; i++) @@ -1624,412 +1729,659 @@ BOOL LASreadOpener::parse(int argc, char* argv[]) { LASfilter().usage(); LAStransform().usage(); + LASignore().usage(); usage(); return TRUE; } - else if (strcmp(argv[i],"-i") == 0) + else if (strncmp(argv[i], "-i", 2) == 0) { - if ((i+1) >= argc) - { - REprintf("ERROR: '%s' needs at least 1 argument: file_name or wild_card\n", argv[i]); - return FALSE; - } - *argv[i]='\0'; - i+=1; - do + if (strcmp(argv[i],"-i") == 0) { - add_file_name(argv[i], unique); + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs at least 1 argument: file_name or wild_card\n", argv[i]); + return FALSE; + } *argv[i]='\0'; i+=1; - } while ((i < argc) && (*argv[i] != '-') && (*argv[i] != '\0')); - i-=1; - } - else if (strcmp(argv[i],"-unique") == 0) - { - unique = TRUE; - *argv[i]='\0'; - } - else if (strncmp(argv[i],"-inside", 7) == 0) - { - if (strcmp(argv[i],"-inside_tile") == 0) + do + { + add_file_name(argv[i], unique); + *argv[i]='\0'; + i+=1; + } while ((i < argc) && (*argv[i] != '-') && (*argv[i] != '\0')); + i-=1; + } + else if (strncmp(argv[i],"-ignore_", 8) == 0) { - if ((i+3) >= argc) + if (parse_ignore) { - REprintf("ERROR: '%s' needs 3 arguments: ll_x, ll_y, size\n", argv[i]); + if (ignore == 0) + { + ignore = new LASignore(); + } + if (!ignore->parse(i, argc, argv)) + { + delete ignore; + ignore = 0; + return FALSE; + } + } + else + { + fprintf(stderr,"ERROR: this tool does not process '-ignore_xxxx' options\n"); return FALSE; } - set_inside_tile((F32)atof(argv[i+1]), (F32)atof(argv[i+2]), (F32)atof(argv[i+3])); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } - else if (strcmp(argv[i],"-inside_circle") == 0) + else if (strncmp(argv[i],"-inside", 7) == 0) { - if ((i+3) >= argc) + if (strcmp(argv[i],"-inside_tile") == 0) + { + if ((i+3) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: ll_x ll_y size\n", argv[i]); + return FALSE; + } + F32 ll_x; + if (sscanf(argv[i+1], "%f", &ll_x) != 1) + { + fprintf(stderr, "ERROR: '%s' needs 3 arguments: ll_x ll_y size, but '%s' is not a valid ll_x.\n", argv[i], argv[i+1]); + return FALSE; + } + F32 ll_y; + if (sscanf(argv[i+2], "%f", &ll_y) != 1) + { + fprintf(stderr, "ERROR: '%s' needs 3 arguments: ll_x ll_y size, but '%s' is not a valid ll_y.\n", argv[i], argv[i+2]); + return FALSE; + } + F32 size; + if (sscanf(argv[i+3], "%f", &size) != 1) + { + fprintf(stderr, "ERROR: '%s' needs 3 arguments: ll_x ll_y size, but '%s' is not a valid size.\n", argv[i], argv[i+3]); + return FALSE; + } + if (size <= 0.0f) + { + fprintf(stderr, "ERROR: '%s' needs 3 arguments: ll_x ll_y size, but %f is not valid a size.\n", argv[i], size); + return FALSE; + } + set_inside_tile(ll_x, ll_y, size); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + } + else if (strcmp(argv[i],"-inside_circle") == 0) + { + if ((i+3) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: center_x center_y radius\n", argv[i]); + return FALSE; + } + F64 center_x; + if (sscanf(argv[i+1], "%lf", ¢er_x) != 1) + { + fprintf(stderr, "ERROR: '%s' needs 3 arguments: center_x center_y radius, but '%s' is not a valid center_x.\n", argv[i], argv[i+1]); + return FALSE; + } + F64 center_y; + if (sscanf(argv[i+2], "%lf", ¢er_y) != 1) + { + fprintf(stderr, "ERROR: '%s' needs 3 arguments: center_x center_y radius, but '%s' is not a valid center_y.\n", argv[i], argv[i+2]); + return FALSE; + } + F64 radius; + if (sscanf(argv[i+3], "%lf", &radius) != 1) + { + fprintf(stderr, "ERROR: '%s' needs 3 arguments: center_x center_y radius, but '%s' is not a valid radius.\n", argv[i], argv[i+3]); + return FALSE; + } + if (radius <= 0.0f) + { + fprintf(stderr, "ERROR: '%s' needs 3 arguments: center_x center_y radius, but %lf is not valid a radius.\n", argv[i], radius); + return FALSE; + } + set_inside_circle(center_x, center_y, radius); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + } + else if (strcmp(argv[i],"-inside") == 0 || strcmp(argv[i],"-inside_rectangle") == 0) + { + if ((i+4) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y\n", argv[i]); + return FALSE; + } + F64 min_x; + if (sscanf(argv[i+1], "%lf", &min_x) != 1) + { + fprintf(stderr, "ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y, but '%s' is not a valid min_x.\n", argv[i], argv[i+1]); + return FALSE; + } + F64 min_y; + if (sscanf(argv[i+2], "%lf", &min_y) != 1) + { + fprintf(stderr, "ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y, but '%s' is not a valid min_y.\n", argv[i], argv[i+2]); + return FALSE; + } + F64 max_x; + if (sscanf(argv[i+3], "%lf", &max_x) != 1) + { + fprintf(stderr, "ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y, but '%s' is not a valid max_x.\n", argv[i], argv[i+3]); + return FALSE; + } + F64 max_y; + if (sscanf(argv[i+4], "%lf", &max_y) != 1) + { + fprintf(stderr, "ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y, but '%s' is not a valid max_y.\n", argv[i], argv[i+4]); + return FALSE; + } + if (min_x >= max_x) + { + fprintf(stderr, "ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y, but %lf / %lf are not a valid min_x / max_x pair.\n", argv[i], min_x, max_x); + return FALSE; + } + if (min_y >= max_y) + { + fprintf(stderr, "ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y, but %lf / %lf are not a valid min_y / max_y pair.\n", argv[i], min_y, max_y); + return FALSE; + } + set_inside_rectangle(min_x, min_y, max_x, max_y); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; i+=4; + } + else { - REprintf("ERROR: '%s' needs 3 arguments: center_x, center_y, radius\n", argv[i]); + fprintf(stderr,"ERROR: unknown '-inside' option '%s'\n", argv[i]); return FALSE; } - set_inside_circle(atof(argv[i+1]), atof(argv[i+2]), atof(argv[i+3])); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } - else if (strcmp(argv[i],"-inside") == 0 || strcmp(argv[i],"-inside_rectangle") == 0) + else if (strcmp(argv[i],"-iadd_extra") == 0 || strcmp(argv[i],"-iadd_attribute") == 0) { - if ((i+4) >= argc) + if ((i+3) >= argc) { - REprintf("ERROR: '%s' needs 4 arguments: min_x, min_y, max_x, max_y\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: data_type name description\n", argv[i]); return FALSE; } - set_inside_rectangle(atof(argv[i+1]), atof(argv[i+2]), atof(argv[i+3]), atof(argv[i+4])); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; i+=4; - } - else - { - REprintf("ERROR: unknown '-inside' option '%s'\n", argv[i]); - return FALSE; - } - } - else if (strcmp(argv[i],"-comma_not_point") == 0) - { - comma_not_point = TRUE; - *argv[i]='\0'; - } - else if (strcmp(argv[i],"-stdin") == 0) - { - use_stdin = TRUE; - *argv[i]='\0'; - } - else if (strcmp(argv[i],"-lof") == 0) - { - if ((i+1) >= argc) - { - REprintf("ERROR: '%s' needs 1 argument: list_of_files\n", argv[i]); - return FALSE; - } - if (!add_list_of_files(argv[i+1], unique)) - { - REprintf( "ERROR: cannot load list of files '%s'\n", argv[i+1]); - return FALSE; - } - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; - } - else if (strcmp(argv[i],"-rescale") == 0) - { - if ((i+3) >= argc) - { - REprintf("ERROR: '%s' needs 3 arguments: rescale_x rescale_y rescale_z\n", argv[i]); - return FALSE; - } - F64 scale_factor[3]; - scale_factor[0] = atof(argv[i+1]); - scale_factor[1] = atof(argv[i+2]); - scale_factor[2] = atof(argv[i+3]); - set_scale_factor(scale_factor); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; - } - else if (strcmp(argv[i],"-rescale_xy") == 0) - { - if ((i+2) >= argc) - { - REprintf("ERROR: '%s' needs 2 argument: rescale_x rescale_y\n", argv[i]); - return FALSE; - } - F64 scale_factor[3]; - scale_factor[0] = atof(argv[i+1]); - scale_factor[1] = atof(argv[i+2]); - scale_factor[2] = 0; - set_scale_factor(scale_factor); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; - } - else if (strcmp(argv[i],"-rescale_z") == 0) - { - if ((i+1) >= argc) - { - REprintf("ERROR: '%s' needs 1 argument: scale\n", argv[i]); - return FALSE; - } - F64 scale_factor[3]; - scale_factor[0] = 0; - scale_factor[1] = 0; - scale_factor[2] = atof(argv[i+1]); - set_scale_factor(scale_factor); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; - } - else if (strcmp(argv[i],"-reoffset") == 0) - { - if ((i+3) >= argc) - { - REprintf("ERROR: '%s' needs 3 arguments: reoffset_x, reoffset_y, reoffset_z\n", argv[i]); - return FALSE; - } - F64 offset[3]; - offset[0] = atof(argv[i+1]); - offset[1] = atof(argv[i+2]); - offset[2] = atof(argv[i+3]); - set_offset(offset); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; - } - else if (strcmp(argv[i],"-auto_reoffset") == 0) - { - set_auto_reoffset(TRUE); - *argv[i]='\0'; - } - else if (strcmp(argv[i],"-files_are_flightlines") == 0 || strcmp(argv[i],"-faf") == 0) - { - if (((i+1) < argc) && ('1' <= argv[i+1][0]) && (argv[i+1][0] <= '9')) - { - set_files_are_flightlines(atoi(argv[i+1])); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; - } - else - { - set_files_are_flightlines(1); - *argv[i]='\0'; - } - } - else if (strcmp(argv[i],"-faf_index") == 0) - { - if ((i+1) >= argc) - { - REprintf("ERROR: '%s' needs 1 argument: index\n", argv[i]); - return FALSE; - } - set_files_are_flightlines_index(atoi(argv[i+1])); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; - } - else if (strcmp(argv[i],"-apply_file_source_ID") == 0) - { - set_apply_file_source_ID(TRUE); - *argv[i]='\0'; - } - else if (strcmp(argv[i],"-itranslate_intensity") == 0) - { - if ((i+1) >= argc) - { - REprintf("ERROR: '%s' needs 1 argument: offset\n", argv[i]); - return FALSE; - } - set_translate_intensity((F32)atof(argv[i+1])); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; - } - else if (strcmp(argv[i],"-iscale_intensity") == 0) - { - if ((i+1) >= argc) - { - REprintf("ERROR: '%s' needs 1 argument: scale\n", argv[i]); - return FALSE; - } - set_scale_intensity((F32)atof(argv[i+1])); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; - } - else if (strcmp(argv[i],"-itranslate_scan_angle") == 0) - { - if ((i+1) >= argc) - { - REprintf("ERROR: '%s' needs 1 argument: offset\n", argv[i]); - return FALSE; - } - set_translate_scan_angle((F32)atof(argv[i+1])); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; - } - else if (strcmp(argv[i],"-iscale_scan_angle") == 0) - { - if ((i+1) >= argc) - { - REprintf("ERROR: '%s' needs 1 argument: scale\n", argv[i]); - return FALSE; - } - set_scale_scan_angle((F32)atof(argv[i+1])); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; - } - else if (strcmp(argv[i],"-iadd_extra") == 0 || strcmp(argv[i],"-iadd_attribute") == 0) - { - if ((i+3) >= argc) - { - REprintf("ERROR: '%s' needs 3 arguments: data_type name description\n", argv[i]); - return FALSE; - } - if (((i+4) < argc) && (atof(argv[i+4]) != 0.0)) - { - if (((i+5) < argc) && ((atof(argv[i+5]) != 0.0) || (strcmp(argv[i+5], "0") == 0) || (strcmp(argv[i+5], "0.0") == 0))) + if (((i+4) < argc) && (atof(argv[i+4]) != 0.0)) { - if (((i+6) < argc) && (atof(argv[i+6]) != 0.0)) + if (((i+5) < argc) && ((atof(argv[i+5]) != 0.0) || (strcmp(argv[i+5], "0") == 0) || (strcmp(argv[i+5], "0.0") == 0))) { - if (((i+7) < argc) && ((atof(argv[i+7]) != 0.0) || (strcmp(argv[i+7], "0") == 0) || (strcmp(argv[i+7], "0.0") == 0))) + if (((i+6) < argc) && (atof(argv[i+6]) != 0.0)) { - if (((i+8) < argc) && ((atof(argv[i+8]) != 0.0) || (strcmp(argv[i+8], "0") == 0) || (strcmp(argv[i+8], "0.0") == 0))) + if (((i+7) < argc) && ((atof(argv[i+7]) != 0.0) || (strcmp(argv[i+7], "0") == 0) || (strcmp(argv[i+7], "0.0") == 0))) { - add_attribute(atoi(argv[i+1]), argv[i+2], argv[i+3], atof(argv[i+4]), atof(argv[i+5]), atof(argv[i+6]), atof(argv[i+7]), atof(argv[i+8])); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; *argv[i+5]='\0'; *argv[i+6]='\0'; *argv[i+7]='\0'; *argv[i+8]='\0'; i+=8; + if (((i+8) < argc) && ((atof(argv[i+8]) != 0.0) || (strcmp(argv[i+8], "0") == 0) || (strcmp(argv[i+8], "0.0") == 0))) + { + add_attribute(atoi(argv[i+1]), argv[i+2], argv[i+3], atof(argv[i+4]), atof(argv[i+5]), atof(argv[i+6]), atof(argv[i+7]), atof(argv[i+8])); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; *argv[i+5]='\0'; *argv[i+6]='\0'; *argv[i+7]='\0'; *argv[i+8]='\0'; i+=8; + } + else + { + add_attribute(atoi(argv[i+1]), argv[i+2], argv[i+3], atof(argv[i+4]), atof(argv[i+5]), atof(argv[i+6]), atof(argv[i+7])); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; *argv[i+5]='\0'; *argv[i+6]='\0'; *argv[i+7]='\0'; i+=7; + } } else { - add_attribute(atoi(argv[i+1]), argv[i+2], argv[i+3], atof(argv[i+4]), atof(argv[i+5]), atof(argv[i+6]), atof(argv[i+7])); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; *argv[i+5]='\0'; *argv[i+6]='\0'; *argv[i+7]='\0'; i+=7; + add_attribute(atoi(argv[i+1]), argv[i+2], argv[i+3], atof(argv[i+4]), atof(argv[i+5]), atof(argv[i+6])); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; *argv[i+5]='\0'; *argv[i+6]='\0'; i+=6; } } else { - add_attribute(atoi(argv[i+1]), argv[i+2], argv[i+3], atof(argv[i+4]), atof(argv[i+5]), atof(argv[i+6])); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; *argv[i+5]='\0'; *argv[i+6]='\0'; i+=6; + add_attribute(atoi(argv[i+1]), argv[i+2], argv[i+3], atof(argv[i+4]), atof(argv[i+5])); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; *argv[i+5]='\0'; i+=5; } } else { - add_attribute(atoi(argv[i+1]), argv[i+2], argv[i+3], atof(argv[i+4]), atof(argv[i+5])); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; *argv[i+5]='\0'; i+=5; + add_attribute(atoi(argv[i+1]), argv[i+2], argv[i+3], atof(argv[i+4])); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; i+=4; } } else { - add_attribute(atoi(argv[i+1]), argv[i+2], argv[i+3], atof(argv[i+4])); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; i+=4; + add_attribute(atoi(argv[i+1]), argv[i+2], argv[i+3]); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } } - else + else if (strcmp(argv[i],"-iparse") == 0) { - add_attribute(atoi(argv[i+1]), argv[i+2], argv[i+3]); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; - } - } - else if (strcmp(argv[i],"-iparse") == 0) - { - if ((i+1) >= argc) + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: string\n", argv[i]); + return FALSE; + } + set_parse_string(argv[i+1]); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i],"-iskip") == 0) { - REprintf("ERROR: '%s' needs 1 argument: string\n", argv[i]); - return FALSE; + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: number_of_lines\n", argv[i]); + return FALSE; + } + U32 number_of_lines; + if (sscanf(argv[i+1], "%u", &number_of_lines) != 1) + { + fprintf(stderr, "ERROR: '%s' needs 1 argument: number_of_lines but '%s' is not a valid number.\n", argv[i], argv[i+1]); + return FALSE; + } + if (number_of_lines == 0) + { + fprintf(stderr, "ERROR: '%s' needs 1 argument: number_of_lines but %u is not valid.\n", argv[i], number_of_lines); + return FALSE; + } + set_skip_lines(number_of_lines); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i],"-io_ibuffer") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: size\n", argv[i]); + return FALSE; + } + U32 buffer_size; + if (sscanf(argv[i+1], "%u", &buffer_size) != 1) + { + fprintf(stderr, "ERROR: '%s' needs 1 argument: size but '%s' is not a valid size.\n", argv[i], argv[i+1]); + return FALSE; + } + if (buffer_size == 0) + { + fprintf(stderr, "ERROR: '%s' needs 1 argument: size but %u is not valid.\n", argv[i], buffer_size); + return FALSE; + } + set_io_ibuffer_size(buffer_size); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i],"-itranslate_intensity") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: translation\n", argv[i]); + return FALSE; + } + F32 translation; + if (sscanf(argv[i+1], "%f", &translation) != 1) + { + fprintf(stderr, "ERROR: '%s' needs 1 argument: translation but '%s' is not valid.\n", argv[i], argv[i+1]); + return FALSE; + } + if (translation == 0.0f) + { + fprintf(stderr, "ERROR: '%s' needs 1 argument: translation but %f is not valid.\n", argv[i], translation); + return FALSE; + } + set_translate_intensity(translation); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i],"-iscale_intensity") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: scale\n", argv[i]); + return FALSE; + } + F32 scale; + if (sscanf(argv[i+1], "%f", &scale) != 1) + { + fprintf(stderr, "ERROR: '%s' needs 1 argument: scale but '%s' is not valid.\n", argv[i], argv[i+1]); + return FALSE; + } + if (scale == 0.0f) + { + fprintf(stderr, "ERROR: '%s' needs 1 argument: scale but %f is not valid.\n", argv[i], scale); + return FALSE; + } + set_scale_intensity(scale); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i],"-itranslate_scan_angle") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: translation\n", argv[i]); + return FALSE; + } + F32 translation; + if (sscanf(argv[i+1], "%f", &translation) != 1) + { + fprintf(stderr, "ERROR: '%s' needs 1 argument: translation but '%s' is not valid.\n", argv[i], argv[i+1]); + return FALSE; + } + if (translation == 0.0f) + { + fprintf(stderr, "ERROR: '%s' needs 1 argument: translation but %f is not valid.\n", argv[i], translation); + return FALSE; + } + set_translate_scan_angle(translation); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i],"-iscale_scan_angle") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: scale\n", argv[i]); + return FALSE; + } + F32 scale; + if (sscanf(argv[i+1], "%f", &scale) != 1) + { + fprintf(stderr, "ERROR: '%s' needs 1 argument: scale but '%s' is not valid.\n", argv[i], argv[i+1]); + return FALSE; + } + if (scale == 0.0f) + { + fprintf(stderr, "ERROR: '%s' needs 1 argument: scale but %f is not valid.\n", argv[i], scale); + return FALSE; + } + set_scale_scan_angle(scale); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i],"-ipts") == 0) + { + itxt = TRUE; + ipts = TRUE; + *argv[i]='\0'; + } + else if (strcmp(argv[i],"-iptx") == 0) + { + itxt = TRUE; + iptx = TRUE; + *argv[i]='\0'; + } + else if (strcmp(argv[i],"-itxt") == 0) + { + itxt = TRUE; + *argv[i]='\0'; } - set_parse_string(argv[i+1]); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } - else if (strcmp(argv[i],"-iskip") == 0) + else if (strncmp(argv[i], "-r", 2) == 0) { - if ((i+1) >= argc) + if (strcmp(argv[i],"-rescale") == 0) { - REprintf("ERROR: '%s' needs 1 argument: number_of_lines\n", argv[i]); - return FALSE; + if ((i+3) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: rescale_x rescale_y rescale_z\n", argv[i]); + return FALSE; + } + F64 scale_factor[3]; + if (sscanf(argv[i+1], "%lf", &(scale_factor[0])) != 1) + { + fprintf(stderr, "ERROR: '%s' needs 3 arguments: rescale_x rescale_y rescale_z, but '%s' is not a valid rescale_x", argv[i], argv[i+1]); + return FALSE; + } + if (scale_factor[0] == 0.0) + { + fprintf(stderr, "ERROR: '%s' needs 3 arguments: rescale_x rescale_y rescale_z, but %lf is not a valid rescale_x", argv[i], scale_factor[0]); + return FALSE; + } + if (sscanf(argv[i+2], "%lf", &(scale_factor[1])) != 1) + { + fprintf(stderr, "ERROR: '%s' needs 3 arguments: rescale_x rescale_y rescale_z, but '%s' is not a valid rescale_y", argv[i], argv[i+2]); + return FALSE; + } + if (scale_factor[1] == 0.0) + { + fprintf(stderr, "ERROR: '%s' needs 3 arguments: rescale_x rescale_y rescale_z, but %lf is not a valid rescale_y", argv[i], scale_factor[1]); + return FALSE; + } + if (sscanf(argv[i+3], "%lf", &(scale_factor[2])) != 1) + { + fprintf(stderr, "ERROR: '%s' needs 3 arguments: rescale_x rescale_y rescale_z, but '%s' is not a valid rescale_z", argv[i], argv[i+3]); + return FALSE; + } + if (scale_factor[2] == 0.0) + { + fprintf(stderr, "ERROR: '%s' needs 3 arguments: rescale_x rescale_y rescale_z, but %lf is not a valid rescale_z", argv[i], scale_factor[2]); + return FALSE; + } + set_scale_factor(scale_factor); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + } + else if (strcmp(argv[i],"-rescale_xy") == 0) + { + if ((i+2) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 2 argument: rescale_x rescale_y\n", argv[i]); + return FALSE; + } + F64 scale_factor[3]; + if (sscanf(argv[i+1], "%lf", &(scale_factor[0])) != 1) + { + fprintf(stderr, "ERROR: '%s' needs 3 arguments: rescale_x rescale_y, but '%s' is not a valid rescale_x", argv[i], argv[i+1]); + return FALSE; + } + if (scale_factor[0] == 0.0) + { + fprintf(stderr, "ERROR: '%s' needs 3 arguments: rescale_x rescale_y, but %lf is not a valid rescale_x", argv[i], scale_factor[0]); + return FALSE; + } + if (sscanf(argv[i+2], "%lf", &(scale_factor[1])) != 1) + { + fprintf(stderr, "ERROR: '%s' needs 3 arguments: rescale_x rescale_y, but '%s' is not a valid rescale_y", argv[i], argv[i+2]); + return FALSE; + } + if (scale_factor[1] == 0.0) + { + fprintf(stderr, "ERROR: '%s' needs 3 arguments: rescale_x rescale_y, but %lf is not a valid rescale_y", argv[i], scale_factor[1]); + return FALSE; + } + scale_factor[2] = 0.0; + set_scale_factor(scale_factor); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + } + else if (strcmp(argv[i],"-rescale_z") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: rescale_z\n", argv[i]); + return FALSE; + } + F64 scale_factor[3]; + scale_factor[0] = 0.0; + scale_factor[1] = 0.0; + if (sscanf(argv[i+1], "%lf", &(scale_factor[2])) != 1) + { + fprintf(stderr, "ERROR: '%s' needs 1 argument: rescale_z, but '%s' is not a valid rescale_z", argv[i], argv[i+1]); + return FALSE; + } + if (scale_factor[2] == 0.0) + { + fprintf(stderr, "ERROR: '%s' needs 1 argument: rescale_z, but %lf is not a valid rescale_z", argv[i], scale_factor[2]); + return FALSE; + } + set_scale_factor(scale_factor); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i],"-reoffset") == 0) + { + if ((i+3) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: reoffset_x, reoffset_y, reoffset_z\n", argv[i]); + return FALSE; + } + F64 offset[3]; + if (sscanf(argv[i+1], "%lf", &(offset[0])) != 1) + { + fprintf(stderr, "ERROR: '%s' needs 3 arguments: reoffset_x, reoffset_y, reoffset_z, but '%s' is not a valid reoffset_x", argv[i], argv[i+1]); + return FALSE; + } + if (sscanf(argv[i+2], "%lf", &(offset[1])) != 1) + { + fprintf(stderr, "ERROR: '%s' needs 3 arguments: reoffset_x, reoffset_y, reoffset_z, but '%s' is not a valid reoffset_y", argv[i], argv[i+2]); + return FALSE; + } + if (sscanf(argv[i+3], "%lf", &(offset[2])) != 1) + { + fprintf(stderr, "ERROR: '%s' needs 3 arguments: reoffset_x, reoffset_y, reoffset_z, but '%s' is not a valid reoffset_z", argv[i], argv[i+3]); + return FALSE; + } + set_offset(offset); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } - set_skip_lines(atoi(argv[i+1])); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } - else if (strcmp(argv[i],"-merged") == 0) + else if (strcmp(argv[i],"-unique") == 0) { - set_merged(TRUE); + unique = TRUE; *argv[i]='\0'; } - else if (strcmp(argv[i],"-stored") == 0) + else if (strcmp(argv[i],"-comma_not_point") == 0) { - set_stored(TRUE); + comma_not_point = TRUE; *argv[i]='\0'; } - else if (strcmp(argv[i],"-buffered") == 0) + else if (strncmp(argv[i], "-s", 2) == 0) { - if ((i+1) >= argc) + if (strcmp(argv[i],"-stdin") == 0) { - REprintf("ERROR: '%s' needs 1 argument: size\n", argv[i]); - return FALSE; + use_stdin = TRUE; + *argv[i]='\0'; + } + else if (strcmp(argv[i],"-stored") == 0) + { + set_stored(TRUE); + *argv[i]='\0'; } - set_buffer_size((F32)atof(argv[i+1])); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } - else if (strcmp(argv[i],"-temp_files") == 0) + else if (strcmp(argv[i],"-lof") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: base name\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: list_of_files\n", argv[i]); + return FALSE; + } + if (!add_list_of_files(argv[i+1], unique)) + { + fprintf(stderr, "ERROR: cannot load list of files '%s'\n", argv[i+1]); return FALSE; } - temp_file_base = LASCopyString(argv[i+1]); *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } - else if (strcmp(argv[i],"-neighbors") == 0) + else if (strncmp(argv[i], "-a", 2) == 0) { - if ((i+1) >= argc) + if (strcmp(argv[i],"-auto_reoffset") == 0) { - REprintf("ERROR: '%s' needs at least 1 argument: file_name or wild_card\n", argv[i]); - return FALSE; + set_auto_reoffset(TRUE); + *argv[i]='\0'; } - *argv[i]='\0'; - i+=1; - do + else if (strcmp(argv[i],"-apply_file_source_ID") == 0) { - add_neighbor_file_name(argv[i]); + set_apply_file_source_ID(TRUE); *argv[i]='\0'; - i+=1; - } while ((i < argc) && (*argv[i] != '-') && (*argv[i] != '\0')); - i-=1; + } } - else if (strcmp(argv[i],"-neighbors_lof") == 0) + else if (strncmp(argv[i], "-f", 2) == 0) { - if ((i+1) >= argc) - { - REprintf("ERROR: '%s' needs at least 1 argument: file_name\n", argv[i]); - return FALSE; - } - FILE* file = fopen(argv[i+1], "r"); - if (file == 0) + if (strcmp(argv[i],"-files_are_flightlines") == 0 || strcmp(argv[i],"-faf") == 0) { - REprintf( "ERROR: cannot open '%s'\n", argv[i+1]); - return FALSE; + if (((i+1) < argc) && ('1' <= argv[i+1][0]) && (argv[i+1][0] <= '9')) + { + set_files_are_flightlines(atoi(argv[i+1])); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else + { + set_files_are_flightlines(1); + *argv[i]='\0'; + } } - CHAR line[1024]; - while (fgets(line, 1024, file)) + else if (strcmp(argv[i],"-faf_index") == 0) { - // find end of line - I32 len = (I32)strlen(line) - 1; - // remove extra white spaces and line return at the end - while (len > 0 && ((line[len] == '\n') || (line[len] == ' ') || (line[len] == '\t') || (line[len] == '\012'))) + if ((i+1) >= argc) { - line[len] = '\0'; - len--; + fprintf(stderr,"ERROR: '%s' needs 1 argument: index\n", argv[i]); + return FALSE; } -#ifdef _WIN32 - add_neighbor_file_name_single(line); -#else - add_neighbor_file_name(line); -#endif + set_files_are_flightlines_index(atoi(argv[i+1])); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } - fclose(file); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; - } - else if (strcmp(argv[i],"-pipe_on") == 0) - { - set_pipe_on(TRUE); - *argv[i]='\0'; } - else if (strcmp(argv[i],"-populate") == 0) + else if (strcmp(argv[i],"-merged") == 0) { - set_populate_header(TRUE); + set_merged(TRUE); *argv[i]='\0'; } - else if (strcmp(argv[i],"-io_ibuffer") == 0) + else if (strcmp(argv[i],"-buffered") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: size\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: buffer_size\n", argv[i]); return FALSE; } - set_io_ibuffer_size((I32)atoi(argv[i+1])); + F32 buffer_size; + if (sscanf(argv[i+1], "%f", &buffer_size) != 1) + { + fprintf(stderr, "ERROR: '%s' needs 1 argument: buffer_size. but '%s' is not a valid buffer_size", argv[i], argv[i+1]); + return FALSE; + } + if (buffer_size <= 0.0f) + { + fprintf(stderr, "ERROR: '%s' needs 1 argument: buffer_size, but %f is not valid", argv[i], buffer_size); + return FALSE; + } + set_buffer_size(buffer_size); *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } - else if (strcmp(argv[i],"-do_not_populate") == 0) + else if (strcmp(argv[i],"-temp_files") == 0) { - set_populate_header(FALSE); - *argv[i]='\0'; + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: base name\n", argv[i]); + return FALSE; + } + temp_file_base = LASCopyString(argv[i+1]); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } - else if (strcmp(argv[i],"-ipts") == 0) + else if (strncmp(argv[i], "-n", 2) == 0) { - itxt = TRUE; - ipts = TRUE; - *argv[i]='\0'; + if (strcmp(argv[i],"-neighbors") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs at least 1 argument: file_name or wild_card\n", argv[i]); + return FALSE; + } + *argv[i]='\0'; + i+=1; + do + { + add_neighbor_file_name(argv[i]); + *argv[i]='\0'; + i+=1; + } while ((i < argc) && (*argv[i] != '-') && (*argv[i] != '\0')); + i-=1; + } + else if (strcmp(argv[i],"-neighbors_lof") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs at least 1 argument: file_name\n", argv[i]); + return FALSE; + } + if (!add_neighbor_list_of_files(argv[i+1], unique)) + { + fprintf(stderr, "ERROR: cannot load neighbor list of files '%s'\n", argv[i+1]); + return FALSE; + } + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } } - else if (strcmp(argv[i],"-iptx") == 0) + else if (strncmp(argv[i], "-p", 2) == 0) { - itxt = TRUE; - iptx = TRUE; - *argv[i]='\0'; + if (strcmp(argv[i],"-pipe_on") == 0) + { + set_pipe_on(TRUE); + *argv[i]='\0'; + } + else if (strcmp(argv[i],"-populate") == 0) + { + set_populate_header(TRUE); + *argv[i]='\0'; + } } - else if (strcmp(argv[i],"-itxt") == 0) + else if (strcmp(argv[i],"-do_not_populate") == 0) { - itxt = TRUE; + set_populate_header(FALSE); *argv[i]='\0'; } } @@ -2040,12 +2392,12 @@ BOOL LASreadOpener::parse(int argc, char* argv[]) { if (file_name_number > 1) { - REprintf( "ERROR: neighbors only supported for one buffered input file, not for %d\n", file_name_number); + fprintf(stderr, "ERROR: neighbors only supported for one buffered input file, not for %d\n", file_name_number); return FALSE; } if (buffer_size == 0.0f) { - REprintf( "ERROR: neighbors only make sense when used with '-buffered 50' or similar\n"); + fprintf(stderr, "ERROR: neighbors only make sense when used with '-buffered 50' or similar\n"); return FALSE; } } @@ -2055,6 +2407,7 @@ BOOL LASreadOpener::parse(int argc, char* argv[]) if (!filter->parse(argc, argv)) { delete filter; + filter = 0; return FALSE; } if (!filter->active()) @@ -2068,17 +2421,29 @@ BOOL LASreadOpener::parse(int argc, char* argv[]) if (!transform->parse(argc, argv)) { delete transform; + transform = 0; return FALSE; } if (!transform->active()) { + if (transform->filtered()) + { + fprintf(stderr, "WARNING: no LAStransform specified. '-filtered_transform' has no effect.\n"); + } delete transform; transform = 0; } else if (transform->filtered()) { - transform->setFilter(filter); - filter = 0; + if (filter == 0) + { + fprintf(stderr, "WARNING: no LASfilter specified. '-filtered_transform' has no effect.\n"); + } + else + { + transform->setFilter(filter); + filter = 0; + } } if (files_are_flightlines || apply_file_source_ID) @@ -2154,6 +2519,24 @@ const CHAR* LASreadOpener::get_file_name_only() const return file_name_only; } +const CHAR* LASreadOpener::get_file_extension_only() const +{ + const CHAR* file_extension_only = 0; + const CHAR* file_name_curr = get_file_name(); + + if (file_name_curr) + { + I32 len = (I32)strlen(file_name_curr); + while ((len > 0) && (file_name_curr[len] != '.')) len--; + if (len) + { + file_extension_only = file_name_curr + len + 1; + } + } + + return file_extension_only; +} + const CHAR* LASreadOpener::get_file_name(U32 number) const { return file_names[number]; @@ -2181,6 +2564,24 @@ const CHAR* LASreadOpener::get_file_name_only(U32 number) const return file_name_only; } +const CHAR* LASreadOpener::get_file_extension_only(U32 number) const +{ + const CHAR* file_extension_only = 0; + const CHAR* file_name_curr = get_file_name(number); + + if (file_name_curr) + { + I32 len = (I32)strlen(file_name_curr); + while ((len > 0) && (file_name_curr[len] != '.')) len--; + if (len) + { + file_extension_only = file_name_curr + len + 1; + } + } + + return file_extension_only; +} + I32 LASreadOpener::get_file_format(U32 number) const { if (strstr(file_names[number], ".las") || strstr(file_names[number], ".LAS")) @@ -2221,6 +2622,38 @@ I32 LASreadOpener::get_file_format(U32 number) const } } +CHAR* LASreadOpener::get_file_name_base() const +{ + CHAR* file_name_base = 0; + + if (file_name) + { + file_name_base = LASCopyString(file_name); + // remove extension + I32 len = (I32)strlen(file_name_base); + while ((len > 0) && (file_name_base[len] != '\\') && (file_name_base[len] != '/') && (file_name_base[len] != ':')) len--; + file_name_base[len] = '\0'; + } + + return file_name_base; +} + +CHAR* LASreadOpener::get_file_name_base(U32 number) const +{ + CHAR* file_name_base = 0; + + if (get_file_name(number)) + { + file_name_base = LASCopyString(get_file_name(number)); + // remove extension + I32 len = (I32)strlen(file_name_base); + while ((len > 0) && (file_name_base[len] != '\\') && (file_name_base[len] != '/') && (file_name_base[len] != ':')) len--; + file_name_base[len] = '\0'; + } + + return file_name_base; +} + void LASreadOpener::set_merged(const BOOL merged) { this->merged = merged; @@ -2261,11 +2694,11 @@ void LASreadOpener::set_files_are_flightlines(const I32 files_are_flightlines) this->files_are_flightlines = files_are_flightlines; if (files_are_flightlines > (I32)(U16_MAX)) { - REprintf( "WARNING: files_are_flightlines start value %d is too large\n", files_are_flightlines); + fprintf(stderr, "WARNING: files_are_flightlines start value %d is too large\n", files_are_flightlines); } else if ((files_are_flightlines + files_are_flightlines_index) > (I32)(U16_MAX)) { - REprintf( "WARNING: files_are_flightlines start value %d plus index %d is too large\n", files_are_flightlines, files_are_flightlines_index); + fprintf(stderr, "WARNING: files_are_flightlines start value %d plus index %d is too large\n", files_are_flightlines, files_are_flightlines_index); } } @@ -2274,11 +2707,11 @@ void LASreadOpener::set_files_are_flightlines_index(const I32 files_are_flightli this->files_are_flightlines_index = files_are_flightlines_index-1; if (files_are_flightlines_index > (I32)(U16_MAX)) { - REprintf( "WARNING: files_are_flightlines_index index value %d is too large\n", files_are_flightlines_index); + fprintf(stderr, "WARNING: files_are_flightlines_index index value %d is too large\n", files_are_flightlines_index); } else if ((files_are_flightlines + files_are_flightlines_index) > (I32)(U16_MAX)) { - REprintf( "WARNING: files_are_flightlines start value %d plus index %d is too large\n", files_are_flightlines, files_are_flightlines_index); + fprintf(stderr, "WARNING: files_are_flightlines start value %d plus index %d is too large\n", files_are_flightlines, files_are_flightlines_index); } } @@ -2287,9 +2720,9 @@ void LASreadOpener::set_apply_file_source_ID(const BOOL apply_file_source_ID) this->apply_file_source_ID = apply_file_source_ID; } -void LASreadOpener::set_io_ibuffer_size(I32 io_ibuffer_size) +void LASreadOpener::set_io_ibuffer_size(const U32 buffer_size) { - this->io_ibuffer_size = io_ibuffer_size; + this->io_ibuffer_size = buffer_size; } void LASreadOpener::set_file_name(const CHAR* file_name, BOOL unique) @@ -2365,7 +2798,7 @@ BOOL LASreadOpener::add_file_name(const CHAR* file_name, BOOL unique) } if (file_names == 0) { - REprintf( "ERROR: alloc for file_names pointer array failed at %d\n", file_name_allocated); + fprintf(stderr, "ERROR: alloc for file_names pointer array failed at %d\n", file_name_allocated); } } file_names[file_name_number] = LASCopyString(file_name); @@ -2373,26 +2806,365 @@ BOOL LASreadOpener::add_file_name(const CHAR* file_name, BOOL unique) return TRUE; } +BOOL LASreadOpener::add_file_name(const CHAR* file_name, U32 ID, BOOL unique) +{ + if (unique) + { + U32 i; + for (i = 0; i < file_name_number; i++) + { + if (strcmp(file_names[i], file_name) == 0) + { + return FALSE; + } + } + } + if (file_name_number == file_name_allocated) + { + if (file_names) + { + file_name_allocated *= 2; + file_names = (CHAR**)realloc(file_names, sizeof(CHAR*)*file_name_allocated); + file_names_ID = (U32*)realloc(file_names_ID, sizeof(U32)*file_name_allocated); + } + else + { + file_name_allocated = 16; + file_names = (CHAR**)malloc(sizeof(CHAR*)*file_name_allocated); + file_names_ID = (U32*)malloc(sizeof(U32)*file_name_allocated); + } + if (file_names == 0) + { + fprintf(stderr, "ERROR: alloc for file_names pointer array failed at %d\n", file_name_allocated); + return FALSE; + } + if (file_names_ID == 0) + { + fprintf(stderr, "ERROR: alloc for file_names_ID array failed at %d\n", file_name_allocated); + return FALSE; + } + } + file_names[file_name_number] = LASCopyString(file_name); + file_names_ID[file_name_number] = ID; + file_name_number++; + return TRUE; +} + +BOOL LASreadOpener::add_file_name(const CHAR* file_name, U32 ID, I64 npoints, F64 min_x, F64 min_y, F64 max_x, F64 max_y, BOOL unique) +{ + if (unique) + { + U32 i; + for (i = 0; i < file_name_number; i++) + { + if (strcmp(file_names[i], file_name) == 0) + { + return FALSE; + } + } + } + if (file_name_number == file_name_allocated) + { + if (file_names) + { + file_name_allocated *= 2; + file_names = (CHAR**)realloc(file_names, sizeof(CHAR*)*file_name_allocated); + file_names_ID = (U32*)realloc(file_names_ID, sizeof(U32)*file_name_allocated); + file_names_npoints = (I64*)realloc(file_names_npoints, sizeof(I64)*file_name_allocated); + file_names_min_x = (F64*)realloc(file_names_min_x, sizeof(F64)*file_name_allocated); + file_names_min_y = (F64*)realloc(file_names_min_y, sizeof(F64)*file_name_allocated); + file_names_max_x = (F64*)realloc(file_names_max_x, sizeof(F64)*file_name_allocated); + file_names_max_y = (F64*)realloc(file_names_max_y, sizeof(F64)*file_name_allocated); + } + else + { + file_name_allocated = 16; + file_names = (CHAR**)malloc(sizeof(CHAR*)*file_name_allocated); + file_names_ID = (U32*)malloc(sizeof(U32)*file_name_allocated); + file_names_npoints = (I64*)malloc(sizeof(I64)*file_name_allocated); + file_names_min_x = (F64*)malloc(sizeof(F64)*file_name_allocated); + file_names_min_y = (F64*)malloc(sizeof(F64)*file_name_allocated); + file_names_max_x = (F64*)malloc(sizeof(F64)*file_name_allocated); + file_names_max_y = (F64*)malloc(sizeof(F64)*file_name_allocated); + if (kdtree_rectangles == 0) + { + kdtree_rectangles = new LASkdtreeRectangles(); + if (kdtree_rectangles == 0) + { + fprintf(stderr, "ERROR: alloc for LASkdtreeRectangles failed\n"); + return FALSE; + } + } + kdtree_rectangles->init(); + } + if (file_names == 0) + { + fprintf(stderr, "ERROR: alloc for file_names pointer array failed at %d\n", file_name_allocated); + return FALSE; + } + if (file_names_ID == 0) + { + fprintf(stderr, "ERROR: alloc for file_names_ID array failed at %d\n", file_name_allocated); + return FALSE; + } + if (file_names_npoints == 0) + { + fprintf(stderr, "ERROR: alloc for file_names_npoints array failed at %d\n", file_name_allocated); + return FALSE; + } + if (file_names_min_x == 0) + { + fprintf(stderr, "ERROR: alloc for file_names_min_x array failed at %d\n", file_name_allocated); + return FALSE; + } + if (file_names_min_y == 0) + { + fprintf(stderr, "ERROR: alloc for file_names_min_y array failed at %d\n", file_name_allocated); + return FALSE; + } + if (file_names_max_x == 0) + { + fprintf(stderr, "ERROR: alloc for file_names_max_x array failed at %d\n", file_name_allocated); + return FALSE; + } + if (file_names_max_y == 0) + { + fprintf(stderr, "ERROR: alloc for file_names_max_y array failed at %d\n", file_name_allocated); + return FALSE; + } + } + file_names[file_name_number] = LASCopyString(file_name); + file_names_ID[file_name_number] = ID; + file_names_npoints[file_name_number] = npoints; + file_names_min_x[file_name_number] = min_x; + file_names_min_y[file_name_number] = min_y; + file_names_max_x[file_name_number] = max_x; + file_names_max_y[file_name_number] = max_y; + kdtree_rectangles->add(min_x, min_y, max_x, max_y); + file_name_number++; + return TRUE; +} + BOOL LASreadOpener::add_list_of_files(const CHAR* list_of_files, BOOL unique) { FILE* file = fopen(list_of_files, "r"); if (file == 0) { - REprintf( "ERROR: cannot open '%s'\n", list_of_files); + fprintf(stderr, "ERROR: cannot open '%s'\n", list_of_files); + return FALSE; + } + CHAR line[2048]; + CHAR name[2048]; + U32 ID; + I64 npoints; + F64 min_x; + F64 min_y; + F64 max_x; + F64 max_y; + int num; + while (fgets(line, 2048, file)) + { + // find end of line + I32 len = (I32)strlen(line) - 1; + // remove extra white spaces and line return at the end + while ((len > 0) && ((line[len] == '\n') || (line[len] == ' ') || (line[len] == '\t') || (line[len] == '\012'))) + { + line[len] = '\0'; + len--; + } + // try to parse number of points and xy bounds +#ifdef _WIN32 + num = sscanf(line, "%u,%I64d,%lf,%lf,%lf,%lf,", &ID, &npoints, &min_x, &min_y, &max_x, &max_y); +#else + num = sscanf(line, "%u,%lld,%lf,%lf,%lf,%lf,", &ID, &npoints, &min_x, &min_y, &max_x, &max_y); +#endif + + if (num == 6) + { + // skip ID, number of points, and xy bounds + num = 0; + while ((num < len) && (line[num] != ',')) num++; + num++; + while ((num < len) && (line[num] != ',')) num++; + num++; + while ((num < len) && (line[num] != ',')) num++; + num++; + while ((num < len) && (line[num] != ',')) num++; + num++; + while ((num < len) && (line[num] != ',')) num++; + num++; + while ((num < len) && (line[num] != ',')) num++; + num++; + // remove extra white spaces at the beginning + while ((num < len) && ((line[num] == ' ') || (line[num] == '\t'))) num++; + add_file_name(&line[num], ID, npoints, min_x, min_y, max_x, max_y, unique); + } + else + { + // try to parse number and file name + num = sscanf(line, "%u,%s", &ID, name); + if (num == 2) + { + // skip ID + num = 0; + while ((num < len) && (line[num] != ',')) num++; + num++; + // remove extra white spaces at the beginning + while ((num < len) && ((line[num] == ' ') || (line[num] == '\t'))) num++; + add_file_name(&line[num], ID, unique); + } + else + { + add_file_name(line, unique); + } + } + } + fclose(file); + return TRUE; +} + +BOOL LASreadOpener::add_neighbor_file_name(const CHAR* neighbor_file_name, I64 npoints, F64 min_x, F64 min_y, F64 max_x, F64 max_y, BOOL unique) +{ + if (unique) + { + U32 i; + for (i = 0; i < neighbor_file_name_number; i++) + { + if (strcmp(neighbor_file_names[i], neighbor_file_name) == 0) + { + return FALSE; + } + } + } + if (neighbor_file_name_number == neighbor_file_name_allocated) + { + if (neighbor_file_names) + { + neighbor_file_name_allocated *= 2; + neighbor_file_names = (CHAR**)realloc(neighbor_file_names, sizeof(CHAR*)*neighbor_file_name_allocated); + neighbor_file_names_npoints = (I64*)realloc(neighbor_file_names_npoints, sizeof(I64)*neighbor_file_name_allocated); + neighbor_file_names_min_x = (F64*)realloc(neighbor_file_names_min_x, sizeof(F64)*neighbor_file_name_allocated); + neighbor_file_names_min_y = (F64*)realloc(neighbor_file_names_min_y, sizeof(F64)*neighbor_file_name_allocated); + neighbor_file_names_max_x = (F64*)realloc(neighbor_file_names_max_x, sizeof(F64)*neighbor_file_name_allocated); + neighbor_file_names_max_y = (F64*)realloc(neighbor_file_names_max_y, sizeof(F64)*neighbor_file_name_allocated); + } + else + { + neighbor_file_name_allocated = 16; + neighbor_file_names = (CHAR**)malloc(sizeof(CHAR*)*neighbor_file_name_allocated); + neighbor_file_names_npoints = (I64*)malloc(sizeof(I64)*neighbor_file_name_allocated); + neighbor_file_names_min_x = (F64*)malloc(sizeof(F64)*neighbor_file_name_allocated); + neighbor_file_names_min_y = (F64*)malloc(sizeof(F64)*neighbor_file_name_allocated); + neighbor_file_names_max_x = (F64*)malloc(sizeof(F64)*neighbor_file_name_allocated); + neighbor_file_names_max_y = (F64*)malloc(sizeof(F64)*neighbor_file_name_allocated); + if (neighbor_kdtree_rectangles == 0) + { + neighbor_kdtree_rectangles = new LASkdtreeRectangles(); + if (neighbor_kdtree_rectangles == 0) + { + fprintf(stderr, "ERROR: alloc for neighbor LASkdtreeRectangles failed\n"); + return FALSE; + } + } + kdtree_rectangles->init(); + } + if (neighbor_file_names == 0) + { + fprintf(stderr, "ERROR: alloc for neighbor_file_names pointer array failed at %d\n", neighbor_file_name_allocated); + return FALSE; + } + if (neighbor_file_names_min_x == 0) + { + fprintf(stderr, "ERROR: alloc for neighbor_file_names_min_x array failed at %d\n", neighbor_file_name_allocated); + return FALSE; + } + if (neighbor_file_names_min_y == 0) + { + fprintf(stderr, "ERROR: alloc for neighbor_file_names_min_y array failed at %d\n", neighbor_file_name_allocated); + return FALSE; + } + if (neighbor_file_names_max_x == 0) + { + fprintf(stderr, "ERROR: alloc for neighbor_file_names_max_x array failed at %d\n", neighbor_file_name_allocated); + return FALSE; + } + if (neighbor_file_names_max_y == 0) + { + fprintf(stderr, "ERROR: alloc for neighbor_file_names_max_y array failed at %d\n", neighbor_file_name_allocated); + return FALSE; + } + } + neighbor_file_names[neighbor_file_name_number] = LASCopyString(neighbor_file_name); + neighbor_file_names_npoints[neighbor_file_name_number] = npoints; + neighbor_file_names_min_x[neighbor_file_name_number] = min_x; + neighbor_file_names_min_y[neighbor_file_name_number] = min_y; + neighbor_file_names_max_x[neighbor_file_name_number] = max_x; + neighbor_file_names_max_y[neighbor_file_name_number] = max_y; + neighbor_kdtree_rectangles->add(min_x, min_y, max_x, max_y); + neighbor_file_name_number++; + return TRUE; +} + +BOOL LASreadOpener::add_neighbor_list_of_files(const CHAR* neighbor_list_of_files, BOOL unique) +{ + FILE* file = fopen(neighbor_list_of_files, "r"); + if (file == 0) + { + fprintf(stderr, "ERROR: cannot open '%s'\n", neighbor_list_of_files); return FALSE; } - CHAR line[1024]; - while (fgets(line, 1024, file)) + CHAR line[2048]; + U32 ID; + I64 npoints; + F64 min_x; + F64 min_y; + F64 max_x; + F64 max_y; + int num; + while (fgets(line, 2048, file)) { // find end of line I32 len = (I32)strlen(line) - 1; // remove extra white spaces and line return at the end - while (len > 0 && ((line[len] == '\n') || (line[len] == ' ') || (line[len] == '\t') || (line[len] == '\012'))) + while ((len > 0) && ((line[len] == '\n') || (line[len] == ' ') || (line[len] == '\t') || (line[len] == '\012'))) { line[len] = '\0'; len--; } - add_file_name(line, unique); + // try to parse number of points and xy bounds +#ifdef _WIN32 + num = sscanf(line, "%u,%I64d,%lf,%lf,%lf,%lf,", &ID, &npoints, &min_x, &min_y, &max_x, &max_y); +#else + num = sscanf(line, "%u,%lld,%lf,%lf,%lf,%lf,", &ID, &npoints, &min_x, &min_y, &max_x, &max_y); +#endif + if (num == 6) + { + // skip number of points and xy bounds + num = 0; + while ((num < len) && (line[num] != ',')) num++; + num++; + while ((num < len) && (line[num] != ',')) num++; + num++; + while ((num < len) && (line[num] != ',')) num++; + num++; + while ((num < len) && (line[num] != ',')) num++; + num++; + while ((num < len) && (line[num] != ',')) num++; + num++; + while ((num < len) && (line[num] != ',')) num++; + num++; + // remove extra white spaces at the beginning + while ((num < len) && ((line[num] == ' ') || (line[num] == '\t'))) num++; + add_neighbor_file_name(&line[num], npoints, min_x, min_y, max_x, max_y, unique); + } + else + { +#ifdef _WIN32 + add_neighbor_file_name_single(line); +#else + add_neighbor_file_name(line); +#endif + } } fclose(file); return TRUE; @@ -2491,7 +3263,7 @@ BOOL LASreadOpener::add_neighbor_file_name(const CHAR* neighbor_file_name, BOOL } if (neighbor_file_names == 0) { - REprintf( "ERROR: alloc for neighbor_file_names pointer array failed at %d\n", neighbor_file_name_allocated); + fprintf(stderr, "ERROR: alloc for neighbor_file_names pointer array failed at %d\n", neighbor_file_name_allocated); } } neighbor_file_names[neighbor_file_name_number] = LASCopyString(neighbor_file_name); @@ -2559,24 +3331,24 @@ void LASreadOpener::set_offset(const F64* offset) } } -void LASreadOpener::set_translate_intensity(F32 translate_intensity) +void LASreadOpener::set_translate_intensity(const F32 translation) { - this->translate_intensity = translate_intensity; + this->translate_intensity = translation; } -void LASreadOpener::set_scale_intensity(F32 scale_intensity) +void LASreadOpener::set_scale_intensity(const F32 scale) { - this->scale_intensity = scale_intensity; + this->scale_intensity = scale; } -void LASreadOpener::set_translate_scan_angle(F32 translate_scan_angle) +void LASreadOpener::set_translate_scan_angle(const F32 translation) { - this->translate_scan_angle = translate_scan_angle; + this->translate_scan_angle = translation; } -void LASreadOpener::set_scale_scan_angle(F32 scale_scan_angle) +void LASreadOpener::set_scale_scan_angle(const F32 scale) { - this->scale_scan_angle = scale_scan_angle; + this->scale_scan_angle = scale; } void LASreadOpener::add_attribute(I32 data_type, const CHAR* name, const CHAR* description, F64 scale, F64 offset, F64 pre_scale, F64 pre_offset, F64 no_data) @@ -2592,9 +3364,9 @@ void LASreadOpener::add_attribute(I32 data_type, const CHAR* name, const CHAR* d number_attributes++; } -void LASreadOpener::set_skip_lines(I32 skip_lines) +void LASreadOpener::set_skip_lines(const U32 number_of_lines) { - this->skip_lines = skip_lines; + this->skip_lines = number_of_lines; } void LASreadOpener::set_populate_header(BOOL populate_header) @@ -2623,6 +3395,10 @@ void LASreadOpener::set_decompress_selective(U32 decompress_selective) { this->decompress_selective |= transform->get_decompress_selective(); } + if (ignore) + { + this->decompress_selective |= ignore->get_decompress_selective(); + } } void LASreadOpener::set_inside_tile(const F32 ll_x, const F32 ll_y, const F32 size) @@ -2658,9 +3434,22 @@ BOOL LASreadOpener::active() const LASreadOpener::LASreadOpener() { io_ibuffer_size = LAS_TOOLS_IO_IBUFFER_SIZE; - file_names = 0; file_name = 0; + file_names = 0; + file_names_ID = 0; + file_names_npoints = 0; + file_names_min_x = 0; + file_names_min_y = 0; + file_names_max_x = 0; + file_names_max_y = 0; + kdtree_rectangles = 0; neighbor_file_names = 0; + neighbor_file_names_npoints = 0; + neighbor_file_names_min_x = 0; + neighbor_file_names_min_y = 0; + neighbor_file_names_max_x = 0; + neighbor_file_names_max_y = 0; + neighbor_kdtree_rectangles = 0; merged = FALSE; stored = FALSE; use_stdin = FALSE; @@ -2709,6 +3498,7 @@ LASreadOpener::LASreadOpener() inside_rectangle = 0; filter = 0; transform = 0; + ignore = 0; temp_file_base = 0; } @@ -2719,12 +3509,33 @@ LASreadOpener::~LASreadOpener() U32 i; for (i = 0; i < file_name_number; i++) free(file_names[i]); free(file_names); + if (file_names_ID) + { + free(file_names_ID); + if (file_names_npoints) + { + free(file_names_npoints); + free(file_names_min_x); + free(file_names_min_y); + free(file_names_max_x); + free(file_names_max_y); + } + } } + if (kdtree_rectangles) delete kdtree_rectangles; if (neighbor_file_names) { U32 i; for (i = 0; i < neighbor_file_name_number; i++) free(neighbor_file_names[i]); free(neighbor_file_names); + if (neighbor_file_names_npoints) + { + free(neighbor_file_names_npoints); + free(neighbor_file_names_min_x); + free(neighbor_file_names_min_y); + free(neighbor_file_names_max_x); + free(neighbor_file_names_max_y); + } } if (parse_string) free(parse_string); if (scale_factor) delete [] scale_factor; @@ -2734,5 +3545,6 @@ LASreadOpener::~LASreadOpener() if (inside_rectangle) delete [] inside_rectangle; if (filter) delete filter; if (transform) delete transform; + if (ignore) delete ignore; if (temp_file_base) free(temp_file_base); } diff --git a/inst/include/lasreader.hpp b/src/LASlib/lasreader.hpp similarity index 77% rename from inst/include/lasreader.hpp rename to src/LASlib/lasreader.hpp index a3c7e41..dc1b7a4 100644 --- a/inst/include/lasreader.hpp +++ b/src/LASlib/lasreader.hpp @@ -14,7 +14,7 @@ COPYRIGHT: - (c) 2007-2017, martin isenburg, rapidlasso - fast tools to catch reality + (c) 2007-2019, martin isenburg, rapidlasso - fast tools to catch reality This is free software; you can redistribute and/or modify it under the terms of the GNU Lesser General Licence as published by the Free Software @@ -25,6 +25,8 @@ CHANGE HISTORY: + 31 October 2019 -- adding kdtree of bounding boxes for large number of LAS/LAZ files + 19 August 2019 -- unify '-ignore_class 7', '-ignore_withheld', etc ... in LASignore 7 September 2018 -- replaced calls to _strdup with calls to the LASCopyString macro 8 February 2018 -- new LASreaderStored via '-stored' option to allow piped operation 15 December 2017 -- optional '-files_are_flightline 101' start number like '-faf 101' @@ -49,11 +51,13 @@ #define LAS_READER_HPP #include "lasdefinitions.hpp" +#include "lasignore.hpp" class LASindex; class LASfilter; class LAStransform; class ByteStreamIn; +class LASkdtreeRectangles; class LASLIB_DLL LASreader { @@ -73,6 +77,8 @@ class LASLIB_DLL LASreader inline LASfilter* get_filter() const { return filter; }; virtual void set_transform(LAStransform* transform); inline LAStransform* get_transform() const { return transform; }; + void set_ignore(LASignore* ignore); + inline LASignore* get_ignore() const { return ignore; }; inline U32 get_inside() const { return inside; }; virtual BOOL inside_none(); @@ -93,6 +99,8 @@ class LASLIB_DLL LASreader virtual BOOL seek(const I64 p_index) = 0; BOOL read_point() { return (this->*read_simple)(); }; + inline BOOL ignore_point() { return (ignore ? ignore->ignore(&point) : FALSE); }; + inline void compute_coordinates() { point.compute_coordinates(); }; inline F64 get_min_x() const { return header.min_x; }; @@ -111,9 +119,9 @@ class LASLIB_DLL LASreader inline F64 get_y(const I32 y) const { return header.get_y(y); }; inline F64 get_z(const I32 z) const { return header.get_z(z); }; - inline I32 get_X(const F64 x) const { return header.get_X(x); }; - inline I32 get_Y(const F64 y) const { return header.get_Y(y); }; - inline I32 get_Z(const F64 z) const { return header.get_Z(z); }; + inline I64 get_X(const F64 x) const { return header.get_X(x); }; + inline I64 get_Y(const F64 y) const { return header.get_Y(y); }; + inline I64 get_Z(const F64 z) const { return header.get_Z(z); }; virtual ByteStreamIn* get_stream() const = 0; virtual void close(BOOL close_stream=TRUE) = 0; @@ -121,12 +129,15 @@ class LASLIB_DLL LASreader LASreader(); virtual ~LASreader(); + void dealloc(); + protected: virtual BOOL read_point_default() = 0; LASindex* index; LASfilter* filter; LAStransform* transform; + LASignore* ignore; U32 inside; F32 t_ll_x, t_ll_y, t_size, t_ur_x, t_ur_y; @@ -156,14 +167,18 @@ class LASLIB_DLL LASreader class LASLIB_DLL LASreadOpener { public: - void set_io_ibuffer_size(I32 io_ibuffer_size); - inline I32 get_io_ibuffer_size() const { return io_ibuffer_size; }; + void set_io_ibuffer_size(const U32 buffer_size); + inline U32 get_io_ibuffer_size() const { return io_ibuffer_size; }; U32 get_file_name_number() const; U32 get_file_name_current() const; const CHAR* get_file_name() const; const CHAR* get_file_name_only() const; + const CHAR* get_file_extension_only() const; const CHAR* get_file_name(U32 number) const; const CHAR* get_file_name_only(U32 number) const; + const CHAR* get_file_extension_only(U32 number) const; + CHAR* get_file_name_base() const; + CHAR* get_file_name_base(U32 number) const; void set_file_name(const CHAR* file_name, BOOL unique=FALSE); BOOL add_file_name(const CHAR* file_name, BOOL unique=FALSE); BOOL add_list_of_files(const CHAR* list_of_files, BOOL unique=FALSE); @@ -178,6 +193,8 @@ class LASLIB_DLL LASreadOpener F32 get_buffer_size() const; void set_neighbor_file_name(const CHAR* neighbor_file_name, BOOL unique=FALSE); BOOL add_neighbor_file_name(const CHAR* neighbor_file_name, BOOL unique=FALSE); + BOOL add_neighbor_file_name(const CHAR* file_name, I64 npoints, F64 min_x, F64 min_y, F64 max_x, F64 max_y, BOOL unique=FALSE); + BOOL add_neighbor_list_of_files(const CHAR* list_of_files, BOOL unique=FALSE); void set_auto_reoffset(const BOOL auto_reoffset); inline BOOL is_auto_reoffset() const { return auto_reoffset; }; void set_files_are_flightlines(const I32 files_are_flightlines); @@ -190,14 +207,14 @@ class LASLIB_DLL LASreadOpener inline const F64* get_scale_factor() const { return scale_factor; }; void set_offset(const F64* offset); inline const F64* get_offset() const { return offset; }; - void set_translate_intensity(F32 translate_intensity); - void set_scale_intensity(F32 scale_intensity); - void set_translate_scan_angle(F32 translate_scan_angle); - void set_scale_scan_angle(F32 scale_scan_angle); + void set_translate_intensity(const F32 translation); + void set_scale_intensity(const F32 scale); + void set_translate_scan_angle(const F32 translate_scan_angle); + void set_scale_scan_angle(const F32 scale_scan_angle); void add_attribute(I32 data_type, const CHAR* name, const CHAR* description=0, F64 scale=1.0, F64 offset=0.0, F64 pre_scale=1.0, F64 pre_offset=0.0, F64 no_data=F64_MAX); BOOL set_point_type(U8 point_type); void set_parse_string(const CHAR* parse_string); - void set_skip_lines(I32 skip_lines); + void set_skip_lines(const U32 number_of_lines); void set_populate_header(BOOL populate_header); void set_keep_lastiling(BOOL keep_lastiling); void set_pipe_on(BOOL pipe_on); @@ -207,7 +224,7 @@ class LASLIB_DLL LASreadOpener void set_inside_tile(const F32 ll_x, const F32 ll_y, const F32 size); void set_inside_circle(const F64 center_x, const F64 center_y, const F64 radius); void set_inside_rectangle(const F64 min_x, const F64 min_y, const F64 max_x, const F64 max_y); - BOOL parse(int argc, char* argv[]); + BOOL parse(int argc, char* argv[], BOOL parse_ignore=FALSE); BOOL parse_str(CHAR* string); BOOL is_piped() const; BOOL is_buffered() const; @@ -216,14 +233,23 @@ class LASLIB_DLL LASreadOpener BOOL is_inside() const; I32 unparse(CHAR* string) const; void set_filter(LASfilter* filter); - LASfilter* get_filter() { return filter; }; + inline LASfilter* get_filter() { return filter; }; void set_transform(LAStransform* transform); - LAStransform* get_transform() { return transform; }; + inline LAStransform* get_transform() { return transform; }; + void set_ignore(LASignore* ignore); + inline LASignore* get_ignore() { return ignore; }; void reset(); const CHAR* get_temp_file_base() const { return temp_file_base; }; LASreader* open(const CHAR* other_file_name=0, BOOL reset_after_other=TRUE); BOOL reopen(LASreader* lasreader, BOOL remain_buffered=TRUE); LASwaveform13reader* open_waveform13(const LASheader* lasheader); + I32 get_number_attributes() const { return number_attributes; }; + I32 get_attribute_data_type(U32 index) const { return attribute_data_types[index]; }; + const CHAR* get_attribute_name(U32 index) const { return attribute_names[index]; }; + const CHAR* get_attribute_description(U32 index) const { return attribute_descriptions[index]; }; + F64 get_attribute_scale(U32 index) const { return attribute_scales[index]; }; + F64 get_attribute_offset(U32 index) const { return attribute_offsets[index]; }; + F64 get_attribute_no_data(U32 index) const { return attribute_no_datas[index]; }; LASreadOpener(); ~LASreadOpener(); private: @@ -231,19 +257,34 @@ class LASLIB_DLL LASreadOpener BOOL add_file_name_single(const CHAR* file_name, BOOL unique=FALSE); BOOL add_neighbor_file_name_single(const CHAR* neighbor_file_name, BOOL unique=FALSE); #endif - I32 io_ibuffer_size; - CHAR** file_names; + BOOL add_file_name(const CHAR* file_name, U32 ID, BOOL unique); + BOOL add_file_name(const CHAR* file_name, U32 ID, I64 npoints, F64 min_x, F64 min_y, F64 max_x, F64 max_y, BOOL unique=FALSE); + U32 io_ibuffer_size; const CHAR* file_name; BOOL merged; BOOL stored; + U32 file_name_current; + CHAR** file_names; U32 file_name_number; U32 file_name_allocated; - U32 file_name_current; + U32* file_names_ID; + I64* file_names_npoints; + F64* file_names_min_x; + F64* file_names_min_y; + F64* file_names_max_x; + F64* file_names_max_y; + LASkdtreeRectangles* kdtree_rectangles; F32 buffer_size; CHAR* temp_file_base; CHAR** neighbor_file_names; U32 neighbor_file_name_number; U32 neighbor_file_name_allocated; + I64* neighbor_file_names_npoints; + F64* neighbor_file_names_min_x; + F64* neighbor_file_names_min_y; + F64* neighbor_file_names_max_x; + F64* neighbor_file_names_max_y; + LASkdtreeRectangles* neighbor_kdtree_rectangles; BOOL comma_not_point; F64* scale_factor; F64* offset; @@ -269,7 +310,7 @@ class LASLIB_DLL LASreadOpener F64 attribute_no_datas[32]; U8 point_type; CHAR* parse_string; - I32 skip_lines; + U32 skip_lines; BOOL populate_header; BOOL keep_lastiling; BOOL pipe_on; @@ -280,6 +321,7 @@ class LASLIB_DLL LASreadOpener LASindex* index; LASfilter* filter; LAStransform* transform; + LASignore* ignore; // optional selective decompression (compressed new LAS 1.4 point types only) U32 decompress_selective; diff --git a/src/LASlib/lasreader_asc.cpp b/src/LASlib/lasreader_asc.cpp index 9af4c27..615acc7 100644 --- a/src/LASlib/lasreader_asc.cpp +++ b/src/LASlib/lasreader_asc.cpp @@ -2,11 +2,11 @@ =============================================================================== FILE: lasreader_asc.cpp - + CONTENTS: - + see corresponding header file - + PROGRAMMERS: martin.isenburg@rapidlasso.com - http://rapidlasso.com @@ -21,15 +21,17 @@ This software is distributed WITHOUT ANY WARRANTY and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - + CHANGE HISTORY: - + see corresponding header file - + =============================================================================== */ #include "lasreader_asc.hpp" +#include "lasvlrpayload.hpp" + #include #include @@ -43,7 +45,7 @@ BOOL LASreaderASC::open(const CHAR* file_name, BOOL comma_not_point) { if (file_name == 0) { - REprintf("ERROR: file name pointer is zero\n"); + fprintf(stderr,"ERROR: file name pointer is zero\n"); return FALSE; } @@ -53,13 +55,13 @@ BOOL LASreaderASC::open(const CHAR* file_name, BOOL comma_not_point) file = fopen_compressed(file_name, "r", &piped); if (file == 0) { - REprintf( "ERROR: cannot open file '%s'\n", file_name); + fprintf(stderr, "ERROR: cannot open file '%s'\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, 10*LAS_TOOLS_IO_IBUFFER_SIZE) != 0) { - REprintf( "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); + fprintf(stderr, "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); } // clean the header @@ -213,7 +215,7 @@ BOOL LASreaderASC::open(const CHAR* file_name, BOOL comma_not_point) if (!complete) { - REprintf("ERROR: was not able to find header\n"); + fprintf(stderr,"ERROR: was not able to find header\n"); return FALSE; } @@ -234,7 +236,7 @@ BOOL LASreaderASC::open(const CHAR* file_name, BOOL comma_not_point) // init the bounding box z and count the rasters - F32 elevation = 0; + F64 elevation = 0; npoints = 0; header.min_z = F64_MAX; header.max_z = F64_MIN; @@ -252,9 +254,9 @@ BOOL LASreaderASC::open(const CHAR* file_name, BOOL comma_not_point) if (!fgets(line, line_size, file)) { #ifdef _WIN32 - REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); + fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); #else - REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); + fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); #endif } @@ -274,7 +276,7 @@ BOOL LASreaderASC::open(const CHAR* file_name, BOOL comma_not_point) while ((line[line_curr] != '\0') && (line[line_curr] <= ' ')) line_curr++; } // get elevation value - sscanf(&(line[line_curr]), "%f", &elevation); + sscanf(&(line[line_curr]), "%lf", &elevation); // skip parsed number while ((line[line_curr] != '\0') && (line[line_curr] > ' ')) line_curr++; // skip following spaces @@ -309,11 +311,30 @@ BOOL LASreaderASC::open(const CHAR* file_name, BOOL comma_not_point) } else { - REprintf("WARNING: ASC raster contains only no data values\n"); + fprintf(stderr,"WARNING: ASC raster contains only no data values\n"); header.min_z = 0; header.max_z = 0; } + // add the VLR for Raster LAZ + + LASvlrRasterLAZ vlrRasterLAZ; + vlrRasterLAZ.nbands = 1; + vlrRasterLAZ.nbits = 32; + vlrRasterLAZ.ncols = ncols; + vlrRasterLAZ.nrows = nrows; + vlrRasterLAZ.reserved1 = 0; + vlrRasterLAZ.reserved2 = 0; + vlrRasterLAZ.stepx = cellsize; + vlrRasterLAZ.stepx_y = 0.0; + vlrRasterLAZ.stepy = cellsize; + vlrRasterLAZ.stepy_x = 0.0; + vlrRasterLAZ.llx = xllcenter - 0.5*cellsize; + vlrRasterLAZ.lly = yllcenter - 0.5*cellsize; + vlrRasterLAZ.sigmaxy = 0.0; + + header.add_vlr("Raster LAZ", 7113, (U16)vlrRasterLAZ.get_payload_size(), vlrRasterLAZ.get_payload(), FALSE, "by LAStools of rapidlasso GmbH", FALSE); + // reopen return reopen(file_name); @@ -358,7 +379,7 @@ BOOL LASreaderASC::seek(const I64 p_index) BOOL LASreaderASC::read_point_default() { - F32 elevation; + F64 elevation; while (p_count < npoints) { if (line[line_curr] == '\0') @@ -366,9 +387,9 @@ BOOL LASreaderASC::read_point_default() if (!fgets(line, line_size, file)) { #ifdef _WIN32 - REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); + fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); #else - REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); + fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); #endif npoints = p_count; return FALSE; @@ -394,7 +415,7 @@ BOOL LASreaderASC::read_point_default() row++; } // get elevation value - sscanf(&(line[line_curr]), "%f", &elevation); + sscanf(&(line[line_curr]), "%lf", &elevation); // skip parsed number while ((line[line_curr] != '\0') && (line[line_curr] > ' ')) line_curr++; // skip following spaces @@ -403,9 +424,18 @@ BOOL LASreaderASC::read_point_default() if (elevation != nodata) { // compute the quantized x, y, and z values - point.set_x(xllcenter + col*cellsize); - point.set_y(yllcenter + (nrows - row - 1) * cellsize); - point.set_z(elevation); + if (!point.set_x(xllcenter + col*cellsize)) + { + overflow_I32_x++; + } + if (!point.set_y(yllcenter + (nrows - row - 1) * cellsize)) + { + overflow_I32_y++; + } + if (!point.set_z(elevation)) + { + overflow_I32_z++; + } p_count++; col++; return TRUE; @@ -425,6 +455,33 @@ ByteStreamIn* LASreaderASC::get_stream() const void LASreaderASC::close(BOOL close_stream) { + if (overflow_I32_x) + { +#ifdef _WIN32 + fprintf(stderr, "WARNING: total of %I64d integer overflows in x\n", overflow_I32_x); +#else + fprintf(stderr, "WARNING: total of %lld integer overflows in x\n", overflow_I32_x); +#endif + overflow_I32_x = 0; + } + if (overflow_I32_y) + { +#ifdef _WIN32 + fprintf(stderr, "WARNING: total of %I64d integer overflows in y\n", overflow_I32_y); +#else + fprintf(stderr, "WARNING: total of %lld integer overflows in y\n", overflow_I32_y); +#endif + overflow_I32_y = 0; + } + if (overflow_I32_z) + { +#ifdef _WIN32 + fprintf(stderr, "WARNING: total of %I64d integer overflows in z\n", overflow_I32_z); +#else + fprintf(stderr, "WARNING: total of %lld integer overflows in z\n", overflow_I32_z); +#endif + overflow_I32_z = 0; + } if (file) { if (piped) while(fgets(line, line_size, file)); @@ -437,20 +494,20 @@ BOOL LASreaderASC::reopen(const CHAR* file_name) { if (file_name == 0) { - REprintf("ERROR: file name pointer is zero\n"); + fprintf(stderr,"ERROR: file name pointer is zero\n"); return FALSE; } file = fopen_compressed(file_name, "r", &piped); if (file == 0) { - REprintf( "ERROR: cannot reopen file '%s'\n", file_name); + fprintf(stderr, "ERROR: cannot reopen file '%s'\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, 10*LAS_TOOLS_IO_IBUFFER_SIZE) != 0) { - REprintf( "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); + fprintf(stderr, "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); } // read the header lines @@ -458,7 +515,7 @@ BOOL LASreaderASC::reopen(const CHAR* file_name) I32 i; for (i = 0; i < header_lines; i++) { - if(fgets(line, line_size, file)); + fgets(line, line_size, file); } // special handling for European numbers @@ -507,6 +564,9 @@ void LASreaderASC::clean() yllcenter = F64_MAX; cellsize = 0; nodata = -9999; + overflow_I32_x = 0; + overflow_I32_y = 0; + overflow_I32_z = 0; } LASreaderASC::LASreaderASC() @@ -587,19 +647,19 @@ void LASreaderASC::populate_bounding_box() { // compute quantized and then unquantized bounding box - F64 dequant_min_x = header.get_x(header.get_X(header.min_x)); - F64 dequant_max_x = header.get_x(header.get_X(header.max_x)); - F64 dequant_min_y = header.get_y(header.get_Y(header.min_y)); - F64 dequant_max_y = header.get_y(header.get_Y(header.max_y)); - F64 dequant_min_z = header.get_z(header.get_Z(header.min_z)); - F64 dequant_max_z = header.get_z(header.get_Z(header.max_z)); + F64 dequant_min_x = header.get_x((I32)(header.get_X(header.min_x))); + F64 dequant_max_x = header.get_x((I32)(header.get_X(header.max_x))); + F64 dequant_min_y = header.get_y((I32)(header.get_Y(header.min_y))); + F64 dequant_max_y = header.get_y((I32)(header.get_Y(header.max_y))); + F64 dequant_min_z = header.get_z((I32)(header.get_Z(header.min_z))); + F64 dequant_max_z = header.get_z((I32)(header.get_Z(header.max_z))); // make sure there is not sign flip if ((header.min_x > 0) != (dequant_min_x > 0)) { - REprintf( "WARNING: quantization sign flip for min_x from %g to %g.\n", header.min_x, dequant_min_x); - REprintf( " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for min_x from %g to %g.\n", header.min_x, dequant_min_x); + fprintf(stderr, " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); } else { @@ -607,8 +667,8 @@ void LASreaderASC::populate_bounding_box() } if ((header.max_x > 0) != (dequant_max_x > 0)) { - REprintf( "WARNING: quantization sign flip for max_x from %g to %g.\n", header.max_x, dequant_max_x); - REprintf( " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for max_x from %g to %g.\n", header.max_x, dequant_max_x); + fprintf(stderr, " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); } else { @@ -616,8 +676,8 @@ void LASreaderASC::populate_bounding_box() } if ((header.min_y > 0) != (dequant_min_y > 0)) { - REprintf( "WARNING: quantization sign flip for min_y from %g to %g.\n", header.min_y, dequant_min_y); - REprintf( " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for min_y from %g to %g.\n", header.min_y, dequant_min_y); + fprintf(stderr, " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); } else { @@ -625,8 +685,8 @@ void LASreaderASC::populate_bounding_box() } if ((header.max_y > 0) != (dequant_max_y > 0)) { - REprintf( "WARNING: quantization sign flip for max_y from %g to %g.\n", header.max_y, dequant_max_y); - REprintf( " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for max_y from %g to %g.\n", header.max_y, dequant_max_y); + fprintf(stderr, " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); } else { @@ -634,8 +694,8 @@ void LASreaderASC::populate_bounding_box() } if ((header.min_z > 0) != (dequant_min_z > 0)) { - REprintf( "WARNING: quantization sign flip for min_z from %g to %g.\n", header.min_z, dequant_min_z); - REprintf( " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for min_z from %g to %g.\n", header.min_z, dequant_min_z); + fprintf(stderr, " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); } else { @@ -643,8 +703,8 @@ void LASreaderASC::populate_bounding_box() } if ((header.max_z > 0) != (dequant_max_z > 0)) { - REprintf( "WARNING: quantization sign flip for max_z from %g to %g.\n", header.max_z, dequant_max_z); - REprintf( " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for max_z from %g to %g.\n", header.max_z, dequant_max_z); + fprintf(stderr, " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); } else { diff --git a/inst/include/lasreader_asc.hpp b/src/LASlib/lasreader_asc.hpp similarity index 89% rename from inst/include/lasreader_asc.hpp rename to src/LASlib/lasreader_asc.hpp index 11a5185..db711a6 100644 --- a/inst/include/lasreader_asc.hpp +++ b/src/LASlib/lasreader_asc.hpp @@ -13,7 +13,7 @@ COPYRIGHT: - (c) 2007-2013, martin isenburg, rapidlasso - fast tools to catch reality + (c) 2007-2019, martin isenburg, rapidlasso - fast tools to catch reality This is free software; you can redistribute and/or modify it under the terms of the GNU Lesser General Licence as published by the Free Software @@ -24,6 +24,8 @@ CHANGE HISTORY: + 31 August 2019 -- add RasterLAZ during code sprint after FOSS4G 2019 in Bucharest + 10 May 2019 -- checking for overflows in X, Y, Z 32 bit integers of fixed-point LAS 06 December 2013 -- option to deal with European '-comma_not_dot' numbers 26 March 2012 -- created after forgetting my laptop adaptor in the pre-fab @@ -72,6 +74,9 @@ class LASreaderASC : public LASreader F64 xllcenter, yllcenter; F32 cellsize; F32 nodata; + I64 overflow_I32_x; + I64 overflow_I32_y; + I64 overflow_I32_z; void clean(); void populate_scale_and_offset(); diff --git a/src/LASlib/lasreader_bil.cpp b/src/LASlib/lasreader_bil.cpp index f6f27dd..e8298a7 100644 --- a/src/LASlib/lasreader_bil.cpp +++ b/src/LASlib/lasreader_bil.cpp @@ -13,7 +13,7 @@ COPYRIGHT: - (c) 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality + (c) 2007-2019, martin isenburg, rapidlasso - fast tools to catch reality This is free software; you can redistribute and/or modify it under the terms of the GNU Lesser General Licence as published by the Free Software @@ -30,6 +30,8 @@ */ #include "lasreader_bil.hpp" +#include "lasvlrpayload.hpp" + #include #include @@ -41,7 +43,7 @@ BOOL LASreaderBIL::open(const CHAR* file_name) { if (file_name == 0) { - REprintf("ERROR: file name pointer is zero\n"); + fprintf(stderr,"ERROR: file name pointer is zero\n"); return FALSE; } @@ -53,7 +55,7 @@ BOOL LASreaderBIL::open(const CHAR* file_name) if (!read_hdr_file(file_name)) { - REprintf("ERROR: reading the *.hdr file for '%s'\n", file_name); + fprintf(stderr,"ERROR: reading the *.hdr file for '%s'\n", file_name); return FALSE; } @@ -61,7 +63,7 @@ BOOL LASreaderBIL::open(const CHAR* file_name) if (!read_blw_file(file_name)) { - REprintf("WARNING: reading the *.blw file for '%s'\n", file_name); + fprintf(stderr,"WARNING: reading the *.blw file for '%s'\n", file_name); } // check that we have all the needed info @@ -69,25 +71,25 @@ BOOL LASreaderBIL::open(const CHAR* file_name) if (xdim <= 0) { xdim = 1; - REprintf("WARNING: xdim was not set. setting to %g\n", xdim); + fprintf(stderr,"WARNING: xdim was not set. setting to %g\n", xdim); } if (ydim <= 0) { ydim = 1; - REprintf("WARNING: ydim was not set. setting to %g\n", ydim); + fprintf(stderr,"WARNING: ydim was not set. setting to %g\n", ydim); } if (ulxcenter == F64_MAX) { ulxcenter = 0.5*xdim; - REprintf("WARNING: ulxcenter was not set. setting to %g\n", ulxcenter); + fprintf(stderr,"WARNING: ulxcenter was not set. setting to %g\n", ulxcenter); } if (ulycenter == F64_MAX) { ulycenter = (-0.5+nrows)*ydim; - REprintf("WARNING: ulycenter was not set. setting to %g\n", ulycenter); + fprintf(stderr,"WARNING: ulycenter was not set. setting to %g\n", ulycenter); } // open the BIL file @@ -95,13 +97,13 @@ BOOL LASreaderBIL::open(const CHAR* file_name) file = fopen(file_name, "rb"); if (file == 0) { - REprintf( "ERROR: cannot open file '%s'\n", file_name); + fprintf(stderr, "ERROR: cannot open file '%s'\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, 2*LAS_TOOLS_IO_IBUFFER_SIZE) != 0) { - REprintf( "WARNING: setvbuf() failed with buffer size %d\n", 2*LAS_TOOLS_IO_IBUFFER_SIZE); + fprintf(stderr, "WARNING: setvbuf() failed with buffer size %d\n", 2*LAS_TOOLS_IO_IBUFFER_SIZE); } // populate the header as much as it makes sense @@ -123,7 +125,7 @@ BOOL LASreaderBIL::open(const CHAR* file_name) if ((((creation.wYear)%4) == 0) && (creation.wMonth > 2)) header.file_creation_day++; #else header.file_creation_day = 333; - header.file_creation_year = 2012; + header.file_creation_year = 2019; #endif // initialize point format in header @@ -327,11 +329,30 @@ BOOL LASreaderBIL::open(const CHAR* file_name) } else { - REprintf("WARNING: BIL raster contains only no data values\n"); + fprintf(stderr,"WARNING: BIL raster contains only no data values\n"); header.min_z = 0; header.max_z = 0; } + // add the VLR for Raster LAZ + + LASvlrRasterLAZ vlrRasterLAZ; + vlrRasterLAZ.nbands = 1; + vlrRasterLAZ.nbits = 32; + vlrRasterLAZ.ncols = ncols; + vlrRasterLAZ.nrows = nrows; + vlrRasterLAZ.reserved1 = 0; + vlrRasterLAZ.reserved2 = 0; + vlrRasterLAZ.stepx = xdim; + vlrRasterLAZ.stepx_y = 0.0; + vlrRasterLAZ.stepy = ydim; + vlrRasterLAZ.stepy_x = 0.0; + vlrRasterLAZ.llx = ulxcenter - 0.5*xdim; + vlrRasterLAZ.lly = ulycenter + (0.5 - nrows)*ydim; + vlrRasterLAZ.sigmaxy = 0.0; + + header.add_vlr("Raster LAZ", 7113, (U16)vlrRasterLAZ.get_payload_size(), vlrRasterLAZ.get_payload(), FALSE, "by LAStools of rapidlasso GmbH", FALSE); + // reopen return reopen(file_name); @@ -341,7 +362,7 @@ BOOL LASreaderBIL::read_hdr_file(const CHAR* file_name) { if (file_name == 0) { - REprintf("ERROR: file name pointer is zero\n"); + fprintf(stderr,"ERROR: file name pointer is zero\n"); return FALSE; } @@ -354,7 +375,7 @@ BOOL LASreaderBIL::read_hdr_file(const CHAR* file_name) if ((len == 0) && (file_name_hdr[len] != '.')) { - REprintf("ERROR: file name '%s' is not a valid BIL file\n", file_name); + fprintf(stderr,"ERROR: file name '%s' is not a valid BIL file\n", file_name); return FALSE; } @@ -376,7 +397,7 @@ BOOL LASreaderBIL::read_hdr_file(const CHAR* file_name) if (file == 0) { file_name_hdr[len] = '\0'; - REprintf( "ERROR: cannot open files '%s.hdr' or '%s.HDR'\n", file_name_hdr, file_name_hdr); + fprintf(stderr, "ERROR: cannot open files '%s.hdr' or '%s.HDR'\n", file_name_hdr, file_name_hdr); return FALSE; } } @@ -429,12 +450,12 @@ BOOL LASreaderBIL::read_hdr_file(const CHAR* file_name) { if (strcmp(layout, "bil") && strcmp(layout, "BIL")) { - REprintf( "WARNING: %s '%s' not recognized by LASreader_bil\n", dummy, layout); + fprintf(stderr, "WARNING: %s '%s' not recognized by LASreader_bil\n", dummy, layout); } } else { - REprintf( "WARNING: argument of %s missing for LASreader_bil\n", dummy); + fprintf(stderr, "WARNING: argument of %s missing for LASreader_bil\n", dummy); } } else if (strstr(line, "pixeltype") || strstr(line, "PIXELTYPE")) @@ -451,7 +472,7 @@ BOOL LASreaderBIL::read_hdr_file(const CHAR* file_name) } else { - REprintf( "WARNING: pixeltype '%s' not recognized by LASreader_bil\n", pixeltype); + fprintf(stderr, "WARNING: pixeltype '%s' not recognized by LASreader_bil\n", pixeltype); } } else if (strstr(line, "nodata") || strstr(line, "NODATA")) @@ -464,7 +485,7 @@ BOOL LASreaderBIL::read_hdr_file(const CHAR* file_name) sscanf(line, "%s %s", dummy, byteorder); if (strcmp(byteorder, "i") && strcmp(byteorder, "I")) { - REprintf( "WARNING: byteorder '%s' not recognized by LASreader_bil\n", byteorder); + fprintf(stderr, "WARNING: byteorder '%s' not recognized by LASreader_bil\n", byteorder); } } else if (strstr(line, "ulxmap") || strstr(line, "ULXMAP")) @@ -499,11 +520,11 @@ BOOL LASreaderBIL::read_hdr_file(const CHAR* file_name) if ((ncols <= 0) || (nrows <= 0) || (nbands <= 0) || (nbits <= 0)) { - REprintf("WARNING: not able to find all entries in HDR file\n"); - REprintf(" ncols = %d\n", ncols); - REprintf(" nrows = %d\n", nrows); - REprintf(" nbands = %d\n", nbands); - REprintf(" nbits = %d\n", nbits); + fprintf(stderr,"WARNING: not able to find all entries in HDR file\n"); + fprintf(stderr," ncols = %d\n", ncols); + fprintf(stderr," nrows = %d\n", nrows); + fprintf(stderr," nbands = %d\n", nbands); + fprintf(stderr," nbits = %d\n", nbits); return FALSE; } @@ -514,7 +535,7 @@ BOOL LASreaderBIL::read_blw_file(const CHAR* file_name) { if (file_name == 0) { - REprintf("ERROR: file name pointer is zero\n"); + fprintf(stderr,"ERROR: file name pointer is zero\n"); return FALSE; } @@ -527,7 +548,7 @@ BOOL LASreaderBIL::read_blw_file(const CHAR* file_name) if ((len == 0) && (file_name_bwl[len] != '.')) { - REprintf("ERROR: file name '%s' is not a valid BIL file\n", file_name); + fprintf(stderr,"ERROR: file name '%s' is not a valid BIL file\n", file_name); return FALSE; } @@ -548,7 +569,7 @@ BOOL LASreaderBIL::read_blw_file(const CHAR* file_name) if (file == 0) { file_name_bwl[len] = '\0'; - REprintf( "WARNING: cannot open files '%s.blw' or '%s.BLW'\n", file_name_bwl, file_name_bwl); + fprintf(stderr, "WARNING: cannot open files '%s.blw' or '%s.BLW'\n", file_name_bwl, file_name_bwl); free(file_name_bwl); return FALSE; } @@ -560,36 +581,36 @@ BOOL LASreaderBIL::read_blw_file(const CHAR* file_name) if (!fgets(line, 256, file)) { - REprintf( "WARNING: corrupt world file\n"); + fprintf(stderr, "WARNING: corrupt world file\n"); return FALSE; } sscanf(line, "%f", &xdim); if (!fgets(line, 256, file)) { - REprintf( "WARNING: corrupt world file\n"); + fprintf(stderr, "WARNING: corrupt world file\n"); return FALSE; } if (!fgets(line, 256, file)) { - REprintf( "WARNING: corrupt world file\n"); + fprintf(stderr, "WARNING: corrupt world file\n"); return FALSE; } if (!fgets(line, 256, file)) { - REprintf( "WARNING: corrupt world file\n"); + fprintf(stderr, "WARNING: corrupt world file\n"); return FALSE; } sscanf(line, "%f", &ydim); ydim = -1*ydim; if (!fgets(line, 256, file)) { - REprintf( "WARNING: corrupt world file\n"); + fprintf(stderr, "WARNING: corrupt world file\n"); return FALSE; } sscanf(line, "%lf", &ulxcenter); if (!fgets(line, 256, file)) { - REprintf( "WARNING: corrupt world file\n"); + fprintf(stderr, "WARNING: corrupt world file\n"); return FALSE; } sscanf(line, "%lf", &ulycenter); @@ -655,9 +676,9 @@ BOOL LASreaderBIL::read_point_default() if (fread((void*)&elevation, 4, 1, file) != 1) { #ifdef _WIN32 - REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); + fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); #else - REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); + fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); #endif npoints = p_count; return FALSE; @@ -669,9 +690,9 @@ BOOL LASreaderBIL::read_point_default() if (fread((void*)&elev, 4, 1, file) != 1) { #ifdef _WIN32 - REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); + fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); #else - REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); + fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); #endif npoints = p_count; return FALSE; @@ -687,9 +708,9 @@ BOOL LASreaderBIL::read_point_default() if (fread((void*)&elev, 2, 1, file) != 1) { #ifdef _WIN32 - REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); + fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); #else - REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); + fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); #endif npoints = p_count; return FALSE; @@ -702,9 +723,9 @@ BOOL LASreaderBIL::read_point_default() if (fread((void*)&elev, 2, 1, file) != 1) { #ifdef _WIN32 - REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); + fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); #else - REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); + fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); #endif npoints = p_count; return FALSE; @@ -720,9 +741,9 @@ BOOL LASreaderBIL::read_point_default() if (fread((void*)rgb, 1, nbands, file) != (U32)nbands) { #ifdef _WIN32 - REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); + fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); #else - REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); + fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); #endif npoints = p_count; return FALSE; @@ -735,9 +756,9 @@ BOOL LASreaderBIL::read_point_default() if (fread((void*)rgb, 1, nbands, file) != (U32)nbands) { #ifdef _WIN32 - REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); + fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); #else - REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); + fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); #endif npoints = p_count; return FALSE; @@ -748,9 +769,18 @@ BOOL LASreaderBIL::read_point_default() if (elevation != nodata) { - point.set_x(ulxcenter + col * xdim); - point.set_y(ulycenter - row * ydim); - point.set_z(elevation); + if (!point.set_x(ulxcenter + col * xdim)) + { + overflow_I32_x++; + } + if (!point.set_y(ulycenter - row * ydim)) + { + overflow_I32_y++; + } + if (!point.set_z(elevation)) + { + overflow_I32_z++; + } p_count++; col++; return TRUE; @@ -770,6 +800,33 @@ ByteStreamIn* LASreaderBIL::get_stream() const void LASreaderBIL::close(BOOL close_stream) { + if (overflow_I32_x) + { +#ifdef _WIN32 + fprintf(stderr, "WARNING: total of %I64d integer overflows in x\n", overflow_I32_x); +#else + fprintf(stderr, "WARNING: total of %lld integer overflows in x\n", overflow_I32_x); +#endif + overflow_I32_x = 0; + } + if (overflow_I32_y) + { +#ifdef _WIN32 + fprintf(stderr, "WARNING: total of %I64d integer overflows in y\n", overflow_I32_y); +#else + fprintf(stderr, "WARNING: total of %lld integer overflows in y\n", overflow_I32_y); +#endif + overflow_I32_y = 0; + } + if (overflow_I32_z) + { +#ifdef _WIN32 + fprintf(stderr, "WARNING: total of %I64d integer overflows in z\n", overflow_I32_z); +#else + fprintf(stderr, "WARNING: total of %lld integer overflows in z\n", overflow_I32_z); +#endif + overflow_I32_z = 0; + } if (file) { fclose(file); @@ -781,20 +838,20 @@ BOOL LASreaderBIL::reopen(const CHAR* file_name) { if (file_name == 0) { - REprintf("ERROR: file name pointer is zero\n"); + fprintf(stderr,"ERROR: file name pointer is zero\n"); return FALSE; } file = fopen(file_name, "rb"); if (file == 0) { - REprintf( "ERROR: cannot reopen file '%s'\n", file_name); + fprintf(stderr, "ERROR: cannot reopen file '%s'\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, 2*LAS_TOOLS_IO_IBUFFER_SIZE) != 0) { - REprintf( "WARNING: setvbuf() failed with buffer size %d\n", 2*LAS_TOOLS_IO_IBUFFER_SIZE); + fprintf(stderr, "WARNING: setvbuf() failed with buffer size %d\n", 2*LAS_TOOLS_IO_IBUFFER_SIZE); } col = 0; @@ -824,6 +881,9 @@ void LASreaderBIL::clean() nodata = -9999; floatpixels = FALSE; signedpixels = FALSE; + overflow_I32_x = 0; + overflow_I32_y = 0; + overflow_I32_z = 0; } LASreaderBIL::LASreaderBIL() @@ -917,19 +977,19 @@ void LASreaderBIL::populate_bounding_box() { // compute quantized and then unquantized bounding box - F64 dequant_min_x = header.get_x(header.get_X(header.min_x)); - F64 dequant_max_x = header.get_x(header.get_X(header.max_x)); - F64 dequant_min_y = header.get_y(header.get_Y(header.min_y)); - F64 dequant_max_y = header.get_y(header.get_Y(header.max_y)); - F64 dequant_min_z = header.get_z(header.get_Z(header.min_z)); - F64 dequant_max_z = header.get_z(header.get_Z(header.max_z)); + F64 dequant_min_x = header.get_x((I32)(header.get_X(header.min_x))); + F64 dequant_max_x = header.get_x((I32)(header.get_X(header.max_x))); + F64 dequant_min_y = header.get_y((I32)(header.get_Y(header.min_y))); + F64 dequant_max_y = header.get_y((I32)(header.get_Y(header.max_y))); + F64 dequant_min_z = header.get_z((I32)(header.get_Z(header.min_z))); + F64 dequant_max_z = header.get_z((I32)(header.get_Z(header.max_z))); // make sure there is not sign flip if ((header.min_x > 0) != (dequant_min_x > 0)) { - REprintf( "WARNING: quantization sign flip for min_x from %g to %g.\n", header.min_x, dequant_min_x); - REprintf( " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for min_x from %g to %g.\n", header.min_x, dequant_min_x); + fprintf(stderr, " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); } else { @@ -937,8 +997,8 @@ void LASreaderBIL::populate_bounding_box() } if ((header.max_x > 0) != (dequant_max_x > 0)) { - REprintf( "WARNING: quantization sign flip for max_x from %g to %g.\n", header.max_x, dequant_max_x); - REprintf( " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for max_x from %g to %g.\n", header.max_x, dequant_max_x); + fprintf(stderr, " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); } else { @@ -946,8 +1006,8 @@ void LASreaderBIL::populate_bounding_box() } if ((header.min_y > 0) != (dequant_min_y > 0)) { - REprintf( "WARNING: quantization sign flip for min_y from %g to %g.\n", header.min_y, dequant_min_y); - REprintf( " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for min_y from %g to %g.\n", header.min_y, dequant_min_y); + fprintf(stderr, " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); } else { @@ -955,8 +1015,8 @@ void LASreaderBIL::populate_bounding_box() } if ((header.max_y > 0) != (dequant_max_y > 0)) { - REprintf( "WARNING: quantization sign flip for max_y from %g to %g.\n", header.max_y, dequant_max_y); - REprintf( " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for max_y from %g to %g.\n", header.max_y, dequant_max_y); + fprintf(stderr, " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); } else { @@ -964,8 +1024,8 @@ void LASreaderBIL::populate_bounding_box() } if ((header.min_z > 0) != (dequant_min_z > 0)) { - REprintf( "WARNING: quantization sign flip for min_z from %g to %g.\n", header.min_z, dequant_min_z); - REprintf( " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for min_z from %g to %g.\n", header.min_z, dequant_min_z); + fprintf(stderr, " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); } else { @@ -973,8 +1033,8 @@ void LASreaderBIL::populate_bounding_box() } if ((header.max_z > 0) != (dequant_max_z > 0)) { - REprintf( "WARNING: quantization sign flip for max_z from %g to %g.\n", header.max_z, dequant_max_z); - REprintf( " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for max_z from %g to %g.\n", header.max_z, dequant_max_z); + fprintf(stderr, " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); } else { diff --git a/inst/include/lasreader_bil.hpp b/src/LASlib/lasreader_bil.hpp similarity index 89% rename from inst/include/lasreader_bil.hpp rename to src/LASlib/lasreader_bil.hpp index 38aeb22..49349a0 100644 --- a/inst/include/lasreader_bil.hpp +++ b/src/LASlib/lasreader_bil.hpp @@ -13,7 +13,7 @@ COPYRIGHT: - (c) 2007-2014, martin isenburg, rapidlasso - fast tools to catch reality + (c) 2007-2019, martin isenburg, rapidlasso - fast tools to catch reality This is free software; you can redistribute and/or modify it under the terms of the GNU Lesser General Licence as published by the Free Software @@ -24,6 +24,8 @@ CHANGE HISTORY: + 31 August 2019 -- add RasterLAZ during code sprint after FOSS4G 2019 in Bucharest + 10 May 2019 -- checking for overflows in X, Y, Z 32 bit integers of fixed-point LAS 7 September 2018 -- replaced calls to _strdup with calls to the LASCopyString macro 20 June 2017 -- fixed reading of signed versus unsigned 16 and 8 bit intergers 3 April 2012 -- created after joining the Spar Europe 2012 Advisory Board @@ -69,6 +71,9 @@ class LASreaderBIL : public LASreader F32 nodata; BOOL floatpixels; BOOL signedpixels; + I64 overflow_I32_x; + I64 overflow_I32_y; + I64 overflow_I32_z; void clean(); BOOL read_hdr_file(const CHAR* file_name); diff --git a/src/LASlib/lasreader_bin.cpp b/src/LASlib/lasreader_bin.cpp index 401c958..a8f5226 100644 --- a/src/LASlib/lasreader_bin.cpp +++ b/src/LASlib/lasreader_bin.cpp @@ -82,7 +82,7 @@ BOOL LASreaderBIN::open(const char* file_name) { if (file_name == 0) { - REprintf("ERROR: file name pointer is zero\n"); + fprintf(stderr,"ERROR: file name pointer is zero\n"); return FALSE; } @@ -91,13 +91,13 @@ BOOL LASreaderBIN::open(const char* file_name) file = fopen(file_name, "rb"); if (file == 0) { - REprintf( "ERROR: cannot open file '%s'\n", file_name); + fprintf(stderr, "ERROR: cannot open file '%s'\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, 2*LAS_TOOLS_IO_IBUFFER_SIZE) != 0) { - REprintf( "WARNING: setvbuf() failed with buffer size %d\n", 2*LAS_TOOLS_IO_IBUFFER_SIZE); + fprintf(stderr, "WARNING: setvbuf() failed with buffer size %d\n", 2*LAS_TOOLS_IO_IBUFFER_SIZE); } // create input stream @@ -138,7 +138,7 @@ BOOL LASreaderBIN::open(ByteStreamIn* stream) if (stream == 0) { - REprintf("ERROR: ByteStreamIn* pointer is zero\n"); + fprintf(stderr,"ERROR: ByteStreamIn* pointer is zero\n"); return FALSE; } @@ -149,7 +149,7 @@ BOOL LASreaderBIN::open(ByteStreamIn* stream) TSheader tsheader; try { stream->getBytes((U8*)&tsheader, sizeof(TSheader)); } catch(...) { - REprintf("ERROR: reading terrasolid header\n"); + fprintf(stderr,"ERROR: reading terrasolid header\n"); return FALSE; } @@ -157,19 +157,19 @@ BOOL LASreaderBIN::open(ByteStreamIn* stream) if (tsheader.size != sizeof(TSheader)) { - REprintf("ERROR: corrupt terrasolid header. size != 56.\n"); + fprintf(stderr,"ERROR: corrupt terrasolid header. size != 56.\n"); return FALSE; } if (tsheader.recog_val != 970401) { - REprintf("ERROR: corrupt terrasolid header. recog_val != 979401.\n"); + fprintf(stderr,"ERROR: corrupt terrasolid header. recog_val != 979401.\n"); return FALSE; } if (strncmp(tsheader.recog_str, "CXYZ", 4) != 0) { - REprintf("ERROR: corrupt terrasolid header. recog_str != CXYZ.\n"); + fprintf(stderr,"ERROR: corrupt terrasolid header. recog_str != CXYZ.\n"); return FALSE; } @@ -279,7 +279,7 @@ BOOL LASreaderBIN::read_point_default() TSpoint tspoint; try { stream->getBytes((U8*)&tspoint, sizeof(TSpoint)); } catch(...) { - REprintf("ERROR: reading terrasolid point after %u of %u\n", (U32)p_count, (U32)npoints); + fprintf(stderr,"ERROR: reading terrasolid point after %u of %u\n", (U32)p_count, (U32)npoints); return FALSE; } point.set_X(tspoint.x); @@ -295,7 +295,7 @@ BOOL LASreaderBIN::read_point_default() TSrow tsrow; try { stream->getBytes((U8*)&tsrow, sizeof(TSrow)); } catch(...) { - REprintf("ERROR: reading terrasolid row after %u of %u\n", (U32)p_count, (U32)npoints); + fprintf(stderr,"ERROR: reading terrasolid row after %u of %u\n", (U32)p_count, (U32)npoints); return FALSE; } point.set_X(tsrow.x); @@ -344,7 +344,7 @@ BOOL LASreaderBIN::read_point_default() U32 time; try { stream->getBytes((U8*)&time, sizeof(U32)); } catch(...) { - REprintf("ERROR: reading terrasolid time\n"); + fprintf(stderr,"ERROR: reading terrasolid time\n"); return FALSE; } point.gps_time = 0.0002*time; @@ -355,7 +355,7 @@ BOOL LASreaderBIN::read_point_default() U8 rgba[4]; try { stream->getBytes((U8*)rgba, sizeof(U8)*4); } catch(...) { - REprintf("ERROR: reading terrasolid color\n"); + fprintf(stderr,"ERROR: reading terrasolid color\n"); return FALSE; } point.rgb[0] = 256*rgba[0]; diff --git a/inst/include/lasreader_bin.hpp b/src/LASlib/lasreader_bin.hpp similarity index 100% rename from inst/include/lasreader_bin.hpp rename to src/LASlib/lasreader_bin.hpp diff --git a/src/LASlib/lasreader_dtm.cpp b/src/LASlib/lasreader_dtm.cpp index 9bec04c..1a8ff17 100644 --- a/src/LASlib/lasreader_dtm.cpp +++ b/src/LASlib/lasreader_dtm.cpp @@ -30,6 +30,8 @@ */ #include "lasreader_dtm.hpp" +#include "lasvlrpayload.hpp" + // used to map GeoTIFF codes to GCTP codes static const unsigned short PCS_NAD83_Alabama_East = 26929; @@ -289,7 +291,7 @@ BOOL LASreaderDTM::open(const CHAR* file_name) { if (file_name == 0) { - REprintf("ERROR: file name pointer is zero\n"); + fprintf(stderr,"ERROR: file name pointer is zero\n"); return FALSE; } @@ -302,13 +304,13 @@ BOOL LASreaderDTM::open(const CHAR* file_name) file = fopen(file_name, "rb"); if (file == 0) { - REprintf( "ERROR: cannot open file '%s'\n", file_name); + fprintf(stderr, "ERROR: cannot open file '%s'\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, 2*LAS_TOOLS_IO_IBUFFER_SIZE) != 0) { - REprintf( "WARNING: setvbuf() failed with buffer size %d\n", 2*LAS_TOOLS_IO_IBUFFER_SIZE); + fprintf(stderr, "WARNING: setvbuf() failed with buffer size %d\n", 2*LAS_TOOLS_IO_IBUFFER_SIZE); } // read the 200 byte header @@ -316,7 +318,7 @@ BOOL LASreaderDTM::open(const CHAR* file_name) CHAR signature[21]; if (fread(signature, 1, 21, file) != 21) { - REprintf( "ERROR: reading 21 byte signature for '%s'\n", file_name); + fprintf(stderr, "ERROR: reading 21 byte signature for '%s'\n", file_name); return FALSE; } @@ -324,7 +326,7 @@ BOOL LASreaderDTM::open(const CHAR* file_name) if (strncmp(signature, "PLANS-PC BINARY .DTM", 21) != 0) { - REprintf( "ERROR: cannot open DTM file '%s', wrong signature '%21s'\n", file_name, signature); + fprintf(stderr, "ERROR: cannot open DTM file '%s', wrong signature '%21s'\n", file_name, signature); return FALSE; } @@ -333,7 +335,7 @@ BOOL LASreaderDTM::open(const CHAR* file_name) CHAR description[61]; if (fread(description, 1, 61, file) != 61) { - REprintf( "ERROR: reading 61 byte description for '%s'\n", file_name); + fprintf(stderr, "ERROR: reading 61 byte description for '%s'\n", file_name); return FALSE; } @@ -342,7 +344,7 @@ BOOL LASreaderDTM::open(const CHAR* file_name) F32 version; if (fread(&version, 4, 1, file) != 1) { - REprintf( "ERROR: reading 4 byte version for '%s'\n", file_name); + fprintf(stderr, "ERROR: reading 4 byte version for '%s'\n", file_name); return FALSE; } @@ -350,7 +352,7 @@ BOOL LASreaderDTM::open(const CHAR* file_name) if (version != 3.1f) { - REprintf( "WARNING: expected 3.1 but version is %1.1f\n", version); + fprintf(stderr, "WARNING: expected 3.1 but version is %1.1f\n", version); } // read lower left x @@ -390,7 +392,7 @@ BOOL LASreaderDTM::open(const CHAR* file_name) if (rotation != 0.0) { - REprintf( "WARNING: expected 0.0 but rotation is %g\n", rotation); + fprintf(stderr, "WARNING: expected 0.0 but rotation is %g\n", rotation); } F64 column_spacing; @@ -426,43 +428,43 @@ BOOL LASreaderDTM::open(const CHAR* file_name) if (fread(&horizontal_units, 2, 1, file) != 1) { - REprintf( "ERROR: reading 2 byte horizontal_units for '%s'\n", file_name); + fprintf(stderr, "ERROR: reading 2 byte horizontal_units for '%s'\n", file_name); return FALSE; } if (fread(&vertical_units, 2, 1, file) != 1) { - REprintf( "ERROR: reading 2 byte vertical_units for '%s'\n", file_name); + fprintf(stderr, "ERROR: reading 2 byte vertical_units for '%s'\n", file_name); return FALSE; } if (fread(&data_type, 2, 1, file) != 1) { - REprintf( "ERROR: reading 2 byte data_type for '%s'\n", file_name); + fprintf(stderr, "ERROR: reading 2 byte data_type for '%s'\n", file_name); return FALSE; } if (fread(&coordinate_system, 2, 1, file) != 1) { - REprintf( "ERROR: reading 2 byte horizontal_units for '%s'\n", file_name); + fprintf(stderr, "ERROR: reading 2 byte horizontal_units for '%s'\n", file_name); return FALSE; } if (fread(&coordinate_zone, 2, 1, file) != 1) { - REprintf( "ERROR: reading 2 byte coordinate_zone for '%s'\n", file_name); + fprintf(stderr, "ERROR: reading 2 byte coordinate_zone for '%s'\n", file_name); return FALSE; } if (fread(&horizontal_datum, 2, 1, file) != 1) { - REprintf( "ERROR: reading 2 byte horizontal_datum for '%s'\n", file_name); + fprintf(stderr, "ERROR: reading 2 byte horizontal_datum for '%s'\n", file_name); return FALSE; } if (fread(&vertical_datum, 2, 1, file) != 1) { - REprintf( "ERROR: reading 2 byte vertical_datum for '%s'\n", file_name); + fprintf(stderr, "ERROR: reading 2 byte vertical_datum for '%s'\n", file_name); return FALSE; } @@ -481,7 +483,7 @@ BOOL LASreaderDTM::open(const CHAR* file_name) } else { - REprintf( "UTM zone %d for NAD27 out-of-range\n", (int)coordinate_zone); + fprintf(stderr, "UTM zone %d for NAD27 out-of-range\n", (int)coordinate_zone); } } else if (horizontal_datum == 2) // GEO_DATUM_NAD83 @@ -496,7 +498,7 @@ BOOL LASreaderDTM::open(const CHAR* file_name) } else { - REprintf( "UTM zone %d for NAD83 out-of-range\n", (int)coordinate_zone); + fprintf(stderr, "UTM zone %d for NAD83 out-of-range\n", (int)coordinate_zone); } } else if (horizontal_datum == 3) // GEO_DATUM_WGS84 @@ -902,7 +904,7 @@ BOOL LASreaderDTM::open(const CHAR* file_name) geokey = PCS_NAD83_Puerto_Rico; break; default: - REprintf( "state plane NAD83 zone %d not implemented\n", (int)coordinate_zone); + fprintf(stderr, "state plane NAD83 zone %d not implemented\n", (int)coordinate_zone); } } @@ -982,14 +984,14 @@ BOOL LASreaderDTM::open(const CHAR* file_name) if (xdim <= 0) { - REprintf("WARNING: xdim was %g. setting to 1.0\n", xdim); + fprintf(stderr,"WARNING: xdim was %g. setting to 1.0\n", xdim); xdim = 1; } if (ydim <= 0) { ydim = 1; - REprintf("WARNING: ydim was %g. setting to 1.0\n", ydim); + fprintf(stderr,"WARNING: ydim was %g. setting to 1.0\n", ydim); } // populate the header as much as it makes sense @@ -1134,7 +1136,7 @@ BOOL LASreaderDTM::open(const CHAR* file_name) } else { - REprintf("ERROR: unknown data type %d\n", (I32)data_type); + fprintf(stderr,"ERROR: unknown data type %d\n", (I32)data_type); return FALSE; } @@ -1154,11 +1156,30 @@ BOOL LASreaderDTM::open(const CHAR* file_name) } else { - REprintf("WARNING: DTM raster contains only no data values\n"); + fprintf(stderr,"WARNING: DTM raster contains only no data values\n"); header.min_z = 0; header.max_z = 0; } + // add the VLR for Raster LAZ + + LASvlrRasterLAZ vlrRasterLAZ; + vlrRasterLAZ.nbands = 1; + vlrRasterLAZ.nbits = 32; + vlrRasterLAZ.ncols = ncols; + vlrRasterLAZ.nrows = nrows; + vlrRasterLAZ.reserved1 = 0; + vlrRasterLAZ.reserved2 = 0; + vlrRasterLAZ.stepx = xdim; + vlrRasterLAZ.stepx_y = 0.0; + vlrRasterLAZ.stepy = ydim; + vlrRasterLAZ.stepy_x = 0.0; + vlrRasterLAZ.llx = ll_x; + vlrRasterLAZ.lly = ll_y; + vlrRasterLAZ.sigmaxy = 0.0; + + header.add_vlr("Raster LAZ", 7113, (U16)vlrRasterLAZ.get_payload_size(), vlrRasterLAZ.get_payload(), FALSE, "by LAStools of rapidlasso GmbH", FALSE); + // reopen return reopen(file_name); @@ -1218,9 +1239,9 @@ BOOL LASreaderDTM::read_point_default() if (fread((void*)&elevation, 4, 1, file) != 1) { #ifdef _WIN32 - REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); + fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); #else - REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); + fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); #endif npoints = p_count; return FALSE; @@ -1232,9 +1253,9 @@ BOOL LASreaderDTM::read_point_default() if (fread((void*)&elev, 4, 1, file) != 1) { #ifdef _WIN32 - REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); + fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); #else - REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); + fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); #endif npoints = p_count; return FALSE; @@ -1247,9 +1268,9 @@ BOOL LASreaderDTM::read_point_default() if (fread((void*)&elev, 2, 1, file) != 1) { #ifdef _WIN32 - REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); + fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); #else - REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); + fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); #endif npoints = p_count; return FALSE; @@ -1262,9 +1283,9 @@ BOOL LASreaderDTM::read_point_default() if (fread((void*)&elev, 8, 1, file) != 1) { #ifdef _WIN32 - REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); + fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); #else - REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); + fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); #endif npoints = p_count; return FALSE; @@ -1273,15 +1294,24 @@ BOOL LASreaderDTM::read_point_default() } else { - REprintf("ERROR: unknown data type %d\n", (I32)data_type); + fprintf(stderr,"ERROR: unknown data type %d\n", (I32)data_type); return FALSE; } if (elevation != nodata) { - point.set_x(ll_x + col * xdim); - point.set_y(ll_y + row * ydim); - point.set_z(elevation); + if (!point.set_x(ll_x + col * xdim)) + { + overflow_I32_x++; + } + if (!point.set_y(ll_y + row * ydim)) + { + overflow_I32_y++; + } + if (!point.set_z(elevation)) + { + overflow_I32_z++; + } p_count++; row++; return TRUE; @@ -1301,6 +1331,33 @@ ByteStreamIn* LASreaderDTM::get_stream() const void LASreaderDTM::close(BOOL close_stream) { + if (overflow_I32_x) + { +#ifdef _WIN32 + fprintf(stderr, "WARNING: total of %I64d integer overflows in x\n", overflow_I32_x); +#else + fprintf(stderr, "WARNING: total of %lld integer overflows in x\n", overflow_I32_x); +#endif + overflow_I32_x = 0; + } + if (overflow_I32_y) + { +#ifdef _WIN32 + fprintf(stderr, "WARNING: total of %I64d integer overflows in y\n", overflow_I32_y); +#else + fprintf(stderr, "WARNING: total of %lld integer overflows in y\n", overflow_I32_y); +#endif + overflow_I32_y = 0; + } + if (overflow_I32_z) + { +#ifdef _WIN32 + fprintf(stderr, "WARNING: total of %I64d integer overflows in z\n", overflow_I32_z); +#else + fprintf(stderr, "WARNING: total of %lld integer overflows in z\n", overflow_I32_z); +#endif + overflow_I32_z = 0; + } if (file) { fclose(file); @@ -1312,7 +1369,7 @@ BOOL LASreaderDTM::reopen(const CHAR* file_name) { if (file_name == 0) { - REprintf("ERROR: file name pointer is zero\n"); + fprintf(stderr,"ERROR: file name pointer is zero\n"); return FALSE; } @@ -1327,13 +1384,13 @@ BOOL LASreaderDTM::reopen(const CHAR* file_name) file = fopen(file_name, "rb"); if (file == 0) { - REprintf( "ERROR: cannot reopen file '%s'\n", file_name); + fprintf(stderr, "ERROR: cannot reopen file '%s'\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, 2*LAS_TOOLS_IO_IBUFFER_SIZE) != 0) { - REprintf( "WARNING: setvbuf() failed with buffer size %d\n", 2*LAS_TOOLS_IO_IBUFFER_SIZE); + fprintf(stderr, "WARNING: setvbuf() failed with buffer size %d\n", 2*LAS_TOOLS_IO_IBUFFER_SIZE); } col = 0; @@ -1368,6 +1425,9 @@ void LASreaderDTM::clean() ll_y = 0.0; xdim = 0; ydim = 0; + overflow_I32_x = 0; + overflow_I32_y = 0; + overflow_I32_z = 0; } LASreaderDTM::LASreaderDTM() @@ -1447,19 +1507,19 @@ void LASreaderDTM::populate_bounding_box() { // compute quantized and then unquantized bounding box - F64 dequant_min_x = header.get_x(header.get_X(header.min_x)); - F64 dequant_max_x = header.get_x(header.get_X(header.max_x)); - F64 dequant_min_y = header.get_y(header.get_Y(header.min_y)); - F64 dequant_max_y = header.get_y(header.get_Y(header.max_y)); - F64 dequant_min_z = header.get_z(header.get_Z(header.min_z)); - F64 dequant_max_z = header.get_z(header.get_Z(header.max_z)); + F64 dequant_min_x = header.get_x((I32)(header.get_X(header.min_x))); + F64 dequant_max_x = header.get_x((I32)(header.get_X(header.max_x))); + F64 dequant_min_y = header.get_y((I32)(header.get_Y(header.min_y))); + F64 dequant_max_y = header.get_y((I32)(header.get_Y(header.max_y))); + F64 dequant_min_z = header.get_z((I32)(header.get_Z(header.min_z))); + F64 dequant_max_z = header.get_z((I32)(header.get_Z(header.max_z))); // make sure there is not sign flip if ((header.min_x > 0) != (dequant_min_x > 0)) { - REprintf( "WARNING: quantization sign flip for min_x from %g to %g.\n", header.min_x, dequant_min_x); - REprintf( " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for min_x from %g to %g.\n", header.min_x, dequant_min_x); + fprintf(stderr, " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); } else { @@ -1467,8 +1527,8 @@ void LASreaderDTM::populate_bounding_box() } if ((header.max_x > 0) != (dequant_max_x > 0)) { - REprintf( "WARNING: quantization sign flip for max_x from %g to %g.\n", header.max_x, dequant_max_x); - REprintf( " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for max_x from %g to %g.\n", header.max_x, dequant_max_x); + fprintf(stderr, " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); } else { @@ -1476,8 +1536,8 @@ void LASreaderDTM::populate_bounding_box() } if ((header.min_y > 0) != (dequant_min_y > 0)) { - REprintf( "WARNING: quantization sign flip for min_y from %g to %g.\n", header.min_y, dequant_min_y); - REprintf( " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for min_y from %g to %g.\n", header.min_y, dequant_min_y); + fprintf(stderr, " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); } else { @@ -1485,8 +1545,8 @@ void LASreaderDTM::populate_bounding_box() } if ((header.max_y > 0) != (dequant_max_y > 0)) { - REprintf( "WARNING: quantization sign flip for max_y from %g to %g.\n", header.max_y, dequant_max_y); - REprintf( " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for max_y from %g to %g.\n", header.max_y, dequant_max_y); + fprintf(stderr, " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); } else { @@ -1494,8 +1554,8 @@ void LASreaderDTM::populate_bounding_box() } if ((header.min_z > 0) != (dequant_min_z > 0)) { - REprintf( "WARNING: quantization sign flip for min_z from %g to %g.\n", header.min_z, dequant_min_z); - REprintf( " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for min_z from %g to %g.\n", header.min_z, dequant_min_z); + fprintf(stderr, " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); } else { @@ -1503,8 +1563,8 @@ void LASreaderDTM::populate_bounding_box() } if ((header.max_z > 0) != (dequant_max_z > 0)) { - REprintf( "WARNING: quantization sign flip for max_z from %g to %g.\n", header.max_z, dequant_max_z); - REprintf( " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for max_z from %g to %g.\n", header.max_z, dequant_max_z); + fprintf(stderr, " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); } else { diff --git a/inst/include/lasreader_dtm.hpp b/src/LASlib/lasreader_dtm.hpp similarity index 88% rename from inst/include/lasreader_dtm.hpp rename to src/LASlib/lasreader_dtm.hpp index 8b5df3a..b6a4001 100644 --- a/inst/include/lasreader_dtm.hpp +++ b/src/LASlib/lasreader_dtm.hpp @@ -13,7 +13,7 @@ COPYRIGHT: - (c) 2007-2013, martin isenburg, rapidlasso - fast tools to catch reality + (c) 2007-2019, martin isenburg, rapidlasso - fast tools to catch reality This is free software; you can redistribute and/or modify it under the terms of the GNU Lesser General Licence as published by the Free Software @@ -24,6 +24,8 @@ CHANGE HISTORY: + 31 August 2019 -- add RasterLAZ during code sprint after FOSS4G 2019 in Bucharest + 10 May 2019 -- checking for overflows in X, Y, Z 32 bit integers of fixed-point LAS 10 October 2013 -- created after returning from INTERGEO 2013 in Essen =============================================================================== @@ -66,6 +68,9 @@ class LASreaderDTM : public LASreader F32 xdim, ydim; F32 nodata; I16 data_type; // 2 = F32, 1 = I32, 0 = I16, 3 = F64 + I64 overflow_I32_x; + I64 overflow_I32_y; + I64 overflow_I32_z; void clean(); void populate_scale_and_offset(); diff --git a/src/LASlib/lasreader_las.cpp b/src/LASlib/lasreader_las.cpp index ada932e..be76a41 100644 --- a/src/LASlib/lasreader_las.cpp +++ b/src/LASlib/lasreader_las.cpp @@ -48,20 +48,44 @@ BOOL LASreaderLAS::open(const char* file_name, I32 io_buffer_size, BOOL peek_onl { if (file_name == 0) { - REprintf("ERROR: file name pointer is zero\n"); + fprintf(stderr,"ERROR: file name pointer is zero\n"); return FALSE; } +#ifdef _MSC_VER file = fopen(file_name, "rb"); if (file == 0) { - REprintf( "ERROR: cannot open file '%s'\n", file_name); + wchar_t* utf16_file_name = UTF8toUTF16(file_name); + file = _wfopen(utf16_file_name, L"rb"); + if (file == 0) + { + fprintf(stderr, "ERROR: cannot open file '%ws' for read\n", utf16_file_name); + } + delete [] utf16_file_name; + } +#else + file = fopen(file_name, "rb"); +#endif + + if (file == 0) + { + fprintf(stderr, "ERROR: cannot open file '%s' for read\n", file_name); return FALSE; } + // save file name for better ERROR message + + if (this->file_name) + { + free(this->file_name); + this->file_name = 0; + } + this->file_name = LASCopyString(file_name); + if (setvbuf(file, NULL, _IOFBF, io_buffer_size) != 0) { - REprintf( "WARNING: setvbuf() failed with buffer size %d\n", io_buffer_size); + fprintf(stderr, "WARNING: setvbuf() failed with buffer size %d\n", io_buffer_size); } // create input @@ -78,7 +102,7 @@ BOOL LASreaderLAS::open(FILE* file, BOOL peek_only, U32 decompress_selective) { if (file == 0) { - REprintf("ERROR: file pointer is zero\n"); + fprintf(stderr,"ERROR: file pointer is zero\n"); return FALSE; } @@ -87,7 +111,7 @@ BOOL LASreaderLAS::open(FILE* file, BOOL peek_only, U32 decompress_selective) { if(_setmode( _fileno( stdin ), _O_BINARY ) == -1 ) { - REprintf( "ERROR: cannot set stdin to binary (untranslated) mode\n"); + fprintf(stderr, "ERROR: cannot set stdin to binary (untranslated) mode\n"); return FALSE; } } @@ -121,7 +145,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel if (stream == 0) { - REprintf("ERROR: ByteStreamIn* pointer is zero\n"); + fprintf(stderr,"ERROR: ByteStreamIn* pointer is zero\n"); return FALSE; } @@ -135,165 +159,165 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel try { stream->getBytes((U8*)header.file_signature, 4); } catch(...) { - REprintf("ERROR: reading header.file_signature\n"); + fprintf(stderr,"ERROR: reading header.file_signature\n"); return FALSE; } try { stream->get16bitsLE((U8*)&(header.file_source_ID)); } catch(...) { - REprintf("ERROR: reading header.file_source_ID\n"); + fprintf(stderr,"ERROR: reading header.file_source_ID\n"); return FALSE; } try { stream->get16bitsLE((U8*)&(header.global_encoding)); } catch(...) { - REprintf("ERROR: reading header.global_encoding\n"); + fprintf(stderr,"ERROR: reading header.global_encoding\n"); return FALSE; } try { stream->get32bitsLE((U8*)&(header.project_ID_GUID_data_1)); } catch(...) { - REprintf("ERROR: reading header.project_ID_GUID_data_1\n"); + fprintf(stderr,"ERROR: reading header.project_ID_GUID_data_1\n"); return FALSE; } try { stream->get16bitsLE((U8*)&(header.project_ID_GUID_data_2)); } catch(...) { - REprintf("ERROR: reading header.project_ID_GUID_data_2\n"); + fprintf(stderr,"ERROR: reading header.project_ID_GUID_data_2\n"); return FALSE; } try { stream->get16bitsLE((U8*)&(header.project_ID_GUID_data_3)); } catch(...) { - REprintf("ERROR: reading header.project_ID_GUID_data_3\n"); + fprintf(stderr,"ERROR: reading header.project_ID_GUID_data_3\n"); return FALSE; } try { stream->getBytes((U8*)header.project_ID_GUID_data_4, 8); } catch(...) { - REprintf("ERROR: reading header.project_ID_GUID_data_4\n"); + fprintf(stderr,"ERROR: reading header.project_ID_GUID_data_4\n"); return FALSE; } try { stream->getBytes((U8*)&(header.version_major), 1); } catch(...) { - REprintf("ERROR: reading header.version_major\n"); + fprintf(stderr,"ERROR: reading header.version_major\n"); return FALSE; } try { stream->getBytes((U8*)&(header.version_minor), 1); } catch(...) { - REprintf("ERROR: reading header.version_minor\n"); + fprintf(stderr,"ERROR: reading header.version_minor\n"); return FALSE; } try { stream->getBytes((U8*)header.system_identifier, 32); } catch(...) { - REprintf("ERROR: reading header.system_identifier\n"); + fprintf(stderr,"ERROR: reading header.system_identifier\n"); return FALSE; } try { stream->getBytes((U8*)header.generating_software, 32); } catch(...) { - REprintf("ERROR: reading header.generating_software\n"); + fprintf(stderr,"ERROR: reading header.generating_software\n"); return FALSE; } try { stream->get16bitsLE((U8*)&(header.file_creation_day)); } catch(...) { - REprintf("ERROR: reading header.file_creation_day\n"); + fprintf(stderr,"ERROR: reading header.file_creation_day\n"); return FALSE; } try { stream->get16bitsLE((U8*)&(header.file_creation_year)); } catch(...) { - REprintf("ERROR: reading header.file_creation_year\n"); + fprintf(stderr,"ERROR: reading header.file_creation_year\n"); return FALSE; } try { stream->get16bitsLE((U8*)&(header.header_size)); } catch(...) { - REprintf("ERROR: reading header.header_size\n"); + fprintf(stderr,"ERROR: reading header.header_size\n"); return FALSE; } try { stream->get32bitsLE((U8*)&(header.offset_to_point_data)); } catch(...) { - REprintf("ERROR: reading header.offset_to_point_data\n"); + fprintf(stderr,"ERROR: reading header.offset_to_point_data\n"); return FALSE; } try { stream->get32bitsLE((U8*)&(header.number_of_variable_length_records)); } catch(...) { - REprintf("ERROR: reading header.number_of_variable_length_records\n"); + fprintf(stderr,"ERROR: reading header.number_of_variable_length_records\n"); return FALSE; } try { stream->getBytes((U8*)&(header.point_data_format), 1); } catch(...) { - REprintf("ERROR: reading header.point_data_format\n"); + fprintf(stderr,"ERROR: reading header.point_data_format\n"); return FALSE; } try { stream->get16bitsLE((U8*)&(header.point_data_record_length)); } catch(...) { - REprintf("ERROR: reading header.point_data_record_length\n"); + fprintf(stderr,"ERROR: reading header.point_data_record_length\n"); return FALSE; } try { stream->get32bitsLE((U8*)&(header.number_of_point_records)); } catch(...) { - REprintf("ERROR: reading header.number_of_point_records\n"); + fprintf(stderr,"ERROR: reading header.number_of_point_records\n"); return FALSE; } for (i = 0; i < 5; i++) { try { stream->get32bitsLE((U8*)&(header.number_of_points_by_return[i])); } catch(...) { - REprintf("ERROR: reading header.number_of_points_by_return %d\n", i); + fprintf(stderr,"ERROR: reading header.number_of_points_by_return %d\n", i); return FALSE; } } try { stream->get64bitsLE((U8*)&(header.x_scale_factor)); } catch(...) { - REprintf("ERROR: reading header.x_scale_factor\n"); + fprintf(stderr,"ERROR: reading header.x_scale_factor\n"); return FALSE; } try { stream->get64bitsLE((U8*)&(header.y_scale_factor)); } catch(...) { - REprintf("ERROR: reading header.y_scale_factor\n"); + fprintf(stderr,"ERROR: reading header.y_scale_factor\n"); return FALSE; } try { stream->get64bitsLE((U8*)&(header.z_scale_factor)); } catch(...) { - REprintf("ERROR: reading header.z_scale_factor\n"); + fprintf(stderr,"ERROR: reading header.z_scale_factor\n"); return FALSE; } try { stream->get64bitsLE((U8*)&(header.x_offset)); } catch(...) { - REprintf("ERROR: reading header.x_offset\n"); + fprintf(stderr,"ERROR: reading header.x_offset\n"); return FALSE; } try { stream->get64bitsLE((U8*)&(header.y_offset)); } catch(...) { - REprintf("ERROR: reading header.y_offset\n"); + fprintf(stderr,"ERROR: reading header.y_offset\n"); return FALSE; } try { stream->get64bitsLE((U8*)&(header.z_offset)); } catch(...) { - REprintf("ERROR: reading header.z_offset\n"); + fprintf(stderr,"ERROR: reading header.z_offset\n"); return FALSE; } try { stream->get64bitsLE((U8*)&(header.max_x)); } catch(...) { - REprintf("ERROR: reading header.max_x\n"); + fprintf(stderr,"ERROR: reading header.max_x\n"); return FALSE; } try { stream->get64bitsLE((U8*)&(header.min_x)); } catch(...) { - REprintf("ERROR: reading header.min_x\n"); + fprintf(stderr,"ERROR: reading header.min_x\n"); return FALSE; } try { stream->get64bitsLE((U8*)&(header.max_y)); } catch(...) { - REprintf("ERROR: reading header.max_y\n"); + fprintf(stderr,"ERROR: reading header.max_y\n"); return FALSE; } try { stream->get64bitsLE((U8*)&(header.min_y)); } catch(...) { - REprintf("ERROR: reading header.min_y\n"); + fprintf(stderr,"ERROR: reading header.min_y\n"); return FALSE; } try { stream->get64bitsLE((U8*)&(header.max_z)); } catch(...) { - REprintf("ERROR: reading header.max_z\n"); + fprintf(stderr,"ERROR: reading header.max_z\n"); return FALSE; } try { stream->get64bitsLE((U8*)&(header.min_z)); } catch(...) { - REprintf("ERROR: reading header.min_z\n"); + fprintf(stderr,"ERROR: reading header.min_z\n"); return FALSE; } @@ -308,14 +332,14 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (header.header_size < 235) { - REprintf("WARNING: for LAS 1.%d header_size should at least be 235 but it is only %d\n", header.version_minor, header.header_size); + fprintf(stderr,"WARNING: for LAS 1.%d header_size should at least be 235 but it is only %d\n", header.version_minor, header.header_size); header.user_data_in_header_size = header.header_size - 227; } else { try { stream->get64bitsLE((U8*)&(header.start_of_waveform_data_packet_record)); } catch(...) { - REprintf("ERROR: reading header.start_of_waveform_data_packet_record\n"); + fprintf(stderr,"ERROR: reading header.start_of_waveform_data_packet_record\n"); return FALSE; } header.user_data_in_header_size = header.header_size - 235; @@ -331,31 +355,31 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (header.header_size < 375) { - REprintf("ERROR: for LAS 1.%d header_size should at least be 375 but it is only %d\n", header.version_minor, header.header_size); + fprintf(stderr,"ERROR: for LAS 1.%d header_size should at least be 375 but it is only %d\n", header.version_minor, header.header_size); return FALSE; } else { try { stream->get64bitsLE((U8*)&(header.start_of_first_extended_variable_length_record)); } catch(...) { - REprintf("ERROR: reading header.start_of_first_extended_variable_length_record\n"); + fprintf(stderr,"ERROR: reading header.start_of_first_extended_variable_length_record\n"); return FALSE; } try { stream->get32bitsLE((U8*)&(header.number_of_extended_variable_length_records)); } catch(...) { - REprintf("ERROR: reading header.number_of_extended_variable_length_records\n"); + fprintf(stderr,"ERROR: reading header.number_of_extended_variable_length_records\n"); return FALSE; } try { stream->get64bitsLE((U8*)&(header.extended_number_of_point_records)); } catch(...) { - REprintf("ERROR: reading header.extended_number_of_point_records\n"); + fprintf(stderr,"ERROR: reading header.extended_number_of_point_records\n"); return FALSE; } for (i = 0; i < 15; i++) { try { stream->get64bitsLE((U8*)&(header.extended_number_of_points_by_return[i])); } catch(...) { - REprintf("ERROR: reading header.extended_number_of_points_by_return[%d]\n", i); + fprintf(stderr,"ERROR: reading header.extended_number_of_points_by_return[%d]\n", i); return FALSE; } } @@ -370,7 +394,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel try { stream->getBytes((U8*)header.user_data_in_header, header.user_data_in_header_size); } catch(...) { - REprintf("ERROR: reading %d bytes of data into header.user_data_in_header\n", header.user_data_in_header_size); + fprintf(stderr,"ERROR: reading %d bytes of data into header.user_data_in_header\n", header.user_data_in_header_size); return FALSE; } } @@ -399,7 +423,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel if (((int)header.offset_to_point_data - vlrs_size - header.header_size) < 54) { - REprintf("WARNING: only %d bytes until point block after reading %d of %d vlrs. skipping remaining vlrs ...\n", (int)header.offset_to_point_data - vlrs_size - header.header_size, i, header.number_of_variable_length_records); + fprintf(stderr,"WARNING: only %d bytes until point block after reading %d of %d vlrs. skipping remaining vlrs ...\n", (int)header.offset_to_point_data - vlrs_size - header.header_size, i, header.number_of_variable_length_records); header.number_of_variable_length_records = i; break; } @@ -408,28 +432,28 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel try { stream->get16bitsLE((U8*)&(header.vlrs[i].reserved)); } catch(...) { - REprintf("ERROR: reading header.vlrs[%d].reserved\n", i); + fprintf(stderr,"ERROR: reading header.vlrs[%d].reserved\n", i); return FALSE; } try { stream->getBytes((U8*)header.vlrs[i].user_id, 16); } catch(...) { - REprintf("ERROR: reading header.vlrs[%d].user_id\n", i); + fprintf(stderr,"ERROR: reading header.vlrs[%d].user_id\n", i); return FALSE; } try { stream->get16bitsLE((U8*)&(header.vlrs[i].record_id)); } catch(...) { - REprintf("ERROR: reading header.vlrs[%d].record_id\n", i); + fprintf(stderr,"ERROR: reading header.vlrs[%d].record_id\n", i); return FALSE; } try { stream->get16bitsLE((U8*)&(header.vlrs[i].record_length_after_header)); } catch(...) { - REprintf("ERROR: reading header.vlrs[%d].record_length_after_header\n", i); + fprintf(stderr,"ERROR: reading header.vlrs[%d].record_length_after_header\n", i); return FALSE; } try { stream->getBytes((U8*)header.vlrs[i].description, 32); } catch(...) { - REprintf("ERROR: reading header.vlrs[%d].description\n", i); + fprintf(stderr,"ERROR: reading header.vlrs[%d].description\n", i); return FALSE; } @@ -442,7 +466,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel /* if (header.vlrs[i].reserved != 0xAABB) { - REprintf("WARNING: wrong header.vlrs[%d].reserved: %d != 0xAABB\n", i, header.vlrs[i].reserved); + fprintf(stderr,"WARNING: wrong header.vlrs[%d].reserved: %d != 0xAABB\n", i, header.vlrs[i].reserved); } */ @@ -450,7 +474,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel if (((int)header.offset_to_point_data - vlrs_size - header.header_size) < header.vlrs[i].record_length_after_header) { - REprintf("WARNING: only %d bytes until point block when trying to read %d bytes into header.vlrs[%d].data\n", (int)header.offset_to_point_data - vlrs_size - header.header_size, header.vlrs[i].record_length_after_header, i); + fprintf(stderr,"WARNING: only %d bytes until point block when trying to read %d bytes into header.vlrs[%d].data\n", (int)header.offset_to_point_data - vlrs_size - header.header_size, header.vlrs[i].record_length_after_header, i); header.vlrs[i].record_length_after_header = (int)header.offset_to_point_data - vlrs_size - header.header_size; } @@ -480,52 +504,52 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel try { stream->get16bitsLE((U8*)&(header.laszip->compressor)); } catch(...) { - REprintf("ERROR: reading compressor %d\n", (I32)header.laszip->compressor); + fprintf(stderr,"ERROR: reading compressor %d\n", (I32)header.laszip->compressor); return FALSE; } try { stream->get16bitsLE((U8*)&(header.laszip->coder)); } catch(...) { - REprintf("ERROR: reading coder %d\n", (I32)header.laszip->coder); + fprintf(stderr,"ERROR: reading coder %d\n", (I32)header.laszip->coder); return FALSE; } try { stream->getBytes((U8*)&(header.laszip->version_major), 1); } catch(...) { - REprintf("ERROR: reading version_major %d\n", header.laszip->version_major); + fprintf(stderr,"ERROR: reading version_major %d\n", header.laszip->version_major); return FALSE; } try { stream->getBytes((U8*)&(header.laszip->version_minor), 1); } catch(...) { - REprintf("ERROR: reading version_minor %d\n", header.laszip->version_minor); + fprintf(stderr,"ERROR: reading version_minor %d\n", header.laszip->version_minor); return FALSE; } try { stream->get16bitsLE((U8*)&(header.laszip->version_revision)); } catch(...) { - REprintf("ERROR: reading version_revision %d\n", header.laszip->version_revision); + fprintf(stderr,"ERROR: reading version_revision %d\n", header.laszip->version_revision); return FALSE; } try { stream->get32bitsLE((U8*)&(header.laszip->options)); } catch(...) { - REprintf("ERROR: reading options %d\n", (I32)header.laszip->options); + fprintf(stderr,"ERROR: reading options %d\n", (I32)header.laszip->options); return FALSE; } try { stream->get32bitsLE((U8*)&(header.laszip->chunk_size)); } catch(...) { - REprintf("ERROR: reading chunk_size %d\n", header.laszip->chunk_size); + fprintf(stderr,"ERROR: reading chunk_size %d\n", header.laszip->chunk_size); return FALSE; } try { stream->get64bitsLE((U8*)&(header.laszip->number_of_special_evlrs)); } catch(...) { - REprintf("ERROR: reading number_of_special_evlrs %d\n", (I32)header.laszip->number_of_special_evlrs); + fprintf(stderr,"ERROR: reading number_of_special_evlrs %d\n", (I32)header.laszip->number_of_special_evlrs); return FALSE; } try { stream->get64bitsLE((U8*)&(header.laszip->offset_to_special_evlrs)); } catch(...) { - REprintf("ERROR: reading offset_to_special_evlrs %d\n", (I32)header.laszip->offset_to_special_evlrs); + fprintf(stderr,"ERROR: reading offset_to_special_evlrs %d\n", (I32)header.laszip->offset_to_special_evlrs); return FALSE; } try { stream->get16bitsLE((U8*)&(header.laszip->num_items)); } catch(...) { - REprintf("ERROR: reading num_items %d\n", header.laszip->num_items); + fprintf(stderr,"ERROR: reading num_items %d\n", header.laszip->num_items); return FALSE; } header.laszip->items = new LASitem[header.laszip->num_items]; @@ -534,17 +558,17 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel U16 type, size, version; try { stream->get16bitsLE((U8*)&type); } catch(...) { - REprintf("ERROR: reading type %d of item %d\n", type, j); + fprintf(stderr,"ERROR: reading type %d of item %d\n", type, j); return FALSE; } try { stream->get16bitsLE((U8*)&size); } catch(...) { - REprintf("ERROR: reading size %d of item %d\n", size, j); + fprintf(stderr,"ERROR: reading size %d of item %d\n", size, j); return FALSE; } try { stream->get16bitsLE((U8*)&version); } catch(...) { - REprintf("ERROR: reading version %d of item %d\n", version, j); + fprintf(stderr,"ERROR: reading version %d of item %d\n", version, j); return FALSE; } header.laszip->items[j].type = (LASitem::Type)type; @@ -570,43 +594,43 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { try { stream->get32bitsLE((U8*)&(header.vlr_lastiling->level)); } catch(...) { - REprintf("ERROR: reading vlr_lastiling->level %u\n", header.vlr_lastiling->level); + fprintf(stderr,"ERROR: reading vlr_lastiling->level %u\n", header.vlr_lastiling->level); return FALSE; } try { stream->get32bitsLE((U8*)&(header.vlr_lastiling->level_index)); } catch(...) { - REprintf("ERROR: reading vlr_lastiling->level_index %u\n", header.vlr_lastiling->level_index); + fprintf(stderr,"ERROR: reading vlr_lastiling->level_index %u\n", header.vlr_lastiling->level_index); return FALSE; } try { stream->get32bitsLE(((U8*)header.vlr_lastiling)+8); } catch(...) { - REprintf("ERROR: reading vlr_lastiling->implicit_levels %u\n", header.vlr_lastiling->implicit_levels); + fprintf(stderr,"ERROR: reading vlr_lastiling->implicit_levels %u\n", header.vlr_lastiling->implicit_levels); return FALSE; } try { stream->get32bitsLE((U8*)&(header.vlr_lastiling->min_x)); } catch(...) { - REprintf("ERROR: reading vlr_lastiling->min_x %g\n", header.vlr_lastiling->min_x); + fprintf(stderr,"ERROR: reading vlr_lastiling->min_x %g\n", header.vlr_lastiling->min_x); return FALSE; } try { stream->get32bitsLE((U8*)&(header.vlr_lastiling->max_x)); } catch(...) { - REprintf("ERROR: reading vlr_lastiling->max_x %g\n", header.vlr_lastiling->max_x); + fprintf(stderr,"ERROR: reading vlr_lastiling->max_x %g\n", header.vlr_lastiling->max_x); return FALSE; } try { stream->get32bitsLE((U8*)&(header.vlr_lastiling->min_y)); } catch(...) { - REprintf("ERROR: reading vlr_lastiling->min_y %g\n", header.vlr_lastiling->min_y); + fprintf(stderr,"ERROR: reading vlr_lastiling->min_y %g\n", header.vlr_lastiling->min_y); return FALSE; } try { stream->get32bitsLE((U8*)&(header.vlr_lastiling->max_y)); } catch(...) { - REprintf("ERROR: reading vlr_lastiling->max_y %g\n", header.vlr_lastiling->max_y); + fprintf(stderr,"ERROR: reading vlr_lastiling->max_y %g\n", header.vlr_lastiling->max_y); return FALSE; } } else { - REprintf("ERROR: record_length_after_header of VLR %s (%d) is %d instead of 28\n", header.vlrs[i].user_id, header.vlrs[i].record_id, header.vlrs[i].record_length_after_header); + fprintf(stderr,"ERROR: record_length_after_header of VLR %s (%d) is %d instead of 28\n", header.vlrs[i].user_id, header.vlrs[i].record_id, header.vlrs[i].record_length_after_header); return FALSE; } } @@ -621,51 +645,51 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { try { stream->get64bitsLE((U8*)&(header.vlr_lasoriginal->number_of_point_records)); } catch(...) { - REprintf("ERROR: reading vlr_lasoriginal->number_of_point_records %u\n", (U32)header.vlr_lasoriginal->number_of_point_records); + fprintf(stderr,"ERROR: reading vlr_lasoriginal->number_of_point_records %u\n", (U32)header.vlr_lasoriginal->number_of_point_records); return FALSE; } for (j = 0; j < 15; j++) { try { stream->get64bitsLE((U8*)&(header.vlr_lasoriginal->number_of_points_by_return[j])); } catch(...) { - REprintf("ERROR: reading vlr_lasoriginal->number_of_points_by_return[%d] %u\n", j, (U32)header.vlr_lasoriginal->number_of_points_by_return[j]); + fprintf(stderr,"ERROR: reading vlr_lasoriginal->number_of_points_by_return[%d] %u\n", j, (U32)header.vlr_lasoriginal->number_of_points_by_return[j]); return FALSE; } } try { stream->get64bitsLE((U8*)&(header.vlr_lasoriginal->min_x)); } catch(...) { - REprintf("ERROR: reading vlr_lasoriginal->min_x %g\n", header.vlr_lasoriginal->min_x); + fprintf(stderr,"ERROR: reading vlr_lasoriginal->min_x %g\n", header.vlr_lasoriginal->min_x); return FALSE; } try { stream->get64bitsLE((U8*)&(header.vlr_lasoriginal->max_x)); } catch(...) { - REprintf("ERROR: reading vlr_lasoriginal->max_x %g\n", header.vlr_lasoriginal->max_x); + fprintf(stderr,"ERROR: reading vlr_lasoriginal->max_x %g\n", header.vlr_lasoriginal->max_x); return FALSE; } try { stream->get64bitsLE((U8*)&(header.vlr_lasoriginal->min_y)); } catch(...) { - REprintf("ERROR: reading vlr_lasoriginal->min_y %g\n", header.vlr_lasoriginal->min_y); + fprintf(stderr,"ERROR: reading vlr_lasoriginal->min_y %g\n", header.vlr_lasoriginal->min_y); return FALSE; } try { stream->get64bitsLE((U8*)&(header.vlr_lasoriginal->max_y)); } catch(...) { - REprintf("ERROR: reading vlr_lasoriginal->max_y %g\n", header.vlr_lasoriginal->max_y); + fprintf(stderr,"ERROR: reading vlr_lasoriginal->max_y %g\n", header.vlr_lasoriginal->max_y); return FALSE; } try { stream->get64bitsLE((U8*)&(header.vlr_lasoriginal->min_z)); } catch(...) { - REprintf("ERROR: reading vlr_lasoriginal->min_z %g\n", header.vlr_lasoriginal->min_z); + fprintf(stderr,"ERROR: reading vlr_lasoriginal->min_z %g\n", header.vlr_lasoriginal->min_z); return FALSE; } try { stream->get64bitsLE((U8*)&(header.vlr_lasoriginal->max_z)); } catch(...) { - REprintf("ERROR: reading vlr_lasoriginal->max_z %g\n", header.vlr_lasoriginal->max_z); + fprintf(stderr,"ERROR: reading vlr_lasoriginal->max_z %g\n", header.vlr_lasoriginal->max_z); return FALSE; } } else { - REprintf("ERROR: record_length_after_header of VLR %s (%d) is %d instead of 176\n", header.vlrs[i].user_id, header.vlrs[i].record_id, header.vlrs[i].record_length_after_header); + fprintf(stderr,"ERROR: record_length_after_header of VLR %s (%d) is %d instead of 176\n", header.vlrs[i].user_id, header.vlrs[i].record_id, header.vlrs[i].record_length_after_header); return FALSE; } } @@ -675,7 +699,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel try { stream->getBytes(header.vlrs[i].data, header.vlrs[i].record_length_after_header); } catch(...) { - REprintf("ERROR: reading %d bytes of data into header.vlrs[%d].data\n", header.vlrs[i].record_length_after_header, i); + fprintf(stderr,"ERROR: reading %d bytes of data into header.vlrs[%d].data\n", header.vlrs[i].record_length_after_header, i); return FALSE; } } @@ -699,7 +723,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (header.vlr_geo_keys) { - REprintf("WARNING: variable length records contain more than one GeoKeyDirectoryTag\n"); + fprintf(stderr,"WARNING: variable length records contain more than one GeoKeyDirectoryTag\n"); } header.vlr_geo_keys = (LASvlr_geo_keys*)header.vlrs[i].data; @@ -707,15 +731,15 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel if (header.vlr_geo_keys->key_directory_version != 1) { - REprintf("WARNING: wrong vlr_geo_keys->key_directory_version: %d != 1\n",header.vlr_geo_keys->key_directory_version); + fprintf(stderr,"WARNING: wrong vlr_geo_keys->key_directory_version: %d != 1\n",header.vlr_geo_keys->key_directory_version); } if (header.vlr_geo_keys->key_revision != 1) { - REprintf("WARNING: wrong vlr_geo_keys->key_revision: %d != 1\n",header.vlr_geo_keys->key_revision); + fprintf(stderr,"WARNING: wrong vlr_geo_keys->key_revision: %d != 1\n",header.vlr_geo_keys->key_revision); } if (header.vlr_geo_keys->minor_revision != 0) { - REprintf("WARNING: wrong vlr_geo_keys->minor_revision: %d != 0\n",header.vlr_geo_keys->minor_revision); + fprintf(stderr,"WARNING: wrong vlr_geo_keys->minor_revision: %d != 0\n",header.vlr_geo_keys->minor_revision); } header.vlr_geo_key_entries = (LASvlr_key_entry*)&header.vlr_geo_keys[1]; } @@ -723,7 +747,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (header.vlr_geo_double_params) { - REprintf("WARNING: variable length records contain more than one GeoDoubleParamsTag\n"); + fprintf(stderr,"WARNING: variable length records contain more than one GeoDoubleParamsTag\n"); } header.vlr_geo_double_params = (F64*)header.vlrs[i].data; } @@ -731,7 +755,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (header.vlr_geo_ascii_params) { - REprintf("WARNING: variable length records contain more than one GeoAsciiParamsTag\n"); + fprintf(stderr,"WARNING: variable length records contain more than one GeoAsciiParamsTag\n"); } header.vlr_geo_ascii_params = (CHAR*)header.vlrs[i].data; } @@ -739,7 +763,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (header.vlr_geo_ogc_wkt_math) { - REprintf("WARNING: variable length records contain more than one WKT OGC MATH TRANSFORM\n"); + fprintf(stderr,"WARNING: variable length records contain more than one WKT OGC MATH TRANSFORM\n"); } header.vlr_geo_ogc_wkt_math = (CHAR*)header.vlrs[i].data; } @@ -747,18 +771,18 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (header.vlr_geo_ogc_wkt) { - REprintf("WARNING: variable length records contain more than one WKT OGC COORDINATE SYSTEM\n"); + fprintf(stderr,"WARNING: variable length records contain more than one WKT OGC COORDINATE SYSTEM\n"); } header.vlr_geo_ogc_wkt = (CHAR*)header.vlrs[i].data; } else { - REprintf("WARNING: unknown LASF_Projection VLR with record_id %d.\n", header.vlrs[i].record_id); + fprintf(stderr,"WARNING: unknown LASF_Projection VLR with record_id %d.\n", header.vlrs[i].record_id); } } else { - REprintf("WARNING: no payload for LASF_Projection VLR with record_id %d.\n", header.vlrs[i].record_id); + fprintf(stderr,"WARNING: no payload for LASF_Projection VLR with record_id %d.\n", header.vlrs[i].record_id); } } else if (strcmp(header.vlrs[i].user_id, "LASF_Spec") == 0) @@ -769,7 +793,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (header.vlr_classification) { - REprintf("WARNING: variable length records contain more than one ClassificationLookup\n"); + fprintf(stderr,"WARNING: variable length records contain more than one ClassificationLookup\n"); } header.vlr_classification = (LASvlr_classification*)header.vlrs[i].data; } @@ -786,7 +810,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (header.attributes[j].data_type > 10) { - REprintf("WARNING: data type %d of attribute %d ('%s') is deprecated\n", header.attributes[j].data_type, j, header.attributes[j].name); + fprintf(stderr,"WARNING: data type %d of attribute %d ('%s') is deprecated\n", header.attributes[j].data_type, j, header.attributes[j].name); } } } @@ -801,28 +825,28 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel } if (header.vlr_wave_packet_descr[idx]) { - REprintf("WARNING: variable length records defines wave packet descr %d more than once\n", idx); + fprintf(stderr,"WARNING: variable length records defines wave packet descr %d more than once\n", idx); } if (header.vlrs[i].record_length_after_header != 26) { - REprintf("WARNING: variable length record payload for wave packet descr %d is %d instead of 26 bytes\n", idx, (I32)header.vlrs[i].record_length_after_header); + fprintf(stderr,"WARNING: variable length record payload for wave packet descr %d is %d instead of 26 bytes\n", idx, (I32)header.vlrs[i].record_length_after_header); } header.vlr_wave_packet_descr[idx] = (LASvlr_wave_packet_descr*)header.vlrs[i].data; if ((header.vlr_wave_packet_descr[idx]->getBitsPerSample() != 8) && (header.vlr_wave_packet_descr[idx]->getBitsPerSample() != 16)) { - REprintf("WARNING: bits per sample for wave packet descr %d is %d instead of 8 or 16\n", idx, (I32)header.vlr_wave_packet_descr[idx]->getBitsPerSample()); + fprintf(stderr,"WARNING: bits per sample for wave packet descr %d is %d instead of 8 or 16\n", idx, (I32)header.vlr_wave_packet_descr[idx]->getBitsPerSample()); } if (header.vlr_wave_packet_descr[idx]->getNumberOfSamples() == 0) { - REprintf("WARNING: number of samples for wave packet descr %d is zero\n", idx); + fprintf(stderr,"WARNING: number of samples for wave packet descr %d is zero\n", idx); } if (header.vlr_wave_packet_descr[idx]->getNumberOfSamples() > 8096) { - REprintf("WARNING: number of samples of %u for wave packet descr %d is with unusually large\n", header.vlr_wave_packet_descr[idx]->getNumberOfSamples(), idx); + fprintf(stderr,"WARNING: number of samples of %u for wave packet descr %d is with unusually large\n", header.vlr_wave_packet_descr[idx]->getNumberOfSamples(), idx); } if (header.vlr_wave_packet_descr[idx]->getTemporalSpacing() == 0) { - REprintf("WARNING: temporal spacing for wave packet descr %d is zero\n", idx); + fprintf(stderr,"WARNING: temporal spacing for wave packet descr %d is zero\n", idx); } /* // fix for RiPROCESS export error @@ -838,7 +862,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel } else { - REprintf("WARNING: no payload for LASF_Spec (not specification-conform).\n"); + fprintf(stderr,"WARNING: no payload for LASF_Spec (not specification-conform).\n"); } } else if ((strcmp(header.vlrs[i].user_id, "laszip encoded") == 0) || ((strcmp(header.vlrs[i].user_id, "LAStools") == 0) && (header.vlrs[i].record_id < 2000)) || (strcmp(header.vlrs[i].user_id, "lastools tile") == 0)) @@ -861,7 +885,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel try { stream->getBytes((U8*)header.user_data_after_header, header.user_data_after_header_size); } catch(...) { - REprintf("ERROR: reading %d bytes of data into header.user_data_after_header\n", header.user_data_after_header_size); + fprintf(stderr,"ERROR: reading %d bytes of data into header.user_data_after_header\n", header.user_data_after_header_size); return FALSE; } } @@ -873,7 +897,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (!stream->isSeekable()) { - REprintf("WARNING: LAS %d.%d file has %d EVLRs but stream is not seekable ...\n", header.version_major, header.version_minor, header.number_of_extended_variable_length_records); + fprintf(stderr,"WARNING: LAS %d.%d file has %d EVLRs but stream is not seekable ...\n", header.version_major, header.version_minor, header.number_of_extended_variable_length_records); } else { @@ -892,27 +916,27 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel try { stream->get16bitsLE((U8*)&(header.evlrs[i].reserved)); } catch(...) { - REprintf("ERROR: reading header.evlrs[%d].reserved\n", i); + fprintf(stderr,"ERROR: reading header.evlrs[%d].reserved\n", i); return FALSE; } try { stream->getBytes((U8*)header.evlrs[i].user_id, 16); } catch(...) { - REprintf("ERROR: reading header.evlrs[%d].user_id\n", i); + fprintf(stderr,"ERROR: reading header.evlrs[%d].user_id\n", i); return FALSE; } try { stream->get16bitsLE((U8*)&(header.evlrs[i].record_id)); } catch(...) { - REprintf("ERROR: reading header.evlrs[%d].record_id\n", i); + fprintf(stderr,"ERROR: reading header.evlrs[%d].record_id\n", i); return FALSE; } try { stream->get64bitsLE((U8*)&(header.evlrs[i].record_length_after_header)); } catch(...) { - REprintf("ERROR: reading header.evlrs[%d].record_length_after_header\n", i); + fprintf(stderr,"ERROR: reading header.evlrs[%d].record_length_after_header\n", i); return FALSE; } try { stream->getBytes((U8*)header.evlrs[i].description, 32); } catch(...) { - REprintf("ERROR: reading header.evlrs[%d].description\n", i); + fprintf(stderr,"ERROR: reading header.evlrs[%d].description\n", i); return FALSE; } @@ -925,7 +949,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel /* if (header.evlrs[i].reserved != 0) { - REprintf("WARNING: wrong header.evlrs[%d].reserved: %d != 0\n", i, header.evlrs[i].reserved); + fprintf(stderr,"WARNING: wrong header.evlrs[%d].reserved: %d != 0\n", i, header.evlrs[i].reserved); } */ @@ -955,52 +979,52 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel try { stream->get16bitsLE((U8*)&(header.laszip->compressor)); } catch(...) { - REprintf("ERROR: reading compressor %d\n", (I32)header.laszip->compressor); + fprintf(stderr,"ERROR: reading compressor %d\n", (I32)header.laszip->compressor); return FALSE; } try { stream->get16bitsLE((U8*)&(header.laszip->coder)); } catch(...) { - REprintf("ERROR: reading coder %d\n", (I32)header.laszip->coder); + fprintf(stderr,"ERROR: reading coder %d\n", (I32)header.laszip->coder); return FALSE; } try { stream->getBytes((U8*)&(header.laszip->version_major), 1); } catch(...) { - REprintf("ERROR: reading version_major %d\n", header.laszip->version_major); + fprintf(stderr,"ERROR: reading version_major %d\n", header.laszip->version_major); return FALSE; } try { stream->getBytes((U8*)&(header.laszip->version_minor), 1); } catch(...) { - REprintf("ERROR: reading version_minor %d\n", header.laszip->version_minor); + fprintf(stderr,"ERROR: reading version_minor %d\n", header.laszip->version_minor); return FALSE; } try { stream->get16bitsLE((U8*)&(header.laszip->version_revision)); } catch(...) { - REprintf("ERROR: reading version_revision %d\n", header.laszip->version_revision); + fprintf(stderr,"ERROR: reading version_revision %d\n", header.laszip->version_revision); return FALSE; } try { stream->get32bitsLE((U8*)&(header.laszip->options)); } catch(...) { - REprintf("ERROR: reading options %d\n", (I32)header.laszip->options); + fprintf(stderr,"ERROR: reading options %d\n", (I32)header.laszip->options); return FALSE; } try { stream->get32bitsLE((U8*)&(header.laszip->chunk_size)); } catch(...) { - REprintf("ERROR: reading chunk_size %d\n", header.laszip->chunk_size); + fprintf(stderr,"ERROR: reading chunk_size %d\n", header.laszip->chunk_size); return FALSE; } try { stream->get64bitsLE((U8*)&(header.laszip->number_of_special_evlrs)); } catch(...) { - REprintf("ERROR: reading number_of_special_evlrs %d\n", (I32)header.laszip->number_of_special_evlrs); + fprintf(stderr,"ERROR: reading number_of_special_evlrs %d\n", (I32)header.laszip->number_of_special_evlrs); return FALSE; } try { stream->get64bitsLE((U8*)&(header.laszip->offset_to_special_evlrs)); } catch(...) { - REprintf("ERROR: reading offset_to_special_evlrs %d\n", (I32)header.laszip->offset_to_special_evlrs); + fprintf(stderr,"ERROR: reading offset_to_special_evlrs %d\n", (I32)header.laszip->offset_to_special_evlrs); return FALSE; } try { stream->get16bitsLE((U8*)&(header.laszip->num_items)); } catch(...) { - REprintf("ERROR: reading num_items %d\n", header.laszip->num_items); + fprintf(stderr,"ERROR: reading num_items %d\n", header.laszip->num_items); return FALSE; } header.laszip->items = new LASitem[header.laszip->num_items]; @@ -1009,17 +1033,17 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel U16 type, size, version; try { stream->get16bitsLE((U8*)&type); } catch(...) { - REprintf("ERROR: reading type %d of item %d\n", type, j); + fprintf(stderr,"ERROR: reading type %d of item %d\n", type, j); return FALSE; } try { stream->get16bitsLE((U8*)&size); } catch(...) { - REprintf("ERROR: reading size %d of item %d\n", size, j); + fprintf(stderr,"ERROR: reading size %d of item %d\n", size, j); return FALSE; } try { stream->get16bitsLE((U8*)&version); } catch(...) { - REprintf("ERROR: reading version %d of item %d\n", version, j); + fprintf(stderr,"ERROR: reading version %d of item %d\n", version, j); return FALSE; } header.laszip->items[j].type = (LASitem::Type)type; @@ -1045,43 +1069,43 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { try { stream->get32bitsLE((U8*)&(header.vlr_lastiling->level)); } catch(...) { - REprintf("ERROR: reading vlr_lastiling->level %u\n", header.vlr_lastiling->level); + fprintf(stderr,"ERROR: reading vlr_lastiling->level %u\n", header.vlr_lastiling->level); return FALSE; } try { stream->get32bitsLE((U8*)&(header.vlr_lastiling->level_index)); } catch(...) { - REprintf("ERROR: reading vlr_lastiling->level_index %u\n", header.vlr_lastiling->level_index); + fprintf(stderr,"ERROR: reading vlr_lastiling->level_index %u\n", header.vlr_lastiling->level_index); return FALSE; } try { stream->get32bitsLE(((U8*)header.vlr_lastiling)+8); } catch(...) { - REprintf("ERROR: reading vlr_lastiling->implicit_levels %u\n", header.vlr_lastiling->implicit_levels); + fprintf(stderr,"ERROR: reading vlr_lastiling->implicit_levels %u\n", header.vlr_lastiling->implicit_levels); return FALSE; } try { stream->get32bitsLE((U8*)&(header.vlr_lastiling->min_x)); } catch(...) { - REprintf("ERROR: reading vlr_lastiling->min_x %g\n", header.vlr_lastiling->min_x); + fprintf(stderr,"ERROR: reading vlr_lastiling->min_x %g\n", header.vlr_lastiling->min_x); return FALSE; } try { stream->get32bitsLE((U8*)&(header.vlr_lastiling->max_x)); } catch(...) { - REprintf("ERROR: reading vlr_lastiling->max_x %g\n", header.vlr_lastiling->max_x); + fprintf(stderr,"ERROR: reading vlr_lastiling->max_x %g\n", header.vlr_lastiling->max_x); return FALSE; } try { stream->get32bitsLE((U8*)&(header.vlr_lastiling->min_y)); } catch(...) { - REprintf("ERROR: reading vlr_lastiling->min_y %g\n", header.vlr_lastiling->min_y); + fprintf(stderr,"ERROR: reading vlr_lastiling->min_y %g\n", header.vlr_lastiling->min_y); return FALSE; } try { stream->get32bitsLE((U8*)&(header.vlr_lastiling->max_y)); } catch(...) { - REprintf("ERROR: reading vlr_lastiling->max_y %g\n", header.vlr_lastiling->max_y); + fprintf(stderr,"ERROR: reading vlr_lastiling->max_y %g\n", header.vlr_lastiling->max_y); return FALSE; } } else { - REprintf("ERROR: record_length_after_header of EVLR %s (%d) is %u instead of 28\n", header.evlrs[i].user_id, header.evlrs[i].record_id, (U32)header.evlrs[i].record_length_after_header); + fprintf(stderr,"ERROR: record_length_after_header of EVLR %s (%d) is %u instead of 28\n", header.evlrs[i].user_id, header.evlrs[i].record_id, (U32)header.evlrs[i].record_length_after_header); return FALSE; } } @@ -1091,7 +1115,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel try { stream->getBytes(header.evlrs[i].data, (U32)header.evlrs[i].record_length_after_header); } catch(...) { - REprintf("ERROR: reading %d bytes of data into header.evlrs[%d].data\n", (I32)header.evlrs[i].record_length_after_header, i); + fprintf(stderr,"ERROR: reading %d bytes of data into header.evlrs[%d].data\n", (I32)header.evlrs[i].record_length_after_header, i); return FALSE; } } @@ -1113,7 +1137,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (header.vlr_geo_keys) { - REprintf("WARNING: extended variable length records contain more than one GeoKeyDirectoryTag\n"); + fprintf(stderr,"WARNING: extended variable length records contain more than one GeoKeyDirectoryTag\n"); } header.vlr_geo_keys = (LASvlr_geo_keys*)header.evlrs[i].data; @@ -1121,15 +1145,15 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel if (header.vlr_geo_keys->key_directory_version != 1) { - REprintf("WARNING: wrong evlr_geo_keys->key_directory_version: %d != 1\n",header.vlr_geo_keys->key_directory_version); + fprintf(stderr,"WARNING: wrong evlr_geo_keys->key_directory_version: %d != 1\n",header.vlr_geo_keys->key_directory_version); } if (header.vlr_geo_keys->key_revision != 1) { - REprintf("WARNING: wrong evlr_geo_keys->key_revision: %d != 1\n",header.vlr_geo_keys->key_revision); + fprintf(stderr,"WARNING: wrong evlr_geo_keys->key_revision: %d != 1\n",header.vlr_geo_keys->key_revision); } if (header.vlr_geo_keys->minor_revision != 0) { - REprintf("WARNING: wrong evlr_geo_keys->minor_revision: %d != 0\n",header.vlr_geo_keys->minor_revision); + fprintf(stderr,"WARNING: wrong evlr_geo_keys->minor_revision: %d != 0\n",header.vlr_geo_keys->minor_revision); } header.vlr_geo_key_entries = (LASvlr_key_entry*)&header.vlr_geo_keys[1]; } @@ -1137,7 +1161,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (header.vlr_geo_double_params) { - REprintf("WARNING: extended variable length records contain more than one GeoF64ParamsTag\n"); + fprintf(stderr,"WARNING: extended variable length records contain more than one GeoF64ParamsTag\n"); } header.vlr_geo_double_params = (F64*)header.evlrs[i].data; } @@ -1145,7 +1169,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (header.vlr_geo_ascii_params) { - REprintf("WARNING: extended variable length records contain more than one GeoAsciiParamsTag\n"); + fprintf(stderr,"WARNING: extended variable length records contain more than one GeoAsciiParamsTag\n"); } header.vlr_geo_ascii_params = (CHAR*)header.evlrs[i].data; } @@ -1153,7 +1177,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (header.vlr_geo_ogc_wkt_math) { - REprintf("WARNING: extended variable length records contain more than one WKT OGC MATH TRANSFORM\n"); + fprintf(stderr,"WARNING: extended variable length records contain more than one WKT OGC MATH TRANSFORM\n"); } header.vlr_geo_ogc_wkt_math = (CHAR*)header.evlrs[i].data; } @@ -1161,13 +1185,13 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (header.vlr_geo_ogc_wkt) { - REprintf("WARNING: extended variable length records contain more than one WKT OGC COORDINATE SYSTEM\n"); + fprintf(stderr,"WARNING: extended variable length records contain more than one WKT OGC COORDINATE SYSTEM\n"); } header.vlr_geo_ogc_wkt = (CHAR*)header.evlrs[i].data; } else { - REprintf("WARNING: unknown LASF_Projection EVLR with record_id %d.\n", header.evlrs[i].record_id); + fprintf(stderr,"WARNING: unknown LASF_Projection EVLR with record_id %d.\n", header.evlrs[i].record_id); } } else if (strcmp(header.evlrs[i].user_id, "LASF_Spec") == 0) @@ -1176,7 +1200,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (header.vlr_classification) { - REprintf("WARNING: extended variable length records contain more than one ClassificationLookup\n"); + fprintf(stderr,"WARNING: extended variable length records contain more than one ClassificationLookup\n"); } header.vlr_classification = (LASvlr_classification*)header.evlrs[i].data; } @@ -1201,7 +1225,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel } if (header.vlr_wave_packet_descr[idx]) { - REprintf("WARNING: extended variable length records defines wave packet descr %d more than once\n", idx); + fprintf(stderr,"WARNING: extended variable length records defines wave packet descr %d more than once\n", idx); } header.vlr_wave_packet_descr[idx] = (LASvlr_wave_packet_descr*)header.evlrs[i].data; } @@ -1225,9 +1249,9 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (!header.laszip->check(header.point_data_record_length)) { - REprintf("ERROR: %s\n", header.laszip->get_error()); - REprintf(" please upgrade to the latest release of LAStools (with LASzip)\n"); - REprintf(" or contact 'martin.isenburg@rapidlasso.com' for assistance.\n"); + fprintf(stderr,"ERROR: %s\n", header.laszip->get_error()); + fprintf(stderr," please upgrade to the latest release of LAStools (with LASzip)\n"); + fprintf(stderr," or contact 'martin.isenburg@rapidlasso.com' for assistance.\n"); return FALSE; } } @@ -1238,8 +1262,8 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (!header.laszip) { - REprintf("ERROR: this file was compressed with an experimental version of laszip\n"); - REprintf("ERROR: please contact 'martin.isenburg@rapidlasso.com' for assistance.\n"); + fprintf(stderr,"ERROR: this file was compressed with an experimental version of laszip\n"); + fprintf(stderr,"ERROR: please contact 'martin.isenburg@rapidlasso.com' for assistance.\n"); return FALSE; } header.point_data_format &= 127; @@ -1303,7 +1327,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel } catch(...) { - REprintf("ERROR: trying to read %u internal EVLRs. ignoring ...\n", (U32)header.laszip->number_of_special_evlrs); + fprintf(stderr,"ERROR: trying to read %u internal EVLRs. ignoring ...\n", (U32)header.laszip->number_of_special_evlrs); } stream->seek(here); } @@ -1346,13 +1370,17 @@ BOOL LASreaderLAS::read_point_default() { if (reader->read(point.point) == FALSE) { + if (reader->warning()) + { + fprintf(stderr,"WARNING: '%s' for '%s'\n", reader->warning(), file_name); + } if (reader->error()) { - REprintf("ERROR: '%s' after %u of %u points\n", reader->error(), (U32)p_count, (U32)npoints); + fprintf(stderr,"ERROR: '%s' after %u of %u points for '%s'\n", reader->error(), (U32)p_count, (U32)npoints, file_name); } else { - REprintf("WARNING: end-of-file after %u of %u points\n", (U32)p_count, (U32)npoints); + fprintf(stderr,"WARNING: end-of-file after %u of %u points for '%s'\n", (U32)p_count, (U32)npoints, file_name); } return FALSE; } @@ -1388,12 +1416,12 @@ BOOL LASreaderLAS::read_point_default() { if (reader->check_end() == FALSE) { - REprintf("ERROR: '%s' when reaching end of encoding\n", reader->error()); + fprintf(stderr,"ERROR: '%s' when reaching end of encoding\n", reader->error()); p_count--; } if (reader->warning()) { - REprintf("WARNING: '%s'\n", reader->warning()); + fprintf(stderr,"WARNING: '%s'\n", reader->warning()); } checked_end = TRUE; } @@ -1429,12 +1457,18 @@ void LASreaderLAS::close(BOOL close_stream) fclose(file); file = 0; } + if (file_name) + { + free(file_name); + file_name = 0; + } } } LASreaderLAS::LASreaderLAS() { file = 0; + file_name = 0; stream = 0; delete_stream = TRUE; reader = 0; @@ -1513,14 +1547,14 @@ BOOL LASreaderLASrescale::open(ByteStreamIn* stream, BOOL peek_only, U32 decompr temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - REprintf("WARNING: rescaling from %g to %g causes LAS integer overflow for min_x\n", orig_x_scale_factor, header.x_scale_factor); + fprintf(stderr,"WARNING: rescaling from %g to %g causes LAS integer overflow for min_x\n", orig_x_scale_factor, header.x_scale_factor); } // make sure rescale does not cause integer overflow for max_x temp_f = (orig_x_scale_factor*quantizer.get_X(header.max_x))/header.x_scale_factor; temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - REprintf("WARNING: rescaling from %g to %g causes LAS integer overflow for max_x\n", orig_x_scale_factor, header.x_scale_factor); + fprintf(stderr,"WARNING: rescaling from %g to %g causes LAS integer overflow for max_x\n", orig_x_scale_factor, header.x_scale_factor); } } @@ -1531,14 +1565,14 @@ BOOL LASreaderLASrescale::open(ByteStreamIn* stream, BOOL peek_only, U32 decompr temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - REprintf("WARNING: rescaling from %g to %g causes LAS integer overflow for min_y\n", orig_y_scale_factor, header.y_scale_factor); + fprintf(stderr,"WARNING: rescaling from %g to %g causes LAS integer overflow for min_y\n", orig_y_scale_factor, header.y_scale_factor); } // make sure rescale does not cause integer overflow for max_y temp_f = (orig_y_scale_factor*quantizer.get_Y(header.max_y))/header.y_scale_factor; temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - REprintf("WARNING: rescaling from %g to %g causes LAS integer overflow for max_y\n", orig_y_scale_factor, header.y_scale_factor); + fprintf(stderr,"WARNING: rescaling from %g to %g causes LAS integer overflow for max_y\n", orig_y_scale_factor, header.y_scale_factor); } } @@ -1549,14 +1583,14 @@ BOOL LASreaderLASrescale::open(ByteStreamIn* stream, BOOL peek_only, U32 decompr temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - REprintf("WARNING: rescaling from %g to %g causes LAS integer overflow for min_z\n", orig_z_scale_factor, header.z_scale_factor); + fprintf(stderr,"WARNING: rescaling from %g to %g causes LAS integer overflow for min_z\n", orig_z_scale_factor, header.z_scale_factor); } // make sure rescale does not cause integer overflow for max_z temp_f = (orig_z_scale_factor*quantizer.get_Z(header.max_z))/header.z_scale_factor; temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - REprintf("WARNING: rescaling from %g to %g causes LAS integer overflow for max_z\n", orig_z_scale_factor, header.z_scale_factor); + fprintf(stderr,"WARNING: rescaling from %g to %g causes LAS integer overflow for max_z\n", orig_z_scale_factor, header.z_scale_factor); } } } @@ -1653,14 +1687,14 @@ BOOL LASreaderLASreoffset::open(ByteStreamIn* stream, BOOL peek_only, U32 decomp temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - REprintf("WARNING: reoffsetting from %g to %g causes LAS integer overflow for min_x\n", orig_x_offset, header.x_offset); + fprintf(stderr,"WARNING: reoffsetting from %g to %g causes LAS integer overflow for min_x\n", orig_x_offset, header.x_offset); } // make sure reoffset_x does not cause integer overflow for max_x temp_f = ((header.x_scale_factor*quantizer.get_X(header.max_x))+orig_x_offset-header.x_offset)/header.x_scale_factor; temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - REprintf("WARNING: reoffsetting from %g to %g causes LAS integer overflow for max_x\n", orig_x_offset, header.x_offset); + fprintf(stderr,"WARNING: reoffsetting from %g to %g causes LAS integer overflow for max_x\n", orig_x_offset, header.x_offset); } } @@ -1671,14 +1705,14 @@ BOOL LASreaderLASreoffset::open(ByteStreamIn* stream, BOOL peek_only, U32 decomp temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - REprintf("WARNING: reoffsetting from %g to %g causes LAS integer overflow for min_y\n", orig_y_offset, header.y_offset); + fprintf(stderr,"WARNING: reoffsetting from %g to %g causes LAS integer overflow for min_y\n", orig_y_offset, header.y_offset); } // make sure reoffset_y does not cause integer overflow for max_y temp_f = ((header.y_scale_factor*quantizer.get_Y(header.max_y))+orig_y_offset-header.y_offset)/header.y_scale_factor; temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - REprintf("WARNING: reoffsetting from %g to %g causes LAS integer overflow for max_y\n", orig_y_offset, header.y_offset); + fprintf(stderr,"WARNING: reoffsetting from %g to %g causes LAS integer overflow for max_y\n", orig_y_offset, header.y_offset); } } @@ -1689,14 +1723,14 @@ BOOL LASreaderLASreoffset::open(ByteStreamIn* stream, BOOL peek_only, U32 decomp temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - REprintf("WARNING: reoffsetting from %g to %g causes LAS integer overflow for min_z\n", orig_z_offset, header.z_offset); + fprintf(stderr,"WARNING: reoffsetting from %g to %g causes LAS integer overflow for min_z\n", orig_z_offset, header.z_offset); } // make sure rescale does not cause integer overflow for max_z temp_f = ((header.z_scale_factor*quantizer.get_Z(header.max_z))+orig_z_offset-header.z_offset)/header.z_scale_factor; temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - REprintf("WARNING: reoffsetting from %g to %g causes LAS integer overflow for max_z\n", orig_z_offset, header.z_offset); + fprintf(stderr,"WARNING: reoffsetting from %g to %g causes LAS integer overflow for max_z\n", orig_z_offset, header.z_offset); } } @@ -1809,7 +1843,7 @@ BOOL LASreaderLASrescalereoffset::open(ByteStreamIn* stream, BOOL peek_only, U32 temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - REprintf("WARNING: rescaling from %g to %g and reoffsetting from %g to %g causes LAS integer overflow for min_x\n", orig_x_scale_factor, header.x_scale_factor, orig_x_offset, header.x_offset); + fprintf(stderr,"WARNING: rescaling from %g to %g and reoffsetting from %g to %g causes LAS integer overflow for min_x\n", orig_x_scale_factor, header.x_scale_factor, orig_x_offset, header.x_offset); } // make sure rescale & reoffset do not cause integer overflow for max_x @@ -1824,7 +1858,7 @@ BOOL LASreaderLASrescalereoffset::open(ByteStreamIn* stream, BOOL peek_only, U32 temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - REprintf("WARNING: rescaling from %g to %g and reoffsetting from %g to %g causes LAS integer overflow for max_x\n", orig_x_scale_factor, header.x_scale_factor, orig_x_offset, header.x_offset); + fprintf(stderr,"WARNING: rescaling from %g to %g and reoffsetting from %g to %g causes LAS integer overflow for max_x\n", orig_x_scale_factor, header.x_scale_factor, orig_x_offset, header.x_offset); } } @@ -1842,7 +1876,7 @@ BOOL LASreaderLASrescalereoffset::open(ByteStreamIn* stream, BOOL peek_only, U32 temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - REprintf("WARNING: rescaling from %g to %g and reoffsetting from %g to %g causes LAS integer overflow for min_y\n", orig_y_scale_factor, header.y_scale_factor, orig_y_offset, header.y_offset); + fprintf(stderr,"WARNING: rescaling from %g to %g and reoffsetting from %g to %g causes LAS integer overflow for min_y\n", orig_y_scale_factor, header.y_scale_factor, orig_y_offset, header.y_offset); } // make sure rescale & reoffset do not cause integer overflow for max_y @@ -1857,7 +1891,7 @@ BOOL LASreaderLASrescalereoffset::open(ByteStreamIn* stream, BOOL peek_only, U32 temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - REprintf("WARNING: rescaling from %g to %g and reoffsetting from %g to %g causes LAS integer overflow for max_y\n", orig_y_scale_factor, header.y_scale_factor, orig_y_offset, header.y_offset); + fprintf(stderr,"WARNING: rescaling from %g to %g and reoffsetting from %g to %g causes LAS integer overflow for max_y\n", orig_y_scale_factor, header.y_scale_factor, orig_y_offset, header.y_offset); } } @@ -1875,7 +1909,7 @@ BOOL LASreaderLASrescalereoffset::open(ByteStreamIn* stream, BOOL peek_only, U32 temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - REprintf("WARNING: rescaling from %g to %g and reoffsetting from %g to %g causes LAS integer overflow for min_z\n", orig_z_scale_factor, header.z_scale_factor, orig_z_offset, header.z_offset); + fprintf(stderr,"WARNING: rescaling from %g to %g and reoffsetting from %g to %g causes LAS integer overflow for min_z\n", orig_z_scale_factor, header.z_scale_factor, orig_z_offset, header.z_offset); } // make sure rescale & reoffset do not cause integer overflow for max_z @@ -1890,7 +1924,7 @@ BOOL LASreaderLASrescalereoffset::open(ByteStreamIn* stream, BOOL peek_only, U32 temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - REprintf("WARNING: rescaling from %g to %g and reoffsetting from %g to %g causes LAS integer overflow for max_z\n", orig_z_scale_factor, header.z_scale_factor, orig_z_offset, header.z_offset); + fprintf(stderr,"WARNING: rescaling from %g to %g and reoffsetting from %g to %g causes LAS integer overflow for max_z\n", orig_z_scale_factor, header.z_scale_factor, orig_z_offset, header.z_offset); } } diff --git a/inst/include/lasreader_las.hpp b/src/LASlib/lasreader_las.hpp similarity index 99% rename from inst/include/lasreader_las.hpp rename to src/LASlib/lasreader_las.hpp index 6fa246f..c4fe8ed 100644 --- a/inst/include/lasreader_las.hpp +++ b/src/LASlib/lasreader_las.hpp @@ -82,6 +82,7 @@ class LASreaderLAS : public LASreader private: FILE* file; + CHAR* file_name; ByteStreamIn* stream; BOOL delete_stream; LASreadPoint* reader; diff --git a/src/LASlib/lasreader_ply.cpp b/src/LASlib/lasreader_ply.cpp index 76914e6..1576826 100644 --- a/src/LASlib/lasreader_ply.cpp +++ b/src/LASlib/lasreader_ply.cpp @@ -2,11 +2,11 @@ =============================================================================== FILE: lasreader_ply.cpp - + CONTENTS: - + see corresponding header file - + PROGRAMMERS: martin.isenburg@rapidlasso.com - http://rapidlasso.com @@ -21,11 +21,11 @@ This software is distributed WITHOUT ANY WARRANTY and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - + CHANGE HISTORY: - + see corresponding header file - + =============================================================================== */ #include "lasreader_ply.hpp" @@ -45,20 +45,20 @@ BOOL LASreaderPLY::open(const CHAR* file_name, U8 point_type, BOOL populate_head { if (file_name == 0) { - REprintf("ERROR: file name pointer is zero\n"); + fprintf(stderr,"ERROR: file name pointer is zero\n"); return FALSE; } FILE* file = fopen_compressed(file_name, "rb", &piped); if (file == 0) { - REprintf( "ERROR: cannot open file '%s'\n", file_name); + fprintf(stderr, "ERROR: cannot open file '%s'\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, 10*LAS_TOOLS_IO_IBUFFER_SIZE) != 0) { - REprintf( "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); + fprintf(stderr, "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); } return open(file, file_name, point_type, populate_header); @@ -66,11 +66,11 @@ BOOL LASreaderPLY::open(const CHAR* file_name, U8 point_type, BOOL populate_head BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL populate_header) { - int i; + int i,j; if (file == 0) { - REprintf("ERROR: file pointer is zero\n"); + fprintf(stderr,"ERROR: file pointer is zero\n"); return FALSE; } @@ -137,7 +137,7 @@ BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL p if (point_type) { - switch (point_type) + switch (point_type) { case 1: header.point_data_record_length = 28; @@ -232,7 +232,7 @@ BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL p for (i = 0; i < number_attributes; i++) { I32 type = (attributes_data_types[i]-1)%10; - try { + try { LASattribute attribute(type, attribute_names[i], attribute_descriptions[i]); if (attribute_scales[i] != 1.0 || attribute_offsets[i] != 0.0) { @@ -249,7 +249,7 @@ BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL p header.add_attribute(attribute); } catch(...) { - REprintf("ERROR: initializing attribute %s\n", attribute_descriptions[i]); + fprintf(stderr,"ERROR: initializing attribute %s\n", attribute_descriptions[i]); return FALSE; } } @@ -270,7 +270,7 @@ BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL p if (streamin) // binary { - // read the first point + // read the first point read_binary_point(); } else @@ -287,7 +287,7 @@ BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL p else { line[strlen(line)-1] = '\0'; - REprintf( "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_string); + fprintf(stderr, "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_string); } } @@ -295,7 +295,7 @@ BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL p if (!found) { - REprintf( "ERROR: could not parse any lines with '%s'\n", parse_string); + fprintf(stderr, "ERROR: could not parse any lines with '%s'\n", parse_string); fclose(file); file = 0; return FALSE; @@ -330,7 +330,7 @@ BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL p } } - // read the remaining points + // read the remaining points for (i = 1; i < npoints; i++) { @@ -354,7 +354,7 @@ BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL p else { line[strlen(line)-1] = '\0'; - REprintf( "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_string); + fprintf(stderr, "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_string); } } } @@ -383,10 +383,10 @@ BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL p // update the min and max of attributes in extra bytes if (number_attributes) { - for (i = 0; i < number_attributes; i++) + for (j = 0; j < number_attributes; j++) { - header.attributes[i].update_min(point.extra_bytes + header.attribute_starts[i]); - header.attributes[i].update_max(point.extra_bytes + header.attribute_starts[i]); + header.attributes[j].update_min(point.extra_bytes + header.attribute_starts[j]); + header.attributes[j].update_max(point.extra_bytes + header.attribute_starts[j]); } } } @@ -402,9 +402,9 @@ BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL p } // close the input file - + fclose(file); - + // populate scale and offset populate_scale_and_offset(); @@ -422,13 +422,13 @@ BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL p file = fopen_compressed(file_name, "rb", &piped); if (file == 0) { - REprintf( "ERROR: could not open '%s' for second pass\n", file_name); + fprintf(stderr, "ERROR: could not open '%s' for second pass\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, 10*LAS_TOOLS_IO_IBUFFER_SIZE) != 0) { - REprintf( "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); + fprintf(stderr, "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); } // set the file pointer @@ -445,7 +445,7 @@ BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL p if (streamin) // binary { - // read the first point + // read the first point read_binary_point(); } else @@ -464,7 +464,7 @@ BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL p else { line[strlen(line)-1] = '\0'; - REprintf( "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_string); + fprintf(stderr, "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_string); } } @@ -472,7 +472,7 @@ BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL p if (i != 1) { - REprintf( "ERROR: could not parse any lines with '%s'\n", parse_string); + fprintf(stderr, "ERROR: could not parse any lines with '%s'\n", parse_string); fclose(this->file); this->file = 0; free(parse_string); @@ -480,7 +480,7 @@ BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL p return FALSE; } } - + if (!populated_header) { // init the bounding box that we will incrementally compute @@ -605,13 +605,13 @@ BOOL LASreaderPLY::seek(const I64 p_index) else { line[strlen(line)-1] = '\0'; - REprintf( "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_string); + fprintf(stderr, "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_string); } } // did we manage to parse a line if (i != 1) { - REprintf( "ERROR: could not parse any lines with '%s'\n", parse_string); + fprintf(stderr, "ERROR: could not parse any lines with '%s'\n", parse_string); fclose(file); file = 0; free(parse_string); @@ -652,7 +652,7 @@ BOOL LASreaderPLY::read_point_default() else { line[strlen(line)-1] = '\0'; - REprintf( "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_string); + fprintf(stderr, "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_string); } } else @@ -660,9 +660,9 @@ BOOL LASreaderPLY::read_point_default() if (p_count != npoints) { #ifdef _WIN32 - REprintf("WARNING: end-of-file after %I64d of %I64d points\n", p_count, npoints); + fprintf(stderr,"WARNING: end-of-file after %I64d of %I64d points\n", p_count, npoints); #else - REprintf("WARNING: end-of-file after %lld of %lld points\n", p_count, npoints); + fprintf(stderr,"WARNING: end-of-file after %lld of %lld points\n", p_count, npoints); #endif npoints = p_count; @@ -676,11 +676,11 @@ BOOL LASreaderPLY::read_point_default() } } } - + // compute the quantized x, y, and z values - point.set_X(header.get_X(point.coordinates[0])); - point.set_Y(header.get_Y(point.coordinates[1])); - point.set_Z(header.get_Z(point.coordinates[2])); + point.set_X((I32)header.get_X(point.coordinates[0])); + point.set_Y((I32)header.get_Y(point.coordinates[1])); + point.set_Z((I32)header.get_Z(point.coordinates[2])); p_count++; if (!populated_header) { @@ -738,20 +738,20 @@ BOOL LASreaderPLY::reopen(const char* file_name) if (file_name == 0) { - REprintf("ERROR: file name pointer is zero\n"); + fprintf(stderr,"ERROR: file name pointer is zero\n"); return FALSE; } file = fopen_compressed(file_name, "r", &piped); if (file == 0) { - REprintf( "ERROR: cannot reopen file '%s'\n", file_name); + fprintf(stderr, "ERROR: cannot reopen file '%s'\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, 10*LAS_TOOLS_IO_IBUFFER_SIZE) != 0) { - REprintf( "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); + fprintf(stderr, "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); } // read the first line with full parse_string @@ -768,7 +768,7 @@ BOOL LASreaderPLY::reopen(const char* file_name) else { line[strlen(line)-1] = '\0'; - REprintf( "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_string); + fprintf(stderr, "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_string); } } @@ -776,7 +776,7 @@ BOOL LASreaderPLY::reopen(const char* file_name) if (i != 1) { - REprintf( "ERROR: could not parse any lines with '%s'\n", parse_string); + fprintf(stderr, "ERROR: could not parse any lines with '%s'\n", parse_string); fclose(file); file = 0; return FALSE; @@ -869,7 +869,7 @@ BOOL LASreaderPLY::set_attribute(I32 index, F64 value) } if (temp_i < U8_MIN || temp_i > U8_MAX) { - REprintf( "WARNING: attribute %d of type U8 is %d. clamped to [%d %d] range.\n", index, temp_i, U8_MIN, U8_MAX); + fprintf(stderr, "WARNING: attribute %d of type U8 is %d. clamped to [%d %d] range.\n", index, temp_i, U8_MIN, U8_MAX); point.set_attribute(header.attribute_starts[index], U8_CLAMP(temp_i)); } else @@ -894,7 +894,7 @@ BOOL LASreaderPLY::set_attribute(I32 index, F64 value) } if (temp_i < I8_MIN || temp_i > I8_MAX) { - REprintf( "WARNING: attribute %d of type I8 is %d. clamped to [%d %d] range.\n", index, temp_i, I8_MIN, I8_MAX); + fprintf(stderr, "WARNING: attribute %d of type I8 is %d. clamped to [%d %d] range.\n", index, temp_i, I8_MIN, I8_MAX); point.set_attribute(header.attribute_starts[index], I8_CLAMP(temp_i)); } else @@ -919,7 +919,7 @@ BOOL LASreaderPLY::set_attribute(I32 index, F64 value) } if (temp_i < U16_MIN || temp_i > U16_MAX) { - REprintf( "WARNING: attribute %d of type U16 is %d. clamped to [%d %d] range.\n", index, temp_i, U16_MIN, U16_MAX); + fprintf(stderr, "WARNING: attribute %d of type U16 is %d. clamped to [%d %d] range.\n", index, temp_i, U16_MIN, U16_MAX); point.set_attribute(header.attribute_starts[index], U16_CLAMP(temp_i)); } else @@ -944,7 +944,7 @@ BOOL LASreaderPLY::set_attribute(I32 index, F64 value) } if (temp_i < I16_MIN || temp_i > I16_MAX) { - REprintf( "WARNING: attribute %d of type I16 is %d. clamped to [%d %d] range.\n", index, temp_i, I16_MIN, I16_MAX); + fprintf(stderr, "WARNING: attribute %d of type I16 is %d. clamped to [%d %d] range.\n", index, temp_i, I16_MIN, I16_MAX); point.set_attribute(header.attribute_starts[index], I16_CLAMP(temp_i)); } else @@ -997,7 +997,7 @@ BOOL LASreaderPLY::set_attribute(I32 index, F64 value) } else { - REprintf( "WARNING: attribute %d not (yet) implemented.\n", index); + fprintf(stderr, "WARNING: attribute %d not (yet) implemented.\n", index); return FALSE; } return TRUE; @@ -1015,7 +1015,7 @@ F64 LASreaderPLY::read_binary_value(CHAR type) } else if (type == 'd') { - streamin->get32bitsLE((U8*)&value); + streamin->get64bitsLE((U8*)&value); } else if (type == 'C') { @@ -1104,19 +1104,19 @@ BOOL LASreaderPLY::read_binary_point() { if (translate_intensity != 0.0f) value = value+translate_intensity; if (scale_intensity != 1.0f) value = value*scale_intensity; - if (value < 0.0 || value >= 65535.5) REprintf( "WARNING: intensity %g is out of range of unsigned short\n", value); + if (value < 0.0 || value >= 65535.5) fprintf(stderr, "WARNING: intensity %g is out of range of unsigned short\n", value); point.set_intensity(U16_QUANTIZE(value)); } else if (p[0] == 'n') // we expect the number of returns of given pulse { if (point_type > 5) { - if ((value < 0) || (value > 15)) REprintf( "WARNING: number of returns of given pulse %g is out of range of four bits\n", value); + if ((value < 0) || (value > 15)) fprintf(stderr, "WARNING: number of returns of given pulse %g is out of range of four bits\n", value); point.set_extended_number_of_returns(U8_QUANTIZE(value) & 15); } else { - if ((value < 0) || (value > 7)) REprintf( "WARNING: number of returns of given pulse %g is out of range of three bits\n", value); + if ((value < 0) || (value > 7)) fprintf(stderr, "WARNING: number of returns of given pulse %g is out of range of three bits\n", value); point.set_number_of_returns(U8_QUANTIZE(value) & 7); } } @@ -1124,12 +1124,12 @@ BOOL LASreaderPLY::read_binary_point() { if (point_type > 5) { - if ((value < 0) || (value > 15)) REprintf( "WARNING: return number %g is out of range of four bits\n", value); + if ((value < 0) || (value > 15)) fprintf(stderr, "WARNING: return number %g is out of range of four bits\n", value); point.set_extended_return_number(U8_QUANTIZE(value) & 15); } else { - if ((value < 0) || (value > 7)) REprintf( "WARNING: return number %g is out of range of three bits\n", value); + if ((value < 0) || (value > 7)) fprintf(stderr, "WARNING: return number %g is out of range of three bits\n", value); point.set_return_number(U8_QUANTIZE(value) & 7); } } @@ -1137,23 +1137,23 @@ BOOL LASreaderPLY::read_binary_point() { if (point_type > 5) { - if ((value < 0) || (value > 255)) REprintf( "WARNING: classification %g is out of range of eight bits\n", value); + if ((value < 0) || (value > 255)) fprintf(stderr, "WARNING: classification %g is out of range of eight bits\n", value); point.set_extended_classification(U8_QUANTIZE(value)); } else { - if ((value < 0) || (value > 31)) REprintf( "WARNING: classification %g is out of range of five bits\n", value); + if ((value < 0) || (value > 31)) fprintf(stderr, "WARNING: classification %g is out of range of five bits\n", value); point.set_classification(U8_QUANTIZE(value) & 31); } } else if (p[0] == 'u') // we expect the user data { - if ((value < 0) || (value > 255)) REprintf( "WARNING: user data %g is out of range of eight bits\n", value); + if ((value < 0) || (value > 255)) fprintf(stderr, "WARNING: user data %g is out of range of eight bits\n", value); point.set_user_data(U8_QUANTIZE(value)); } else if (p[0] == 'p') // we expect the point source ID { - if ((value < 0) || (value > 65535)) REprintf( "WARNING: point source ID %g is out of range of sixteen bits\n", value); + if ((value < 0) || (value > 65535)) fprintf(stderr, "WARNING: point source ID %g is out of range of sixteen bits\n", value); point.set_point_source_ID(U16_QUANTIZE(value)); } else if ((p[0] >= '0') && (p[0] <= '9')) // we expect attribute number 0 to 9 @@ -1174,7 +1174,7 @@ BOOL LASreaderPLY::read_binary_point() } else { - REprintf( "ERROR: unknown symbol '%c' in parse string\n", p[0]); + fprintf(stderr, "ERROR: unknown symbol '%c' in parse string\n", p[0]); } p++; t++; @@ -1272,7 +1272,7 @@ BOOL LASreaderPLY::parse(const char* parse_string) if (sscanf(l, "%f", &temp_f) != 1) return FALSE; if (translate_intensity != 0.0f) temp_f = temp_f+translate_intensity; if (scale_intensity != 1.0f) temp_f = temp_f*scale_intensity; - if (temp_f < 0.0f || temp_f >= 65535.5f) REprintf( "WARNING: intensity %g is out of range of unsigned short\n", temp_f); + if (temp_f < 0.0f || temp_f >= 65535.5f) fprintf(stderr, "WARNING: intensity %g is out of range of unsigned short\n", temp_f); point.set_intensity(U16_QUANTIZE(temp_f)); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1281,7 +1281,7 @@ BOOL LASreaderPLY::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%f", &temp_f) != 1) return FALSE; - if (temp_f < -128.0f || temp_f > 127.0f) REprintf( "WARNING: scan angle %g is out of range of char\n", temp_f); + if (temp_f < -128.0f || temp_f > 127.0f) fprintf(stderr, "WARNING: scan angle %g is out of range of char\n", temp_f); point.set_scan_angle(temp_f); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1292,12 +1292,12 @@ BOOL LASreaderPLY::parse(const char* parse_string) if (sscanf(l, "%d", &temp_i) != 1) return FALSE; if (point_type > 5) { - if (temp_i < 0 || temp_i > 15) REprintf( "WARNING: number of returns of given pulse %d is out of range of four bits\n", temp_i); + if (temp_i < 0 || temp_i > 15) fprintf(stderr, "WARNING: number of returns of given pulse %d is out of range of four bits\n", temp_i); point.set_extended_number_of_returns(temp_i & 15); } else { - if (temp_i < 0 || temp_i > 7) REprintf( "WARNING: number of returns of given pulse %d is out of range of three bits\n", temp_i); + if (temp_i < 0 || temp_i > 7) fprintf(stderr, "WARNING: number of returns of given pulse %d is out of range of three bits\n", temp_i); point.set_number_of_returns(temp_i & 7); } while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space @@ -1309,12 +1309,12 @@ BOOL LASreaderPLY::parse(const char* parse_string) if (sscanf(l, "%d", &temp_i) != 1) return FALSE; if (point_type > 5) { - if (temp_i < 0 || temp_i > 15) REprintf( "WARNING: return number %d is out of range of four bits\n", temp_i); + if (temp_i < 0 || temp_i > 15) fprintf(stderr, "WARNING: return number %d is out of range of four bits\n", temp_i); point.set_extended_return_number(temp_i & 15); } else { - if (temp_i < 0 || temp_i > 7) REprintf( "WARNING: return number %d is out of range of three bits\n", temp_i); + if (temp_i < 0 || temp_i > 7) fprintf(stderr, "WARNING: return number %d is out of range of three bits\n", temp_i); point.set_return_number(temp_i & 7); } while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space @@ -1324,7 +1324,7 @@ BOOL LASreaderPLY::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 1) REprintf( "WARNING: withheld flag %d is out of range of single bit\n", temp_i); + if (temp_i < 0 || temp_i > 1) fprintf(stderr, "WARNING: withheld flag %d is out of range of single bit\n", temp_i); point.set_withheld_flag(temp_i ? 1 : 0); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1333,7 +1333,7 @@ BOOL LASreaderPLY::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 1) REprintf( "WARNING: keypoint flag %d is out of range of single bit\n", temp_i); + if (temp_i < 0 || temp_i > 1) fprintf(stderr, "WARNING: keypoint flag %d is out of range of single bit\n", temp_i); point.set_keypoint_flag(temp_i ? 1 : 0); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1342,7 +1342,7 @@ BOOL LASreaderPLY::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 1) REprintf( "WARNING: keypoint flag %d is out of range of single bit\n", temp_i); + if (temp_i < 0 || temp_i > 1) fprintf(stderr, "WARNING: keypoint flag %d is out of range of single bit\n", temp_i); point.set_synthetic_flag(temp_i ? 1 : 0); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1351,7 +1351,7 @@ BOOL LASreaderPLY::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 1) REprintf( "WARNING: overlap flag %d is out of range of single bit\n", temp_i); + if (temp_i < 0 || temp_i > 1) fprintf(stderr, "WARNING: overlap flag %d is out of range of single bit\n", temp_i); point.set_extended_overlap_flag(temp_i ? 1 : 0); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1360,7 +1360,7 @@ BOOL LASreaderPLY::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 3) REprintf( "WARNING: scanner channel %d is out of range of two bits\n", temp_i); + if (temp_i < 0 || temp_i > 3) fprintf(stderr, "WARNING: scanner channel %d is out of range of two bits\n", temp_i); point.extended_scanner_channel = temp_i & 3; while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1369,7 +1369,7 @@ BOOL LASreaderPLY::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 3) REprintf( "WARNING: terrasolid echo encoding %d is out of range of 0 to 3\n", temp_i); + if (temp_i < 0 || temp_i > 3) fprintf(stderr, "WARNING: terrasolid echo encoding %d is out of range of 0 to 3\n", temp_i); if (temp_i == 0) // only echo { point.number_of_returns = 1; @@ -1399,7 +1399,7 @@ BOOL LASreaderPLY::parse(const char* parse_string) if (sscanf(l, "%d", &temp_i) != 1) return FALSE; if (temp_i < 0 || temp_i > 255) { - REprintf( "WARNING: classification %d is out of range of unsigned char\n", temp_i); + fprintf(stderr, "WARNING: classification %d is out of range of unsigned char\n", temp_i); point.set_classification(U8_CLAMP(temp_i)); } else @@ -1415,7 +1415,7 @@ BOOL LASreaderPLY::parse(const char* parse_string) if (sscanf(l, "%d", &temp_i) != 1) return FALSE; if (temp_i < 0 || temp_i > 255) { - REprintf( "WARNING: user data %d is out of range of unsigned char\n", temp_i); + fprintf(stderr, "WARNING: user data %d is out of range of unsigned char\n", temp_i); point.set_user_data(U8_CLAMP(temp_i)); } else @@ -1431,7 +1431,7 @@ BOOL LASreaderPLY::parse(const char* parse_string) if (sscanf(l, "%d", &temp_i) != 1) return FALSE; if (temp_i < 0 || temp_i > 65535) { - REprintf( "WARNING: point source ID %d is out of range of unsigned short\n", temp_i); + fprintf(stderr, "WARNING: point source ID %d is out of range of unsigned short\n", temp_i); point.set_point_source_ID(U16_CLAMP(temp_i)); } else @@ -1445,7 +1445,7 @@ BOOL LASreaderPLY::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 1) REprintf( "WARNING: edge of flight line flag %d is out of range of boolean flag\n", temp_i); + if (temp_i < 0 || temp_i > 1) fprintf(stderr, "WARNING: edge of flight line flag %d is out of range of boolean flag\n", temp_i); point.edge_of_flight_line = (temp_i ? 1 : 0); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1454,7 +1454,7 @@ BOOL LASreaderPLY::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 1) REprintf( "WARNING: direction of scan flag %d is out of range of boolean flag\n", temp_i); + if (temp_i < 0 || temp_i > 1) fprintf(stderr, "WARNING: direction of scan flag %d is out of range of boolean flag\n", temp_i); point.scan_direction_flag = (temp_i ? 1 : 0); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1487,13 +1487,13 @@ BOOL LASreaderPLY::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';' || l[0] == '\"')) l++; // first skip white spaces and quotes if (l[0] == 0) return FALSE; hex_string[0] = l[0]; hex_string[1] = l[1]; - sscanf(hex_string,"%d",&hex_value); - point.rgb[0] = hex_value; + sscanf(hex_string,"%x",&hex_value); + point.rgb[0] = hex_value; hex_string[0] = l[2]; hex_string[1] = l[3]; - sscanf(hex_string,"%d",&hex_value); - point.rgb[1] = hex_value; + sscanf(hex_string,"%x",&hex_value); + point.rgb[1] = hex_value; hex_string[0] = l[4]; hex_string[1] = l[5]; - sscanf(hex_string,"%d",&hex_value); + sscanf(hex_string,"%x",&hex_value); point.rgb[2] = hex_value; l+=6; while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space @@ -1503,14 +1503,14 @@ BOOL LASreaderPLY::parse(const char* parse_string) I32 hex_value; while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';' || l[0] == '\"')) l++; // first skip white spaces and quotes if (l[0] == 0) return FALSE; - sscanf(l,"%d",&hex_value); + sscanf(l,"%x",&hex_value); point.intensity = U8_CLAMP(((F64)hex_value/(F64)0xFFFFFF)*255); l+=6; while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } else { - REprintf( "ERROR: unknown symbol '%c' in parse string\n", p[0]); + fprintf(stderr, "ERROR: unknown symbol '%c' in parse string\n", p[0]); } p++; } @@ -1526,7 +1526,7 @@ BOOL LASreaderPLY::parse_header(BOOL quiet) // first header line containing "ply" - if (fgets(line, 512, file)); + fgets(line, 512, file); if (strncmp(line, "ply", 3) != 0) { return FALSE; @@ -1545,8 +1545,8 @@ BOOL LASreaderPLY::parse_header(BOOL quiet) while (true) { // next line - if (fgets(line, 512, file)); - + fgets(line, 512, file); + if (strncmp(line, "end_header", 10) == 0) { break; @@ -1571,7 +1571,7 @@ BOOL LASreaderPLY::parse_header(BOOL quiet) } else { - REprintf( "format: %snot implemented. contact martin@rapidlasso.com\n", &line[7]); + fprintf(stderr, "format: %snot implemented. contact martin@rapidlasso.com\n", &line[7]); return FALSE; } } @@ -1579,6 +1579,10 @@ BOOL LASreaderPLY::parse_header(BOOL quiet) { // ignore comments } + else if (strncmp(line, "obj_info", 8) == 0) + { + // ignore obj_info + } else if (strncmp(line, "element", 7) == 0) { if (strncmp(&line[8], "vertex", 6) == 0) @@ -1589,13 +1593,13 @@ BOOL LASreaderPLY::parse_header(BOOL quiet) if (sscanf(&line[15], "%lld", &npoints) != 1) #endif { - REprintf( "element vertex: %scannot parse number of points. contact martin@rapidlasso.com\n", &line[15]); + fprintf(stderr, "element vertex: %scannot parse number of points. contact martin@rapidlasso.com\n", &line[15]); return FALSE; } } else { - if (!quiet) REprintf( "not supported: %sskipping remaining header ...\n", line); + if (!quiet) fprintf(stderr, "not supported: %sskipping remaining header ...\n", line); skip_remaining = TRUE; continue; } @@ -1688,19 +1692,19 @@ BOOL LASreaderPLY::parse_header(BOOL quiet) if (strncmp(&line[offset], "x", 1) == 0) { parse_string[items] = 'x'; - type_string[items] = 'f'; + type_string[items] = 'd'; items++; } else if (strncmp(&line[offset], "y", 1) == 0) { parse_string[items] = 'y'; - type_string[items] = 'f'; + type_string[items] = 'd'; items++; } else if (strncmp(&line[offset], "z", 1) == 0) { parse_string[items] = 'z'; - type_string[items] = 'f'; + type_string[items] = 'd'; items++; } else if (strncmp(&line[offset], "nx", 2) == 0) @@ -1708,7 +1712,7 @@ BOOL LASreaderPLY::parse_header(BOOL quiet) I32 num = number_attributes; add_attribute(LAS_ATTRIBUTE_I16, "nx", "normal x coordinate", 0.00005); parse_string[items] = '0' + num; - type_string[items] = 'f'; + type_string[items] = 'd'; items++; } else if (strncmp(&line[offset], "ny", 2) == 0) @@ -1716,7 +1720,7 @@ BOOL LASreaderPLY::parse_header(BOOL quiet) I32 num = number_attributes; add_attribute(LAS_ATTRIBUTE_I16, "ny", "normal y coordinate", 0.00005); parse_string[items] = '0' + num; - type_string[items] = 'f'; + type_string[items] = 'd'; items++; } else if (strncmp(&line[offset], "nz", 2) == 0) @@ -1724,7 +1728,7 @@ BOOL LASreaderPLY::parse_header(BOOL quiet) I32 num = number_attributes; add_attribute(LAS_ATTRIBUTE_I16, "nz", "normal z coordinate", 0.00005); parse_string[items] = '0' + num; - type_string[items] = 'f'; + type_string[items] = 'd'; items++; } else @@ -1736,9 +1740,9 @@ BOOL LASreaderPLY::parse_header(BOOL quiet) memset(description, 0, 32); sscanf(&line[offset], "%15s", name); sscanf(&line[offset], "%31s", description); - add_attribute(LAS_ATTRIBUTE_F32, name, description); + add_attribute(LAS_ATTRIBUTE_F64, name, description); parse_string[items] = '0' + num; - type_string[items] = 'f'; + type_string[items] = 'd'; items++; } } @@ -1783,18 +1787,46 @@ BOOL LASreaderPLY::parse_header(BOOL quiet) items++; } } - else + else if (strncmp(&line[9], "int", 3) == 0) { - REprintf( "unknown property type: %snot implemented. contact martin@rapidlasso.com\n", &line[9]); + I32 num = number_attributes; + CHAR name[16]; + CHAR description[32]; + memset(name, 0, 16); + memset(description, 0, 32); + sscanf(&line[13], "%15s", name); + sscanf(&line[13], "%31s", description); + add_attribute(LAS_ATTRIBUTE_I32, name, description); + parse_string[items] = '0' + num; + type_string[items] = 'i'; + items++; + } + else if (strncmp(&line[9], "uint", 4) == 0) + { + I32 num = number_attributes; + CHAR name[16]; + CHAR description[32]; + memset(name, 0, 16); + memset(description, 0, 32); + sscanf(&line[13], "%15s", name); + sscanf(&line[13], "%31s", description); + add_attribute(LAS_ATTRIBUTE_I32, name, description); + parse_string[items] = '0' + num; + type_string[items] = 'I'; + items++; + } + else + { + fprintf(stderr, "unknown property type: %snot implemented. contact martin@rapidlasso.com\n", &line[9]); return FALSE; } } else { - REprintf( "unknown header item: %snot implemented. contact martin@rapidlasso.com", line); + fprintf(stderr, "unknown header item: %snot implemented. contact martin@rapidlasso.com", line); } - if (!quiet) REprintf( "parsed: %s", line); + if (!quiet) fprintf(stderr, "parsed: %s", line); } return TRUE; @@ -1855,19 +1887,19 @@ void LASreaderPLY::populate_bounding_box() { // compute quantized and then unquantized bounding box - F64 dequant_min_x = header.get_x(header.get_X(header.min_x)); - F64 dequant_max_x = header.get_x(header.get_X(header.max_x)); - F64 dequant_min_y = header.get_y(header.get_Y(header.min_y)); - F64 dequant_max_y = header.get_y(header.get_Y(header.max_y)); - F64 dequant_min_z = header.get_z(header.get_Z(header.min_z)); - F64 dequant_max_z = header.get_z(header.get_Z(header.max_z)); + F64 dequant_min_x = header.get_x((I32)header.get_X(header.min_x)); + F64 dequant_max_x = header.get_x((I32)header.get_X(header.max_x)); + F64 dequant_min_y = header.get_y((I32)header.get_Y(header.min_y)); + F64 dequant_max_y = header.get_y((I32)header.get_Y(header.max_y)); + F64 dequant_min_z = header.get_z((I32)header.get_Z(header.min_z)); + F64 dequant_max_z = header.get_z((I32)header.get_Z(header.max_z)); // make sure there is not sign flip if ((header.min_x > 0) != (dequant_min_x > 0)) { - REprintf( "WARNING: quantization sign flip for min_x from %g to %g.\n", header.min_x, dequant_min_x); - REprintf( " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for min_x from %g to %g.\n", header.min_x, dequant_min_x); + fprintf(stderr, " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); } else { @@ -1875,8 +1907,8 @@ void LASreaderPLY::populate_bounding_box() } if ((header.max_x > 0) != (dequant_max_x > 0)) { - REprintf( "WARNING: quantization sign flip for max_x from %g to %g.\n", header.max_x, dequant_max_x); - REprintf( " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for max_x from %g to %g.\n", header.max_x, dequant_max_x); + fprintf(stderr, " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); } else { @@ -1884,8 +1916,8 @@ void LASreaderPLY::populate_bounding_box() } if ((header.min_y > 0) != (dequant_min_y > 0)) { - REprintf( "WARNING: quantization sign flip for min_y from %g to %g.\n", header.min_y, dequant_min_y); - REprintf( " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for min_y from %g to %g.\n", header.min_y, dequant_min_y); + fprintf(stderr, " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); } else { @@ -1893,8 +1925,8 @@ void LASreaderPLY::populate_bounding_box() } if ((header.max_y > 0) != (dequant_max_y > 0)) { - REprintf( "WARNING: quantization sign flip for max_y from %g to %g.\n", header.max_y, dequant_max_y); - REprintf( " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for max_y from %g to %g.\n", header.max_y, dequant_max_y); + fprintf(stderr, " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); } else { @@ -1902,8 +1934,8 @@ void LASreaderPLY::populate_bounding_box() } if ((header.min_z > 0) != (dequant_min_z > 0)) { - REprintf( "WARNING: quantization sign flip for min_z from %g to %g.\n", header.min_z, dequant_min_z); - REprintf( " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for min_z from %g to %g.\n", header.min_z, dequant_min_z); + fprintf(stderr, " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); } else { @@ -1911,8 +1943,8 @@ void LASreaderPLY::populate_bounding_box() } if ((header.max_z > 0) != (dequant_max_z > 0)) { - REprintf( "WARNING: quantization sign flip for max_z from %g to %g.\n", header.max_z, dequant_max_z); - REprintf( " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for max_z from %g to %g.\n", header.max_z, dequant_max_z); + fprintf(stderr, " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); } else { diff --git a/inst/include/lasreader_ply.hpp b/src/LASlib/lasreader_ply.hpp similarity index 98% rename from inst/include/lasreader_ply.hpp rename to src/LASlib/lasreader_ply.hpp index edbb452..651ab78 100644 --- a/inst/include/lasreader_ply.hpp +++ b/src/LASlib/lasreader_ply.hpp @@ -24,6 +24,7 @@ CHANGE HISTORY: + 9 May 2020 -- added silly 'obj_info' used by Cloud Compare 4 September 2018 -- created after returning to Samara with locks changed =============================================================================== diff --git a/src/LASlib/lasreader_qfit.cpp b/src/LASlib/lasreader_qfit.cpp index 9124c42..db14c1e 100644 --- a/src/LASlib/lasreader_qfit.cpp +++ b/src/LASlib/lasreader_qfit.cpp @@ -44,7 +44,7 @@ BOOL LASreaderQFIT::open(const char* file_name) { if (file_name == 0) { - REprintf("ERROR: file name pointer is zero\n"); + fprintf(stderr,"ERROR: file name pointer is zero\n"); return FALSE; } @@ -53,7 +53,7 @@ BOOL LASreaderQFIT::open(const char* file_name) file = fopen(file_name, "rb"); if (file == 0) { - REprintf( "ERROR: cannot open file '%s'\n", file_name); + fprintf(stderr, "ERROR: cannot open file '%s'\n", file_name); return FALSE; } @@ -125,7 +125,7 @@ BOOL LASreaderQFIT::open(ByteStreamIn* stream) if (stream == 0) { - REprintf("ERROR: ByteStreamIn* pointer is zero\n"); + fprintf(stderr,"ERROR: ByteStreamIn* pointer is zero\n"); return FALSE; } @@ -135,7 +135,7 @@ BOOL LASreaderQFIT::open(ByteStreamIn* stream) try { stream->get32bitsLE((U8*)&version); } catch(...) { - REprintf("ERROR: reading QFIT header\n"); + fprintf(stderr,"ERROR: reading QFIT header\n"); return FALSE; } @@ -156,7 +156,7 @@ BOOL LASreaderQFIT::open(ByteStreamIn* stream) } else { - REprintf("ERROR: corrupt QFIT header.\n"); + fprintf(stderr,"ERROR: corrupt QFIT header.\n"); return FALSE; } } @@ -165,7 +165,7 @@ BOOL LASreaderQFIT::open(ByteStreamIn* stream) try { stream->getBytes((U8*)buffer, version); } catch(...) { - REprintf("ERROR: reading %d bytes until point start offset from QFIT header\n", version); + fprintf(stderr,"ERROR: reading %d bytes until point start offset from QFIT header\n", version); return FALSE; } @@ -173,7 +173,7 @@ BOOL LASreaderQFIT::open(ByteStreamIn* stream) try { if (little_endian) stream->get32bitsLE((U8*)&offset); else stream->get32bitsBE((U8*)&offset); } catch(...) { - REprintf("ERROR: reading point start offset from QFIT header\n"); + fprintf(stderr,"ERROR: reading point start offset from QFIT header\n"); return FALSE; } @@ -212,7 +212,7 @@ BOOL LASreaderQFIT::open(ByteStreamIn* stream) header.add_attribute(scan_azimuth); } catch(...) { - REprintf("ERROR: initializing attribute scan_azimuth\n"); + fprintf(stderr,"ERROR: initializing attribute scan_azimuth\n"); return FALSE; } @@ -225,7 +225,7 @@ BOOL LASreaderQFIT::open(ByteStreamIn* stream) header.add_attribute(pitch); } catch(...) { - REprintf("ERROR: initializing attribute pitch\n"); + fprintf(stderr,"ERROR: initializing attribute pitch\n"); return FALSE; } @@ -238,7 +238,7 @@ BOOL LASreaderQFIT::open(ByteStreamIn* stream) header.add_attribute(roll); } catch(...) { - REprintf("ERROR: initializing attribute roll\n"); + fprintf(stderr,"ERROR: initializing attribute roll\n"); return FALSE; } @@ -249,7 +249,7 @@ BOOL LASreaderQFIT::open(ByteStreamIn* stream) header.add_attribute(pulse_width); } catch(...) { - REprintf("ERROR: initializing attribute pulse width\n"); + fprintf(stderr,"ERROR: initializing attribute pulse width\n"); return FALSE; } } @@ -314,7 +314,7 @@ BOOL LASreaderQFIT::read_point_default() { try { stream->getBytes((U8*)buffer, version); } catch(...) { - REprintf("ERROR: reading QFIT point after %u of %u\n", (U32)p_count, (U32)npoints); + fprintf(stderr,"ERROR: reading QFIT point after %u of %u\n", (U32)p_count, (U32)npoints); return FALSE; } @@ -402,7 +402,7 @@ BOOL LASreaderQFIT::reopen(const char* file_name) { if (file_name == 0) { - REprintf("ERROR: file name pointer is zero\n"); + fprintf(stderr,"ERROR: file name pointer is zero\n"); return FALSE; } @@ -411,7 +411,7 @@ BOOL LASreaderQFIT::reopen(const char* file_name) file = fopen(file_name, "rb"); if (file == 0) { - REprintf( "ERROR: cannot open file '%s'\n", file_name); + fprintf(stderr, "ERROR: cannot open file '%s'\n", file_name); return FALSE; } diff --git a/inst/include/lasreader_qfit.hpp b/src/LASlib/lasreader_qfit.hpp similarity index 100% rename from inst/include/lasreader_qfit.hpp rename to src/LASlib/lasreader_qfit.hpp diff --git a/src/LASlib/lasreader_shp.cpp b/src/LASlib/lasreader_shp.cpp index 34646a4..b652457 100644 --- a/src/LASlib/lasreader_shp.cpp +++ b/src/LASlib/lasreader_shp.cpp @@ -105,7 +105,7 @@ BOOL LASreaderSHP::open(const char* file_name) { if (file_name == 0) { - REprintf("ERROR: file name pointer is zero\n"); + fprintf(stderr,"ERROR: file name pointer is zero\n"); return FALSE; } @@ -114,7 +114,7 @@ BOOL LASreaderSHP::open(const char* file_name) file = fopen_compressed(file_name, "rb", &piped); if (file == 0) { - REprintf( "ERROR: cannot open file '%s'\n", file_name); + fprintf(stderr, "ERROR: cannot open file '%s'\n", file_name); return FALSE; } @@ -158,7 +158,7 @@ BOOL LASreaderSHP::open(const char* file_name) from_big_endian(&int_input); if (int_input != 9994) { - REprintf( "ERROR: wrong shapefile code %d != 9994\n", int_input); + fprintf(stderr, "ERROR: wrong shapefile code %d != 9994\n", int_input); return FALSE; } if (fread(&int_input, sizeof(int), 1, file) != 1) return false; // unused (BIG) @@ -173,7 +173,7 @@ BOOL LASreaderSHP::open(const char* file_name) from_little_endian(&int_input); if (int_input != 1000) { - REprintf( "ERROR: wrong shapefile version %d != 1000\n", int_input); + fprintf(stderr, "ERROR: wrong shapefile version %d != 1000\n", int_input); return FALSE; } if (fread(&int_input, sizeof(int), 1, file) != 1) return false; // shape type (LITTLE) @@ -181,7 +181,7 @@ BOOL LASreaderSHP::open(const char* file_name) shape_type = int_input; if (shape_type != 1 && shape_type != 11 && shape_type != 21 && shape_type != 8 && shape_type != 18 && shape_type != 28) { - REprintf( "ERROR: wrong shape type %d != 1,11,21,8,18,28\n", shape_type); + fprintf(stderr, "ERROR: wrong shape type %d != 1,11,21,8,18,28\n", shape_type); return FALSE; } double double_input; @@ -298,7 +298,7 @@ BOOL LASreaderSHP::read_point_default() from_little_endian(&int_input); if (int_input != shape_type) { - REprintf( "WARNING: wrong shape type %d != %d in record\n", int_input, shape_type); + fprintf(stderr, "WARNING: wrong shape type %d != %d in record\n", int_input, shape_type); } double double_input; if (shape_type == 8 || shape_type == 18 || shape_type == 28) // Multipoint @@ -328,10 +328,10 @@ BOOL LASreaderSHP::read_point_default() { if (fread(&double_input, sizeof(double), 1, file) != 1) { npoints = p_count; return FALSE; }; // x of point (LITTLE) from_little_endian(&double_input); - points[3*i+0] = header.get_X(double_input); + points[3*i+0] = (I32)header.get_X(double_input); if (fread(&double_input, sizeof(double), 1, file) != 1) { npoints = p_count; return FALSE; }; // y of point (LITTLE) from_little_endian(&double_input); - points[3*i+1] = header.get_Y(double_input); + points[3*i+1] = (I32)header.get_Y(double_input); } // read points z and write LAS points if (shape_type == 18) // Multipoint @@ -343,7 +343,7 @@ BOOL LASreaderSHP::read_point_default() { if (fread(&double_input, sizeof(double), 1, file) != 1) { npoints = p_count; return FALSE; }; // z of point (LITTLE) from_little_endian(&double_input); - points[3*i+2] = header.get_Z(double_input); + points[3*i+2] = (I32)header.get_Z(double_input); } } else @@ -359,10 +359,10 @@ BOOL LASreaderSHP::read_point_default() { if (fread(&double_input, sizeof(double), 1, file) != 1) { npoints = p_count; return FALSE; }; // x of point (LITTLE) from_little_endian(&double_input); - points[2*i+0] = header.get_Z(double_input); + points[2*i+0] = (I32)header.get_X(double_input); if (fread(&double_input, sizeof(double), 1, file) != 1) { npoints = p_count; return FALSE; }; // y of point (LITTLE) from_little_endian(&double_input); - points[2*i+1] = header.get_Z(double_input); + points[2*i+1] = (I32)header.get_Y(double_input); } } // read points m @@ -416,14 +416,14 @@ BOOL LASreaderSHP::reopen(const char* file_name) { if (file_name == 0) { - REprintf("ERROR: file name pointer is zero\n"); + fprintf(stderr,"ERROR: file name pointer is zero\n"); return FALSE; } file = fopen_compressed(file_name, "rb", &piped); if (file == 0) { - REprintf( "ERROR: cannot reopen file '%s'\n", file_name); + fprintf(stderr, "ERROR: cannot reopen file '%s'\n", file_name); return FALSE; } @@ -555,19 +555,19 @@ void LASreaderSHP::populate_bounding_box() { // compute quantized and then unquantized bounding box - F64 dequant_min_x = header.get_x(header.get_X(header.min_x)); - F64 dequant_max_x = header.get_x(header.get_X(header.max_x)); - F64 dequant_min_y = header.get_y(header.get_Y(header.min_y)); - F64 dequant_max_y = header.get_y(header.get_Y(header.max_y)); - F64 dequant_min_z = header.get_z(header.get_Z(header.min_z)); - F64 dequant_max_z = header.get_z(header.get_Z(header.max_z)); + F64 dequant_min_x = header.get_x((I32)(header.get_X(header.min_x))); + F64 dequant_max_x = header.get_x((I32)(header.get_X(header.max_x))); + F64 dequant_min_y = header.get_y((I32)(header.get_Y(header.min_y))); + F64 dequant_max_y = header.get_y((I32)(header.get_Y(header.max_y))); + F64 dequant_min_z = header.get_z((I32)(header.get_Z(header.min_z))); + F64 dequant_max_z = header.get_z((I32)(header.get_Z(header.max_z))); // make sure there is not sign flip if ((header.min_x > 0) != (dequant_min_x > 0)) { - REprintf( "WARNING: quantization sign flip for min_x from %g to %g.\n", header.min_x, dequant_min_x); - REprintf( " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for min_x from %g to %g.\n", header.min_x, dequant_min_x); + fprintf(stderr, " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); } else { @@ -575,8 +575,8 @@ void LASreaderSHP::populate_bounding_box() } if ((header.max_x > 0) != (dequant_max_x > 0)) { - REprintf( "WARNING: quantization sign flip for max_x from %g to %g.\n", header.max_x, dequant_max_x); - REprintf( " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for max_x from %g to %g.\n", header.max_x, dequant_max_x); + fprintf(stderr, " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); } else { @@ -584,8 +584,8 @@ void LASreaderSHP::populate_bounding_box() } if ((header.min_y > 0) != (dequant_min_y > 0)) { - REprintf( "WARNING: quantization sign flip for min_y from %g to %g.\n", header.min_y, dequant_min_y); - REprintf( " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for min_y from %g to %g.\n", header.min_y, dequant_min_y); + fprintf(stderr, " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); } else { @@ -593,8 +593,8 @@ void LASreaderSHP::populate_bounding_box() } if ((header.max_y > 0) != (dequant_max_y > 0)) { - REprintf( "WARNING: quantization sign flip for max_y from %g to %g.\n", header.max_y, dequant_max_y); - REprintf( " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for max_y from %g to %g.\n", header.max_y, dequant_max_y); + fprintf(stderr, " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); } else { @@ -602,8 +602,8 @@ void LASreaderSHP::populate_bounding_box() } if ((header.min_z > 0) != (dequant_min_z > 0)) { - REprintf( "WARNING: quantization sign flip for min_z from %g to %g.\n", header.min_z, dequant_min_z); - REprintf( " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for min_z from %g to %g.\n", header.min_z, dequant_min_z); + fprintf(stderr, " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); } else { @@ -611,8 +611,8 @@ void LASreaderSHP::populate_bounding_box() } if ((header.max_z > 0) != (dequant_max_z > 0)) { - REprintf( "WARNING: quantization sign flip for max_z from %g to %g.\n", header.max_z, dequant_max_z); - REprintf( " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for max_z from %g to %g.\n", header.max_z, dequant_max_z); + fprintf(stderr, " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); } else { diff --git a/inst/include/lasreader_shp.hpp b/src/LASlib/lasreader_shp.hpp similarity index 100% rename from inst/include/lasreader_shp.hpp rename to src/LASlib/lasreader_shp.hpp diff --git a/src/LASlib/lasreader_txt.cpp b/src/LASlib/lasreader_txt.cpp index 4b322ed..9560489 100644 --- a/src/LASlib/lasreader_txt.cpp +++ b/src/LASlib/lasreader_txt.cpp @@ -43,20 +43,20 @@ BOOL LASreaderTXT::open(const CHAR* file_name, U8 point_type, const CHAR* parse_ { if (file_name == 0) { - REprintf("ERROR: file name pointer is zero\n"); + fprintf(stderr,"ERROR: file name pointer is zero\n"); return FALSE; } FILE* file = fopen_compressed(file_name, "r", &piped); if (file == 0) { - REprintf( "ERROR: cannot open file '%s'\n", file_name); + fprintf(stderr, "ERROR: cannot open file '%s'\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, 10*LAS_TOOLS_IO_IBUFFER_SIZE) != 0) { - REprintf( "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); + fprintf(stderr, "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); } return open(file, file_name, point_type, parse_string, skip_lines, populate_header); @@ -68,7 +68,7 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const if (file == 0) { - REprintf("ERROR: file pointer is zero\n"); + fprintf(stderr,"ERROR: file pointer is zero\n"); return FALSE; } @@ -108,7 +108,7 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const header.add_attribute(attribute); } catch(...) { - REprintf("ERROR: initializing attribute %s\n", attribute_descriptions[i]); + fprintf(stderr,"ERROR: initializing attribute %s\n", attribute_descriptions[i]); return FALSE; } } @@ -231,11 +231,10 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const this->point_type = header.point_data_format; - // maybe attributes in extra bytes + // maybe update point size with extra bytes if (header.number_attributes) { - header.update_extra_bytes_vlr(); header.point_data_record_length += header.get_attributes_size(); } @@ -277,7 +276,7 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const // skip lines if we have to - for (i = 0; i < skip_lines; i++) if (fgets(line, 512, file)); + for (i = 0; i < skip_lines; i++) fgets(line, 512, file); if (ipts) { @@ -289,19 +288,19 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const if (sscanf(line, "%lld", &npoints) != 1) #endif { - REprintf( "ERROR: parsing number of points for '-itps'\n"); + fprintf(stderr, "ERROR: parsing number of points for '-itps'\n"); return FALSE; } #ifdef _WIN32 - REprintf( "PTS header states %I64d points. ignoring ...\n", npoints); + fprintf(stderr, "PTS header states %I64d points. ignoring ...\n", npoints); #else - REprintf( "PTS header states %lld points. ignoring ...\n", npoints); + fprintf(stderr, "PTS header states %lld points. ignoring ...\n", npoints); #endif npoints = 0; } else { - REprintf( "ERROR: reading PTS header for '-itps'\n"); + fprintf(stderr, "ERROR: reading PTS header for '-itps'\n"); return FALSE; } } @@ -312,13 +311,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%d", &ncols) != 1) { - REprintf( "ERROR: parsing number of cols\n"); + fprintf(stderr, "ERROR: parsing number of cols\n"); return FALSE; } } else { - REprintf( "ERROR: reading line with number of cols\n"); + fprintf(stderr, "ERROR: reading line with number of cols\n"); return FALSE; } I32 nrows; @@ -326,33 +325,33 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%d", &nrows) != 1) { - REprintf( "ERROR: parsing number of rows\n"); + fprintf(stderr, "ERROR: parsing number of rows\n"); return FALSE; } } else { - REprintf( "ERROR: reading line with number of rows\n"); + fprintf(stderr, "ERROR: reading line with number of rows\n"); return FALSE; } npoints = (I64)ncols*(I64)nrows; #ifdef _WIN32 - REprintf( "PTX header states %d cols by %d rows aka %I64d points. ignoring ...\n", ncols, nrows, npoints); + fprintf(stderr, "PTX header states %d cols by %d rows aka %I64d points. ignoring ...\n", ncols, nrows, npoints); #else - REprintf( "PTX header states %d cols by %d rows aka %lld points. ignoring ...\n", ncols, nrows, npoints); + fprintf(stderr, "PTX header states %d cols by %d rows aka %lld points. ignoring ...\n", ncols, nrows, npoints); #endif F64 translation[3]; if (fgets(line, 512, file)) { if (sscanf(line, "%lf %lf %lf", &(translation[0]), &(translation[1]), &(translation[2])) != 3) { - REprintf( "ERROR: parsing translation\n"); + fprintf(stderr, "ERROR: parsing translation\n"); return FALSE; } } else { - REprintf( "ERROR: reading line with translation\n"); + fprintf(stderr, "ERROR: reading line with translation\n"); return FALSE; } F64 rotation_row_0[3]; @@ -360,13 +359,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%lf %lf %lf", &(rotation_row_0[0]), &(rotation_row_0[1]), &(rotation_row_0[2])) != 3) { - REprintf( "ERROR: parsing rotation row 0\n"); + fprintf(stderr, "ERROR: parsing rotation row 0\n"); return FALSE; } } else { - REprintf( "ERROR: reading line with rotation row 0\n"); + fprintf(stderr, "ERROR: reading line with rotation row 0\n"); return FALSE; } F64 rotation_row_1[3]; @@ -374,13 +373,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%lf %lf %lf", &(rotation_row_1[0]), &(rotation_row_1[1]), &(rotation_row_1[2])) != 3) { - REprintf( "ERROR: parsing rotation row 1\n"); + fprintf(stderr, "ERROR: parsing rotation row 1\n"); return FALSE; } } else { - REprintf( "ERROR: reading line with rotation row 1\n"); + fprintf(stderr, "ERROR: reading line with rotation row 1\n"); return FALSE; } F64 rotation_row_2[3]; @@ -388,13 +387,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%lf %lf %lf", &(rotation_row_2[0]), &(rotation_row_2[1]), &(rotation_row_2[2])) != 3) { - REprintf( "ERROR: parsing rotation row 2\n"); + fprintf(stderr, "ERROR: parsing rotation row 2\n"); return FALSE; } } else { - REprintf( "ERROR: reading line with rotation row 2\n"); + fprintf(stderr, "ERROR: reading line with rotation row 2\n"); return FALSE; } F64 transformation_row_0[4]; @@ -402,13 +401,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%lf %lf %lf %lf", &(transformation_row_0[0]), &(transformation_row_0[1]), &(transformation_row_0[2]), &(transformation_row_0[3])) != 4) { - REprintf( "ERROR: parsing transformation row 0\n"); + fprintf(stderr, "ERROR: parsing transformation row 0\n"); return FALSE; } } else { - REprintf( "ERROR: reading line with transformation row 0\n"); + fprintf(stderr, "ERROR: reading line with transformation row 0\n"); return FALSE; } F64 transformation_row_1[4]; @@ -416,13 +415,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%lf %lf %lf %lf", &(transformation_row_1[0]), &(transformation_row_1[1]), &(transformation_row_1[2]), &(transformation_row_1[3])) != 4) { - REprintf( "ERROR: parsing transformation row 1\n"); + fprintf(stderr, "ERROR: parsing transformation row 1\n"); return FALSE; } } else { - REprintf( "ERROR: reading line with transformation row 1\n"); + fprintf(stderr, "ERROR: reading line with transformation row 1\n"); return FALSE; } F64 transformation_row_2[4]; @@ -430,13 +429,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%lf %lf %lf %lf", &(transformation_row_2[0]), &(transformation_row_2[1]), &(transformation_row_2[2]), &(transformation_row_2[3])) != 4) { - REprintf( "ERROR: parsing transformation row 2\n"); + fprintf(stderr, "ERROR: parsing transformation row 2\n"); return FALSE; } } else { - REprintf( "ERROR: reading line with transformation row 2\n"); + fprintf(stderr, "ERROR: reading line with transformation row 2\n"); return FALSE; } F64 transformation_row_3[4]; @@ -444,13 +443,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%lf %lf %lf %lf", &(transformation_row_3[0]), &(transformation_row_3[1]), &(transformation_row_3[2]), &(transformation_row_3[3])) != 4) { - REprintf( "ERROR: parsing transformation row 3\n"); + fprintf(stderr, "ERROR: parsing transformation row 3\n"); return FALSE; } } else { - REprintf( "ERROR: reading line with transformation row 3\n"); + fprintf(stderr, "ERROR: reading line with transformation row 3\n"); return FALSE; } npoints = 0; @@ -470,7 +469,7 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const else { line[strlen(line)-1] = '\0'; - REprintf( "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_less); + fprintf(stderr, "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_less); } } @@ -478,7 +477,7 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const if (npoints == 0) { - REprintf( "ERROR: could not parse any lines with '%s'\n", parse_less); + fprintf(stderr, "ERROR: could not parse any lines with '%s'\n", parse_less); fclose(file); file = 0; free(parse_less); @@ -550,14 +549,14 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const else { line[strlen(line)-1] = '\0'; - REprintf( "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_less); + fprintf(stderr, "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_less); } } #ifdef _WIN32 - REprintf( "counted %I64d points in populate pass.\n", npoints); + fprintf(stderr, "counted %I64d points in populate pass.\n", npoints); #else - REprintf( "counted %lld points in populate pass.\n", npoints); + fprintf(stderr, "counted %lld points in populate pass.\n", npoints); #endif if (point.extended_point_type || (npoints > U32_MAX) || header.extended_number_of_points_by_return[5] || header.extended_number_of_points_by_return[6] || header.extended_number_of_points_by_return[7] || header.extended_number_of_points_by_return[8] || header.extended_number_of_points_by_return[9] || header.extended_number_of_points_by_return[10] || header.extended_number_of_points_by_return[11] || header.extended_number_of_points_by_return[12] || header.extended_number_of_points_by_return[13] || header.extended_number_of_points_by_return[14]) @@ -591,6 +590,9 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const header.extended_number_of_points_by_return[3] = 0; header.extended_number_of_points_by_return[4] = 0; } + + // free the parse less string + free(parse_less); // close the input file @@ -614,13 +616,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const file = fopen_compressed(file_name, "r", &piped); if (file == 0) { - REprintf( "ERROR: could not open '%s' for second pass\n", file_name); + fprintf(stderr, "ERROR: could not open '%s' for second pass\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, 10*LAS_TOOLS_IO_IBUFFER_SIZE) != 0) { - REprintf( "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); + fprintf(stderr, "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); } } @@ -638,7 +640,7 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const this->skip_lines = skip_lines; if (skip_lines) { - for (i = 0; i < skip_lines; i++) if (fgets(line, 512, file)); + for (i = 0; i < skip_lines; i++) fgets(line, 512, file); } else if (ipts) { @@ -652,7 +654,7 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const if (sscanf(line, "%lld", &npoints) != 1) #endif { - REprintf( "ERROR: parsing number of points for '-itps'\n"); + fprintf(stderr, "ERROR: parsing number of points for '-itps'\n"); return FALSE; } } @@ -683,7 +685,7 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const } else { - REprintf( "ERROR: reading PTS header for '-itps'\n"); + fprintf(stderr, "ERROR: reading PTS header for '-itps'\n"); return FALSE; } @@ -703,13 +705,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%d", &ncols) != 1) { - REprintf( "ERROR: parsing number of cols\n"); + fprintf(stderr, "ERROR: parsing number of cols\n"); return FALSE; } } else { - REprintf( "ERROR: reading line with number of cols\n"); + fprintf(stderr, "ERROR: reading line with number of cols\n"); return FALSE; } I32 nrows; @@ -717,13 +719,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%d", &nrows) != 1) { - REprintf( "ERROR: parsing number of rows\n"); + fprintf(stderr, "ERROR: parsing number of rows\n"); return FALSE; } } else { - REprintf( "ERROR: reading line with number of rows\n"); + fprintf(stderr, "ERROR: reading line with number of rows\n"); return FALSE; } npoints = (I64)ncols*(I64)nrows; @@ -756,13 +758,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%lf %lf %lf", &(translation[0]), &(translation[1]), &(translation[2])) != 3) { - REprintf( "ERROR: parsing translation\n"); + fprintf(stderr, "ERROR: parsing translation\n"); return FALSE; } } else { - REprintf( "ERROR: reading line with translation\n"); + fprintf(stderr, "ERROR: reading line with translation\n"); return FALSE; } F64 rotation_row_0[3]; @@ -770,13 +772,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%lf %lf %lf", &(rotation_row_0[0]), &(rotation_row_0[1]), &(rotation_row_0[2])) != 3) { - REprintf( "ERROR: parsing rotation row 0\n"); + fprintf(stderr, "ERROR: parsing rotation row 0\n"); return FALSE; } } else { - REprintf( "ERROR: reading line with rotation row 0\n"); + fprintf(stderr, "ERROR: reading line with rotation row 0\n"); return FALSE; } F64 rotation_row_1[3]; @@ -784,13 +786,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%lf %lf %lf", &(rotation_row_1[0]), &(rotation_row_1[1]), &(rotation_row_1[2])) != 3) { - REprintf( "ERROR: parsing rotation row 1\n"); + fprintf(stderr, "ERROR: parsing rotation row 1\n"); return FALSE; } } else { - REprintf( "ERROR: reading line with rotation row 1\n"); + fprintf(stderr, "ERROR: reading line with rotation row 1\n"); return FALSE; } F64 rotation_row_2[3]; @@ -798,13 +800,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%lf %lf %lf", &(rotation_row_2[0]), &(rotation_row_2[1]), &(rotation_row_2[2])) != 3) { - REprintf( "ERROR: parsing rotation row 2\n"); + fprintf(stderr, "ERROR: parsing rotation row 2\n"); return FALSE; } } else { - REprintf( "ERROR: reading line with rotation row 2\n"); + fprintf(stderr, "ERROR: reading line with rotation row 2\n"); return FALSE; } F64 transformation_row_0[4]; @@ -812,13 +814,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%lf %lf %lf %lf", &(transformation_row_0[0]), &(transformation_row_0[1]), &(transformation_row_0[2]), &(transformation_row_0[3])) != 4) { - REprintf( "ERROR: parsing transformation row 0\n"); + fprintf(stderr, "ERROR: parsing transformation row 0\n"); return FALSE; } } else { - REprintf( "ERROR: reading line with transformation row 0\n"); + fprintf(stderr, "ERROR: reading line with transformation row 0\n"); return FALSE; } F64 transformation_row_1[4]; @@ -826,13 +828,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%lf %lf %lf %lf", &(transformation_row_1[0]), &(transformation_row_1[1]), &(transformation_row_1[2]), &(transformation_row_1[3])) != 4) { - REprintf( "ERROR: parsing transformation row 1\n"); + fprintf(stderr, "ERROR: parsing transformation row 1\n"); return FALSE; } } else { - REprintf( "ERROR: reading line with transformation row 1\n"); + fprintf(stderr, "ERROR: reading line with transformation row 1\n"); return FALSE; } F64 transformation_row_2[4]; @@ -840,13 +842,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%lf %lf %lf %lf", &(transformation_row_2[0]), &(transformation_row_2[1]), &(transformation_row_2[2]), &(transformation_row_2[3])) != 4) { - REprintf( "ERROR: parsing transformation row 2\n"); + fprintf(stderr, "ERROR: parsing transformation row 2\n"); return FALSE; } } else { - REprintf( "ERROR: reading line with transformation row 2\n"); + fprintf(stderr, "ERROR: reading line with transformation row 2\n"); return FALSE; } F64 transformation_row_3[4]; @@ -854,13 +856,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%lf %lf %lf %lf", &(transformation_row_3[0]), &(transformation_row_3[1]), &(transformation_row_3[2]), &(transformation_row_3[3])) != 4) { - REprintf( "ERROR: parsing transformation row 3\n"); + fprintf(stderr, "ERROR: parsing transformation row 3\n"); return FALSE; } } else { - REprintf( "ERROR: reading line with transformation row 3\n"); + fprintf(stderr, "ERROR: reading line with transformation row 3\n"); return FALSE; } @@ -919,6 +921,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const } } + // maybe attributes in extra bytes + + if (header.number_attributes) + { + header.update_extra_bytes_vlr(); + } + // read the first line with full parse_string i = 0; @@ -933,7 +942,7 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const else { line[strlen(line)-1] = '\0'; - REprintf( "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, this->parse_string); + fprintf(stderr, "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, this->parse_string); } } @@ -941,7 +950,7 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const if (i != 1) { - REprintf( "ERROR: could not parse any lines with '%s'\n", this->parse_string); + fprintf(stderr, "ERROR: could not parse any lines with '%s'\n", this->parse_string); fclose(this->file); this->file = 0; free(this->parse_string); @@ -1086,7 +1095,7 @@ BOOL LASreaderTXT::seek(const I64 p_index) fseek(file, 0, SEEK_SET); // skip lines if we have to int i; - for (i = 0; i < skip_lines; i++) if (fgets(line, 512, file)); + for (i = 0; i < skip_lines; i++) fgets(line, 512, file); // read the first line with full parse_string i = 0; while (fgets(line, 512, file)) @@ -1100,13 +1109,13 @@ BOOL LASreaderTXT::seek(const I64 p_index) else { line[strlen(line)-1] = '\0'; - REprintf( "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, this->parse_string); + fprintf(stderr, "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, this->parse_string); } } // did we manage to parse a line if (i != 1) { - REprintf( "ERROR: could not parse any lines with '%s'\n", this->parse_string); + fprintf(stderr, "ERROR: could not parse any lines with '%s'\n", this->parse_string); fclose(file); file = 0; free(this->parse_string); @@ -1139,7 +1148,7 @@ BOOL LASreaderTXT::read_point_default() else { line[strlen(line)-1] = '\0'; - REprintf( "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, this->parse_string); + fprintf(stderr, "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, this->parse_string); } } else @@ -1149,9 +1158,9 @@ BOOL LASreaderTXT::read_point_default() if (p_count != npoints) { #ifdef _WIN32 - REprintf("WARNING: end-of-file after %I64d of %I64d points\n", p_count, npoints); + fprintf(stderr,"WARNING: end-of-file after %I64d of %I64d points\n", p_count, npoints); #else - REprintf("WARNING: end-of-file after %lld of %lld points\n", p_count, npoints); + fprintf(stderr,"WARNING: end-of-file after %lld of %lld points\n", p_count, npoints); #endif } } @@ -1162,9 +1171,9 @@ BOOL LASreaderTXT::read_point_default() if (p_count != npoints) { #ifdef _WIN32 - REprintf("WARNING: end-of-file after %I64d of %I64d points\n", p_count, npoints); + fprintf(stderr,"WARNING: end-of-file after %I64d of %I64d points\n", p_count, npoints); #else - REprintf("WARNING: end-of-file after %lld of %lld points\n", p_count, npoints); + fprintf(stderr,"WARNING: end-of-file after %lld of %lld points\n", p_count, npoints); #endif } } @@ -1176,9 +1185,9 @@ BOOL LASreaderTXT::read_point_default() } } // compute the quantized x, y, and z values - point.set_X(header.get_X(point.coordinates[0])); - point.set_Y(header.get_Y(point.coordinates[1])); - point.set_Z(header.get_Z(point.coordinates[2])); + point.set_X((I32)header.get_X(point.coordinates[0])); + point.set_Y((I32)header.get_Y(point.coordinates[1])); + point.set_Z((I32)header.get_Z(point.coordinates[2])); p_count++; if (!populated_header) { @@ -1237,25 +1246,25 @@ BOOL LASreaderTXT::reopen(const char* file_name) if (file_name == 0) { - REprintf("ERROR: file name pointer is zero\n"); + fprintf(stderr,"ERROR: file name pointer is zero\n"); return FALSE; } file = fopen_compressed(file_name, "r", &piped); if (file == 0) { - REprintf( "ERROR: cannot reopen file '%s'\n", file_name); + fprintf(stderr, "ERROR: cannot reopen file '%s'\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, 10*LAS_TOOLS_IO_IBUFFER_SIZE) != 0) { - REprintf( "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); + fprintf(stderr, "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); } // skip lines if we have to - for (i = 0; i < skip_lines; i++) if (fgets(line, 512, file)); + for (i = 0; i < skip_lines; i++) fgets(line, 512, file); // read the first line with full parse_string @@ -1271,7 +1280,7 @@ BOOL LASreaderTXT::reopen(const char* file_name) else { line[strlen(line)-1] = '\0'; - REprintf( "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_string); + fprintf(stderr, "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_string); } } @@ -1279,7 +1288,7 @@ BOOL LASreaderTXT::reopen(const char* file_name) if (i != 1) { - REprintf( "ERROR: could not parse any lines with '%s'\n", parse_string); + fprintf(stderr, "ERROR: could not parse any lines with '%s'\n", parse_string); fclose(file); file = 0; return FALSE; @@ -1372,7 +1381,7 @@ BOOL LASreaderTXT::parse_attribute(const char* l, I32 index) } if (temp_i < U8_MIN || temp_i > U8_MAX) { - REprintf( "WARNING: attribute %d of type U8 is %d. clamped to [%d %d] range.\n", index, temp_i, U8_MIN, U8_MAX); + fprintf(stderr, "WARNING: attribute %d of type U8 is %d. clamped to [%d %d] range.\n", index, temp_i, U8_MIN, U8_MAX); point.set_attribute(attribute_starts[index], U8_CLAMP(temp_i)); } else @@ -1397,7 +1406,7 @@ BOOL LASreaderTXT::parse_attribute(const char* l, I32 index) } if (temp_i < I8_MIN || temp_i > I8_MAX) { - REprintf( "WARNING: attribute %d of type I8 is %d. clamped to [%d %d] range.\n", index, temp_i, I8_MIN, I8_MAX); + fprintf(stderr, "WARNING: attribute %d of type I8 is %d. clamped to [%d %d] range.\n", index, temp_i, I8_MIN, I8_MAX); point.set_attribute(attribute_starts[index], I8_CLAMP(temp_i)); } else @@ -1422,7 +1431,7 @@ BOOL LASreaderTXT::parse_attribute(const char* l, I32 index) } if (temp_i < U16_MIN || temp_i > U16_MAX) { - REprintf( "WARNING: attribute %d of type U16 is %d. clamped to [%d %d] range.\n", index, temp_i, U16_MIN, U16_MAX); + fprintf(stderr, "WARNING: attribute %d of type U16 is %d. clamped to [%d %d] range.\n", index, temp_i, U16_MIN, U16_MAX); point.set_attribute(attribute_starts[index], U16_CLAMP(temp_i)); } else @@ -1447,7 +1456,7 @@ BOOL LASreaderTXT::parse_attribute(const char* l, I32 index) } if (temp_i < I16_MIN || temp_i > I16_MAX) { - REprintf( "WARNING: attribute %d of type I16 is %d. clamped to [%d %d] range.\n", index, temp_i, I16_MIN, I16_MAX); + fprintf(stderr, "WARNING: attribute %d of type I16 is %d. clamped to [%d %d] range.\n", index, temp_i, I16_MIN, I16_MAX); point.set_attribute(attribute_starts[index], I16_CLAMP(temp_i)); } else @@ -1500,7 +1509,7 @@ BOOL LASreaderTXT::parse_attribute(const char* l, I32 index) } else { - REprintf( "WARNING: attribute %d not (yet) implemented.\n", index); + fprintf(stderr, "WARNING: attribute %d not (yet) implemented.\n", index); return FALSE; } return TRUE; @@ -1588,7 +1597,7 @@ BOOL LASreaderTXT::parse(const char* parse_string) if (sscanf(l, "%f", &temp_f) != 1) return FALSE; if (translate_intensity != 0.0f) temp_f = temp_f+translate_intensity; if (scale_intensity != 1.0f) temp_f = temp_f*scale_intensity; - if (temp_f < 0.0f || temp_f >= 65535.5f) REprintf( "WARNING: intensity %g is out of range of unsigned short\n", temp_f); + if (temp_f < 0.0f || temp_f >= 65535.5f) fprintf(stderr, "WARNING: intensity %g is out of range of unsigned short\n", temp_f); point.set_intensity(U16_QUANTIZE(temp_f)); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1599,7 +1608,7 @@ BOOL LASreaderTXT::parse(const char* parse_string) if (sscanf(l, "%f", &temp_f) != 1) return FALSE; if (translate_scan_angle != 0.0f) temp_f = temp_f+translate_scan_angle; if (scale_scan_angle != 1.0f) temp_f = temp_f*scale_scan_angle; - if (temp_f < -128.0f || temp_f > 127.0f) REprintf( "WARNING: scan angle %g is out of range of char\n", temp_f); + if (temp_f < -128.0f || temp_f > 127.0f) fprintf(stderr, "WARNING: scan angle %g is out of range of char\n", temp_f); point.set_scan_angle(temp_f); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1610,12 +1619,12 @@ BOOL LASreaderTXT::parse(const char* parse_string) if (sscanf(l, "%d", &temp_i) != 1) return FALSE; if (point_type > 5) { - if (temp_i < 0 || temp_i > 15) REprintf( "WARNING: number of returns of given pulse %d is out of range of four bits\n", temp_i); + if (temp_i < 0 || temp_i > 15) fprintf(stderr, "WARNING: number of returns of given pulse %d is out of range of four bits\n", temp_i); point.set_extended_number_of_returns(temp_i & 15); } else { - if (temp_i < 0 || temp_i > 7) REprintf( "WARNING: number of returns of given pulse %d is out of range of three bits\n", temp_i); + if (temp_i < 0 || temp_i > 7) fprintf(stderr, "WARNING: number of returns of given pulse %d is out of range of three bits\n", temp_i); point.set_number_of_returns(temp_i & 7); } while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space @@ -1627,12 +1636,12 @@ BOOL LASreaderTXT::parse(const char* parse_string) if (sscanf(l, "%d", &temp_i) != 1) return FALSE; if (point_type > 5) { - if (temp_i < 0 || temp_i > 15) REprintf( "WARNING: return number %d is out of range of four bits\n", temp_i); + if (temp_i < 0 || temp_i > 15) fprintf(stderr, "WARNING: return number %d is out of range of four bits\n", temp_i); point.set_extended_return_number(temp_i & 15); } else { - if (temp_i < 0 || temp_i > 7) REprintf( "WARNING: return number %d is out of range of three bits\n", temp_i); + if (temp_i < 0 || temp_i > 7) fprintf(stderr, "WARNING: return number %d is out of range of three bits\n", temp_i); point.set_return_number(temp_i & 7); } while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space @@ -1642,7 +1651,7 @@ BOOL LASreaderTXT::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 1) REprintf( "WARNING: withheld flag %d is out of range of single bit\n", temp_i); + if (temp_i < 0 || temp_i > 1) fprintf(stderr, "WARNING: withheld flag %d is out of range of single bit\n", temp_i); point.set_withheld_flag(temp_i ? 1 : 0); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1651,7 +1660,7 @@ BOOL LASreaderTXT::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 1) REprintf( "WARNING: keypoint flag %d is out of range of single bit\n", temp_i); + if (temp_i < 0 || temp_i > 1) fprintf(stderr, "WARNING: keypoint flag %d is out of range of single bit\n", temp_i); point.set_keypoint_flag(temp_i ? 1 : 0); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1660,7 +1669,7 @@ BOOL LASreaderTXT::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 1) REprintf( "WARNING: keypoint flag %d is out of range of single bit\n", temp_i); + if (temp_i < 0 || temp_i > 1) fprintf(stderr, "WARNING: keypoint flag %d is out of range of single bit\n", temp_i); point.set_synthetic_flag(temp_i ? 1 : 0); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1669,7 +1678,7 @@ BOOL LASreaderTXT::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 1) REprintf( "WARNING: overlap flag %d is out of range of single bit\n", temp_i); + if (temp_i < 0 || temp_i > 1) fprintf(stderr, "WARNING: overlap flag %d is out of range of single bit\n", temp_i); point.set_extended_overlap_flag(temp_i ? 1 : 0); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1678,7 +1687,7 @@ BOOL LASreaderTXT::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 3) REprintf( "WARNING: scanner channel %d is out of range of two bits\n", temp_i); + if (temp_i < 0 || temp_i > 3) fprintf(stderr, "WARNING: scanner channel %d is out of range of two bits\n", temp_i); point.extended_scanner_channel = temp_i & 3; while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1687,7 +1696,7 @@ BOOL LASreaderTXT::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 3) REprintf( "WARNING: terrasolid echo encoding %d is out of range of 0 to 3\n", temp_i); + if (temp_i < 0 || temp_i > 3) fprintf(stderr, "WARNING: terrasolid echo encoding %d is out of range of 0 to 3\n", temp_i); if (temp_i == 0) // only echo { point.number_of_returns = 1; @@ -1715,14 +1724,35 @@ BOOL LASreaderTXT::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 255) + if (temp_i < 0) { - REprintf( "WARNING: classification %d is out of range of unsigned char\n", temp_i); - point.set_classification(U8_CLAMP(temp_i)); + fprintf(stderr, "WARNING: classification %d is negative. zeroing ...\n", temp_i); + point.set_classification(0); + point.set_extended_classification(0); + } + else if (point.extended_point_type) + { + if (temp_i > 255) + { + fprintf(stderr, "WARNING: extended classification %d is larger than 255. clamping ...\n", temp_i); + point.set_extended_classification(255); + } + else + { + point.set_extended_classification((U8)temp_i); + } } else { - point.set_classification((U8)temp_i); + if (temp_i > 31) + { + fprintf(stderr, "WARNING: classification %d is larger than 31. clamping ...\n", temp_i); + point.set_classification(31); + } + else + { + point.set_classification((U8)temp_i); + } } while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1733,7 +1763,7 @@ BOOL LASreaderTXT::parse(const char* parse_string) if (sscanf(l, "%d", &temp_i) != 1) return FALSE; if (temp_i < 0 || temp_i > 255) { - REprintf( "WARNING: user data %d is out of range of unsigned char\n", temp_i); + fprintf(stderr, "WARNING: user data %d is out of range of unsigned char\n", temp_i); point.set_user_data(U8_CLAMP(temp_i)); } else @@ -1749,7 +1779,7 @@ BOOL LASreaderTXT::parse(const char* parse_string) if (sscanf(l, "%d", &temp_i) != 1) return FALSE; if (temp_i < 0 || temp_i > 65535) { - REprintf( "WARNING: point source ID %d is out of range of unsigned short\n", temp_i); + fprintf(stderr, "WARNING: point source ID %d is out of range of unsigned short\n", temp_i); point.set_point_source_ID(U16_CLAMP(temp_i)); } else @@ -1763,7 +1793,7 @@ BOOL LASreaderTXT::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 1) REprintf( "WARNING: edge of flight line flag %d is out of range of boolean flag\n", temp_i); + if (temp_i < 0 || temp_i > 1) fprintf(stderr, "WARNING: edge of flight line flag %d is out of range of boolean flag\n", temp_i); point.edge_of_flight_line = (temp_i ? 1 : 0); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1772,7 +1802,7 @@ BOOL LASreaderTXT::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 1) REprintf( "WARNING: direction of scan flag %d is out of range of boolean flag\n", temp_i); + if (temp_i < 0 || temp_i > 1) fprintf(stderr, "WARNING: direction of scan flag %d is out of range of boolean flag\n", temp_i); point.scan_direction_flag = (temp_i ? 1 : 0); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1805,13 +1835,13 @@ BOOL LASreaderTXT::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';' || l[0] == '\"')) l++; // first skip white spaces and quotes if (l[0] == 0) return FALSE; hex_string[0] = l[0]; hex_string[1] = l[1]; - sscanf(hex_string,"%d",&hex_value); + sscanf(hex_string,"%x",&hex_value); point.rgb[0] = hex_value; hex_string[0] = l[2]; hex_string[1] = l[3]; - sscanf(hex_string,"%d",&hex_value); + sscanf(hex_string,"%x",&hex_value); point.rgb[1] = hex_value; hex_string[0] = l[4]; hex_string[1] = l[5]; - sscanf(hex_string,"%d",&hex_value); + sscanf(hex_string,"%x",&hex_value); point.rgb[2] = hex_value; l+=6; while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space @@ -1821,14 +1851,14 @@ BOOL LASreaderTXT::parse(const char* parse_string) I32 hex_value; while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';' || l[0] == '\"')) l++; // first skip white spaces and quotes if (l[0] == 0) return FALSE; - sscanf(l,"%d",&hex_value); + sscanf(l,"%x",&hex_value); point.intensity = U8_CLAMP(((F64)hex_value/(F64)0xFFFFFF)*255); l+=6; while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } else { - REprintf( "ERROR: unknown symbol '%c' in parse string\n", p[0]); + fprintf(stderr, "ERROR: unknown symbol '%c' in parse string\n", p[0]); } p++; } @@ -1872,7 +1902,7 @@ BOOL LASreaderTXT::check_parse_string(const char* parse_string) I32 index = (I32)(p[0] - '0'); if (index >= header.number_attributes) { - REprintf( "ERROR: extra bytes attribute '%d' was not described.\n", index); + fprintf(stderr, "ERROR: extra bytes attribute '%d' was not described.\n", index); return FALSE; } attribute_starts[index] = header.get_attribute_start(index); @@ -1890,53 +1920,53 @@ BOOL LASreaderTXT::check_parse_string(const char* parse_string) } if (index >= header.number_attributes) { - REprintf( "ERROR: extra bytes attribute '%d' was not described.\n", index); + fprintf(stderr, "ERROR: extra bytes attribute '%d' was not described.\n", index); return FALSE; } if (p[0] != ')') { - REprintf( "ERROR: extra bytes attribute '%d' misses closing bracket.\n", index); + fprintf(stderr, "ERROR: extra bytes attribute '%d' misses closing bracket.\n", index); return FALSE; } attribute_starts[index] = header.get_attribute_start(index); } else { - REprintf( "ERROR: parse string opening bracket '(' misses extra bytes index.\n"); + fprintf(stderr, "ERROR: parse string opening bracket '(' misses extra bytes index.\n"); return FALSE; } } else { - REprintf( "ERROR: unknown symbol '%c' in parse string. valid are\n", p[0]); - REprintf( " 'x' : the coordinate\n"); - REprintf( " 'y' : the coordinate\n"); - REprintf( " 'z' : the coordinate\n"); - REprintf( " 't' : the gps ime\n"); - REprintf( " 'R' : the ed channel of the RGB field\n"); - REprintf( " 'G' : the reen channel of the RGB field\n"); - REprintf( " 'B' : the lue channel of the RGB field\n"); - REprintf( " 'I' : the NR channel of LAS 1.4 point type 8\n"); - REprintf( " 's' : kip a string or a number that we don't care about\n"); - REprintf( " 'i' : the ntensity\n"); - REprintf( " 'a' : the scan ngle\n"); - REprintf( " 'n' : the umber of returns of that given pulse\n"); - REprintf( " 'r' : the number of the eturn\n"); - REprintf( " 'h' : the witheld flag\n"); - REprintf( " 'k' : the eypoint flag\n"); - REprintf( " 'g' : the synthetic fla\n"); - REprintf( " 'o' : the verlap flag of LAS 1.4 point types 6, 7, 8\n"); - REprintf( " 'l' : the scanner channe of LAS 1.4 point types 6, 7, 8\n"); - REprintf( " 'E' : terrasolid hco Encoding\n"); - REprintf( " 'c' : the lassification\n"); - REprintf( " 'u' : the ser data\n"); - REprintf( " 'p' : the

oint source ID\n"); - REprintf( " 'e' : the dge of flight line flag\n"); - REprintf( " 'd' : the irection of scan flag\n"); - REprintf( " '0'-'9' : additional attributes described as extra bytes (0 through 9)\n"); - REprintf( " '(13)' : additional attributes described as extra bytes (10 and up)\n"); - REprintf( " 'H' : a hexadecimal string encoding the RGB color\n"); - REprintf( " 'J' : a hexadecimal string encoding the intensity\n"); + fprintf(stderr, "ERROR: unknown symbol '%c' in parse string. valid are\n", p[0]); + fprintf(stderr, " 'x' : the coordinate\n"); + fprintf(stderr, " 'y' : the coordinate\n"); + fprintf(stderr, " 'z' : the coordinate\n"); + fprintf(stderr, " 't' : the gps ime\n"); + fprintf(stderr, " 'R' : the ed channel of the RGB field\n"); + fprintf(stderr, " 'G' : the reen channel of the RGB field\n"); + fprintf(stderr, " 'B' : the lue channel of the RGB field\n"); + fprintf(stderr, " 'I' : the NR channel of LAS 1.4 point type 8\n"); + fprintf(stderr, " 's' : kip a string or a number that we don't care about\n"); + fprintf(stderr, " 'i' : the ntensity\n"); + fprintf(stderr, " 'a' : the scan ngle\n"); + fprintf(stderr, " 'n' : the umber of returns of that given pulse\n"); + fprintf(stderr, " 'r' : the number of the eturn\n"); + fprintf(stderr, " 'h' : the witheld flag\n"); + fprintf(stderr, " 'k' : the eypoint flag\n"); + fprintf(stderr, " 'g' : the synthetic fla\n"); + fprintf(stderr, " 'o' : the verlap flag of LAS 1.4 point types 6, 7, 8\n"); + fprintf(stderr, " 'l' : the scanner channe of LAS 1.4 point types 6, 7, 8\n"); + fprintf(stderr, " 'E' : terrasolid hco Encoding\n"); + fprintf(stderr, " 'c' : the lassification\n"); + fprintf(stderr, " 'u' : the ser data\n"); + fprintf(stderr, " 'p' : the

oint source ID\n"); + fprintf(stderr, " 'e' : the dge of flight line flag\n"); + fprintf(stderr, " 'd' : the irection of scan flag\n"); + fprintf(stderr, " '0'-'9' : additional attributes described as extra bytes (0 through 9)\n"); + fprintf(stderr, " '(13)' : additional attributes described as extra bytes (10 and up)\n"); + fprintf(stderr, " 'H' : a hexadecimal string encoding the RGB color\n"); + fprintf(stderr, " 'J' : a hexadecimal string encoding the intensity\n"); return FALSE; } } @@ -1999,19 +2029,19 @@ void LASreaderTXT::populate_bounding_box() { // compute quantized and then unquantized bounding box - F64 dequant_min_x = header.get_x(header.get_X(header.min_x)); - F64 dequant_max_x = header.get_x(header.get_X(header.max_x)); - F64 dequant_min_y = header.get_y(header.get_Y(header.min_y)); - F64 dequant_max_y = header.get_y(header.get_Y(header.max_y)); - F64 dequant_min_z = header.get_z(header.get_Z(header.min_z)); - F64 dequant_max_z = header.get_z(header.get_Z(header.max_z)); + F64 dequant_min_x = header.get_x((I32)(header.get_X(header.min_x))); + F64 dequant_max_x = header.get_x((I32)(header.get_X(header.max_x))); + F64 dequant_min_y = header.get_y((I32)(header.get_Y(header.min_y))); + F64 dequant_max_y = header.get_y((I32)(header.get_Y(header.max_y))); + F64 dequant_min_z = header.get_z((I32)(header.get_Z(header.min_z))); + F64 dequant_max_z = header.get_z((I32)(header.get_Z(header.max_z))); // make sure there is not sign flip if ((header.min_x > 0) != (dequant_min_x > 0)) { - REprintf( "WARNING: quantization sign flip for min_x from %g to %g.\n", header.min_x, dequant_min_x); - REprintf( " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for min_x from %g to %g.\n", header.min_x, dequant_min_x); + fprintf(stderr, " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); } else { @@ -2019,8 +2049,8 @@ void LASreaderTXT::populate_bounding_box() } if ((header.max_x > 0) != (dequant_max_x > 0)) { - REprintf( "WARNING: quantization sign flip for max_x from %g to %g.\n", header.max_x, dequant_max_x); - REprintf( " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for max_x from %g to %g.\n", header.max_x, dequant_max_x); + fprintf(stderr, " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); } else { @@ -2028,8 +2058,8 @@ void LASreaderTXT::populate_bounding_box() } if ((header.min_y > 0) != (dequant_min_y > 0)) { - REprintf( "WARNING: quantization sign flip for min_y from %g to %g.\n", header.min_y, dequant_min_y); - REprintf( " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for min_y from %g to %g.\n", header.min_y, dequant_min_y); + fprintf(stderr, " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); } else { @@ -2037,8 +2067,8 @@ void LASreaderTXT::populate_bounding_box() } if ((header.max_y > 0) != (dequant_max_y > 0)) { - REprintf( "WARNING: quantization sign flip for max_y from %g to %g.\n", header.max_y, dequant_max_y); - REprintf( " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for max_y from %g to %g.\n", header.max_y, dequant_max_y); + fprintf(stderr, " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); } else { @@ -2046,8 +2076,8 @@ void LASreaderTXT::populate_bounding_box() } if ((header.min_z > 0) != (dequant_min_z > 0)) { - REprintf( "WARNING: quantization sign flip for min_z from %g to %g.\n", header.min_z, dequant_min_z); - REprintf( " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for min_z from %g to %g.\n", header.min_z, dequant_min_z); + fprintf(stderr, " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); } else { @@ -2055,8 +2085,8 @@ void LASreaderTXT::populate_bounding_box() } if ((header.max_z > 0) != (dequant_max_z > 0)) { - REprintf( "WARNING: quantization sign flip for max_z from %g to %g.\n", header.max_z, dequant_max_z); - REprintf( " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); + fprintf(stderr, "WARNING: quantization sign flip for max_z from %g to %g.\n", header.max_z, dequant_max_z); + fprintf(stderr, " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); } else { diff --git a/inst/include/lasreader_txt.hpp b/src/LASlib/lasreader_txt.hpp similarity index 100% rename from inst/include/lasreader_txt.hpp rename to src/LASlib/lasreader_txt.hpp diff --git a/src/LASlib/lasreaderbuffered.cpp b/src/LASlib/lasreaderbuffered.cpp index 71ac57f..6ebc025 100644 --- a/src/LASlib/lasreaderbuffered.cpp +++ b/src/LASlib/lasreaderbuffered.cpp @@ -96,14 +96,14 @@ BOOL LASreaderBuffered::set_file_name(const char* file_name) // do we have a file name if (file_name == 0) { - REprintf( "ERROR: file name pointer is NULL\n"); + fprintf(stderr, "ERROR: file name pointer is NULL\n"); return FALSE; } // does the file exist FILE* file = fopen(file_name, "r"); if (file == 0) { - REprintf( "ERROR: file '%s' cannot be opened\n", file_name); + fprintf(stderr, "ERROR: file '%s' cannot be opened\n", file_name); return FALSE; } fclose(file); @@ -117,14 +117,14 @@ BOOL LASreaderBuffered::add_neighbor_file_name(const char* file_name) // do we have a file name if (file_name == 0) { - REprintf( "ERROR: file name pointer is NULL\n"); + fprintf(stderr, "ERROR: file name pointer is NULL\n"); return FALSE; } // does the file exist FILE* file = fopen(file_name, "r"); if (file == 0) { - REprintf( "ERROR: file '%s' cannot be opened\n", file_name); + fprintf(stderr, "ERROR: file '%s' cannot be opened\n", file_name); return FALSE; } fclose(file); @@ -142,7 +142,7 @@ BOOL LASreaderBuffered::open() { if (!lasreadopener.active()) { - REprintf( "ERROR: no input name\n"); + fprintf(stderr, "ERROR: no input name\n"); return FALSE; } @@ -151,7 +151,7 @@ BOOL LASreaderBuffered::open() lasreader = lasreadopener.open(); if (lasreader == 0) { - REprintf( "ERROR: opening '%s'\n", lasreadopener.get_file_name()); + fprintf(stderr, "ERROR: opening '%s'\n", lasreadopener.get_file_name()); return FALSE; } @@ -204,20 +204,20 @@ BOOL LASreaderBuffered::open() LASreader* lasreader_neighbor = lasreadopener_neighbors.open(); if (lasreader_neighbor == 0) { - REprintf( "ERROR: opening neighbor '%s'\n", lasreadopener_neighbors.get_file_name()); + fprintf(stderr, "ERROR: opening neighbor '%s'\n", lasreadopener_neighbors.get_file_name()); return FALSE; } // a point type change could be problematic if (header.point_data_format != lasreader_neighbor->header.point_data_format) { - if (!point_type_change) REprintf( "WARNING: files have different point types: %d vs %d\n", header.point_data_format, lasreader_neighbor->header.point_data_format); + if (!point_type_change) fprintf(stderr, "WARNING: files have different point types: %d vs %d\n", header.point_data_format, lasreader_neighbor->header.point_data_format); point_type_change = TRUE; } // a point size change could be problematic if (header.point_data_record_length != lasreader_neighbor->header.point_data_record_length) { - if (!point_size_change) REprintf( "WARNING: files have different point sizes: %d vs %d\n", header.point_data_record_length, lasreader_neighbor->header.point_data_record_length); + if (!point_size_change) fprintf(stderr, "WARNING: files have different point sizes: %d vs %d\n", header.point_data_record_length, lasreader_neighbor->header.point_data_record_length); point_size_change = TRUE; } @@ -271,7 +271,7 @@ BOOL LASreaderBuffered::open() header.extended_number_of_point_records += buffered_points; } - REprintf( "LASreaderBuffered: adding %u buffer points.\n", buffered_points); + fprintf(stderr, "LASreaderBuffered: adding %u buffer points.\n", buffered_points); } // check if the header can support the enlarged bounding box @@ -289,14 +289,14 @@ BOOL LASreaderBuffered::open() } if (header.x_scale_factor != x_scale_factor) { - REprintf( "WARNING: i changed x_scale_factor from %g to %g to accommodate enlarged bounding box\n", header.x_scale_factor, x_scale_factor); + fprintf(stderr, "WARNING: i changed x_scale_factor from %g to %g to accommodate enlarged bounding box\n", header.x_scale_factor, x_scale_factor); header.x_scale_factor = x_scale_factor; rescale = TRUE; } // maybe we changed the resolution ... so do we really need to adjuste the offset if ((((header.max_x - header.x_offset) / x_scale_factor) > I32_MAX) || (((header.min_x - header.x_offset) / x_scale_factor) < I32_MIN)) { - REprintf( "WARNING: i changed x_offset from %g to %g to accommodate enlarged bounding box\n", header.x_offset, x_offset); + fprintf(stderr, "WARNING: i changed x_offset from %g to %g to accommodate enlarged bounding box\n", header.x_offset, x_offset); header.x_offset = x_offset; reoffset = TRUE; } @@ -315,14 +315,14 @@ BOOL LASreaderBuffered::open() } if (header.y_scale_factor != y_scale_factor) { - REprintf( "WARNING: i changed y_scale_factor from %g to %g to accommodate enlarged bounding box\n", header.y_scale_factor, y_scale_factor); + fprintf(stderr, "WARNING: i changed y_scale_factor from %g to %g to accommodate enlarged bounding box\n", header.y_scale_factor, y_scale_factor); header.y_scale_factor = y_scale_factor; rescale = TRUE; } // maybe we changed the resolution ... so do we really need to adjuste the offset if ((((header.max_y - header.y_offset) / y_scale_factor) > I32_MAX) || (((header.min_y - header.y_offset) / y_scale_factor) < I32_MIN)) { - REprintf( "WARNING: i changed y_offset from %g to %g to accommodate enlarged bounding box\n", header.y_offset, y_offset); + fprintf(stderr, "WARNING: i changed y_offset from %g to %g to accommodate enlarged bounding box\n", header.y_offset, y_offset); header.y_offset = y_offset; reoffset = TRUE; } @@ -341,14 +341,14 @@ BOOL LASreaderBuffered::open() } if (header.z_scale_factor != z_scale_factor) { - REprintf( "WARNING: i changed z_scale_factor from %g to %g to accommodate enlarged bounding box\n", header.z_scale_factor, z_scale_factor); + fprintf(stderr, "WARNING: i changed z_scale_factor from %g to %g to accommodate enlarged bounding box\n", header.z_scale_factor, z_scale_factor); header.z_scale_factor = z_scale_factor; rescale = TRUE; } // maybe we changed the resolution ... so do we really need to adjuste the offset if ((((header.max_z - header.z_offset) / z_scale_factor) > I32_MAX) || (((header.min_z - header.z_offset) / z_scale_factor) < I32_MIN)) { - REprintf( "WARNING: i changed z_offset from %g to %g to accommodate enlarged bounding box\n", header.z_offset, z_offset); + fprintf(stderr, "WARNING: i changed z_offset from %g to %g to accommodate enlarged bounding box\n", header.z_offset, z_offset); header.z_offset = z_offset; reoffset = TRUE; } diff --git a/inst/include/lasreaderbuffered.hpp b/src/LASlib/lasreaderbuffered.hpp similarity index 100% rename from inst/include/lasreaderbuffered.hpp rename to src/LASlib/lasreaderbuffered.hpp diff --git a/src/LASlib/lasreadermerged.cpp b/src/LASlib/lasreadermerged.cpp index be8d75c..09f0e17 100644 --- a/src/LASlib/lasreadermerged.cpp +++ b/src/LASlib/lasreadermerged.cpp @@ -13,7 +13,7 @@ COPYRIGHT: - (c) 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality + (c) 2007-2019, martin isenburg, rapidlasso - fast tools to catch reality This is free software; you can redistribute and/or modify it under the terms of the GNU Lesser General Licence as published by the Free Software @@ -42,19 +42,19 @@ void LASreaderMerged::set_io_ibuffer_size(I32 io_ibuffer_size) this->io_ibuffer_size = io_ibuffer_size; } -BOOL LASreaderMerged::add_file_name(const char* file_name) +BOOL LASreaderMerged::add_file_name(const CHAR* file_name) { // do we have a file name if (file_name == 0) { - REprintf( "ERROR: file name pointer is NULL\n"); + fprintf(stderr, "ERROR: file name pointer is NULL\n"); return FALSE; } // does the file exist FILE* file = fopen(file_name, "r"); if (file == 0) { - REprintf( "ERROR: file '%s' cannot be opened\n", file_name); + fprintf(stderr, "ERROR: file '%s' cannot be opened\n", file_name); return FALSE; } fclose(file); @@ -63,42 +63,42 @@ BOOL LASreaderMerged::add_file_name(const char* file_name) { if (lasreaderbin) { - REprintf( "ERROR: cannot mix BIN with LAS. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix BIN with LAS. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadershp) { - REprintf( "ERROR: cannot mix SHP with LAS. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix SHP with LAS. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderasc) { - REprintf( "ERROR: cannot mix ASC with LAS. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix ASC with LAS. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbil) { - REprintf( "ERROR: cannot mix BIL with LAS. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix BIL with LAS. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderdtm) { - REprintf( "ERROR: cannot mix DTM with LAS. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix DTM with LAS. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderply) { - REprintf( "ERROR: cannot mix PLY with LAS. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix PLY with LAS. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderqfit) { - REprintf( "ERROR: cannot mix QFIT with LAS. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix QFIT with LAS. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadertxt) { - REprintf( "ERROR: cannot mix TXT with LAS. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix TXT with LAS. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderlas == 0) @@ -110,42 +110,42 @@ BOOL LASreaderMerged::add_file_name(const char* file_name) { if (lasreaderlas) { - REprintf( "ERROR: cannot mix LAS with BIN. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix LAS with BIN. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadershp) { - REprintf( "ERROR: cannot mix SHP with BIN. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix SHP with BIN. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderasc) { - REprintf( "ERROR: cannot mix ASC with BIN. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix ASC with BIN. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbil) { - REprintf( "ERROR: cannot mix BIL with BIN. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix BIL with BIN. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderdtm) { - REprintf( "ERROR: cannot mix DTM with BIN. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix DTM with BIN. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderply) { - REprintf( "ERROR: cannot mix PLY with BIN. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix PLY with BIN. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderqfit) { - REprintf( "ERROR: cannot mix QFIT with BIN. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix QFIT with BIN. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadertxt) { - REprintf( "ERROR: cannot mix TXT with BIN. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix TXT with BIN. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbin == 0) @@ -157,42 +157,42 @@ BOOL LASreaderMerged::add_file_name(const char* file_name) { if (lasreaderlas) { - REprintf( "ERROR: cannot mix LAS with SHP. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix LAS with SHP. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbin) { - REprintf( "ERROR: cannot mix BIN with SHP. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix BIN with SHP. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderasc) { - REprintf( "ERROR: cannot mix ASC with SHP. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix ASC with SHP. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbil) { - REprintf( "ERROR: cannot mix BIL with SHP. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix BIL with SHP. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderdtm) { - REprintf( "ERROR: cannot mix DTM with SHP. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix DTM with SHP. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderply) { - REprintf( "ERROR: cannot mix PLY with SHP. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix PLY with SHP. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderqfit) { - REprintf( "ERROR: cannot mix QFIT with SHP. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix QFIT with SHP. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadertxt) { - REprintf( "ERROR: cannot mix TXT with SHP. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix TXT with SHP. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadershp == 0) @@ -204,42 +204,42 @@ BOOL LASreaderMerged::add_file_name(const char* file_name) { if (lasreaderlas) { - REprintf( "ERROR: cannot mix LAS with ASC. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix LAS with ASC. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbin) { - REprintf( "ERROR: cannot mix BIN with ASC. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix BIN with ASC. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadershp) { - REprintf( "ERROR: cannot mix SHP with ASC. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix SHP with ASC. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbil) { - REprintf( "ERROR: cannot mix BIL with ASC. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix BIL with ASC. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderdtm) { - REprintf( "ERROR: cannot mix DTM with ASC. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix DTM with ASC. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderply) { - REprintf( "ERROR: cannot mix PLY with ASC. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix PLY with ASC. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderqfit) { - REprintf( "ERROR: cannot mix QFIT with ASC. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix QFIT with ASC. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadertxt) { - REprintf( "ERROR: cannot mix TXT with ASC. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix TXT with ASC. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderasc == 0) @@ -251,42 +251,42 @@ BOOL LASreaderMerged::add_file_name(const char* file_name) { if (lasreaderlas) { - REprintf( "ERROR: cannot mix LAS with BIL. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix LAS with BIL. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbin) { - REprintf( "ERROR: cannot mix BIN with BIL. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix BIN with BIL. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadershp) { - REprintf( "ERROR: cannot mix SHP with BIL. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix SHP with BIL. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderdtm) { - REprintf( "ERROR: cannot mix DTM with BIL. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix DTM with BIL. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderasc) { - REprintf( "ERROR: cannot mix ASC with BIL. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix ASC with BIL. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderply) { - REprintf( "ERROR: cannot mix PLY with BIL. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix PLY with BIL. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderqfit) { - REprintf( "ERROR: cannot mix QFIT with BIL. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix QFIT with BIL. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadertxt) { - REprintf( "ERROR: cannot mix TXT with BIL. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix TXT with BIL. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbil == 0) @@ -298,42 +298,42 @@ BOOL LASreaderMerged::add_file_name(const char* file_name) { if (lasreaderlas) { - REprintf( "ERROR: cannot mix LAS with DTM. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix LAS with DTM. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbin) { - REprintf( "ERROR: cannot mix BIN with DTM. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix BIN with DTM. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadershp) { - REprintf( "ERROR: cannot mix SHP with DTM. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix SHP with DTM. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbil) { - REprintf( "ERROR: cannot mix BIL with DTM. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix BIL with DTM. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderasc) { - REprintf( "ERROR: cannot mix ASC with DTM. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix ASC with DTM. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderply) { - REprintf( "ERROR: cannot mix PLY with DTM. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix PLY with DTM. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderqfit) { - REprintf( "ERROR: cannot mix QFIT with DTM. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix QFIT with DTM. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadertxt) { - REprintf( "ERROR: cannot mix TXT with DTM. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix TXT with DTM. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderdtm == 0) @@ -345,42 +345,42 @@ BOOL LASreaderMerged::add_file_name(const char* file_name) { if (lasreaderlas) { - REprintf( "ERROR: cannot mix LAS with PLY. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix LAS with PLY. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbin) { - REprintf( "ERROR: cannot mix BIN with PLY. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix BIN with PLY. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadershp) { - REprintf( "ERROR: cannot mix SHP with PLY. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix SHP with PLY. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderasc) { - REprintf( "ERROR: cannot mix ASC with PLY. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix ASC with PLY. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbil) { - REprintf( "ERROR: cannot mix BIL with PLY. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix BIL with PLY. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderdtm) { - REprintf( "ERROR: cannot mix DTM with PLY. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix DTM with PLY. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderqfit) { - REprintf( "ERROR: cannot mix QFIT with PLY. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix QFIT with PLY. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadertxt) { - REprintf( "ERROR: cannot mix TXT with PLY. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix TXT with PLY. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderply == 0) @@ -392,42 +392,42 @@ BOOL LASreaderMerged::add_file_name(const char* file_name) { if (lasreaderlas) { - REprintf( "ERROR: cannot mix LAS with QFIT. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix LAS with QFIT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbin) { - REprintf( "ERROR: cannot mix BIN with QFIT. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix BIN with QFIT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadershp) { - REprintf( "ERROR: cannot mix SHP with QFIT. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix SHP with QFIT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderasc) { - REprintf( "ERROR: cannot mix ASC with QFIT. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix ASC with QFIT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbil) { - REprintf( "ERROR: cannot mix BIL with QFIT. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix BIL with QFIT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderdtm) { - REprintf( "ERROR: cannot mix DTM with QFIT. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix DTM with QFIT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderply) { - REprintf( "ERROR: cannot mix PLY with QFIT. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix PLY with QFIT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadertxt) { - REprintf( "ERROR: cannot mix TXT with QFIT. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix TXT with QFIT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderqfit == 0) @@ -439,42 +439,42 @@ BOOL LASreaderMerged::add_file_name(const char* file_name) { if (lasreaderlas) { - REprintf( "ERROR: cannot mix LAS with TXT. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix LAS with TXT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbin) { - REprintf( "ERROR: cannot mix BIN with TXT. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix BIN with TXT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadershp) { - REprintf( "ERROR: cannot mix SHP with TXT. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix SHP with TXT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderasc) { - REprintf( "ERROR: cannot mix ASC with TXT. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix ASC with TXT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbil) { - REprintf( "ERROR: cannot mix BIL with TXT. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix BIL with TXT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderdtm) { - REprintf( "ERROR: cannot mix DTM with TXT. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix DTM with TXT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderply) { - REprintf( "ERROR: cannot mix PLY with TXT. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix PLY with TXT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderqfit) { - REprintf( "ERROR: cannot mix QFIT with TXT. skipping '%s' ...\n", file_name); + fprintf(stderr, "ERROR: cannot mix QFIT with TXT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadertxt == 0) @@ -488,15 +488,24 @@ BOOL LASreaderMerged::add_file_name(const char* file_name) file_name_allocated += 1024; if (file_names) { - file_names = (char**)realloc(file_names, sizeof(char*)*file_name_allocated); + file_names = (CHAR**)realloc(file_names, sizeof(CHAR*)*file_name_allocated); + if (file_names_ID) + { + file_names_ID = (U32*)realloc(file_names_ID, sizeof(U32)*file_name_allocated); + if (file_names_ID == 0) + { + fprintf(stderr, "ERROR: alloc for file_names_ID array failed at %d\n", file_name_allocated); + return FALSE; + } + } } else { - file_names = (char**)malloc(sizeof(char*)*file_name_allocated); + file_names = (CHAR**)malloc(sizeof(CHAR*)*file_name_allocated); } if (file_names == 0) { - REprintf( "ERROR: alloc for file_names pointer array failed at %d\n", file_name_allocated); + fprintf(stderr, "ERROR: alloc for file_names pointer array failed at %d\n", file_name_allocated); return FALSE; } } @@ -505,6 +514,25 @@ BOOL LASreaderMerged::add_file_name(const char* file_name) return TRUE; } +BOOL LASreaderMerged::add_file_name(const CHAR* file_name, U32 ID) +{ + if (add_file_name(file_name)) + { + if (file_names_ID == 0) + { + file_names_ID = (U32*)malloc(sizeof(U32)*file_name_allocated); + if (file_names_ID == 0) + { + fprintf(stderr, "ERROR: alloc for file_names_ID array failed at %d\n", file_name_allocated); + return FALSE; + } + } + file_names_ID[file_name_number-1] = ID; + return TRUE; + } + return FALSE; +} + void LASreaderMerged::set_scale_factor(const F64* scale_factor) { if (scale_factor) @@ -577,7 +605,7 @@ void LASreaderMerged::set_scale_scan_angle(F32 scale_scan_angle) this->scale_scan_angle = scale_scan_angle; } -void LASreaderMerged::set_parse_string(const char* parse_string) +void LASreaderMerged::set_parse_string(const CHAR* parse_string) { if (this->parse_string) free(this->parse_string); if (parse_string) @@ -609,7 +637,7 @@ BOOL LASreaderMerged::open() { if (file_name_number == 0) { - REprintf( "ERROR: no valid file names\n"); + fprintf(stderr, "ERROR: no valid file names\n"); return FALSE; } @@ -633,7 +661,7 @@ BOOL LASreaderMerged::open() { if (!lasreaderlas->open(file_names[i], 512, (first == FALSE) && (attributes == FALSE))) // starting from second just "peek" into file to get bounding box and count { - REprintf( "ERROR: could not open lasreaderlas for file '%s'\n", file_names[i]); + fprintf(stderr, "ERROR: could not open lasreaderlas for file '%s'\n", file_names[i]); return FALSE; } } @@ -641,7 +669,7 @@ BOOL LASreaderMerged::open() { if (!lasreaderbin->open(file_names[i])) { - REprintf( "ERROR: could not open lasreaderbin for file '%s'\n", file_names[i]); + fprintf(stderr, "ERROR: could not open lasreaderbin for file '%s'\n", file_names[i]); return FALSE; } } @@ -649,7 +677,7 @@ BOOL LASreaderMerged::open() { if (!lasreadershp->open(file_names[i])) { - REprintf( "ERROR: could not open lasreadershp for file '%s'\n", file_names[i]); + fprintf(stderr, "ERROR: could not open lasreadershp for file '%s'\n", file_names[i]); return FALSE; } } @@ -657,7 +685,7 @@ BOOL LASreaderMerged::open() { if (!lasreaderasc->open(file_names[i])) { - REprintf( "ERROR: could not open lasreaderasc for file '%s'\n", file_names[i]); + fprintf(stderr, "ERROR: could not open lasreaderasc for file '%s'\n", file_names[i]); return FALSE; } } @@ -665,7 +693,7 @@ BOOL LASreaderMerged::open() { if (!lasreaderbil->open(file_names[i])) { - REprintf( "ERROR: could not open lasreaderbil for file '%s'\n", file_names[i]); + fprintf(stderr, "ERROR: could not open lasreaderbil for file '%s'\n", file_names[i]); return FALSE; } } @@ -673,7 +701,7 @@ BOOL LASreaderMerged::open() { if (!lasreaderdtm->open(file_names[i])) { - REprintf( "ERROR: could not open lasreaderdtm for file '%s'\n", file_names[i]); + fprintf(stderr, "ERROR: could not open lasreaderdtm for file '%s'\n", file_names[i]); return FALSE; } } @@ -681,7 +709,7 @@ BOOL LASreaderMerged::open() { if (!lasreaderply->open(file_names[i])) { - REprintf( "ERROR: could not open lasreaderply for file '%s'\n", file_names[i]); + fprintf(stderr, "ERROR: could not open lasreaderply for file '%s'\n", file_names[i]); return FALSE; } } @@ -689,7 +717,7 @@ BOOL LASreaderMerged::open() { if (!lasreaderqfit->open(file_names[i])) { - REprintf( "ERROR: could not open lasreaderqfit for file '%s'\n", file_names[i]); + fprintf(stderr, "ERROR: could not open lasreaderqfit for file '%s'\n", file_names[i]); return FALSE; } } @@ -703,7 +731,7 @@ BOOL LASreaderMerged::open() lasreadertxt->set_offset(offset); if (!lasreadertxt->open(file_names[i], 0, parse_string, skip_lines, populate_header)) { - REprintf( "ERROR: could not open lasreadertxt for file '%s'\n", file_names[i]); + fprintf(stderr, "ERROR: could not open lasreadertxt for file '%s'\n", file_names[i]); return FALSE; } } @@ -733,7 +761,7 @@ BOOL LASreaderMerged::open() { if (lasreader->header.vlr_lastiling->buffer) { - REprintf( "WARNING: first file is a buffered tile. maybe remove buffers first?\n"); + fprintf(stderr, "WARNING: first file is a buffered tile. maybe remove buffers first?\n"); } } // maybe we should keep the tiling @@ -741,7 +769,7 @@ BOOL LASreaderMerged::open() { if (lasreader->header.vlr_lastiling == 0) { - REprintf( "WARNING: first file has no LAStiling VLR cannot '-keep_lastiling' ...\n"); + fprintf(stderr, "WARNING: first file has no LAStiling VLR cannot '-keep_lastiling' ...\n"); } } else @@ -856,32 +884,32 @@ BOOL LASreaderMerged::open() header.y_scale_factor != lasreader->header.y_scale_factor || header.z_scale_factor != lasreader->header.z_scale_factor) { - // if (!rescale) REprintf( "WARNING: files have different scale factors: %g %g %g vs %g %g %g\n", header.x_scale_factor, header.y_scale_factor, header.z_scale_factor, lasreader->header.x_scale_factor, lasreader->header.y_scale_factor, lasreader->header.z_scale_factor); + // if (!rescale) fprintf(stderr, "WARNING: files have different scale factors: %g %g %g vs %g %g %g\n", header.x_scale_factor, header.y_scale_factor, header.z_scale_factor, lasreader->header.x_scale_factor, lasreader->header.y_scale_factor, lasreader->header.z_scale_factor); rescale = TRUE; } if (header.x_offset != lasreader->header.x_offset || header.y_offset != lasreader->header.y_offset || header.z_offset != lasreader->header.z_offset) { - // if (!reoffset) REprintf( "WARNING: files have different offsets: %g %g %g vs %g %g %g\n", header.x_offset, header.y_offset, header.z_offset, lasreader->header.x_offset, lasreader->header.y_offset, lasreader->header.z_offset); + // if (!reoffset) fprintf(stderr, "WARNING: files have different offsets: %g %g %g vs %g %g %g\n", header.x_offset, header.y_offset, header.z_offset, lasreader->header.x_offset, lasreader->header.y_offset, lasreader->header.z_offset); reoffset = TRUE; } // a point type change could be problematic if (header.point_data_format != lasreader->header.point_data_format) { - if (!point_type_change) REprintf( "WARNING: files have different point types: %d vs %d\n", header.point_data_format, lasreader->header.point_data_format); + if (!point_type_change) fprintf(stderr, "WARNING: files have different point types: %d vs %d\n", header.point_data_format, lasreader->header.point_data_format); point_type_change = TRUE; } // a point size change could be problematic if (header.point_data_record_length != lasreader->header.point_data_record_length) { - if (!point_size_change) REprintf( "WARNING: files have different point sizes: %d vs %d\n", header.point_data_record_length, lasreader->header.point_data_record_length); + if (!point_size_change) fprintf(stderr, "WARNING: files have different point sizes: %d vs %d\n", header.point_data_record_length, lasreader->header.point_data_record_length); point_size_change = TRUE; } // a change in additional attributes (in the extra bytes) could be problematic if (header.number_attributes != lasreader->header.number_attributes) { - if (!additional_attribute_change) REprintf( "WARNING: files have different number of attributes: %d vs %d\n", header.number_attributes, lasreader->header.number_attributes); + if (!additional_attribute_change) fprintf(stderr, "WARNING: files have different number of attributes: %d vs %d\n", header.number_attributes, lasreader->header.number_attributes); additional_attribute_change = TRUE; } else if (header.number_attributes) @@ -890,7 +918,7 @@ BOOL LASreaderMerged::open() { if (memcmp((const void*)&(header.attributes[j]), (const void*)&(lasreader->header.attributes[j]), 192)) { - if (!additional_attribute_change) REprintf( "WARNING: files have different attribute %d\n", j); + if (!additional_attribute_change) fprintf(stderr, "WARNING: files have different attribute %d\n", j); additional_attribute_change = TRUE; } } @@ -905,9 +933,9 @@ BOOL LASreaderMerged::open() if (0) // (auto_upgrade) { #ifdef _WIN32 - REprintf("WARNING: on-the-fly merged LAS 1.%d files contain too many points (%I64d). upgrading to LAS 1.4\n", header.version_minor, npoints); + fprintf(stderr,"WARNING: on-the-fly merged LAS 1.%d files contain too many points (%I64d). upgrading to LAS 1.4\n", header.version_minor, npoints); #else - REprintf("WARNING: on-the-fly merged LAS 1.%d files contain too many points (%lld). upgrading to LAS 1.4\n", header.version_minor, npoints); + fprintf(stderr,"WARNING: on-the-fly merged LAS 1.%d files contain too many points (%lld). upgrading to LAS 1.4\n", header.version_minor, npoints); #endif if (header.version_minor == 3) { @@ -924,9 +952,9 @@ BOOL LASreaderMerged::open() else { #ifdef _WIN32 - REprintf("WARNING: on-the-fly merged LAS 1.%d files contain too many points (%I64d) for single LAS 1.%d file.\n", header.version_minor, npoints, header.version_minor); + fprintf(stderr,"WARNING: on-the-fly merged LAS 1.%d files contain too many points (%I64d) for single LAS 1.%d file.\n", header.version_minor, npoints, header.version_minor); #else - REprintf("WARNING: on-the-fly merged LAS 1.%d files contain too many points (%lld) for single LAS 1.%d file.\n", header.version_minor, npoints, header.version_minor); + fprintf(stderr,"WARNING: on-the-fly merged LAS 1.%d files contain too many points (%lld) for single LAS 1.%d file.\n", header.version_minor, npoints, header.version_minor); #endif } } @@ -996,14 +1024,14 @@ BOOL LASreaderMerged::open() } if (header.x_scale_factor != x_scale_factor) { - REprintf( "WARNING: i changed x_scale_factor from %g to %g to accommodate enlarged bounding box\n", header.x_scale_factor, x_scale_factor); + fprintf(stderr, "WARNING: i changed x_scale_factor from %g to %g to accommodate enlarged bounding box\n", header.x_scale_factor, x_scale_factor); header.x_scale_factor = x_scale_factor; rescale = TRUE; } // maybe we changed the resolution ... so do we really need to adjuste the offset if ((((header.max_x - header.x_offset) / x_scale_factor) > I32_MAX) || (((header.min_x - header.x_offset) / x_scale_factor) < I32_MIN)) { - REprintf( "WARNING: i changed x_offset from %g to %g to accommodate enlarged bounding box\n", header.x_offset, x_offset); + fprintf(stderr, "WARNING: i changed x_offset from %g to %g to accommodate enlarged bounding box\n", header.x_offset, x_offset); header.x_offset = x_offset; reoffset = TRUE; } @@ -1022,14 +1050,14 @@ BOOL LASreaderMerged::open() } if (header.y_scale_factor != y_scale_factor) { - REprintf( "WARNING: i changed y_scale_factor from %g to %g to accommodate enlarged bounding box\n", header.y_scale_factor, y_scale_factor); + fprintf(stderr, "WARNING: i changed y_scale_factor from %g to %g to accommodate enlarged bounding box\n", header.y_scale_factor, y_scale_factor); header.y_scale_factor = y_scale_factor; rescale = TRUE; } // maybe we changed the resolution ... so do we really need to adjuste the offset if ((((header.max_y - header.y_offset) / y_scale_factor) > I32_MAX) || (((header.min_y - header.y_offset) / y_scale_factor) < I32_MIN)) { - REprintf( "WARNING: i changed y_offset from %g to %g to accommodate enlarged bounding box\n", header.y_offset, y_offset); + fprintf(stderr, "WARNING: i changed y_offset from %g to %g to accommodate enlarged bounding box\n", header.y_offset, y_offset); header.y_offset = y_offset; reoffset = TRUE; } @@ -1048,14 +1076,14 @@ BOOL LASreaderMerged::open() } if (header.z_scale_factor != z_scale_factor) { - REprintf( "WARNING: i changed z_scale_factor from %g to %g to accommodate enlarged bounding box\n", header.z_scale_factor, z_scale_factor); + fprintf(stderr, "WARNING: i changed z_scale_factor from %g to %g to accommodate enlarged bounding box\n", header.z_scale_factor, z_scale_factor); header.z_scale_factor = z_scale_factor; rescale = TRUE; } // maybe we changed the resolution ... so do we really need to adjuste the offset if ((((header.max_z - header.z_offset) / z_scale_factor) > I32_MAX) || (((header.min_z - header.z_offset) / z_scale_factor) < I32_MIN)) { - REprintf( "WARNING: i changed z_offset from %g to %g to accommodate enlarged bounding box\n", header.z_offset, z_offset); + fprintf(stderr, "WARNING: i changed z_offset from %g to %g to accommodate enlarged bounding box\n", header.z_offset, z_offset); header.z_offset = z_offset; reoffset = TRUE; } @@ -1370,6 +1398,11 @@ void LASreaderMerged::clean() } free(file_names); file_names = 0; + if (file_names_ID) + { + free(file_names_ID); + file_names_ID = 0; + } } if (bounding_boxes) { @@ -1401,6 +1434,7 @@ LASreaderMerged::LASreaderMerged() parse_string = 0; io_ibuffer_size = LAS_TOOLS_IO_IBUFFER_SIZE; file_names = 0; + file_names_ID = 0; bounding_boxes = 0; clean(); } @@ -1460,7 +1494,7 @@ BOOL LASreaderMerged::open_next_file() { if (!lasreaderlas->open(file_names[file_name_current], io_ibuffer_size)) { - REprintf( "ERROR: could not open lasreaderlas for file '%s'\n", file_names[file_name_current]); + fprintf(stderr, "ERROR: could not open lasreaderlas for file '%s'\n", file_names[file_name_current]); return FALSE; } LASindex* index = new LASindex; @@ -1473,7 +1507,7 @@ BOOL LASreaderMerged::open_next_file() { if (!lasreaderbin->open(file_names[file_name_current])) { - REprintf( "ERROR: could not open lasreaderbin for file '%s'\n", file_names[file_name_current]); + fprintf(stderr, "ERROR: could not open lasreaderbin for file '%s'\n", file_names[file_name_current]); return FALSE; } LASindex* index = new LASindex; @@ -1486,7 +1520,7 @@ BOOL LASreaderMerged::open_next_file() { if (!lasreadershp->open(file_names[file_name_current])) { - REprintf( "ERROR: could not open lasreadershp for file '%s'\n", file_names[file_name_current]); + fprintf(stderr, "ERROR: could not open lasreadershp for file '%s'\n", file_names[file_name_current]); return FALSE; } } @@ -1494,7 +1528,7 @@ BOOL LASreaderMerged::open_next_file() { if (!lasreaderasc->open(file_names[file_name_current])) { - REprintf( "ERROR: could not open lasreaderasc for file '%s'\n", file_names[file_name_current]); + fprintf(stderr, "ERROR: could not open lasreaderasc for file '%s'\n", file_names[file_name_current]); return FALSE; } } @@ -1502,7 +1536,7 @@ BOOL LASreaderMerged::open_next_file() { if (!lasreaderbil->open(file_names[file_name_current])) { - REprintf( "ERROR: could not open lasreaderbil for file '%s'\n", file_names[file_name_current]); + fprintf(stderr, "ERROR: could not open lasreaderbil for file '%s'\n", file_names[file_name_current]); return FALSE; } LASindex* index = new LASindex; @@ -1515,7 +1549,7 @@ BOOL LASreaderMerged::open_next_file() { if (!lasreaderdtm->open(file_names[file_name_current])) { - REprintf( "ERROR: could not open lasreaderdtm for file '%s'\n", file_names[file_name_current]); + fprintf(stderr, "ERROR: could not open lasreaderdtm for file '%s'\n", file_names[file_name_current]); return FALSE; } LASindex* index = new LASindex; @@ -1528,7 +1562,7 @@ BOOL LASreaderMerged::open_next_file() { if (!lasreaderply->open(file_names[file_name_current])) { - REprintf( "ERROR: could not open lasreaderply for file '%s'\n", file_names[file_name_current]); + fprintf(stderr, "ERROR: could not open lasreaderply for file '%s'\n", file_names[file_name_current]); return FALSE; } LASindex* index = new LASindex; @@ -1541,7 +1575,7 @@ BOOL LASreaderMerged::open_next_file() { if (!lasreaderqfit->open(file_names[file_name_current])) { - REprintf( "ERROR: could not open lasreaderqfit for file '%s'\n", file_names[file_name_current]); + fprintf(stderr, "ERROR: could not open lasreaderqfit for file '%s'\n", file_names[file_name_current]); return FALSE; } LASindex* index = new LASindex; @@ -1554,19 +1588,26 @@ BOOL LASreaderMerged::open_next_file() { if (!lasreadertxt->open(file_names[file_name_current], 0, parse_string, skip_lines, populate_header)) { - REprintf( "ERROR: could not open lasreadertxt for file '%s'\n", file_names[file_name_current]); + fprintf(stderr, "ERROR: could not open lasreadertxt for file '%s'\n", file_names[file_name_current]); return FALSE; } } - file_name_current++; if (files_are_flightlines) { - transform->setPointSource(file_name_current + files_are_flightlines - 1); + if (file_names_ID) + { + transform->setPointSource(file_names_ID[file_name_current] + 1); + } + else + { + transform->setPointSource(file_name_current + files_are_flightlines); + } } else if (apply_file_source_ID) { transform->setPointSource(lasreader->header.file_source_ID); } + file_name_current++; if (filter) lasreader->set_filter(filter); if (transform) lasreader->set_transform(transform); if (inside) diff --git a/inst/include/lasreadermerged.hpp b/src/LASlib/lasreadermerged.hpp similarity index 94% rename from inst/include/lasreadermerged.hpp rename to src/LASlib/lasreadermerged.hpp index a0b5952..96aba37 100644 --- a/inst/include/lasreadermerged.hpp +++ b/src/LASlib/lasreadermerged.hpp @@ -13,7 +13,7 @@ COPYRIGHT: - (c) 2007-2017, martin isenburg, rapidlasso - fast tools to catch reality + (c) 2007-2019, martin isenburg, rapidlasso - fast tools to catch reality This is free software; you can redistribute and/or modify it under the terms of the GNU Lesser General Licence as published by the Free Software @@ -24,6 +24,7 @@ CHANGE HISTORY: + 4 November 2019 -- add ID to files for subsets of merged '-faf' files 5 September 2018 -- support for reading points from the PLY format 1 December 2017 -- support extra bytes during '-merged' operations 3 May 2015 -- header sets file source ID to 0 when merging flightlines @@ -51,6 +52,7 @@ class LASreaderMerged : public LASreader void set_io_ibuffer_size(I32 io_ibuffer_size); inline I32 get_io_ibuffer_size() const { return io_ibuffer_size; }; BOOL add_file_name(const CHAR* file_name); + BOOL add_file_name(const CHAR* file_name, U32 ID); void set_scale_factor(const F64* scale_factor); void set_offset(const F64* offset); void set_files_are_flightlines(const I32 files_are_flightlines); @@ -122,6 +124,7 @@ class LASreaderMerged : public LASreader U32 file_name_allocated; I32 io_ibuffer_size; CHAR** file_names; + U32* file_names_ID; F64* bounding_boxes; }; diff --git a/src/LASlib/lasreaderpipeon.cpp b/src/LASlib/lasreaderpipeon.cpp index 7f01788..bd7715b 100644 --- a/src/LASlib/lasreaderpipeon.cpp +++ b/src/LASlib/lasreaderpipeon.cpp @@ -2,17 +2,17 @@ =============================================================================== FILE: lasreaderpipeon.cpp - + CONTENTS: - + see corresponding header file - + PROGRAMMERS: - + martin.isenburg@rapidlasso.com - http://rapidlasso.com - + COPYRIGHT: - + (c) 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality This is free software; you can redistribute and/or modify it under the @@ -21,11 +21,11 @@ This software is distributed WITHOUT ANY WARRANTY and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - + CHANGE HISTORY: - + see corresponding header file - + =============================================================================== */ #include "lasreaderpipeon.hpp" @@ -43,7 +43,7 @@ BOOL LASreaderPipeOn::open(LASreader* lasreader) { if (lasreader == 0) { - REprintf( "ERROR: no lasreader\n"); + fprintf(stderr, "ERROR: no lasreader\n"); return FALSE; } @@ -89,16 +89,16 @@ BOOL LASreaderPipeOn::open(LASreader* lasreader) if (laswriterlas == 0) { - REprintf( "ERROR: allocating laswriterlas\n"); + fprintf(stderr, "ERROR: allocating laswriterlas\n"); return FALSE; } - /*if (!laswriterlas->open(stdout, &header)) + if (!laswriterlas->open(stdout, &header)) { delete laswriterlas; - REprintf( "ERROR: opening laswriterlas to stdout\n"); + fprintf(stderr, "ERROR: opening laswriterlas to stdout\n"); return FALSE; - }*/ + } laswriter = laswriterlas; @@ -175,7 +175,7 @@ BOOL LASreaderPipeOn::read_point_default() void LASreaderPipeOn::close(BOOL close_stream) { - if (lasreader) + if (lasreader) { lasreader->close(close_stream); } diff --git a/inst/include/lasreaderpipeon.hpp b/src/LASlib/lasreaderpipeon.hpp similarity index 100% rename from inst/include/lasreaderpipeon.hpp rename to src/LASlib/lasreaderpipeon.hpp diff --git a/src/LASlib/lasreaderstored.cpp b/src/LASlib/lasreaderstored.cpp index f619701..743e3e4 100644 --- a/src/LASlib/lasreaderstored.cpp +++ b/src/LASlib/lasreaderstored.cpp @@ -44,7 +44,7 @@ BOOL LASreaderStored::open(LASreader* lasreader) { if (lasreader == 0) { - REprintf( "ERROR: no lasreader\n"); + fprintf(stderr, "ERROR: no lasreader\n"); return FALSE; } @@ -88,7 +88,7 @@ BOOL LASreaderStored::open(LASreader* lasreader) if (streamoutarray == 0) { - REprintf( "ERROR: allocating streamoutarray\n"); + fprintf(stderr, "ERROR: allocating streamoutarray\n"); return FALSE; } @@ -101,7 +101,7 @@ BOOL LASreaderStored::open(LASreader* lasreader) if (laswriterlas == 0) { - REprintf( "ERROR: allocating laswriterlas\n"); + fprintf(stderr, "ERROR: allocating laswriterlas\n"); return FALSE; } @@ -109,7 +109,7 @@ BOOL LASreaderStored::open(LASreader* lasreader) { delete laswriterlas; laswriterlas = 0; - REprintf( "ERROR: opening laswriterlas to streamoutarray\n"); + fprintf(stderr, "ERROR: opening laswriterlas to streamoutarray\n"); return FALSE; } @@ -133,13 +133,13 @@ BOOL LASreaderStored::reopen() { if (streamoutarray == 0) { - REprintf( "ERROR: no streamoutarray\n"); + fprintf(stderr, "ERROR: no streamoutarray\n"); return FALSE; } if (streamoutarray->getSize() == 0) { - REprintf( "ERROR: nothing stored in streamoutarray\n"); + fprintf(stderr, "ERROR: nothing stored in streamoutarray\n"); return FALSE; } @@ -150,7 +150,7 @@ BOOL LASreaderStored::reopen() if (streaminarray == 0) { - REprintf( "ERROR: creating streaminarray\n"); + fprintf(stderr, "ERROR: creating streaminarray\n"); return FALSE; } } @@ -164,7 +164,7 @@ BOOL LASreaderStored::reopen() if (lasreaderlas == 0) { - REprintf( "ERROR: allocating lasreaderlas\n"); + fprintf(stderr, "ERROR: allocating lasreaderlas\n"); return FALSE; } @@ -172,7 +172,7 @@ BOOL LASreaderStored::reopen() { delete lasreaderlas; lasreaderlas = 0; - REprintf( "ERROR: opening lasreaderlas from streaminarray\n"); + fprintf(stderr, "ERROR: opening lasreaderlas from streaminarray\n"); return FALSE; } diff --git a/inst/include/lasreaderstored.hpp b/src/LASlib/lasreaderstored.hpp similarity index 100% rename from inst/include/lasreaderstored.hpp rename to src/LASlib/lasreaderstored.hpp diff --git a/src/LASlib/lastransform.cpp b/src/LASlib/lastransform.cpp index f3ae835..2cad3d2 100644 --- a/src/LASlib/lastransform.cpp +++ b/src/LASlib/lastransform.cpp @@ -2,18 +2,18 @@ =============================================================================== FILE: lastransform.cpp - + CONTENTS: - + see corresponding header file - + PROGRAMMERS: martin.isenburg@rapidlasso.com - http://rapidlasso.com COPYRIGHT: - (c) 2007-2018, martin isenburg, rapidlasso - fast tools to catch reality + (c) 2007-2019, martin isenburg, rapidlasso - fast tools to catch reality This is free software; you can redistribute and/or modify it under the terms of the GNU Lesser General Licence as published by the Free Software @@ -21,15 +21,13 @@ This software is distributed WITHOUT ANY WARRANTY and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - + CHANGE HISTORY: - + see corresponding header file - + =============================================================================== */ -#include - #include "lastransform.hpp" #include "lasfilter.hpp" @@ -45,7 +43,10 @@ class LASoperationTranslateX : public LASoperation inline const CHAR* name() const { return "translate_x"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %lf ", name(), offset); }; inline void transform(LASpoint* point) { - point->set_x(point->get_x() + offset); + if (!point->set_x(point->get_x() + offset)) + { + overflow++; + } }; LASoperationTranslateX(F64 offset) { this->offset = offset; }; private: @@ -58,7 +59,10 @@ class LASoperationTranslateY : public LASoperation inline const CHAR* name() const { return "translate_y"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %lf ", name(), offset); }; inline void transform(LASpoint* point) { - point->set_y(point->get_y() + offset); + if (!point->set_y(point->get_y() + offset)) + { + overflow++; + } }; LASoperationTranslateY(F64 offset) { this->offset = offset; }; private: @@ -72,7 +76,10 @@ class LASoperationTranslateZ : public LASoperation inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %lf ", name(), offset); }; inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_Z; }; inline void transform(LASpoint* point) { - point->set_z(point->get_z() + offset); + if (!point->set_z(point->get_z() + offset)) + { + overflow++; + } }; LASoperationTranslateZ(F64 offset) { this->offset = offset; }; private: @@ -86,9 +93,18 @@ class LASoperationTranslateXYZ : public LASoperation inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %lf %lf %lf ", name(), offset[0], offset[1], offset[2]); }; inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_CHANNEL_RETURNS_XY | LASZIP_DECOMPRESS_SELECTIVE_Z; }; inline void transform(LASpoint* point) { - point->set_x(point->get_x() + offset[0]); - point->set_y(point->get_y() + offset[1]); - point->set_z(point->get_z() + offset[2]); + if (!point->set_x(point->get_x() + offset[0])) + { + overflow++; + } + if (!point->set_y(point->get_y() + offset[1])) + { + overflow++; + } + if (!point->set_z(point->get_z() + offset[2])) + { + overflow++; + } }; LASoperationTranslateXYZ(F64 x_offset, F64 y_offset, F64 z_offset) { this->offset[0] = x_offset; this->offset[1] = y_offset; this->offset[2] = z_offset; }; private: @@ -101,7 +117,10 @@ class LASoperationScaleX : public LASoperation inline const CHAR* name() const { return "scale_x"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %lf ", name(), scale); }; inline void transform(LASpoint* point) { - point->set_x(point->get_x() * scale); + if (!point->set_x(point->get_x() * scale)) + { + overflow++; + } }; LASoperationScaleX(F64 scale) { this->scale = scale; }; private: @@ -114,7 +133,10 @@ class LASoperationScaleY : public LASoperation inline const CHAR* name() const { return "scale_y"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %lf ", name(), scale); }; inline void transform(LASpoint* point) { - point->set_y(point->get_y() * scale); + if (!point->set_y(point->get_y() * scale)) + { + overflow++; + } }; LASoperationScaleY(F64 scale) { this->scale = scale; }; private: @@ -128,7 +150,10 @@ class LASoperationScaleZ : public LASoperation inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %lf ", name(), scale); }; inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_Z; }; inline void transform(LASpoint* point) { - point->set_z(point->get_z() * scale); + if (!point->set_z(point->get_z() * scale)) + { + overflow++; + } }; LASoperationScaleZ(F64 scale) { this->scale = scale; }; private: @@ -142,9 +167,18 @@ class LASoperationScaleXYZ : public LASoperation inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %lf %lf %lf ", name(), scale[0], scale[1], scale[2]); }; inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_CHANNEL_RETURNS_XY | LASZIP_DECOMPRESS_SELECTIVE_Z; }; inline void transform(LASpoint* point) { - point->set_x(point->get_x() * scale[0]); - point->set_y(point->get_y() * scale[1]); - point->set_z(point->get_z() * scale[2]); + if (!point->set_x(point->get_x() * scale[0])) + { + overflow++; + } + if (!point->set_y(point->get_y() * scale[1])) + { + overflow++; + } + if (!point->set_z(point->get_z() * scale[2])) + { + overflow++; + } }; LASoperationScaleXYZ(F64 x_scale, F64 y_scale, F64 z_scale) { this->scale[0] = x_scale; this->scale[1] = y_scale; this->scale[2] = z_scale; }; private: @@ -157,7 +191,10 @@ class LASoperationTranslateThenScaleX : public LASoperation inline const CHAR* name() const { return "translate_then_scale_x"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %lf %lf ", name(), offset, scale); }; inline void transform(LASpoint* point) { - point->set_x((point->get_x()+offset)*scale); + if (!point->set_x((point->get_x()+offset)*scale)) + { + overflow++; + } }; LASoperationTranslateThenScaleX(F64 offset, F64 scale) { this->offset = offset; this->scale = scale; }; private: @@ -171,7 +208,10 @@ class LASoperationTranslateThenScaleY : public LASoperation inline const CHAR* name() const { return "translate_then_scale_y"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %lf %lf ", name(), offset, scale); }; inline void transform(LASpoint* point) { - point->set_y((point->get_y()+offset)*scale); + if (!point->set_y((point->get_y()+offset)*scale)) + { + overflow++; + } }; LASoperationTranslateThenScaleY(F64 offset, F64 scale) { this->offset = offset; this->scale = scale; }; private: @@ -186,7 +226,10 @@ class LASoperationTranslateThenScaleZ : public LASoperation inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %lf %lf ", name(), offset, scale); }; inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_Z; }; inline void transform(LASpoint* point) { - point->set_z((point->get_z()+offset)*scale); + if (!point->set_z((point->get_z()+offset)*scale)) + { + overflow++; + } }; LASoperationTranslateThenScaleZ(F64 offset, F64 scale) { this->offset = offset; this->scale = scale; }; private: @@ -202,8 +245,14 @@ class LASoperationRotateXY : public LASoperation inline void transform(LASpoint* point) { F64 x = point->get_x() - x_offset; F64 y = point->get_y() - y_offset; - point->set_x(cos_angle*x - sin_angle*y + x_offset); - point->set_y(cos_angle*y + sin_angle*x + y_offset); + if (!point->set_x(cos_angle*x - sin_angle*y + x_offset)) + { + overflow++; + } + if (!point->set_y(cos_angle*y + sin_angle*x + y_offset)) + { + overflow++; + } }; LASoperationRotateXY(F64 angle, F64 x_offset, F64 y_offset) { this->angle = angle; this->x_offset = x_offset; this->y_offset = y_offset; cos_angle = cos(3.141592653589793238462643383279502884197169/180*angle); sin_angle = sin(3.141592653589793238462643383279502884197169/180*angle); }; private: @@ -221,8 +270,14 @@ class LASoperationRotateXZ : public LASoperation inline void transform(LASpoint* point) { F64 x = point->get_x() - x_offset; F64 z = point->get_z() - z_offset; - point->set_x(cos_angle*x - sin_angle*z + x_offset); - point->set_z(cos_angle*z + sin_angle*x + z_offset); + if (!point->set_x(cos_angle*x - sin_angle*z + x_offset)) + { + overflow++; + } + if (!point->set_z(cos_angle*z + sin_angle*x + z_offset)) + { + overflow++; + } }; LASoperationRotateXZ(F64 angle, F64 x_offset, F64 z_offset) { this->angle = angle; this->x_offset = x_offset; this->z_offset = z_offset; cos_angle = cos(3.141592653589793238462643383279502884197169/180*angle); sin_angle = sin(3.141592653589793238462643383279502884197169/180*angle); }; private: @@ -231,6 +286,31 @@ class LASoperationRotateXZ : public LASoperation F64 cos_angle, sin_angle; }; +class LASoperationRotateYZ : public LASoperation +{ +public: + inline const CHAR* name() const { return "rotate_yz"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %lf %lf %lf ", name(), angle, y_offset, z_offset); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_CHANNEL_RETURNS_XY | LASZIP_DECOMPRESS_SELECTIVE_Z; }; + inline void transform(LASpoint* point) { + F64 y = point->get_y() - y_offset; + F64 z = point->get_z() - z_offset; + if (!point->set_y(cos_angle*y - sin_angle*z + y_offset)) + { + overflow++; + } + if (!point->set_z(cos_angle*z + sin_angle*y + z_offset)) + { + overflow++; + } + }; + LASoperationRotateYZ(F64 angle, F64 y_offset, F64 z_offset) { this->angle = angle; this->y_offset = y_offset; this->z_offset = z_offset; cos_angle = cos(3.141592653589793238462643383279502884197169/180*angle); sin_angle = sin(3.141592653589793238462643383279502884197169/180*angle); }; +private: + F64 angle; + F64 y_offset, z_offset; + F64 cos_angle, sin_angle; +}; + class LASoperationTransformHelmert : public LASoperation { public: @@ -241,9 +321,18 @@ class LASoperationTransformHelmert : public LASoperation F64 x = scale*( ( point->get_x())-(rz_rad*point->get_y())+(ry_rad*point->get_z())) + dx; F64 y = scale*( (rz_rad*point->get_x())+( point->get_y())-(rx_rad*point->get_z())) + dy; F64 z = scale*(-(ry_rad*point->get_x())+(rx_rad*point->get_y())+( point->get_z())) + dz; - point->set_x(x); - point->set_y(y); - point->set_z(z); + if (!point->set_x(x)) + { + overflow++; + } + if (!point->set_y(y)) + { + overflow++; + } + if (!point->set_z(z)) + { + overflow++; + } }; LASoperationTransformHelmert(F64 dx, F64 dy, F64 dz, F64 rx, F64 ry, F64 rz, F64 m) { this->dx = dx; this->dy = dy; this->dz = dz; this->rx = rx; this->ry = ry; this->rz = rz; this->m = m; rx_rad = 4.84813681109536e-6*rx; ry_rad = 4.84813681109536e-6*ry; rz_rad = 4.84813681109536e-6*rz; scale = 1.0+(1.0e-6*m); }; private: @@ -259,8 +348,14 @@ class LASoperationTransformAffine : public LASoperation inline void transform(LASpoint* point) { F64 x = r * ((cosw * point->get_x()) + (sinw * point->get_y())) + tx; F64 y = r * ((cosw * point->get_y()) - (sinw * point->get_x())) + ty; - point->set_x(x); - point->set_y(y); + if (!point->set_x(x)) + { + overflow++; + } + if (!point->set_y(y)) + { + overflow++; + } }; LASoperationTransformAffine(F64 r, F64 w, F64 tx, F64 ty) { this->r = r; this->w = w; this->cosw = cos(4.84813681109536e-6*w); this->sinw = sin(4.84813681109536e-6*w); this->tx = tx; this->ty = ty; }; private: @@ -275,8 +370,20 @@ class LASoperationClampZ : public LASoperation inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_Z; }; inline void transform(LASpoint* point) { F64 z = point->get_z(); - if (z < below) point->set_z(below); - else if (z > above) point->set_z(above); + if (z < below) + { + if (!point->set_z(below)) + { + overflow++; + } + } + else if (z > above) + { + if (!point->set_z(above)) + { + overflow++; + } + } }; LASoperationClampZ(F64 below, F64 above) { this->below = below; this->above = above; }; private: @@ -291,7 +398,13 @@ class LASoperationClampZbelow : public LASoperation inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_Z; }; inline void transform(LASpoint* point) { F64 z = point->get_z(); - if (z < below) point->set_z(below); + if (z < below) + { + if (!point->set_z(below)) + { + overflow++; + } + } }; LASoperationClampZbelow(F64 below) { this->below = below; }; private: @@ -306,13 +419,55 @@ class LASoperationClampZabove : public LASoperation inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_Z; }; inline void transform(LASpoint* point) { F64 z = point->get_z(); - if (z > above) point->set_z(above); + if (z > above) + { + if (!point->set_z(above)) + { + overflow++; + } + } }; LASoperationClampZabove(F64 above) { this->above = above; }; private: F64 above; }; +class LASoperationCopyAttributeIntoX : public LASoperation +{ +public: + inline const CHAR* name() const { return "copy_attribute_into_x"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u ", name(), index); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_EXTRA_BYTES; }; + inline void transform(LASpoint* point) { + F64 x = point->get_attribute_as_float(index); + if (!point->set_x(x)) + { + overflow++; + } + }; + LASoperationCopyAttributeIntoX(U32 index) { this->index = index; }; +private: + U32 index; +}; + +class LASoperationCopyAttributeIntoY : public LASoperation +{ +public: + inline const CHAR* name() const { return "copy_attribute_into_y"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u ", name(), index); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_EXTRA_BYTES; }; + inline void transform(LASpoint* point) { + F64 y = point->get_attribute_as_float(index); + if (!point->set_y(y)) + { + overflow++; + } + }; + LASoperationCopyAttributeIntoY(U32 index) { this->index = index; }; +private: + U32 index; +}; + class LASoperationCopyAttributeIntoZ : public LASoperation { public: @@ -321,7 +476,10 @@ class LASoperationCopyAttributeIntoZ : public LASoperation inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_EXTRA_BYTES; }; inline void transform(LASpoint* point) { F64 z = point->get_attribute_as_float(index); - point->set_z(z); + if (!point->set_z(z)) + { + overflow++; + } }; LASoperationCopyAttributeIntoZ(U32 index) { this->index = index; }; private: @@ -334,7 +492,28 @@ class LASoperationCopyIntensityIntoZ : public LASoperation inline const CHAR* name() const { return "copy_intensity_into_z"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s ", name()); }; inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_INTENSITY; }; - inline void transform(LASpoint* point) { point->set_z((F64)point->get_intensity()); }; + inline void transform(LASpoint* point) { + F64 intensity = (F64)point->get_intensity(); + if (!point->set_z(intensity)) + { + overflow++; + } + }; +}; + +class LASoperationCopyUserDataIntoZ : public LASoperation +{ +public: + inline const CHAR* name() const { return "copy_user_data_into_z"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s ", name()); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_USER_DATA; }; + inline void transform(LASpoint* point) { + F64 user_data = point->get_user_data(); + if (!point->set_z(user_data)) + { + overflow++; + } + }; }; class LASoperationTranslateRawX : public LASoperation @@ -400,9 +579,8 @@ class LASoperationTranslateRawXYatRandom : public LASoperation inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d %d ", name(), max_raw_offset[0], max_raw_offset[1]); }; inline void transform(LASpoint* point) { I32 r; - //srand(seed); - //seed = rand(); - seed = R::runif(0, RAND_MAX); + srand(seed); + seed = rand(); r = ((seed >> 3) % ((2 * max_raw_offset[0]) + 1)) - max_raw_offset[0]; point->set_X(point->get_X() + r); r = ((seed >> 6) % ((2 * max_raw_offset[1]) + 1)) - max_raw_offset[1]; @@ -590,452 +768,815 @@ class LASoperationCopyAttributeIntoIntensity : public LASoperation U32 index; }; -class LASoperationBinGpsTimeIntoIntensity : public LASoperation +class LASoperationCopyAttributeIntoPointSource : public LASoperation { public: - inline const CHAR* name() const { return "bin_gps_time_into_intensity"; }; - inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %lf", name(), bin_size); }; - inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_GPS_TIME; }; - inline void transform(LASpoint* point) { point->set_intensity((U16)(I32_QUANTIZE(point->get_gps_time()/bin_size) & 0xFFFF)); }; - LASoperationBinGpsTimeIntoIntensity(F64 bin_size=1.0) { this->bin_size = bin_size; }; + inline const CHAR* name() const { return "copy_attribute_into_point_source"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u ", name(), index); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_EXTRA_BYTES; }; + inline void transform(LASpoint* point) { + F64 point_source = point->get_attribute_as_float(index); + point->set_point_source_ID(U16_CLAMP(point_source)); + }; + LASoperationCopyAttributeIntoPointSource(U32 index) { this->index = index; }; private: - F64 bin_size; + U32 index; }; -class LASoperationSetScanAngle : public LASoperation +class LASoperationCopyAttributeIntoRGBNIR : public LASoperation { public: - inline const CHAR* name() const { return "set_scan_angle"; }; - inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %g ", name(), scan_angle); }; + inline const CHAR* name() const { return "copy_attribute_into_"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s%c %u ", name(), (rgbi == 0 ? 'R' : (rgbi == 1 ? 'G' : (rgbi == 2 ? 'B' : 'NIR'))), index); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_EXTRA_BYTES; }; inline void transform(LASpoint* point) { - point->set_scan_angle(scan_angle); + F64 attribute = point->get_attribute_as_float(index); + point->set_RGBI(rgbi, U16_CLAMP(attribute)); }; - LASoperationSetScanAngle(F32 scan_angle) { this->scan_angle = scan_angle; }; + LASoperationCopyAttributeIntoRGBNIR(U32 index, U32 rgbi) { this->index = index; this->rgbi = rgbi; }; private: - F32 scan_angle; + U32 index; + U32 rgbi; }; -class LASoperationScaleScanAngle : public LASoperation +class LASoperationAddRegisters : public LASoperation { public: - inline const CHAR* name() const { return "scale_scan_angle"; }; - inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %g ", name(), scale); }; - inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_SCAN_ANGLE; }; + inline const CHAR* name() const { return "add_registers"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u %u %u ", name(), input1, input2, output); }; inline void transform(LASpoint* point) { - F32 scan_angle_rank = scale*point->scan_angle_rank; - point->scan_angle_rank = I8_CLAMP(I32_QUANTIZE(scan_angle_rank)); + F64 result = registers[input1] + registers[input2]; + registers[output] = result; }; - LASoperationScaleScanAngle(F32 scale) { this->scale = scale; }; + LASoperationAddRegisters(F64* registers, U32 input1, U32 input2, U32 output) { this->registers = registers; this->input1 = input1; this->input2 = input2; this->output = output; }; private: - F32 scale; + F64* registers; + U32 input1; + U32 input2; + U32 output; }; -class LASoperationTranslateScanAngle : public LASoperation +class LASoperationSubtractRegisters : public LASoperation { public: - inline const CHAR* name() const { return "translate_scan_angle"; }; - inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %g ", name(), offset); }; - inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_SCAN_ANGLE; }; + inline const CHAR* name() const { return "subtract_registers"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u %u %u ", name(), input1, input2, output); }; inline void transform(LASpoint* point) { - F32 scan_angle_rank = offset+point->scan_angle_rank; - point->scan_angle_rank = I8_CLAMP(I32_QUANTIZE(scan_angle_rank)); + F64 result = registers[input1] - registers[input2]; + registers[output] = result; }; - LASoperationTranslateScanAngle(F32 offset) { this->offset = offset; }; + LASoperationSubtractRegisters(F64* registers, U32 input1, U32 input2, U32 output) { this->registers = registers; this->input1 = input1; this->input2 = input2; this->output = output; }; private: - F32 offset; + F64* registers; + U32 input1; + U32 input2; + U32 output; }; -class LASoperationTranslateThenScaleScanAngle : public LASoperation +class LASoperationMultiplyRegisters : public LASoperation { public: - inline const CHAR* name() const { return "translate_then_scale_scan_angle"; }; - inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %g %g ", name(), offset, scale); }; - inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_SCAN_ANGLE; }; + inline const CHAR* name() const { return "multiply_registers"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u %u %u ", name(), input1, input2, output); }; inline void transform(LASpoint* point) { - F32 scan_angle_rank = (offset+point->scan_angle_rank)*scale; - point->scan_angle_rank = I8_CLAMP(I32_QUANTIZE(scan_angle_rank)); + F64 result = registers[input1] * registers[input2]; + registers[output] = result; }; - LASoperationTranslateThenScaleScanAngle(F32 offset, F32 scale) { this->offset = offset; this->scale = scale; }; + LASoperationMultiplyRegisters(F64* registers, U32 input1, U32 input2, U32 output) { this->registers = registers; this->input1 = input1; this->input2 = input2; this->output = output; }; private: - F32 offset; - F32 scale; + F64* registers; + U32 input1; + U32 input2; + U32 output; }; -class LASoperationSetClassification : public LASoperation +class LASoperationDivideRegisters : public LASoperation { public: - inline const CHAR* name() const { return "set_classification"; }; - inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d ", name(), classification); }; - inline void transform(LASpoint* point) { point->set_extended_classification(classification); }; - LASoperationSetClassification(U8 classification) { this->classification = classification; }; + inline const CHAR* name() const { return "divide_registers"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u %u %u ", name(), input1, input2, output); }; + inline void transform(LASpoint* point) { + F64 result = registers[input1] / registers[input2]; + registers[output] = result; + }; + LASoperationDivideRegisters(F64* registers, U32 input1, U32 input2, U32 output) { this->registers = registers; this->input1 = input1; this->input2 = input2; this->output = output; }; private: - U8 classification; + F64* registers; + U32 input1; + U32 input2; + U32 output; }; -class LASoperationChangeClassificationFromTo : public LASoperation +class LASoperationCopyIntensityIntoRegister : public LASoperation { public: - inline const CHAR* name() const { return "change_classification_from_to"; }; - inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d %d ", name(), class_from, class_to); }; - inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_CLASSIFICATION; }; + inline const CHAR* name() const { return "copy_intensity_into_register"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u ", name(), index); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_INTENSITY; }; inline void transform(LASpoint* point) { - if (class_from > 31) - { - if (point->get_extended_classification() == class_from) - { - point->set_extended_classification(class_to); - } - } - else if (point->get_classification() == class_from) - { - point->set_extended_classification(class_to); - } + registers[index] = point->get_intensity(); }; - LASoperationChangeClassificationFromTo(U8 class_from, U8 class_to) { this->class_from = class_from; this->class_to = class_to; }; + LASoperationCopyIntensityIntoRegister(F64* registers, const U32 index) { this->registers = registers; this->index = index; }; private: - U8 class_from; - U8 class_to; + F64* registers; + U32 index; }; -class LASoperationMoveAncientToExtendedClassification : public LASoperation +class LASoperationCopyUserDataIntoRegister : public LASoperation { public: - inline const CHAR* name() const { return "move_ancient_to_extended_classification"; }; - inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s ", name()); }; - inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_FLAGS | LASZIP_DECOMPRESS_SELECTIVE_CLASSIFICATION; }; + inline const CHAR* name() const { return "copy_user_data_into_register"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u ", name(), index); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_USER_DATA; }; inline void transform(LASpoint* point) { - if (point->get_withheld_flag() || point->get_keypoint_flag() || point->get_synthetic_flag()) - { - point->set_extended_classification((point->get_withheld_flag() ? 128 : 0) | (point->get_keypoint_flag() ? 64 : 0) | (point->get_synthetic_flag() ? 32 : 0) | point->get_classification()); - point->set_synthetic_flag(0); - point->set_keypoint_flag(0); - point->set_withheld_flag(0); - } + registers[index] = point->get_user_data(); }; - LASoperationMoveAncientToExtendedClassification() { }; + LASoperationCopyUserDataIntoRegister(F64* registers, U32 index) { this->registers = registers; this->index = index; }; +private: + F64* registers; + U32 index; }; -class LASoperationClassifyZbelowAs : public LASoperation +class LASoperationCopyPointSourceIntoRegister : public LASoperation { public: - inline const CHAR* name() const { return "classify_z_below_as"; }; - inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %lf %d ", name(), z_below, class_to); }; - inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_Z; }; + inline const CHAR* name() const { return "copy_point_source_into_register"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u ", name(), index); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_POINT_SOURCE; }; inline void transform(LASpoint* point) { - if (point->get_z() < z_below) - { - point->set_extended_classification(class_to); - } + registers[index] = point->get_point_source_ID(); }; - LASoperationClassifyZbelowAs(F64 z_below, U8 class_to) { this->z_below = z_below; this->class_to = class_to; }; + LASoperationCopyPointSourceIntoRegister(F64* registers, U32 index) { this->registers = registers; this->index = index; }; private: - F64 z_below; - U8 class_to; + F64* registers; + U32 index; }; -class LASoperationClassifyZaboveAs : public LASoperation +class LASoperationCopyAttributeIntoRegister : public LASoperation { public: - inline const CHAR* name() const { return "classify_z_above_as"; }; - inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %lf %d ", name(), z_above, class_to); }; - inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_Z; }; + inline const CHAR* name() const { return "copy_attribute_into_register"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u %u ", name(), index_attribute, index_register); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_EXTRA_BYTES; }; inline void transform(LASpoint* point) { - if (point->get_z() > z_above) - { - point->set_extended_classification(class_to); - } + F64 attribute = point->get_attribute_as_float(index_attribute); + registers[index_register] = attribute; }; - LASoperationClassifyZaboveAs(F64 z_above, U8 class_to) { this->z_above = z_above; this->class_to = class_to; }; + LASoperationCopyAttributeIntoRegister(U32 index_attribute, F64* registers, U32 index_register) { this->index_attribute = index_attribute; this->registers = registers; this->index_register = index_register; }; private: - F64 z_above; - U8 class_to; + U32 index_attribute; + F64* registers; + U32 index_register; }; -class LASoperationClassifyZbetweenAs : public LASoperation +class LASoperationSetRegister : public LASoperation { public: - inline const CHAR* name() const { return "classify_z_between_as"; }; - inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %lf %lf %d ", name(), z_below, z_above, class_to); }; - inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_Z; }; - inline void transform(LASpoint* point) { - if ((z_below <= point->get_z()) && (point->get_z() <= z_above)) - { - point->set_extended_classification(class_to); - } - }; - LASoperationClassifyZbetweenAs(F64 z_below, F64 z_above, U8 class_to) { this->z_below = z_below; this->z_above = z_above; this->class_to = class_to; }; + inline const CHAR* name() const { return "set_register"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u %g ", name(), index, value); }; + inline void transform(LASpoint* point) { registers[index] = value; }; + LASoperationSetRegister(F64* registers, U32 index, F64 value) { this->registers = registers; this->index = index; this->value = value; }; private: - F64 z_below; - F64 z_above; - U8 class_to; + F64* registers; + U32 index; + F64 value; }; -class LASoperationClassifyIntensityBelowAs : public LASoperation +class LASoperationScaleRegister : public LASoperation { public: - inline const CHAR* name() const { return "classify_intensity_below_as"; }; - inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d %d ", name(), (I32)intensity_below, (I32)class_to); }; - inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_INTENSITY; }; + inline const CHAR* name() const { return "scale_register"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u %g ", name(), index, scale); }; + inline void transform(LASpoint* point) { registers[index] *= scale; }; + LASoperationScaleRegister(F64* registers, U32 index, F32 scale) { this->registers = registers; this->index = index; this->scale = scale; }; +private: + F64* registers; + U32 index; + F32 scale; +}; + +class LASoperationTranslateRegister : public LASoperation +{ +public: + inline const CHAR* name() const { return "translate_register"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u %lf ", name(), index, offset); }; + inline void transform(LASpoint* point) { registers[index] += offset; }; + LASoperationTranslateRegister(F64* registers, U32 index, F64 offset) { this->registers = registers; this->index = index; this->offset = offset; }; +private: + F64* registers; + U32 index; + F64 offset; +}; + +class LASoperationCopyRegisterIntoX : public LASoperation +{ +public: + inline const CHAR* name() const { return "copy_register_into_x"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u ", name(), index); }; inline void transform(LASpoint* point) { - if (point->get_intensity() < intensity_below) + if (!point->set_x(registers[index])) { - point->set_extended_classification(class_to); + overflow++; } }; - LASoperationClassifyIntensityBelowAs(U16 intensity_below, U8 class_to) { this->intensity_below = intensity_below; this->class_to = class_to; }; + LASoperationCopyRegisterIntoX(F64* registers, U32 index) { this->registers = registers; this->index = index; }; private: - U16 intensity_below; - U8 class_to; + F64* registers; + U32 index; }; -class LASoperationClassifyIntensityAboveAs : public LASoperation +class LASoperationCopyRegisterIntoY : public LASoperation { public: - inline const CHAR* name() const { return "classify_intensity_above_as"; }; - inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d %d ", name(), (I32)intensity_above, (I32)class_to); }; - inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_INTENSITY; }; + inline const CHAR* name() const { return "copy_register_into_y"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u ", name(), index); }; inline void transform(LASpoint* point) { - if (point->get_intensity() > intensity_above) + if (!point->set_y(registers[index])) { - point->set_extended_classification(class_to); + overflow++; } }; - LASoperationClassifyIntensityAboveAs(U16 intensity_above, U8 class_to) { this->intensity_above = intensity_above; this->class_to = class_to; }; + LASoperationCopyRegisterIntoY(F64* registers, U32 index) { this->registers = registers; this->index = index; }; private: - U16 intensity_above; - U8 class_to; + F64* registers; + U32 index; }; -class LASoperationClassifyIntensityBetweenAs : public LASoperation +class LASoperationCopyRegisterIntoZ : public LASoperation { public: - inline const CHAR* name() const { return "classify_intensity_between_as"; }; - inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d %d %d ", name(), (I32)intensity_below, (I32)intensity_above, (I32)class_to); }; - inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_INTENSITY; }; + inline const CHAR* name() const { return "copy_register_into_z"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u ", name(), index); }; inline void transform(LASpoint* point) { - if ((intensity_below <= point->get_intensity()) && (point->get_intensity() <= intensity_above)) + if (!point->set_z(registers[index])) { - point->set_extended_classification(class_to); + overflow++; } }; - LASoperationClassifyIntensityBetweenAs(U16 intensity_below, U16 intensity_above, U8 class_to) { this->intensity_below = intensity_below; this->intensity_above = intensity_above; this->class_to = class_to; }; + LASoperationCopyRegisterIntoZ(F64* registers, U32 index) { this->registers = registers; this->index = index; }; private: - U16 intensity_below; - U16 intensity_above; - U8 class_to; + F64* registers; + U32 index; }; -class LASoperationClassifyAttributeBelowAs : public LASoperation +class LASoperationCopyRegisterIntoUserData : public LASoperation { public: - inline const CHAR* name() const { return "classify_attribute_below_as"; }; - inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d %lf %d ", name(), index, below, class_to); }; - inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_EXTRA_BYTES; }; + inline const CHAR* name() const { return "copy_attribute_into_user_data"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u ", name(), index); }; inline void transform(LASpoint* point) { - if (point->get_attribute_as_float(index) < below) - { - point->set_extended_classification(class_to); - } + point->set_user_data(U8_CLAMP(registers[index])); }; - LASoperationClassifyAttributeBelowAs(U32 index, F64 below, U8 class_to) { this->index = index; this->below = below; this->class_to = class_to; }; + LASoperationCopyRegisterIntoUserData(F64* registers, U32 index) { this->registers = registers; this->index = index; }; private: + F64* registers; U32 index; - F64 below; - U8 class_to; }; -class LASoperationClassifyAttributeAboveAs : public LASoperation +class LASoperationCopyRegisterIntoIntensity : public LASoperation { public: - inline const CHAR* name() const { return "classify_attribute_above_as"; }; - inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d %lf %d ", name(), index, above, class_to); }; - inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_EXTRA_BYTES; }; + inline const CHAR* name() const { return "copy_register_into_intensity"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u ", name(), index); }; inline void transform(LASpoint* point) { - if (point->get_attribute_as_float(index) > above) - { - point->set_extended_classification(class_to); - } + point->set_intensity(U16_CLAMP(registers[index])); }; - LASoperationClassifyAttributeAboveAs(U32 index, F64 above, U8 class_to) { this->index = index; this->above = above; this->class_to = class_to; }; + LASoperationCopyRegisterIntoIntensity(F64* registers, U32 index) { this->registers = registers; this->index = index; }; private: + F64* registers; U32 index; - F64 above; - U8 class_to; }; -class LASoperationClassifyAttributeBetweenAs : public LASoperation +class LASoperationCopyRegisterIntoPointSource : public LASoperation { public: - inline const CHAR* name() const { return "classify_attribute_between_as"; }; - inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d %lf %lf %d ", name(), index, below, above, class_to); }; - inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_EXTRA_BYTES; }; + inline const CHAR* name() const { return "copy_register_into_point_source"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u ", name(), index); }; inline void transform(LASpoint* point) { - F64 value = point->get_attribute_as_float(index); - if ((below <= value) && (value <= above)) - { - point->set_extended_classification(class_to); - } + point->set_point_source_ID(U16_CLAMP(registers[index])); }; - LASoperationClassifyAttributeBetweenAs(U32 index, F64 z_below, F64 z_above, U8 class_to) { this->index = index; this->below = z_below; this->above = z_above; this->class_to = class_to; }; + LASoperationCopyRegisterIntoPointSource(F64* registers, U32 index) { this->registers = registers; this->index = index; }; private: + F64* registers; U32 index; - F64 below; - F64 above; - U8 class_to; }; -class LASoperationSetWithheldFlag : public LASoperation +class LASoperationCopyRegisterIntoRGBNIR : public LASoperation { public: - inline const CHAR* name() const { return "set_withheld_flag"; }; - inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d ", name(), flag); }; - inline void transform(LASpoint* point) { point->set_withheld_flag(flag); }; - LASoperationSetWithheldFlag(U8 flag) { this->flag = (flag ? 1 : 0); }; + inline const CHAR* name() const { return "copy_register_into_"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s%c %u ", name(), (rgbi == 0 ? 'R' : (rgbi == 1 ? 'G' : (rgbi == 2 ? 'B' : 'NIR'))), index); }; + inline void transform(LASpoint* point) { + point->set_RGBI(rgbi, U16_CLAMP(registers[index])); + }; + LASoperationCopyRegisterIntoRGBNIR(F64* registers, U32 index, U32 rgbi) { this->registers = registers; this->index = index; this->rgbi = rgbi; }; private: - U8 flag; + F64* registers; + U32 index; + U32 rgbi; }; -class LASoperationSetSyntheticFlag : public LASoperation +class LASoperationCopyRegisterIntoAttribute : public LASoperation { public: - inline const CHAR* name() const { return "set_synthetic_flag"; }; - inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d ", name(), flag); }; - inline void transform(LASpoint* point) { point->set_synthetic_flag(flag); }; - LASoperationSetSyntheticFlag(U8 flag) { this->flag = (flag ? 1 : 0); }; + inline const CHAR* name() const { return "copy_register_into_attribute"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u %u ", name(), index_register, index_attribute); }; + inline void transform(LASpoint* point) { + point->set_attribute_as_float(index_attribute, registers[index_register]); + }; + LASoperationCopyRegisterIntoAttribute(F64* registers, U32 index_register, U32 index_attribute) { this->registers = registers; this->index_register = index_register; this->index_attribute = index_attribute; }; private: - U8 flag; + F64* registers; + U32 index_register; + U32 index_attribute; }; -class LASoperationSetKeypointFlag : public LASoperation +class LASoperationBinGpsTimeIntoIntensity : public LASoperation { public: - inline const CHAR* name() const { return "set_keypoint_flag"; }; - inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d ", name(), flag); }; - inline void transform(LASpoint* point) { point->set_keypoint_flag(flag); }; - LASoperationSetKeypointFlag(U8 flag) { this->flag = (flag ? 1 : 0); }; + inline const CHAR* name() const { return "bin_gps_time_into_intensity"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %lf", name(), bin_size); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_GPS_TIME; }; + inline void transform(LASpoint* point) { point->set_intensity((U16)(I32_QUANTIZE(point->get_gps_time()/bin_size) & 0xFFFF)); }; + LASoperationBinGpsTimeIntoIntensity(F64 bin_size=1.0) { this->bin_size = bin_size; }; private: - U8 flag; + F64 bin_size; }; -class LASoperationSetExtendedOverlapFlag : public LASoperation +class LASoperationSetScanAngle : public LASoperation { public: - inline const CHAR* name() const { return "set_overlap_flag"; }; - inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d ", name(), flag); }; - inline void transform(LASpoint* point) { point->set_extended_overlap_flag(flag); }; - LASoperationSetExtendedOverlapFlag(U8 flag) { this->flag = (flag ? 1 : 0); }; + inline const CHAR* name() const { return "set_scan_angle"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %g ", name(), scan_angle); }; + inline void transform(LASpoint* point) { + point->set_scan_angle(scan_angle); + }; + LASoperationSetScanAngle(F32 scan_angle) { this->scan_angle = scan_angle; }; private: - U8 flag; + F32 scan_angle; }; -class LASoperationSetExtendedScannerChannel : public LASoperation +class LASoperationScaleScanAngle : public LASoperation { public: - inline const CHAR* name() const { return "set_scanner_channel"; }; - inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d ", name(), channel); }; - inline void transform(LASpoint* point) { point->set_extended_scanner_channel(channel); }; - LASoperationSetExtendedScannerChannel(U8 channel) { this->channel = (channel >= 3 ? 3 : channel); }; + inline const CHAR* name() const { return "scale_scan_angle"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %g ", name(), scale); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_SCAN_ANGLE; }; + inline void transform(LASpoint* point) { + F32 scan_angle_rank = scale*point->scan_angle_rank; + point->scan_angle_rank = I8_CLAMP(I32_QUANTIZE(scan_angle_rank)); + }; + LASoperationScaleScanAngle(F32 scale) { this->scale = scale; }; private: - U8 channel; + F32 scale; }; -class LASoperationSetUserData : public LASoperation +class LASoperationTranslateScanAngle : public LASoperation { public: - inline const CHAR* name() const { return "set_user_data"; }; - inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d ", name(), user_data); }; - inline void transform(LASpoint* point) { point->user_data = user_data; }; - LASoperationSetUserData(U8 user_data) { this->user_data = user_data; }; + inline const CHAR* name() const { return "translate_scan_angle"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %g ", name(), offset); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_SCAN_ANGLE; }; + inline void transform(LASpoint* point) { + F32 scan_angle_rank = offset+point->scan_angle_rank; + point->scan_angle_rank = I8_CLAMP(I32_QUANTIZE(scan_angle_rank)); + }; + LASoperationTranslateScanAngle(F32 offset) { this->offset = offset; }; private: - U8 user_data; + F32 offset; }; -class LASoperationScaleUserData : public LASoperation +class LASoperationTranslateThenScaleScanAngle : public LASoperation { public: - inline const CHAR* name() const { return "scale_user_data"; }; - inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %g ", name(), scale); }; - inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_USER_DATA; }; + inline const CHAR* name() const { return "translate_then_scale_scan_angle"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %g %g ", name(), offset, scale); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_SCAN_ANGLE; }; inline void transform(LASpoint* point) { - point->set_user_data(U8_CLAMP(scale*point->get_user_data())); + F32 scan_angle_rank = (offset+point->scan_angle_rank)*scale; + point->scan_angle_rank = I8_CLAMP(I32_QUANTIZE(scan_angle_rank)); }; - LASoperationScaleUserData(F32 scale) { this->scale = scale; }; + LASoperationTranslateThenScaleScanAngle(F32 offset, F32 scale) { this->offset = offset; this->scale = scale; }; private: + F32 offset; F32 scale; }; -class LASoperationChangeUserDataFromTo : public LASoperation +class LASoperationSetClassification : public LASoperation { public: - inline const CHAR* name() const { return "change_user_data_from_to"; }; - inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d %d ", name(), user_data_from, user_data_to); }; - inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_USER_DATA; }; - inline void transform(LASpoint* point) { if (point->get_user_data() == user_data_from) point->set_user_data(user_data_to); }; - LASoperationChangeUserDataFromTo(U8 user_data_from, U8 user_data_to) { this->user_data_from = user_data_from; this->user_data_to = user_data_to; }; + inline const CHAR* name() const { return "set_classification"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d ", name(), classification); }; + inline void transform(LASpoint* point) { point->set_extended_classification(classification); }; + LASoperationSetClassification(U8 classification) { this->classification = classification; }; private: - U8 user_data_from; - U8 user_data_to; + U8 classification; }; -class LASoperationMapUserData : public LASoperation +class LASoperationChangeClassificationFromTo : public LASoperation { public: - inline const CHAR* name() const { return "map_user_data"; }; - inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s \"%s\" ", name(), map_file_name); }; - inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_USER_DATA; }; - inline void transform(LASpoint* point) { U8 user_data = point->get_user_data(); point->set_user_data(map[user_data]); }; - LASoperationMapUserData(const CHAR* file_name) - { - for (U32 u = 0; u < 256; u++) - { - map[u] = u; - } - FILE* file = fopen(file_name, "r"); - if (file) + inline const CHAR* name() const { return "change_classification_from_to"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d %d ", name(), class_from, class_to); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_CLASSIFICATION; }; + inline void transform(LASpoint* point) { + if (class_from > 31) { - U32 from, to; - CHAR line[128]; - while (fgets(line, 128, file)) + if (point->get_extended_classification() == class_from) { - if (sscanf(line, "%u %u", &from, &to) == 2) - { - if ((from < 256) && (to < 256)) - { - map[from] = to; - } - } + point->set_extended_classification(class_to); } - fclose(file); - map_file_name = LASCopyString(file_name); } - else + else if (point->get_classification() == class_from) { - map_file_name = 0; + point->set_extended_classification(class_to); } }; - ~LASoperationMapUserData() { if (map_file_name) free(map_file_name); }; + LASoperationChangeClassificationFromTo(U8 class_from, U8 class_to) { this->class_from = class_from; this->class_to = class_to; }; private: - U8 map[256]; - CHAR* map_file_name; -}; - -class LASoperationCopyClassificationIntoUserData : public LASoperation -{ -public: - inline const CHAR* name() const { return "copy_classification_into_user_data"; }; - inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s ", name()); }; - inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_CLASSIFICATION; }; - inline void transform(LASpoint* point) { point->set_user_data(point->get_classification() ? point->get_classification() : point->get_extended_classification()); }; + U8 class_from; + U8 class_to; }; -class LASoperationCopyClassificationIntoPointSource : public LASoperation +class LASoperationMoveAncientToExtendedClassification : public LASoperation { public: - inline const CHAR* name() const { return "copy_classification_into_point_source"; }; + inline const CHAR* name() const { return "move_ancient_to_extended_classification"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s ", name()); }; - inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_CLASSIFICATION; }; - inline void transform(LASpoint* point) { point->set_point_source_ID(point->get_classification() ? point->get_classification() : point->get_extended_classification()); }; -}; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_FLAGS | LASZIP_DECOMPRESS_SELECTIVE_CLASSIFICATION; }; + inline void transform(LASpoint* point) { + if (point->get_withheld_flag() || point->get_keypoint_flag() || point->get_synthetic_flag()) + { + point->set_extended_classification((point->get_withheld_flag() ? 128 : 0) | (point->get_keypoint_flag() ? 64 : 0) | (point->get_synthetic_flag() ? 32 : 0) | point->get_classification()); + point->set_synthetic_flag(0); + point->set_keypoint_flag(0); + point->set_withheld_flag(0); + } + }; + LASoperationMoveAncientToExtendedClassification() { }; +}; + +class LASoperationClassifyZbelowAs : public LASoperation +{ +public: + inline const CHAR* name() const { return "classify_z_below_as"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %lf %d ", name(), z_below, class_to); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_Z; }; + inline void transform(LASpoint* point) { + if (point->get_z() < z_below) + { + point->set_extended_classification(class_to); + } + }; + LASoperationClassifyZbelowAs(F64 z_below, U8 class_to) { this->z_below = z_below; this->class_to = class_to; }; +private: + F64 z_below; + U8 class_to; +}; + +class LASoperationClassifyZaboveAs : public LASoperation +{ +public: + inline const CHAR* name() const { return "classify_z_above_as"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %lf %d ", name(), z_above, class_to); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_Z; }; + inline void transform(LASpoint* point) { + if (point->get_z() > z_above) + { + point->set_extended_classification(class_to); + } + }; + LASoperationClassifyZaboveAs(F64 z_above, U8 class_to) { this->z_above = z_above; this->class_to = class_to; }; +private: + F64 z_above; + U8 class_to; +}; + +class LASoperationClassifyZbetweenAs : public LASoperation +{ +public: + inline const CHAR* name() const { return "classify_z_between_as"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %lf %lf %d ", name(), z_below, z_above, class_to); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_Z; }; + inline void transform(LASpoint* point) { + if ((z_below <= point->get_z()) && (point->get_z() <= z_above)) + { + point->set_extended_classification(class_to); + } + }; + LASoperationClassifyZbetweenAs(F64 z_below, F64 z_above, U8 class_to) { this->z_below = z_below; this->z_above = z_above; this->class_to = class_to; }; +private: + F64 z_below; + F64 z_above; + U8 class_to; +}; + +class LASoperationClassifyIntensityBelowAs : public LASoperation +{ +public: + inline const CHAR* name() const { return "classify_intensity_below_as"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d %d ", name(), (I32)intensity_below, (I32)class_to); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_INTENSITY; }; + inline void transform(LASpoint* point) { + if (point->get_intensity() < intensity_below) + { + point->set_extended_classification(class_to); + } + }; + LASoperationClassifyIntensityBelowAs(U16 intensity_below, U8 class_to) { this->intensity_below = intensity_below; this->class_to = class_to; }; +private: + U16 intensity_below; + U8 class_to; +}; + +class LASoperationClassifyIntensityAboveAs : public LASoperation +{ +public: + inline const CHAR* name() const { return "classify_intensity_above_as"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d %d ", name(), (I32)intensity_above, (I32)class_to); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_INTENSITY; }; + inline void transform(LASpoint* point) { + if (point->get_intensity() > intensity_above) + { + point->set_extended_classification(class_to); + } + }; + LASoperationClassifyIntensityAboveAs(U16 intensity_above, U8 class_to) { this->intensity_above = intensity_above; this->class_to = class_to; }; +private: + U16 intensity_above; + U8 class_to; +}; + +class LASoperationClassifyIntensityBetweenAs : public LASoperation +{ +public: + inline const CHAR* name() const { return "classify_intensity_between_as"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d %d %d ", name(), (I32)intensity_below, (I32)intensity_above, (I32)class_to); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_INTENSITY; }; + inline void transform(LASpoint* point) { + if ((intensity_below <= point->get_intensity()) && (point->get_intensity() <= intensity_above)) + { + point->set_extended_classification(class_to); + } + }; + LASoperationClassifyIntensityBetweenAs(U16 intensity_below, U16 intensity_above, U8 class_to) { this->intensity_below = intensity_below; this->intensity_above = intensity_above; this->class_to = class_to; }; +private: + U16 intensity_below; + U16 intensity_above; + U8 class_to; +}; + +class LASoperationClassifyAttributeBelowAs : public LASoperation +{ +public: + inline const CHAR* name() const { return "classify_attribute_below_as"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d %lf %d ", name(), index, below, class_to); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_EXTRA_BYTES; }; + inline void transform(LASpoint* point) { + if (point->get_attribute_as_float(index) < below) + { + point->set_extended_classification(class_to); + } + }; + LASoperationClassifyAttributeBelowAs(U32 index, F64 below, U8 class_to) { this->index = index; this->below = below; this->class_to = class_to; }; +private: + U32 index; + F64 below; + U8 class_to; +}; + +class LASoperationClassifyAttributeAboveAs : public LASoperation +{ +public: + inline const CHAR* name() const { return "classify_attribute_above_as"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d %lf %d ", name(), index, above, class_to); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_EXTRA_BYTES; }; + inline void transform(LASpoint* point) { + if (point->get_attribute_as_float(index) > above) + { + point->set_extended_classification(class_to); + } + }; + LASoperationClassifyAttributeAboveAs(U32 index, F64 above, U8 class_to) { this->index = index; this->above = above; this->class_to = class_to; }; +private: + U32 index; + F64 above; + U8 class_to; +}; + +class LASoperationClassifyAttributeBetweenAs : public LASoperation +{ +public: + inline const CHAR* name() const { return "classify_attribute_between_as"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d %lf %lf %d ", name(), index, below, above, class_to); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_EXTRA_BYTES; }; + inline void transform(LASpoint* point) { + F64 value = point->get_attribute_as_float(index); + if ((below <= value) && (value <= above)) + { + point->set_extended_classification(class_to); + } + }; + LASoperationClassifyAttributeBetweenAs(U32 index, F64 z_below, F64 z_above, U8 class_to) { this->index = index; this->below = z_below; this->above = z_above; this->class_to = class_to; }; +private: + U32 index; + F64 below; + F64 above; + U8 class_to; +}; + +class LASoperationCopyIntensityIntoClassification : public LASoperation +{ +public: + inline const CHAR* name() const { return "copy_intensity_into_classification"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s ", name()); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_INTENSITY; }; + inline void transform(LASpoint* point) { point->set_classification((U8)point->get_intensity()); }; +}; + +class LASoperationSetWithheldFlag : public LASoperation +{ +public: + inline const CHAR* name() const { return "set_withheld_flag"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d ", name(), flag); }; + inline void transform(LASpoint* point) { point->set_withheld_flag(flag); }; + LASoperationSetWithheldFlag(U8 flag) { this->flag = (flag ? 1 : 0); }; +private: + U8 flag; +}; + +class LASoperationSetSyntheticFlag : public LASoperation +{ +public: + inline const CHAR* name() const { return "set_synthetic_flag"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d ", name(), flag); }; + inline void transform(LASpoint* point) { point->set_synthetic_flag(flag); }; + LASoperationSetSyntheticFlag(U8 flag) { this->flag = (flag ? 1 : 0); }; +private: + U8 flag; +}; + +class LASoperationSetKeypointFlag : public LASoperation +{ +public: + inline const CHAR* name() const { return "set_keypoint_flag"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d ", name(), flag); }; + inline void transform(LASpoint* point) { point->set_keypoint_flag(flag); }; + LASoperationSetKeypointFlag(U8 flag) { this->flag = (flag ? 1 : 0); }; +private: + U8 flag; +}; + +class LASoperationSetExtendedOverlapFlag : public LASoperation +{ +public: + inline const CHAR* name() const { return "set_overlap_flag"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d ", name(), flag); }; + inline void transform(LASpoint* point) { point->set_extended_overlap_flag(flag); }; + LASoperationSetExtendedOverlapFlag(U8 flag) { this->flag = (flag ? 1 : 0); }; +private: + U8 flag; +}; + +class LASoperationSetScanDirectionFlag : public LASoperation +{ +public: + inline const CHAR* name() const { return "set_scan_direction_flag"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d ", name(), flag); }; + inline void transform(LASpoint* point) { point->set_scan_direction_flag(flag); }; + LASoperationSetScanDirectionFlag(U8 flag) { this->flag = (flag ? 1 : 0); }; +private: + U8 flag; +}; + +class LASoperationSetEdgeOfFlightLine : public LASoperation +{ +public: + inline const CHAR* name() const { return "set_edge_of_flight_line"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d ", name(), flag); }; + inline void transform(LASpoint* point) { point->set_edge_of_flight_line(flag); }; + LASoperationSetEdgeOfFlightLine(U8 flag) { this->flag = (flag ? 1 : 0); }; +private: + U8 flag; +}; + +class LASoperationSetExtendedScannerChannel : public LASoperation +{ +public: + inline const CHAR* name() const { return "set_scanner_channel"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d ", name(), channel); }; + inline void transform(LASpoint* point) { point->set_extended_scanner_channel(channel); }; + LASoperationSetExtendedScannerChannel(U8 channel) { this->channel = (channel >= 3 ? 3 : channel); }; +private: + U8 channel; +}; + +class LASoperationSetUserData : public LASoperation +{ +public: + inline const CHAR* name() const { return "set_user_data"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d ", name(), user_data); }; + inline void transform(LASpoint* point) { point->user_data = user_data; }; + LASoperationSetUserData(U8 user_data) { this->user_data = user_data; }; +private: + U8 user_data; +}; + +class LASoperationScaleUserData : public LASoperation +{ +public: + inline const CHAR* name() const { return "scale_user_data"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %g ", name(), scale); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_USER_DATA; }; + inline void transform(LASpoint* point) { + point->set_user_data(U8_CLAMP(scale*point->get_user_data())); + }; + LASoperationScaleUserData(F32 scale) { this->scale = scale; }; +private: + F32 scale; +}; + +class LASoperationChangeUserDataFromTo : public LASoperation +{ +public: + inline const CHAR* name() const { return "change_user_data_from_to"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d %d ", name(), user_data_from, user_data_to); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_USER_DATA; }; + inline void transform(LASpoint* point) { if (point->get_user_data() == user_data_from) point->set_user_data(user_data_to); }; + LASoperationChangeUserDataFromTo(U8 user_data_from, U8 user_data_to) { this->user_data_from = user_data_from; this->user_data_to = user_data_to; }; +private: + U8 user_data_from; + U8 user_data_to; +}; + +class LASoperationMapUserData : public LASoperation +{ +public: + inline const CHAR* name() const { return "map_user_data"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s \"%s\" ", name(), map_file_name); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_USER_DATA; }; + inline void transform(LASpoint* point) { U8 user_data = point->get_user_data(); point->set_user_data(map[user_data]); }; + LASoperationMapUserData(const CHAR* file_name) + { + for (U32 u = 0; u < 256; u++) + { + map[u] = u; + } + FILE* file = fopen(file_name, "r"); + if (file) + { + U32 from, to; + CHAR line[128]; + while (fgets(line, 128, file)) + { + if (sscanf(line, "%u %u", &from, &to) == 2) + { + if ((from < 256) && (to < 256)) + { + map[from] = to; + } + } + } + fclose(file); + map_file_name = LASCopyString(file_name); + } + else + { + map_file_name = 0; + } + }; + ~LASoperationMapUserData() { if (map_file_name) free(map_file_name); }; +private: + U8 map[256]; + CHAR* map_file_name; +}; + +class LASoperationCopyClassificationIntoUserData : public LASoperation +{ +public: + inline const CHAR* name() const { return "copy_classification_into_user_data"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s ", name()); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_CLASSIFICATION; }; + inline void transform(LASpoint* point) { point->set_user_data(point->get_classification() ? point->get_classification() : point->get_extended_classification()); }; +}; + +class LASoperationCopyUserDataIntoClassification : public LASoperation +{ +public: + inline const CHAR* name() const { return "copy_user_data_into_classification"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s ", name()); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_USER_DATA; }; + inline void transform(LASpoint* point) { if (point->is_extended_point_type()) point->set_extended_classification(point->get_user_data()); else point->set_classification(point->get_user_data()); }; +}; + +class LASoperationCopyClassificationIntoPointSource : public LASoperation +{ +public: + inline const CHAR* name() const { return "copy_classification_into_point_source"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s ", name()); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_CLASSIFICATION; }; + inline void transform(LASpoint* point) { point->set_point_source_ID(point->get_classification() ? point->get_classification() : point->get_extended_classification()); }; +}; class LASoperationCopyAttributeIntoUserData : public LASoperation { @@ -1052,12 +1593,57 @@ class LASoperationCopyAttributeIntoUserData : public LASoperation U32 index; }; +class LASoperationCopyUserDataIntoAttribute : public LASoperation +{ +public: + inline const CHAR* name() const { return "copy_user_data_into_attribute"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u ", name(), index); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_USER_DATA; }; + inline void transform(LASpoint* point) { + F64 user_data = point->get_user_data(); + point->set_attribute_as_float(index, user_data); + }; + LASoperationCopyUserDataIntoAttribute(U32 index) { this->index = index; }; +private: + U32 index; +}; + +class LASoperationCopyIntensityIntoAttribute : public LASoperation +{ +public: + inline const CHAR* name() const { return "copy_user_data_into_attribute"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u ", name(), index); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_INTENSITY; }; + inline void transform(LASpoint* point) { + F64 user_data = point->get_intensity(); + point->set_attribute_as_float(index, user_data); + }; + LASoperationCopyIntensityIntoAttribute(U32 index) { this->index = index; }; +private: + U32 index; +}; + +class LASoperationCopyZIntoAttribute : public LASoperation +{ +public: + inline const CHAR* name() const { return "copy_z_into_attribute"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u ", name(), index); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_Z; }; + inline void transform(LASpoint* point) { + F64 user_data = point->get_z(); + point->set_attribute_as_float(index, user_data); + }; + LASoperationCopyZIntoAttribute(U32 index) { this->index = index; }; +private: + U32 index; +}; + class LASoperationSetPointSource : public LASoperation { public: inline const CHAR* name() const { return "set_point_source"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d ", name(), psid); }; - inline void transform(LASpoint* point) { point->point_source_ID = psid; }; + inline void transform(LASpoint* point) { point->set_point_source_ID(psid); }; LASoperationSetPointSource(U16 psid) { this->psid = psid; }; private: U16 psid; @@ -1069,7 +1655,7 @@ class LASoperationChangePointSourceFromTo : public LASoperation inline const CHAR* name() const { return "change_point_source_from_to"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d %d ", name(), psid_from, psid_to); }; inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_POINT_SOURCE; }; - inline void transform(LASpoint* point) { if (point->point_source_ID == psid_from) point->point_source_ID = psid_to; }; + inline void transform(LASpoint* point) { if (point->get_point_source_ID() == psid_from) point->set_point_source_ID(psid_to); }; LASoperationChangePointSourceFromTo(U16 psid_from, U16 psid_to) { this->psid_from = psid_from; this->psid_to = psid_to; }; private: U16 psid_from; @@ -1135,7 +1721,7 @@ class LASoperationRepairZeroReturns : public LASoperation public: inline const CHAR* name() const { return "repair_zero_returns"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s ", name()); }; - inline void transform(LASpoint* point) { if (point->number_of_returns == 0) point->number_of_returns = 1; if (point->return_number == 0) point->return_number = 1; }; + inline void transform(LASpoint* point) { if (point->get_number_of_returns() == 0) point->set_number_of_returns(1); if (point->get_return_number() == 0) point->set_return_number(1); }; }; class LASoperationSetReturnNumber : public LASoperation @@ -1143,7 +1729,7 @@ class LASoperationSetReturnNumber : public LASoperation public: inline const CHAR* name() const { return "set_return_number"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d ", name(), return_number); }; - inline void transform(LASpoint* point) { point->return_number = return_number; }; + inline void transform(LASpoint* point) { point->set_return_number(return_number); }; LASoperationSetReturnNumber(U8 return_number) { this->return_number = return_number; }; private: U8 return_number; @@ -1154,7 +1740,7 @@ class LASoperationSetExtendedReturnNumber : public LASoperation public: inline const CHAR* name() const { return "set_extended_return_number"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d ", name(), extended_return_number); }; - inline void transform(LASpoint* point) { point->extended_return_number = extended_return_number; }; + inline void transform(LASpoint* point) { point->set_extended_return_number(extended_return_number); }; LASoperationSetExtendedReturnNumber(U8 extended_return_number) { this->extended_return_number = extended_return_number; }; private: U8 extended_return_number; @@ -1165,19 +1751,31 @@ class LASoperationChangeReturnNumberFromTo : public LASoperation public: inline const CHAR* name() const { return "change_return_number_from_to"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d %d ", name(), return_number_from, return_number_to); }; - inline void transform(LASpoint* point) { if (point->return_number == return_number_from) point->return_number = return_number_to; }; + inline void transform(LASpoint* point) { if (point->get_return_number() == return_number_from) point->set_return_number(return_number_to); }; LASoperationChangeReturnNumberFromTo(U8 return_number_from, U8 return_number_to) { this->return_number_from = return_number_from; this->return_number_to = return_number_to; }; private: U8 return_number_from; U8 return_number_to; }; +class LASoperationChangeExtendedReturnNumberFromTo : public LASoperation +{ +public: + inline const CHAR* name() const { return "change_extended_return_number_from_to"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d %d ", name(), extended_return_number_from, extended_return_number_to); }; + inline void transform(LASpoint* point) { if (point->get_extended_return_number() == extended_return_number_from) point->set_extended_return_number(extended_return_number_to); }; + LASoperationChangeExtendedReturnNumberFromTo(U8 extended_return_number_from, U8 extended_return_number_to) { this->extended_return_number_from = extended_return_number_from; this->extended_return_number_to = extended_return_number_to; }; +private: + U8 extended_return_number_from; + U8 extended_return_number_to; +}; + class LASoperationSetNumberOfReturns : public LASoperation { public: inline const CHAR* name() const { return "set_number_of_returns"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d ", name(), number_of_returns); }; - inline void transform(LASpoint* point) { point->number_of_returns = number_of_returns; }; + inline void transform(LASpoint* point) { point->set_number_of_returns(number_of_returns); }; LASoperationSetNumberOfReturns(U8 number_of_returns) { this->number_of_returns = number_of_returns; }; private: U8 number_of_returns; @@ -1188,7 +1786,7 @@ class LASoperationSetExtendedNumberOfReturns : public LASoperation public: inline const CHAR* name() const { return "set_extended_number_of_returns"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d ", name(), extended_number_of_returns); }; - inline void transform(LASpoint* point) { point->extended_number_of_returns = extended_number_of_returns; }; + inline void transform(LASpoint* point) { point->set_extended_number_of_returns(extended_number_of_returns); }; LASoperationSetExtendedNumberOfReturns(U8 extended_number_of_returns) { this->extended_number_of_returns = extended_number_of_returns; }; private: U8 extended_number_of_returns; @@ -1199,13 +1797,25 @@ class LASoperationChangeNumberOfReturnsFromTo : public LASoperation public: inline const CHAR* name() const { return "change_number_of_returns_from_to"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d %d ", name(), number_of_returns_from, number_of_returns_to); }; - inline void transform(LASpoint* point) { if (point->number_of_returns == number_of_returns_from) point->number_of_returns = number_of_returns_to; }; + inline void transform(LASpoint* point) { if (point->get_number_of_returns() == number_of_returns_from) point->set_number_of_returns(number_of_returns_to); }; LASoperationChangeNumberOfReturnsFromTo(U8 number_of_returns_from, U8 number_of_returns_to) { this->number_of_returns_from = number_of_returns_from; this->number_of_returns_to = number_of_returns_to; }; private: U8 number_of_returns_from; U8 number_of_returns_to; }; +class LASoperationChangeExtendedNumberOfReturnsFromTo : public LASoperation +{ +public: + inline const CHAR* name() const { return "change_extended_number_of_returns_from_to"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d %d ", name(), extended_number_of_returns_from, extended_number_of_returns_to); }; + inline void transform(LASpoint* point) { if (point->get_extended_number_of_returns() == extended_number_of_returns_from) point->set_extended_number_of_returns(extended_number_of_returns_to); }; + LASoperationChangeExtendedNumberOfReturnsFromTo(U8 extended_number_of_returns_from, U8 extended_number_of_returns_to) { this->extended_number_of_returns_from = extended_number_of_returns_from; this->extended_number_of_returns_to = extended_number_of_returns_to; }; +private: + U8 extended_number_of_returns_from; + U8 extended_number_of_returns_to; +}; + class LASoperationSetGpsTime : public LASoperation { public: @@ -1323,6 +1933,72 @@ class LASoperationScaleRGBup : public LASoperation inline void transform(LASpoint* point) { point->rgb[0] = point->rgb[0]*256; point->rgb[1] = point->rgb[1]*256; point->rgb[2] = point->rgb[2]*256; }; }; +class LASoperationScaleRGBto8bit : public LASoperation +{ +public: + inline const CHAR* name() const { return "scale_RGB_to_8bit"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s ", name()); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_RGB; }; + inline void transform(LASpoint* point) { if ((point->get_R() > 255) || (point->get_G() > 255) || (point->get_B() > 255)) { point->rgb[0] = point->rgb[0]/256; point->rgb[1] = point->rgb[1]/256; point->rgb[2] = point->rgb[2]/256; } }; +}; + +class LASoperationScaleRGBto16bit : public LASoperation +{ +public: + inline const CHAR* name() const { return "scale_RGB_to_16bit"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s ", name()); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_RGB; }; + inline void transform(LASpoint* point) { if ((point->get_R() < 256) && (point->get_G() < 256) && (point->get_B() < 256)) { point->rgb[0] = point->rgb[0]*256; point->rgb[1] = point->rgb[1]*256; point->rgb[2] = point->rgb[2]*256; } }; +}; + +class LASoperationScaleNIR : public LASoperation +{ +public: + inline const CHAR* name() const { return "scale_NIR"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %g ", name(), scale); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_NIR; }; + inline void transform(LASpoint* point) { point->rgb[3] = U16_CLAMP(scale*point->rgb[3]); }; + LASoperationScaleNIR(F32 scale_NIR) { scale = scale_NIR; }; +private: + F32 scale; +}; + +class LASoperationScaleNIRdown : public LASoperation +{ +public: + inline const CHAR* name() const { return "scale_NIR_down"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s ", name()); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_NIR; }; + inline void transform(LASpoint* point) { point->rgb[3] = point->rgb[3]/256; }; +}; + +class LASoperationScaleNIRup : public LASoperation +{ +public: + inline const CHAR* name() const { return "scale_NIR_up"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s ", name()); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_NIR; }; + inline void transform(LASpoint* point) { point->rgb[3] = point->rgb[3]*256; }; +}; + +class LASoperationScaleNIRto8bit : public LASoperation +{ +public: + inline const CHAR* name() const { return "scale_NIR_to_8bit"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s ", name()); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_NIR; }; + inline void transform(LASpoint* point) { if (point->get_NIR() > 255) { point->rgb[3] = point->rgb[3]/256; } }; +}; + +class LASoperationScaleNIRto16bit : public LASoperation +{ +public: + inline const CHAR* name() const { return "scale_NIR_to_16bit"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s ", name()); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_NIR; }; + inline void transform(LASpoint* point) { if (point->get_R() < 256) { point->rgb[3] = point->rgb[3]*256; } }; +}; + class LASoperationSwitchXY : public LASoperation { public: @@ -1376,6 +2052,146 @@ class LASoperationSwitchGB : public LASoperation inline void transform(LASpoint* point) { I16 temp = point->get_G(); point->set_G(point->get_B()); point->set_B(temp); }; }; +class LASoperationMapAttributeIntoRGB : public LASoperation +{ +public: + inline const CHAR* name() const { return "map_attribute_into_RGB"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u \"%s\" ", name(), index, map_file_name); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_EXTRA_BYTES; }; + inline void transform(LASpoint* point) + { + if (size) + { + F64 value = point->get_attribute_as_float(index); + if (value <= values[0]) + { + point->set_R(Rs[0]); + point->set_G(Gs[0]); + point->set_B(Bs[0]); + } + else if (value >= values[size-1]) + { + point->set_R(Rs[size-1]); + point->set_G(Gs[size-1]); + point->set_B(Bs[size-1]); + } + else + { + U32 min_pos = 0; + F64 min_abs_dist = (value < values[0] ? values[0] - value : value - values[0]); + U32 pos; + F64 abs_dist; + for (pos = 1; pos < size; pos++) + { + abs_dist = (value < values[pos] ? values[pos] - value : value - values[pos]); + if (abs_dist < min_abs_dist) + { + min_abs_dist = abs_dist; + min_pos = pos; + } + } + point->set_R(Rs[min_pos]); + point->set_G(Gs[min_pos]); + point->set_B(Bs[min_pos]); + } + } + }; + LASoperationMapAttributeIntoRGB(const U32 index, const CHAR* file_name) + { + F64 value; + U32 R, G, B; + CHAR line[256]; + FILE* file = fopen(file_name, "r"); + size = 0; + if (file) + { + while (fgets(line, 256, file)) + { + if (sscanf(line, "%lf %u %u %u", &value, &R, &G, &B) == 4) + { + if ((R <= 255) && (G <= 255) && (B <= 255)) + { + size++; + } + } + } + fclose(file); + } + if (size) + { + U32 count = 0; + values = new F64[size]; + Rs = new U8[size]; + Gs = new U8[size]; + Bs = new U8[size]; + file = fopen(file_name, "r"); + while (fgets(line, 256, file)) + { + if (sscanf(line, "%lf %u %u %u", &value, &R, &G, &B) == 4) + { + if ((R <= 255) && (G <= 255) && (B <= 255)) + { + values[count] = value; + Rs[count] = R; + Gs[count] = G; + Bs[count] = B; + count++; + } + } + } + fclose(file); + } + this->index = index; + map_file_name = LASCopyString(file_name); + }; + ~LASoperationMapAttributeIntoRGB() { if (size) { delete [] values; delete [] Rs; delete [] Gs; delete [] Bs; } free(map_file_name); }; +private: + U32 index; + U32 size; + F64* values; + U8* Rs; + U8* Gs; + U8* Bs; + CHAR* map_file_name; +}; + +class LASoperationLoadAttributeFromText : public LASoperation +{ +public: + inline const CHAR* name() const { return "load_attribute_from_text"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u \"%s\" ", name(), index, file_name); }; + inline void transform(LASpoint* point) + { + if (file) + { + CHAR line[256]; + while (fgets(line, 256, file)) + { + F64 value; + if (sscanf(line, "%lf", &value) == 1) + { + point->set_attribute_as_float(index, value); + return; + } + } + fclose(file); + file = 0; + } + }; + void reset() { if (file) fclose(file); file = fopen(file_name, "r"); }; + LASoperationLoadAttributeFromText(const U32 index, const CHAR* file_name) + { + this->index = index; + this->file_name = LASCopyString(file_name); + file = fopen(this->file_name, "r"); + }; + ~LASoperationLoadAttributeFromText() { if (file) fclose(file); if (file_name) free(file_name); }; +private: + U32 index; + CHAR* file_name; + FILE* file; +}; + class LASoperationCopyRGBintoIntensity : public LASoperation { public: @@ -1394,6 +2210,22 @@ class LASoperationCopyRintoIntensity : public LASoperation inline void transform(LASpoint* point) { point->set_intensity(point->get_R()); }; }; +class LASoperationCopyRBGNIRintoRegister : public LASoperation +{ +public: + inline const CHAR* name() const { return (band == 0 ? "copy_R_into_register" : (band == 1 ? "copy_G_into_register" : (band == 2 ? "copy_B_into_register" : "copy_NIR_into_register"))); }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s ", name()); }; + inline U32 get_decompress_selective() const { return (band < 3 ? LASZIP_DECOMPRESS_SELECTIVE_RGB : LASZIP_DECOMPRESS_SELECTIVE_NIR); }; + inline void transform(LASpoint* point) { + registers[index] = point->get_RGBI(band); + }; + LASoperationCopyRBGNIRintoRegister(const U32 band, F64* registers, const U32 index) { this->band = band; this->registers = registers; this->index = index; }; +private: + F64* registers; + U32 band; + U32 index; +}; + class LASoperationCopyRintoNIR : public LASoperation { public: @@ -1457,6 +2289,38 @@ class LASoperationCopyIntensityIntoNIR : public LASoperation inline void transform(LASpoint* point) { point->set_NIR(point->get_intensity()); }; }; +class LASoperationSwitchRGBItoCIR : public LASoperation +{ +public: + inline const CHAR* name() const { return "switch_RGBI_into_CIR"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s ", name()); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_RGB | LASZIP_DECOMPRESS_SELECTIVE_NIR; }; + inline void transform(LASpoint* point) { + U16 R = point->get_R(); + U16 G = point->get_G(); + U16 I = point->get_NIR(); + point->set_R(I); + point->set_G(R); + point->set_B(G); + }; +}; + +class LASoperationSwitchRGBIntensitytoCIR : public LASoperation +{ +public: + inline const CHAR* name() const { return "switch_RGB_intensity_into_CIR"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s ", name()); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_RGB | LASZIP_DECOMPRESS_SELECTIVE_INTENSITY; }; + inline void transform(LASpoint* point) { + U16 R = point->get_R(); + U16 G = point->get_G(); + U16 intensity = point->get_intensity(); + point->set_R(intensity); + point->set_G(R); + point->set_B(G); + }; +}; + class LASoperationFlipWaveformDirection : public LASoperation { public: @@ -1472,7 +2336,7 @@ class LASoperationCopyUserDataIntoPointSource : public LASoperation inline const CHAR* name() const { return "copy_user_data_into_point_source"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s ", name()); }; inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_USER_DATA; }; - inline void transform(LASpoint* point) { point->point_source_ID = point->get_user_data(); }; + inline void transform(LASpoint* point) { point->set_point_source_ID(point->get_user_data()); }; }; class LASoperationCopyUserDataIntoScannerChannel : public LASoperation @@ -1481,7 +2345,15 @@ class LASoperationCopyUserDataIntoScannerChannel : public LASoperation inline const CHAR* name() const { return "copy_user_data_into_scanner_channel"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s ", name()); }; inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_USER_DATA; }; - inline void transform(LASpoint* point) { point->extended_scanner_channel = (point->get_user_data() & 0x0003); }; + inline void transform(LASpoint* point) { point->set_extended_scanner_channel(point->get_user_data() & 0x0003); }; +}; + +class LASoperationCopyScannerChannelIntoUserData : public LASoperation +{ +public: + inline const CHAR* name() const { return "copy_scanner_channel_into_user_data"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s ", name()); }; + inline void transform(LASpoint* point) { point->set_user_data(point->get_extended_scanner_channel()); }; }; class LASoperationCopyScannerChannelIntoPointSource : public LASoperation @@ -1489,7 +2361,7 @@ class LASoperationCopyScannerChannelIntoPointSource : public LASoperation public: inline const CHAR* name() const { return "copy_scanner_channel_into_point_source"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s ", name()); }; - inline void transform(LASpoint* point) { point->point_source_ID = point->get_extended_scanner_channel(); }; + inline void transform(LASpoint* point) { point->set_point_source_ID(point->get_extended_scanner_channel()); }; }; class LASoperationMergeScannerChannelIntoPointSource : public LASoperation @@ -1498,7 +2370,7 @@ class LASoperationMergeScannerChannelIntoPointSource : public LASoperation inline const CHAR* name() const { return "merge_scanner_channel_into_point_source"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s ", name()); }; inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_POINT_SOURCE; }; - inline void transform(LASpoint* point) { point->point_source_ID = (point->get_point_source_ID() << 2) | point->get_extended_scanner_channel(); }; + inline void transform(LASpoint* point) { point->set_point_source_ID((point->get_point_source_ID() << 2) | point->get_extended_scanner_channel()); }; }; class LASoperationSplitScannerChannelFromPointSource : public LASoperation @@ -1507,7 +2379,7 @@ class LASoperationSplitScannerChannelFromPointSource : public LASoperation inline const CHAR* name() const { return "split_scanner_channel_from_point_source"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s ", name()); }; inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_POINT_SOURCE; }; - inline void transform(LASpoint* point) { point->extended_scanner_channel = (point->get_point_source_ID() & 0x0003); point->point_source_ID = (point->get_point_source_ID() >> 2); }; + inline void transform(LASpoint* point) { point->set_extended_scanner_channel(point->get_point_source_ID() & 0x0003); point->set_point_source_ID(point->get_point_source_ID() >> 2); }; }; class LASoperationBinZintoPointSource : public LASoperation @@ -1516,7 +2388,7 @@ class LASoperationBinZintoPointSource : public LASoperation inline const CHAR* name() const { return "bin_Z_into_point_source"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d", name(), bin_size); }; inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_Z; }; - inline void transform(LASpoint* point) { point->point_source_ID = U16_CLAMP(point->get_Z()/bin_size); }; + inline void transform(LASpoint* point) { point->set_point_source_ID(U16_CLAMP(point->get_Z()/bin_size)); }; LASoperationBinZintoPointSource(I32 bin_size=1) { this->bin_size = bin_size; }; private: I32 bin_size; @@ -1528,7 +2400,7 @@ class LASoperationBinAbsScanAngleIntoPointSource : public LASoperation inline const CHAR* name() const { return "bin_abs_scan_angle_into_point_source"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %g", name(), bin_size); }; inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_SCAN_ANGLE; }; - inline void transform(LASpoint* point) { point->point_source_ID = U16_CLAMP(point->get_abs_scan_angle()/bin_size); }; + inline void transform(LASpoint* point) { point->set_point_source_ID(U16_CLAMP(point->get_abs_scan_angle()/bin_size)); }; LASoperationBinAbsScanAngleIntoPointSource(F32 bin_size=1.0f) { this->bin_size = bin_size; }; private: F32 bin_size; @@ -1544,9 +2416,25 @@ class LASoperationAddAttributeToZ : public LASoperation F64 z = point->get_z() + point->get_attribute_as_float(index); point->set_z(z); }; - LASoperationAddAttributeToZ(U32 index) { this->index = index; }; + LASoperationAddAttributeToZ(U32 index) { this->index = index; }; +private: + U32 index; +}; + +class LASoperationMultiplyScaledIntensityIntoRGB : public LASoperation +{ +public: + inline const CHAR* name() const { return "multiply_scaled_intensity_into_RGB"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s_%s %f ", name(), (channel == 0 ? "red" : (channel == 1 ? "green" : (channel == 2 ? "blue" : "nir"))), scale); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_INTENSITY | LASZIP_DECOMPRESS_SELECTIVE_RGB; }; + inline void transform(LASpoint* point) { + F32 rgb = scale * point->get_intensity() * point->rgb[channel]; + point->rgb[channel] = U16_CLAMP(rgb); + }; + LASoperationMultiplyScaledIntensityIntoRGB(U32 channel, F32 scale) { this->channel = channel; this->scale = scale; }; private: - U32 index; + U32 channel; + F32 scale; }; class LASoperationAddScaledAttributeToZ : public LASoperation @@ -1581,6 +2469,18 @@ class LASoperationAddScaledAttributeToUserData : public LASoperation F32 scale; }; +class LASoperationSetAttribute : public LASoperation +{ +public: + inline const CHAR* name() const { return "set_attribute"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u %g ", name(), index, value); }; + inline void transform(LASpoint* point) { point->set_attribute_as_float(index, value); }; + LASoperationSetAttribute(U32 index, F64 value) { this->index = index; this->value = value; }; +private: + U32 index; + F64 value; +}; + class LASoperationScaleAttribute : public LASoperation { public: @@ -1613,6 +2513,24 @@ class LASoperationTranslateAttribute : public LASoperation F64 offset; }; +void LAStransform::check_for_overflow() const +{ + U32 i; + for (i = 0; i < num_operations; i++) + { + if (operations[i]->get_overflow()) + { + CHAR command[256]; + operations[i]->get_command(command); +#ifdef _WIN32 + fprintf(stderr, "WARNING: total of %I64d overflows caused by '%s'\n", operations[i]->get_overflow(), command); +#else + fprintf(stderr, "WARNING: total of %lld overflows caused by '%s'\n", operations[i]->get_overflow(), command); +#endif + } + } +} + void LAStransform::clean() { U32 i; @@ -1621,7 +2539,7 @@ void LAStransform::clean() delete operations[i]; } if (operations) delete [] operations; - change_coordinates = FALSE; + transformed_fields = 0; alloc_operations = 0; num_operations = 0; operations = 0; @@ -1634,109 +2552,143 @@ void LAStransform::clean() void LAStransform::usage() const { - REprintf("Transform coordinates.\n"); - REprintf(" -translate_x -2.5\n"); - REprintf(" -scale_z 0.3048\n"); - REprintf(" -rotate_xy 15.0 620000 4100000 (angle + origin)\n"); - REprintf(" -translate_xyz 0.5 0.5 0\n"); - REprintf(" -translate_then_scale_y -0.5 1.001\n"); - REprintf(" -transform_helmert -199.87,74.79,246.62\n"); - REprintf(" -transform_helmert 598.1,73.7,418.2,0.202,0.045,-2.455,6.7\n"); - REprintf(" -transform_affine 0.9999652,0.903571,171.67,736.26\n"); - REprintf(" -switch_x_y -switch_x_z -switch_y_z\n"); - REprintf(" -clamp_z_below 70.5\n"); - REprintf(" -clamp_z 70.5 72.5\n"); - REprintf(" -copy_attribute_into_z 0\n"); - REprintf(" -add_attribute_to_z 1\n"); - REprintf(" -add_scaled_attribute_to_z 1 -1.2\n"); - REprintf(" -copy_intensity_into_z\n"); - REprintf("Transform raw xyz integers.\n"); - REprintf(" -translate_raw_z 20\n"); - REprintf(" -translate_raw_xyz 1 1 0\n"); - REprintf(" -translate_raw_xy_at_random 2 2\n"); - REprintf(" -clamp_raw_z 500 800\n"); - REprintf("Transform intensity.\n"); - REprintf(" -set_intensity 0\n"); - REprintf(" -scale_intensity 2.5\n"); - REprintf(" -translate_intensity 50\n"); - REprintf(" -translate_then_scale_intensity 0.5 3.1\n"); - REprintf(" -clamp_intensity 0 255\n"); - REprintf(" -clamp_intensity_above 255\n"); - REprintf(" -copy_RGB_into_intensity\n"); - REprintf(" -copy_NIR_into_intensity\n"); - REprintf(" -copy_attribute_into_intensity 0\n"); - REprintf(" -bin_gps_time_into_intensity 0.5\n"); - REprintf("Transform scan_angle.\n"); - REprintf(" -set_scan_angle 0.0\n"); - REprintf(" -scale_scan_angle 1.944445\n"); - REprintf(" -translate_scan_angle -5\n"); - REprintf(" -translate_then_scale_scan_angle -0.5 2.1\n"); - REprintf("Change the return number or return count of points.\n"); - REprintf(" -repair_zero_returns\n"); - REprintf(" -set_return_number 1\n"); - REprintf(" -set_extended_return_number 10\n"); - REprintf(" -change_return_number_from_to 2 1\n"); - REprintf(" -set_number_of_returns 2\n"); - REprintf(" -set_number_of_returns 15\n"); - REprintf(" -change_number_of_returns_from_to 0 2\n"); - REprintf("Modify the classification.\n"); - REprintf(" -set_classification 2\n"); - REprintf(" -set_extended_classification 41\n"); - REprintf(" -change_classification_from_to 2 4\n"); - REprintf(" -classify_z_below_as -5.0 7\n"); - REprintf(" -classify_z_above_as 70.0 7\n"); - REprintf(" -classify_z_between_as 2.0 5.0 4\n"); - REprintf(" -classify_intensity_above_as 200 9\n"); - REprintf(" -classify_intensity_below_as 30 11 \n"); - REprintf(" -classify_intensity_between_as 500 900 15\n"); - REprintf(" -classify_attribute_below_as 0 -5.0 7\n"); - REprintf(" -classify_attribute_above_as 1 70.0 7\n"); - REprintf(" -classify_attribute_between_as 1 2.0 5.0 4\n"); - REprintf(" -change_extended_classification_from_to 6 46\n"); - REprintf(" -move_ancient_to_extended_classification\n"); - REprintf("Change the flags.\n"); - REprintf(" -set_withheld_flag 0\n"); - REprintf(" -set_synthetic_flag 1\n"); - REprintf(" -set_keypoint_flag 0\n"); - REprintf(" -set_overlap_flag 1\n"); - REprintf("Modify the extended scanner channel.\n"); - REprintf(" -set_scanner_channel 2\n"); - REprintf(" -copy_user_data_into_scanner_channel\n"); - REprintf("Modify the user data.\n"); - REprintf(" -set_user_data 0\n"); - REprintf(" -scale_user_data 1.5\n"); - REprintf(" -change_user_data_from_to 23 26\n"); - REprintf(" -change_user_data_from_to 23 26\n"); - REprintf(" -copy_attribute_into_user_data 1\n"); - REprintf(" -add_scaled_attribute_to_user_data 0 10.0\n"); - REprintf("Modify the point source ID.\n"); - REprintf(" -set_point_source 500\n"); - REprintf(" -change_point_source_from_to 1023 1024\n"); - REprintf(" -copy_user_data_into_point_source\n"); - REprintf(" -copy_scanner_channel_into_point_source\n"); - REprintf(" -merge_scanner_channel_into_point_source\n"); - REprintf(" -split_scanner_channel_from_point_source\n"); - REprintf(" -bin_Z_into_point_source 200\n"); - REprintf(" -bin_abs_scan_angle_into_point_source 2\n"); - REprintf("Transform gps_time.\n"); - REprintf(" -set_gps_time 113556962.005715\n"); - REprintf(" -translate_gps_time 40.50\n"); - REprintf(" -adjusted_to_week\n"); - REprintf(" -week_to_adjusted 1671\n"); - REprintf("Transform RGB/NIR colors.\n"); - REprintf(" -set_RGB 255 0 127\n"); - REprintf(" -set_RGB_of_class 9 0 0 255\n"); - REprintf(" -scale_RGB 2 4 2\n"); - REprintf(" -scale_RGB_down (by 256)\n"); - REprintf(" -scale_RGB_up (by 256)\n"); - REprintf(" -switch_R_G -switch_R_B -switch_B_G\n"); - REprintf(" -copy_R_into_NIR -copy_R_into_intensity\n"); - REprintf(" -copy_G_into_NIR -copy_G_into_intensity\n"); - REprintf(" -copy_B_into_NIR -copy_B_into_intensity\n"); - REprintf(" -copy_intensity_into_NIR\n"); - REprintf("Transform attributes in \"Extra Bytes\".\n"); - REprintf(" -scale_attribute 0 1.5\n"); - REprintf(" -translate_attribute 1 0.2\n"); + fprintf(stderr,"Transform coordinates.\n"); + fprintf(stderr," -translate_x -2.5\n"); + fprintf(stderr," -scale_z 0.3048\n"); + fprintf(stderr," -rotate_xy 15.0 620000 4100000 (angle + origin)\n"); + fprintf(stderr," -translate_xyz 0.5 0.5 0\n"); + fprintf(stderr," -translate_then_scale_y -0.5 1.001\n"); + fprintf(stderr," -transform_helmert -199.87,74.79,246.62\n"); + fprintf(stderr," -transform_helmert 598.1,73.7,418.2,0.202,0.045,-2.455,6.7\n"); + fprintf(stderr," -transform_affine 0.9999652,0.903571,171.67,736.26\n"); + fprintf(stderr," -switch_x_y -switch_x_z -switch_y_z\n"); + fprintf(stderr," -clamp_z_below 70.5\n"); + fprintf(stderr," -clamp_z 70.5 72.5\n"); + fprintf(stderr," -copy_attribute_into_z 0\n"); + fprintf(stderr," -add_attribute_to_z 1\n"); + fprintf(stderr," -add_scaled_attribute_to_z 1 -1.2\n"); + fprintf(stderr," -copy_intensity_into_z\n"); + fprintf(stderr," -copy_user_data_into_z\n"); + fprintf(stderr,"Transform raw xyz integers.\n"); + fprintf(stderr," -translate_raw_z 20\n"); + fprintf(stderr," -translate_raw_xyz 1 1 0\n"); + fprintf(stderr," -translate_raw_xy_at_random 2 2\n"); + fprintf(stderr," -clamp_raw_z 500 800\n"); + fprintf(stderr,"Transform intensity.\n"); + fprintf(stderr," -set_intensity 0\n"); + fprintf(stderr," -scale_intensity 2.5\n"); + fprintf(stderr," -translate_intensity 50\n"); + fprintf(stderr," -translate_then_scale_intensity 0.5 3.1\n"); + fprintf(stderr," -clamp_intensity 0 255\n"); + fprintf(stderr," -clamp_intensity_above 255\n"); + fprintf(stderr," -map_intensity map_file.txt\n"); + fprintf(stderr," -copy_RGB_into_intensity\n"); + fprintf(stderr," -copy_NIR_into_intensity\n"); + fprintf(stderr," -copy_attribute_into_intensity 0\n"); + fprintf(stderr," -bin_gps_time_into_intensity 0.5\n"); + fprintf(stderr,"Transform scan_angle.\n"); + fprintf(stderr," -set_scan_angle 0.0\n"); + fprintf(stderr," -scale_scan_angle 1.944445\n"); + fprintf(stderr," -translate_scan_angle -5\n"); + fprintf(stderr," -translate_then_scale_scan_angle -0.5 2.1\n"); + fprintf(stderr,"Change the return number or return count of points.\n"); + fprintf(stderr," -repair_zero_returns\n"); + fprintf(stderr," -set_return_number 1\n"); + fprintf(stderr," -set_extended_return_number 10\n"); + fprintf(stderr," -change_return_number_from_to 2 1\n"); + fprintf(stderr," -change_extended_return_number_from_to 2 8\n"); + fprintf(stderr," -set_number_of_returns 2\n"); + fprintf(stderr," -set_extended_number_of_returns 15\n"); + fprintf(stderr," -change_number_of_returns_from_to 0 2\n"); + fprintf(stderr," -change_extended_number_of_returns_from_to 8 10\n"); + fprintf(stderr,"Modify the classification.\n"); + fprintf(stderr," -set_classification 2\n"); + fprintf(stderr," -set_extended_classification 41\n"); + fprintf(stderr," -change_classification_from_to 2 4\n"); + fprintf(stderr," -classify_z_below_as -5.0 7\n"); + fprintf(stderr," -classify_z_above_as 70.0 7\n"); + fprintf(stderr," -classify_z_between_as 2.0 5.0 4\n"); + fprintf(stderr," -classify_intensity_above_as 200 9\n"); + fprintf(stderr," -classify_intensity_below_as 30 11 \n"); + fprintf(stderr," -classify_intensity_between_as 500 900 15\n"); + fprintf(stderr," -classify_attribute_below_as 0 -5.0 7\n"); + fprintf(stderr," -classify_attribute_above_as 1 70.0 7\n"); + fprintf(stderr," -classify_attribute_between_as 1 2.0 5.0 4\n"); + fprintf(stderr," -change_extended_classification_from_to 6 46\n"); + fprintf(stderr," -move_ancient_to_extended_classification\n"); + fprintf(stderr," -copy_user_data_into_classification\n"); + fprintf(stderr,"Change the flags.\n"); + fprintf(stderr," -set_withheld_flag 0\n"); + fprintf(stderr," -set_synthetic_flag 1\n"); + fprintf(stderr," -set_keypoint_flag 0\n"); + fprintf(stderr," -set_overlap_flag 1\n"); + fprintf(stderr,"Modify the extended scanner channel.\n"); + fprintf(stderr," -set_scanner_channel 2\n"); + fprintf(stderr," -copy_user_data_into_scanner_channel\n"); + fprintf(stderr,"Modify the user data.\n"); + fprintf(stderr," -set_user_data 0\n"); + fprintf(stderr," -scale_user_data 1.5\n"); + fprintf(stderr," -change_user_data_from_to 23 26\n"); + fprintf(stderr," -change_user_data_from_to 23 26\n"); + fprintf(stderr," -map_user_data map_file.txt\n"); + fprintf(stderr," -copy_scanner_channel_into_user_data\n"); + fprintf(stderr," -copy_attribute_into_user_data 1\n"); + fprintf(stderr," -add_scaled_attribute_to_user_data 0 10.0\n"); + fprintf(stderr,"Modify the point source ID.\n"); + fprintf(stderr," -set_point_source 500\n"); + fprintf(stderr," -change_point_source_from_to 1023 1024\n"); + fprintf(stderr," -map_point_source map_file.txt\n"); + fprintf(stderr," -copy_user_data_into_point_source\n"); + fprintf(stderr," -copy_scanner_channel_into_point_source\n"); + fprintf(stderr," -copy_attribute_into_point_source 0\n"); + fprintf(stderr," -merge_scanner_channel_into_point_source\n"); + fprintf(stderr," -split_scanner_channel_from_point_source\n"); + fprintf(stderr," -bin_Z_into_point_source 200\n"); + fprintf(stderr," -bin_abs_scan_angle_into_point_source 2\n"); + fprintf(stderr," -bin_gps_time_into_point_source 5.0\n"); + fprintf(stderr,"Transform gps_time.\n"); + fprintf(stderr," -set_gps_time 113556962.005715\n"); + fprintf(stderr," -translate_gps_time 40.50\n"); + fprintf(stderr," -adjusted_to_week\n"); + fprintf(stderr," -week_to_adjusted 1671\n"); + fprintf(stderr,"Transform RGB/NIR colors.\n"); + fprintf(stderr," -set_RGB 255 0 127\n"); + fprintf(stderr," -set_RGB_of_class 9 0 0 255\n"); + fprintf(stderr," -scale_RGB 2 4 2\n"); + fprintf(stderr," -scale_RGB_down (by 256)\n"); + fprintf(stderr," -scale_RGB_up (by 256)\n"); + fprintf(stderr," -scale_RGB_to_8bit (only scales down 16 bit values)\n"); + fprintf(stderr," -scale_RGB_to_16bit (only scales up 8 bit values)\n"); + fprintf(stderr," -scale_NIR 2\n"); + fprintf(stderr," -scale_NIR_down (by 256)\n"); + fprintf(stderr," -scale_NIR_up (by 256)\n"); + fprintf(stderr," -scale_NIR_to_8bit (only scales down 16 bit values)\n"); + fprintf(stderr," -scale_NIR_to_16bit (only scales up 8 bit values)\n"); + fprintf(stderr," -switch_R_G -switch_R_B -switch_B_G\n"); + fprintf(stderr," -copy_R_into_NIR -copy_R_into_intensity\n"); + fprintf(stderr," -copy_G_into_NIR -copy_G_into_intensity\n"); + fprintf(stderr," -copy_B_into_NIR -copy_B_into_intensity\n"); + fprintf(stderr," -copy_intensity_into_NIR\n"); + fprintf(stderr," -switch_RGBI_into_CIR\n"); + fprintf(stderr," -switch_RGB_intensity_into_CIR\n"); + fprintf(stderr,"Transform attributes in \"Extra Bytes\".\n"); + fprintf(stderr," -scale_attribute 0 1.5\n"); + fprintf(stderr," -translate_attribute 1 0.2\n"); + fprintf(stderr," -copy_user_data_into_attribute 0\n"); + fprintf(stderr," -copy_z_into_attribute 0\n"); + fprintf(stderr," -map_attribute_into_RGB 0 map_height_to_RGB.txt\n"); + fprintf(stderr,"Transform using \"LASregisters\".\n"); + fprintf(stderr," -copy_attribute_into_register 0 0\n"); + fprintf(stderr," -scale_register 0 1.5\n"); + fprintf(stderr," -translate_register 1 10.7\n"); + fprintf(stderr," -add_registers 0 1 3\n"); + fprintf(stderr," -multiply_registers 0 1 2\n"); + fprintf(stderr," -copy_intensity_into_register 0\n"); + fprintf(stderr," -copy_R_into_register 1\n"); + fprintf(stderr," -copy_G_into_register 2\n"); + fprintf(stderr," -copy_B_into_register 3\n"); + fprintf(stderr," -copy_NIR_into_register 4\n"); + fprintf(stderr," -copy_register_into_intensity 1\n"); } BOOL LAStransform::parse(int argc, char* argv[]) @@ -1760,150 +2712,152 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: offset\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: offset\n", argv[i]); return FALSE; } F64 offset; if (sscanf(argv[i+1], "%lf", &offset) != 1) { - REprintf("ERROR: '%s' needs 1 argument: offset but '%s' is no valid number\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: offset but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } - change_coordinates = TRUE; + transformed_fields |= LASTRANSFORM_X_COORDINATE; add_operation(new LASoperationTranslateX(offset)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-translate_y") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: offset\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: offset\n", argv[i]); return FALSE; } F64 offset; if (sscanf(argv[i+1], "%lf", &offset) != 1) { - REprintf("ERROR: '%s' needs 1 argument: offset but '%s' is no valid number\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: offset but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } - change_coordinates = TRUE; + transformed_fields |= LASTRANSFORM_Y_COORDINATE; add_operation(new LASoperationTranslateY(offset)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-translate_z") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: offset\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: offset\n", argv[i]); return FALSE; } F64 offset; if (sscanf(argv[i+1], "%lf", &offset) != 1) { - REprintf("ERROR: '%s' needs 1 argument: offset but '%s' is no valid number\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: offset but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } - change_coordinates = TRUE; + transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationTranslateZ(offset)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-translate_xyz") == 0) { if ((i+3) >= argc) { - REprintf("ERROR: '%s' needs 3 arguments: offset_x offset_y offset_z\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: offset_x offset_y offset_z\n", argv[i]); return FALSE; } F64 offset_x; if (sscanf(argv[i+1], "%lf", &offset_x) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: offset_x offset_y offset_z but '%s' is no valid number\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: offset_x offset_y offset_z but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } F64 offset_y; if (sscanf(argv[i+2], "%lf", &offset_y) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: offset_x offset_y offset_z but '%s' is no valid number\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: offset_x offset_y offset_z but '%s' is no valid number\n", argv[i], argv[i+2]); return FALSE; } F64 offset_z; if (sscanf(argv[i+3], "%lf", &offset_z) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: offset_x offset_y offset_z but '%s' is no valid number\n", argv[i], argv[i+3]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: offset_x offset_y offset_z but '%s' is no valid number\n", argv[i], argv[i+3]); return FALSE; } - change_coordinates = TRUE; + if (offset_x) transformed_fields |= LASTRANSFORM_X_COORDINATE; + if (offset_y) transformed_fields |= LASTRANSFORM_Y_COORDINATE; + if (offset_z) transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationTranslateXYZ(offset_x, offset_y, offset_z)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } else if (strcmp(argv[i],"-translate_then_scale_x") == 0) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: offset scale\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale\n", argv[i]); return FALSE; } F64 offset; if (sscanf(argv[i+1], "%lf", &offset) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid number\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } F64 scale; if (sscanf(argv[i+2], "%lf", &scale) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid number\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid number\n", argv[i], argv[i+2]); return FALSE; } - change_coordinates = TRUE; + transformed_fields |= LASTRANSFORM_X_COORDINATE; add_operation(new LASoperationTranslateThenScaleX(offset, scale)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-translate_then_scale_y") == 0) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: offset scale\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale\n", argv[i]); return FALSE; } F64 offset; if (sscanf(argv[i+1], "%lf", &offset) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid number\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } F64 scale; if (sscanf(argv[i+2], "%lf", &scale) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid number\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid number\n", argv[i], argv[i+2]); return FALSE; } - change_coordinates = TRUE; + transformed_fields |= LASTRANSFORM_Y_COORDINATE; add_operation(new LASoperationTranslateThenScaleY(offset, scale)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-translate_then_scale_z") == 0) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: offset scale\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale\n", argv[i]); return FALSE; } F64 offset; if (sscanf(argv[i+1], "%lf", &offset) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid number\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } F64 scale; if (sscanf(argv[i+2], "%lf", &scale) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid number\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid number\n", argv[i], argv[i+2]); return FALSE; } - change_coordinates = TRUE; + transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationTranslateThenScaleZ(offset, scale)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strncmp(argv[i],"-translate_raw_", 14) == 0) { @@ -1911,219 +2865,244 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: raw_offset\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: raw_offset\n", argv[i]); return FALSE; } I32 raw_offset; if (sscanf(argv[i+1], "%d", &raw_offset) != 1) { - REprintf("ERROR: '%s' needs 1 argument: raw_offset but '%s' is no valid raw_offset\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: raw_offset but '%s' is no valid raw_offset\n", argv[i], argv[i+1]); return FALSE; } - change_coordinates = TRUE; + transformed_fields |= LASTRANSFORM_X_COORDINATE; add_operation(new LASoperationTranslateRawX(raw_offset)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-translate_raw_y") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: raw_offset\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: raw_offset\n", argv[i]); return FALSE; } I32 raw_offset; if (sscanf(argv[i+1], "%d", &raw_offset) != 1) { - REprintf("ERROR: '%s' needs 1 argument: raw_offset but '%s' is no valid raw_offset\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: raw_offset but '%s' is no valid raw_offset\n", argv[i], argv[i+1]); return FALSE; } - change_coordinates = TRUE; + transformed_fields |= LASTRANSFORM_Y_COORDINATE; add_operation(new LASoperationTranslateRawY(raw_offset)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-translate_raw_z") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: raw_offset\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: raw_offset\n", argv[i]); return FALSE; } I32 raw_offset; if (sscanf(argv[i+1], "%d", &raw_offset) != 1) { - REprintf("ERROR: '%s' needs 1 argument: raw_offset but '%s' is no valid raw_offset\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: raw_offset but '%s' is no valid raw_offset\n", argv[i], argv[i+1]); return FALSE; } - change_coordinates = TRUE; + transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationTranslateRawZ(raw_offset)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-translate_raw_xyz") == 0) { if ((i+3) >= argc) { - REprintf("ERROR: '%s' needs 3 arguments: raw_offset_x raw_offset_y raw_offset_z\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: raw_offset_x raw_offset_y raw_offset_z\n", argv[i]); return FALSE; } I32 raw_offset_x; if (sscanf(argv[i+1], "%d", &raw_offset_x) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: raw_offset_x raw_offset_y raw_offset_z but '%s' is no valid raw_offset_x\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: raw_offset_x raw_offset_y raw_offset_z but '%s' is no valid raw_offset_x\n", argv[i], argv[i+1]); return FALSE; } I32 raw_offset_y; if (sscanf(argv[i+2], "%d", &raw_offset_y) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: raw_offset_x raw_offset_y raw_offset_z but '%s' is no valid raw_offset_y\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: raw_offset_x raw_offset_y raw_offset_z but '%s' is no valid raw_offset_y\n", argv[i], argv[i+2]); return FALSE; } I32 raw_offset_z; if (sscanf(argv[i+3], "%d", &raw_offset_z) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: raw_offset_x raw_offset_y raw_offset_z but '%s' is no valid raw_offset_z\n", argv[i], argv[i+3]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: raw_offset_x raw_offset_y raw_offset_z but '%s' is no valid raw_offset_z\n", argv[i], argv[i+3]); return FALSE; } - change_coordinates = TRUE; + if (raw_offset_x) transformed_fields |= LASTRANSFORM_X_COORDINATE; + if (raw_offset_y) transformed_fields |= LASTRANSFORM_Y_COORDINATE; + if (raw_offset_z) transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationTranslateRawXYZ(raw_offset_x, raw_offset_y, raw_offset_z)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } else if (strcmp(argv[i],"-translate_raw_xy_at_random") == 0) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: max_raw_offset_x max_raw_offset_y\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: max_raw_offset_x max_raw_offset_y\n", argv[i]); return FALSE; } I32 max_raw_offset_x; if (sscanf(argv[i+1], "%d", &max_raw_offset_x) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: max_raw_offset_x max_raw_offset_y but '%s' is no valid max_raw_offset_x\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: max_raw_offset_x max_raw_offset_y but '%s' is no valid max_raw_offset_x\n", argv[i], argv[i+1]); return FALSE; } I32 max_raw_offset_y; if (sscanf(argv[i+2], "%d", &max_raw_offset_y) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: max_raw_offset_x max_raw_offset_y but '%s' is no valid max_raw_offset_y\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: max_raw_offset_x max_raw_offset_y but '%s' is no valid max_raw_offset_y\n", argv[i], argv[i+2]); return FALSE; } - change_coordinates = TRUE; + if (max_raw_offset_x) transformed_fields |= LASTRANSFORM_X_COORDINATE; + if (max_raw_offset_y) transformed_fields |= LASTRANSFORM_Y_COORDINATE; add_operation(new LASoperationTranslateRawXYatRandom(max_raw_offset_x, max_raw_offset_y)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } } else if (strcmp(argv[i],"-translate_intensity") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: offset\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: offset\n", argv[i]); return FALSE; } F32 offset; if (sscanf(argv[i+1], "%f", &offset) != 1) { - REprintf("ERROR: '%s' needs 1 argument: offset but '%s' is no valid offset\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: offset but '%s' is no valid offset\n", argv[i], argv[i+1]); return FALSE; } add_operation(new LASoperationTranslateIntensity(offset)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-translate_then_scale_intensity") == 0) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: offset scale\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale\n", argv[i]); return FALSE; } F32 offset; if (sscanf(argv[i+1], "%f", &offset) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid offset\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid offset\n", argv[i], argv[i+1]); return FALSE; } F32 scale; if (sscanf(argv[i+2], "%f", &scale) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid scale\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid scale\n", argv[i], argv[i+2]); return FALSE; } add_operation(new LASoperationTranslateThenScaleIntensity(offset, scale)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-translate_scan_angle") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: offset\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: offset\n", argv[i]); return FALSE; } F32 offset; if (sscanf(argv[i+1], "%f", &offset) != 1) { - REprintf("ERROR: '%s' needs 1 argument: offset but '%s' is no valid offset\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: offset but '%s' is no valid offset\n", argv[i], argv[i+1]); return FALSE; } add_operation(new LASoperationTranslateScanAngle(offset)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-translate_then_scale_scan_angle") == 0) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: offset scale\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale\n", argv[i]); return FALSE; } F32 offset; if (sscanf(argv[i+1], "%f", &offset) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid offset\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid offset\n", argv[i], argv[i+1]); return FALSE; } F32 scale; if (sscanf(argv[i+2], "%f", &scale) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid scale\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid scale\n", argv[i], argv[i+2]); return FALSE; } add_operation(new LASoperationTranslateThenScaleScanAngle(offset, scale)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-translate_gps_time") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: offset\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: offset\n", argv[i]); return FALSE; } F64 offset; if (sscanf(argv[i+1], "%lf", &offset) != 1) { - REprintf("ERROR: '%s' needs 1 argument: offset but '%s' is no valid offset\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: offset but '%s' is no valid offset\n", argv[i], argv[i+1]); return FALSE; } add_operation(new LASoperationTranslateGpsTime(offset)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-translate_attribute") == 0) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: index offset\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index offset\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: index offset but '%s' is no valid index\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index offset but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } F64 offset; if (sscanf(argv[i+2], "%lf", &offset) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: index offset but '%s' is no valid offset\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index offset but '%s' is no valid offset\n", argv[i], argv[i+2]); return FALSE; } add_operation(new LASoperationTranslateAttribute(index, offset)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + } + else if (strcmp(argv[i],"-translate_register") == 0) + { + if ((i+2) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index offset\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index offset but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + F64 offset; + if (sscanf(argv[i+2], "%lf", &offset) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index offset but '%s' is no valid offset\n", argv[i], argv[i+2]); + return FALSE; + } + add_operation(new LASoperationTranslateRegister(registers, index, offset)); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } } else if (strncmp(argv[i],"-rotate_", 8) == 0) @@ -2132,59 +3111,106 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+3) >= argc) { - REprintf("ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_y\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_y\n", argv[i]); return FALSE; } F64 angle; if (sscanf(argv[i+1], "%lf", &angle) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_y but '%s' is no valid angle\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_y but '%s' is no valid angle\n", argv[i], argv[i+1]); + return FALSE; + } + if (angle == 0.0) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_y but %g is no valid angle\n", argv[i], angle); return FALSE; } F64 rot_center_x; if (sscanf(argv[i+2], "%lf", &rot_center_x) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_y but '%s' is no valid rot_center_x\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_y but '%s' is no valid rot_center_x\n", argv[i], argv[i+2]); return FALSE; } F64 rot_center_y; if (sscanf(argv[i+3], "%lf", &rot_center_y) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_y but '%s' is no valid rot_center_y\n", argv[i], argv[i+3]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_y but '%s' is no valid rot_center_y\n", argv[i], argv[i+3]); return FALSE; } - change_coordinates = TRUE; + transformed_fields |= LASTRANSFORM_X_COORDINATE; + transformed_fields |= LASTRANSFORM_Y_COORDINATE; add_operation(new LASoperationRotateXY(angle, rot_center_x, rot_center_y)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } else if (strcmp(argv[i],"-rotate_xz") == 0) { if ((i+3) >= argc) { - REprintf("ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_z\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_z\n", argv[i]); return FALSE; } F64 angle; if (sscanf(argv[i+1], "%lf", &angle) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_z but '%s' is no valid angle\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_z but '%s' is no valid angle\n", argv[i], argv[i+1]); + return FALSE; + } + if (angle == 0.0) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_y but %g is no valid angle\n", argv[i], angle); return FALSE; } F64 rot_center_x; if (sscanf(argv[i+2], "%lf", &rot_center_x) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_z but '%s' is no valid rot_center_x\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_z but '%s' is no valid rot_center_x\n", argv[i], argv[i+2]); return FALSE; } F64 rot_center_z; if (sscanf(argv[i+3], "%lf", &rot_center_z) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_z but '%s' is no valid rot_center_z\n", argv[i], argv[i+3]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_z but '%s' is no valid rot_center_z\n", argv[i], argv[i+3]); return FALSE; } - change_coordinates = TRUE; + transformed_fields |= LASTRANSFORM_X_COORDINATE; + transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationRotateXZ(angle, rot_center_x, rot_center_z)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + } + else if (strcmp(argv[i],"-rotate_yz") == 0) + { + if ((i+3) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle rot_center_y rot_center_z\n", argv[i]); + return FALSE; + } + F64 angle; + if (sscanf(argv[i+1], "%lf", &angle) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle rot_center_y rot_center_z but '%s' is no valid angle\n", argv[i], argv[i+1]); + return FALSE; + } + if (angle == 0.0) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_y but %g is no valid angle\n", argv[i], angle); + return FALSE; + } + F64 rot_center_y; + if (sscanf(argv[i+2], "%lf", &rot_center_y) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle rot_center_y rot_center_z but '%s' is no valid rot_center_y\n", argv[i], argv[i+2]); + return FALSE; + } + F64 rot_center_z; + if (sscanf(argv[i+3], "%lf", &rot_center_z) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle rot_center_y rot_center_z but '%s' is no valid rot_center_z\n", argv[i], argv[i+3]); + return FALSE; + } + transformed_fields |= LASTRANSFORM_Y_COORDINATE; + transformed_fields |= LASTRANSFORM_Z_COORDINATE; + add_operation(new LASoperationRotateYZ(angle, rot_center_y, rot_center_z)); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } } else if (strncmp(argv[i],"-clamp_", 7) == 0) @@ -2193,209 +3219,593 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: below above\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: below above\n", argv[i]); return FALSE; } F64 below; if (sscanf(argv[i+1], "%lf", &below) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: below above but '%s' is no valid below value\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: below above but '%s' is no valid below value\n", argv[i], argv[i+1]); return FALSE; } F64 above; if (sscanf(argv[i+2], "%lf", &above) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: below above but '%s' is no valid above value\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: below above but '%s' is no valid above value\n", argv[i], argv[i+2]); return FALSE; } - change_coordinates = TRUE; + transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationClampZ(below, above)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-clamp_z_below") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: below\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: below\n", argv[i]); return FALSE; } F64 below; if (sscanf(argv[i+1], "%lf", &below) != 1) { - REprintf("ERROR: '%s' needs 1 argument: below but '%s' is no valid below value\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: below but '%s' is no valid below value\n", argv[i], argv[i+1]); return FALSE; } - change_coordinates = TRUE; + transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationClampZbelow(below)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-clamp_z_above") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: above\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: above\n", argv[i]); return FALSE; } F64 above; if (sscanf(argv[i+1], "%lf", &above) != 1) { - REprintf("ERROR: '%s' needs 1 argument: above but '%s' is no valid above value\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: above but '%s' is no valid above value\n", argv[i], argv[i+1]); return FALSE; } - change_coordinates = TRUE; + transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationClampZabove(above)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-clamp_intensity") == 0) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: below above\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: below above\n", argv[i]); return FALSE; } U32 below; if (sscanf(argv[i+1], "%u", &below) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: below above but '%s' is no valid below value\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: below above but '%s' is no valid below value\n", argv[i], argv[i+1]); return FALSE; } U32 above; if (sscanf(argv[i+2], "%u", &above) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: below above but '%s' is no valid above value\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: below above but '%s' is no valid above value\n", argv[i], argv[i+2]); return FALSE; } if (below > U16_MAX) { - REprintf("ERROR: cannot clamp intensity because below value of %u is larger than %u\n", below, U16_MAX); + fprintf(stderr,"ERROR: cannot clamp intensity because below value of %u is larger than %u\n", below, U16_MAX); return FALSE; } if (above > U16_MAX) { - REprintf("ERROR: cannot clamp intensity because above value of %u is larger than %u\n", above, U16_MAX); + fprintf(stderr,"ERROR: cannot clamp intensity because above value of %u is larger than %u\n", above, U16_MAX); return FALSE; } add_operation(new LASoperationClampIntensity((U16)below, (U16)above)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-clamp_intensity_below") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: below\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: below\n", argv[i]); return FALSE; } U32 below; if (sscanf(argv[i+1], "%u", &below) != 1) { - REprintf("ERROR: '%s' needs 1 argument: below but '%s' is no valid below value\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: below but '%s' is no valid below value\n", argv[i], argv[i+1]); return FALSE; } if (below > U16_MAX) { - REprintf("ERROR: cannot clamp intensity because below value of %u is larger than %u\n", below, U16_MAX); + fprintf(stderr,"ERROR: cannot clamp intensity because below value of %u is larger than %u\n", below, U16_MAX); + return FALSE; + } + add_operation(new LASoperationClampIntensityBelow((U16)below)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i],"-clamp_intensity_above") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: above\n", argv[i]); + return FALSE; + } + U32 above; + if (sscanf(argv[i+1], "%u", &above) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: above but '%s' is no valid above value\n", argv[i], argv[i+1]); + return FALSE; + } + if (above > U16_MAX) + { + fprintf(stderr,"ERROR: cannot clamp intensity because above value of %u is larger than %u\n", above, U16_MAX); + return FALSE; + } + add_operation(new LASoperationClampIntensityAbove((U16)above)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i],"-clamp_raw_z") == 0) + { + if ((i+2) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: below above\n", argv[i]); + return FALSE; + } + I32 below; + if (sscanf(argv[i+1], "%d", &below) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: below above but '%s' is no valid below value\n", argv[i], argv[i+1]); + return FALSE; + } + I32 above; + if (sscanf(argv[i+2], "%d", &above) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: below above but '%s' is no valid above value\n", argv[i], argv[i+2]); return FALSE; } - add_operation(new LASoperationClampIntensityBelow((U16)below)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + transformed_fields |= LASTRANSFORM_Z_COORDINATE; + add_operation(new LASoperationClampRawZ(below, above)); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + } + } + else if (strncmp(argv[i],"-copy_", 6) == 0) + { + if (strncmp(argv[i],"-copy_attribute_", 16) == 0) + { + if (strcmp(argv[i],"-copy_attribute_into_x") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + transformed_fields |= LASTRANSFORM_X_COORDINATE; + add_operation(new LASoperationCopyAttributeIntoX(index)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i],"-copy_attribute_into_y") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + transformed_fields |= LASTRANSFORM_Y_COORDINATE; + add_operation(new LASoperationCopyAttributeIntoY(index)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i],"-copy_attribute_into_z") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + transformed_fields |= LASTRANSFORM_Z_COORDINATE; + add_operation(new LASoperationCopyAttributeIntoZ(index)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i],"-copy_attribute_into_user_data") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + add_operation(new LASoperationCopyAttributeIntoUserData(index)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i],"-copy_attribute_into_intensity") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + add_operation(new LASoperationCopyAttributeIntoIntensity(index)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i],"-copy_attribute_into_point_source") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + add_operation(new LASoperationCopyAttributeIntoPointSource(index)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i],"-copy_attribute_into_R") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + add_operation(new LASoperationCopyAttributeIntoRGBNIR(index, 0)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i],"-copy_attribute_into_G") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + add_operation(new LASoperationCopyAttributeIntoRGBNIR(index, 1)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i],"-copy_attribute_into_B") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + add_operation(new LASoperationCopyAttributeIntoRGBNIR(index, 2)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if ((strcmp(argv[i],"-copy_attribute_into_NIR") == 0) || (strcmp(argv[i],"-copy_attribute_into_I") == 0)) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + add_operation(new LASoperationCopyAttributeIntoRGBNIR(index, 3)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i],"-copy_attribute_into_register") == 0) + { + if ((i+2) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index of attribute, index of register\n", argv[i]); + return FALSE; + } + U32 index_attribute; + if (sscanf(argv[i+1], "%u", &index_attribute) != 1) + { + fprintf(stderr,"ERROR: '%s' 1st of 2 arguments index of attribute '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + U32 index_register; + if (sscanf(argv[i+2], "%u", &index_register) != 1) + { + fprintf(stderr,"ERROR: '%s' 2nd of 2 arguments index of register '%s' is no valid index\n", argv[i], argv[i+2]); + return FALSE; + } + if (index_register >= 16) + { + fprintf(stderr,"ERROR: '%s' 2nd of 2 arguments index of register %u is out of valid [0,15] range\n", argv[i], index_register); + return FALSE; + } + add_operation(new LASoperationCopyAttributeIntoRegister(index_attribute, registers, index_register)); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + } } - else if (strcmp(argv[i],"-clamp_intensity_above") == 0) + else if (strncmp(argv[i],"-copy_register_", 15) == 0) { - if ((i+1) >= argc) + if (strcmp(argv[i],"-copy_register_into_x") == 0) { - REprintf("ERROR: '%s' needs 1 argument: above\n", argv[i]); - return FALSE; + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + if (index >= 16) + { + fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + return FALSE; + } + transformed_fields |= LASTRANSFORM_X_COORDINATE; + add_operation(new LASoperationCopyRegisterIntoX(registers, index)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } - U32 above; - if (sscanf(argv[i+1], "%u", &above) != 1) + else if (strcmp(argv[i],"-copy_register_into_y") == 0) { - REprintf("ERROR: '%s' needs 1 argument: above but '%s' is no valid above value\n", argv[i], argv[i+1]); - return FALSE; + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + if (index >= 16) + { + fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + return FALSE; + } + transformed_fields |= LASTRANSFORM_Y_COORDINATE; + add_operation(new LASoperationCopyRegisterIntoY(registers, index)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } - if (above > U16_MAX) + else if (strcmp(argv[i],"-copy_register_into_z") == 0) { - REprintf("ERROR: cannot clamp intensity because above value of %u is larger than %u\n", above, U16_MAX); - return FALSE; + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + if (index >= 16) + { + fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + return FALSE; + } + transformed_fields |= LASTRANSFORM_Z_COORDINATE; + add_operation(new LASoperationCopyRegisterIntoZ(registers, index)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } - add_operation(new LASoperationClampIntensityAbove((U16)above)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; - } - else if (strcmp(argv[i],"-clamp_raw_z") == 0) - { - if ((i+2) >= argc) + else if (strcmp(argv[i],"-copy_register_into_user_data") == 0) { - REprintf("ERROR: '%s' needs 2 arguments: below above\n", argv[i]); - return FALSE; + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + if (index >= 16) + { + fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + return FALSE; + } + add_operation(new LASoperationCopyRegisterIntoUserData(registers, index)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } - I32 below; - if (sscanf(argv[i+1], "%d", &below) != 1) + else if (strcmp(argv[i],"-copy_register_into_intensity") == 0) { - REprintf("ERROR: '%s' needs 2 arguments: below above but '%s' is no valid below value\n", argv[i], argv[i+1]); - return FALSE; + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + if (index >= 16) + { + fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + return FALSE; + } + add_operation(new LASoperationCopyRegisterIntoIntensity(registers, index)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } - I32 above; - if (sscanf(argv[i+2], "%d", &above) != 1) + else if (strcmp(argv[i],"-copy_register_into_point_source") == 0) { - REprintf("ERROR: '%s' needs 2 arguments: below above but '%s' is no valid above value\n", argv[i], argv[i+2]); - return FALSE; + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + if (index >= 16) + { + fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + return FALSE; + } + add_operation(new LASoperationCopyRegisterIntoPointSource(registers, index)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } - change_coordinates = TRUE; - add_operation(new LASoperationClampRawZ(below, above)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; - } - } - else if (strncmp(argv[i],"-copy_", 6) == 0) - { - if (strncmp(argv[i],"-copy_attribute_", 16) == 0) - { - if (strcmp(argv[i],"-copy_attribute_into_z") == 0) + else if (strcmp(argv[i],"-copy_register_into_R") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - REprintf("ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } - change_coordinates = TRUE; - add_operation(new LASoperationCopyAttributeIntoZ(index)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + if (index >= 16) + { + fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + return FALSE; + } + add_operation(new LASoperationCopyRegisterIntoRGBNIR(registers, index, 0)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } - else if (strcmp(argv[i],"-copy_attribute_into_user_data") == 0) + else if (strcmp(argv[i],"-copy_register_into_G") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - REprintf("ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } - add_operation(new LASoperationCopyAttributeIntoUserData(index)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + if (index >= 16) + { + fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + return FALSE; + } + add_operation(new LASoperationCopyRegisterIntoRGBNIR(registers, index, 1)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } - else if (strcmp(argv[i],"-copy_attribute_into_intensity") == 0) + else if (strcmp(argv[i],"-copy_register_into_B") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - REprintf("ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } - add_operation(new LASoperationCopyAttributeIntoIntensity(index)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + if (index >= 16) + { + fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + return FALSE; + } + add_operation(new LASoperationCopyRegisterIntoRGBNIR(registers, index, 2)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if ((strcmp(argv[i],"-copy_register_into_NIR") == 0) || (strcmp(argv[i],"-copy_register_into_I") == 0)) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + if (index >= 16) + { + fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + return FALSE; + } + add_operation(new LASoperationCopyRegisterIntoRGBNIR(registers, index, 3)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i],"-copy_register_into_attribute") == 0) + { + if ((i+2) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index of register, index of attribute\n", argv[i]); + return FALSE; + } + U32 index_register; + if (sscanf(argv[i+1], "%u", &index_register) != 1) + { + fprintf(stderr,"ERROR: '%s' 1st of 2 arguments index of register '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + if (index_register >= 16) + { + fprintf(stderr,"ERROR: '%s' 1st of 2 arguments index of register %u is out of valid [0,15] range\n", argv[i], index_register); + return FALSE; + } + U32 index_attribute; + if (sscanf(argv[i+2], "%u", &index_attribute) != 1) + { + fprintf(stderr,"ERROR: '%s' 2nd of 2 arguments index of attribute '%s' is no valid index\n", argv[i], argv[i+2]); + return FALSE; + } + add_operation(new LASoperationCopyRegisterIntoAttribute(registers, index_register, index_attribute)); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } } else if (strncmp(argv[i],"-copy_user_data_", 16) == 0) @@ -2403,22 +3813,122 @@ BOOL LAStransform::parse(int argc, char* argv[]) if (strcmp(argv[i],"-copy_user_data_into_point_source") == 0) { add_operation(new LASoperationCopyUserDataIntoPointSource()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-copy_user_data_into_scanner_channel") == 0) { add_operation(new LASoperationCopyUserDataIntoScannerChannel()); - *argv[i]='\0'; + *argv[i]='\0'; + } + else if (strcmp(argv[i],"-copy_user_data_into_classification") == 0) + { + add_operation(new LASoperationCopyUserDataIntoClassification()); + *argv[i]='\0'; + } + else if (strcmp(argv[i],"-copy_user_data_into_z") == 0) + { + add_operation(new LASoperationCopyUserDataIntoZ()); + *argv[i]='\0'; + } + else if (strcmp(argv[i],"-copy_user_data_into_attribute") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + add_operation(new LASoperationCopyUserDataIntoAttribute(index)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i],"-copy_user_data_into_register") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + if (index >= 16) + { + fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + return FALSE; + } + add_operation(new LASoperationCopyUserDataIntoRegister(registers, index)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } } - else if (strcmp(argv[i],"-copy_scanner_channel_into_point_source") == 0) + else if (strncmp(argv[i],"-copy_point_source_", 19) == 0) { - add_operation(new LASoperationCopyScannerChannelIntoPointSource()); - *argv[i]='\0'; + if (strcmp(argv[i],"-copy_point_source_into_register") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + if (index >= 16) + { + fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + return FALSE; + } + add_operation(new LASoperationCopyPointSourceIntoRegister(registers, index)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } } + else if (strncmp(argv[i],"-copy_scanner_channel_", 19) == 0) + { + if (strcmp(argv[i],"-copy_scanner_channel_into_point_source") == 0) + { + add_operation(new LASoperationCopyScannerChannelIntoPointSource()); + *argv[i]='\0'; + } + else if (strcmp(argv[i],"-copy_scanner_channel_into_user_data") == 0) + { + add_operation(new LASoperationCopyScannerChannelIntoUserData()); + *argv[i]='\0'; + } + } else if (strncmp(argv[i],"-copy_R", 7) == 0) { - if (strcmp(argv[i],"-copy_RGB_into_intensity") == 0) + if (strcmp(argv[i],"-copy_R_into_register") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + if (index >= 16) + { + fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + return FALSE; + } + add_operation(new LASoperationCopyRBGNIRintoRegister(0, registers, index)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i],"-copy_RGB_into_intensity") == 0) { add_operation(new LASoperationCopyRGBintoIntensity()); *argv[i]='\0'; @@ -2426,7 +3936,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) else if (strcmp(argv[i],"-copy_R_into_intensity") == 0) { add_operation(new LASoperationCopyRintoIntensity()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-copy_R_into_NIR") == 0) { @@ -2436,47 +3946,155 @@ BOOL LAStransform::parse(int argc, char* argv[]) } else if (strncmp(argv[i],"-copy_G_", 8) == 0) { - if (strcmp(argv[i],"-copy_G_into_intensity") == 0) + if (strcmp(argv[i],"-copy_G_into_register") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + if (index >= 16) + { + fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + return FALSE; + } + add_operation(new LASoperationCopyRBGNIRintoRegister(1, registers, index)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i],"-copy_G_into_intensity") == 0) { add_operation(new LASoperationCopyGintoIntensity()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-copy_G_into_NIR") == 0) { add_operation(new LASoperationCopyGintoNIR()); - *argv[i]='\0'; + *argv[i]='\0'; } } else if (strncmp(argv[i],"-copy_B_", 8) == 0) { - if (strcmp(argv[i],"-copy_B_into_intensity") == 0) + if (strcmp(argv[i],"-copy_B_into_register") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + if (index >= 16) + { + fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + return FALSE; + } + add_operation(new LASoperationCopyRBGNIRintoRegister(2, registers, index)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i],"-copy_B_into_intensity") == 0) { add_operation(new LASoperationCopyBintoIntensity()); - *argv[i]='\0'; + *argv[i]='\0'; + } + else if (strcmp(argv[i],"-copy_B_into_NIR") == 0) + { + add_operation(new LASoperationCopyBintoNIR()); + *argv[i]='\0'; + } + } + else if (strncmp(argv[i],"-copy_NIR_", 10) == 0) + { + if (strcmp(argv[i],"-copy_NIR_into_register") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + if (index >= 16) + { + fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + return FALSE; + } + add_operation(new LASoperationCopyRBGNIRintoRegister(3, registers, index)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } - else if (strcmp(argv[i],"-copy_B_into_NIR") == 0) + else if (strcmp(argv[i],"-copy_NIR_into_intensity") == 0) { - add_operation(new LASoperationCopyBintoNIR()); - *argv[i]='\0'; + add_operation(new LASoperationCopyNIRintoIntensity()); + *argv[i]='\0'; } } - else if (strcmp(argv[i],"-copy_NIR_into_intensity") == 0) - { - add_operation(new LASoperationCopyNIRintoIntensity()); - *argv[i]='\0'; - } else if (strncmp(argv[i],"-copy_intensity_", 16) == 0) { if (strcmp(argv[i],"-copy_intensity_into_z") == 0) { - change_coordinates = TRUE; + transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationCopyIntensityIntoZ()); - *argv[i]='\0'; - } + *argv[i]='\0'; + } else if (strcmp(argv[i],"-copy_intensity_into_NIR") == 0) { add_operation(new LASoperationCopyIntensityIntoNIR()); - *argv[i]='\0'; + *argv[i]='\0'; + } + else if (strcmp(argv[i],"-copy_intensity_into_classification") == 0) + { + add_operation(new LASoperationCopyIntensityIntoClassification()); + *argv[i]='\0'; + } + else if (strcmp(argv[i],"-copy_intensity_into_attribute") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + add_operation(new LASoperationCopyIntensityIntoAttribute(index)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i],"-copy_intensity_into_register") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + if (index >= 16) + { + fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + return FALSE; + } + add_operation(new LASoperationCopyIntensityIntoRegister(registers, index)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } } else if (strncmp(argv[i],"-copy_classification_", 21) == 0) @@ -2484,12 +4102,31 @@ BOOL LAStransform::parse(int argc, char* argv[]) if (strcmp(argv[i],"-copy_classification_into_user_data") == 0) { add_operation(new LASoperationCopyClassificationIntoUserData()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-copy_classification_into_point_source") == 0) { add_operation(new LASoperationCopyClassificationIntoPointSource()); - *argv[i]='\0'; + *argv[i]='\0'; + } + } + else if (strncmp(argv[i],"-copy_z_", 8) == 0) + { + if (strcmp(argv[i],"-copy_z_into_attribute") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: index but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + add_operation(new LASoperationCopyZIntoAttribute(index)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } } } @@ -2499,317 +4136,361 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: classification\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: classification\n", argv[i]); return FALSE; } U32 classification; if (sscanf(argv[i+1], "%u", &classification) != 1) { - REprintf("ERROR: '%s' needs 1 argument: classification but '%s' is no valid classification\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: classification but '%s' is no valid classification\n", argv[i], argv[i+1]); return FALSE; } if (classification > 255) { - REprintf("ERROR: cannot set classification because classification of %u is larger than 255\n", classification); + fprintf(stderr,"ERROR: cannot set classification because classification of %u is larger than 255\n", classification); return FALSE; } add_operation(new LASoperationSetClassification((U8)classification)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-set_intensity") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: value\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: value\n", argv[i]); return FALSE; } U32 value; if (sscanf(argv[i+1], "%u", &value) != 1) { - REprintf("ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } if (value > U16_MAX) { - REprintf("ERROR: cannot set intensity because value of %u is larger than %u\n", value, U16_MAX); + fprintf(stderr,"ERROR: cannot set intensity because value of %u is larger than %u\n", value, U16_MAX); return FALSE; } add_operation(new LASoperationSetIntensity(U16_CLAMP(value))); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-set_withheld_flag") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' need 1 argument: value\n", argv[i]); + fprintf(stderr,"ERROR: '%s' need 1 argument: value\n", argv[i]); return FALSE; } U32 value; if (sscanf(argv[i+1], "%u", &value) != 1) { - REprintf("ERROR: '%s' needs 1 argument: value but '%s' is no valid flag\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: value but '%s' is no valid flag\n", argv[i], argv[i+1]); return FALSE; } if (value > 1) { - REprintf("ERROR: cannot set withheld flag because value %u is larger than 1\n", value); + fprintf(stderr,"ERROR: cannot set withheld flag because value %u is larger than 1\n", value); return FALSE; } add_operation(new LASoperationSetWithheldFlag((U8)value)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-set_synthetic_flag") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' need 1 argument: value\n", argv[i]); + fprintf(stderr,"ERROR: '%s' need 1 argument: value\n", argv[i]); return FALSE; } U32 value; if (sscanf(argv[i+1], "%u", &value) != 1) { - REprintf("ERROR: '%s' needs 1 argument: value but '%s' is no valid flag\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: value but '%s' is no valid flag\n", argv[i], argv[i+1]); return FALSE; } if (value > 1) { - REprintf("ERROR: cannot set synthetic flag because value %u is larger than 1\n", value); + fprintf(stderr,"ERROR: cannot set synthetic flag because value %u is larger than 1\n", value); return FALSE; } add_operation(new LASoperationSetSyntheticFlag((U8)value)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-set_keypoint_flag") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' need 1 argument: value\n", argv[i]); + fprintf(stderr,"ERROR: '%s' need 1 argument: value\n", argv[i]); return FALSE; } U32 value; if (sscanf(argv[i+1], "%u", &value) != 1) { - REprintf("ERROR: '%s' needs 1 argument: value but '%s' is no valid flag\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: value but '%s' is no valid flag\n", argv[i], argv[i+1]); return FALSE; } if (value > 1) { - REprintf("ERROR: cannot set keypoint flag because value %u is larger than 1\n", value); + fprintf(stderr,"ERROR: cannot set keypoint flag because value %u is larger than 1\n", value); return FALSE; } add_operation(new LASoperationSetKeypointFlag((U8)value)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if ((strcmp(argv[i],"-set_extended_overlap_flag") == 0) || (strcmp(argv[i],"-set_overlap_flag") == 0)) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' need 1 argument: value\n", argv[i]); + fprintf(stderr,"ERROR: '%s' need 1 argument: value\n", argv[i]); return FALSE; } U32 value; if (sscanf(argv[i+1], "%u", &value) != 1) { - REprintf("ERROR: '%s' needs 1 argument: value but '%s' is no valid flag\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: value but '%s' is no valid flag\n", argv[i], argv[i+1]); return FALSE; } if (value > 1) { - REprintf("ERROR: cannot set overlap flag because value %u is larger than 1\n", value); + fprintf(stderr,"ERROR: cannot set overlap flag because value %u is larger than 1\n", value); return FALSE; } add_operation(new LASoperationSetExtendedOverlapFlag((U8)value)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if ((strcmp(argv[i],"-set_extended_scanner_channel") == 0) || (strcmp(argv[i],"-set_scanner_channel") == 0)) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' need 1 argument: value\n", argv[i]); + fprintf(stderr,"ERROR: '%s' need 1 argument: value\n", argv[i]); return FALSE; } U32 value; if (sscanf(argv[i+1], "%u", &value) != 1) { - REprintf("ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } if (value > 3) { - REprintf("ERROR: cannot set scanner channel because value %u is larger than 3\n", value); + fprintf(stderr,"ERROR: cannot set scanner channel because value %u is larger than 3\n", value); return FALSE; } add_operation(new LASoperationSetExtendedScannerChannel((U8)value)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-set_user_data") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' need 1 argument: value\n", argv[i]); + fprintf(stderr,"ERROR: '%s' need 1 argument: value\n", argv[i]); return FALSE; } U32 value; if (sscanf(argv[i+1], "%u", &value) != 1) { - REprintf("ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } if (value > U8_MAX) { - REprintf("ERROR: cannot set user data because value %u is larger than %d\n", value, U8_MAX); + fprintf(stderr,"ERROR: cannot set user data because value %u is larger than %d\n", value, U8_MAX); return FALSE; } add_operation(new LASoperationSetUserData((U8)value)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-set_scan_angle") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' need 1 argument: value\n", argv[i]); + fprintf(stderr,"ERROR: '%s' need 1 argument: value\n", argv[i]); return FALSE; } F32 value; if (sscanf(argv[i+1], "%g", &value) != 1) { - REprintf("ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } if (value < -180.0f) { - REprintf("ERROR: cannot set scan angle because value %g is smaller than -180\n", value); + fprintf(stderr,"ERROR: cannot set scan angle because value %g is smaller than -180\n", value); return FALSE; } else if (value > 180.0f) { - REprintf("ERROR: cannot set scan angle rank because value %g is larger than 180\n", value); + fprintf(stderr,"ERROR: cannot set scan angle rank because value %g is larger than 180\n", value); return FALSE; } add_operation(new LASoperationSetScanAngle(value)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strncmp(argv[i],"-set_point_source", 17) == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' need 1 argument: psid\n", argv[i]); + fprintf(stderr,"ERROR: '%s' need 1 argument: psid\n", argv[i]); return FALSE; } U32 value; if (sscanf(argv[i+1], "%u", &value) != 1) { - REprintf("ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } if (value > U16_MAX) { - REprintf("ERROR: cannot set point source ID because value %u is larger than %d\n", value, U16_MAX); + fprintf(stderr,"ERROR: cannot set point source ID because value %u is larger than %d\n", value, U16_MAX); return FALSE; } add_operation(new LASoperationSetPointSource((U16)value)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-set_return_number") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: return_number\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: return_number\n", argv[i]); return FALSE; } U32 return_number; if (sscanf(argv[i+1], "%u", &return_number) != 1) { - REprintf("ERROR: '%s' needs 1 argument: return_number but '%s' is no valid return_number\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: return_number but '%s' is no valid return_number\n", argv[i], argv[i+1]); return FALSE; } if (return_number > 7) { - REprintf("ERROR: cannot set return_number because %u is larger than 7\n", return_number); + fprintf(stderr,"ERROR: cannot set return_number because %u is larger than 7\n", return_number); return FALSE; } add_operation(new LASoperationSetReturnNumber((U8)return_number)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-set_extended_return_number") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: extended_return_number\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: extended_return_number\n", argv[i]); return FALSE; } U32 extended_return_number; if (sscanf(argv[i+1], "%u", &extended_return_number) != 1) { - REprintf("ERROR: '%s' needs 1 argument: extended_return_number but '%s' is no valid extended_return_number\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: extended_return_number but '%s' is no valid extended_return_number\n", argv[i], argv[i+1]); return FALSE; } if (extended_return_number > 15) { - REprintf("ERROR: cannot set extended_return_number because %u is larger than 15\n", extended_return_number); + fprintf(stderr,"ERROR: cannot set extended_return_number because %u is larger than 15\n", extended_return_number); return FALSE; } add_operation(new LASoperationSetExtendedReturnNumber((U8)extended_return_number)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-set_number_of_returns") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: number_of_returns\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: number_of_returns\n", argv[i]); return FALSE; } U32 number_of_returns; if (sscanf(argv[i+1], "%u", &number_of_returns) != 1) { - REprintf("ERROR: '%s' needs 1 argument: number_of_returns but '%s' is no valid number_of_returns\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: number_of_returns but '%s' is no valid number_of_returns\n", argv[i], argv[i+1]); return FALSE; } if (number_of_returns > 7) { - REprintf("ERROR: cannot set number_of_returns because %u is larger than 7\n", number_of_returns); + fprintf(stderr,"ERROR: cannot set number_of_returns because %u is larger than 7\n", number_of_returns); return FALSE; } add_operation(new LASoperationSetNumberOfReturns((U8)number_of_returns)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-set_extended_number_of_returns") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: extended_number_of_returns\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: extended_number_of_returns\n", argv[i]); return FALSE; } U32 extended_number_of_returns; if (sscanf(argv[i+1], "%u", &extended_number_of_returns) != 1) { - REprintf("ERROR: '%s' needs 1 argument: extended_number_of_returns but '%s' is no valid extended_return_number\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: extended_number_of_returns but '%s' is no valid extended_return_number\n", argv[i], argv[i+1]); return FALSE; } if (extended_number_of_returns > 15) { - REprintf("ERROR: cannot set extended_number_of_returns because %u is larger than 15\n", extended_number_of_returns); + fprintf(stderr,"ERROR: cannot set extended_number_of_returns because %u is larger than 15\n", extended_number_of_returns); return FALSE; } add_operation(new LASoperationSetExtendedNumberOfReturns((U8)extended_number_of_returns)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-set_gps_time") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: gps_time\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: gps_time\n", argv[i]); return FALSE; } F64 gps_time; if (sscanf(argv[i+1], "%lf", &gps_time) != 1) { - REprintf("ERROR: '%s' needs 1 argument: gps_time but '%s' is no valid gps_time\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: gps_time but '%s' is no valid gps_time\n", argv[i], argv[i+1]); return FALSE; } add_operation(new LASoperationSetGpsTime(gps_time)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if ((strcmp(argv[i],"-set_attribute") == 0)) + { + if ((i+2) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + F64 value; + if (sscanf(argv[i+2], "%lf", &value) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value but '%s' is no valid value\n", argv[i], argv[i+2]); + return FALSE; + } + add_operation(new LASoperationSetAttribute(index, value)); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + } + else if ((strcmp(argv[i],"-set_register") == 0)) + { + if ((i+2) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value but '%s' is no valid index\n", argv[i], argv[i+1]); + return FALSE; + } + F64 value; + if (sscanf(argv[i+2], "%lf", &value) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value but '%s' is no valid value\n", argv[i], argv[i+2]); + return FALSE; + } + add_operation(new LASoperationSetRegister(registers, index, value)); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strncmp(argv[i],"-set_RGB", 8) == 0) { @@ -2817,94 +4498,94 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+3) >= argc) { - REprintf("ERROR: '%s' needs 3 arguments: R G B\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: R G B\n", argv[i]); return FALSE; } U32 R; if (sscanf(argv[i+1], "%u", &R) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: R G B but '%s' is no valid R\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: R G B but '%s' is no valid R\n", argv[i], argv[i+1]); return FALSE; } if (R > U16_MAX) { - REprintf("ERROR: cannot set RGB because R is %u, which is larger than %u\n", R, U16_MAX); + fprintf(stderr,"ERROR: cannot set RGB because R is %u, which is larger than %u\n", R, U16_MAX); return FALSE; } U32 G; if (sscanf(argv[i+2], "%u", &G) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: R G B but '%s' is no valid G\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: R G B but '%s' is no valid G\n", argv[i], argv[i+2]); return FALSE; } if (G > U16_MAX) { - REprintf("ERROR: cannot set RGB because G is %u, which is larger than %u\n", G, U16_MAX); + fprintf(stderr,"ERROR: cannot set RGB because G is %u, which is larger than %u\n", G, U16_MAX); return FALSE; } U32 B; if (sscanf(argv[i+3], "%u", &B) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: R G B but '%s' is no valid B\n", argv[i], argv[i+3]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: R G B but '%s' is no valid B\n", argv[i], argv[i+3]); return FALSE; } if (B > U16_MAX) { - REprintf("ERROR: cannot set RGB because B is %u, which is larger than %u\n", B, U16_MAX); + fprintf(stderr,"ERROR: cannot set RGB because B is %u, which is larger than %u\n", B, U16_MAX); return FALSE; } add_operation(new LASoperationSetRGB((U16)R, (U16)G, (U16)B)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } else if (strcmp(argv[i],"-set_RGB_of_class") == 0) { if ((i+4) >= argc) { - REprintf("ERROR: '%s' needs 4 arguments: classification R G B\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 4 arguments: classification R G B\n", argv[i]); return FALSE; } U32 classification; if (sscanf(argv[i+1], "%u", &classification) != 1) { - REprintf("ERROR: '%s' needs 4 arguments: classification R G B but '%s' is no valid classification\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 4 arguments: classification R G B but '%s' is no valid classification\n", argv[i], argv[i+1]); return FALSE; } if (classification > U8_MAX) { - REprintf("ERROR: cannot set RGB because classification is %u, which is larger than %u\n", classification, U8_MAX); + fprintf(stderr,"ERROR: cannot set RGB because classification is %u, which is larger than %u\n", classification, U8_MAX); return FALSE; } U32 R; if (sscanf(argv[i+2], "%u", &R) != 1) { - REprintf("ERROR: '%s' needs 4 arguments: classification R G B but '%s' is no valid R\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 4 arguments: classification R G B but '%s' is no valid R\n", argv[i], argv[i+2]); return FALSE; } if (R > U16_MAX) { - REprintf("ERROR: cannot set RGB because R is %u, which is larger than %u\n", R, U16_MAX); + fprintf(stderr,"ERROR: cannot set RGB because R is %u, which is larger than %u\n", R, U16_MAX); return FALSE; } U32 G; if (sscanf(argv[i+3], "%u", &G) != 1) { - REprintf("ERROR: '%s' needs 4 arguments: classification R G B but '%s' is no valid G\n", argv[i], argv[i+3]); + fprintf(stderr,"ERROR: '%s' needs 4 arguments: classification R G B but '%s' is no valid G\n", argv[i], argv[i+3]); return FALSE; } if (G > U16_MAX) { - REprintf("ERROR: cannot set RGB because G is %u, which is larger than %u\n", G, U16_MAX); + fprintf(stderr,"ERROR: cannot set RGB because G is %u, which is larger than %u\n", G, U16_MAX); return FALSE; } U32 B; if (sscanf(argv[i+4], "%u", &B) != 1) { - REprintf("ERROR: '%s' needs 4 arguments: classification R G B but '%s' is no valid B\n", argv[i], argv[i+4]); + fprintf(stderr,"ERROR: '%s' needs 4 arguments: classification R G B but '%s' is no valid B\n", argv[i], argv[i+4]); return FALSE; } if (B > U16_MAX) { - REprintf("ERROR: cannot set RGB because B is %u, which is larger than %u\n", B, U16_MAX); + fprintf(stderr,"ERROR: cannot set RGB because B is %u, which is larger than %u\n", B, U16_MAX); return FALSE; } if (classification < 32) @@ -2918,6 +4599,48 @@ BOOL LAStransform::parse(int argc, char* argv[]) *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; i+=4; } } + else if (strcmp(argv[i],"-set_scan_direction_flag") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' need 1 argument: value\n", argv[i]); + return FALSE; + } + U32 value; + if (sscanf(argv[i+1], "%u", &value) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: value but '%s' is no valid flag\n", argv[i], argv[i+1]); + return FALSE; + } + if (value > 1) + { + fprintf(stderr,"ERROR: cannot set scan direction flag because value %u is larger than 1\n", value); + return FALSE; + } + add_operation(new LASoperationSetScanDirectionFlag((U8)value)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i],"-set_edge_of_flight_line") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' need 1 argument: value\n", argv[i]); + return FALSE; + } + U32 value; + if (sscanf(argv[i+1], "%u", &value) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: value but '%s' is no valid flag\n", argv[i], argv[i+1]); + return FALSE; + } + if (value > 1) + { + fprintf(stderr,"ERROR: cannot set edge of flight line because value %u is larger than 1\n", value); + return FALSE; + } + add_operation(new LASoperationSetEdgeOfFlightLine((U8)value)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } } else if (strncmp(argv[i],"-change_",8) == 0) { @@ -2925,161 +4648,225 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: from_value to_value\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value\n", argv[i]); return FALSE; } U32 from_value; if (sscanf(argv[i+1], "%u", &from_value) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid from_value\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid from_value\n", argv[i], argv[i+1]); return FALSE; } if (from_value > U8_MAX) { - REprintf("ERROR: cannot change classification because from_value %u is larger than %u\n", from_value, U8_MAX); + fprintf(stderr,"ERROR: cannot change classification because from_value %u is larger than %u\n", from_value, U8_MAX); return FALSE; } U32 to_value; if (sscanf(argv[i+2], "%u", &to_value) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid to_value\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid to_value\n", argv[i], argv[i+2]); return FALSE; } if (to_value > U8_MAX) { - REprintf("ERROR: cannot change classification because to_value %u is larger than %u\n", to_value, U8_MAX); + fprintf(stderr,"ERROR: cannot change classification because to_value %u is larger than %u\n", to_value, U8_MAX); return FALSE; } add_operation(new LASoperationChangeClassificationFromTo((U8)from_value, (U8)to_value)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-change_user_data_from_to") == 0) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: from_value to_value\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value\n", argv[i]); return FALSE; } U32 from_value; if (sscanf(argv[i+1], "%u", &from_value) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid from_value\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid from_value\n", argv[i], argv[i+1]); return FALSE; } if (from_value > U8_MAX) { - REprintf("ERROR: cannot change classification because from_value %u is larger than %u\n", from_value, U8_MAX); + fprintf(stderr,"ERROR: cannot change classification because from_value %u is larger than %u\n", from_value, U8_MAX); return FALSE; } U32 to_value; if (sscanf(argv[i+2], "%u", &to_value) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid to_value\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid to_value\n", argv[i], argv[i+2]); return FALSE; } if (to_value > U8_MAX) { - REprintf("ERROR: cannot change classification because to_value %u is larger than %u\n", to_value, U8_MAX); + fprintf(stderr,"ERROR: cannot change classification because to_value %u is larger than %u\n", to_value, U8_MAX); return FALSE; } add_operation(new LASoperationChangeUserDataFromTo(from_value, to_value)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-change_point_source_from_to") == 0) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: from_value to_value\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value\n", argv[i]); return FALSE; } U32 from_value; if (sscanf(argv[i+1], "%u", &from_value) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid from_value\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid from_value\n", argv[i], argv[i+1]); return FALSE; } if (from_value > U16_MAX) { - REprintf("ERROR: cannot change classification because from_value %u is larger than %u\n", from_value, U16_MAX); + fprintf(stderr,"ERROR: cannot change classification because from_value %u is larger than %u\n", from_value, U16_MAX); return FALSE; } U32 to_value; if (sscanf(argv[i+2], "%u", &to_value) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid to_value\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid to_value\n", argv[i], argv[i+2]); return FALSE; } if (to_value > U16_MAX) { - REprintf("ERROR: cannot change classification because to_value %u is larger than %u\n", to_value, U16_MAX); + fprintf(stderr,"ERROR: cannot change classification because to_value %u is larger than %u\n", to_value, U16_MAX); return FALSE; } add_operation(new LASoperationChangePointSourceFromTo((U16)from_value, (U16)to_value)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-change_return_number_from_to") == 0) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: from_value to_value\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value\n", argv[i]); return FALSE; } U32 from_value; if (sscanf(argv[i+1], "%u", &from_value) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid from_value\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid from_value\n", argv[i], argv[i+1]); return FALSE; } - if (from_value > U8_MAX) + if (from_value > 7) { - REprintf("ERROR: cannot change return_number because from_value %u is larger than %u\n", from_value, U8_MAX); + fprintf(stderr,"ERROR: cannot change return_number because from_value %u is larger than %u\n", from_value, 7); return FALSE; } U32 to_value; if (sscanf(argv[i+2], "%u", &to_value) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid to_value\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid to_value\n", argv[i], argv[i+2]); return FALSE; } - if (to_value > U8_MAX) + if (to_value > 7) { - REprintf("ERROR: cannot change return_number because to_value %u is larger than %u\n", to_value, U8_MAX); + fprintf(stderr,"ERROR: cannot change return_number because to_value %u is larger than %u\n", to_value, 7); return FALSE; } add_operation(new LASoperationChangeReturnNumberFromTo((U8)from_value, (U8)to_value)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-change_number_of_returns_from_to") == 0) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: from_value to_value\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value\n", argv[i]); return FALSE; } U32 from_value; if (sscanf(argv[i+1], "%u", &from_value) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid from_value\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid from_value\n", argv[i], argv[i+1]); return FALSE; } - if (from_value > U8_MAX) + if (from_value > 7) { - REprintf("ERROR: cannot change return_number because from_value %u is larger than %u\n", from_value, U8_MAX); + fprintf(stderr,"ERROR: cannot change number_of_returns because from_value %u is larger than %u\n", from_value, 7); return FALSE; } U32 to_value; if (sscanf(argv[i+2], "%u", &to_value) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid to_value\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid to_value\n", argv[i], argv[i+2]); return FALSE; } - if (to_value > U8_MAX) + if (to_value > 7) { - REprintf("ERROR: cannot change return_number because to_value %u is larger than %u\n", to_value, U8_MAX); + fprintf(stderr,"ERROR: cannot change number_of_returns because to_value %u is larger than %u\n", to_value, 7); return FALSE; } add_operation(new LASoperationChangeNumberOfReturnsFromTo((U8)from_value, (U8)to_value)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + } + else if (strcmp(argv[i],"-change_extended_return_number_from_to") == 0) + { + if ((i+2) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value\n", argv[i]); + return FALSE; + } + U32 from_value; + if (sscanf(argv[i+1], "%u", &from_value) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid from_value\n", argv[i], argv[i+1]); + return FALSE; + } + if (from_value > 15) + { + fprintf(stderr,"ERROR: cannot change extended_return_number because from_value %u is larger than %u\n", from_value, 15); + return FALSE; + } + U32 to_value; + if (sscanf(argv[i+2], "%u", &to_value) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid to_value\n", argv[i], argv[i+2]); + return FALSE; + } + if (to_value > 15) + { + fprintf(stderr,"ERROR: cannot change extended_return_number because to_value %u is larger than %u\n", to_value, 15); + return FALSE; + } + add_operation(new LASoperationChangeExtendedReturnNumberFromTo((U8)from_value, (U8)to_value)); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + } + else if (strcmp(argv[i],"-change_extended_number_of_returns_from_to") == 0) + { + if ((i+2) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value\n", argv[i]); + return FALSE; + } + U32 from_value; + if (sscanf(argv[i+1], "%u", &from_value) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid from_value\n", argv[i], argv[i+1]); + return FALSE; + } + if (from_value > 15) + { + fprintf(stderr,"ERROR: cannot change extended_number_of_returns because from_value %u is larger than %u\n", from_value, 15); + return FALSE; + } + U32 to_value; + if (sscanf(argv[i+2], "%u", &to_value) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid to_value\n", argv[i], argv[i+2]); + return FALSE; + } + if (to_value > 15) + { + fprintf(stderr,"ERROR: cannot change extended_number_of_returns because to_value %u is larger than %u\n", to_value, 15); + return FALSE; + } + add_operation(new LASoperationChangeExtendedNumberOfReturnsFromTo((U8)from_value, (U8)to_value)); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } } else if (strncmp(argv[i],"-classify_", 10) == 0) @@ -3090,88 +4877,88 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: z_value classification\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: z_value classification\n", argv[i]); return FALSE; } F64 z_value; if (sscanf(argv[i+1], "%lf", &z_value) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: z_value classification but '%s' is no valid z_value\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: z_value classification but '%s' is no valid z_value\n", argv[i], argv[i+1]); return FALSE; } U32 classification; if (sscanf(argv[i+2], "%u", &classification) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: z_value classification but '%s' is no valid classification\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: z_value classification but '%s' is no valid classification\n", argv[i], argv[i+2]); return FALSE; } if (classification > 255) { - REprintf("ERROR: cannot classify z_value because classification of %u is larger than 255\n", classification); + fprintf(stderr,"ERROR: cannot classify z_value because classification of %u is larger than 255\n", classification); return FALSE; } add_operation(new LASoperationClassifyZbelowAs(z_value, U8_CLAMP(classification))); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-classify_z_above_as") == 0) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: z_value classification\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: z_value classification\n", argv[i]); return FALSE; } F64 z_value; if (sscanf(argv[i+1], "%lf", &z_value) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: z_value classification but '%s' is no valid z_value\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: z_value classification but '%s' is no valid z_value\n", argv[i], argv[i+1]); return FALSE; } U32 classification; if (sscanf(argv[i+2], "%u", &classification) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: z_value classification but '%s' is no valid classification\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: z_value classification but '%s' is no valid classification\n", argv[i], argv[i+2]); return FALSE; } if (classification > 255) { - REprintf("ERROR: cannot classify z_value because classification of %u is larger than 255\n", classification); + fprintf(stderr,"ERROR: cannot classify z_value because classification of %u is larger than 255\n", classification); return FALSE; } add_operation(new LASoperationClassifyZaboveAs(z_value, U8_CLAMP(classification))); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-classify_z_between_as") == 0) { if ((i+3) >= argc) { - REprintf("ERROR: '%s' needs 3 arguments: z_min z_max classification\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: z_min z_max classification\n", argv[i]); return FALSE; } F64 z_min; if (sscanf(argv[i+1], "%lf", &z_min) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: z_min z_max classification but '%s' is no valid z_min\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: z_min z_max classification but '%s' is no valid z_min\n", argv[i], argv[i+1]); return FALSE; } F64 z_max; if (sscanf(argv[i+2], "%lf", &z_max) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: z_min z_max classification but '%s' is no valid z_max\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: z_min z_max classification but '%s' is no valid z_max\n", argv[i], argv[i+2]); return FALSE; } U32 classification; if (sscanf(argv[i+3], "%u", &classification) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: z_min z_max classification but '%s' is no valid classification\n", argv[i], argv[i+3]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: z_min z_max classification but '%s' is no valid classification\n", argv[i], argv[i+3]); return FALSE; } if (classification > 255) { - REprintf("ERROR: cannot classify z_value because classification of %u is larger than 255\n", classification); + fprintf(stderr,"ERROR: cannot classify z_value because classification of %u is larger than 255\n", classification); return FALSE; } add_operation(new LASoperationClassifyZbetweenAs(z_min, z_max, U8_CLAMP(classification))); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } } else if (strncmp(argv[i],"-classify_intensity_", 20) == 0) @@ -3180,108 +4967,108 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: value classification\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: value classification\n", argv[i]); return FALSE; } U32 value; if (sscanf(argv[i+1], "%u", &value) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: value classification but '%s' is no valid value\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: value classification but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } U32 classification; if (sscanf(argv[i+2], "%u", &classification) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: value classification but '%s' is no valid classification\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: value classification but '%s' is no valid classification\n", argv[i], argv[i+2]); return FALSE; } if (value > U16_MAX) { - REprintf("ERROR: cannot classify intensity because value of %u is larger than %u\n", value, U16_MAX); + fprintf(stderr,"ERROR: cannot classify intensity because value of %u is larger than %u\n", value, U16_MAX); return FALSE; } if (classification > 255) { - REprintf("ERROR: cannot classify intensity because classification of %u is larger than 255\n", classification); + fprintf(stderr,"ERROR: cannot classify intensity because classification of %u is larger than 255\n", classification); return FALSE; } add_operation(new LASoperationClassifyIntensityBelowAs(value, classification)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-classify_intensity_above_as") == 0) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: value classification\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: value classification\n", argv[i]); return FALSE; } U32 value; if (sscanf(argv[i+1], "%u", &value) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: value classification but '%s' is no valid value\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: value classification but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } U32 classification; if (sscanf(argv[i+2], "%u", &classification) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: value classification but '%s' is no valid classification\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: value classification but '%s' is no valid classification\n", argv[i], argv[i+2]); return FALSE; } if (value > U16_MAX) { - REprintf("ERROR: cannot classify intensity because value of %u is larger than %u\n", value, U16_MAX); + fprintf(stderr,"ERROR: cannot classify intensity because value of %u is larger than %u\n", value, U16_MAX); return FALSE; } if (classification > 255) { - REprintf("ERROR: cannot classify intensity because classification of %u is larger than 255\n", classification); + fprintf(stderr,"ERROR: cannot classify intensity because classification of %u is larger than 255\n", classification); return FALSE; } add_operation(new LASoperationClassifyIntensityAboveAs(value, classification)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-classify_intensity_between_as") == 0) { if ((i+3) >= argc) { - REprintf("ERROR: '%s' needs 3 arguments: min_value max_value classification\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: min_value max_value classification\n", argv[i]); return FALSE; } U32 min_value; if (sscanf(argv[i+1], "%u", &min_value) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: min_value max_value classification but '%s' is no valid min_value\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: min_value max_value classification but '%s' is no valid min_value\n", argv[i], argv[i+1]); return FALSE; } U32 max_value; if (sscanf(argv[i+2], "%u", &max_value) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: min_value max_value classification but '%s' is no valid max_value\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: min_value max_value classification but '%s' is no valid max_value\n", argv[i], argv[i+2]); return FALSE; } U32 classification; if (sscanf(argv[i+3], "%u", &classification) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: min_value max_value classification but '%s' is no valid classification\n", argv[i], argv[i+3]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: min_value max_value classification but '%s' is no valid classification\n", argv[i], argv[i+3]); return FALSE; } if (min_value > U16_MAX) { - REprintf("ERROR: cannot classify intensity because min_value of %u is larger than %u\n", min_value, U16_MAX); + fprintf(stderr,"ERROR: cannot classify intensity because min_value of %u is larger than %u\n", min_value, U16_MAX); return FALSE; } if (max_value > U16_MAX) { - REprintf("ERROR: cannot classify intensity because max_value of %u is larger than %u\n", max_value, U16_MAX); + fprintf(stderr,"ERROR: cannot classify intensity because max_value of %u is larger than %u\n", max_value, U16_MAX); return FALSE; } if (classification > 255) { - REprintf("ERROR: cannot classify intensity because classification of %u is larger than 255\n", classification); + fprintf(stderr,"ERROR: cannot classify intensity because classification of %u is larger than 255\n", classification); return FALSE; } add_operation(new LASoperationClassifyIntensityBetweenAs(min_value, max_value, classification)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } } else if (strncmp(argv[i],"-classify_attribute_", 12) == 0) @@ -3290,106 +5077,106 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+3) >= argc) { - REprintf("ERROR: '%s' needs 3 arguments: attribute_index value classification\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: attribute_index value classification\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: attribute_index value classification but '%s' is no valid attribute_index\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: attribute_index value classification but '%s' is no valid attribute_index\n", argv[i], argv[i+1]); return FALSE; } F64 value; if (sscanf(argv[i+2], "%lf", &value) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: attribute_index value classification but '%s' is no valid value\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: attribute_index value classification but '%s' is no valid value\n", argv[i], argv[i+2]); return FALSE; } U32 classification; if (sscanf(argv[i+3], "%u", &classification) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: attribute_index value classification but '%s' is no valid classification\n", argv[i], argv[i+3]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: attribute_index value classification but '%s' is no valid classification\n", argv[i], argv[i+3]); return FALSE; } if (classification > 255) { - REprintf("ERROR: cannot classify attribute below because classification of %u is larger than 255\n", classification); + fprintf(stderr,"ERROR: cannot classify attribute below because classification of %u is larger than 255\n", classification); return FALSE; } add_operation(new LASoperationClassifyAttributeBelowAs(index, value, U8_CLAMP(classification))); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } else if (strcmp(argv[i],"-classify_attribute_above_as") == 0) { if ((i+3) >= argc) { - REprintf("ERROR: '%s' needs 3 arguments: attribute_index value classification\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: attribute_index value classification\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: attribute_index value classification but '%s' is no valid attribute_index\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: attribute_index value classification but '%s' is no valid attribute_index\n", argv[i], argv[i+1]); return FALSE; } F64 value; if (sscanf(argv[i+2], "%lf", &value) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: attribute_index value classification but '%s' is no valid value\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: attribute_index value classification but '%s' is no valid value\n", argv[i], argv[i+2]); return FALSE; } U32 classification; if (sscanf(argv[i+3], "%u", &classification) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: attribute_index value classification but '%s' is no valid classification\n", argv[i], argv[i+3]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: attribute_index value classification but '%s' is no valid classification\n", argv[i], argv[i+3]); return FALSE; } if (classification > 255) { - REprintf("ERROR: cannot classify attribute above because classification of %u is larger than 255\n", classification); + fprintf(stderr,"ERROR: cannot classify attribute above because classification of %u is larger than 255\n", classification); return FALSE; } add_operation(new LASoperationClassifyAttributeAboveAs(index, value, U8_CLAMP(classification))); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } else if (strcmp(argv[i],"-classify_attribute_between_as") == 0) { if ((i+4) >= argc) { - REprintf("ERROR: '%s' needs 4 arguments: attribute_index min max classification\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 4 arguments: attribute_index min max classification\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - REprintf("ERROR: '%s' needs 4 arguments: attribute_index min max classification but '%s' is no valid attribute_index\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 4 arguments: attribute_index min max classification but '%s' is no valid attribute_index\n", argv[i], argv[i+1]); return FALSE; } F64 min; if (sscanf(argv[i+2], "%lf", &min) != 1) { - REprintf("ERROR: '%s' needs 4 arguments: attribute_index min max classification but '%s' is no valid min\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 4 arguments: attribute_index min max classification but '%s' is no valid min\n", argv[i], argv[i+2]); return FALSE; } F64 max; if (sscanf(argv[i+3], "%lf", &max) != 1) { - REprintf("ERROR: '%s' needs 4 arguments: attribute_index min max classification but '%s' is no valid max\n", argv[i], argv[i+3]); + fprintf(stderr,"ERROR: '%s' needs 4 arguments: attribute_index min max classification but '%s' is no valid max\n", argv[i], argv[i+3]); return FALSE; } U32 classification; if (sscanf(argv[i+4], "%u", &classification) != 1) { - REprintf("ERROR: '%s' needs 4 arguments: attribute_index min max classification but '%s' is no valid classification\n", argv[i], argv[i+4]); + fprintf(stderr,"ERROR: '%s' needs 4 arguments: attribute_index min max classification but '%s' is no valid classification\n", argv[i], argv[i+4]); return FALSE; } if (classification > 255) { - REprintf("ERROR: cannot classify attribute between because classification of %u is larger than 255\n", classification); + fprintf(stderr,"ERROR: cannot classify attribute between because classification of %u is larger than 255\n", classification); return FALSE; } add_operation(new LASoperationClassifyAttributeBetweenAs(index, min, max, U8_CLAMP(classification))); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; i+=4; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; i+=4; } } } @@ -3399,222 +5186,308 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: scale\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: scale\n", argv[i]); return FALSE; } F64 scale_x; if (sscanf(argv[i+1], "%lf", &scale_x) != 1) { - REprintf("ERROR: '%s' needs 1 argument: scale_x but '%s' is no valid number\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: scale_x but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } - change_coordinates = TRUE; + if (scale_x != 1.0) transformed_fields |= LASTRANSFORM_X_COORDINATE; add_operation(new LASoperationScaleX(scale_x)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-scale_y") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: scale\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: scale\n", argv[i]); return FALSE; } F64 scale_y; if (sscanf(argv[i+1], "%lf", &scale_y) != 1) { - REprintf("ERROR: '%s' needs 1 argument: scale_y but '%s' is no valid number\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: scale_y but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } - change_coordinates = TRUE; + if (scale_y != 1.0) transformed_fields |= LASTRANSFORM_Y_COORDINATE; add_operation(new LASoperationScaleY(scale_y)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-scale_z") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: scale\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: scale\n", argv[i]); return FALSE; } F64 scale_z; if (sscanf(argv[i+1], "%lf", &scale_z) != 1) { - REprintf("ERROR: '%s' needs 1 argument: scale_z but '%s' is no valid number\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: scale_z but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } - change_coordinates = TRUE; + if (scale_z != 1.0) transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationScaleZ(scale_z)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-scale_xyz") == 0) { if ((i+3) >= argc) { - REprintf("ERROR: '%s' needs 3 arguments: scale_x scale_y scale_z\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: scale_x scale_y scale_z\n", argv[i]); return FALSE; } F64 scale_x; if (sscanf(argv[i+1], "%lf", &scale_x) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: scale_x scale_y scale_z but '%s' is no valid number\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: scale_x scale_y scale_z but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } F64 scale_y; if (sscanf(argv[i+2], "%lf", &scale_y) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: scale_x scale_y scale_z but '%s' is no valid number\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: scale_x scale_y scale_z but '%s' is no valid number\n", argv[i], argv[i+2]); return FALSE; } F64 scale_z; if (sscanf(argv[i+3], "%lf", &scale_z) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: scale_x scale_y scale_z but '%s' is no valid number\n", argv[i], argv[i+3]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: scale_x scale_y scale_z but '%s' is no valid number\n", argv[i], argv[i+3]); return FALSE; } - change_coordinates = TRUE; + if (scale_x != 1.0) transformed_fields |= LASTRANSFORM_X_COORDINATE; + if (scale_y != 1.0) transformed_fields |= LASTRANSFORM_Y_COORDINATE; + if (scale_z != 1.0) transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationScaleXYZ(scale_x, scale_y, scale_z)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } else if (strcmp(argv[i],"-scale_intensity") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: scale\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: scale\n", argv[i]); return FALSE; } F32 scale; if (sscanf(argv[i+1], "%f", &scale) != 1) { - REprintf("ERROR: '%s' needs 1 argument: scale but '%s' is no valid number\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: scale but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } add_operation(new LASoperationScaleIntensity(scale)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-scale_scan_angle") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: scale\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: scale\n", argv[i]); return FALSE; } F32 scale; if (sscanf(argv[i+1], "%f", &scale) != 1) { - REprintf("ERROR: '%s' needs 1 argument: scale but '%s' is no valid number\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: scale but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } add_operation(new LASoperationScaleScanAngle(scale)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } - else if (strcmp(argv[i],"-scale_RGB") == 0 || strcmp(argv[i],"-scale_rgb") == 0) + else if (strcmp(argv[i],"-scale_user_data") == 0) { - if ((i+3) >= argc) + if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 3 arguments: scale_R scale_G scale_B\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: scale\n", argv[i]); return FALSE; } - F32 scale_R; - if (sscanf(argv[i+1], "%f", &scale_R) != 1) + F32 scale; + if (sscanf(argv[i+1], "%f", &scale) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: scale_R scale_G scale_B but '%s' is no valid number\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: scale but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } - F32 scale_G; - if (sscanf(argv[i+2], "%f", &scale_G) != 1) + add_operation(new LASoperationScaleUserData(scale)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strncmp(argv[i],"-scale_RGB", 10) == 0 || strncmp(argv[i],"-scale_rgb", 10) == 0) + { + if (strcmp(argv[i],"-scale_RGB") == 0 || strcmp(argv[i],"-scale_rgb") == 0) { - REprintf("ERROR: '%s' needs 3 arguments: scale_R scale_G scale_B but '%s' is no valid number\n", argv[i], argv[i+2]); - return FALSE; + if ((i+3) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: scale_R scale_G scale_B\n", argv[i]); + return FALSE; + } + F32 scale_R; + if (sscanf(argv[i+1], "%f", &scale_R) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: scale_R scale_G scale_B but '%s' is no valid number\n", argv[i], argv[i+1]); + return FALSE; + } + F32 scale_G; + if (sscanf(argv[i+2], "%f", &scale_G) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: scale_R scale_G scale_B but '%s' is no valid number\n", argv[i], argv[i+2]); + return FALSE; + } + F32 scale_B; + if (sscanf(argv[i+3], "%f", &scale_B) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: scale_R scale_G scale_B but '%s' is no valid number\n", argv[i], argv[i+3]); + return FALSE; + } + add_operation(new LASoperationScaleRGB(scale_R, scale_G, scale_B)); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + } + else if ((strcmp(argv[i],"-scale_RGB_down") == 0) || (strcmp(argv[i],"-scale_rgb_down") == 0)) + { + add_operation(new LASoperationScaleRGBdown()); + *argv[i]='\0'; + } + else if ((strcmp(argv[i],"-scale_RGB_up") == 0) || (strcmp(argv[i],"-scale_rgb_up") == 0)) + { + add_operation(new LASoperationScaleRGBup()); + *argv[i]='\0'; } - F32 scale_B; - if (sscanf(argv[i+3], "%f", &scale_B) != 1) + else if ((strcmp(argv[i],"-scale_RGB_to_8bit") == 0) || (strcmp(argv[i],"-scale_rgb_to_8bit") == 0)) + { + add_operation(new LASoperationScaleRGBto8bit()); + *argv[i]='\0'; + } + else if ((strcmp(argv[i],"-scale_RGB_to_16bit") == 0) || (strcmp(argv[i],"-scale_rgb_to_16bit") == 0)) + { + add_operation(new LASoperationScaleRGBto16bit()); + *argv[i]='\0'; + } + } + else if ((strncmp(argv[i],"-scale_NIR", 10) == 0) || (strncmp(argv[i],"-scale_nir", 10) == 0)) + { + if (strcmp(argv[i],"-scale_NIR") == 0 || strcmp(argv[i],"-scale_nir") == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: scale_NIR\n", argv[i]); + return FALSE; + } + F32 scale_NIR; + if (sscanf(argv[i+1], "%f", &scale_NIR) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: scale_NIR but '%s' is no valid number\n", argv[i], argv[i+1]); + return FALSE; + } + add_operation(new LASoperationScaleNIR(scale_NIR)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if ((strcmp(argv[i],"-scale_NIR_down") == 0) || (strcmp(argv[i],"-scale_nir_down") == 0)) + { + add_operation(new LASoperationScaleNIRdown()); + *argv[i]='\0'; + } + else if ((strcmp(argv[i],"-scale_NIR_up") == 0) || (strcmp(argv[i],"-scale_nir_up") == 0)) + { + add_operation(new LASoperationScaleNIRup()); + *argv[i]='\0'; + } + else if ((strcmp(argv[i],"-scale_NIR_to_8bit") == 0) || (strcmp(argv[i],"-scale_nir_to_8bit") == 0)) + { + add_operation(new LASoperationScaleNIRto8bit()); + *argv[i]='\0'; + } + else if ((strcmp(argv[i],"-scale_NIR_to_16bit") == 0) || (strcmp(argv[i],"-scale_nir_to_16bit") == 0)) + { + add_operation(new LASoperationScaleNIRto16bit()); + *argv[i]='\0'; + } + } + else if (strcmp(argv[i],"-scale_attribute") == 0) + { + if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 3 arguments: scale_R scale_G scale_B but '%s' is no valid number\n", argv[i], argv[i+3]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index scale\n", argv[i]); return FALSE; } - add_operation(new LASoperationScaleRGB(scale_R, scale_G, scale_B)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; - } - else if (strcmp(argv[i],"-scale_user_data") == 0) - { - if ((i+1) >= argc) + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) { - REprintf("ERROR: '%s' needs 1 argument: scale\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index scale but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } F32 scale; - if (sscanf(argv[i+1], "%f", &scale) != 1) + if (sscanf(argv[i+2], "%f", &scale) != 1) { - REprintf("ERROR: '%s' needs 1 argument: scale but '%s' is no valid number\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index scale but '%s' is no valid scale\n", argv[i], argv[i+2]); return FALSE; } - add_operation(new LASoperationScaleUserData(scale)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; - } - else if (strcmp(argv[i],"-scale_RGB_down") == 0 || strcmp(argv[i],"-scale_rgb_down") == 0) - { - add_operation(new LASoperationScaleRGBdown()); - *argv[i]='\0'; - } - else if (strcmp(argv[i],"-scale_RGB_up") == 0 || strcmp(argv[i],"-scale_rgb_up") == 0) - { - add_operation(new LASoperationScaleRGBup()); - *argv[i]='\0'; + add_operation(new LASoperationScaleAttribute(index, scale)); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } - else if (strcmp(argv[i],"-scale_attribute") == 0) + else if (strcmp(argv[i],"-scale_register") == 0) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: index scale\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index scale\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: index scale but '%s' is no valid index\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index scale but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } F32 scale; if (sscanf(argv[i+2], "%f", &scale) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: index scale but '%s' is no valid scale\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index scale but '%s' is no valid scale\n", argv[i], argv[i+2]); return FALSE; } - add_operation(new LASoperationScaleAttribute(index, scale)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; - } + add_operation(new LASoperationScaleRegister(registers, index, scale)); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + } } else if (strncmp(argv[i],"-switch_", 8) == 0) { if (strcmp(argv[i],"-switch_x_y") == 0) { add_operation(new LASoperationSwitchXY()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-switch_x_z") == 0) { add_operation(new LASoperationSwitchXZ()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-switch_y_z") == 0) { add_operation(new LASoperationSwitchYZ()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-switch_R_G") == 0) { add_operation(new LASoperationSwitchRG()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-switch_R_B") == 0) { add_operation(new LASoperationSwitchRB()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-switch_G_B") == 0) { add_operation(new LASoperationSwitchGB()); - *argv[i]='\0'; + *argv[i]='\0'; + } + else if (strcmp(argv[i],"-switch_RGBI_into_CIR") == 0) + { + add_operation(new LASoperationSwitchRGBItoCIR()); + *argv[i]='\0'; + } + else if (strcmp(argv[i],"-switch_RGB_intensity_into_CIR") == 0) + { + add_operation(new LASoperationSwitchRGBIntensitytoCIR()); + *argv[i]='\0'; } } else if (strncmp(argv[i],"-bin_", 5) == 0) @@ -3623,85 +5496,85 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: bin_size\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: bin_size\n", argv[i]); return FALSE; } U32 bin_size; if (sscanf(argv[i+1], "%u", &bin_size) != 1) { - REprintf("ERROR: '%s' needs 1 argument: bin_size but '%s' is no valid bin_size\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: bin_size but '%s' is no valid bin_size\n", argv[i], argv[i+1]); return FALSE; } if (bin_size == 0) { - REprintf("ERROR: %u is no valid bin_size for '%s'\n", bin_size, argv[i]); + fprintf(stderr,"ERROR: %u is no valid bin_size for '%s'\n", bin_size, argv[i]); return FALSE; } add_operation(new LASoperationBinZintoPointSource(bin_size)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-bin_abs_scan_angle_into_point_source") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: bin_size\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: bin_size\n", argv[i]); return FALSE; } F32 bin_size; if (sscanf(argv[i+1], "%f", &bin_size) != 1) { - REprintf("ERROR: '%s' needs 1 argument: bin_size but '%s' is no valid bin_size\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: bin_size but '%s' is no valid bin_size\n", argv[i], argv[i+1]); return FALSE; } if (bin_size <= 0.0f) { - REprintf("ERROR: %f is no valid bin_size for '%s'\n", bin_size, argv[i]); + fprintf(stderr,"ERROR: %f is no valid bin_size for '%s'\n", bin_size, argv[i]); return FALSE; } add_operation(new LASoperationBinAbsScanAngleIntoPointSource(bin_size)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-bin_gps_time_into_intensity") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: bin_size\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: bin_size\n", argv[i]); return FALSE; } F64 bin_size; if (sscanf(argv[i+1], "%lf", &bin_size) != 1) { - REprintf("ERROR: '%s' needs 1 argument: bin_size but '%s' is no valid bin_size\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: bin_size but '%s' is no valid bin_size\n", argv[i], argv[i+1]); return FALSE; } if (bin_size <= 0.0) { - REprintf("ERROR: %g is no valid bin_size for '%s'\n", bin_size, argv[i]); + fprintf(stderr,"ERROR: %g is no valid bin_size for '%s'\n", bin_size, argv[i]); return FALSE; } add_operation(new LASoperationBinGpsTimeIntoIntensity(bin_size)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-bin_gps_time_into_point_source") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: bin_size\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: bin_size\n", argv[i]); return FALSE; } F64 bin_size; if (sscanf(argv[i+1], "%lf", &bin_size) != 1) { - REprintf("ERROR: '%s' needs 1 argument: bin_size but '%s' is no valid bin_size\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: bin_size but '%s' is no valid bin_size\n", argv[i], argv[i+1]); return FALSE; } if (bin_size <= 0.0) { - REprintf("ERROR: %g is no valid bin_size for '%s'\n", bin_size, argv[i]); + fprintf(stderr,"ERROR: %g is no valid bin_size for '%s'\n", bin_size, argv[i]); return FALSE; } add_operation(new LASoperationBinGpsTimeIntoPointSource(bin_size)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } } else if (strncmp(argv[i],"-map_", 5) == 0) @@ -3710,13 +5583,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: map_file_name.txt\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: map_file_name.txt\n", argv[i]); return FALSE; } FILE* file = fopen(argv[i+1], "r"); if (file == 0) { - REprintf("ERROR: cannot '%s' needs text file with map but '%s' cannot be opened\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: cannot '%s' needs text file with map but '%s' cannot be opened\n", argv[i], argv[i+1]); return FALSE; } else @@ -3724,19 +5597,19 @@ BOOL LAStransform::parse(int argc, char* argv[]) fclose(file); } add_operation(new LASoperationMapUserData(argv[i+1])); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-map_point_source") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: map_file_name.txt\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: map_file_name.txt\n", argv[i]); return FALSE; } FILE* file = fopen(argv[i+1], "r"); if (file == 0) { - REprintf("ERROR: cannot '%s' needs text file with map but '%s' cannot be opened\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs text file with map but '%s' cannot be opened\n", argv[i], argv[i+1]); return FALSE; } else @@ -3744,19 +5617,19 @@ BOOL LAStransform::parse(int argc, char* argv[]) fclose(file); } add_operation(new LASoperationMapPointSource(argv[i+1])); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-map_intensity") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: map_file_name.txt\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: map_file_name.txt\n", argv[i]); return FALSE; } FILE* file = fopen(argv[i+1], "r"); if (file == 0) { - REprintf("ERROR: cannot '%s' needs text file with map but '%s' cannot be opened\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs text file with map but '%s' cannot be opened\n", argv[i], argv[i+1]); return FALSE; } else @@ -3764,7 +5637,62 @@ BOOL LAStransform::parse(int argc, char* argv[]) fclose(file); } add_operation(new LASoperationMapIntensity(argv[i+1])); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i],"-map_attribute_into_RGB") == 0) + { + if ((i+2) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: attribute_index map_file_name.txt\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: attribute_index map_file_name.txt but '%s' is no valid attribute_index\n", argv[i], argv[i+1]); + return FALSE; + } + FILE* file = fopen(argv[i+2], "r"); + if (file == 0) + { + fprintf(stderr,"ERROR: '%s' needs text file with map but '%s' cannot be opened\n", argv[i], argv[i+2]); + return FALSE; + } + else + { + fclose(file); + } + add_operation(new LASoperationMapAttributeIntoRGB(index, argv[i+2])); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + } + } + else if (strncmp(argv[i],"-load_", 6) == 0) + { + if (strcmp(argv[i],"-load_attribute_from_text") == 0) + { + if ((i+2) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: attribute_index attribute_file_name.txt\n", argv[i]); + return FALSE; + } + U32 index; + if (sscanf(argv[i+1], "%u", &index) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: attribute_index attribute_file_name.txt but '%s' is no valid attribute_index\n", argv[i], argv[i+1]); + return FALSE; + } + FILE* file = fopen(argv[i+2], "r"); + if (file == 0) + { + fprintf(stderr,"ERROR: '%s' needs text file with attribute values but '%s' cannot be opened\n", argv[i], argv[i+2]); + return FALSE; + } + else + { + fclose(file); + } + add_operation(new LASoperationLoadAttributeFromText(index, argv[i+2])); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } } else if (strncmp(argv[i], "-transform_", 11) == 0) @@ -3773,7 +5701,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: 3 or 7 comma separated parameters\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: 3 or 7 comma separated parameters\n", argv[i]); return FALSE; } F64 dx, dy, dz, rx, ry, rz, m, dummy; @@ -3788,16 +5716,16 @@ BOOL LAStransform::parse(int argc, char* argv[]) } else { - REprintf("ERROR: '%s' needs 3 or 7 comma separated parameters as argument\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 3 or 7 comma separated parameters as argument\n", argv[i]); return FALSE; } - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i], "-transform_affine") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: 4 comma separated parameters\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: 4 comma separated parameters\n", argv[i]); return FALSE; } F64 k, w, tx, ty, dummy; @@ -3808,10 +5736,10 @@ BOOL LAStransform::parse(int argc, char* argv[]) } else { - REprintf("ERROR: '%s' needs 4 comma separated parameters as argument\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 4 comma separated parameters as argument\n", argv[i]); return FALSE; } - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } } else if (strcmp(argv[i],"-merge_scanner_channel_into_point_source") == 0) @@ -3832,105 +5760,378 @@ BOOL LAStransform::parse(int argc, char* argv[]) else if (strcmp(argv[i],"-flip_waveform_direction") == 0) { add_operation(new LASoperationFlipWaveformDirection()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-repair_zero_returns") == 0) { add_operation(new LASoperationRepairZeroReturns()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-adjusted_to_week") == 0) { add_operation(new LASoperationConvertAdjustedGpsToWeek()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-week_to_adjusted") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: week\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: week\n", argv[i]); return FALSE; } U32 week; if (sscanf(argv[i+1], "%u", &week) != 1) { - REprintf("ERROR: '%s' needs 1 argument: week but '%s' is no valid week\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: week but '%s' is no valid week\n", argv[i], argv[i+1]); return FALSE; } add_operation(new LASoperationConvertWeekToAdjustedGps(week)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-filtered_transform") == 0) { is_filtered = TRUE; - *argv[i]='\0'; + *argv[i]='\0'; } else if (strncmp(argv[i],"-add_", 5) == 0) { - if (strncmp(argv[i],"-add_scaled_", 12) == 0) + if (strcmp(argv[i],"-add_registers") == 0) + { + if ((i+3) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output\n", argv[i]); + return FALSE; + } + U32 input1; + if (sscanf(argv[i+1], "%u", &input1) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input1\n", argv[i], argv[i+1]); + return FALSE; + } + if (input1 > 15) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for input1\n", argv[i], input1); + return FALSE; + } + U32 input2; + if (sscanf(argv[i+2], "%u", &input2) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input2\n", argv[i], argv[i+2]); + return FALSE; + } + if (input2 > 15) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for input2\n", argv[i], input2); + return FALSE; + } + U32 output; + if (sscanf(argv[i+3], "%u", &output) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input3\n", argv[i], argv[i+3]); + return FALSE; + } + if (output > 15) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for output\n", argv[i], output); + return FALSE; + } + add_operation(new LASoperationAddRegisters(registers, input1, input2, output)); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + } + else if (strncmp(argv[i],"-add_scaled_", 12) == 0) { if (strcmp(argv[i], "-add_scaled_attribute_to_z") == 0) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: index scale\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index scale\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: index scale but '%s' is no valid index\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index scale but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } F32 scale; if (sscanf(argv[i+2], "%f", &scale) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: index scale but '%s' is no valid scale\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index scale but '%s' is no valid scale\n", argv[i], argv[i+2]); return FALSE; } - change_coordinates = TRUE; + if (scale == 0.0f) + { + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index scale but '%g' is no valid scale\n", argv[i], scale); + return FALSE; + } + transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationAddScaledAttributeToZ(index, scale)); - *argv[i]='\0'; *argv[i+2]='\0'; *argv[i+1]='\0'; i+=2; + *argv[i]='\0'; *argv[i+2]='\0'; *argv[i+1]='\0'; i+=2; } else if (strcmp(argv[i], "-add_scaled_attribute_to_user_data") == 0) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: index scale\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index scale\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: index scale but '%s' is no valid index\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index scale but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } F32 scale; if (sscanf(argv[i+2], "%f", &scale) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: index scale but '%s' is no valid scale\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: index scale but '%s' is no valid scale\n", argv[i], argv[i+2]); return FALSE; } add_operation(new LASoperationAddScaledAttributeToUserData(index, scale)); - *argv[i]='\0'; *argv[i+2]='\0'; *argv[i+1]='\0'; i+=2; + *argv[i]='\0'; *argv[i+2]='\0'; *argv[i+1]='\0'; i+=2; } } else if (strcmp(argv[i], "-add_attribute_to_z") == 0) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - REprintf("ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } - change_coordinates = TRUE; + transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationAddAttributeToZ(index)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + } + else if (strncmp(argv[i],"-multiply_", 10) == 0) + { + if (strcmp(argv[i],"-multiply_registers") == 0) + { + if ((i+3) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output\n", argv[i]); + return FALSE; + } + U32 input1; + if (sscanf(argv[i+1], "%u", &input1) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input1\n", argv[i], argv[i+1]); + return FALSE; + } + if (input1 > 15) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for input1\n", argv[i], input1); + return FALSE; + } + U32 input2; + if (sscanf(argv[i+2], "%u", &input2) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input2\n", argv[i], argv[i+2]); + return FALSE; + } + if (input2 > 15) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for input2\n", argv[i], input2); + return FALSE; + } + U32 output; + if (sscanf(argv[i+3], "%u", &output) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input3\n", argv[i], argv[i+3]); + return FALSE; + } + if (output > 15) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for output\n", argv[i], output); + return FALSE; + } + add_operation(new LASoperationMultiplyRegisters(registers, input1, input2, output)); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + } + else if (strncmp(argv[i]+10, "scaled_intensity_into_RGB", 25) == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: scale\n", argv[i]); + return FALSE; + } + F32 scale; + if (sscanf(argv[i+1], "%f", &scale) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: scale but '%s' is no valid scale\n", argv[i], argv[i+1]); + return FALSE; + } + if (scale == 0.0f) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: scale but '%g' is no valid scale\n", argv[i], scale); + return FALSE; + } + if (strcmp(argv[i]+36,"red") == 0) + { + transformed_fields |= LASTRANSFORM_RGB; + add_operation(new LASoperationMultiplyScaledIntensityIntoRGB(0, scale)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i]+36,"green") == 0) + { + transformed_fields |= LASTRANSFORM_RGB; + add_operation(new LASoperationMultiplyScaledIntensityIntoRGB(1, scale)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i]+36,"blue") == 0) + { + transformed_fields |= LASTRANSFORM_RGB; + add_operation(new LASoperationMultiplyScaledIntensityIntoRGB(2, scale)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i]+36,"nir") == 0) + { + transformed_fields |= LASTRANSFORM_NIR; + add_operation(new LASoperationMultiplyScaledIntensityIntoRGB(3, scale)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + } + else if (strncmp(argv[i]+10, "divided_intensity_into_RGB", 25) == 0) + { + if ((i+1) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: divisor \n", argv[i]); + return FALSE; + } + F32 divisor; + if (sscanf(argv[i+1], "%f", &divisor) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: scale but '%s' is no valid divisor\n", argv[i], argv[i+1]); + return FALSE; + } + if (divisor == 0.0f) + { + fprintf(stderr,"ERROR: '%s' needs 1 argument: scale but '%g' is no valid divisor\n", argv[i], divisor); + return FALSE; + } + F32 scale = 1.0f / divisor; + if (strcmp(argv[i]+37,"red") == 0) + { + transformed_fields |= LASTRANSFORM_RGB; + add_operation(new LASoperationMultiplyScaledIntensityIntoRGB(0, scale)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i]+37,"green") == 0) + { + transformed_fields |= LASTRANSFORM_RGB; + add_operation(new LASoperationMultiplyScaledIntensityIntoRGB(1, scale)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i]+37,"blue") == 0) + { + transformed_fields |= LASTRANSFORM_RGB; + add_operation(new LASoperationMultiplyScaledIntensityIntoRGB(2, scale)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + else if (strcmp(argv[i]+37,"nir") == 0) + { + transformed_fields |= LASTRANSFORM_NIR; + add_operation(new LASoperationMultiplyScaledIntensityIntoRGB(3, scale)); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } + } + } + else if (strncmp(argv[i],"-subtract_", 10) == 0) + { + if (strcmp(argv[i],"-subtract_registers") == 0) + { + if ((i+3) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output\n", argv[i]); + return FALSE; + } + U32 input1; + if (sscanf(argv[i+1], "%u", &input1) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input1\n", argv[i], argv[i+1]); + return FALSE; + } + if (input1 > 15) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for input1\n", argv[i], input1); + return FALSE; + } + U32 input2; + if (sscanf(argv[i+2], "%u", &input2) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input2\n", argv[i], argv[i+2]); + return FALSE; + } + if (input2 > 15) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for input2\n", argv[i], input2); + return FALSE; + } + U32 output; + if (sscanf(argv[i+3], "%u", &output) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input3\n", argv[i], argv[i+3]); + return FALSE; + } + if (output > 15) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for output\n", argv[i], output); + return FALSE; + } + add_operation(new LASoperationSubtractRegisters(registers, input1, input2, output)); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + } + } + else if (strncmp(argv[i],"-divide_", 8) == 0) + { + if (strcmp(argv[i],"-divide_registers") == 0) + { + if ((i+3) >= argc) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output\n", argv[i]); + return FALSE; + } + U32 input1; + if (sscanf(argv[i+1], "%u", &input1) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input1\n", argv[i], argv[i+1]); + return FALSE; + } + if (input1 > 15) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for input1\n", argv[i], input1); + return FALSE; + } + U32 input2; + if (sscanf(argv[i+2], "%u", &input2) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input2\n", argv[i], argv[i+2]); + return FALSE; + } + if (input2 > 15) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for input2\n", argv[i], input2); + return FALSE; + } + U32 output; + if (sscanf(argv[i+3], "%u", &output) != 1) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input3\n", argv[i], argv[i+3]); + return FALSE; + } + if (output > 15) + { + fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for output\n", argv[i], output); + return FALSE; + } + add_operation(new LASoperationDivideRegisters(registers, input1, input2, output)); + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } } } @@ -4007,11 +6208,13 @@ void LAStransform::reset() { operations[i]->reset(); } + memset(registers, 0, sizeof(F64)*16); } LAStransform::LAStransform() { - change_coordinates = FALSE; + transformed_fields = 0; + memset(registers, 0, sizeof(F64)*16); alloc_operations = 0; num_operations = 0; operations = 0; @@ -4045,27 +6248,41 @@ void LAStransform::add_operation(LASoperation* transform_operation) num_operations++; } -void LAStransform::setFilter(LASfilter* filter) -{ - if (this->filter) delete this->filter; - this->filter = filter; - if (filter == 0) is_filtered = FALSE; -} - -void LAStransform::setPointSource(U16 value) +void LAStransform::delete_operation(const CHAR* name) { if (operations) { U32 i; for (i = 0; i < num_operations; i++) { - if (strcmp(operations[i]->name(), "set_point_source") == 0) + if (strcmp(operations[i]->name(), name) == 0) { delete operations[i]; - operations[i] = new LASoperationSetPointSource(value); + for (i = i+1; i < num_operations; i++) + { + operations[i-1] = operations[i]; + } + num_operations--; return; } } } +} + +void LAStransform::setFilter(LASfilter* filter) +{ + if (this->filter) delete this->filter; + this->filter = filter; + if (filter == 0) is_filtered = FALSE; +} + +void LAStransform::setPointSource(U16 value) +{ + delete_operation("set_point_source"); add_operation(new LASoperationSetPointSource(value)); } + +void LAStransform::unsetPointSource() +{ + delete_operation("set_point_source"); +} diff --git a/inst/include/lastransform.hpp b/src/LASlib/lastransform.hpp similarity index 74% rename from inst/include/lastransform.hpp rename to src/LASlib/lastransform.hpp index c9f1d04..f761506 100644 --- a/inst/include/lastransform.hpp +++ b/src/LASlib/lastransform.hpp @@ -24,6 +24,7 @@ CHANGE HISTORY: + 10 May 2019 -- checking for overflows in X, Y, Z 32 bit integers of fixed-point LAS 6 March 2018 -- changed '%g' to '%lf' for all sprintf() of F64 values 28 February 2017 -- now '-set_RGB_of_class' also works for classifications > 31 1 February 2017 -- new '-copy_intensity_into_z' for use in lasgrid or lascanopy @@ -50,16 +51,32 @@ class LASoperation virtual const CHAR * name() const = 0; virtual I32 get_command(CHAR* string) const = 0; virtual U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_CHANNEL_RETURNS_XY; }; + inline I64 get_overflow() const { return overflow; }; + inline void zero_overflow() { overflow = 0; }; virtual void transform(LASpoint* point) = 0; - virtual void reset(){}; + virtual void reset(){ overflow = 0; }; + inline LASoperation(){ overflow = 0; }; virtual ~LASoperation(){}; +protected: + I64 overflow; }; +#define LASTRANSFORM_X_COORDINATE 0x00000001 +#define LASTRANSFORM_Y_COORDINATE 0x00000002 +#define LASTRANSFORM_Z_COORDINATE 0x00000004 +#define LASTRANSFORM_INTENSITY 0x00000008 +#define LASTRANSFORM_RGB 0x00020000 +#define LASTRANSFORM_NIR 0x02000000 + +#define LASTRANSFORM_XY_COORDINATE (LASTRANSFORM_X_COORDINATE | LASTRANSFORM_Y_COORDINATE) +#define LASTRANSFORM_XYZ_COORDINATE (LASTRANSFORM_XY_COORDINATE | LASTRANSFORM_Z_COORDINATE) + class LAStransform { public: - BOOL change_coordinates; + U32 transformed_fields; + F64 registers[16]; void usage() const; void clean(); @@ -73,8 +90,12 @@ class LAStransform void setFilter(LASfilter* filter); void setPointSource(U16 value); + void unsetPointSource(); void transform(LASpoint* point); + + void check_for_overflow() const; + void reset(); LAStransform(); @@ -83,6 +104,7 @@ class LAStransform private: void add_operation(LASoperation* operation); + void delete_operation(const CHAR* name); U32 num_operations; U32 alloc_operations; LASoperation** operations; diff --git a/src/LASlib/lasutility.cpp b/src/LASlib/lasutility.cpp index cb0127d..f666def 100644 --- a/src/LASlib/lasutility.cpp +++ b/src/LASlib/lasutility.cpp @@ -2,11 +2,11 @@ =============================================================================== FILE: lasutility.cpp - + CONTENTS: - + see corresponding header file - + PROGRAMMERS: martin.isenburg@rapidlasso.com - http://rapidlasso.com @@ -21,9 +21,9 @@ This software is distributed WITHOUT ANY WARRANTY and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - + CHANGE HISTORY: - + see corresponding header file =============================================================================== @@ -33,7 +33,6 @@ #include #include #include -#include LASinventory::LASinventory() { @@ -55,12 +54,12 @@ BOOL LASinventory::init(const LASheader* header) extended_number_of_points_by_return[0] = 0; for (i = 0; i < 5; i++) extended_number_of_points_by_return[i+1] = (header->number_of_points_by_return[i] ? header->number_of_points_by_return[i] : header->extended_number_of_points_by_return[i]); for (i = 5; i < 15; i++) extended_number_of_points_by_return[i+1] = header->extended_number_of_points_by_return[i]; - max_X = header->get_X(header->max_x); - min_X = header->get_X(header->min_x); - max_Y = header->get_Y(header->max_y); - min_Y = header->get_Y(header->min_y); - max_Z = header->get_Z(header->max_z); - min_Z = header->get_Z(header->min_z); + max_X = (I32)header->get_X(header->max_x); + min_X = (I32)header->get_X(header->min_x); + max_Y = (I32)header->get_Y(header->max_y); + min_Y = (I32)header->get_Y(header->min_y); + max_Z = (I32)header->get_Z(header->max_z); + min_Z = (I32)header->get_Z(header->min_z); first = FALSE; return TRUE; } @@ -161,7 +160,14 @@ LASsummary::LASsummary() for (i = 0; i < 16; i++) number_of_points_by_return[i] = 0; for (i = 0; i < 16; i++) number_of_returns[i] = 0; for (i = 0; i < 32; i++) classification[i] = 0; - for (i = 0; i < 256; i++) extended_classification[i] = 0; + for (i = 0; i < 256; i++) + { + extended_classification[i] = 0; + flagged_synthetic_classification[i] = 0; + flagged_keypoint_classification[i] = 0; + flagged_withheld_classification[i] = 0; + flagged_extended_overlap_classification[i] = 0; + } for (i = 0; i < 3; i++) { xyz_fluff_10[i] = 0; @@ -169,10 +175,10 @@ LASsummary::LASsummary() xyz_fluff_1000[i] = 0; xyz_fluff_10000[i] = 0; } - classification_synthetic = 0; - classification_keypoint = 0; - classification_withheld = 0; - classification_extended_overlap = 0; + flagged_synthetic = 0; + flagged_keypoint = 0; + flagged_withheld = 0; + flagged_extended_overlap = 0; first = TRUE; } @@ -191,7 +197,7 @@ BOOL LASsummary::add(const LASpoint* point) { classification[point->get_classification()]++; } - if (point->get_extended_overlap_flag()) classification_extended_overlap++; + if (point->get_extended_overlap_flag()) { flagged_extended_overlap++; flagged_extended_overlap_classification[(point->get_classification() ? point->get_classification() : point->get_extended_classification())]++; } } else { @@ -199,9 +205,9 @@ BOOL LASsummary::add(const LASpoint* point) classification[point->get_classification()]++; number_of_returns[point->get_number_of_returns()]++; } - if (point->get_synthetic_flag()) classification_synthetic++; - if (point->get_keypoint_flag()) classification_keypoint++; - if (point->get_withheld_flag()) classification_withheld++; + if (point->get_synthetic_flag()) { flagged_synthetic++; flagged_synthetic_classification[(point->get_classification() ? point->get_classification() : point->get_extended_classification())]++; } + if (point->get_keypoint_flag()) { flagged_keypoint++; flagged_keypoint_classification[(point->get_classification() ? point->get_classification() : point->get_extended_classification())]++; } + if (point->get_withheld_flag()) { flagged_withheld++; flagged_withheld_classification[(point->get_classification() ? point->get_classification() : point->get_extended_classification())]++; } if (first) { // does the point have extra bytes @@ -477,8 +483,8 @@ void LASbin::add_to_bin(I32 bin) bins_pos = (U32*)malloc(sizeof(U32)*size_pos); if (bins_pos == 0) { - REprintf( "ERROR: allocating %u pos bins\012", size_pos); - throw std::runtime_error("Internal error"); + fprintf(stderr, "ERROR: allocating %u pos bins\012", size_pos); + exit(1); } for (i = 0; i < size_pos; i++) bins_pos[i] = 0; } @@ -488,8 +494,8 @@ void LASbin::add_to_bin(I32 bin) bins_pos = (U32*)realloc(bins_pos, sizeof(U32)*new_size); if (bins_pos == 0) { - REprintf( "ERROR: reallocating %u pos bins\012", new_size); - throw std::runtime_error("Internal error"); + fprintf(stderr, "ERROR: reallocating %u pos bins\012", new_size); + exit(1); } for (i = size_pos; i < new_size; i++) bins_pos[i] = 0; size_pos = new_size; @@ -509,8 +515,8 @@ void LASbin::add_to_bin(I32 bin) bins_neg = (U32*)malloc(sizeof(U32)*size_neg); if (bins_neg == 0) { - REprintf( "ERROR: allocating %u neg bins\012", size_neg); - throw std::runtime_error("Internal error"); + fprintf(stderr, "ERROR: allocating %u neg bins\012", size_neg); + exit(1); } for (i = 0; i < size_neg; i++) bins_neg[i] = 0; } @@ -520,8 +526,8 @@ void LASbin::add_to_bin(I32 bin) bins_neg = (U32*)realloc(bins_neg, sizeof(U32)*new_size); if (bins_neg == 0) { - REprintf( "ERROR: reallocating %u neg bins\012", new_size); - throw std::runtime_error("Internal error"); + fprintf(stderr, "ERROR: reallocating %u neg bins\012", new_size); + exit(1); } for (i = size_neg; i < new_size; i++) bins_neg[i] = 0; size_neg = new_size; @@ -554,13 +560,13 @@ void LASbin::add(I32 item, I32 value) values_pos = (F64*)malloc(sizeof(F64)*size_pos); if (bins_pos == 0) { - REprintf( "ERROR: allocating %u pos bins\012", size_pos); - throw std::runtime_error("Internal error"); + fprintf(stderr, "ERROR: allocating %u pos bins\012", size_pos); + exit(1); } if (values_pos == 0) { - REprintf( "ERROR: allocating %u pos values\012", size_pos); - throw std::runtime_error("Internal error"); + fprintf(stderr, "ERROR: allocating %u pos values\012", size_pos); + exit(1); } for (i = 0; i < size_pos; i++) { bins_pos[i] = 0; values_pos[i] = 0; } } @@ -571,13 +577,13 @@ void LASbin::add(I32 item, I32 value) values_pos = (F64*)realloc(values_pos, sizeof(F64)*new_size); if (bins_pos == 0) { - REprintf( "ERROR: reallocating %u pos bins\012", new_size); - throw std::runtime_error("Internal error"); + fprintf(stderr, "ERROR: reallocating %u pos bins\012", new_size); + exit(1); } if (values_pos == 0) { - REprintf( "ERROR: reallocating %u pos values\012", new_size); - throw std::runtime_error("Internal error"); + fprintf(stderr, "ERROR: reallocating %u pos values\012", new_size); + exit(1); } for (i = size_pos; i < new_size; i++) { bins_pos[i] = 0; values_pos[i] = 0; } size_pos = new_size; @@ -599,13 +605,13 @@ void LASbin::add(I32 item, I32 value) values_neg = (F64*)malloc(sizeof(F64)*size_neg); if (bins_neg == 0) { - REprintf( "ERROR: allocating %u neg bins\012", size_neg); - throw std::runtime_error("Internal error"); + fprintf(stderr, "ERROR: allocating %u neg bins\012", size_neg); + exit(1); } if (values_neg == 0) { - REprintf( "ERROR: allocating %u neg values\012", size_neg); - throw std::runtime_error("Internal error"); + fprintf(stderr, "ERROR: allocating %u neg values\012", size_neg); + exit(1); } for (i = 0; i < size_neg; i++) { bins_neg[i] = 0; values_neg[i] = 0; } } @@ -616,13 +622,13 @@ void LASbin::add(I32 item, I32 value) values_neg = (F64*)realloc(values_neg, sizeof(F64)*new_size); if (bins_neg == 0) { - REprintf( "ERROR: reallocating %u neg bins\012", new_size); - throw std::runtime_error("Internal error"); + fprintf(stderr, "ERROR: reallocating %u neg bins\012", new_size); + exit(1); } if (values_neg == 0) { - REprintf( "ERROR: reallocating %u neg values\012", new_size); - throw std::runtime_error("Internal error"); + fprintf(stderr, "ERROR: reallocating %u neg values\012", new_size); + exit(1); } for (i = size_neg; i < new_size; i++) { bins_neg[i] = 0; values_neg[i] = 0; } size_neg = new_size; @@ -656,13 +662,13 @@ void LASbin::add(F64 item, F64 value) values_pos = (F64*)malloc(sizeof(F64)*size_pos); if (bins_pos == 0) { - REprintf( "ERROR: allocating %u pos bins\012", size_pos); - throw std::runtime_error("Internal error"); + fprintf(stderr, "ERROR: allocating %u pos bins\012", size_pos); + exit(1); } if (values_pos == 0) { - REprintf( "ERROR: allocating %u pos values\012", size_pos); - throw std::runtime_error("Internal error"); + fprintf(stderr, "ERROR: allocating %u pos values\012", size_pos); + exit(1); } for (i = 0; i < size_pos; i++) { bins_pos[i] = 0; values_pos[i] = 0; } } @@ -673,13 +679,13 @@ void LASbin::add(F64 item, F64 value) values_pos = (F64*)realloc(values_pos, sizeof(F64)*new_size); if (bins_pos == 0) { - REprintf( "ERROR: reallocating %u pos bins\012", new_size); - throw std::runtime_error("Internal error"); + fprintf(stderr, "ERROR: reallocating %u pos bins\012", new_size); + exit(1); } if (values_pos == 0) { - REprintf( "ERROR: reallocating %u pos values\012", new_size); - throw std::runtime_error("Internal error"); + fprintf(stderr, "ERROR: reallocating %u pos values\012", new_size); + exit(1); } for (i = size_pos; i < new_size; i++) { bins_pos[i] = 0; values_pos[i] = 0; } size_pos = new_size; @@ -701,13 +707,13 @@ void LASbin::add(F64 item, F64 value) values_neg = (F64*)malloc(sizeof(F64)*size_neg); if (bins_neg == 0) { - REprintf( "ERROR: allocating %u neg bins\012", size_neg); - throw std::runtime_error("Internal error"); + fprintf(stderr, "ERROR: allocating %u neg bins\012", size_neg); + exit(1); } if (values_neg == 0) { - REprintf( "ERROR: allocating %u neg values\012", size_neg); - throw std::runtime_error("Internal error"); + fprintf(stderr, "ERROR: allocating %u neg values\012", size_neg); + exit(1); } for (i = 0; i < size_neg; i++) { bins_neg[i] = 0; values_neg[i] = 0; } } @@ -718,13 +724,13 @@ void LASbin::add(F64 item, F64 value) values_neg = (F64*)realloc(values_neg, sizeof(F64)*new_size); if (bins_neg == 0) { - REprintf( "ERROR: reallocating %u neg bins\012", new_size); - throw std::runtime_error("Internal error"); + fprintf(stderr, "ERROR: reallocating %u neg bins\012", new_size); + exit(1); } if (values_neg == 0) { - REprintf( "ERROR: reallocating %u neg values\012", new_size); - throw std::runtime_error("Internal error"); + fprintf(stderr, "ERROR: reallocating %u neg values\012", new_size); + exit(1); } for (i = size_neg; i < new_size; i++) { bins_neg[i] = 0; values_neg[i] = 0; } size_neg = new_size; @@ -906,6 +912,11 @@ LAShistogram::LAShistogram() attribute2_bin = 0; attribute3_bin = 0; attribute4_bin = 0; + attribute5_bin = 0; + attribute6_bin = 0; + attribute7_bin = 0; + attribute8_bin = 0; + attribute9_bin = 0; wavepacket_index_bin = 0; wavepacket_offset_bin = 0; wavepacket_size_bin = 0; @@ -947,6 +958,11 @@ LAShistogram::~LAShistogram() if (attribute2_bin) delete attribute2_bin; if (attribute3_bin) delete attribute3_bin; if (attribute4_bin) delete attribute4_bin; + if (attribute5_bin) delete attribute5_bin; + if (attribute6_bin) delete attribute6_bin; + if (attribute7_bin) delete attribute7_bin; + if (attribute8_bin) delete attribute8_bin; + if (attribute9_bin) delete attribute9_bin; if (wavepacket_index_bin) delete wavepacket_index_bin; if (wavepacket_offset_bin) delete wavepacket_offset_bin; if (wavepacket_size_bin) delete wavepacket_size_bin; @@ -977,33 +993,33 @@ BOOL LAShistogram::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - REprintf("ERROR: '%s' needs 2 arguments: name step\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: name step\n", argv[i]); return FALSE; } F64 step = 0.0; if (sscanf(argv[i+2], "%lf", &step) != 1) { - REprintf("ERROR: '%s' needs 2 arguments: name step but '%s' is no valid step\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 2 arguments: name step but '%s' is no valid step\n", argv[i], argv[i+2]); return FALSE; } if (!histo(argv[i+1], step)) return FALSE; - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-histo_avg") == 0) { if ((i+3) >= argc) { - REprintf("ERROR: '%s' needs 3 arguments: name step name_avg\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: name step name_avg\n", argv[i]); return FALSE; } F64 step = 0.0; if (sscanf(argv[i+2], "%lf", &step) != 1) { - REprintf("ERROR: '%s' needs 3 arguments: name step name_avg but '%s' is no valid step\n", argv[i], argv[i+2]); + fprintf(stderr,"ERROR: '%s' needs 3 arguments: name step name_avg but '%s' is no valid step\n", argv[i], argv[i+2]); return FALSE; } if (!histo_avg(argv[i+1], step, argv[i+3])) return FALSE; - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } } return TRUE; @@ -1032,11 +1048,16 @@ I32 LAShistogram::unparse(CHAR* string) const if (G_bin) n += sprintf(&string[n], "-histo G %lf ", G_bin->get_step()); if (B_bin) n += sprintf(&string[n], "-histo B %lf ", B_bin->get_step()); if (I_bin) n += sprintf(&string[n], "-histo I %lf ", I_bin->get_step()); - if (attribute0_bin) n += sprintf(&string[n], "-histo 0 %lf ", attribute0_bin->get_step()); - if (attribute1_bin) n += sprintf(&string[n], "-histo 1 %lf ", attribute1_bin->get_step()); - if (attribute2_bin) n += sprintf(&string[n], "-histo 2 %lf ", attribute2_bin->get_step()); - if (attribute3_bin) n += sprintf(&string[n], "-histo 3 %lf ", attribute3_bin->get_step()); - if (attribute4_bin) n += sprintf(&string[n], "-histo 4 %lf ", attribute4_bin->get_step()); + if (attribute0_bin) n += sprintf(&string[n], "-histo attribute0 %lf ", attribute0_bin->get_step()); + if (attribute1_bin) n += sprintf(&string[n], "-histo attribute1 %lf ", attribute1_bin->get_step()); + if (attribute2_bin) n += sprintf(&string[n], "-histo attribute2 %lf ", attribute2_bin->get_step()); + if (attribute3_bin) n += sprintf(&string[n], "-histo attribute3 %lf ", attribute3_bin->get_step()); + if (attribute4_bin) n += sprintf(&string[n], "-histo attribute4 %lf ", attribute4_bin->get_step()); + if (attribute5_bin) n += sprintf(&string[n], "-histo attribute5 %lf ", attribute5_bin->get_step()); + if (attribute6_bin) n += sprintf(&string[n], "-histo attribute6 %lf ", attribute6_bin->get_step()); + if (attribute7_bin) n += sprintf(&string[n], "-histo attribute7 %lf ", attribute7_bin->get_step()); + if (attribute8_bin) n += sprintf(&string[n], "-histo attribute8 %lf ", attribute8_bin->get_step()); + if (attribute9_bin) n += sprintf(&string[n], "-histo attribute9 %lf ", attribute9_bin->get_step()); if (wavepacket_index_bin) n += sprintf(&string[n], "-histo wavepacket_index %lf ", wavepacket_index_bin->get_step()); if (wavepacket_offset_bin) n += sprintf(&string[n], "-histo wavepacket_offset %lf ", wavepacket_offset_bin->get_step()); if (wavepacket_size_bin) n += sprintf(&string[n], "-histo wavepacket_size %lf ", wavepacket_size_bin->get_step()); @@ -1096,6 +1117,16 @@ BOOL LAShistogram::histo(const CHAR* name, F64 step) attribute3_bin = new LASbin(step); else if (strcmp(name, "4") == 0 || strcmp(name, "attribute4") == 0) attribute4_bin = new LASbin(step); + else if (strcmp(name, "5") == 0 || strcmp(name, "attribute5") == 0) + attribute5_bin = new LASbin(step); + else if (strcmp(name, "6") == 0 || strcmp(name, "attribute6") == 0) + attribute6_bin = new LASbin(step); + else if (strcmp(name, "7") == 0 || strcmp(name, "attribute7") == 0) + attribute7_bin = new LASbin(step); + else if (strcmp(name, "8") == 0 || strcmp(name, "attribute8") == 0) + attribute8_bin = new LASbin(step); + else if (strcmp(name, "9") == 0 || strcmp(name, "attribute9") == 0) + attribute9_bin = new LASbin(step); else if (strstr(name, "wavepacket_index") != 0) wavepacket_index_bin = new LASbin(step); else if (strstr(name, "wavepacket_offset") != 0) @@ -1106,7 +1137,7 @@ BOOL LAShistogram::histo(const CHAR* name, F64 step) wavepacket_location_bin = new LASbin(step); else { - REprintf("ERROR: histogram of '%s' not implemented\n", name); + fprintf(stderr,"ERROR: histogram of '%s' not implemented\n", name); return FALSE; } is_active = TRUE; @@ -1123,7 +1154,7 @@ BOOL LAShistogram::histo_avg(const CHAR* name, F64 step, const CHAR* name_avg) classification_bin_scan_angle = new LASbin(step); else { - REprintf("ERROR: histogram of '%s' with '%s' averages not implemented\n", name, name_avg); + fprintf(stderr,"ERROR: histogram of '%s' with '%s' averages not implemented\n", name, name_avg); return FALSE; } } @@ -1137,7 +1168,7 @@ BOOL LAShistogram::histo_avg(const CHAR* name, F64 step, const CHAR* name_avg) scan_angle_bin_intensity = new LASbin(step); else { - REprintf("ERROR: histogram of '%s' with '%s' averages not implemented\n", name, name_avg); + fprintf(stderr,"ERROR: histogram of '%s' with '%s' averages not implemented\n", name, name_avg); return FALSE; } } @@ -1147,13 +1178,13 @@ BOOL LAShistogram::histo_avg(const CHAR* name, F64 step, const CHAR* name_avg) return_map_bin_intensity = new LASbin(1); else { - REprintf("ERROR: histogram of '%s' with '%s' averages not implemented\n", name, name_avg); + fprintf(stderr,"ERROR: histogram of '%s' with '%s' averages not implemented\n", name, name_avg); return FALSE; } } else { - REprintf("ERROR: histogram of '%s' not implemented\n", name); + fprintf(stderr,"ERROR: histogram of '%s' not implemented\n", name); return FALSE; } is_active = TRUE; @@ -1194,6 +1225,11 @@ void LAShistogram::add(const LASpoint* point) if (attribute2_bin) attribute2_bin->add(point->get_attribute_as_float(2)); if (attribute3_bin) attribute3_bin->add(point->get_attribute_as_float(3)); if (attribute4_bin) attribute4_bin->add(point->get_attribute_as_float(4)); + if (attribute5_bin) attribute5_bin->add(point->get_attribute_as_float(5)); + if (attribute6_bin) attribute6_bin->add(point->get_attribute_as_float(6)); + if (attribute7_bin) attribute7_bin->add(point->get_attribute_as_float(7)); + if (attribute8_bin) attribute8_bin->add(point->get_attribute_as_float(8)); + if (attribute9_bin) attribute9_bin->add(point->get_attribute_as_float(9)); if (wavepacket_index_bin) wavepacket_index_bin->add(point->wavepacket.getIndex()); if (wavepacket_offset_bin) wavepacket_offset_bin->add((I64)point->wavepacket.getOffset()); if (wavepacket_size_bin) wavepacket_size_bin->add((I32)point->wavepacket.getSize()); @@ -1252,6 +1288,11 @@ void LAShistogram::report(FILE* file) const if (attribute2_bin) attribute2_bin->report(file, "attribute 2"); if (attribute3_bin) attribute3_bin->report(file, "attribute 3"); if (attribute4_bin) attribute4_bin->report(file, "attribute 4"); + if (attribute5_bin) attribute5_bin->report(file, "attribute 5"); + if (attribute6_bin) attribute6_bin->report(file, "attribute 6"); + if (attribute7_bin) attribute7_bin->report(file, "attribute 7"); + if (attribute8_bin) attribute8_bin->report(file, "attribute 8"); + if (attribute9_bin) attribute9_bin->report(file, "attribute 9"); if (wavepacket_index_bin) wavepacket_index_bin->report(file, "wavepacket_index"); if (wavepacket_offset_bin) wavepacket_offset_bin->report(file, "wavepacket_offset"); if (wavepacket_size_bin) wavepacket_size_bin->report(file, "wavepacket_size"); @@ -1293,6 +1334,11 @@ void LAShistogram::reset() if (attribute2_bin) attribute2_bin->reset(); if (attribute3_bin) attribute3_bin->reset(); if (attribute4_bin) attribute4_bin->reset(); + if (attribute5_bin) attribute5_bin->reset(); + if (attribute6_bin) attribute6_bin->reset(); + if (attribute7_bin) attribute7_bin->reset(); + if (attribute8_bin) attribute8_bin->reset(); + if (attribute9_bin) attribute9_bin->reset(); if (wavepacket_index_bin) wavepacket_index_bin->reset(); if (wavepacket_offset_bin) wavepacket_offset_bin->reset(); if (wavepacket_size_bin) wavepacket_size_bin->reset(); @@ -1637,7 +1683,7 @@ LASoccupancyGrid::LASoccupancyGrid(F32 grid_spacing) this->grid_spacing = -grid_spacing; minus_ankers = 0; minus_minus_size = 0; - minus_minus = 0; + minus_minus = 0; minus_minus_sizes = 0; minus_plus_size = 0; minus_plus = 0; diff --git a/inst/include/lasutility.hpp b/src/LASlib/lasutility.hpp similarity index 90% rename from inst/include/lasutility.hpp rename to src/LASlib/lasutility.hpp index d494914..ebf73d2 100644 --- a/inst/include/lasutility.hpp +++ b/src/LASlib/lasutility.hpp @@ -36,7 +36,7 @@ #include "lasdefinitions.hpp" -class LASinventory +class LASLIB_DLL LASinventory { public: BOOL active() const { return (first == FALSE); }; @@ -56,7 +56,7 @@ class LASinventory BOOL first; }; -class LASsummary +class LASLIB_DLL LASsummary { public: BOOL active() const { return (first == FALSE); }; @@ -65,10 +65,14 @@ class LASsummary I64 number_of_returns[16]; I64 classification[32]; I64 extended_classification[256]; - I64 classification_synthetic; - I64 classification_keypoint; - I64 classification_withheld; - I64 classification_extended_overlap; + I64 flagged_synthetic; + I64 flagged_synthetic_classification[256]; + I64 flagged_keypoint; + I64 flagged_keypoint_classification[256]; + I64 flagged_withheld; + I64 flagged_withheld_classification[256]; + I64 flagged_extended_overlap; + I64 flagged_extended_overlap_classification[256]; LASpoint min; LASpoint max; U16 xyz_low_digits_10[3]; @@ -81,7 +85,7 @@ class LASsummary I64 xyz_fluff_10000[3]; BOOL add(const LASpoint* point); BOOL has_fluff() const { return has_fluff(0) || has_fluff(1) || has_fluff(2); }; - BOOL has_fluff(U32 i) const { return (number_of_point_records && (number_of_point_records == xyz_fluff_10[i])); }; + BOOL has_fluff(U32 i) const { return (number_of_point_records && ((min.get_XYZ())[i] != (max.get_XYZ())[i]) && (number_of_point_records == xyz_fluff_10[i])); }; BOOL has_serious_fluff() const { return has_serious_fluff(0) || has_serious_fluff(1) || has_serious_fluff(2); }; BOOL has_serious_fluff(U32 i) const { return (number_of_point_records && (number_of_point_records == xyz_fluff_100[i])); }; BOOL has_very_serious_fluff() const { return has_very_serious_fluff(0) || has_very_serious_fluff(1) || has_very_serious_fluff(2); }; @@ -124,7 +128,7 @@ class LASbin F64* values_neg; }; -class LAShistogram +class LASLIB_DLL LAShistogram { public: BOOL active() const { return is_active; }; @@ -165,6 +169,11 @@ class LAShistogram LASbin* attribute2_bin; LASbin* attribute3_bin; LASbin* attribute4_bin; + LASbin* attribute5_bin; + LASbin* attribute6_bin; + LASbin* attribute7_bin; + LASbin* attribute8_bin; + LASbin* attribute9_bin; LASbin* wavepacket_index_bin; LASbin* wavepacket_offset_bin; LASbin* wavepacket_size_bin; @@ -178,7 +187,7 @@ class LAShistogram LASbin* return_map_bin_intensity; }; -class LASoccupancyGrid +class LASLIB_DLL LASoccupancyGrid { public: void reset(); diff --git a/src/LASlib/lasvlr.cpp b/src/LASlib/lasvlr.cpp new file mode 100644 index 0000000..a22baf8 --- /dev/null +++ b/src/LASlib/lasvlr.cpp @@ -0,0 +1,41 @@ +/* +=============================================================================== + + FILE: lasvlr.cpp + + CONTENTS: + + see corresponding header file + + PROGRAMMERS: + + martin.isenburg@rapidlasso.com - http://rapidlasso.com + + COPYRIGHT: + + (c) 2007-2019, martin isenburg, rapidlasso - fast tools to catch reality + + This is free software; you can redistribute and/or modify it under the + terms of the GNU Lesser General Licence as published by the Free Software + Foundation. See the LICENSE.txt file for more information. + + This software is distributed WITHOUT ANY WARRANTY and without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + CHANGE HISTORY: + + see corresponding header file + +=============================================================================== +*/ +#include "lasvlr.hpp" + +LASvlr_lastiling::LASvlr_lastiling() +{ + memset((void*)this, 0, sizeof(LASvlr_lastiling)); +} + +LASvlr_lasoriginal::LASvlr_lasoriginal() +{ + memset((void*)this, 0, sizeof(LASvlr_lasoriginal)); +} diff --git a/src/LASlib/lasvlr.hpp b/src/LASlib/lasvlr.hpp new file mode 100644 index 0000000..cfc7515 --- /dev/null +++ b/src/LASlib/lasvlr.hpp @@ -0,0 +1,76 @@ +/* +=============================================================================== + + FILE: lasvlr.hpp + + CONTENTS: + + This class defines those VLRs and EVLRs that are defined either in the LAS + specification or are specific to and used by LAStools. + + PROGRAMMERS: + + martin.isenburg@rapidlasso.com - http://rapidlasso.com + + COPYRIGHT: + + (c) 2007-2019, martin isenburg, rapidlasso - fast tools to catch reality + + This is free software; you can redistribute and/or modify it under the + terms of the GNU Lesser General Licence as published by the Free Software + Foundation. See the LICENSE.txt file for more information. + + This software is distributed WITHOUT ANY WARRANTY and without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + CHANGE HISTORY: + + 28 November 2019 -- created after Tobago paddle week in flight POS -> PTY + +=============================================================================== +*/ +#ifndef LAS_VLR_HPP +#define LAS_VLR_HPP + +#include "mydefs.hpp" + +class LASvlr_lastiling +{ +public: + U32 level; + U32 level_index; + U32 implicit_levels : 30; + U32 buffer : 1; + U32 reversible : 1; + F32 min_x; + F32 max_x; + F32 min_y; + F32 max_y; + + LASvlr_lastiling() + { + memset((void*)this, 0, sizeof(LASvlr_lastiling)); + }; +}; + +class LASvlr_lasoriginal +{ +public: + I64 number_of_point_records; + I64 number_of_points_by_return[15]; + F64 max_x; + F64 min_x; + F64 max_y; + F64 min_y; + F64 max_z; + F64 min_z; + I64 position; + + LASvlr_lasoriginal() + { + memset((void*)this, 0, sizeof(LASvlr_lasoriginal)); + }; +}; + + +#endif // LAS_VLR_HPP diff --git a/src/LASlib/lasvlrpayload.hpp b/src/LASlib/lasvlrpayload.hpp new file mode 100644 index 0000000..a9ed0d0 --- /dev/null +++ b/src/LASlib/lasvlrpayload.hpp @@ -0,0 +1,275 @@ +/* +=============================================================================== + + FILE: lasvlrpayload.hpp + + CONTENTS: + + This class describes a few useful payloads for Variable Length Records + (VLRs) and Extended Variable Length Records (EVLRs) used by LASlib. + + PROGRAMMERS: + + martin.isenburg@rapidlasso.com - http://rapidlasso.com + + COPYRIGHT: + + (c) 2007-2019, martin isenburg, rapidlasso - fast tools to catch reality + + This is free software; you can redistribute and/or modify it under the + terms of the GNU Lesser General Licence as published by the Free Software + Foundation. See the LICENSE.txt file for more information. + + This software is distributed WITHOUT ANY WARRANTY and without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + CHANGE HISTORY: + + 7 July 2019 -- created after US beat NL 2:0 in Women World Cup Final + +=============================================================================== +*/ +#ifndef LAS_VLR_PAYLOAD_HPP +#define LAS_VLR_PAYLOAD_HPP + +#include "bytestreamin_array.hpp" +#include "bytestreamout_array.hpp" + +class LASvlrPayload +{ +public: + CHAR user_id[16]; + virtual U16 get_record_id() const = 0; + virtual const CHAR* get_user_id() const = 0; + virtual I64 get_payload_size() const = 0; + virtual U8* get_payload() const = 0; + virtual BOOL set_payload(const U8* payload, I64 size) = 0; + virtual ~LASvlrPayload() {}; +protected: + virtual BOOL save(ByteStreamOut* stream) const = 0; + virtual BOOL load(ByteStreamIn* stream) = 0; +}; + +class LASvlrRasterLAZ : public LASvlrPayload +{ +public: + I32 nbands; + I32 nbits; + I32 ncols; + I32 nrows; + U32 reserved1; + U32 reserved2; + F64 stepx; + F64 stepx_y; + F64 stepy; + F64 stepy_x; + F64 llx; + F64 lly; + F64 sigmaxy; // horizontal uncertainty [meters] + LASvlrRasterLAZ() + { + memcpy(user_id, "Raster LAZ\0\0\0\0\0", 16); + nbands = -1; + nbits = -1; + ncols = -1; + nrows = -1; + reserved1 = 0; + reserved2 = 0; + stepx = 1.0; + stepx_y = 0.0; + stepy = 1.0; + stepy_x = 0.0; + llx = 0.0; + lly = 0.0; + sigmaxy = 0.0; + }; + U16 get_record_id() const + { + return 7113; + } + const CHAR* get_user_id() const + { + return user_id; + } + I64 get_payload_size() const + { + return (6 * sizeof(I32) + 7 * sizeof(F64)); + }; + U8* get_payload() const + { + U8* payload = 0; + I64 size = get_payload_size(); + ByteStreamOutArray* stream = 0; + if (IS_LITTLE_ENDIAN()) + stream = new ByteStreamOutArrayLE(size); + else + stream = new ByteStreamOutArrayBE(size); + if (stream) + { + if (save(stream)) + { + payload = stream->takeData(); + } + delete stream; + } + return payload; + }; + BOOL set_payload(const U8* payload, I64 size) + { + ByteStreamInArray* stream = 0; + if (IS_LITTLE_ENDIAN()) + stream = new ByteStreamInArrayLE(payload, size); + else + stream = new ByteStreamInArrayBE(payload, size); + if (stream) + { + if (load(stream)) + { + delete stream; + return TRUE; + } + delete stream; + } + return FALSE; + } + BOOL save(ByteStreamOut* stream) const + { + if (!stream->put32bitsLE((U8*)&nbands)) + { + fprintf(stderr,"ERROR: writing LASvlrRasterLAZ.nbands\n"); + return FALSE; + } + if (!stream->put32bitsLE((U8*)&nbits)) + { + fprintf(stderr,"ERROR: writing LASvlrRasterLAZ.nbits\n"); + return FALSE; + } + if (!stream->put32bitsLE((U8*)&ncols)) + { + fprintf(stderr,"ERROR: writing LASvlrRasterLAZ.ncols\n"); + return FALSE; + } + if (!stream->put32bitsLE((U8*)&nrows)) + { + fprintf(stderr,"ERROR: writing LASvlrRasterLAZ.nrows\n"); + return FALSE; + } + if (!stream->put32bitsLE((U8*)&reserved1)) + { + fprintf(stderr,"ERROR: writing LASvlrRasterLAZ.reserved1\n"); + return FALSE; + } + if (!stream->put32bitsLE((U8*)&reserved2)) + { + fprintf(stderr,"ERROR: writing LASvlrRasterLAZ.reserved2\n"); + return FALSE; + } + if (!stream->put64bitsLE((U8*)&stepx)) + { + fprintf(stderr,"ERROR: writing LASvlrRasterLAZ.stepx\n"); + return FALSE; + } + if (!stream->put64bitsLE((U8*)&stepx_y)) + { + fprintf(stderr,"ERROR: writing LASvlrRasterLAZ.stepx_y\n"); + return FALSE; + } + if (!stream->put64bitsLE((U8*)&stepy)) + { + fprintf(stderr,"ERROR: writing LASvlrRasterLAZ.stepy\n"); + return FALSE; + } + if (!stream->put64bitsLE((U8*)&stepy_x)) + { + fprintf(stderr,"ERROR: writing LASvlrRasterLAZ.stepy_x\n"); + return FALSE; + } + if (!stream->put64bitsLE((U8*)&llx)) + { + fprintf(stderr,"ERROR: writing LASvlrRasterLAZ.llx\n"); + return FALSE; + } + if (!stream->put64bitsLE((U8*)&lly)) + { + fprintf(stderr,"ERROR: writing LASvlrRasterLAZ.lly\n"); + return FALSE; + } + if (!stream->put64bitsLE((U8*)&sigmaxy)) + { + fprintf(stderr,"ERROR: writing LASvlrRasterLAZ.sigmaxy\n"); + return FALSE; + } + return TRUE; + }; + BOOL load(ByteStreamIn* stream) + { + try { stream->get32bitsLE((U8*)&nbands); } catch(...) + { + fprintf(stderr,"ERROR: reading LASvlrRasterLAZ.nbands\n"); + return FALSE; + } + try { stream->get32bitsLE((U8*)&nbits); } catch(...) + { + fprintf(stderr,"ERROR: reading LASvlrRasterLAZ.nbits\n"); + return FALSE; + } + try { stream->get32bitsLE((U8*)&ncols); } catch(...) + { + fprintf(stderr,"ERROR: reading LASvlrRasterLAZ.ncols\n"); + return FALSE; + } + try { stream->get32bitsLE((U8*)&nrows); } catch(...) + { + fprintf(stderr,"ERROR: reading LASvlrRasterLAZ.nrows\n"); + return FALSE; + } + try { stream->get32bitsLE((U8*)&reserved1); } catch(...) + { + fprintf(stderr,"ERROR: reading LASvlrRasterLAZ.reserved1\n"); + return FALSE; + } + try { stream->get32bitsLE((U8*)&reserved2); } catch(...) + { + fprintf(stderr,"ERROR: reading LASvlrRasterLAZ.reserved2\n"); + return FALSE; + } + try { stream->get64bitsLE((U8*)&stepx); } catch(...) + { + fprintf(stderr,"ERROR: reading LASvlrRasterLAZ.stepx\n"); + return FALSE; + } + try { stream->get64bitsLE((U8*)&stepx_y); } catch(...) + { + fprintf(stderr,"ERROR: reading LASvlrRasterLAZ.stepx_y\n"); + return FALSE; + } + try { stream->get64bitsLE((U8*)&stepy); } catch(...) + { + fprintf(stderr,"ERROR: reading LASvlrRasterLAZ.stepy\n"); + return FALSE; + } + try { stream->get64bitsLE((U8*)&stepy_x); } catch(...) + { + fprintf(stderr,"ERROR: reading LASvlrRasterLAZ.stepy_x\n"); + return FALSE; + } + try { stream->get64bitsLE((U8*)&llx); } catch(...) + { + fprintf(stderr,"ERROR: reading LASvlrRasterLAZ.llx\n"); + return FALSE; + } + try { stream->get64bitsLE((U8*)&lly); } catch(...) + { + fprintf(stderr,"ERROR: reading LASvlrRasterLAZ.lly\n"); + return FALSE; + } + try { stream->get64bitsLE((U8*)&sigmaxy); } catch(...) + { + fprintf(stderr,"ERROR: reading LASvlrRasterLAZ.sigmax\n"); + return FALSE; + } + return TRUE; + }; +}; + +#endif diff --git a/src/LASlib/laswaveform13reader.cpp b/src/LASlib/laswaveform13reader.cpp index 646d24e..5d4fae8 100644 --- a/src/LASlib/laswaveform13reader.cpp +++ b/src/LASlib/laswaveform13reader.cpp @@ -81,7 +81,7 @@ BOOL LASwaveform13reader::open(const char* file_name, I64 start_of_waveform_data { if (file_name == 0) { - REprintf("ERROR: file name pointer is zero\n"); + fprintf(stderr,"ERROR: file name pointer is zero\n"); return FALSE; } @@ -89,7 +89,7 @@ BOOL LASwaveform13reader::open(const char* file_name, I64 start_of_waveform_data if (wave_packet_descr == 0) { - REprintf("ERROR: wave packet descriptor pointer is zero\n"); + fprintf(stderr,"ERROR: wave packet descriptor pointer is zero\n"); return FALSE; } @@ -97,7 +97,7 @@ BOOL LASwaveform13reader::open(const char* file_name, I64 start_of_waveform_data if (wave_packet_descr[0] != 0) { - REprintf("ERROR: wave_packet_descr[0] with index 0 must be zero\n"); + fprintf(stderr,"ERROR: wave_packet_descr[0] with index 0 must be zero\n"); return FALSE; } @@ -153,7 +153,7 @@ BOOL LASwaveform13reader::open(const char* file_name, I64 start_of_waveform_data if (file == 0) { - REprintf( "ERROR: cannot open waveform file '%s'\n", file_name); + fprintf(stderr, "ERROR: cannot open waveform file '%s'\n", file_name); return FALSE; } @@ -177,7 +177,7 @@ BOOL LASwaveform13reader::open(const char* file_name, I64 start_of_waveform_data char magic[25]; try { stream->getBytes((U8*)magic, 24); } catch(...) { - REprintf("ERROR: reading waveform descriptor cross-check\n"); + fprintf(stderr,"ERROR: reading waveform descriptor cross-check\n"); return FALSE; } @@ -188,7 +188,7 @@ BOOL LASwaveform13reader::open(const char* file_name, I64 start_of_waveform_data U16 i, number; try { stream->get16bitsLE((U8*)&number); } catch(...) { - REprintf("ERROR: reading number of waveform descriptors\n"); + fprintf(stderr,"ERROR: reading number of waveform descriptors\n"); return FALSE; } for (i = 0; i < number; i++) @@ -196,21 +196,21 @@ BOOL LASwaveform13reader::open(const char* file_name, I64 start_of_waveform_data U16 index; try { stream->get16bitsLE((U8*)&index); } catch(...) { - REprintf("ERROR: reading index of waveform descriptor %d\n", i); + fprintf(stderr,"ERROR: reading index of waveform descriptor %d\n", i); return FALSE; } if ((index == 0) || (index > 255)) { - REprintf("ERROR: cross-check - index %d of waveform descriptor %d out-of-range\n", index, i); + fprintf(stderr,"ERROR: cross-check - index %d of waveform descriptor %d out-of-range\n", index, i); return FALSE; } if (wave_packet_descr[index] == 0) { - REprintf("WARNING: cross-check - waveform descriptor %d with index %d unknown\n", i, index); + fprintf(stderr,"WARNING: cross-check - waveform descriptor %d with index %d unknown\n", i, index); I32 dummy; try { stream->get32bitsLE((U8*)&dummy); } catch(...) { - REprintf("ERROR: cross-check - reading rest of waveform descriptor %d\n", i); + fprintf(stderr,"ERROR: cross-check - reading rest of waveform descriptor %d\n", i); return FALSE; } continue; @@ -218,34 +218,34 @@ BOOL LASwaveform13reader::open(const char* file_name, I64 start_of_waveform_data U8 compression; try { stream->getBytes(&compression, 1); } catch(...) { - REprintf("ERROR: reading compression of waveform descriptor %d\n", i); + fprintf(stderr,"ERROR: reading compression of waveform descriptor %d\n", i); return FALSE; } if (compression != wave_packet_descr[index]->getCompressionType()) { - REprintf("ERROR: cross-check - compression %d %d of waveform descriptor %d with index %d is different\n", compression, wave_packet_descr[index]->getCompressionType(), i, index); + fprintf(stderr,"ERROR: cross-check - compression %d %d of waveform descriptor %d with index %d is different\n", compression, wave_packet_descr[index]->getCompressionType(), i, index); return FALSE; } U8 nbits; try { stream->getBytes(&nbits, 1); } catch(...) { - REprintf("ERROR: reading nbits of waveform descriptor %d\n", i); + fprintf(stderr,"ERROR: reading nbits of waveform descriptor %d\n", i); return FALSE; } if (nbits != wave_packet_descr[index]->getBitsPerSample()) { - REprintf("ERROR: cross-check - nbits %d %d of waveform descriptor %d with index %d is different\n", nbits, wave_packet_descr[index]->getBitsPerSample(), i, index); + fprintf(stderr,"ERROR: cross-check - nbits %d %d of waveform descriptor %d with index %d is different\n", nbits, wave_packet_descr[index]->getBitsPerSample(), i, index); return FALSE; } U16 nsamples; try { stream->get16bitsLE((U8*)&nsamples); } catch(...) { - REprintf("ERROR: reading nsamples of waveform descriptor %d\n", i); + fprintf(stderr,"ERROR: reading nsamples of waveform descriptor %d\n", i); return FALSE; } if (nsamples != wave_packet_descr[index]->getNumberOfSamples()) { - REprintf("ERROR: cross-check - nsamples %d %d of waveform descriptor %d with index %d is different\n", nsamples, wave_packet_descr[index]->getNumberOfSamples(), i, index); + fprintf(stderr,"ERROR: cross-check - nsamples %d %d of waveform descriptor %d with index %d is different\n", nsamples, wave_packet_descr[index]->getNumberOfSamples(), i, index); return FALSE; } } @@ -274,14 +274,14 @@ BOOL LASwaveform13reader::read_waveform(const LASpoint* point) if (wave_packet_descr[index] == 0) { - REprintf( "ERROR: wavepacket is indexing non-existant descriptor %u\n", index); + fprintf(stderr, "ERROR: wavepacket is indexing non-existant descriptor %u\n", index); return FALSE; } nbits = wave_packet_descr[index]->getBitsPerSample(); if ((nbits != 8) && (nbits != 16)) { - REprintf( "ERROR: waveform with %d bits per samples not supported yet\n", nbits); + fprintf(stderr, "ERROR: waveform with %d bits per samples not supported yet\n", nbits); return FALSE; } @@ -293,7 +293,7 @@ BOOL LASwaveform13reader::read_waveform(const LASpoint* point) if (nsamples == 0) { - REprintf( "ERROR: waveform has no samples\n"); + fprintf(stderr, "ERROR: waveform has no samples\n"); return FALSE; } @@ -327,7 +327,7 @@ BOOL LASwaveform13reader::read_waveform(const LASpoint* point) { try { stream->getBytes(samples, size); } catch(...) { - REprintf( "ERROR: cannot read %u bytes for waveform with %u samples of %u bits\n", size, nsamples, nbits); + fprintf(stderr, "ERROR: cannot read %u bytes for waveform with %u samples of %u bits\n", size, nsamples, nbits); return FALSE; } } diff --git a/inst/include/laswaveform13reader.hpp b/src/LASlib/laswaveform13reader.hpp similarity index 98% rename from inst/include/laswaveform13reader.hpp rename to src/LASlib/laswaveform13reader.hpp index 3555c94..d3910c3 100644 --- a/inst/include/laswaveform13reader.hpp +++ b/src/LASlib/laswaveform13reader.hpp @@ -40,7 +40,7 @@ class LASwaveformDescription; class ArithmeticDecoder; class IntegerCompressor; -class LASwaveform13reader +class LASLIB_DLL LASwaveform13reader { public: U32 nbits; diff --git a/src/LASlib/laswaveform13writer.cpp b/src/LASlib/laswaveform13writer.cpp index 2b21cd9..aa694de 100644 --- a/src/LASlib/laswaveform13writer.cpp +++ b/src/LASlib/laswaveform13writer.cpp @@ -73,7 +73,7 @@ BOOL LASwaveform13writer::open(const char* file_name, const LASvlr_wave_packet_d { if (file_name == 0) { - REprintf("ERROR: file name pointer is zero\n"); + fprintf(stderr,"ERROR: file name pointer is zero\n"); return FALSE; } @@ -81,7 +81,7 @@ BOOL LASwaveform13writer::open(const char* file_name, const LASvlr_wave_packet_d if (wave_packet_descr == 0) { - REprintf("ERROR: wave packet descriptor pointer is zero\n"); + fprintf(stderr,"ERROR: wave packet descriptor pointer is zero\n"); return FALSE; } @@ -89,7 +89,7 @@ BOOL LASwaveform13writer::open(const char* file_name, const LASvlr_wave_packet_d if (wave_packet_descr[0] != 0) { - REprintf("ERROR: wave_packet_descr[0] with index 0 must be zero\n"); + fprintf(stderr,"ERROR: wave_packet_descr[0] with index 0 must be zero\n"); return FALSE; } @@ -149,7 +149,7 @@ BOOL LASwaveform13writer::open(const char* file_name, const LASvlr_wave_packet_d if (file == 0) { - REprintf( "ERROR: cannot open waveform file '%s'\n", file_name_temp); + fprintf(stderr, "ERROR: cannot open waveform file '%s'\n", file_name_temp); free(file_name_temp); return FALSE; } @@ -171,7 +171,7 @@ BOOL LASwaveform13writer::open(const char* file_name, const LASvlr_wave_packet_d U16 reserved = 0xAABB; if (!stream->put16bitsLE((U8*)&reserved)) { - REprintf("ERROR: writing EVLR reserved\n"); + fprintf(stderr,"ERROR: writing EVLR reserved\n"); return FALSE; } I8 user_id[16]; @@ -179,19 +179,19 @@ BOOL LASwaveform13writer::open(const char* file_name, const LASvlr_wave_packet_d strcpy(user_id, "LASF_Spec"); if (!stream->putBytes((U8*)user_id, 16)) { - REprintf("ERROR: writing EVLR user_id\n"); + fprintf(stderr,"ERROR: writing EVLR user_id\n"); return FALSE; } U16 record_id = 65535; if (!stream->put16bitsLE((U8*)&record_id)) { - REprintf("ERROR: writing EVLR record_id\n"); + fprintf(stderr,"ERROR: writing EVLR record_id\n"); return FALSE; } I64 record_length_after_header = 0; if (!stream->put64bitsLE((U8*)&record_length_after_header)) { - REprintf("ERROR: writing EVLR record_length_after_header\n"); + fprintf(stderr,"ERROR: writing EVLR record_length_after_header\n"); return FALSE; } I8 description[32]; @@ -199,7 +199,7 @@ BOOL LASwaveform13writer::open(const char* file_name, const LASvlr_wave_packet_d sprintf(description, "%s by LAStools (%d)", (compressed ? "compressed" : "created"), LAS_TOOLS_VERSION); if (!stream->putBytes((U8*)description, 32)) { - REprintf("ERROR: writing EVLR description\n"); + fprintf(stderr,"ERROR: writing EVLR description\n"); return FALSE; } @@ -210,13 +210,13 @@ BOOL LASwaveform13writer::open(const char* file_name, const LASvlr_wave_packet_d if (!stream->putBytes((U8*)magic, 24)) { - REprintf("ERROR: writing waveform descriptor cross-check\n"); + fprintf(stderr,"ERROR: writing waveform descriptor cross-check\n"); return FALSE; } if (!stream->put16bitsLE((U8*)&number)) { - REprintf("ERROR: writing number of waveform descriptors\n"); + fprintf(stderr,"ERROR: writing number of waveform descriptors\n"); return FALSE; } @@ -226,22 +226,22 @@ BOOL LASwaveform13writer::open(const char* file_name, const LASvlr_wave_packet_d { if (!stream->put16bitsLE((U8*)&i)) { - REprintf("ERROR: writing index of waveform descriptor %d\n", i); + fprintf(stderr,"ERROR: writing index of waveform descriptor %d\n", i); return FALSE; } if (!stream->putByte(waveforms[i]->compression)) { - REprintf("ERROR: writing compression of waveform descriptor %d\n", i); + fprintf(stderr,"ERROR: writing compression of waveform descriptor %d\n", i); return FALSE; } if (!stream->putByte(waveforms[i]->nbits)) { - REprintf("ERROR: writing nbits of waveform descriptor %d\n", i); + fprintf(stderr,"ERROR: writing nbits of waveform descriptor %d\n", i); return FALSE; } if (!stream->put16bitsLE((U8*)&(waveforms[i]->nsamples))) { - REprintf("ERROR: writing nsamples of waveform descriptor %d\n", i); + fprintf(stderr,"ERROR: writing nsamples of waveform descriptor %d\n", i); return FALSE; } } @@ -270,14 +270,14 @@ BOOL LASwaveform13writer::write_waveform(LASpoint* point, U8* samples) U32 nbits = waveforms[index]->nbits; if ((nbits != 8) && (nbits != 16)) { - REprintf( "ERROR: waveform with %d bits per samples not supported yet\n", nbits); + fprintf(stderr, "ERROR: waveform with %d bits per samples not supported yet\n", nbits); return FALSE; } U32 nsamples = waveforms[index]->nsamples; if (nsamples == 0) { - REprintf( "ERROR: waveform has no samples\n"); + fprintf(stderr, "ERROR: waveform has no samples\n"); return FALSE; } @@ -293,7 +293,7 @@ BOOL LASwaveform13writer::write_waveform(LASpoint* point, U8* samples) U32 size = ((nbits/8) * nsamples); if (!stream->putBytes(samples, size)) { - REprintf( "ERROR: cannot write %u bytes for waveform with %u samples of %u bits\n", size, nsamples, nbits); + fprintf(stderr, "ERROR: cannot write %u bytes for waveform with %u samples of %u bits\n", size, nsamples, nbits); return FALSE; } point->wavepacket.setSize(size); @@ -338,7 +338,7 @@ void LASwaveform13writer::close() stream->seek(18); if (!stream->put64bitsLE((U8*)&record_length_after_header)) { - REprintf("ERROR: updating EVLR record_length_after_header\n"); + fprintf(stderr,"ERROR: updating EVLR record_length_after_header\n"); } stream->seekEnd(); } diff --git a/inst/include/laswaveform13writer.hpp b/src/LASlib/laswaveform13writer.hpp similarity index 97% rename from inst/include/laswaveform13writer.hpp rename to src/LASlib/laswaveform13writer.hpp index 57748a0..5594f9e 100644 --- a/inst/include/laswaveform13writer.hpp +++ b/src/LASlib/laswaveform13writer.hpp @@ -40,7 +40,7 @@ class LASwaveformDescription; class ArithmeticEncoder; class IntegerCompressor; -class LASwaveform13writer +class LASLIB_DLL LASwaveform13writer { public: BOOL open(const char* file_name, const LASvlr_wave_packet_descr * const * wave_packet_descr); diff --git a/src/LASlib/laswriter.cpp b/src/LASlib/laswriter.cpp index 68df434..87485b7 100644 --- a/src/LASlib/laswriter.cpp +++ b/src/LASlib/laswriter.cpp @@ -47,6 +47,11 @@ #define DIRECTORY_SLASH '/' #endif +void LASwriter::dealloc() +{ + delete this; +} + BOOL LASwriteOpener::is_piped() const { return ((file_name == 0) && use_stdout); @@ -59,7 +64,7 @@ LASwriter* LASwriteOpener::open(const LASheader* header) LASwriterLAS* laswriterlas = new LASwriterLAS(); if (!laswriterlas->open(header, (format == LAS_TOOLS_FORMAT_LAZ ? (native ? LASZIP_COMPRESSOR_LAYERED_CHUNKED : LASZIP_COMPRESSOR_CHUNKED) : LASZIP_COMPRESSOR_NONE), 2, chunk_size)) { - REprintf("ERROR: cannot open laswriterlas to NULL\n"); + fprintf(stderr,"ERROR: cannot open laswriterlas to NULL\n"); delete laswriterlas; return 0; } @@ -72,7 +77,7 @@ LASwriter* LASwriteOpener::open(const LASheader* header) LASwriterLAS* laswriterlas = new LASwriterLAS(); if (!laswriterlas->open(file_name, header, (format == LAS_TOOLS_FORMAT_LAZ ? (native ? LASZIP_COMPRESSOR_LAYERED_CHUNKED : LASZIP_COMPRESSOR_CHUNKED) : LASZIP_COMPRESSOR_NONE), 2, chunk_size, io_obuffer_size)) { - REprintf("ERROR: cannot open laswriterlas with file name '%s'\n", file_name); + fprintf(stderr,"ERROR: cannot open laswriterlas with file name '%s'\n", file_name); delete laswriterlas; return 0; } @@ -85,7 +90,7 @@ LASwriter* LASwriteOpener::open(const LASheader* header) else if (optx) laswritertxt->set_ptx(TRUE); if (!laswritertxt->open(file_name, header, parse_string, separator)) { - REprintf("ERROR: cannot open laswritertxt with file name '%s'\n", file_name); + fprintf(stderr,"ERROR: cannot open laswritertxt with file name '%s'\n", file_name); delete laswritertxt; return 0; } @@ -97,7 +102,7 @@ LASwriter* LASwriteOpener::open(const LASheader* header) LASwriterBIN* laswriterbin = new LASwriterBIN(); if (!laswriterbin->open(file_name, header, "ts8")) { - REprintf("ERROR: cannot open laswriterbin with file name '%s'\n", file_name); + fprintf(stderr,"ERROR: cannot open laswriterbin with file name '%s'\n", file_name); delete laswriterbin; return 0; } @@ -108,7 +113,7 @@ LASwriter* LASwriteOpener::open(const LASheader* header) LASwriterQFIT* laswriterqfit = new LASwriterQFIT(); if (!laswriterqfit->open(file_name, header, 40)) { - REprintf("ERROR: cannot open laswriterqfit with file name '%s'\n", file_name); + fprintf(stderr,"ERROR: cannot open laswriterqfit with file name '%s'\n", file_name); delete laswriterqfit; return 0; } @@ -119,7 +124,7 @@ LASwriter* LASwriteOpener::open(const LASheader* header) LASwriterWRL* laswriterwrl = new LASwriterWRL(); if (!laswriterwrl->open(file_name, header, parse_string)) { - REprintf("ERROR: cannot open laswriterwrl with file name '%s'\n", file_name); + fprintf(stderr,"ERROR: cannot open laswriterwrl with file name '%s'\n", file_name); delete laswriterwrl; return 0; } @@ -127,18 +132,18 @@ LASwriter* LASwriteOpener::open(const LASheader* header) } else { - REprintf("ERROR: unknown format %d\n", format); + fprintf(stderr,"ERROR: unknown format %d\n", format); return 0; } } - /*else if (use_stdout) + else if (use_stdout) { if (format <= LAS_TOOLS_FORMAT_LAZ) { LASwriterLAS* laswriterlas = new LASwriterLAS(); if (!laswriterlas->open(stdout, header, (format == LAS_TOOLS_FORMAT_LAZ ? (native ? LASZIP_COMPRESSOR_LAYERED_CHUNKED : LASZIP_COMPRESSOR_CHUNKED) : LASZIP_COMPRESSOR_NONE), 2, chunk_size)) { - REprintf("ERROR: cannot open laswriterlas to stdout\n"); + fprintf(stderr,"ERROR: cannot open laswriterlas to stdout\n"); delete laswriterlas; return 0; } @@ -151,7 +156,7 @@ LASwriter* LASwriteOpener::open(const LASheader* header) else if (optx) laswritertxt->set_ptx(TRUE); if (!laswritertxt->open(stdout, header, parse_string, separator)) { - REprintf("ERROR: cannot open laswritertxt to stdout\n"); + fprintf(stderr,"ERROR: cannot open laswritertxt to stdout\n"); delete laswritertxt; return 0; } @@ -163,7 +168,7 @@ LASwriter* LASwriteOpener::open(const LASheader* header) LASwriterBIN* laswriterbin = new LASwriterBIN(); if (!laswriterbin->open(stdout, header, "ts8")) { - REprintf("ERROR: cannot open laswriterbin to stdout\n"); + fprintf(stderr,"ERROR: cannot open laswriterbin to stdout\n"); delete laswriterbin; return 0; } @@ -174,7 +179,7 @@ LASwriter* LASwriteOpener::open(const LASheader* header) LASwriterQFIT* laswriterqfit = new LASwriterQFIT(); if (!laswriterqfit->open(stdout, header, 40)) { - REprintf("ERROR: cannot open laswriterbin to stdout\n"); + fprintf(stderr,"ERROR: cannot open laswriterbin to stdout\n"); delete laswriterqfit; return 0; } @@ -185,7 +190,7 @@ LASwriter* LASwriteOpener::open(const LASheader* header) LASwriterWRL* laswriterwrl = new LASwriterWRL(); if (!laswriterwrl->open(stdout, header, parse_string)) { - REprintf("ERROR: cannot open laswriterwrl with file name '%s'\n", file_name); + fprintf(stderr,"ERROR: cannot open laswriterwrl with file name '%s'\n", file_name); delete laswriterwrl; return 0; } @@ -193,13 +198,13 @@ LASwriter* LASwriteOpener::open(const LASheader* header) } else { - REprintf("ERROR: unknown format %d\n", format); + fprintf(stderr,"ERROR: unknown format %d\n", format); return 0; } - }*/ + } else { - REprintf("ERROR: no laswriter output specified\n"); + fprintf(stderr,"ERROR: no laswriter output specified\n"); return 0; } } @@ -221,18 +226,18 @@ LASwaveform13writer* LASwriteOpener::open_waveform13(const LASheader* lasheader) void LASwriteOpener::usage() const { - REprintf("Supported LAS Outputs\n"); - REprintf(" -o lidar.las\n"); - REprintf(" -o lidar.laz\n"); - REprintf(" -o xyzta.txt -oparse xyzta (on-the-fly to ASCII)\n"); - REprintf(" -o terrasolid.bin\n"); - REprintf(" -o nasa.qi\n"); - REprintf(" -odir C:%cdata%cground (specify output directory)\n", DIRECTORY_SLASH, DIRECTORY_SLASH); - REprintf(" -odix _classified (specify file name appendix)\n"); - REprintf(" -ocut 2 (cut the last two characters from name)\n"); - REprintf(" -olas -olaz -otxt -obin -oqfit (specify format)\n"); - REprintf(" -stdout (pipe to stdout)\n"); - REprintf(" -nil (pipe to NULL)\n"); + fprintf(stderr,"Supported LAS Outputs\n"); + fprintf(stderr," -o lidar.las\n"); + fprintf(stderr," -o lidar.laz\n"); + fprintf(stderr," -o xyzta.txt -oparse xyzta (on-the-fly to ASCII)\n"); + fprintf(stderr," -o terrasolid.bin\n"); + fprintf(stderr," -o nasa.qi\n"); + fprintf(stderr," -odir C:%cdata%cground (specify output directory)\n", DIRECTORY_SLASH, DIRECTORY_SLASH); + fprintf(stderr," -odix _classified (specify file name appendix)\n"); + fprintf(stderr," -ocut 2 (cut the last two characters from name)\n"); + fprintf(stderr," -olas -olaz -otxt -obin -oqfit (specify format)\n"); + fprintf(stderr," -stdout (pipe to stdout)\n"); + fprintf(stderr," -nil (pipe to NULL)\n"); } BOOL LASwriteOpener::parse(int argc, char* argv[]) @@ -253,7 +258,7 @@ BOOL LASwriteOpener::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: file_name\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: file_name\n", argv[i]); return FALSE; } set_file_name(argv[i+1]); @@ -263,12 +268,12 @@ BOOL LASwriteOpener::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: directory\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: directory\n", argv[i]); return FALSE; } if (!set_directory(argv[i+1])) { - REprintf("ERROR: '%s' is not a valid directory\n", argv[i+1]); + fprintf(stderr,"ERROR: '%s' is not a valid directory\n", argv[i+1]); return FALSE; } *argv[i]='\0'; *argv[i+1]='\0'; i+=1; @@ -277,7 +282,7 @@ BOOL LASwriteOpener::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: appendix\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: appendix\n", argv[i]); return FALSE; } set_appendix(argv[i+1]); @@ -287,7 +292,7 @@ BOOL LASwriteOpener::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: number of characters to cut\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: number of characters to cut\n", argv[i]); return FALSE; } set_cut(atoi(argv[i+1])); @@ -355,7 +360,7 @@ BOOL LASwriteOpener::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: number_points\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: number_points\n", argv[i]); return FALSE; } set_chunk_size(atoi(argv[i+1])); @@ -365,7 +370,7 @@ BOOL LASwriteOpener::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: string\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: string\n", argv[i]); return FALSE; } set_parse_string(argv[i+1]); @@ -375,7 +380,7 @@ BOOL LASwriteOpener::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: separator\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: separator\n", argv[i]); return FALSE; } set_separator(argv[i+1]); @@ -385,7 +390,7 @@ BOOL LASwriteOpener::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: scale\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: scale\n", argv[i]); return FALSE; } set_scale_rgb((F32)atof(argv[i+1])); @@ -405,7 +410,7 @@ BOOL LASwriteOpener::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - REprintf("ERROR: '%s' needs 1 argument: size\n", argv[i]); + fprintf(stderr,"ERROR: '%s' needs 1 argument: size\n", argv[i]); return FALSE; } set_io_obuffer_size((I32)atoi(argv[i+1])); @@ -427,10 +432,10 @@ BOOL LASwriteOpener::set_directory(const CHAR* directory) { if (strstr(directory, ";") || strstr(directory, "\"")) { - REprintf("WARNING: specified '-odir' seems to contain a substring '\\\"' such\n"); - REprintf(" as -odir \"D:\\\" or -odir \"..\\tiles\\\". this command will\n"); - REprintf(" probably fail. please use -odir \"D:\" or -odir \"..\\tiles\"\n"); - REprintf(" instead.\n"); + fprintf(stderr,"WARNING: specified '-odir' seems to contain a substring '\\\"' such\n"); + fprintf(stderr," as -odir \"D:\\\" or -odir \"..\\tiles\\\". this command will\n"); + fprintf(stderr," probably fail. please use -odir \"D:\" or -odir \"..\\tiles\"\n"); + fprintf(stderr," instead.\n"); } this->directory = LASCopyString(directory); I32 len = (I32)strlen(this->directory); @@ -814,7 +819,7 @@ void LASwriteOpener::make_file_name(const CHAR* file_name, I32 file_number) } if (file_num) { - REprintf("WARNING: file name number %d too big to store in '%s'. use more digits.\n", file_number, this->file_name); + fprintf(stderr,"WARNING: file name number %d too big to store in '%s'. use more digits.\n", file_number, this->file_name); } } else @@ -914,9 +919,9 @@ void LASwriteOpener::make_file_name(const CHAR* file_name, I32 file_number) { this->file_name = LASCopyString("temp.txt"); } - REprintf("WARNING: generated output name '%s'\n", file_name); - REprintf(" identical to input name. changed to '%s'.\n", this->file_name); - REprintf(" you can override this safety measure with '-oforce'.\n"); + fprintf(stderr,"WARNING: generated output name '%s'\n", file_name); + fprintf(stderr," identical to input name. changed to '%s'.\n", this->file_name); + fprintf(stderr," you can override this safety measure with '-oforce'.\n"); } } } @@ -1128,11 +1133,11 @@ void LASwriteOpener::cut_characters(U32 cut) if ((len == 0) || (file_name[len] == '\\') || (file_name[len] == '/') || (file_name[len] == ':')) { len = (I32)strlen(file_name); - memcpy(new_file_name, file_name, (len-cut)*sizeof(CHAR)); + memcpy(new_file_name, file_name, len-cut); } else { - memcpy(new_file_name, file_name, (len-cut)*sizeof(CHAR)); + strncpy(new_file_name, file_name, len-cut); sprintf(&(new_file_name[len-cut]), "%s", &(file_name[len])); } free(file_name); diff --git a/inst/include/laswriter.hpp b/src/LASlib/laswriter.hpp similarity index 99% rename from inst/include/laswriter.hpp rename to src/LASlib/laswriter.hpp index 9da0022..5e7a2de 100644 --- a/inst/include/laswriter.hpp +++ b/src/LASlib/laswriter.hpp @@ -63,6 +63,8 @@ class LASLIB_DLL LASwriter virtual BOOL update_header(const LASheader* header, BOOL use_inventory=FALSE, BOOL update_extra_bytes=FALSE) = 0; virtual I64 close(BOOL update_npoints=TRUE) = 0; + void dealloc(); + LASwriter() { npoints = 0; p_count = 0; }; virtual ~LASwriter() {}; }; diff --git a/src/LASlib/laswriter_bin.cpp b/src/LASlib/laswriter_bin.cpp index 7ddc7df..c7bd84f 100644 --- a/src/LASlib/laswriter_bin.cpp +++ b/src/LASlib/laswriter_bin.cpp @@ -2,13 +2,13 @@ =============================================================================== FILE: laswriter_bin.cpp - + CONTENTS: - + see corresponding header file - + PROGRAMMERS: - + martin.isenburg@rapidlasso.com - http://rapidlasso.com COPYRIGHT: @@ -21,11 +21,11 @@ This software is distributed WITHOUT ANY WARRANTY and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - + CHANGE HISTORY: - + see corresponding header file - + =============================================================================== */ #include "laswriter_bin.hpp" @@ -89,7 +89,7 @@ BOOL LASwriterBIN::open(const char* file_name, const LASheader* header, const ch { if (file_name == 0) { - REprintf("ERROR: file name pointer is zero\n"); + fprintf(stderr,"ERROR: file name pointer is zero\n"); return FALSE; } @@ -97,13 +97,13 @@ BOOL LASwriterBIN::open(const char* file_name, const LASheader* header, const ch if (file == 0) { - REprintf( "ERROR: cannot open file '%s'\n", file_name); + fprintf(stderr, "ERROR: cannot open file '%s'\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, io_buffer_size) != 0) { - REprintf( "WARNING: setvbuf() failed with buffer size %u\n", io_buffer_size); + fprintf(stderr, "WARNING: setvbuf() failed with buffer size %u\n", io_buffer_size); } ByteStreamOut* out; @@ -119,7 +119,7 @@ BOOL LASwriterBIN::open(FILE* file, const LASheader* header, const char* version { if (file == 0) { - REprintf("ERROR: file pointer is zero\n"); + fprintf(stderr,"ERROR: file pointer is zero\n"); return FALSE; } @@ -128,7 +128,7 @@ BOOL LASwriterBIN::open(FILE* file, const LASheader* header, const char* version { if(_setmode( _fileno( stdout ), _O_BINARY ) == -1 ) { - REprintf( "ERROR: cannot set stdout to binary (untranslated) mode\n"); + fprintf(stderr, "ERROR: cannot set stdout to binary (untranslated) mode\n"); } } #endif @@ -146,14 +146,14 @@ BOOL LASwriterBIN::open(ByteStreamOut* stream, const LASheader* header, const ch { if (stream == 0) { - REprintf("ERROR: ByteStreamOut pointer is zero\n"); + fprintf(stderr,"ERROR: ByteStreamOut pointer is zero\n"); return FALSE; } this->stream = stream; if (header == 0) { - REprintf("ERROR: LASheader pointer is zero\n"); + fprintf(stderr,"ERROR: LASheader pointer is zero\n"); return FALSE; } @@ -170,11 +170,11 @@ BOOL LASwriterBIN::open(ByteStreamOut* stream, const LASheader* header, const ch tsheader.size = sizeof(TSheader); tsheader.version = this->version; tsheader.recog_val = 970401; - memcpy(tsheader.recog_str, "CXYZ", 4); + strncpy(tsheader.recog_str, "CXYZ", 4); tsheader.npoints = (header->number_of_point_records ? header->number_of_point_records : (U32)header->extended_number_of_point_records); double scale = header->x_scale_factor; - if (header->y_scale_factor < scale) scale = header->y_scale_factor; - if (header->z_scale_factor < scale) scale = header->z_scale_factor; + if (header->y_scale_factor < scale) scale = header->y_scale_factor; + if (header->z_scale_factor < scale) scale = header->z_scale_factor; units = tsheader.units = (I32)(1.0 / scale); origin_x = tsheader.origin_x = -header->x_offset/scale; origin_y = tsheader.origin_y = -header->y_offset/scale; @@ -250,7 +250,7 @@ BOOL LASwriterBIN::update_header(const LASheader* header, BOOL use_inventory, BO I64 LASwriterBIN::close(BOOL update_npoints) { I64 bytes = 0; - + if (stream) { if (update_npoints && p_count != npoints) @@ -258,9 +258,9 @@ I64 LASwriterBIN::close(BOOL update_npoints) if (!stream->isSeekable()) { #ifdef _WIN32 - REprintf( "ERROR: stream not seekable. cannot update header from %I64d to %I64d points.\n", npoints, p_count); + fprintf(stderr, "ERROR: stream not seekable. cannot update header from %I64d to %I64d points.\n", npoints, p_count); #else - REprintf( "ERROR: stream not seekable. cannot update header from %lld to %lld points.\n", npoints, p_count); + fprintf(stderr, "ERROR: stream not seekable. cannot update header from %lld to %lld points.\n", npoints, p_count); #endif } else diff --git a/inst/include/laswriter_bin.hpp b/src/LASlib/laswriter_bin.hpp similarity index 100% rename from inst/include/laswriter_bin.hpp rename to src/LASlib/laswriter_bin.hpp diff --git a/src/LASlib/laswriter_las.cpp b/src/LASlib/laswriter_las.cpp index ec75a21..83d7572 100644 --- a/src/LASlib/laswriter_las.cpp +++ b/src/LASlib/laswriter_las.cpp @@ -60,20 +60,35 @@ BOOL LASwriterLAS::open(const char* file_name, const LASheader* header, U32 comp { if (file_name == 0) { - REprintf("ERROR: file name pointer is zero\n"); + fprintf(stderr,"ERROR: file name pointer is zero\n"); return FALSE; } +#ifdef _MSC_VER file = fopen(file_name, "wb"); if (file == 0) { - REprintf( "ERROR: cannot open file '%s'\n", file_name); + wchar_t* utf16_file_name = UTF8toUTF16(file_name); + file = _wfopen(utf16_file_name, L"wb"); + if (file == 0) + { + fprintf(stderr, "ERROR: cannot open file '%ws' for write\n", utf16_file_name); + } + delete [] utf16_file_name; + } +#else + file = fopen(file_name, "wb"); +#endif + + if (file == 0) + { + fprintf(stderr, "ERROR: cannot open file '%s' for write\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, io_buffer_size) != 0) { - REprintf( "WARNING: setvbuf() failed with buffer size %d\n", io_buffer_size); + fprintf(stderr, "WARNING: setvbuf() failed with buffer size %d\n", io_buffer_size); } ByteStreamOut* out; @@ -89,7 +104,7 @@ BOOL LASwriterLAS::open(FILE* file, const LASheader* header, U32 compressor, I32 { if (file == 0) { - REprintf("ERROR: file pointer is zero\n"); + fprintf(stderr,"ERROR: file pointer is zero\n"); return FALSE; } @@ -98,7 +113,7 @@ BOOL LASwriterLAS::open(FILE* file, const LASheader* header, U32 compressor, I32 { if(_setmode( _fileno( stdout ), _O_BINARY ) == -1 ) { - REprintf( "ERROR: cannot set stdout to binary (untranslated) mode\n"); + fprintf(stderr, "ERROR: cannot set stdout to binary (untranslated) mode\n"); } } #endif @@ -129,14 +144,14 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp if (stream == 0) { - REprintf("ERROR: ByteStreamOut pointer is zero\n"); + fprintf(stderr,"ERROR: ByteStreamOut pointer is zero\n"); return FALSE; } this->stream = stream; if (header == 0) { - REprintf("ERROR: LASheader pointer is zero\n"); + fprintf(stderr,"ERROR: LASheader pointer is zero\n"); return FALSE; } @@ -175,7 +190,7 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp if (compressor && (point_data_format > 5) && (compressor != LASZIP_COMPRESSOR_LAYERED_CHUNKED)) { - REprintf("ERROR: point type %d requires using \"native LAS 1.4 extension\" of LASzip\n", point_data_format); + fprintf(stderr,"ERROR: point type %d requires using \"native LAS 1.4 extension\" of LASzip\n", point_data_format); return FALSE; } @@ -189,7 +204,7 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp laszip->setup(point.num_items, point.items, compressor); if (chunk_size > -1) laszip->set_chunk_size((U32)chunk_size); if (compressor == LASZIP_COMPRESSOR_NONE) laszip->request_version(0); - else if (chunk_size == 0 && (point_data_format <= 5)) { REprintf("ERROR: adaptive chunking is depricated for point type %d.\n only available for new LAS 1.4 point types 6 or higher.\n", point_data_format); return FALSE; } + else if (chunk_size == 0 && (point_data_format <= 5)) { fprintf(stderr,"ERROR: adaptive chunking is depricated for point type %d.\n only available for new LAS 1.4 point types 6 or higher.\n", point_data_format); return FALSE; } else if (requested_version) laszip->request_version(requested_version); else laszip->request_version(2); laszip_vlr_data_size = 34 + 6*laszip->num_items; @@ -202,7 +217,7 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp { if (!writer->setup(laszip->num_items, laszip->items, laszip)) { - REprintf("ERROR: point type %d of size %d not supported (with LASzip)\n", header->point_data_format, header->point_data_record_length); + fprintf(stderr,"ERROR: point type %d of size %d not supported (with LASzip)\n", header->point_data_format, header->point_data_record_length); return FALSE; } } @@ -210,7 +225,7 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp { if (!writer->setup(point.num_items, point.items)) { - REprintf("ERROR: point type %d of size %d not supported\n", header->point_data_format, header->point_data_record_length); + fprintf(stderr,"ERROR: point type %d of size %d not supported\n", header->point_data_format, header->point_data_record_length); return FALSE; } } @@ -223,86 +238,86 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp if (!stream->putBytes((U8*)&(header->file_signature), 4)) { - REprintf("ERROR: writing header->file_signature\n"); + fprintf(stderr,"ERROR: writing header->file_signature\n"); return FALSE; } if (!stream->put16bitsLE((U8*)&(header->file_source_ID))) { - REprintf("ERROR: writing header->file_source_ID\n"); + fprintf(stderr,"ERROR: writing header->file_source_ID\n"); return FALSE; } if (!stream->put16bitsLE((U8*)&(header->global_encoding))) { - REprintf("ERROR: writing header->global_encoding\n"); + fprintf(stderr,"ERROR: writing header->global_encoding\n"); return FALSE; } if (!stream->put32bitsLE((U8*)&(header->project_ID_GUID_data_1))) { - REprintf("ERROR: writing header->project_ID_GUID_data_1\n"); + fprintf(stderr,"ERROR: writing header->project_ID_GUID_data_1\n"); return FALSE; } if (!stream->put16bitsLE((U8*)&(header->project_ID_GUID_data_2))) { - REprintf("ERROR: writing header->project_ID_GUID_data_2\n"); + fprintf(stderr,"ERROR: writing header->project_ID_GUID_data_2\n"); return FALSE; } if (!stream->put16bitsLE((U8*)&(header->project_ID_GUID_data_3))) { - REprintf("ERROR: writing header->project_ID_GUID_data_3\n"); + fprintf(stderr,"ERROR: writing header->project_ID_GUID_data_3\n"); return FALSE; } if (!stream->putBytes((U8*)header->project_ID_GUID_data_4, 8)) { - REprintf("ERROR: writing header->project_ID_GUID_data_4\n"); + fprintf(stderr,"ERROR: writing header->project_ID_GUID_data_4\n"); return FALSE; } // check version major U8 version_major = header->version_major; if (header->version_major != 1) { - REprintf("WARNING: header->version_major is %d. writing 1 instead.\n", header->version_major); + fprintf(stderr,"WARNING: header->version_major is %d. writing 1 instead.\n", header->version_major); version_major = 1; } if (!stream->putByte(version_major)) { - REprintf("ERROR: writing header->version_major\n"); + fprintf(stderr,"ERROR: writing header->version_major\n"); return FALSE; } // check version minor U8 version_minor = header->version_minor; if (version_minor > 4) { - REprintf("WARNING: header->version_minor is %d. writing 4 instead.\n", version_minor); + fprintf(stderr,"WARNING: header->version_minor is %d. writing 4 instead.\n", version_minor); version_minor = 4; } if (!stream->putByte(version_minor)) { - REprintf("ERROR: writing header->version_minor\n"); + fprintf(stderr,"ERROR: writing header->version_minor\n"); return FALSE; } if (!stream->putBytes((U8*)header->system_identifier, 32)) { - REprintf("ERROR: writing header->system_identifier\n"); + fprintf(stderr,"ERROR: writing header->system_identifier\n"); return FALSE; } if (!stream->putBytes((U8*)header->generating_software, 32)) { - REprintf("ERROR: writing header->generating_software\n"); + fprintf(stderr,"ERROR: writing header->generating_software\n"); return FALSE; } if (!stream->put16bitsLE((U8*)&(header->file_creation_day))) { - REprintf("ERROR: writing header->file_creation_day\n"); + fprintf(stderr,"ERROR: writing header->file_creation_day\n"); return FALSE; } if (!stream->put16bitsLE((U8*)&(header->file_creation_year))) { - REprintf("ERROR: writing header->file_creation_year\n"); + fprintf(stderr,"ERROR: writing header->file_creation_year\n"); return FALSE; } if (!stream->put16bitsLE((U8*)&(header->header_size))) { - REprintf("ERROR: writing header->header_size\n"); + fprintf(stderr,"ERROR: writing header->header_size\n"); return FALSE; } U32 offset_to_point_data = header->offset_to_point_data; @@ -311,7 +326,7 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp if (header->vlr_lasoriginal) offset_to_point_data += (54 + 176); if (!stream->put32bitsLE((U8*)&offset_to_point_data)) { - REprintf("ERROR: writing header->offset_to_point_data\n"); + fprintf(stderr,"ERROR: writing header->offset_to_point_data\n"); return FALSE; } U32 number_of_variable_length_records = header->number_of_variable_length_records; @@ -320,91 +335,91 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp if (header->vlr_lasoriginal) number_of_variable_length_records++; if (!stream->put32bitsLE((U8*)&(number_of_variable_length_records))) { - REprintf("ERROR: writing header->number_of_variable_length_records\n"); + fprintf(stderr,"ERROR: writing header->number_of_variable_length_records\n"); return FALSE; } if (compressor) point_data_format |= 128; if (!stream->putByte(point_data_format)) { - REprintf("ERROR: writing header->point_data_format\n"); + fprintf(stderr,"ERROR: writing header->point_data_format\n"); return FALSE; } if (!stream->put16bitsLE((U8*)&(header->point_data_record_length))) { - REprintf("ERROR: writing header->point_data_record_length\n"); + fprintf(stderr,"ERROR: writing header->point_data_record_length\n"); return FALSE; } if (!stream->put32bitsLE((U8*)&(header->number_of_point_records))) { - REprintf("ERROR: writing header->number_of_point_records\n"); + fprintf(stderr,"ERROR: writing header->number_of_point_records\n"); return FALSE; } for (i = 0; i < 5; i++) { if (!stream->put32bitsLE((U8*)&(header->number_of_points_by_return[i]))) { - REprintf("ERROR: writing header->number_of_points_by_return[%d]\n", i); + fprintf(stderr,"ERROR: writing header->number_of_points_by_return[%d]\n", i); return FALSE; } } if (!stream->put64bitsLE((U8*)&(header->x_scale_factor))) { - REprintf("ERROR: writing header->x_scale_factor\n"); + fprintf(stderr,"ERROR: writing header->x_scale_factor\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->y_scale_factor))) { - REprintf("ERROR: writing header->y_scale_factor\n"); + fprintf(stderr,"ERROR: writing header->y_scale_factor\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->z_scale_factor))) { - REprintf("ERROR: writing header->z_scale_factor\n"); + fprintf(stderr,"ERROR: writing header->z_scale_factor\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->x_offset))) { - REprintf("ERROR: writing header->x_offset\n"); + fprintf(stderr,"ERROR: writing header->x_offset\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->y_offset))) { - REprintf("ERROR: writing header->y_offset\n"); + fprintf(stderr,"ERROR: writing header->y_offset\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->z_offset))) { - REprintf("ERROR: writing header->z_offset\n"); + fprintf(stderr,"ERROR: writing header->z_offset\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->max_x))) { - REprintf("ERROR: writing header->max_x\n"); + fprintf(stderr,"ERROR: writing header->max_x\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->min_x))) { - REprintf("ERROR: writing header->min_x\n"); + fprintf(stderr,"ERROR: writing header->min_x\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->max_y))) { - REprintf("ERROR: writing header->max_y\n"); + fprintf(stderr,"ERROR: writing header->max_y\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->min_y))) { - REprintf("ERROR: writing header->min_y\n"); + fprintf(stderr,"ERROR: writing header->min_y\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->max_z))) { - REprintf("ERROR: writing header->max_z\n"); + fprintf(stderr,"ERROR: writing header->max_z\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->min_z))) { - REprintf("ERROR: writing header->min_z\n"); + fprintf(stderr,"ERROR: writing header->min_z\n"); return FALSE; } @@ -415,15 +430,15 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp if (start_of_waveform_data_packet_record != 0) { #ifdef _WIN32 - REprintf("WARNING: header->start_of_waveform_data_packet_record is %I64d. writing 0 instead.\n", start_of_waveform_data_packet_record); + fprintf(stderr,"WARNING: header->start_of_waveform_data_packet_record is %I64d. writing 0 instead.\n", start_of_waveform_data_packet_record); #else - REprintf("WARNING: header->start_of_waveform_data_packet_record is %lld. writing 0 instead.\n", start_of_waveform_data_packet_record); + fprintf(stderr,"WARNING: header->start_of_waveform_data_packet_record is %lld. writing 0 instead.\n", start_of_waveform_data_packet_record); #endif start_of_waveform_data_packet_record = 0; } if (!stream->put64bitsLE((U8*)&start_of_waveform_data_packet_record)) { - REprintf("ERROR: writing start_of_waveform_data_packet_record\n"); + fprintf(stderr,"ERROR: writing start_of_waveform_data_packet_record\n"); return FALSE; } } @@ -443,13 +458,13 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp start_of_first_extended_variable_length_record = header->start_of_first_extended_variable_length_record; if (!stream->put64bitsLE((U8*)&(start_of_first_extended_variable_length_record))) { - REprintf("ERROR: writing header->start_of_first_extended_variable_length_record\n"); + fprintf(stderr,"ERROR: writing header->start_of_first_extended_variable_length_record\n"); return FALSE; } number_of_extended_variable_length_records = header->number_of_extended_variable_length_records; if (!stream->put32bitsLE((U8*)&(number_of_extended_variable_length_records))) { - REprintf("ERROR: writing header->number_of_extended_variable_length_records\n"); + fprintf(stderr,"ERROR: writing header->number_of_extended_variable_length_records\n"); return FALSE; } evlrs = header->evlrs; @@ -460,7 +475,7 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp extended_number_of_point_records = header->extended_number_of_point_records; if (!stream->put64bitsLE((U8*)&extended_number_of_point_records)) { - REprintf("ERROR: writing header->extended_number_of_point_records\n"); + fprintf(stderr,"ERROR: writing header->extended_number_of_point_records\n"); return FALSE; } U64 extended_number_of_points_by_return; @@ -472,7 +487,7 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp extended_number_of_points_by_return = header->extended_number_of_points_by_return[i]; if (!stream->put64bitsLE((U8*)&extended_number_of_points_by_return)) { - REprintf("ERROR: writing header->extended_number_of_points_by_return[%d]\n", i); + fprintf(stderr,"ERROR: writing header->extended_number_of_points_by_return[%d]\n", i); return FALSE; } } @@ -491,13 +506,13 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp { if (!stream->putBytes((U8*)header->user_data_in_header, header->user_data_in_header_size)) { - REprintf("ERROR: writing %d bytes of data from header->user_data_in_header\n", header->user_data_in_header_size); + fprintf(stderr,"ERROR: writing %d bytes of data from header->user_data_in_header\n", header->user_data_in_header_size); return FALSE; } } else { - REprintf("ERROR: there should be %d bytes of data in header->user_data_in_header\n", header->user_data_in_header_size); + fprintf(stderr,"ERROR: there should be %d bytes of data in header->user_data_in_header\n", header->user_data_in_header_size); return FALSE; } } @@ -510,34 +525,34 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp if (header->vlrs[i].reserved != 0xAABB) { -// REprintf("WARNING: wrong header->vlrs[%d].reserved: %d != 0xAABB\n", i, header->vlrs[i].reserved); +// fprintf(stderr,"WARNING: wrong header->vlrs[%d].reserved: %d != 0xAABB\n", i, header->vlrs[i].reserved); } // write variable length records variable after variable (to avoid alignment issues) if (!stream->put16bitsLE((U8*)&(header->vlrs[i].reserved))) { - REprintf("ERROR: writing header->vlrs[%d].reserved\n", i); + fprintf(stderr,"ERROR: writing header->vlrs[%d].reserved\n", i); return FALSE; } if (!stream->putBytes((U8*)header->vlrs[i].user_id, 16)) { - REprintf("ERROR: writing header->vlrs[%d].user_id\n", i); + fprintf(stderr,"ERROR: writing header->vlrs[%d].user_id\n", i); return FALSE; } if (!stream->put16bitsLE((U8*)&(header->vlrs[i].record_id))) { - REprintf("ERROR: writing header->vlrs[%d].record_id\n", i); + fprintf(stderr,"ERROR: writing header->vlrs[%d].record_id\n", i); return FALSE; } if (!stream->put16bitsLE((U8*)&(header->vlrs[i].record_length_after_header))) { - REprintf("ERROR: writing header->vlrs[%d].record_length_after_header\n", i); + fprintf(stderr,"ERROR: writing header->vlrs[%d].record_length_after_header\n", i); return FALSE; } if (!stream->putBytes((U8*)header->vlrs[i].description, 32)) { - REprintf("ERROR: writing header->vlrs[%d].description\n", i); + fprintf(stderr,"ERROR: writing header->vlrs[%d].description\n", i); return FALSE; } @@ -549,13 +564,13 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp { if (!stream->putBytes((U8*)header->vlrs[i].data, header->vlrs[i].record_length_after_header)) { - REprintf("ERROR: writing %d bytes of data from header->vlrs[%d].data\n", header->vlrs[i].record_length_after_header, i); + fprintf(stderr,"ERROR: writing %d bytes of data from header->vlrs[%d].data\n", header->vlrs[i].record_length_after_header, i); return FALSE; } } else { - REprintf("ERROR: there should be %d bytes of data in header->vlrs[%d].data\n", header->vlrs[i].record_length_after_header, i); + fprintf(stderr,"ERROR: there should be %d bytes of data in header->vlrs[%d].data\n", header->vlrs[i].record_length_after_header, i); return FALSE; } } @@ -570,25 +585,25 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp U16 reserved = 0xAABB; if (!stream->put16bitsLE((U8*)&(reserved))) { - REprintf("ERROR: writing reserved %d\n", (I32)reserved); + fprintf(stderr,"ERROR: writing reserved %d\n", (I32)reserved); return FALSE; } U8 user_id[16] = "laszip encoded\0"; if (!stream->putBytes((U8*)user_id, 16)) { - REprintf("ERROR: writing user_id %s\n", user_id); + fprintf(stderr,"ERROR: writing user_id %s\n", user_id); return FALSE; } U16 record_id = 22204; if (!stream->put16bitsLE((U8*)&(record_id))) { - REprintf("ERROR: writing record_id %d\n", (I32)record_id); + fprintf(stderr,"ERROR: writing record_id %d\n", (I32)record_id); return FALSE; } U16 record_length_after_header = laszip_vlr_data_size; if (!stream->put16bitsLE((U8*)&(record_length_after_header))) { - REprintf("ERROR: writing record_length_after_header %d\n", (I32)record_length_after_header); + fprintf(stderr,"ERROR: writing record_length_after_header %d\n", (I32)record_length_after_header); return FALSE; } char description[32]; @@ -596,7 +611,7 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp sprintf(description, "by laszip of LAStools (%d)", LAS_TOOLS_VERSION); if (!stream->putBytes((U8*)description, 32)) { - REprintf("ERROR: writing description %s\n", description); + fprintf(stderr,"ERROR: writing description %s\n", description); return FALSE; } // write the data following the header of the variable length record @@ -617,69 +632,69 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp if (!stream->put16bitsLE((U8*)&(laszip->compressor))) { - REprintf("ERROR: writing compressor %d\n", (I32)compressor); + fprintf(stderr,"ERROR: writing compressor %d\n", (I32)compressor); return FALSE; } if (!stream->put16bitsLE((U8*)&(laszip->coder))) { - REprintf("ERROR: writing coder %d\n", (I32)laszip->coder); + fprintf(stderr,"ERROR: writing coder %d\n", (I32)laszip->coder); return FALSE; } if (!stream->putByte(laszip->version_major)) { - REprintf("ERROR: writing version_major %d\n", laszip->version_major); + fprintf(stderr,"ERROR: writing version_major %d\n", laszip->version_major); return FALSE; } if (!stream->putByte(laszip->version_minor)) { - REprintf("ERROR: writing version_minor %d\n", laszip->version_minor); + fprintf(stderr,"ERROR: writing version_minor %d\n", laszip->version_minor); return FALSE; } if (!stream->put16bitsLE((U8*)&(laszip->version_revision))) { - REprintf("ERROR: writing version_revision %d\n", laszip->version_revision); + fprintf(stderr,"ERROR: writing version_revision %d\n", laszip->version_revision); return FALSE; } if (!stream->put32bitsLE((U8*)&(laszip->options))) { - REprintf("ERROR: writing options %d\n", (I32)laszip->options); + fprintf(stderr,"ERROR: writing options %d\n", (I32)laszip->options); return FALSE; } if (!stream->put32bitsLE((U8*)&(laszip->chunk_size))) { - REprintf("ERROR: writing chunk_size %d\n", laszip->chunk_size); + fprintf(stderr,"ERROR: writing chunk_size %d\n", laszip->chunk_size); return FALSE; } if (!stream->put64bitsLE((U8*)&(laszip->number_of_special_evlrs))) { - REprintf("ERROR: writing number_of_special_evlrs %d\n", (I32)laszip->number_of_special_evlrs); + fprintf(stderr,"ERROR: writing number_of_special_evlrs %d\n", (I32)laszip->number_of_special_evlrs); return FALSE; } if (!stream->put64bitsLE((U8*)&(laszip->offset_to_special_evlrs))) { - REprintf("ERROR: writing offset_to_special_evlrs %d\n", (I32)laszip->offset_to_special_evlrs); + fprintf(stderr,"ERROR: writing offset_to_special_evlrs %d\n", (I32)laszip->offset_to_special_evlrs); return FALSE; } if (!stream->put16bitsLE((U8*)&(laszip->num_items))) { - REprintf("ERROR: writing num_items %d\n", laszip->num_items); + fprintf(stderr,"ERROR: writing num_items %d\n", laszip->num_items); return FALSE; } for (i = 0; i < laszip->num_items; i++) { if (!stream->put16bitsLE((U8*)&(laszip->items[i].type))) { - REprintf("ERROR: writing type %d of item %d\n", laszip->items[i].type, i); + fprintf(stderr,"ERROR: writing type %d of item %d\n", laszip->items[i].type, i); return FALSE; } if (!stream->put16bitsLE((U8*)&(laszip->items[i].size))) { - REprintf("ERROR: writing size %d of item %d\n", laszip->items[i].size, i); + fprintf(stderr,"ERROR: writing size %d of item %d\n", laszip->items[i].size, i); return FALSE; } if (!stream->put16bitsLE((U8*)&(laszip->items[i].version))) { - REprintf("ERROR: writing version %d of item %d\n", laszip->items[i].version, i); + fprintf(stderr,"ERROR: writing version %d of item %d\n", laszip->items[i].version, i); return FALSE; } } @@ -697,32 +712,32 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp U16 reserved = 0xAABB; if (!stream->put16bitsLE((U8*)&(reserved))) { - REprintf("ERROR: writing reserved %d\n", (I32)reserved); + fprintf(stderr,"ERROR: writing reserved %d\n", (I32)reserved); return FALSE; } U8 user_id[16] = "LAStools\0\0\0\0\0\0\0"; if (!stream->putBytes((U8*)user_id, 16)) { - REprintf("ERROR: writing user_id %s\n", user_id); + fprintf(stderr,"ERROR: writing user_id %s\n", user_id); return FALSE; } U16 record_id = 10; if (!stream->put16bitsLE((U8*)&(record_id))) { - REprintf("ERROR: writing record_id %d\n", (I32)record_id); + fprintf(stderr,"ERROR: writing record_id %d\n", (I32)record_id); return FALSE; } U16 record_length_after_header = 28; if (!stream->put16bitsLE((U8*)&(record_length_after_header))) { - REprintf("ERROR: writing record_length_after_header %d\n", (I32)record_length_after_header); + fprintf(stderr,"ERROR: writing record_length_after_header %d\n", (I32)record_length_after_header); return FALSE; } CHAR description[33] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; sprintf(description, "tile %s buffer %s", (header->vlr_lastiling->buffer ? "with" : "without"), (header->vlr_lastiling->reversible ? ", reversible" : "")); if (!stream->putBytes((U8*)description, 32)) { - REprintf("ERROR: writing description %s\n", description); + fprintf(stderr,"ERROR: writing description %s\n", description); return FALSE; } @@ -737,37 +752,37 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp if (!stream->put32bitsLE((U8*)&(header->vlr_lastiling->level))) { - REprintf("ERROR: writing header->vlr_lastiling->level %u\n", header->vlr_lastiling->level); + fprintf(stderr,"ERROR: writing header->vlr_lastiling->level %u\n", header->vlr_lastiling->level); return FALSE; } if (!stream->put32bitsLE((U8*)&(header->vlr_lastiling->level_index))) { - REprintf("ERROR: writing header->vlr_lastiling->level_index %u\n", header->vlr_lastiling->level_index); + fprintf(stderr,"ERROR: writing header->vlr_lastiling->level_index %u\n", header->vlr_lastiling->level_index); return FALSE; } if (!stream->put32bitsLE(((U8*)header->vlr_lastiling)+8)) { - REprintf("ERROR: writing header->vlr_lastiling->implicit_levels %u\n", header->vlr_lastiling->implicit_levels); + fprintf(stderr,"ERROR: writing header->vlr_lastiling->implicit_levels %u\n", header->vlr_lastiling->implicit_levels); return FALSE; } if (!stream->put32bitsLE((U8*)&(header->vlr_lastiling->min_x))) { - REprintf("ERROR: writing header->vlr_lastiling->min_x %g\n", header->vlr_lastiling->min_x); + fprintf(stderr,"ERROR: writing header->vlr_lastiling->min_x %g\n", header->vlr_lastiling->min_x); return FALSE; } if (!stream->put32bitsLE((U8*)&(header->vlr_lastiling->max_x))) { - REprintf("ERROR: writing header->vlr_lastiling->max_x %g\n", header->vlr_lastiling->max_x); + fprintf(stderr,"ERROR: writing header->vlr_lastiling->max_x %g\n", header->vlr_lastiling->max_x); return FALSE; } if (!stream->put32bitsLE((U8*)&(header->vlr_lastiling->min_y))) { - REprintf("ERROR: writing header->vlr_lastiling->min_y %g\n", header->vlr_lastiling->min_y); + fprintf(stderr,"ERROR: writing header->vlr_lastiling->min_y %g\n", header->vlr_lastiling->min_y); return FALSE; } if (!stream->put32bitsLE((U8*)&(header->vlr_lastiling->max_y))) { - REprintf("ERROR: writing header->vlr_lastiling->max_y %g\n", header->vlr_lastiling->max_y); + fprintf(stderr,"ERROR: writing header->vlr_lastiling->max_y %g\n", header->vlr_lastiling->max_y); return FALSE; } } @@ -781,77 +796,81 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp U16 reserved = 0xAABB; if (!stream->put16bitsLE((U8*)&(reserved))) { - REprintf("ERROR: writing reserved %d\n", (I32)reserved); + fprintf(stderr,"ERROR: writing reserved %d\n", (I32)reserved); return FALSE; } U8 user_id[16] = "LAStools\0\0\0\0\0\0\0"; if (!stream->putBytes((U8*)user_id, 16)) { - REprintf("ERROR: writing user_id %s\n", user_id); + fprintf(stderr,"ERROR: writing user_id %s\n", user_id); return FALSE; } U16 record_id = 20; if (!stream->put16bitsLE((U8*)&(record_id))) { - REprintf("ERROR: writing record_id %d\n", (I32)record_id); + fprintf(stderr,"ERROR: writing record_id %d\n", (I32)record_id); return FALSE; } U16 record_length_after_header = 176; if (!stream->put16bitsLE((U8*)&(record_length_after_header))) { - REprintf("ERROR: writing record_length_after_header %d\n", (I32)record_length_after_header); + fprintf(stderr,"ERROR: writing record_length_after_header %d\n", (I32)record_length_after_header); return FALSE; } U8 description[32] = "counters and bbox of original\0\0"; if (!stream->putBytes((U8*)description, 32)) { - REprintf("ERROR: writing description %s\n", description); + fprintf(stderr,"ERROR: writing description %s\n", description); return FALSE; } + // save the position in the stream at which the payload of this VLR was written + + header->vlr_lasoriginal->position = stream->tell(); + // write the payload of this VLR which contains 176 bytes if (!stream->put64bitsLE((U8*)&(header->vlr_lasoriginal->number_of_point_records))) { - REprintf("ERROR: writing header->vlr_lasoriginal->number_of_point_records %u\n", (U32)header->vlr_lasoriginal->number_of_point_records); + fprintf(stderr,"ERROR: writing header->vlr_lasoriginal->number_of_point_records %u\n", (U32)header->vlr_lasoriginal->number_of_point_records); return FALSE; } for (j = 0; j < 15; j++) { if (!stream->put64bitsLE((U8*)&(header->vlr_lasoriginal->number_of_points_by_return[j]))) { - REprintf("ERROR: writing header->vlr_lasoriginal->number_of_points_by_return[%u] %u\n", j, (U32)header->vlr_lasoriginal->number_of_points_by_return[j]); + fprintf(stderr,"ERROR: writing header->vlr_lasoriginal->number_of_points_by_return[%u] %u\n", j, (U32)header->vlr_lasoriginal->number_of_points_by_return[j]); return FALSE; } } if (!stream->put64bitsLE((U8*)&(header->vlr_lasoriginal->min_x))) { - REprintf("ERROR: writing header->vlr_lasoriginal->min_x %g\n", header->vlr_lasoriginal->min_x); + fprintf(stderr,"ERROR: writing header->vlr_lasoriginal->min_x %g\n", header->vlr_lasoriginal->min_x); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->vlr_lasoriginal->max_x))) { - REprintf("ERROR: writing header->vlr_lasoriginal->max_x %g\n", header->vlr_lasoriginal->max_x); + fprintf(stderr,"ERROR: writing header->vlr_lasoriginal->max_x %g\n", header->vlr_lasoriginal->max_x); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->vlr_lasoriginal->min_y))) { - REprintf("ERROR: writing header->vlr_lasoriginal->min_y %g\n", header->vlr_lasoriginal->min_y); + fprintf(stderr,"ERROR: writing header->vlr_lasoriginal->min_y %g\n", header->vlr_lasoriginal->min_y); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->vlr_lasoriginal->max_y))) { - REprintf("ERROR: writing header->vlr_lasoriginal->max_y %g\n", header->vlr_lasoriginal->max_y); + fprintf(stderr,"ERROR: writing header->vlr_lasoriginal->max_y %g\n", header->vlr_lasoriginal->max_y); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->vlr_lasoriginal->min_z))) { - REprintf("ERROR: writing header->vlr_lasoriginal->min_z %g\n", header->vlr_lasoriginal->min_z); + fprintf(stderr,"ERROR: writing header->vlr_lasoriginal->min_z %g\n", header->vlr_lasoriginal->min_z); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->vlr_lasoriginal->max_z))) { - REprintf("ERROR: writing header->vlr_lasoriginal->max_z %g\n", header->vlr_lasoriginal->max_z); + fprintf(stderr,"ERROR: writing header->vlr_lasoriginal->max_z %g\n", header->vlr_lasoriginal->max_z); return FALSE; } } @@ -864,13 +883,13 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp { if (!stream->putBytes((U8*)header->user_data_after_header, header->user_data_after_header_size)) { - REprintf("ERROR: writing %d bytes of data from header->user_data_after_header\n", header->user_data_after_header_size); + fprintf(stderr,"ERROR: writing %d bytes of data from header->user_data_after_header\n", header->user_data_after_header_size); return FALSE; } } else { - REprintf("ERROR: there should be %d bytes of data in header->user_data_after_header\n", header->user_data_after_header_size); + fprintf(stderr,"ERROR: there should be %d bytes of data in header->user_data_after_header\n", header->user_data_after_header_size); return FALSE; } } @@ -901,17 +920,17 @@ BOOL LASwriterLAS::update_header(const LASheader* header, BOOL use_inventory, BO I32 i; if (header == 0) { - REprintf("ERROR: header pointer is zero\n"); + fprintf(stderr,"ERROR: header pointer is zero\n"); return FALSE; } if (stream == 0) { - REprintf("ERROR: stream pointer is zero\n"); + fprintf(stderr,"ERROR: stream pointer is zero\n"); return FALSE; } if (!stream->isSeekable()) { - REprintf("WARNING: stream not seekable. cannot update header.\n"); + fprintf(stderr,"WARNING: stream not seekable. cannot update header.\n"); return FALSE; } if (use_inventory) @@ -930,7 +949,7 @@ BOOL LASwriterLAS::update_header(const LASheader* header, BOOL use_inventory, BO } else { - REprintf("WARNING: too many points in LAS %d.%d file. limit is %u.\n", header->version_major, header->version_minor, U32_MAX); + fprintf(stderr,"WARNING: too many points in LAS %d.%d file. limit is %u.\n", header->version_major, header->version_minor, U32_MAX); number = U32_MAX; } } @@ -940,7 +959,7 @@ BOOL LASwriterLAS::update_header(const LASheader* header, BOOL use_inventory, BO } if (!stream->put32bitsLE((U8*)&number)) { - REprintf("ERROR: updating inventory.number_of_point_records\n"); + fprintf(stderr,"ERROR: updating inventory.number_of_point_records\n"); return FALSE; } npoints = inventory.extended_number_of_point_records; @@ -967,7 +986,7 @@ BOOL LASwriterLAS::update_header(const LASheader* header, BOOL use_inventory, BO } if (!stream->put32bitsLE((U8*)&number)) { - REprintf("ERROR: updating inventory.number_of_points_by_return[%d]\n", i); + fprintf(stderr,"ERROR: updating inventory.number_of_points_by_return[%d]\n", i); return FALSE; } } @@ -976,37 +995,37 @@ BOOL LASwriterLAS::update_header(const LASheader* header, BOOL use_inventory, BO value = quantizer.get_x(inventory.max_X); if (!stream->put64bitsLE((U8*)&value)) { - REprintf("ERROR: updating inventory.max_X\n"); + fprintf(stderr,"ERROR: updating inventory.max_X\n"); return FALSE; } value = quantizer.get_x(inventory.min_X); if (!stream->put64bitsLE((U8*)&value)) { - REprintf("ERROR: updating inventory.min_X\n"); + fprintf(stderr,"ERROR: updating inventory.min_X\n"); return FALSE; } value = quantizer.get_y(inventory.max_Y); if (!stream->put64bitsLE((U8*)&value)) { - REprintf("ERROR: updating inventory.max_Y\n"); + fprintf(stderr,"ERROR: updating inventory.max_Y\n"); return FALSE; } value = quantizer.get_y(inventory.min_Y); if (!stream->put64bitsLE((U8*)&value)) { - REprintf("ERROR: updating inventory.min_Y\n"); + fprintf(stderr,"ERROR: updating inventory.min_Y\n"); return FALSE; } value = quantizer.get_z(inventory.max_Z); if (!stream->put64bitsLE((U8*)&value)) { - REprintf("ERROR: updating inventory.max_Z\n"); + fprintf(stderr,"ERROR: updating inventory.max_Z\n"); return FALSE; } value = quantizer.get_z(inventory.min_Z); if (!stream->put64bitsLE((U8*)&value)) { - REprintf("ERROR: updating inventory.min_Z\n"); + fprintf(stderr,"ERROR: updating inventory.min_Z\n"); return FALSE; } // special handling for LAS 1.4 or higher. @@ -1015,14 +1034,14 @@ BOOL LASwriterLAS::update_header(const LASheader* header, BOOL use_inventory, BO stream->seek(header_start_position+247); if (!stream->put64bitsLE((U8*)&(inventory.extended_number_of_point_records))) { - REprintf("ERROR: updating header->extended_number_of_point_records\n"); + fprintf(stderr,"ERROR: updating header->extended_number_of_point_records\n"); return FALSE; } for (i = 0; i < 15; i++) { if (!stream->put64bitsLE((U8*)&(inventory.extended_number_of_points_by_return[i+1]))) { - REprintf("ERROR: updating header->extended_number_of_points_by_return[%d]\n", i); + fprintf(stderr,"ERROR: updating header->extended_number_of_points_by_return[%d]\n", i); return FALSE; } } @@ -1042,7 +1061,7 @@ BOOL LASwriterLAS::update_header(const LASheader* header, BOOL use_inventory, BO } if (!stream->put32bitsLE((U8*)&number)) { - REprintf("ERROR: updating header->number_of_point_records\n"); + fprintf(stderr,"ERROR: updating header->number_of_point_records\n"); return FALSE; } npoints = header->number_of_point_records; @@ -1058,39 +1077,39 @@ BOOL LASwriterLAS::update_header(const LASheader* header, BOOL use_inventory, BO } if (!stream->put32bitsLE((U8*)&number)) { - REprintf("ERROR: updating header->number_of_points_by_return[%d]\n", i); + fprintf(stderr,"ERROR: updating header->number_of_points_by_return[%d]\n", i); return FALSE; } } stream->seek(header_start_position+179); if (!stream->put64bitsLE((U8*)&(header->max_x))) { - REprintf("ERROR: updating header->max_x\n"); + fprintf(stderr,"ERROR: updating header->max_x\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->min_x))) { - REprintf("ERROR: updating header->min_x\n"); + fprintf(stderr,"ERROR: updating header->min_x\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->max_y))) { - REprintf("ERROR: updating header->max_y\n"); + fprintf(stderr,"ERROR: updating header->max_y\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->min_y))) { - REprintf("ERROR: updating header->min_y\n"); + fprintf(stderr,"ERROR: updating header->min_y\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->max_z))) { - REprintf("ERROR: updating header->max_z\n"); + fprintf(stderr,"ERROR: updating header->max_z\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->min_z))) { - REprintf("ERROR: updating header->min_z\n"); + fprintf(stderr,"ERROR: updating header->min_z\n"); return FALSE; } // special handling for LAS 1.3 or higher. @@ -1100,14 +1119,14 @@ BOOL LASwriterLAS::update_header(const LASheader* header, BOOL use_inventory, BO if (header->start_of_waveform_data_packet_record != 0) { #ifdef _WIN32 - REprintf("WARNING: header->start_of_waveform_data_packet_record is %I64d. writing 0 instead.\n", header->start_of_waveform_data_packet_record); + fprintf(stderr,"WARNING: header->start_of_waveform_data_packet_record is %I64d. writing 0 instead.\n", header->start_of_waveform_data_packet_record); #else - REprintf("WARNING: header->start_of_waveform_data_packet_record is %lld. writing 0 instead.\n", header->start_of_waveform_data_packet_record); + fprintf(stderr,"WARNING: header->start_of_waveform_data_packet_record is %lld. writing 0 instead.\n", header->start_of_waveform_data_packet_record); #endif U64 start_of_waveform_data_packet_record = 0; if (!stream->put64bitsLE((U8*)&start_of_waveform_data_packet_record)) { - REprintf("ERROR: updating start_of_waveform_data_packet_record\n"); + fprintf(stderr,"ERROR: updating start_of_waveform_data_packet_record\n"); return FALSE; } } @@ -1115,7 +1134,7 @@ BOOL LASwriterLAS::update_header(const LASheader* header, BOOL use_inventory, BO { if (!stream->put64bitsLE((U8*)&(header->start_of_waveform_data_packet_record))) { - REprintf("ERROR: updating header->start_of_waveform_data_packet_record\n"); + fprintf(stderr,"ERROR: updating header->start_of_waveform_data_packet_record\n"); return FALSE; } } @@ -1126,12 +1145,12 @@ BOOL LASwriterLAS::update_header(const LASheader* header, BOOL use_inventory, BO stream->seek(header_start_position+235); if (!stream->put64bitsLE((U8*)&(header->start_of_first_extended_variable_length_record))) { - REprintf("ERROR: updating header->start_of_first_extended_variable_length_record\n"); + fprintf(stderr,"ERROR: updating header->start_of_first_extended_variable_length_record\n"); return FALSE; } if (!stream->put32bitsLE((U8*)&(header->number_of_extended_variable_length_records))) { - REprintf("ERROR: updating header->number_of_extended_variable_length_records\n"); + fprintf(stderr,"ERROR: updating header->number_of_extended_variable_length_records\n"); return FALSE; } U64 value; @@ -1141,7 +1160,7 @@ BOOL LASwriterLAS::update_header(const LASheader* header, BOOL use_inventory, BO value = header->extended_number_of_point_records; if (!stream->put64bitsLE((U8*)&value)) { - REprintf("ERROR: updating header->extended_number_of_point_records\n"); + fprintf(stderr,"ERROR: updating header->extended_number_of_point_records\n"); return FALSE; } for (i = 0; i < 15; i++) @@ -1152,7 +1171,7 @@ BOOL LASwriterLAS::update_header(const LASheader* header, BOOL use_inventory, BO value = header->extended_number_of_points_by_return[i]; if (!stream->put64bitsLE((U8*)&value)) { - REprintf("ERROR: updating header->extended_number_of_points_by_return[%d]\n", i); + fprintf(stderr,"ERROR: updating header->extended_number_of_points_by_return[%d]\n", i); return FALSE; } } @@ -1163,7 +1182,7 @@ BOOL LASwriterLAS::update_header(const LASheader* header, BOOL use_inventory, BO { if (header == 0) { - REprintf("ERROR: header pointer is zero\n"); + fprintf(stderr,"ERROR: header pointer is zero\n"); return FALSE; } if (header->number_attributes) @@ -1183,14 +1202,14 @@ BOOL LASwriterLAS::update_header(const LASheader* header, BOOL use_inventory, BO } if (i == (I32)header->number_of_variable_length_records) { - REprintf("WARNING: could not find extra bytes VLR for update\n"); + fprintf(stderr,"WARNING: could not find extra bytes VLR for update\n"); } else { stream->seek(start); if (!stream->putBytes((U8*)header->vlrs[i].data, header->vlrs[i].record_length_after_header)) { - REprintf("ERROR: writing %d bytes of data from header->vlrs[%d].data\n", header->vlrs[i].record_length_after_header, i); + fprintf(stderr,"ERROR: writing %d bytes of data from header->vlrs[%d].data\n", header->vlrs[i].record_length_after_header, i); return FALSE; } } @@ -1209,9 +1228,9 @@ I64 LASwriterLAS::close(BOOL update_npoints) if (npoints || !update_npoints) { #ifdef _WIN32 - REprintf("WARNING: written %I64d points but expected %I64d points\n", p_count, npoints); + fprintf(stderr,"WARNING: written %I64d points but expected %I64d points\n", p_count, npoints); #else - REprintf("WARNING: written %lld points but expected %lld points\n", p_count, npoints); + fprintf(stderr,"WARNING: written %lld points but expected %lld points\n", p_count, npoints); #endif } } @@ -1235,34 +1254,34 @@ I64 LASwriterLAS::close(BOOL update_npoints) if (evlrs[i].reserved != 0xAABB) { - // REprintf("WARNING: wrong evlrs[%d].reserved: %d != 0xAABB\n", i, evlrs[i].reserved); + // fprintf(stderr,"WARNING: wrong evlrs[%d].reserved: %d != 0xAABB\n", i, evlrs[i].reserved); } // write variable length records variable after variable (to avoid alignment issues) if (!stream->put16bitsLE((U8*)&(evlrs[i].reserved))) { - REprintf("ERROR: writing evlrs[%d].reserved\n", i); + fprintf(stderr,"ERROR: writing evlrs[%d].reserved\n", i); return FALSE; } if (!stream->putBytes((U8*)evlrs[i].user_id, 16)) { - REprintf("ERROR: writing evlrs[%d].user_id\n", i); + fprintf(stderr,"ERROR: writing evlrs[%d].user_id\n", i); return FALSE; } if (!stream->put16bitsLE((U8*)&(evlrs[i].record_id))) { - REprintf("ERROR: writing evlrs[%d].record_id\n", i); + fprintf(stderr,"ERROR: writing evlrs[%d].record_id\n", i); return FALSE; } if (!stream->put64bitsLE((U8*)&(evlrs[i].record_length_after_header))) { - REprintf("ERROR: writing evlrs[%d].record_length_after_header\n", i); + fprintf(stderr,"ERROR: writing evlrs[%d].record_length_after_header\n", i); return FALSE; } if (!stream->putBytes((U8*)evlrs[i].description, 32)) { - REprintf("ERROR: writing evlrs[%d].description\n", i); + fprintf(stderr,"ERROR: writing evlrs[%d].description\n", i); return FALSE; } @@ -1274,13 +1293,13 @@ I64 LASwriterLAS::close(BOOL update_npoints) { if (!stream->putBytes((U8*)evlrs[i].data, (U32)evlrs[i].record_length_after_header)) { - REprintf("ERROR: writing %u bytes of data from evlrs[%d].data\n", (U32)evlrs[i].record_length_after_header, i); + fprintf(stderr,"ERROR: writing %u bytes of data from evlrs[%d].data\n", (U32)evlrs[i].record_length_after_header, i); return FALSE; } } else { - REprintf("ERROR: there should be %u bytes of data in evlrs[%d].data\n", (U32)evlrs[i].record_length_after_header, i); + fprintf(stderr,"ERROR: there should be %u bytes of data in evlrs[%d].data\n", (U32)evlrs[i].record_length_after_header, i); return FALSE; } } @@ -1301,9 +1320,9 @@ I64 LASwriterLAS::close(BOOL update_npoints) if (!stream->isSeekable()) { #ifdef _WIN32 - REprintf( "WARNING: stream not seekable. cannot update header from %I64d to %I64d points.\n", npoints, p_count); + fprintf(stderr, "WARNING: stream not seekable. cannot update header from %I64d to %I64d points.\n", npoints, p_count); #else - REprintf( "WARNING: stream not seekable. cannot update header from %lld to %lld points.\n", npoints, p_count); + fprintf(stderr, "WARNING: stream not seekable. cannot update header from %lld to %lld points.\n", npoints, p_count); #endif } else diff --git a/inst/include/laswriter_las.hpp b/src/LASlib/laswriter_las.hpp similarity index 100% rename from inst/include/laswriter_las.hpp rename to src/LASlib/laswriter_las.hpp diff --git a/src/LASlib/laswriter_qfit.cpp b/src/LASlib/laswriter_qfit.cpp index 329bd60..2f713b9 100644 --- a/src/LASlib/laswriter_qfit.cpp +++ b/src/LASlib/laswriter_qfit.cpp @@ -51,7 +51,7 @@ BOOL LASwriterQFIT::open(const char* file_name, const LASheader* header, I32 ver { if (file_name == 0) { - REprintf("ERROR: file name pointer is zero\n"); + fprintf(stderr,"ERROR: file name pointer is zero\n"); return FALSE; } @@ -59,13 +59,13 @@ BOOL LASwriterQFIT::open(const char* file_name, const LASheader* header, I32 ver if (file == 0) { - REprintf( "ERROR: cannot open file '%s'\n", file_name); + fprintf(stderr, "ERROR: cannot open file '%s'\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, io_buffer_size) != 0) { - REprintf( "WARNING: setvbuf() failed with buffer size %u\n", io_buffer_size); + fprintf(stderr, "WARNING: setvbuf() failed with buffer size %u\n", io_buffer_size); } return open(file, header, version); @@ -75,7 +75,7 @@ BOOL LASwriterQFIT::open(FILE* file, const LASheader* header, I32 version) { if (file == 0) { - REprintf("ERROR: file pointer is zero\n"); + fprintf(stderr,"ERROR: file pointer is zero\n"); return FALSE; } @@ -84,7 +84,7 @@ BOOL LASwriterQFIT::open(FILE* file, const LASheader* header, I32 version) { if(_setmode( _fileno( stdout ), _O_BINARY ) == -1 ) { - REprintf( "ERROR: cannot set stdout to binary (untranslated) mode\n"); + fprintf(stderr, "ERROR: cannot set stdout to binary (untranslated) mode\n"); } } #endif @@ -108,14 +108,14 @@ BOOL LASwriterQFIT::open(ByteStreamOut* stream, const LASheader* header, I32 ver { if (stream == 0) { - REprintf("ERROR: ByteStreamOut pointer is zero\n"); + fprintf(stderr,"ERROR: ByteStreamOut pointer is zero\n"); return FALSE; } this->stream = stream; if (header == 0) { - REprintf("ERROR: LASheader pointer is zero\n"); + fprintf(stderr,"ERROR: LASheader pointer is zero\n"); return FALSE; } @@ -123,7 +123,7 @@ BOOL LASwriterQFIT::open(ByteStreamOut* stream, const LASheader* header, I32 ver if (((-361 < header->min_x) && (-361 < header->min_y) && (header->max_x < 361) && (header->max_y < 361)) == FALSE) { - REprintf("ERROR: bounding box (%g %g / %g %g) exceeds longitude / latitude\n", header->min_x, header->min_y, header->max_x, header->max_y); + fprintf(stderr,"ERROR: bounding box (%g %g / %g %g) exceeds longitude / latitude\n", header->min_x, header->min_y, header->max_x, header->max_y); return FALSE; } @@ -166,7 +166,7 @@ BOOL LASwriterQFIT::open(ByteStreamOut* stream, const LASheader* header, I32 ver } else { - REprintf("WARNING: version %d of QFIT unknown ... using 48\n", version); + fprintf(stderr,"WARNING: version %d of QFIT unknown ... using 48\n", version); this->version = 48; } @@ -174,7 +174,7 @@ BOOL LASwriterQFIT::open(ByteStreamOut* stream, const LASheader* header, I32 ver if (!stream->put32bitsLE((U8*)&version)) { - REprintf("ERROR: while writing version of QFIT header\n"); + fprintf(stderr,"ERROR: while writing version of QFIT header\n"); return FALSE; } @@ -185,7 +185,7 @@ BOOL LASwriterQFIT::open(ByteStreamOut* stream, const LASheader* header, I32 ver if (!stream->putBytes((U8*)buffer, version-4)) { - REprintf("ERROR: writing first header record of QFIT header\n"); + fprintf(stderr,"ERROR: writing first header record of QFIT header\n"); return FALSE; } @@ -196,12 +196,12 @@ BOOL LASwriterQFIT::open(ByteStreamOut* stream, const LASheader* header, I32 ver if (!stream->put32bitsLE((U8*)&buffer[0])) { - REprintf("ERROR: while writing -9000000 into QFIT header\n"); + fprintf(stderr,"ERROR: while writing -9000000 into QFIT header\n"); return FALSE; } if (!stream->put32bitsLE((U8*)&buffer[1])) { - REprintf("ERROR: while writing offset into QFIT header\n"); + fprintf(stderr,"ERROR: while writing offset into QFIT header\n"); return FALSE; } @@ -211,7 +211,7 @@ BOOL LASwriterQFIT::open(ByteStreamOut* stream, const LASheader* header, I32 ver sprintf((char*)buffer, "LAStools by Martin Isenburg"); if (!stream->putBytes((U8*)buffer, version-8)) { - REprintf("ERROR: writing second header record of QFIT header\n"); + fprintf(stderr,"ERROR: writing second header record of QFIT header\n"); return FALSE; } diff --git a/inst/include/laswriter_qfit.hpp b/src/LASlib/laswriter_qfit.hpp similarity index 100% rename from inst/include/laswriter_qfit.hpp rename to src/LASlib/laswriter_qfit.hpp diff --git a/src/LASlib/laswriter_txt.cpp b/src/LASlib/laswriter_txt.cpp index 60eefc4..75c5a16 100644 --- a/src/LASlib/laswriter_txt.cpp +++ b/src/LASlib/laswriter_txt.cpp @@ -58,7 +58,7 @@ BOOL LASwriterTXT::open(const CHAR* file_name, const LASheader* header, const CH { if (file_name == 0) { - REprintf("ERROR: file name pointer is zero\n"); + fprintf(stderr,"ERROR: file name pointer is zero\n"); return FALSE; } @@ -66,7 +66,7 @@ BOOL LASwriterTXT::open(const CHAR* file_name, const LASheader* header, const CH if (file == 0) { - REprintf( "ERROR: cannot open file '%s'\n", file_name); + fprintf(stderr, "ERROR: cannot open file '%s'\n", file_name); return FALSE; } @@ -79,7 +79,7 @@ BOOL LASwriterTXT::open(FILE* file, const LASheader* header, const CHAR* parse_s { if (file == 0) { - REprintf("ERROR: file pointer is zero\n"); + fprintf(stderr,"ERROR: file pointer is zero\n"); return FALSE; } @@ -128,7 +128,7 @@ BOOL LASwriterTXT::open(FILE* file, const LASheader* header, const CHAR* parse_s } else { - REprintf( "ERROR: unknown seperator '%s'\n", separator); + fprintf(stderr, "ERROR: unknown seperator '%s'\n", separator); return FALSE; } } @@ -153,17 +153,17 @@ BOOL LASwriterTXT::open(FILE* file, const LASheader* header, const CHAR* parse_s } else if (ptsVLR) { - REprintf( "WARNING: found VLR for PTS with wrong payload size of %d.\n", ptsVLR->record_length_after_header); + fprintf(stderr, "WARNING: found VLR for PTS with wrong payload size of %d.\n", ptsVLR->record_length_after_header); } else if (ptxVLR) { - REprintf( "WARNING: found VLR for PTX with wrong payload size of %d.\n", ptxVLR->record_length_after_header); + fprintf(stderr, "WARNING: found VLR for PTX with wrong payload size of %d.\n", ptxVLR->record_length_after_header); } } } else { - REprintf( "WARNING: found no VLR with PTS or PTX info.\n"); + fprintf(stderr, "WARNING: found no VLR with PTS or PTX info.\n"); } if (header->version_minor >= 4) { @@ -179,11 +179,11 @@ BOOL LASwriterTXT::open(FILE* file, const LASheader* header, const CHAR* parse_s } if (this->parse_string && strcmp(this->parse_string, "xyz") && strcmp(this->parse_string, "xyzi") && strcmp(this->parse_string, "xyziRGB") && strcmp(this->parse_string, "xyzRGB")) { - REprintf( "WARNING: the parse string for PTS should be 'xyz', 'xyzi', 'xyziRGB', or 'xyzRGB'\n"); + fprintf(stderr, "WARNING: the parse string for PTS should be 'xyz', 'xyzi', 'xyziRGB', or 'xyzRGB'\n"); } if (separator_sign != ' ') { - REprintf( "WARNING: the separator for PTS should be 'space' not '%s'\n", separator); + fprintf(stderr, "WARNING: the separator for PTS should be 'space' not '%s'\n", separator); } } else if (optx) @@ -213,13 +213,13 @@ BOOL LASwriterTXT::open(FILE* file, const LASheader* header, const CHAR* parse_s { if (ptxVLR) { - REprintf( "WARNING: found VLR for PTX with wrong payload size of %d.\n", ptxVLR->record_length_after_header); + fprintf(stderr, "WARNING: found VLR for PTX with wrong payload size of %d.\n", ptxVLR->record_length_after_header); } else { - REprintf( "WARNING: found no VLR with PTX info.\n"); + fprintf(stderr, "WARNING: found no VLR with PTX info.\n"); } - REprintf( " outputting PTS instead ...\n"); + fprintf(stderr, " outputting PTS instead ...\n"); if (header->version_minor >= 4) { #ifdef _WIN32 @@ -235,11 +235,11 @@ BOOL LASwriterTXT::open(FILE* file, const LASheader* header, const CHAR* parse_s } if (this->parse_string && strcmp(this->parse_string, "xyz") && strcmp(this->parse_string, "xyzi") && strcmp(this->parse_string, "xyziRGB") && strcmp(this->parse_string, "xyzRGB")) { - REprintf( "WARNING: the parse string for PTX should be 'xyz', 'xyzi', 'xyziRGB', or 'xyzRGB'\n"); + fprintf(stderr, "WARNING: the parse string for PTX should be 'xyz', 'xyzi', 'xyziRGB', or 'xyzRGB'\n"); } if (separator_sign != ' ') { - REprintf( "WARNING: the separator for PTX should be 'space' not '%s'\n", separator); + fprintf(stderr, "WARNING: the separator for PTX should be 'space' not '%s'\n", separator); } } @@ -419,7 +419,7 @@ BOOL LASwriterTXT::unparse_attribute(const LASpoint* point, I32 index) } else { - REprintf( "WARNING: attribute %d not (yet) implemented.\n", index); + fprintf(stderr, "WARNING: attribute %d not (yet) implemented.\n", index); return FALSE; } return TRUE; @@ -501,21 +501,21 @@ BOOL LASwriterTXT::write_point(const LASpoint* point) break; case 'R': // the red channel of the RGB field if (scale_rgb != 1.0f) - fprintf(file, "%.2f", scale_rgb*point->get_rgb()[0]); + fprintf(file, "%.2f", scale_rgb*point->get_R()); else - fprintf(file, "%d", point->get_rgb()[0]); + fprintf(file, "%d", point->get_R()); break; case 'G': // the green channel of the RGB field if (scale_rgb != 1.0f) - fprintf(file, "%.2f", scale_rgb*point->get_rgb()[1]); + fprintf(file, "%.2f", scale_rgb*point->get_G()); else - fprintf(file, "%d", point->get_rgb()[1]); + fprintf(file, "%d", point->get_G()); break; case 'B': // the blue channel of the RGB field if (scale_rgb != 1.0f) - fprintf(file, "%.2f", scale_rgb*point->get_rgb()[2]); + fprintf(file, "%.2f", scale_rgb*point->get_B()); else - fprintf(file, "%d", point->get_rgb()[2]); + fprintf(file, "%d", point->get_B()); break; case 'm': // the index of the point (count starts at 0) #ifdef _WIN32 @@ -649,42 +649,42 @@ BOOL LASwriterTXT::check_parse_string(const CHAR* parse_string) I32 index = (I32)(p[0] - '0'); if (index >= header->number_attributes) { - REprintf( "ERROR: extra bytes attribute '%d' does not exist.\n", index); + fprintf(stderr, "ERROR: extra bytes attribute '%d' does not exist.\n", index); return FALSE; } attribute_starts[index] = header->get_attribute_start(index); } else { - REprintf( "ERROR: unknown symbol '%c' in parse string. valid are\n", p[0]); - REprintf( " 'x' : the x coordinate\n"); - REprintf( " 'y' : the y coordinate\n"); - REprintf( " 'z' : the z coordinate\n"); - REprintf( " 't' : the gps time\n"); - REprintf( " 'R' : the red channel of the RGB field\n"); - REprintf( " 'G' : the green channel of the RGB field\n"); - REprintf( " 'B' : the blue channel of the RGB field\n"); - REprintf( " 's' : a string or a number that we don't care about\n"); - REprintf( " 'i' : the intensity\n"); - REprintf( " 'a' : the scan angle\n"); - REprintf( " 'n' : the number of returns of that given pulse\n"); - REprintf( " 'r' : the number of the return\n"); - REprintf( " 'c' : the classification\n"); - REprintf( " 'u' : the user data\n"); - REprintf( " 'p' : the point source ID\n"); - REprintf( " 'e' : the edge of flight line flag\n"); - REprintf( " 'd' : the direction of scan flag\n"); - REprintf( " 'h' : the withheld flag\n"); - REprintf( " 'k' : the keypoint flag\n"); - REprintf( " 'g' : the synthetic flag\n"); - REprintf( " 'o' : the overlap flag\n"); - REprintf( " 'l' : the scanner channel\n"); - REprintf( " 'M' : the index of the point\n"); - REprintf( " 'w' : the wavepacket descriptor index\n"); - REprintf( " 'W' : all wavepacket attributes\n"); - REprintf( " 'X' : the unscaled and unoffset integer x coordinate\n"); - REprintf( " 'Y' : the unscaled and unoffset integer y coordinate\n"); - REprintf( " 'Z' : the unscaled and unoffset integer z coordinate\n"); + fprintf(stderr, "ERROR: unknown symbol '%c' in parse string. valid are\n", p[0]); + fprintf(stderr, " 'x' : the x coordinate\n"); + fprintf(stderr, " 'y' : the y coordinate\n"); + fprintf(stderr, " 'z' : the z coordinate\n"); + fprintf(stderr, " 't' : the gps time\n"); + fprintf(stderr, " 'R' : the red channel of the RGB field\n"); + fprintf(stderr, " 'G' : the green channel of the RGB field\n"); + fprintf(stderr, " 'B' : the blue channel of the RGB field\n"); + fprintf(stderr, " 's' : a string or a number that we don't care about\n"); + fprintf(stderr, " 'i' : the intensity\n"); + fprintf(stderr, " 'a' : the scan angle\n"); + fprintf(stderr, " 'n' : the number of returns of that given pulse\n"); + fprintf(stderr, " 'r' : the number of the return\n"); + fprintf(stderr, " 'c' : the classification\n"); + fprintf(stderr, " 'u' : the user data\n"); + fprintf(stderr, " 'p' : the point source ID\n"); + fprintf(stderr, " 'e' : the edge of flight line flag\n"); + fprintf(stderr, " 'd' : the direction of scan flag\n"); + fprintf(stderr, " 'h' : the withheld flag\n"); + fprintf(stderr, " 'k' : the keypoint flag\n"); + fprintf(stderr, " 'g' : the synthetic flag\n"); + fprintf(stderr, " 'o' : the overlap flag\n"); + fprintf(stderr, " 'l' : the scanner channel\n"); + fprintf(stderr, " 'M' : the index of the point\n"); + fprintf(stderr, " 'w' : the wavepacket descriptor index\n"); + fprintf(stderr, " 'W' : all wavepacket attributes\n"); + fprintf(stderr, " 'X' : the unscaled and unoffset integer x coordinate\n"); + fprintf(stderr, " 'Y' : the unscaled and unoffset integer y coordinate\n"); + fprintf(stderr, " 'Z' : the unscaled and unoffset integer z coordinate\n"); return FALSE; } } diff --git a/inst/include/laswriter_txt.hpp b/src/LASlib/laswriter_txt.hpp similarity index 100% rename from inst/include/laswriter_txt.hpp rename to src/LASlib/laswriter_txt.hpp diff --git a/src/LASlib/laswriter_wrl.cpp b/src/LASlib/laswriter_wrl.cpp index 4ce47f8..77ab495 100644 --- a/src/LASlib/laswriter_wrl.cpp +++ b/src/LASlib/laswriter_wrl.cpp @@ -38,7 +38,7 @@ BOOL LASwriterWRL::open(const CHAR* file_name, const LASheader* header, const CH { if (file_name == 0) { - REprintf("ERROR: file name pointer is zero\n"); + fprintf(stderr,"ERROR: file name pointer is zero\n"); return FALSE; } @@ -46,7 +46,7 @@ BOOL LASwriterWRL::open(const CHAR* file_name, const LASheader* header, const CH if (file == 0) { - REprintf( "ERROR: cannot open file '%s'\n", file_name); + fprintf(stderr, "ERROR: cannot open file '%s'\n", file_name); return FALSE; } @@ -59,7 +59,7 @@ BOOL LASwriterWRL::open(FILE* file, const LASheader* header, const CHAR* parse_s { if (file == 0) { - REprintf("ERROR: file pointer is zero\n"); + fprintf(stderr,"ERROR: file pointer is zero\n"); return FALSE; } @@ -80,7 +80,7 @@ BOOL LASwriterWRL::open(FILE* file, const LASheader* header, const CHAR* parse_s } else { - REprintf("WARNING: points do not have RGB colors\n"); + fprintf(stderr,"WARNING: points do not have RGB colors\n"); if (rgb) { rgb_alloc = 0; diff --git a/inst/include/laswriter_wrl.hpp b/src/LASlib/laswriter_wrl.hpp similarity index 100% rename from inst/include/laswriter_wrl.hpp rename to src/LASlib/laswriter_wrl.hpp diff --git a/src/LASlib/laswritercompatible.cpp b/src/LASlib/laswritercompatible.cpp index dc2e169..4105094 100644 --- a/src/LASlib/laswritercompatible.cpp +++ b/src/LASlib/laswritercompatible.cpp @@ -105,9 +105,9 @@ BOOL LASwriterCompatibleDown::open(LASheader* header, LASwriteOpener* laswriteop if (start_of_waveform_data_packet_record != 0) { #ifdef _WIN32 - REprintf("WARNING: header->start_of_waveform_data_packet_record is %I64d. writing 0 instead.\n", start_of_waveform_data_packet_record); + fprintf(stderr,"WARNING: header->start_of_waveform_data_packet_record is %I64d. writing 0 instead.\n", start_of_waveform_data_packet_record); #else - REprintf("WARNING: header->start_of_waveform_data_packet_record is %lld. writing 0 instead.\n", start_of_waveform_data_packet_record); + fprintf(stderr,"WARNING: header->start_of_waveform_data_packet_record is %lld. writing 0 instead.\n", start_of_waveform_data_packet_record); #endif start_of_waveform_data_packet_record = 0; } @@ -116,9 +116,9 @@ BOOL LASwriterCompatibleDown::open(LASheader* header, LASwriteOpener* laswriteop if (start_of_first_extended_variable_length_record != 0) { #ifdef _WIN32 - REprintf("WARNING: EVLRs not supported. header->start_of_first_extended_variable_length_record is %I64d. writing 0 instead.\n", start_of_first_extended_variable_length_record); + fprintf(stderr,"WARNING: EVLRs not supported. header->start_of_first_extended_variable_length_record is %I64d. writing 0 instead.\n", start_of_first_extended_variable_length_record); #else - REprintf("WARNING: EVLRs not supported. header->start_of_first_extended_variable_length_record is %lld. writing 0 instead.\n", start_of_first_extended_variable_length_record); + fprintf(stderr,"WARNING: EVLRs not supported. header->start_of_first_extended_variable_length_record is %lld. writing 0 instead.\n", start_of_first_extended_variable_length_record); #endif start_of_first_extended_variable_length_record = 0; } @@ -126,7 +126,7 @@ BOOL LASwriterCompatibleDown::open(LASheader* header, LASwriteOpener* laswriteop U32 number_of_extended_variable_length_records = header->number_of_extended_variable_length_records; if (number_of_extended_variable_length_records != 0) { - REprintf("WARNING: EVLRs not supported. header->number_of_extended_variable_length_records is %u. writing 0 instead.\n", number_of_extended_variable_length_records); + fprintf(stderr,"WARNING: EVLRs not supported. header->number_of_extended_variable_length_records is %u. writing 0 instead.\n", number_of_extended_variable_length_records); number_of_extended_variable_length_records = 0; } out->put32bitsLE((U8*)&number_of_extended_variable_length_records); @@ -134,7 +134,7 @@ BOOL LASwriterCompatibleDown::open(LASheader* header, LASwriteOpener* laswriteop if (header->number_of_point_records) { extended_number_of_point_records = header->number_of_point_records; - REprintf("WARNING: legacy number_of_point_records in header of LAS 1.4 file should be zero.\n"); + fprintf(stderr,"WARNING: legacy number_of_point_records in header of LAS 1.4 file should be zero.\n"); } else { @@ -150,7 +150,7 @@ BOOL LASwriterCompatibleDown::open(LASheader* header, LASwriteOpener* laswriteop if (header->number_of_points_by_return[i]) { extended_number_of_points_by_return = header->number_of_points_by_return[i]; - REprintf("WARNING: legacy number_of_points_by_return[%d] in header of LAS 1.4 file should be zero.\n", i); + fprintf(stderr,"WARNING: legacy number_of_points_by_return[%d] in header of LAS 1.4 file should be zero.\n", i); } else { @@ -229,9 +229,9 @@ BOOL LASwriterCompatibleDown::open(LASheader* header, LASwriteOpener* laswriteop else { #ifdef _WIN32 - REprintf("large EVLR with user ID '%s' and record ID %d with payload size %I64d not moved to VLRs.\n", header->evlrs[i].user_id, header->evlrs[i].record_id, header->evlrs[i].record_length_after_header); + fprintf(stderr,"large EVLR with user ID '%s' and record ID %d with payload size %I64d not moved to VLRs.\n", header->evlrs[i].user_id, header->evlrs[i].record_id, header->evlrs[i].record_length_after_header); #else - REprintf("large EVLR with user ID '%s' and record ID %d with payload size %lld not moved to VLRs.\n", header->evlrs[i].user_id, header->evlrs[i].record_id, header->evlrs[i].record_length_after_header); + fprintf(stderr,"large EVLR with user ID '%s' and record ID %d with payload size %lld not moved to VLRs.\n", header->evlrs[i].user_id, header->evlrs[i].record_id, header->evlrs[i].record_length_after_header); #endif } } @@ -269,7 +269,7 @@ BOOL LASwriterCompatibleDown::open(LASheader* header, LASwriteOpener* laswriteop } else { - REprintf("unknown LASF_Projection EVLR with record ID %d not moved to VLRs.\n", header->evlrs[i].record_id); + fprintf(stderr,"unknown LASF_Projection EVLR with record ID %d not moved to VLRs.\n", header->evlrs[i].record_id); } } } @@ -438,40 +438,40 @@ BOOL LASwriterCompatibleUp::open(LASheader* header, LASwriteOpener* laswriteopen const LASvlr* compatibility_vlr = header->get_vlr("lascompatible", 22204); if (compatibility_vlr == 0) { - REprintf( "ERROR: no compatibility VLR in header\n"); + fprintf(stderr, "ERROR: no compatibility VLR in header\n"); return FALSE; } // the compatibility VLR must have the right length if (compatibility_vlr->record_length_after_header != (2+2+4+148)) { - REprintf( "ERROR: compatibility VLR has %u instead of %u bytes in payload\n", compatibility_vlr->record_length_after_header, 2+2+4+148); + fprintf(stderr, "ERROR: compatibility VLR has %u instead of %u bytes in payload\n", compatibility_vlr->record_length_after_header, 2+2+4+148); return FALSE; } I32 index_scan_angle = header->get_attribute_index("LAS 1.4 scan angle"); if (index_scan_angle == -1) { - REprintf( "ERROR: attribute \"LAS 1.4 scan angle\" is not in EXTRA_BYTES\n"); + fprintf(stderr, "ERROR: attribute \"LAS 1.4 scan angle\" is not in EXTRA_BYTES\n"); return FALSE; } start_scan_angle = header->get_attribute_start(index_scan_angle); I32 index_extended_returns = header->get_attribute_index("LAS 1.4 extended returns"); if (index_extended_returns == -1) { - REprintf( "ERROR: attribute \"LAS 1.4 extended returns\" is not in EXTRA_BYTES\n"); + fprintf(stderr, "ERROR: attribute \"LAS 1.4 extended returns\" is not in EXTRA_BYTES\n"); return FALSE; } start_extended_returns = header->get_attribute_start(index_extended_returns); I32 index_classification = header->get_attribute_index("LAS 1.4 classification"); if (index_classification == -1) { - REprintf( "ERROR: attribute \"LAS 1.4 classification\" is not in EXTRA_BYTES\n"); + fprintf(stderr, "ERROR: attribute \"LAS 1.4 classification\" is not in EXTRA_BYTES\n"); return FALSE; } start_classification = header->get_attribute_start(index_classification); I32 index_flags_and_channel = header->get_attribute_index("LAS 1.4 flags and channel"); if (index_scan_angle == -1) { - REprintf( "ERROR: attribute \"LAS 1.4 flags and channel\" is not in EXTRA_BYTES\n"); + fprintf(stderr, "ERROR: attribute \"LAS 1.4 flags and channel\" is not in EXTRA_BYTES\n"); return FALSE; } start_flags_and_channel = header->get_attribute_start(index_flags_and_channel); @@ -517,14 +517,14 @@ BOOL LASwriterCompatibleUp::open(LASheader* header, LASwriteOpener* laswriteopen in->get16bitsLE((U8*)&compatible_version); if (compatible_version != 3) { - REprintf( "ERROR: compatibility mode version %u not implemented\n", compatible_version); + fprintf(stderr, "ERROR: compatibility mode version %u not implemented\n", compatible_version); return FALSE; } U32 unused; in->get32bitsLE((U8*)&unused); if (unused != 0) { - REprintf( "WARNING: unused is %u instead of 0\n", unused); + fprintf(stderr, "WARNING: unused is %u instead of 0\n", unused); } in->get64bitsLE((U8*)&(header->start_of_waveform_data_packet_record)); in->get64bitsLE((U8*)&(header->start_of_first_extended_variable_length_record)); diff --git a/inst/include/laswritercompatible.hpp b/src/LASlib/laswritercompatible.hpp similarity index 95% rename from inst/include/laswritercompatible.hpp rename to src/LASlib/laswritercompatible.hpp index 7c7d2e7..7c25c69 100644 --- a/inst/include/laswritercompatible.hpp +++ b/src/LASlib/laswritercompatible.hpp @@ -34,7 +34,7 @@ #include "laswriter.hpp" -class LASwriterCompatibleDown : public LASwriter +class LASLIB_DLL LASwriterCompatibleDown : public LASwriter { public: BOOL open(LASheader* header, LASwriteOpener* laswriteopener, BOOL moveCRSfromEVLRtoVLR=FALSE, BOOL moveEVLRtoVLR=FALSE); @@ -59,7 +59,7 @@ class LASwriterCompatibleDown : public LASwriter I32 start_NIR_band; }; -class LASwriterCompatibleUp : public LASwriter +class LASLIB_DLL LASwriterCompatibleUp : public LASwriter { public: BOOL open(LASheader* header, LASwriteOpener* laswriteopener); diff --git a/src/LASzip/LICENSE.txt b/src/LASzip/LICENSE.txt deleted file mode 100644 index cadd322..0000000 --- a/src/LASzip/LICENSE.txt +++ /dev/null @@ -1,96 +0,0 @@ --------------------------------------------------------------------------- - - LICENSE AGREEMENT: - - This software is distributed WITHOUT ANY WARRANTY and without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - --------------------------------------------------------------------------- - - There are TWO parts to LAStools. One part is OPEN source (LGPL 2.1). The - other part is CLOSED source and requires licensing for most commercial - or government use. If you're unsure please email 'martin@rapidlasso.com' - before using LAStools. For education and evaluation purposes you can use - and test LAStools as much as you need to ... (-: - - Personal note: The creator of LAStools and LASzip is currently not able - to attend LiDAR conferences or other scientific meetings in the US over - a somewhat unfortunate, kind of silly, and in many ways absurdly funny - incident involving "laser chickens" and a US Nuclear Weapons Lab. If you - have enough "pull" to rectify this ridiculous situation we would like to - hear from you ... (-; - --------------------------------------------------------------------------- - - This part of LAStools is "free" open-source LGPL (see COPYING.txt). To - purchase a different licensing model contact 'license@rapidlasso.com'. - - * laszip - * lasindex - * lasvalidate - * lasliberate - * lasinfo - * las2las - * lasdiff - * lasmerge - * las2txt & txt2las - * lasprecision - * LASzip (with static linking exception) - * LASlib (with LASzip) - the API used by LAStools. - - These two are also "free" to use but not available in open source. - - * lasview - * laspublish - --------------------------------------------------------------------------- - - The following LAStools require licensing for any commercial, government, - or production use. However, they may be used "freely" for all non-profit - personal, non-military educational, or non-profit humanitarian purposes. - Note that the output of the unlicensed version can be slightly distorted - after certain point limits are exceeded. Control output in the console - (aka "the black window") informs the user whenever this happens. - - * blast2dem - * blast2iso - - * lasground & lasground_new - * lasheight & lastrack - * lasclassify - * lasgrid & lascanopy - * lasboundary - * lascontrol - * lasoverlap - * lasoverage - * lasduplicate - * lassplit - * lasreturn - * las2tin - * las2iso - * las2dem - * lasthin & lasnoise - * lassort - * lastile - * lasplanes - * lascolor - * lasclip - * las2shp & shp2las. - --------------------------------------------------------------------------- - - If you want to use LAStools please contact us for licensing. You can - - (a) license the existing executables for production - (b) license the existing executables for inclusion in your software - - You can also contract with rapidlasso GmbH to create LAStools tailored - to your particular needs. - --------------------------------------------------------------------------- - - COPYRIGHT: - - (c) 2007-2015, rapidlasso GmbH, GERMANY - fast tools to catch reality - --------------------------------------------------------------------------- diff --git a/src/LASzip/README.txt b/src/LASzip/README.txt index 531ea19..327d4f1 100644 --- a/src/LASzip/README.txt +++ b/src/LASzip/README.txt @@ -1,12 +1,12 @@ CONTENT: - + This folder contains the source code of LASzip developped by Martin Isenburg - and used in the 'rlas' package. - + and used in the lidR package. + PROGRAMMERS: - + martin.isenburg@rapidlasso.com - http://rapidlasso.com - + COPYRIGHT: (c) 2003-2012, martin isenburg, rapidlasso - fast tools to catch reality diff --git a/inst/include/arithmeticdecoder.hpp b/src/LASzip/arithmeticdecoder.hpp similarity index 100% rename from inst/include/arithmeticdecoder.hpp rename to src/LASzip/arithmeticdecoder.hpp diff --git a/inst/include/arithmeticencoder.hpp b/src/LASzip/arithmeticencoder.hpp similarity index 100% rename from inst/include/arithmeticencoder.hpp rename to src/LASzip/arithmeticencoder.hpp diff --git a/inst/include/arithmeticmodel.hpp b/src/LASzip/arithmeticmodel.hpp similarity index 100% rename from inst/include/arithmeticmodel.hpp rename to src/LASzip/arithmeticmodel.hpp diff --git a/inst/include/bytestreamin.hpp b/src/LASzip/bytestreamin.hpp similarity index 100% rename from inst/include/bytestreamin.hpp rename to src/LASzip/bytestreamin.hpp diff --git a/inst/include/bytestreamin_array.hpp b/src/LASzip/bytestreamin_array.hpp similarity index 100% rename from inst/include/bytestreamin_array.hpp rename to src/LASzip/bytestreamin_array.hpp diff --git a/inst/include/bytestreamin_file.hpp b/src/LASzip/bytestreamin_file.hpp similarity index 100% rename from inst/include/bytestreamin_file.hpp rename to src/LASzip/bytestreamin_file.hpp diff --git a/inst/include/bytestreamin_istream.hpp b/src/LASzip/bytestreamin_istream.hpp similarity index 100% rename from inst/include/bytestreamin_istream.hpp rename to src/LASzip/bytestreamin_istream.hpp diff --git a/inst/include/bytestreaminout.hpp b/src/LASzip/bytestreaminout.hpp similarity index 100% rename from inst/include/bytestreaminout.hpp rename to src/LASzip/bytestreaminout.hpp diff --git a/inst/include/bytestreaminout_file.hpp b/src/LASzip/bytestreaminout_file.hpp similarity index 100% rename from inst/include/bytestreaminout_file.hpp rename to src/LASzip/bytestreaminout_file.hpp diff --git a/inst/include/bytestreamout.hpp b/src/LASzip/bytestreamout.hpp similarity index 100% rename from inst/include/bytestreamout.hpp rename to src/LASzip/bytestreamout.hpp diff --git a/inst/include/bytestreamout_array.hpp b/src/LASzip/bytestreamout_array.hpp similarity index 100% rename from inst/include/bytestreamout_array.hpp rename to src/LASzip/bytestreamout_array.hpp diff --git a/inst/include/bytestreamout_file.hpp b/src/LASzip/bytestreamout_file.hpp similarity index 99% rename from inst/include/bytestreamout_file.hpp rename to src/LASzip/bytestreamout_file.hpp index df45689..43e6d2e 100644 --- a/inst/include/bytestreamout_file.hpp +++ b/src/LASzip/bytestreamout_file.hpp @@ -2,9 +2,9 @@ =============================================================================== FILE: bytestreamout_file.hpp - + CONTENTS: - + Class for FILE*-based output streams with endian handling. PROGRAMMERS: @@ -21,13 +21,13 @@ This software is distributed WITHOUT ANY WARRANTY and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - + CHANGE HISTORY: - + 1 October 2011 -- added 64 bit file support in MSVC 6.0 at McCafe at Hbf Linz 10 January 2011 -- licensing change for LGPL release and liblas integration 12 December 2010 -- created from ByteStreamOutFile after Howard got pushy (-; - + =============================================================================== */ #ifndef BYTE_STREAM_OUT_FILE_H @@ -130,7 +130,7 @@ inline BOOL ByteStreamOutFile::putBytes(const U8* bytes, U32 num_bytes) inline BOOL ByteStreamOutFile::isSeekable() const { - return (true); + return (file != stdout); } inline I64 ByteStreamOutFile::tell() const diff --git a/inst/include/bytestreamout_nil.hpp b/src/LASzip/bytestreamout_nil.hpp similarity index 100% rename from inst/include/bytestreamout_nil.hpp rename to src/LASzip/bytestreamout_nil.hpp diff --git a/inst/include/bytestreamout_ostream.hpp b/src/LASzip/bytestreamout_ostream.hpp similarity index 100% rename from inst/include/bytestreamout_ostream.hpp rename to src/LASzip/bytestreamout_ostream.hpp diff --git a/src/LASzip/demzip_dll.cpp b/src/LASzip/demzip_dll.cpp new file mode 100644 index 0000000..8c2fbdc --- /dev/null +++ b/src/LASzip/demzip_dll.cpp @@ -0,0 +1,4949 @@ +/* +=============================================================================== + + FILE: demzip_dll.cpp + + CONTENTS: + + see corresponding header file + + PROGRAMMERS: + + martin.isenburg@rapidlasso.com - http://rapidlasso.com + + COPYRIGHT: + + (c) 2007-2019, martin isenburg, rapidlasso - fast tools to catch reality + + This is free software; you can redistribute and/or modify it under the + terms of the GNU Lesser General Licence as published by the Free Software + Foundation. See the COPYING file for more information. + + This software is distributed WITHOUT ANY WARRANTY and without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + CHANGE HISTORY: + + 31 August 2019 -- created during codesprint after FOSS4G 2019 in Bucharest + +=============================================================================== +*/ + +#define DEMZIP_DYN_LINK +#define DEMZIP_SOURCE + +#include "demzip_api.h" +#include +#include +#include +#include + +#include "laszip.hpp" +#include "lasattributer.hpp" +#include "bytestreamout_file.hpp" +#include "bytestreamin_file.hpp" +#include "bytestreamout_array.hpp" +#include "bytestreamin_array.hpp" +#include "bytestreamin_istream.hpp" +#include "bytestreamout_ostream.hpp" +#include "laswritepoint.hpp" +#include "lasreadpoint.hpp" +#include "lasquadtree.hpp" +#include "lasindex.hpp" + +class demzip_dll_inventory +{ +public: + BOOL active() const { return (first == FALSE); }; + U32 number_of_point_records; + U32 number_of_points_by_return[16]; + I32 max_X; + I32 min_X; + I32 max_Y; + I32 min_Y; + I32 max_Z; + I32 min_Z; + void add(const demzip_point_struct* point) + { + number_of_point_records++; + if (point->extended_point_type) + { + number_of_points_by_return[point->extended_return_number]++; + } + else + { + number_of_points_by_return[point->return_number]++; + } + if (first) + { + min_X = max_X = point->X; + min_Y = max_Y = point->Y; + min_Z = max_Z = point->Z; + first = FALSE; + } + else + { + if (point->X < min_X) min_X = point->X; + else if (point->X > max_X) max_X = point->X; + if (point->Y < min_Y) min_Y = point->Y; + else if (point->Y > max_Y) max_Y = point->Y; + if (point->Z < min_Z) min_Z = point->Z; + else if (point->Z > max_Z) max_Z = point->Z; + } + } + demzip_dll_inventory() + { + U32 i; + number_of_point_records = 0; + for (i = 0; i < 16; i++) number_of_points_by_return[i] = 0; + max_X = min_X = 0; + max_Y = min_Y = 0; + max_Z = min_Z = 0; + first = TRUE; + } +private: + BOOL first; +}; + +typedef struct demzip_dll { + demzip_header_struct header; + I64 p_count; + I64 npoints; + demzip_point_struct point; + U8** point_items; + FILE* file; + ByteStreamIn* streamin; + LASreadPoint* reader; + ByteStreamOut* streamout; + LASwritePoint* writer; + LASattributer* attributer; + CHAR error[1024]; + CHAR warning[1024]; + LASindex* lax_index; + F64 lax_r_min_x; + F64 lax_r_min_y; + F64 lax_r_max_x; + F64 lax_r_max_y; + CHAR* lax_file_name; + BOOL lax_create; + BOOL lax_append; + BOOL lax_exploit; + U32 las14_decompress_selective; + BOOL preserve_generating_software; + BOOL request_native_extension; + BOOL request_compatibility_mode; + BOOL compatibility_mode; + U32 set_chunk_size; + I32 start_scan_angle; + I32 start_extended_returns; + I32 start_classification; + I32 start_flags_and_channel; + I32 start_NIR_band; + demzip_dll_inventory* inventory; + std::vector buffers; + + void zero() + { + memset(&header, 0, sizeof(demzip_header_struct)); + p_count = 0; + npoints = 0; + memset(&point, 0, sizeof(demzip_point_struct)); + point_items = NULL; + file = NULL; + streamin = NULL; + reader = NULL; + streamout = NULL; + writer = NULL; + attributer = NULL; + memset(error, 0, 1024); + memset(warning, 0, 1024); + lax_index = NULL; + lax_r_min_x = 0.0; + lax_r_min_y = 0.0; + lax_r_max_x = 0.0; + lax_r_max_y = 0.0; + lax_file_name = NULL; + lax_create = FALSE; + lax_append = FALSE; + lax_exploit = FALSE; + las14_decompress_selective = 0; + preserve_generating_software = FALSE; + request_native_extension = FALSE; + request_compatibility_mode = FALSE; + compatibility_mode = FALSE; + set_chunk_size = 0; + start_scan_angle = 0; + start_extended_returns = 0; + start_classification = 0; + start_flags_and_channel = 0; + start_NIR_band = 0; + inventory = NULL; + }; +} demzip_dll_struct; + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_get_version( + demzip_U8* version_major + , demzip_U8* version_minor + , demzip_U16* version_revision + , demzip_U32* version_build +) +{ + try + { + *version_major = LASZIP_VERSION_MAJOR; + *version_minor = LASZIP_VERSION_MINOR; + *version_revision = LASZIP_VERSION_REVISION; + *version_build = LASZIP_VERSION_BUILD_DATE; + } + catch (...) + { + return 1; + } + + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_get_error( + demzip_POINTER pointer + , demzip_CHAR** error +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + *error = demzip_dll->error; + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_get_error"); + return 1; + } + + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_get_warning( + demzip_POINTER pointer + , demzip_CHAR** warning +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + *warning = demzip_dll->warning; + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_get_warning"); + return 1; + } + + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_create( + demzip_POINTER* pointer +) +{ + if (pointer == 0) return 1; + + try + { + demzip_dll_struct* demzip_dll = new demzip_dll_struct; + if (demzip_dll == 0) + { + return 1; + } + + // zero every field of the demzip_dll struct + + demzip_dll->zero(); + + // create the default + + demzip_clean(demzip_dll); + + *pointer = demzip_dll; + } + catch (...) + { + return 1; + } + + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_clean( + demzip_POINTER pointer +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (demzip_dll->reader) + { + sprintf(demzip_dll->error, "cannot clean while reader is open."); + return 1; + } + + if (demzip_dll->writer) + { + sprintf(demzip_dll->error, "cannot clean while writer is open."); + return 1; + } + + // dealloc everything alloc in the header + + if (demzip_dll->header.user_data_in_header) + { + delete [] demzip_dll->header.user_data_in_header; + demzip_dll->header.user_data_in_header = 0; + } + + if (demzip_dll->header.vlrs) + { + U32 i; + for (i = 0; i < demzip_dll->header.number_of_variable_length_records; i++) + { + if (demzip_dll->header.vlrs[i].data) + { + delete [] demzip_dll->header.vlrs[i].data; + } + } + free(demzip_dll->header.vlrs); + demzip_dll->header.vlrs = 0; + } + + if (demzip_dll->header.user_data_after_header) + { + delete [] demzip_dll->header.user_data_after_header; + demzip_dll->header.user_data_after_header = 0; + } + + // dealloc everything alloc in the point + + if (demzip_dll->point.extra_bytes) + { + delete [] demzip_dll->point.extra_bytes; + demzip_dll->point.extra_bytes = 0; + } + + // dealloc point items although close_reader() / close_writer() call should have done this already + + if (demzip_dll->point_items) + { + delete [] demzip_dll->point_items; + demzip_dll->point_items = 0; + } + + // close file although close_reader() / close_writer() call should have done this already + + if (demzip_dll->file) + { + fclose(demzip_dll->file); + demzip_dll->file = 0; + } + + // dealloc streamin although close_reader() call should have done this already + + if (demzip_dll->streamin) + { + delete demzip_dll->streamin; + demzip_dll->streamin = 0; + } + + // dealloc streamout although close_writer() call should have done this already + + if (demzip_dll->streamout) + { + delete demzip_dll->streamout; + demzip_dll->streamout = 0; + } + + // dealloc the attributer + + if (demzip_dll->attributer) + { + delete demzip_dll->attributer; + demzip_dll->attributer = 0; + } + + // dealloc lax_index although close_reader() / close_writer() call should have done this already + + if (demzip_dll->lax_index) + { + delete demzip_dll->lax_index; + demzip_dll->lax_index = 0; + } + + // dealloc lax_file_name although close_writer() call should have done this already + + if (demzip_dll->lax_file_name) + { + free(demzip_dll->lax_file_name); + demzip_dll->lax_file_name = 0; + } + + // dealloc the inventory although close_writer() call should have done this already + + if (demzip_dll->inventory == 0) + { + delete demzip_dll->inventory; + demzip_dll->inventory = 0; + } + + // dealloc any data fields that were kept around in memory for others + + if (demzip_dll->buffers.size()) + { + for (size_t i = 0; i < demzip_dll->buffers.size(); i++) + { + free(demzip_dll->buffers[i]); + } + demzip_dll->buffers.clear(); + } + + // zero every field of the demzip_dll struct + + demzip_dll->zero(); + + // create default header + + sprintf(demzip_dll->header.generating_software, "LASzip DLL %d.%d r%d (%d)", LASZIP_VERSION_MAJOR, LASZIP_VERSION_MINOR, LASZIP_VERSION_REVISION, LASZIP_VERSION_BUILD_DATE); + demzip_dll->header.version_major = 1; + demzip_dll->header.version_minor = 2; + demzip_dll->header.header_size = 227; + demzip_dll->header.offset_to_point_data = 227; + demzip_dll->header.point_data_format = 1; + demzip_dll->header.point_data_record_length = 28; + demzip_dll->header.x_scale_factor = 0.01; + demzip_dll->header.y_scale_factor = 0.01; + demzip_dll->header.z_scale_factor = 0.01; + demzip_dll->set_chunk_size = LASZIP_CHUNK_SIZE_DEFAULT; + demzip_dll->request_native_extension = TRUE; + demzip_dll->las14_decompress_selective = LASZIP_DECOMPRESS_SELECTIVE_ALL; + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_clean"); + return 1; + } + + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_destroy( + demzip_POINTER pointer +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + int err = 0; + + try + { + err = demzip_clean(demzip_dll); + delete demzip_dll; + } + catch (...) + { + return 1; + } + + return err; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_get_header_pointer( + demzip_POINTER pointer + , demzip_header_struct** header_pointer +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (header_pointer == 0) + { + sprintf(demzip_dll->error, "demzip_header_struct pointer 'header_pointer' is zero"); + return 1; + } + + *header_pointer = &demzip_dll->header; + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_get_header_pointer"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_get_point_pointer( + demzip_POINTER pointer + , demzip_point_struct** point_pointer +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (point_pointer == 0) + { + sprintf(demzip_dll->error, "demzip_point_struct pointer 'point_pointer' is zero"); + return 1; + } + + *point_pointer = &demzip_dll->point; + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_get_point_pointer"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_get_point_count( + demzip_POINTER pointer + , demzip_I64* count +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (count == 0) + { + sprintf(demzip_dll->error, "demzip_I64 pointer 'count' is zero"); + return 1; + } + + if ((demzip_dll->reader == 0) && (demzip_dll->writer == 0)) + { + sprintf(demzip_dll->error, "getting count before reader or writer was opened"); + return 1; + } + + *count = demzip_dll->p_count; + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_get_point_count"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_set_header( + demzip_POINTER pointer + , const demzip_header_struct* header +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (header == 0) + { + sprintf(demzip_dll->error, "demzip_header_struct pointer 'header' is zero"); + return 1; + } + + if (demzip_dll->reader) + { + sprintf(demzip_dll->error, "cannot set header after reader was opened"); + return 1; + } + + if (demzip_dll->writer) + { + sprintf(demzip_dll->error, "cannot set header after writer was opened"); + return 1; + } + + // dealloc the attributer (if needed) + + if (demzip_dll->attributer) + { + delete demzip_dll->attributer; + demzip_dll->attributer = 0; + } + + // populate the header + + U32 i; + + demzip_dll->header.file_source_ID = header->file_source_ID; + demzip_dll->header.global_encoding = header->global_encoding; + demzip_dll->header.project_ID_GUID_data_1 = header->project_ID_GUID_data_1; + demzip_dll->header.project_ID_GUID_data_2 = header->project_ID_GUID_data_2; + demzip_dll->header.project_ID_GUID_data_3 = header->project_ID_GUID_data_3; + memcpy(demzip_dll->header.project_ID_GUID_data_4, header->project_ID_GUID_data_4, 8); + demzip_dll->header.version_major = header->version_major; + demzip_dll->header.version_minor = header->version_minor; + memcpy(demzip_dll->header.system_identifier, header->system_identifier, 32); + memcpy(demzip_dll->header.generating_software, header->generating_software, 32); + demzip_dll->header.file_creation_day = header->file_creation_day; + demzip_dll->header.file_creation_year = header->file_creation_year; + demzip_dll->header.header_size = header->header_size; + demzip_dll->header.offset_to_point_data = header->offset_to_point_data; + demzip_dll->header.number_of_variable_length_records = header->number_of_variable_length_records; + demzip_dll->header.point_data_format = header->point_data_format; + demzip_dll->header.point_data_record_length = header->point_data_record_length; + demzip_dll->header.number_of_point_records = header->number_of_point_records; + for (i = 0; i < 5; i++) demzip_dll->header.number_of_points_by_return[i] = header->number_of_points_by_return[i]; + demzip_dll->header.x_scale_factor = header->x_scale_factor; + demzip_dll->header.y_scale_factor = header->y_scale_factor; + demzip_dll->header.z_scale_factor = header->z_scale_factor; + demzip_dll->header.x_offset = header->x_offset; + demzip_dll->header.y_offset = header->y_offset; + demzip_dll->header.z_offset = header->z_offset; + demzip_dll->header.max_x = header->max_x; + demzip_dll->header.min_x = header->min_x; + demzip_dll->header.max_y = header->max_y; + demzip_dll->header.min_y = header->min_y; + demzip_dll->header.max_z = header->max_z; + demzip_dll->header.min_z = header->min_z; + + if (demzip_dll->header.version_minor >= 3) + { + demzip_dll->header.start_of_waveform_data_packet_record = header->start_of_first_extended_variable_length_record; + } + + if (demzip_dll->header.version_minor >= 4) + { + demzip_dll->header.start_of_first_extended_variable_length_record = header->start_of_first_extended_variable_length_record; + demzip_dll->header.number_of_extended_variable_length_records = header->number_of_extended_variable_length_records; + demzip_dll->header.extended_number_of_point_records = header->extended_number_of_point_records; + for (i = 0; i < 15; i++) demzip_dll->header.extended_number_of_points_by_return[i] = header->extended_number_of_points_by_return[i]; + } + + demzip_dll->header.user_data_in_header_size = header->user_data_in_header_size; + if (demzip_dll->header.user_data_in_header) + { + delete [] demzip_dll->header.user_data_in_header; + demzip_dll->header.user_data_in_header = 0; + } + if (header->user_data_in_header_size) + { + if (header->user_data_in_header == 0) + { + sprintf(demzip_dll->error, "header->user_data_in_header_size is %d but header->user_data_in_header is NULL", header->user_data_in_header_size); + return 1; + } + demzip_dll->header.user_data_in_header = new U8[header->user_data_in_header_size]; + memcpy(demzip_dll->header.user_data_in_header, header->user_data_in_header, header->user_data_in_header_size); + } + + if (demzip_dll->header.vlrs) + { + for (i = 0; i < demzip_dll->header.number_of_variable_length_records; i++) + { + if (demzip_dll->header.vlrs[i].data) + { + delete [] demzip_dll->header.vlrs[i].data; + } + } + free(demzip_dll->header.vlrs); + demzip_dll->header.vlrs = 0; + } + if (header->number_of_variable_length_records) + { + demzip_dll->header.vlrs = (demzip_vlr*)malloc(sizeof(demzip_vlr)*header->number_of_variable_length_records); + for (i = 0; i < header->number_of_variable_length_records; i++) + { + demzip_dll->header.vlrs[i].reserved = header->vlrs[i].reserved; + memcpy(demzip_dll->header.vlrs[i].user_id, header->vlrs[i].user_id, 16); + demzip_dll->header.vlrs[i].record_id = header->vlrs[i].record_id; + demzip_dll->header.vlrs[i].record_length_after_header = header->vlrs[i].record_length_after_header; + memcpy(demzip_dll->header.vlrs[i].description, header->vlrs[i].description, 32); + if (header->vlrs[i].record_length_after_header) + { + if (header->vlrs[i].data == 0) + { + sprintf(demzip_dll->error, "header->vlrs[%d].record_length_after_header is %d but header->vlrs[%d].data is NULL", i, header->vlrs[i].record_length_after_header, i); + return 1; + } + demzip_dll->header.vlrs[i].data = new U8[header->vlrs[i].record_length_after_header]; + memcpy(demzip_dll->header.vlrs[i].data, header->vlrs[i].data, header->vlrs[i].record_length_after_header); + } + else + { + demzip_dll->header.vlrs[i].data = 0; + } + + // populate the attributer if needed + + if ((strcmp(demzip_dll->header.vlrs[i].user_id, "LASF_Spec") == 0) && (demzip_dll->header.vlrs[i].record_id == 4)) + { + if (demzip_dll->attributer == 0) + { + demzip_dll->attributer = new LASattributer; + if (demzip_dll->attributer == 0) + { + sprintf(demzip_dll->error, "cannot allocate LASattributer"); + return 1; + } + } + demzip_dll->attributer->init_attributes(demzip_dll->header.vlrs[i].record_length_after_header/sizeof(LASattribute), (LASattribute*)demzip_dll->header.vlrs[i].data); + } + } + } + + demzip_dll->header.user_data_after_header_size = header->user_data_after_header_size; + if (demzip_dll->header.user_data_after_header) + { + delete [] demzip_dll->header.user_data_after_header; + demzip_dll->header.user_data_after_header = 0; + } + if (header->user_data_after_header_size) + { + if (header->user_data_after_header == 0) + { + sprintf(demzip_dll->error, "header->user_data_after_header_size is %d but header->user_data_after_header is NULL", header->user_data_after_header_size); + return 1; + } + demzip_dll->header.user_data_after_header = new U8[header->user_data_after_header_size]; + memcpy(demzip_dll->header.user_data_after_header, header->user_data_after_header, header->user_data_after_header_size); + } + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_set_header"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_set_point_type_and_size( + demzip_POINTER pointer + , demzip_U8 point_type + , demzip_U16 point_size +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (demzip_dll->reader) + { + sprintf(demzip_dll->error, "cannot set point format and point size after reader was opened"); + return 1; + } + + if (demzip_dll->writer) + { + sprintf(demzip_dll->error, "cannot set point format and point size after writer was opened"); + return 1; + } + + // check if point type and type are supported + + if (!LASzip().setup(point_type, point_size, LASZIP_COMPRESSOR_NONE)) + { + sprintf(demzip_dll->error, "invalid combination of point_type %d and point_size %d", (I32)point_type, (I32)point_size); + return 1; + } + + // set point type and point size + + demzip_dll->header.point_data_format = point_type; + demzip_dll->header.point_data_record_length = point_size; + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_set_point_type_and_size"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_check_for_integer_overflow( + demzip_POINTER pointer +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + // get a pointer to the header + + demzip_header_struct* header = &(demzip_dll->header); + + // quantize and dequantize the bounding box with current scale_factor and offset + + I32 quant_min_x = I32_QUANTIZE((header->min_x-header->x_offset)/header->x_scale_factor); + I32 quant_max_x = I32_QUANTIZE((header->max_x-header->x_offset)/header->x_scale_factor); + I32 quant_min_y = I32_QUANTIZE((header->min_y-header->y_offset)/header->y_scale_factor); + I32 quant_max_y = I32_QUANTIZE((header->max_y-header->y_offset)/header->y_scale_factor); + I32 quant_min_z = I32_QUANTIZE((header->min_z-header->z_offset)/header->z_scale_factor); + I32 quant_max_z = I32_QUANTIZE((header->max_z-header->z_offset)/header->z_scale_factor); + + F64 dequant_min_x = header->x_scale_factor*quant_min_x+header->x_offset; + F64 dequant_max_x = header->x_scale_factor*quant_max_x+header->x_offset; + F64 dequant_min_y = header->y_scale_factor*quant_min_y+header->y_offset; + F64 dequant_max_y = header->y_scale_factor*quant_max_y+header->y_offset; + F64 dequant_min_z = header->z_scale_factor*quant_min_z+header->z_offset; + F64 dequant_max_z = header->z_scale_factor*quant_max_z+header->z_offset; + + // make sure that there is not sign flip (a 32-bit integer overflow) for the bounding box + + if ((header->min_x > 0) != (dequant_min_x > 0)) + { + sprintf(demzip_dll->error, "quantization sign flip for min_x from %g to %g. set scale factor for x coarser than %g\n", header->min_x, dequant_min_x, header->x_scale_factor); + return 1; + } + if ((header->max_x > 0) != (dequant_max_x > 0)) + { + sprintf(demzip_dll->error, "quantization sign flip for max_x from %g to %g. set scale factor for x coarser than %g\n", header->max_x, dequant_max_x, header->x_scale_factor); + return 1; + } + if ((header->min_y > 0) != (dequant_min_y > 0)) + { + sprintf(demzip_dll->error, "quantization sign flip for min_y from %g to %g. set scale factor for y coarser than %g\n", header->min_y, dequant_min_y, header->y_scale_factor); + return 1; + } + if ((header->max_y > 0) != (dequant_max_y > 0)) + { + sprintf(demzip_dll->error, "quantization sign flip for max_y from %g to %g. set scale factor for y coarser than %g\n", header->max_y, dequant_max_y, header->y_scale_factor); + return 1; + } + if ((header->min_z > 0) != (dequant_min_z > 0)) + { + sprintf(demzip_dll->error, "quantization sign flip for min_z from %g to %g. set scale factor for z coarser than %g\n", header->min_z, dequant_min_z, header->z_scale_factor); + return 1; + } + if ((header->max_z > 0) != (dequant_max_z > 0)) + { + sprintf(demzip_dll->error, "quantization sign flip for max_z from %g to %g. set scale factor for z coarser than %g\n", header->max_z, dequant_max_z, header->z_scale_factor); + return 1; + } + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_auto_offset"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_auto_offset( + demzip_POINTER pointer +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (demzip_dll->reader) + { + sprintf(demzip_dll->error, "cannot auto offset after reader was opened"); + return 1; + } + + if (demzip_dll->writer) + { + sprintf(demzip_dll->error, "cannot auto offset after writer was opened"); + return 1; + } + + // get a pointer to the header + + demzip_header_struct* header = &(demzip_dll->header); + + // check scale factor + + F64 x_scale_factor = header->x_scale_factor; + F64 y_scale_factor = header->y_scale_factor; + F64 z_scale_factor = header->z_scale_factor; + + if ((x_scale_factor <= 0) || !F64_IS_FINITE(x_scale_factor)) + { + sprintf(demzip_dll->error, "invalid x scale_factor %g in header", header->x_scale_factor); + return 1; + } + + if ((y_scale_factor <= 0) || !F64_IS_FINITE(y_scale_factor)) + { + sprintf(demzip_dll->error, "invalid y scale_factor %g in header", header->y_scale_factor); + return 1; + } + + if ((z_scale_factor <= 0) || !F64_IS_FINITE(z_scale_factor)) + { + sprintf(demzip_dll->error, "invalid z scale_factor %g in header", header->z_scale_factor); + return 1; + } + + F64 center_bb_x = (header->min_x + header->max_x) / 2; + F64 center_bb_y = (header->min_y + header->max_y) / 2; + F64 center_bb_z = (header->min_z + header->max_z) / 2; + + if (!F64_IS_FINITE(center_bb_x)) + { + sprintf(demzip_dll->error, "invalid x coordinate at center of bounding box (min: %g max: %g)", header->min_x, header->max_x); + return 1; + } + + if (!F64_IS_FINITE(center_bb_y)) + { + sprintf(demzip_dll->error, "invalid y coordinate at center of bounding box (min: %g max: %g)", header->min_y, header->max_y); + return 1; + } + + if (!F64_IS_FINITE(center_bb_z)) + { + sprintf(demzip_dll->error, "invalid z coordinate at center of bounding box (min: %g max: %g)", header->min_z, header->max_z); + return 1; + } + + F64 x_offset = header->x_offset; + F64 y_offset = header->y_offset; + F64 z_offset = header->z_offset; + + header->x_offset = (I64_FLOOR(center_bb_x/x_scale_factor/10000000))*10000000*x_scale_factor; + header->y_offset = (I64_FLOOR(center_bb_y/y_scale_factor/10000000))*10000000*y_scale_factor; + header->z_offset = (I64_FLOOR(center_bb_z/z_scale_factor/10000000))*10000000*z_scale_factor; + + if (demzip_check_for_integer_overflow(pointer)) + { + header->x_offset = x_offset; + header->y_offset = y_offset; + header->z_offset = z_offset; + return 1; + } + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_auto_offset"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_set_point( + demzip_POINTER pointer + , const demzip_point_struct* point +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (point == 0) + { + sprintf(demzip_dll->error, "demzip_point_struct pointer 'point' is zero"); + return 1; + } + + if (demzip_dll->reader) + { + sprintf(demzip_dll->error, "cannot set point for reader"); + return 1; + } + + memcpy(&demzip_dll->point, point, ((U8*)&(demzip_dll->point.extra_bytes)) - ((U8*)&(demzip_dll->point.X))); + + if (demzip_dll->point.extra_bytes) + { + if (point->extra_bytes) + { + if (demzip_dll->point.num_extra_bytes == point->num_extra_bytes) + { + memcpy(demzip_dll->point.extra_bytes, point->extra_bytes, demzip_dll->point.num_extra_bytes); + } + else + { + sprintf(demzip_dll->error, "target point has %d extra bytes but source point has %d", demzip_dll->point.num_extra_bytes, point->num_extra_bytes); + return 1; + } + } + else if (!demzip_dll->compatibility_mode) + { + sprintf(demzip_dll->error, "target point has extra bytes but source point does not"); + return 1; + } + } +/* + else + { + if (point->extra_bytes) + { + sprintf(demzip_dll->error, "source point has extra bytes but target point does not"); + return 1; + } + } +*/ + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_set_point"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_set_coordinates( + demzip_POINTER pointer + , const demzip_F64* coordinates +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (coordinates == 0) + { + sprintf(demzip_dll->error, "demzip_F64 pointer 'coordinates' is zero"); + return 1; + } + + if (demzip_dll->reader) + { + sprintf(demzip_dll->error, "cannot set coordinates for reader"); + return 1; + } + + // get a pointer to the header + + demzip_header_struct* header = &(demzip_dll->header); + + // get a pointer to the point + + demzip_point_struct* point = &(demzip_dll->point); + + // set the coordinates + + point->X = I32_QUANTIZE((coordinates[0]-header->x_offset)/header->x_scale_factor); + point->Y = I32_QUANTIZE((coordinates[1]-header->y_offset)/header->y_scale_factor); + point->Z = I32_QUANTIZE((coordinates[2]-header->z_offset)/header->z_scale_factor); + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_set_coordinates"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_get_coordinates( + demzip_POINTER pointer + , demzip_F64* coordinates +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (coordinates == 0) + { + sprintf(demzip_dll->error, "demzip_F64 pointer 'coordinates' is zero"); + return 1; + } + + // get a pointer to the header + + demzip_header_struct* header = &(demzip_dll->header); + + // get a pointer to the point + + demzip_point_struct* point = &(demzip_dll->point); + + // get the coordinates + + coordinates[0] = header->x_scale_factor*point->X+header->x_offset; + coordinates[1] = header->y_scale_factor*point->Y+header->y_offset; + coordinates[2] = header->z_scale_factor*point->Z+header->z_offset; + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_get_coordinates"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_set_geokeys( + demzip_POINTER pointer + , demzip_U32 number + , const demzip_geokey_struct* key_entries +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (number == 0) + { + sprintf(demzip_dll->error, "number of key_entries is zero"); + return 1; + } + + if (key_entries == 0) + { + sprintf(demzip_dll->error, "demzip_geokey_struct pointer 'key_entries' is zero"); + return 1; + } + + if (demzip_dll->reader) + { + sprintf(demzip_dll->error, "cannot set geokeys after reader was opened"); + return 1; + } + + if (demzip_dll->writer) + { + sprintf(demzip_dll->error, "cannot set geokeys after writer was opened"); + return 1; + } + + // create the geokey directory + + demzip_geokey_struct* key_entries_plus_one = new demzip_geokey_struct[number+1]; + if (key_entries_plus_one == 0) + { + sprintf(demzip_dll->error, "allocating demzip_geokey_struct[%u] array", number+1); + return 1; + } + key_entries_plus_one[0].key_id = 1; // aka key_directory_version + key_entries_plus_one[0].tiff_tag_location = 1; // aka key_revision + key_entries_plus_one[0].count = 0; // aka minor_revision + key_entries_plus_one[0].value_offset = number; // aka number_of_keys + memcpy(key_entries_plus_one + 1, key_entries, sizeof(demzip_geokey_struct)*number); + + // add the VLR + + if (demzip_add_vlr(demzip_dll, "LASF_Projection", 34735, (demzip_U16)(8 + number*8), 0, (demzip_U8*)key_entries_plus_one)) + { + sprintf(demzip_dll->error, "setting %u geodouble_params", number); + return 1; + } + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_set_geokey_entries"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_set_geodouble_params( + demzip_POINTER pointer + , demzip_U32 number + , const demzip_F64* geodouble_params +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (number == 0) + { + sprintf(demzip_dll->error, "number of geodouble_params is zero"); + return 1; + } + + if (geodouble_params == 0) + { + sprintf(demzip_dll->error, "demzip_F64 pointer 'geodouble_params' is zero"); + return 1; + } + + if (demzip_dll->reader) + { + sprintf(demzip_dll->error, "cannot set geodouble_params after reader was opened"); + return 1; + } + + if (demzip_dll->writer) + { + sprintf(demzip_dll->error, "cannot set geodouble_params after writer was opened"); + return 1; + } + + // add the VLR + + if (demzip_add_vlr(demzip_dll, "LASF_Projection", 34736, (demzip_U16)(number*8), 0, (demzip_U8*)geodouble_params)) + { + sprintf(demzip_dll->error, "setting %u geodouble_params", number); + return 1; + } + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_set_geodouble_params"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_set_geoascii_params( + demzip_POINTER pointer + , demzip_U32 number + , const demzip_CHAR* geoascii_params +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (number == 0) + { + sprintf(demzip_dll->error, "number of geoascii_params is zero"); + return 1; + } + + if (geoascii_params == 0) + { + sprintf(demzip_dll->error, "demzip_CHAR pointer 'geoascii_params' is zero"); + return 1; + } + + if (demzip_dll->reader) + { + sprintf(demzip_dll->error, "cannot set geoascii_params after reader was opened"); + return 1; + } + + if (demzip_dll->writer) + { + sprintf(demzip_dll->error, "cannot set geoascii_params after writer was opened"); + return 1; + } + + // add the VLR + + if (demzip_add_vlr(demzip_dll, "LASF_Projection", 34737, (demzip_U16)(number), 0, (demzip_U8*)geoascii_params)) + { + sprintf(demzip_dll->error, "setting %u geoascii_params", number); + return 1; + } + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_set_geoascii_params"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_add_attribute( + demzip_POINTER pointer + , demzip_U32 type + , const demzip_CHAR* name + , const demzip_CHAR* description + , demzip_F64 scale + , demzip_F64 offset +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (type > LAS_ATTRIBUTE_F64) + { + sprintf(demzip_dll->error, "demzip_U32 'type' is %u but needs to be between %d and %d", type, LAS_ATTRIBUTE_U8, LAS_ATTRIBUTE_F64); + return 1; + } + + if (name == 0) + { + sprintf(demzip_dll->error, "demzip_CHAR pointer 'name' is zero"); + return 1; + } + + if (demzip_dll->reader) + { + sprintf(demzip_dll->error, "cannot add attribute after reader was opened"); + return 1; + } + + if (demzip_dll->writer) + { + sprintf(demzip_dll->error, "cannot add attribute after writer was opened"); + return 1; + } + + LASattribute lasattribute(type, name, description); + lasattribute.set_scale(scale); + lasattribute.set_offset(offset); + + if (demzip_dll->attributer == 0) + { + demzip_dll->attributer = new LASattributer; + if (demzip_dll->attributer == 0) + { + sprintf(demzip_dll->error, "cannot allocate LASattributer"); + return 1; + } + } + + if (demzip_dll->attributer->add_attribute(lasattribute) == -1) + { + sprintf(demzip_dll->error, "cannot add attribute '%s' to attributer", name); + return 1; + } + + if (demzip_add_vlr(demzip_dll, "LASF_Spec\0\0\0\0\0\0", 4, (demzip_U16)(demzip_dll->attributer->number_attributes*sizeof(LASattribute)), 0, (demzip_U8*)demzip_dll->attributer->attributes)) + { + sprintf(demzip_dll->error, "adding the new extra bytes VLR with the additional attribute '%s'", name); + return 1; + } + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_add_attribute"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_add_vlr( + demzip_POINTER pointer + , const demzip_CHAR* user_id + , demzip_U16 record_id + , demzip_U16 record_length_after_header + , const demzip_CHAR* description + , const demzip_U8* data +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (user_id == 0) + { + sprintf(demzip_dll->error, "demzip_CHAR pointer 'user_id' is zero"); + return 1; + } + + if ((record_length_after_header > 0) && (data == 0)) + { + sprintf(demzip_dll->error, "record_length_after_header of VLR is %u but data pointer is zero", (U32)record_length_after_header); + return 1; + } + + if (demzip_dll->reader) + { + sprintf(demzip_dll->error, "cannot add vlr after reader was opened"); + return 1; + } + + if (demzip_dll->writer) + { + sprintf(demzip_dll->error, "cannot add vlr after writer was opened"); + return 1; + } + + U32 i = 0; + + if (demzip_dll->header.vlrs) + { + // overwrite existing VLR ? + + for (i = 0; i < demzip_dll->header.number_of_variable_length_records; i++) + { + if ((strncmp(demzip_dll->header.vlrs[i].user_id, user_id, 16) == 0) && (demzip_dll->header.vlrs[i].record_id == record_id)) + { + if (demzip_dll->header.vlrs[i].record_length_after_header) + { + demzip_dll->header.offset_to_point_data -= demzip_dll->header.vlrs[i].record_length_after_header; + demzip_dll->header.vlrs[i].record_length_after_header = 0; + delete [] demzip_dll->header.vlrs[i].data; + demzip_dll->header.vlrs[i].data = 0; + } + break; + } + } + + // create new VLR + + if (i == demzip_dll->header.number_of_variable_length_records) + { + demzip_dll->header.number_of_variable_length_records++; + demzip_dll->header.offset_to_point_data += 54; + demzip_dll->header.vlrs = (demzip_vlr_struct*)realloc(demzip_dll->header.vlrs, sizeof(demzip_vlr_struct)*demzip_dll->header.number_of_variable_length_records); + if (demzip_dll->header.vlrs == 0) + { + sprintf(demzip_dll->error, "reallocating vlrs[%u] array", demzip_dll->header.number_of_variable_length_records); + return 1; + } + } + } + else + { + demzip_dll->header.number_of_variable_length_records = 1; + demzip_dll->header.offset_to_point_data += 54; + demzip_dll->header.vlrs = (demzip_vlr_struct*)malloc(sizeof(demzip_vlr_struct)); + if (demzip_dll->header.vlrs == 0) + { + sprintf(demzip_dll->error, "allocating vlrs[1] array"); + return 1; + } + } + + // zero the VLR + + memset(&(demzip_dll->header.vlrs[i]), 0, sizeof(demzip_vlr_struct)); + + // copy the VLR + + demzip_dll->header.vlrs[i].reserved = 0x0; + strncpy(demzip_dll->header.vlrs[i].user_id, user_id, 16); + demzip_dll->header.vlrs[i].record_id = record_id; + demzip_dll->header.vlrs[i].record_length_after_header = record_length_after_header; + if (description) + { + strncpy(demzip_dll->header.vlrs[i].description, description, 32); + } + else + { + sprintf(demzip_dll->header.vlrs[i].description, "LASzip DLL %d.%d r%d (%d)", LASZIP_VERSION_MAJOR, LASZIP_VERSION_MINOR, LASZIP_VERSION_REVISION, LASZIP_VERSION_BUILD_DATE); + } + if (record_length_after_header) + { + demzip_dll->header.offset_to_point_data += record_length_after_header; + demzip_dll->header.vlrs[i].data = new U8[record_length_after_header]; + memcpy(demzip_dll->header.vlrs[i].data, data, record_length_after_header); + } + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_add_vlr"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_remove_vlr( + demzip_POINTER pointer + , const demzip_CHAR* user_id + , demzip_U16 record_id +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (user_id == 0) + { + sprintf(demzip_dll->error, "demzip_CHAR pointer 'user_id' is zero"); + return 1; + } + + if (demzip_dll->reader) + { + sprintf(demzip_dll->error, "cannot remove vlr after reader was opened"); + return 1; + } + + if (demzip_dll->writer) + { + sprintf(demzip_dll->error, "cannot remove vlr after writer was opened"); + return 1; + } + + U32 i = 0; + + if (demzip_dll->header.vlrs) + { + for (i = 0; i < demzip_dll->header.number_of_variable_length_records; i++) + { + if ((strncmp(demzip_dll->header.vlrs[i].user_id, user_id, 16) == 0) && (demzip_dll->header.vlrs[i].record_id == record_id)) + { + if (demzip_dll->header.vlrs[i].record_length_after_header) + { + demzip_dll->header.offset_to_point_data -= (54 + demzip_dll->header.vlrs[i].record_length_after_header); + delete [] demzip_dll->header.vlrs[i].data; + demzip_dll->header.vlrs[i].data = 0; + } + demzip_dll->header.number_of_variable_length_records--; + for (/*i = i*/; i < demzip_dll->header.number_of_variable_length_records; i++) + { + demzip_dll->header.vlrs[i] = demzip_dll->header.vlrs[i+1]; + } + if (demzip_dll->header.number_of_variable_length_records) + { + demzip_dll->header.vlrs = (demzip_vlr_struct*)realloc(demzip_dll->header.vlrs, sizeof(demzip_vlr_struct)*demzip_dll->header.number_of_variable_length_records); + if (demzip_dll->header.vlrs == 0) + { + sprintf(demzip_dll->error, "reallocating vlrs[%u] array", demzip_dll->header.number_of_variable_length_records); + return 1; + } + } + else + { + free(demzip_dll->header.vlrs); + demzip_dll->header.vlrs = 0; + } + i = U32_MAX; + break; + } + } + if (i != U32_MAX) + { + sprintf(demzip_dll->error, "cannot find VLR with user_id '%s' and record_id %d among the %u VLRs in the header", user_id, (I32)record_id, demzip_dll->header.number_of_variable_length_records); + return 1; + } + } + else + { + sprintf(demzip_dll->error, "cannot remove VLR with user_id '%s' and record_id %d because header has no VLRs", user_id, (I32)record_id); + return 1; + } + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_add_vlr"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_preserve_generating_software( + demzip_POINTER pointer + , const demzip_BOOL preserve +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (demzip_dll->reader) + { + sprintf(demzip_dll->error, "reader is already open"); + return 1; + } + + if (demzip_dll->writer) + { + sprintf(demzip_dll->error, "writer is already open"); + return 1; + } + + demzip_dll->preserve_generating_software = preserve; + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_preserve_generating_software"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_request_native_extension( + demzip_POINTER pointer + , const demzip_BOOL request +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (demzip_dll->reader) + { + sprintf(demzip_dll->error, "reader is already open"); + return 1; + } + + if (demzip_dll->writer) + { + sprintf(demzip_dll->error, "writer is already open"); + return 1; + } + + demzip_dll->request_native_extension = request; + + if (request) // only one should be on + { + demzip_dll->request_compatibility_mode = FALSE; + } + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_request_native_extension"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_request_compatibility_mode( + demzip_POINTER pointer + , const demzip_BOOL request +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (demzip_dll->reader) + { + sprintf(demzip_dll->error, "reader is already open"); + return 1; + } + + if (demzip_dll->writer) + { + sprintf(demzip_dll->error, "writer is already open"); + return 1; + } + + demzip_dll->request_compatibility_mode = request; + + if (request) // only one should be on + { + demzip_dll->request_native_extension = FALSE; + } + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_request_compatibility_mode"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_set_chunk_size( + demzip_POINTER pointer + , const demzip_U32 chunk_size +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (demzip_dll->reader) + { + sprintf(demzip_dll->error, "reader is already open"); + return 1; + } + + if (demzip_dll->writer) + { + sprintf(demzip_dll->error, "writer is already open"); + return 1; + } + + demzip_dll->set_chunk_size = chunk_size; + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_set_chunk_size"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_create_spatial_index( + demzip_POINTER pointer + , const demzip_BOOL create + , const demzip_BOOL append +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (demzip_dll->reader) + { + sprintf(demzip_dll->error, "reader is already open"); + return 1; + } + + if (demzip_dll->writer) + { + sprintf(demzip_dll->error, "writer is already open"); + return 1; + } + + if (append) + { + sprintf(demzip_dll->error, "appending of spatial index not (yet) supported in this version"); + return 1; + } + + demzip_dll->lax_create = create; + demzip_dll->lax_append = append; + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_create_spatial_index"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +static I32 +demzip_prepare_header_for_write( + demzip_dll_struct* demzip_dll +) +{ + if ((demzip_dll->header.version_major != 1) || (demzip_dll->header.version_minor > 4)) + { + sprintf(demzip_dll->error, "unknown LAS version %d.%d", (I32)demzip_dll->header.version_major, (I32)demzip_dll->header.version_minor); + return 1; + } + + // check counters + U32 i; + + if (demzip_dll->header.point_data_format > 5) + { + // legacy counters are zero for new point types + + demzip_dll->header.number_of_point_records = 0; + for (i = 0; i < 5; i++) + { + demzip_dll->header.number_of_points_by_return[i] = 0; + } + } + else if (demzip_dll->header.version_minor > 3) + { + // legacy counters must be zero or consistent for old point types + + if (demzip_dll->header.number_of_point_records != demzip_dll->header.extended_number_of_point_records) + { + if (demzip_dll->header.number_of_point_records != 0) + { +#ifdef _WIN32 + sprintf(demzip_dll->error, "inconsistent number_of_point_records %u and extended_number_of_point_records %I64d", demzip_dll->header.number_of_point_records, demzip_dll->header.extended_number_of_point_records); +#else + sprintf(demzip_dll->error, "inconsistent number_of_point_records %u and extended_number_of_point_records %llu", demzip_dll->header.number_of_point_records, demzip_dll->header.extended_number_of_point_records); +#endif + return 1; + } + else if (demzip_dll->header.extended_number_of_point_records <= U32_MAX) + { + demzip_dll->header.number_of_point_records = (U32)demzip_dll->header.extended_number_of_point_records; + } + } + for (i = 0; i < 5; i++) + { + if (demzip_dll->header.number_of_points_by_return[i] != demzip_dll->header.extended_number_of_points_by_return[i]) + { + if (demzip_dll->header.number_of_points_by_return[i] != 0) + { +#ifdef _WIN32 + sprintf(demzip_dll->error, "inconsistent number_of_points_by_return[%u] %u and extended_number_of_points_by_return[%u] %I64d", i, demzip_dll->header.number_of_points_by_return[i], i, demzip_dll->header.extended_number_of_points_by_return[i]); +#else + sprintf(demzip_dll->error, "inconsistent number_of_points_by_return[%u] %u and extended_number_of_points_by_return[%u] %llu", i, demzip_dll->header.number_of_points_by_return[i], i, demzip_dll->header.extended_number_of_points_by_return[i]); +#endif + return 1; + } + else if (demzip_dll->header.extended_number_of_points_by_return[i] <= U32_MAX) + { + demzip_dll->header.number_of_points_by_return[i] = (U32)demzip_dll->header.extended_number_of_points_by_return[i]; + } + } + } + } + + return 0; +} + +/*---------------------------------------------------------------------------*/ +static I32 +demzip_prepare_point_for_write( + demzip_dll_struct* demzip_dll + , const demzip_BOOL compress +) +{ + U32 i; + + if (demzip_dll->header.point_data_format > 5) + { + // must be set for the new point types 6 or higher ... + + demzip_dll->point.extended_point_type = 1; + + if (demzip_dll->request_native_extension) + { + // we are *not* operating in compatibility mode + + demzip_dll->compatibility_mode = FALSE; + } + else if (demzip_dll->request_compatibility_mode) + { + // we are *not* using the native extension + + demzip_dll->request_native_extension = FALSE; + + // make sure there are no more than U32_MAX points + + if (demzip_dll->header.extended_number_of_point_records > U32_MAX) + { +#ifdef _WIN32 + sprintf(demzip_dll->error, "extended_number_of_point_records of %I64d is too much for 32-bit counters of compatibility mode", demzip_dll->header.extended_number_of_point_records); +#else + sprintf(demzip_dll->error, "extended_number_of_point_records of %llu is too much for 32-bit counters of compatibility mode", demzip_dll->header.extended_number_of_point_records); +#endif + return 1; + } + + // copy 64-bit extended counters back into 32-bit legacy counters + + demzip_dll->header.number_of_point_records = (U32)(demzip_dll->header.extended_number_of_point_records); + for (i = 0; i < 5; i++) + { + demzip_dll->header.number_of_points_by_return[i] = (U32)(demzip_dll->header.extended_number_of_points_by_return[i]); + } + + // are there any "extra bytes" already ... ? + + I32 number_of_existing_extrabytes = 0; + + switch (demzip_dll->header.point_data_format) + { + case 6: + number_of_existing_extrabytes = demzip_dll->header.point_data_record_length - 30; + break; + case 7: + number_of_existing_extrabytes = demzip_dll->header.point_data_record_length - 36; + break; + case 8: + number_of_existing_extrabytes = demzip_dll->header.point_data_record_length - 38; + break; + case 9: + number_of_existing_extrabytes = demzip_dll->header.point_data_record_length - 59; + break; + case 10: + number_of_existing_extrabytes = demzip_dll->header.point_data_record_length - 67; + break; + default: + sprintf(demzip_dll->error, "unknown point_data_format %d", demzip_dll->header.point_data_format); + return 1; + } + + if (number_of_existing_extrabytes < 0) + { + sprintf(demzip_dll->error, "bad point_data_format %d point_data_record_length %d combination", demzip_dll->header.point_data_format, demzip_dll->header.point_data_record_length); + return 1; + } + + // downgrade to LAS 1.2 or LAS 1.3 + if (demzip_dll->header.point_data_format <= 8) + { + demzip_dll->header.version_minor = 2; + // LAS 1.2 header is 148 bytes less than LAS 1.4+ header + demzip_dll->header.header_size -= 148; + demzip_dll->header.offset_to_point_data -= 148; + } + else + { + demzip_dll->header.version_minor = 3; + // LAS 1.3 header is 140 bytes less than LAS 1.4+ header + demzip_dll->header.header_size -= 140; + demzip_dll->header.offset_to_point_data -= 140; + } + // turn off the bit indicating the presence of the OGC WKT + demzip_dll->header.global_encoding &= ~(1<<4); + + // old point type is two bytes shorter + demzip_dll->header.point_data_record_length -= 2; + // but we add 5 bytes of attributes + demzip_dll->header.point_data_record_length += 5; + + // create 2+2+4+148 bytes payload for compatibility VLR + ByteStreamOutArray* out; + if (IS_LITTLE_ENDIAN()) + out = new ByteStreamOutArrayLE(); + else + out = new ByteStreamOutArrayBE(); + // write control info + U16 demzip_version = (U16)LASZIP_VERSION_BUILD_DATE; + out->put16bitsLE((U8*)&demzip_version); + U16 compatible_version = 3; + out->put16bitsLE((U8*)&compatible_version); + U32 unused = 0; + out->put32bitsLE((U8*)&unused); + // write the 148 bytes of the extended LAS 1.4 header + U64 start_of_waveform_data_packet_record = demzip_dll->header.start_of_waveform_data_packet_record; + if (start_of_waveform_data_packet_record != 0) + { +#ifdef _WIN32 + fprintf(stderr,"WARNING: header->start_of_waveform_data_packet_record is %I64d. writing 0 instead.\n", start_of_waveform_data_packet_record); +#else + fprintf(stderr,"WARNING: header->start_of_waveform_data_packet_record is %llu. writing 0 instead.\n", start_of_waveform_data_packet_record); +#endif + start_of_waveform_data_packet_record = 0; + } + out->put64bitsLE((U8*)&start_of_waveform_data_packet_record); + U64 start_of_first_extended_variable_length_record = demzip_dll->header.start_of_first_extended_variable_length_record; + if (start_of_first_extended_variable_length_record != 0) + { +#ifdef _WIN32 + fprintf(stderr,"WARNING: EVLRs not supported. header->start_of_first_extended_variable_length_record is %I64d. writing 0 instead.\n", start_of_first_extended_variable_length_record); +#else + fprintf(stderr,"WARNING: EVLRs not supported. header->start_of_first_extended_variable_length_record is %llu. writing 0 instead.\n", start_of_first_extended_variable_length_record); +#endif + start_of_first_extended_variable_length_record = 0; + } + out->put64bitsLE((U8*)&start_of_first_extended_variable_length_record); + U32 number_of_extended_variable_length_records = demzip_dll->header.number_of_extended_variable_length_records; + if (number_of_extended_variable_length_records != 0) + { + fprintf(stderr,"WARNING: EVLRs not supported. header->number_of_extended_variable_length_records is %u. writing 0 instead.\n", number_of_extended_variable_length_records); + number_of_extended_variable_length_records = 0; + } + out->put32bitsLE((U8*)&number_of_extended_variable_length_records); + U64 extended_number_of_point_records; + if (demzip_dll->header.number_of_point_records) + extended_number_of_point_records = demzip_dll->header.number_of_point_records; + else + extended_number_of_point_records = demzip_dll->header.extended_number_of_point_records; + out->put64bitsLE((U8*)&extended_number_of_point_records); + U64 extended_number_of_points_by_return; + for (i = 0; i < 15; i++) + { + if ((i < 5) && demzip_dll->header.number_of_points_by_return[i]) + extended_number_of_points_by_return = demzip_dll->header.number_of_points_by_return[i]; + else + extended_number_of_points_by_return = demzip_dll->header.extended_number_of_points_by_return[i]; + out->put64bitsLE((U8*)&extended_number_of_points_by_return); + } + + // add the compatibility VLR + + if (demzip_add_vlr(demzip_dll, "lascompatible\0\0", 22204, (demzip_U16)(2+2+4+148), 0, (demzip_U8*)out->takeData())) + { + sprintf(demzip_dll->error, "adding the compatibility VLR"); + return 1; + } + delete out; + + // if needed create an attributer to describe the "extra bytes" + + if (demzip_dll->attributer == 0) + { + demzip_dll->attributer = new LASattributer; + if (demzip_dll->attributer == 0) + { + sprintf(demzip_dll->error, "cannot allocate LASattributer"); + return 1; + } + } + + // were there any pre-existing extra bytes + + if (number_of_existing_extrabytes > 0) + { + // make sure the existing "extra bytes" are documented + + if (demzip_dll->attributer->get_attributes_size() > number_of_existing_extrabytes) + { + sprintf(demzip_dll->error, "bad \"extra bytes\" VLR describes %d bytes more than points actually have", demzip_dll->attributer->get_attributes_size() - number_of_existing_extrabytes); + return 1; + } + else if (demzip_dll->attributer->get_attributes_size() < number_of_existing_extrabytes) + { + // maybe the existing "extra bytes" are documented in a VLR + if (demzip_dll->header.vlrs) + { + for (i = 0; i < demzip_dll->header.number_of_variable_length_records; i++) + { + if ((strcmp(demzip_dll->header.vlrs[i].user_id, "LASF_Spec") == 0) && (demzip_dll->header.vlrs[i].record_id == 4)) + { + demzip_dll->attributer->init_attributes(demzip_dll->header.vlrs[i].record_length_after_header/sizeof(LASattribute), (LASattribute*)demzip_dll->header.vlrs[i].data); + } + } + } + + // describe any undocumented "extra bytes" as "unknown" U8 attributes + for (I32 i = (I32)(demzip_dll->attributer->get_attributes_size()); i < number_of_existing_extrabytes; i++) + { + CHAR unknown_name[16]; + memset(unknown_name, 0, 16); + sprintf(unknown_name, "unknown %d", i); + LASattribute lasattribute_unknown(LAS_ATTRIBUTE_U8, unknown_name, unknown_name); + if (demzip_dll->attributer->add_attribute(lasattribute_unknown) == -1) + { + sprintf(demzip_dll->error, "cannot add unknown U8 attribute '%s' of %d to attributer", unknown_name, number_of_existing_extrabytes); + return 1; + } + } + } + } + + // create the "extra bytes" that store the newer LAS 1.4 point attributes + + // scan_angle (difference or remainder) is stored as a I16 + LASattribute lasattribute_scan_angle(LAS_ATTRIBUTE_I16, "LAS 1.4 scan angle", "additional attributes"); + lasattribute_scan_angle.set_scale(0.006); + I32 index_scan_angle = demzip_dll->attributer->add_attribute(lasattribute_scan_angle); + demzip_dll->start_scan_angle = demzip_dll->attributer->get_attribute_start(index_scan_angle); + // extended returns stored as a U8 + LASattribute lasattribute_extended_returns(LAS_ATTRIBUTE_U8, "LAS 1.4 extended returns", "additional attributes"); + I32 index_extended_returns = demzip_dll->attributer->add_attribute(lasattribute_extended_returns); + demzip_dll->start_extended_returns = demzip_dll->attributer->get_attribute_start(index_extended_returns); + // classification stored as a U8 + LASattribute lasattribute_classification(LAS_ATTRIBUTE_U8, "LAS 1.4 classification", "additional attributes"); + I32 index_classification = demzip_dll->attributer->add_attribute(lasattribute_classification); + demzip_dll->start_classification = demzip_dll->attributer->get_attribute_start(index_classification); + // flags and channel stored as a U8 + LASattribute lasattribute_flags_and_channel(LAS_ATTRIBUTE_U8, "LAS 1.4 flags and channel", "additional attributes"); + I32 index_flags_and_channel = demzip_dll->attributer->add_attribute(lasattribute_flags_and_channel); + demzip_dll->start_flags_and_channel = demzip_dll->attributer->get_attribute_start(index_flags_and_channel); + // maybe store the NIR band as a U16 + if (demzip_dll->header.point_data_format == 8 || demzip_dll->header.point_data_format == 10) + { + // the NIR band is stored as a U16 + LASattribute lasattribute_NIR_band(LAS_ATTRIBUTE_U16, "LAS 1.4 NIR band", "additional attributes"); + I32 index_NIR_band = demzip_dll->attributer->add_attribute(lasattribute_NIR_band); + demzip_dll->start_NIR_band = demzip_dll->attributer->get_attribute_start(index_NIR_band); + } + else + { + demzip_dll->start_NIR_band = -1; + } + + // add the extra bytes VLR with the additional attributes + + if (demzip_add_vlr(demzip_dll, "LASF_Spec\0\0\0\0\0\0", 4, (demzip_U16)(demzip_dll->attributer->number_attributes*sizeof(LASattribute)), 0, (demzip_U8*)demzip_dll->attributer->attributes)) + { + sprintf(demzip_dll->error, "adding the extra bytes VLR with the additional attributes"); + return 1; + } + + // update point type + + if (demzip_dll->header.point_data_format == 6) + { + demzip_dll->header.point_data_format = 1; + } + else if (demzip_dll->header.point_data_format <= 8) + { + demzip_dll->header.point_data_format = 3; + } + else // 9->4 and 10->5 + { + demzip_dll->header.point_data_format -= 5; + } + + // we are operating in compatibility mode + demzip_dll->compatibility_mode = TRUE; + } + else if (compress) + { + sprintf(demzip_dll->error, "LASzip DLL %d.%d r%d (%d) cannot compress point data format %d without requesting 'compatibility mode'", LASZIP_VERSION_MAJOR, LASZIP_VERSION_MINOR, LASZIP_VERSION_REVISION, LASZIP_VERSION_BUILD_DATE, (I32)demzip_dll->header.point_data_format); + return 1; + } + } + else + { + // must *not* be set for the old point type 5 or lower + + demzip_dll->point.extended_point_type = 0; + + // we are *not* operating in compatibility mode + + demzip_dll->compatibility_mode = FALSE; + } + + return 0; +} + +/*---------------------------------------------------------------------------*/ +static I32 +demzip_prepare_vlrs_for_write( + demzip_dll_struct* demzip_dll +) +{ + U32 i, vlrs_size = 0; + + if (demzip_dll->header.number_of_variable_length_records) + { + if (demzip_dll->header.vlrs == 0) + { + sprintf(demzip_dll->error, "number_of_variable_length_records is %u but vlrs pointer is zero", demzip_dll->header.number_of_variable_length_records); + return 1; + } + + for (i = 0; i < demzip_dll->header.number_of_variable_length_records; i++) + { + vlrs_size += 54; + if (demzip_dll->header.vlrs[i].record_length_after_header) + { + if (demzip_dll->header.vlrs == 0) + { + sprintf(demzip_dll->error, "vlrs[%u].record_length_after_header is %u but vlrs[%u].data pointer is zero", i, demzip_dll->header.vlrs[i].record_length_after_header, i); + return 1; + } + vlrs_size += demzip_dll->header.vlrs[i].record_length_after_header; + } + } + } + + if ((vlrs_size + demzip_dll->header.header_size + demzip_dll->header.user_data_after_header_size) != demzip_dll->header.offset_to_point_data) + { + sprintf(demzip_dll->error,"header_size (%u) plus vlrs_size (%u) plus user_data_after_header_size (%u) does not equal offset_to_point_data (%u)", (U32)demzip_dll->header.header_size, vlrs_size, demzip_dll->header.user_data_after_header_size, demzip_dll->header.offset_to_point_data); + return 1; + } + + return 0; +} + +/*---------------------------------------------------------------------------*/ +static U32 +demzip_vrl_payload_size( + const LASzip* laszip +) +{ + return 34 + (6 * laszip->num_items); +} + +/*---------------------------------------------------------------------------*/ +static I32 +write_demzip_vlr_header( + demzip_dll_struct* demzip_dll + , const LASzip* laszip + , ByteStreamOut* out +) +{ + // write the LASzip VLR header + + U16 reserved = 0x0; + try { out->put16bitsLE((U8*)&reserved); } catch(...) + { + sprintf(demzip_dll->error, "writing LASzip VLR header.reserved"); + return 1; + } + U8 user_id[16] = "laszip encoded\0"; + try { out->putBytes((U8*)user_id, 16); } catch(...) + { + sprintf(demzip_dll->error, "writing LASzip VLR header.user_id"); + return 1; + } + U16 record_id = 22204; + try { out->put16bitsLE((U8*)&record_id); } catch(...) + { + sprintf(demzip_dll->error, "writing LASzip VLR header.record_id"); + return 1; + } + U16 record_length_after_header = (U16)demzip_vrl_payload_size(laszip); + try { out->put16bitsLE((U8*)&record_length_after_header); } catch(...) + { + sprintf(demzip_dll->error, "writing LASzip VLR header.record_length_after_header"); + return 1; + } + CHAR description[32]; + memset(description, 0, 32); + sprintf(description, "LASzip DLL %d.%d r%d (%d)", LASZIP_VERSION_MAJOR, LASZIP_VERSION_MINOR, LASZIP_VERSION_REVISION, LASZIP_VERSION_BUILD_DATE); + try { out->putBytes((U8*)description, 32); } catch(...) + { + sprintf(demzip_dll->error, "writing LASzip VLR header.description"); + return 1; + } + + return 0; +} + +/*---------------------------------------------------------------------------*/ +static I32 +write_demzip_vlr_payload( + demzip_dll_struct* demzip_dll + , const LASzip* laszip + , ByteStreamOut* out +) +{ + // write the LASzip VLR payload + + // U16 compressor 2 bytes + // U32 coder 2 bytes + // U8 version_major 1 byte + // U8 version_minor 1 byte + // U16 version_revision 2 bytes + // U32 options 4 bytes + // I32 chunk_size 4 bytes + // I64 number_of_special_evlrs 8 bytes + // I64 offset_to_special_evlrs 8 bytes + // U16 num_items 2 bytes + // U16 type 2 bytes * num_items + // U16 size 2 bytes * num_items + // U16 version 2 bytes * num_items + // which totals 34+6*num_items + + try { out->put16bitsLE((const U8*)&(laszip->compressor)); } catch(...) + { + sprintf(demzip_dll->error, "writing compressor %d", (I32)laszip->compressor); + return 1; + } + try { out->put16bitsLE((const U8*)&(laszip->coder)); } catch(...) + { + sprintf(demzip_dll->error, "writing coder %d", (I32)laszip->coder); + return 1; + } + try { out->putBytes((const U8*)&(laszip->version_major), 1); } catch(...) + { + sprintf(demzip_dll->error, "writing version_major %d", (I32)laszip->version_major); + return 1; + } + try { out->putBytes((const U8*)&(laszip->version_minor), 1); } catch(...) + { + sprintf(demzip_dll->error, "writing version_minor %d", (I32)laszip->version_minor); + return 1; + } + try { out->put16bitsLE((const U8*)&(laszip->version_revision)); } catch(...) + { + sprintf(demzip_dll->error, "writing version_revision %d", (I32)laszip->version_revision); + return 1; + } + try { out->put32bitsLE((const U8*)&(laszip->options)); } catch(...) + { + sprintf(demzip_dll->error, "writing options %u", laszip->options); + return 1; + } + try { out->put32bitsLE((const U8*)&(laszip->chunk_size)); } catch(...) + { + sprintf(demzip_dll->error, "writing chunk_size %u", laszip->chunk_size); + return 1; + } + try { out->put64bitsLE((const U8*)&(laszip->number_of_special_evlrs)); } catch(...) + { + sprintf(demzip_dll->error, "writing number_of_special_evlrs %d", (I32)laszip->number_of_special_evlrs); + return 1; + } + try { out->put64bitsLE((const U8*)&(laszip->offset_to_special_evlrs)); } catch(...) + { + sprintf(demzip_dll->error, "writing offset_to_special_evlrs %d", (I32)laszip->offset_to_special_evlrs); + return 1; + } + try { out->put16bitsLE((const U8*)&(laszip->num_items)); } catch(...) + { + sprintf(demzip_dll->error, "writing num_items %d", (I32)laszip->num_items); + return 1; + } + + U32 j; + for (j = 0; j < laszip->num_items; j++) + { + U16 type = (U16)(laszip->items[j].type); + try { out->put16bitsLE((const U8*)&type); } catch(...) + { + sprintf(demzip_dll->error, "writing type %d of item %d", (I32)laszip->items[j].type, j); + return 1; + } + try { out->put16bitsLE((const U8*)&(laszip->items[j].size)); } catch(...) + { + sprintf(demzip_dll->error, "writing size %d of item %d", (I32)laszip->items[j].size, j); + return 1; + } + try { out->put16bitsLE((const U8*)&(laszip->items[j].version)); } catch(...) + { + sprintf(demzip_dll->error, "writing version %d of item %d", (I32)laszip->items[j].version, j); + return 1; + } + } + return 0; +} + +/*---------------------------------------------------------------------------*/ +static I32 +demzip_write_header( + demzip_dll_struct* demzip_dll + , const LASzip* laszip + , const demzip_BOOL compress +) +{ + U32 i; + + try { demzip_dll->streamout->putBytes((const U8*)"LASF", 4); } catch(...) + { + sprintf(demzip_dll->error, "writing header.file_signature"); + return 1; + } + try { demzip_dll->streamout->put16bitsLE((const U8*)&(demzip_dll->header.file_source_ID)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.file_source_ID"); + return 1; + } + try { demzip_dll->streamout->put16bitsLE((const U8*)&(demzip_dll->header.global_encoding)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.global_encoding"); + return 1; + } + try { demzip_dll->streamout->put32bitsLE((const U8*)&(demzip_dll->header.project_ID_GUID_data_1)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.project_ID_GUID_data_1"); + return 1; + } + try { demzip_dll->streamout->put16bitsLE((const U8*)&(demzip_dll->header.project_ID_GUID_data_2)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.project_ID_GUID_data_2"); + return 1; + } + try { demzip_dll->streamout->put16bitsLE((const U8*)&(demzip_dll->header.project_ID_GUID_data_3)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.project_ID_GUID_data_3"); + return 1; + } + try { demzip_dll->streamout->putBytes((const U8*)demzip_dll->header.project_ID_GUID_data_4, 8); } catch(...) + { + sprintf(demzip_dll->error, "writing header.project_ID_GUID_data_4"); + return 1; + } + try { demzip_dll->streamout->putBytes((const U8*)&(demzip_dll->header.version_major), 1); } catch(...) + { + sprintf(demzip_dll->error, "writing header.version_major"); + return 1; + } + try { demzip_dll->streamout->putBytes((const U8*)&(demzip_dll->header.version_minor), 1); } catch(...) + { + sprintf(demzip_dll->error, "writing header.version_minor"); + return 1; + } + try { demzip_dll->streamout->putBytes((const U8*)demzip_dll->header.system_identifier, 32); } catch(...) + { + sprintf(demzip_dll->error, "writing header.system_identifier"); + return 1; + } + if (!demzip_dll->preserve_generating_software) + { + memset(demzip_dll->header.generating_software, 0, 32); + sprintf(demzip_dll->header.generating_software, "LASzip DLL %d.%d r%d (%d)", LASZIP_VERSION_MAJOR, LASZIP_VERSION_MINOR, LASZIP_VERSION_REVISION, LASZIP_VERSION_BUILD_DATE); + } + try { demzip_dll->streamout->putBytes((const U8*)demzip_dll->header.generating_software, 32); } catch(...) + { + sprintf(demzip_dll->error, "writing header.generating_software"); + return 1; + } + try { demzip_dll->streamout->put16bitsLE((const U8*)&(demzip_dll->header.file_creation_day)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.file_creation_day"); + return 1; + } + try { demzip_dll->streamout->put16bitsLE((const U8*)&(demzip_dll->header.file_creation_year)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.file_creation_year"); + return 1; + } + try { demzip_dll->streamout->put16bitsLE((const U8*)&(demzip_dll->header.header_size)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.header_size"); + return 1; + } + if (compress) + { + demzip_dll->header.offset_to_point_data += (54 + demzip_vrl_payload_size(laszip)); + } + try { demzip_dll->streamout->put32bitsLE((const U8*)&(demzip_dll->header.offset_to_point_data)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.offset_to_point_data"); + return 1; + } + if (compress) + { + demzip_dll->header.offset_to_point_data -= (54 + demzip_vrl_payload_size(laszip)); + demzip_dll->header.number_of_variable_length_records += 1; + } + try { demzip_dll->streamout->put32bitsLE((const U8*)&(demzip_dll->header.number_of_variable_length_records)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.number_of_variable_length_records"); + return 1; + } + if (compress) + { + demzip_dll->header.number_of_variable_length_records -= 1; + demzip_dll->header.point_data_format |= 128; + } + try { demzip_dll->streamout->putBytes((const U8*)&(demzip_dll->header.point_data_format), 1); } catch(...) + { + sprintf(demzip_dll->error, "writing header.point_data_format"); + return 1; + } + if (compress) + { + demzip_dll->header.point_data_format &= 127; + } + try { demzip_dll->streamout->put16bitsLE((const U8*)&(demzip_dll->header.point_data_record_length)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.point_data_record_length"); + return 1; + } + try { demzip_dll->streamout->put32bitsLE((const U8*)&(demzip_dll->header.number_of_point_records)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.number_of_point_records"); + return 1; + } + for (i = 0; i < 5; i++) + { + try { demzip_dll->streamout->put32bitsLE((const U8*)&(demzip_dll->header.number_of_points_by_return[i])); } catch(...) + { + sprintf(demzip_dll->error, "writing header.number_of_points_by_return %d", i); + return 1; + } + } + try { demzip_dll->streamout->put64bitsLE((const U8*)&(demzip_dll->header.x_scale_factor)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.x_scale_factor"); + return 1; + } + try { demzip_dll->streamout->put64bitsLE((const U8*)&(demzip_dll->header.y_scale_factor)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.y_scale_factor"); + return 1; + } + try { demzip_dll->streamout->put64bitsLE((const U8*)&(demzip_dll->header.z_scale_factor)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.z_scale_factor"); + return 1; + } + try { demzip_dll->streamout->put64bitsLE((const U8*)&(demzip_dll->header.x_offset)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.x_offset"); + return 1; + } + try { demzip_dll->streamout->put64bitsLE((const U8*)&(demzip_dll->header.y_offset)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.y_offset"); + return 1; + } + try { demzip_dll->streamout->put64bitsLE((const U8*)&(demzip_dll->header.z_offset)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.z_offset"); + return 1; + } + try { demzip_dll->streamout->put64bitsLE((const U8*)&(demzip_dll->header.max_x)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.max_x"); + return 1; + } + try { demzip_dll->streamout->put64bitsLE((const U8*)&(demzip_dll->header.min_x)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.min_x"); + return 1; + } + try { demzip_dll->streamout->put64bitsLE((const U8*)&(demzip_dll->header.max_y)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.max_y"); + return 1; + } + try { demzip_dll->streamout->put64bitsLE((const U8*)&(demzip_dll->header.min_y)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.min_y"); + return 1; + } + try { demzip_dll->streamout->put64bitsLE((const U8*)&(demzip_dll->header.max_z)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.max_z"); + return 1; + } + try { demzip_dll->streamout->put64bitsLE((const U8*)&(demzip_dll->header.min_z)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.min_z"); + return 1; + } + + // special handling for LAS 1.3 + if ((demzip_dll->header.version_major == 1) && (demzip_dll->header.version_minor >= 3)) + { + if (demzip_dll->header.header_size < 235) + { + sprintf(demzip_dll->error, "for LAS 1.%d header_size should at least be 235 but it is only %d", demzip_dll->header.version_minor, demzip_dll->header.header_size); + return 1; + } + else + { + if (demzip_dll->header.start_of_waveform_data_packet_record != 0) + { +#ifdef _WIN32 + sprintf(demzip_dll->warning, "header.start_of_waveform_data_packet_record is %I64d. writing 0 instead.", demzip_dll->header.start_of_waveform_data_packet_record); +#else + sprintf(demzip_dll->warning, "header.start_of_waveform_data_packet_record is %llu. writing 0 instead.", demzip_dll->header.start_of_waveform_data_packet_record); +#endif + demzip_dll->header.start_of_waveform_data_packet_record = 0; + } + try { demzip_dll->streamout->put64bitsLE((const U8*)&(demzip_dll->header.start_of_waveform_data_packet_record)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.start_of_waveform_data_packet_record"); + return 1; + } + demzip_dll->header.user_data_in_header_size = demzip_dll->header.header_size - 235; + } + } + else + { + demzip_dll->header.user_data_in_header_size = demzip_dll->header.header_size - 227; + } + + // special handling for LAS 1.4 + if ((demzip_dll->header.version_major == 1) && (demzip_dll->header.version_minor >= 4)) + { + if (demzip_dll->header.header_size < 375) + { + sprintf(demzip_dll->error, "for LAS 1.%d header_size should at least be 375 but it is only %d", demzip_dll->header.version_minor, demzip_dll->header.header_size); + return 1; + } + else + { + try { demzip_dll->streamout->put64bitsLE((const U8*)&(demzip_dll->header.start_of_first_extended_variable_length_record)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.start_of_first_extended_variable_length_record"); + return 1; + } + try { demzip_dll->streamout->put32bitsLE((const U8*)&(demzip_dll->header.number_of_extended_variable_length_records)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.number_of_extended_variable_length_records"); + return 1; + } + try { demzip_dll->streamout->put64bitsLE((const U8*)&(demzip_dll->header.extended_number_of_point_records)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.extended_number_of_point_records"); + return 1; + } + for (i = 0; i < 15; i++) + { + try { demzip_dll->streamout->put64bitsLE((const U8*)&(demzip_dll->header.extended_number_of_points_by_return[i])); } catch(...) + { + sprintf(demzip_dll->error, "writing header.extended_number_of_points_by_return[%d]", i); + return 1; + } + } + demzip_dll->header.user_data_in_header_size = demzip_dll->header.header_size - 375; + } + } + + // write any number of user-defined bytes that might have been added to the header + if (demzip_dll->header.user_data_in_header_size) + { + try { demzip_dll->streamout->putBytes((const U8*)demzip_dll->header.user_data_in_header, demzip_dll->header.user_data_in_header_size); } catch(...) + { + sprintf(demzip_dll->error, "writing %d bytes of data into header.user_data_in_header", demzip_dll->header.user_data_in_header_size); + return 1; + } + } + + // write variable length records into the header + + if (demzip_dll->header.number_of_variable_length_records) + { + U32 i; + + for (i = 0; i < demzip_dll->header.number_of_variable_length_records; i++) + { + // write variable length records variable after variable (to avoid alignment issues) + + try { demzip_dll->streamout->put16bitsLE((const U8*)&(demzip_dll->header.vlrs[i].reserved)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.vlrs[%d].reserved", i); + return 1; + } + + try { demzip_dll->streamout->putBytes((const U8*)demzip_dll->header.vlrs[i].user_id, 16); } catch(...) + { + sprintf(demzip_dll->error, "writing header.vlrs[%d].user_id", i); + return 1; + } + try { demzip_dll->streamout->put16bitsLE((const U8*)&(demzip_dll->header.vlrs[i].record_id)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.vlrs[%d].record_id", i); + return 1; + } + try { demzip_dll->streamout->put16bitsLE((const U8*)&(demzip_dll->header.vlrs[i].record_length_after_header)); } catch(...) + { + sprintf(demzip_dll->error, "writing header.vlrs[%d].record_length_after_header", i); + return 1; + } + try { demzip_dll->streamout->putBytes((const U8*)demzip_dll->header.vlrs[i].description, 32); } catch(...) + { + sprintf(demzip_dll->error, "writing header.vlrs[%d].description", i); + return 1; + } + + // write data following the header of the variable length record + + if (demzip_dll->header.vlrs[i].record_length_after_header) + { + try { demzip_dll->streamout->putBytes(demzip_dll->header.vlrs[i].data, demzip_dll->header.vlrs[i].record_length_after_header); } catch(...) + { + sprintf(demzip_dll->error, "writing %d bytes of data into header.vlrs[%d].data", demzip_dll->header.vlrs[i].record_length_after_header, i); + return 1; + } + } + } + } + + if (compress) + { + // write the LASzip VLR header + + if (write_demzip_vlr_header(demzip_dll, laszip, demzip_dll->streamout)) + { + return 1; + } + + // write the LASzip VLR payload + + if (write_demzip_vlr_payload(demzip_dll, laszip, demzip_dll->streamout)) + { + return 1; + } + } + + // write any number of user-defined bytes that might have been added after the header + + if (demzip_dll->header.user_data_after_header_size) + { + try { demzip_dll->streamout->putBytes((const U8*)demzip_dll->header.user_data_after_header, demzip_dll->header.user_data_after_header_size); } catch(...) + { + sprintf(demzip_dll->error, "writing %u bytes of data into header.user_data_after_header", demzip_dll->header.user_data_after_header_size); + return 1; + } + } + + return 0; +} + +/*----------------------------------------------------------------------------*/ +demzip_I32 create_point_writer +( + demzip_dll_struct *demzip_dll + , const LASzip *laszip +) +{ + // create the point writer + demzip_dll->writer = new LASwritePoint(); + if (demzip_dll->writer == 0) + { + sprintf(demzip_dll->error, "could not alloc LASwritePoint"); + return 1; + } + + if (!demzip_dll->writer->setup(laszip->num_items, laszip->items, laszip)) + { + sprintf(demzip_dll->error, "setup of LASwritePoint failed"); + return 1; + } + + if (!demzip_dll->writer->init(demzip_dll->streamout)) + { + sprintf(demzip_dll->error, "init of LASwritePoint failed"); + return 1; + } + + return 0; +} + +/*---------------------------------------------------------------------------*/ +static I32 +setup_demzip_items( + demzip_dll_struct* demzip_dll + , LASzip* laszip + , demzip_BOOL compress +) +{ + demzip_U8 point_type = demzip_dll->header.point_data_format; + demzip_U16 point_size = demzip_dll->header.point_data_record_length; + + if ((point_type > 5) && demzip_dll->request_compatibility_mode) + { + if (!laszip->request_compatibility_mode(1)) + { + sprintf(demzip_dll->error, "requesting 'compatibility mode' has failed"); + return 1; + } + } + + // create point items in the LASzip structure from point format and size + + if (!laszip->setup(point_type, point_size, LASZIP_COMPRESSOR_NONE)) + { + sprintf(demzip_dll->error, "invalid combination of point_type %d and point_size %d", (I32)point_type, (I32)point_size); + return 1; + } + + // compute offsets (or points item pointers) for data transfer from the point items + + if (demzip_dll->point_items) + { + delete [] demzip_dll->point_items; + } + + demzip_dll->point_items = new U8*[laszip->num_items]; + + if (demzip_dll->point_items == 0) + { + sprintf(demzip_dll->error, "could not alloc point_items"); + return 1; + } + + for (size_t i = 0; i < laszip->num_items; i++) + { + switch (laszip->items[i].type) + { + case LASitem::POINT10: + case LASitem::POINT14: + demzip_dll->point_items[i] = (U8*)&(demzip_dll->point.X); + break; + case LASitem::GPSTIME11: + demzip_dll->point_items[i] = (U8*)&(demzip_dll->point.gps_time); + break; + case LASitem::RGB12: + case LASitem::RGB14: + case LASitem::RGBNIR14: + demzip_dll->point_items[i] = (U8*)demzip_dll->point.rgb; + break; + case LASitem::BYTE: + case LASitem::BYTE14: + demzip_dll->point.num_extra_bytes = laszip->items[i].size; + if (demzip_dll->point.extra_bytes) delete [] demzip_dll->point.extra_bytes; + demzip_dll->point.extra_bytes = new U8[demzip_dll->point.num_extra_bytes]; + demzip_dll->point_items[i] = demzip_dll->point.extra_bytes; + break; + case LASitem::WAVEPACKET13: + case LASitem::WAVEPACKET14: + demzip_dll->point_items[i] = (U8*)&(demzip_dll->point.wave_packet); + break; + default: + sprintf(demzip_dll->error, "unknown LASitem type %d", (I32)laszip->items[i].type); + return 1; + } + } + + if (compress) + { + if ((point_type > 5) && demzip_dll->request_native_extension) + { + if (!laszip->setup(point_type, point_size, LASZIP_COMPRESSOR_LAYERED_CHUNKED)) + { + sprintf(demzip_dll->error, "cannot compress point_type %d with point_size %d using native", (I32)point_type, (I32)point_size); + return 1; + } + } + else + { + if (!laszip->setup(point_type, point_size, LASZIP_COMPRESSOR_DEFAULT)) + { + sprintf(demzip_dll->error, "cannot compress point_type %d with point_size %d", (I32)point_type, (I32)point_size); + return 1; + } + } + + // request version (old point types only, new point types always use version 3) + + laszip->request_version(2); + + // maybe we should change the chunk size + + if (demzip_dll->set_chunk_size != LASZIP_CHUNK_SIZE_DEFAULT) + { + if (!laszip->set_chunk_size(demzip_dll->set_chunk_size)) + { + sprintf(demzip_dll->error, "setting chunk size %d has failed", demzip_dll->set_chunk_size); + return 1; + } + } + } + else + { + laszip->request_version(0); + } + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_open_writer( + demzip_POINTER pointer + , const demzip_CHAR* file_name + , demzip_BOOL compress +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (file_name == 0) + { + sprintf(demzip_dll->error, "demzip_CHAR pointer 'file_name' is zero"); + return 1; + } + + if (demzip_dll->reader) + { + sprintf(demzip_dll->error, "reader is already open"); + return 1; + } + + if (demzip_dll->writer) + { + sprintf(demzip_dll->error, "writer is already open"); + return 1; + } + + // open the file + + demzip_dll->file = fopen(file_name, "wb"); + + if (demzip_dll->file == 0) + { + sprintf(demzip_dll->error, "cannot open file '%s'", file_name); + return 1; + } + + if (setvbuf(demzip_dll->file, NULL, _IOFBF, 262144) != 0) + { + sprintf(demzip_dll->warning, "setvbuf() failed with buffer size 262144\n"); + } + + // create the outstream + + if (IS_LITTLE_ENDIAN()) + demzip_dll->streamout = new ByteStreamOutFileLE(demzip_dll->file); + else + demzip_dll->streamout = new ByteStreamOutFileBE(demzip_dll->file); + + if (demzip_dll->streamout == 0) + { + sprintf(demzip_dll->error, "could not alloc ByteStreamOutFile"); + return 1; + } + + // setup the items that make up the point + + LASzip laszip; + if (setup_demzip_items(demzip_dll, &laszip, compress)) + { + return 1; + } + + // prepare header + + if (demzip_prepare_header_for_write(demzip_dll)) + { + return 1; + } + + // prepare point + + if (demzip_prepare_point_for_write(demzip_dll, compress)) + { + return 1; + } + + // prepare VLRs + + if (demzip_prepare_vlrs_for_write(demzip_dll)) + { + return 1; + } + + // write header variable after variable + + if (demzip_write_header(demzip_dll, &laszip, compress)) + { + return 1; + } + + // create the point writer + + if (create_point_writer(demzip_dll, &laszip)) + { + return 1; + } + + if (demzip_dll->lax_create) + { + // create spatial indexing information using cell_size = 100.0f and threshold = 1000 + + LASquadtree* lasquadtree = new LASquadtree; + lasquadtree->setup(demzip_dll->header.min_x, demzip_dll->header.max_x, demzip_dll->header.min_y, demzip_dll->header.max_y, 100.0f); + + demzip_dll->lax_index = new LASindex; + demzip_dll->lax_index->prepare(lasquadtree, 1000); + + // copy the file name for later + + demzip_dll->lax_file_name = LASCopyString(file_name); + } + + // set the point number and point count + + demzip_dll->npoints = (demzip_dll->header.number_of_point_records ? demzip_dll->header.number_of_point_records : demzip_dll->header.extended_number_of_point_records); + demzip_dll->p_count = 0; + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_open_writer '%s'", file_name); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_write_point( + demzip_POINTER pointer +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + // temporary fix to avoid corrupt LAZ files + + if (demzip_dll->point.extended_point_type) + { + // make sure legacy flags and extended flags are identical + if ((demzip_dll->point.extended_classification_flags & 0x7) != ((((U8*)&(demzip_dll->point.intensity))[3]) >> 5)) + { + sprintf(demzip_dll->error, "legacy flags and extended flags are not identical"); + return 1; + } + + // make sure legacy classification is zero or identical to extended classification + if (demzip_dll->point.classification != 0) + { + if (demzip_dll->point.classification != demzip_dll->point.extended_classification) + { + sprintf(demzip_dll->error, "legacy classification %d and extended classification %d are not consistent", demzip_dll->point.classification, demzip_dll->point.extended_classification); + return 1; + } + } + } + + // special recoding of points (in compatibility mode only) + + if (demzip_dll->compatibility_mode) + { + I32 scan_angle_remainder; + I32 number_of_returns_increment; + I32 return_number_increment; + I32 return_count_difference; + I32 overlap_bit; + I32 scanner_channel; + + // distill extended attributes + struct demzip_point* point = &demzip_dll->point; + + point->scan_angle_rank = I8_CLAMP(I16_QUANTIZE(0.006f*point->extended_scan_angle)); + scan_angle_remainder = point->extended_scan_angle - I16_QUANTIZE(((F32)point->scan_angle_rank)/0.006f); + if (point->extended_number_of_returns <= 7) + { + point->number_of_returns = point->extended_number_of_returns; + if (point->extended_return_number <= 7) + { + point->return_number = point->extended_return_number; + } + else + { + point->return_number = 7; + } + } + else + { + point->number_of_returns = 7; + if (point->extended_return_number <= 4) + { + point->return_number = point->extended_return_number; + } + else + { + return_count_difference = point->extended_number_of_returns - point->extended_return_number; + if (return_count_difference <= 0) + { + point->return_number = 7; + } + else if (return_count_difference >= 3) + { + point->return_number = 4; + } + else + { + point->return_number = 7 - return_count_difference; + } + } + } + return_number_increment = point->extended_return_number - point->return_number; + number_of_returns_increment = point->extended_number_of_returns - point->number_of_returns; + if (point->extended_classification > 31) + { + point->classification = 0; + } + else + { + point->extended_classification = 0; + } + scanner_channel = point->extended_scanner_channel; + overlap_bit = (point->extended_classification_flags >> 3); + + // write distilled extended attributes into extra bytes + + *((I16*)(point->extra_bytes + demzip_dll->start_scan_angle)) = ((I16)scan_angle_remainder); + point->extra_bytes[demzip_dll->start_extended_returns] = (U8)((return_number_increment << 4) | number_of_returns_increment); + point->extra_bytes[demzip_dll->start_classification] = (U8)(point->extended_classification); + point->extra_bytes[demzip_dll->start_flags_and_channel] = (U8)((scanner_channel << 1) | overlap_bit); + if (demzip_dll->start_NIR_band != -1) + { + *((U16*)(point->extra_bytes + demzip_dll->start_NIR_band)) = point->rgb[3]; + } + } + + // write the point + if (!demzip_dll->writer->write(demzip_dll->point_items)) + { +#ifdef _WIN32 + sprintf(demzip_dll->error, "writing point %I64d of %I64d total points", demzip_dll->p_count, demzip_dll->npoints); +#else + sprintf(demzip_dll->error, "writing point %lld of %lld total points", demzip_dll->p_count, demzip_dll->npoints); +#endif + return 1; + } + + demzip_dll->p_count++; + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_write_point"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_write_indexed_point( + demzip_POINTER pointer +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + // write the point + if (!demzip_dll->writer->write(demzip_dll->point_items)) + { +#ifdef _WIN32 + sprintf(demzip_dll->error, "writing point %I64d of %I64d total points", demzip_dll->p_count, demzip_dll->npoints); +#else + sprintf(demzip_dll->error, "writing point %lld of %lld total points", demzip_dll->p_count, demzip_dll->npoints); +#endif + return 1; + } + // index the point + F64 x = demzip_dll->header.x_scale_factor*demzip_dll->point.X+demzip_dll->header.x_offset; + F64 y = demzip_dll->header.y_scale_factor*demzip_dll->point.Y+demzip_dll->header.y_offset; + demzip_dll->lax_index->add(x, y, (U32)demzip_dll->p_count); + demzip_dll->p_count++; + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_write_indexed_point"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_update_inventory( + demzip_POINTER pointer +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (demzip_dll->inventory == 0) + { + demzip_dll->inventory = new demzip_dll_inventory; + } + + demzip_dll->inventory->add(&demzip_dll->point); + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_update_inventory"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_close_writer( + demzip_POINTER pointer +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (demzip_dll->writer == 0) + { + sprintf(demzip_dll->error, "closing writer before it was opened"); + return 1; + } + + if (!demzip_dll->writer->done()) + { + sprintf(demzip_dll->error, "done of LASwritePoint failed"); + return 1; + } + + delete demzip_dll->writer; + demzip_dll->writer = 0; + + delete [] demzip_dll->point_items; + demzip_dll->point_items = 0; + + // maybe update the header + + if (demzip_dll->inventory) + { + if (demzip_dll->header.point_data_format <= 5) // only update legacy counters for old point types + { + demzip_dll->streamout->seek(107); + if (!demzip_dll->streamout->put32bitsLE((const U8*)&(demzip_dll->inventory->number_of_point_records))) + { + sprintf(demzip_dll->error, "updating demzip_dll->inventory->number_of_point_records"); + return 1; + } + for (I32 i = 0; i < 5; i++) + { + if (!demzip_dll->streamout->put32bitsLE((const U8*)&(demzip_dll->inventory->number_of_points_by_return[i+1]))) + { + sprintf(demzip_dll->error, "updating demzip_dll->inventory->number_of_points_by_return[%d]\n", i); + return 1; + } + } + } + demzip_dll->streamout->seek(179); + F64 value; + value = demzip_dll->header.x_scale_factor*demzip_dll->inventory->max_X+demzip_dll->header.x_offset; + if (!demzip_dll->streamout->put64bitsLE((const U8*)&value)) + { + sprintf(demzip_dll->error, "updating demzip_dll->inventory->max_X"); + return 1; + } + value = demzip_dll->header.x_scale_factor*demzip_dll->inventory->min_X+demzip_dll->header.x_offset; + if (!demzip_dll->streamout->put64bitsLE((const U8*)&value)) + { + sprintf(demzip_dll->error, "updating demzip_dll->inventory->min_X"); + return 1; + } + value = demzip_dll->header.y_scale_factor*demzip_dll->inventory->max_Y+demzip_dll->header.y_offset; + if (!demzip_dll->streamout->put64bitsLE((const U8*)&value)) + { + sprintf(demzip_dll->error, "updating demzip_dll->inventory->max_Y"); + return 1; + } + value = demzip_dll->header.y_scale_factor*demzip_dll->inventory->min_Y+demzip_dll->header.y_offset; + if (!demzip_dll->streamout->put64bitsLE((const U8*)&value)) + { + sprintf(demzip_dll->error, "updating demzip_dll->inventory->min_Y"); + return 1; + } + value = demzip_dll->header.z_scale_factor*demzip_dll->inventory->max_Z+demzip_dll->header.z_offset; + if (!demzip_dll->streamout->put64bitsLE((const U8*)&value)) + { + sprintf(demzip_dll->error, "updating demzip_dll->inventory->max_Z"); + return 1; + } + value = demzip_dll->header.z_scale_factor*demzip_dll->inventory->min_Z+demzip_dll->header.z_offset; + if (!demzip_dll->streamout->put64bitsLE((const U8*)&value)) + { + sprintf(demzip_dll->error, "updating demzip_dll->inventory->min_Z"); + return 1; + } + if (demzip_dll->header.version_minor >= 4) // only update extended counters for LAS 1.4 + { + demzip_dll->streamout->seek(247); + I64 number = demzip_dll->inventory->number_of_point_records; + if (!demzip_dll->streamout->put64bitsLE((const U8*)&number)) + { + sprintf(demzip_dll->error, "updating demzip_dll->inventory->extended_number_of_point_records"); + return 1; + } + for (I32 i = 0; i < 15; i++) + { + number = demzip_dll->inventory->number_of_points_by_return[i+1]; + if (!demzip_dll->streamout->put64bitsLE((const U8*)&number)) + { + sprintf(demzip_dll->error, "updating demzip_dll->inventory->extended_number_of_points_by_return[%d]\n", i); + return 1; + } + } + } + demzip_dll->streamout->seekEnd(); + + delete demzip_dll->inventory; + demzip_dll->inventory = 0; + } + + if (demzip_dll->lax_index) + { + demzip_dll->lax_index->complete(100000, -20, FALSE); + + if (!demzip_dll->lax_index->write(demzip_dll->lax_file_name)) + { + sprintf(demzip_dll->error, "writing LAX file to '%s'", demzip_dll->lax_file_name); + return 1; + } + + free(demzip_dll->lax_file_name); + demzip_dll->lax_file_name = 0; + + delete demzip_dll->lax_index; + demzip_dll->lax_index = 0; + } + + delete demzip_dll->streamout; + demzip_dll->streamout = 0; + + if (demzip_dll->file) + { + fclose(demzip_dll->file); + demzip_dll->file = 0; + } + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_writer_close"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_exploit_spatial_index( + demzip_POINTER pointer + , const demzip_BOOL exploit +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (demzip_dll->reader) + { + sprintf(demzip_dll->error, "reader is already open"); + return 1; + } + + if (demzip_dll->writer) + { + sprintf(demzip_dll->error, "writer is already open"); + return 1; + } + + demzip_dll->lax_exploit = exploit; + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_exploit_spatial_index"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_decompress_selective( + demzip_POINTER pointer + , const demzip_U32 decompress_selective +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (demzip_dll->reader) + { + sprintf(demzip_dll->error, "reader is already open"); + return 1; + } + + if (demzip_dll->writer) + { + sprintf(demzip_dll->error, "writer is already open"); + return 1; + } + + demzip_dll->las14_decompress_selective = decompress_selective; + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_decompress_selective"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +static I32 +demzip_read_header( + demzip_dll_struct* demzip_dll + , demzip_BOOL* is_compressed +) +{ + U32 i; + + // read the header variable after variable + + CHAR file_signature[5]; + try { demzip_dll->streamin->getBytes((U8*)file_signature, 4); } catch(...) + { + sprintf(demzip_dll->error, "reading header.file_signature"); + return 1; + } + if (strncmp(file_signature, "LASF", 4) != 0) + { + sprintf(demzip_dll->error, "wrong file_signature. not a LAS/LAZ file."); + return 1; + } + try { demzip_dll->streamin->get16bitsLE((U8*)&(demzip_dll->header.file_source_ID)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.file_source_ID"); + return 1; + } + try { demzip_dll->streamin->get16bitsLE((U8*)&(demzip_dll->header.global_encoding)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.global_encoding"); + return 1; + } + try { demzip_dll->streamin->get32bitsLE((U8*)&(demzip_dll->header.project_ID_GUID_data_1)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.project_ID_GUID_data_1"); + return 1; + } + try { demzip_dll->streamin->get16bitsLE((U8*)&(demzip_dll->header.project_ID_GUID_data_2)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.project_ID_GUID_data_2"); + return 1; + } + try { demzip_dll->streamin->get16bitsLE((U8*)&(demzip_dll->header.project_ID_GUID_data_3)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.project_ID_GUID_data_3"); + return 1; + } + try { demzip_dll->streamin->getBytes((U8*)demzip_dll->header.project_ID_GUID_data_4, 8); } catch(...) + { + sprintf(demzip_dll->error, "reading header.project_ID_GUID_data_4"); + return 1; + } + try { demzip_dll->streamin->getBytes((U8*)&(demzip_dll->header.version_major), 1); } catch(...) + { + sprintf(demzip_dll->error, "reading header.version_major"); + return 1; + } + try { demzip_dll->streamin->getBytes((U8*)&(demzip_dll->header.version_minor), 1); } catch(...) + { + sprintf(demzip_dll->error, "reading header.version_minor"); + return 1; + } + try { demzip_dll->streamin->getBytes((U8*)demzip_dll->header.system_identifier, 32); } catch(...) + { + sprintf(demzip_dll->error, "reading header.system_identifier"); + return 1; + } + try { demzip_dll->streamin->getBytes((U8*)demzip_dll->header.generating_software, 32); } catch(...) + { + sprintf(demzip_dll->error, "reading header.generating_software"); + return 1; + } + try { demzip_dll->streamin->get16bitsLE((U8*)&(demzip_dll->header.file_creation_day)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.file_creation_day"); + return 1; + } + try { demzip_dll->streamin->get16bitsLE((U8*)&(demzip_dll->header.file_creation_year)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.file_creation_year"); + return 1; + } + try { demzip_dll->streamin->get16bitsLE((U8*)&(demzip_dll->header.header_size)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.header_size"); + return 1; + } + try { demzip_dll->streamin->get32bitsLE((U8*)&(demzip_dll->header.offset_to_point_data)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.offset_to_point_data"); + return 1; + } + try { demzip_dll->streamin->get32bitsLE((U8*)&(demzip_dll->header.number_of_variable_length_records)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.number_of_variable_length_records"); + return 1; + } + try { demzip_dll->streamin->getBytes((U8*)&(demzip_dll->header.point_data_format), 1); } catch(...) + { + sprintf(demzip_dll->error, "reading header.point_data_format"); + return 1; + } + try { demzip_dll->streamin->get16bitsLE((U8*)&(demzip_dll->header.point_data_record_length)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.point_data_record_length"); + return 1; + } + try { demzip_dll->streamin->get32bitsLE((U8*)&(demzip_dll->header.number_of_point_records)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.number_of_point_records"); + return 1; + } + for (i = 0; i < 5; i++) + { + try { demzip_dll->streamin->get32bitsLE((U8*)&(demzip_dll->header.number_of_points_by_return[i])); } catch(...) + { + sprintf(demzip_dll->error, "reading header.number_of_points_by_return %d", i); + return 1; + } + } + try { demzip_dll->streamin->get64bitsLE((U8*)&(demzip_dll->header.x_scale_factor)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.x_scale_factor"); + return 1; + } + try { demzip_dll->streamin->get64bitsLE((U8*)&(demzip_dll->header.y_scale_factor)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.y_scale_factor"); + return 1; + } + try { demzip_dll->streamin->get64bitsLE((U8*)&(demzip_dll->header.z_scale_factor)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.z_scale_factor"); + return 1; + } + try { demzip_dll->streamin->get64bitsLE((U8*)&(demzip_dll->header.x_offset)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.x_offset"); + return 1; + } + try { demzip_dll->streamin->get64bitsLE((U8*)&(demzip_dll->header.y_offset)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.y_offset"); + return 1; + } + try { demzip_dll->streamin->get64bitsLE((U8*)&(demzip_dll->header.z_offset)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.z_offset"); + return 1; + } + try { demzip_dll->streamin->get64bitsLE((U8*)&(demzip_dll->header.max_x)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.max_x"); + return 1; + } + try { demzip_dll->streamin->get64bitsLE((U8*)&(demzip_dll->header.min_x)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.min_x"); + return 1; + } + try { demzip_dll->streamin->get64bitsLE((U8*)&(demzip_dll->header.max_y)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.max_y"); + return 1; + } + try { demzip_dll->streamin->get64bitsLE((U8*)&(demzip_dll->header.min_y)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.min_y"); + return 1; + } + try { demzip_dll->streamin->get64bitsLE((U8*)&(demzip_dll->header.max_z)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.max_z"); + return 1; + } + try { demzip_dll->streamin->get64bitsLE((U8*)&(demzip_dll->header.min_z)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.min_z"); + return 1; + } + + // special handling for LAS 1.3 + if ((demzip_dll->header.version_major == 1) && (demzip_dll->header.version_minor >= 3)) + { + if (demzip_dll->header.header_size < 235) + { + sprintf(demzip_dll->error, "for LAS 1.%d header_size should at least be 235 but it is only %d", demzip_dll->header.version_minor, demzip_dll->header.header_size); + return 1; + } + else + { + try { demzip_dll->streamin->get64bitsLE((U8*)&(demzip_dll->header.start_of_waveform_data_packet_record)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.start_of_waveform_data_packet_record"); + return 1; + } + demzip_dll->header.user_data_in_header_size = demzip_dll->header.header_size - 235; + } + } + else + { + demzip_dll->header.user_data_in_header_size = demzip_dll->header.header_size - 227; + } + + // special handling for LAS 1.4 + if ((demzip_dll->header.version_major == 1) && (demzip_dll->header.version_minor >= 4)) + { + if (demzip_dll->header.header_size < 375) + { + sprintf(demzip_dll->error, "for LAS 1.%d header_size should at least be 375 but it is only %d", demzip_dll->header.version_minor, demzip_dll->header.header_size); + return 1; + } + else + { + try { demzip_dll->streamin->get64bitsLE((U8*)&(demzip_dll->header.start_of_first_extended_variable_length_record)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.start_of_first_extended_variable_length_record"); + return 1; + } + try { demzip_dll->streamin->get32bitsLE((U8*)&(demzip_dll->header.number_of_extended_variable_length_records)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.number_of_extended_variable_length_records"); + return 1; + } + try { demzip_dll->streamin->get64bitsLE((U8*)&(demzip_dll->header.extended_number_of_point_records)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.extended_number_of_point_records"); + return 1; + } + for (i = 0; i < 15; i++) + { + try { demzip_dll->streamin->get64bitsLE((U8*)&(demzip_dll->header.extended_number_of_points_by_return[i])); } catch(...) + { + sprintf(demzip_dll->error, "reading header.extended_number_of_points_by_return[%d]", i); + return 1; + } + } + demzip_dll->header.user_data_in_header_size = demzip_dll->header.header_size - 375; + } + } + + // load any number of user-defined bytes that might have been added to the header + if (demzip_dll->header.user_data_in_header_size) + { + if (demzip_dll->header.user_data_in_header) + { + delete [] demzip_dll->header.user_data_in_header; + } + demzip_dll->header.user_data_in_header = new U8[demzip_dll->header.user_data_in_header_size]; + + try { demzip_dll->streamin->getBytes((U8*)demzip_dll->header.user_data_in_header, demzip_dll->header.user_data_in_header_size); } catch(...) + { + sprintf(demzip_dll->error, "reading %u bytes of data into header.user_data_in_header", demzip_dll->header.user_data_in_header_size); + return 1; + } + } + + // read variable length records into the header + + U32 vlrs_size = 0; + LASzip* laszip = 0; + + if (demzip_dll->header.number_of_variable_length_records) + { + U32 i; + + demzip_dll->header.vlrs = (demzip_vlr*)malloc(sizeof(demzip_vlr)*demzip_dll->header.number_of_variable_length_records); + + if (demzip_dll->header.vlrs == 0) + { + sprintf(demzip_dll->error, "allocating %u VLRs", demzip_dll->header.number_of_variable_length_records); + return 1; + } + + for (i = 0; i < demzip_dll->header.number_of_variable_length_records; i++) + { + // make sure there are enough bytes left to read a variable length record before the point block starts + + if (((int)demzip_dll->header.offset_to_point_data - vlrs_size - demzip_dll->header.header_size) < 54) + { + sprintf(demzip_dll->warning, "only %d bytes until point block after reading %d of %d vlrs. skipping remaining vlrs ...", (int)demzip_dll->header.offset_to_point_data - vlrs_size - demzip_dll->header.header_size, i, demzip_dll->header.number_of_variable_length_records); + demzip_dll->header.number_of_variable_length_records = i; + break; + } + + // read variable length records variable after variable (to avoid alignment issues) + + try { demzip_dll->streamin->get16bitsLE((U8*)&(demzip_dll->header.vlrs[i].reserved)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.vlrs[%u].reserved", i); + return 1; + } + + try { demzip_dll->streamin->getBytes((U8*)demzip_dll->header.vlrs[i].user_id, 16); } catch(...) + { + sprintf(demzip_dll->error, "reading header.vlrs[%u].user_id", i); + return 1; + } + try { demzip_dll->streamin->get16bitsLE((U8*)&(demzip_dll->header.vlrs[i].record_id)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.vlrs[%u].record_id", i); + return 1; + } + try { demzip_dll->streamin->get16bitsLE((U8*)&(demzip_dll->header.vlrs[i].record_length_after_header)); } catch(...) + { + sprintf(demzip_dll->error, "reading header.vlrs[%u].record_length_after_header", i); + return 1; + } + try { demzip_dll->streamin->getBytes((U8*)demzip_dll->header.vlrs[i].description, 32); } catch(...) + { + sprintf(demzip_dll->error, "reading header.vlrs[%u].description", i); + return 1; + } + + // keep track on the number of bytes we have read so far + + vlrs_size += 54; + + // check variable length record contents + + if ((demzip_dll->header.vlrs[i].reserved != 0xAABB) && (demzip_dll->header.vlrs[i].reserved != 0x0)) + { + sprintf(demzip_dll->warning,"wrong header.vlrs[%d].reserved: %d != 0xAABB and %d != 0x0", i, demzip_dll->header.vlrs[i].reserved, demzip_dll->header.vlrs[i].reserved); + } + + // make sure there are enough bytes left to read the data of the variable length record before the point block starts + + if (((int)demzip_dll->header.offset_to_point_data - vlrs_size - demzip_dll->header.header_size) < demzip_dll->header.vlrs[i].record_length_after_header) + { + sprintf(demzip_dll->warning, "only %d bytes until point block when trying to read %d bytes into header.vlrs[%d].data", (int)demzip_dll->header.offset_to_point_data - vlrs_size - demzip_dll->header.header_size, demzip_dll->header.vlrs[i].record_length_after_header, i); + demzip_dll->header.vlrs[i].record_length_after_header = (int)demzip_dll->header.offset_to_point_data - vlrs_size - demzip_dll->header.header_size; + } + + // load data following the header of the variable length record + + if (demzip_dll->header.vlrs[i].record_length_after_header) + { + if ((strcmp(demzip_dll->header.vlrs[i].user_id, "laszip encoded") == 0) && (demzip_dll->header.vlrs[i].record_id == 22204)) + { + if (laszip) + { + delete laszip; + } + + laszip = new LASzip(); + + if (laszip == 0) + { + sprintf(demzip_dll->error, "could not alloc LASzip"); + return 1; + } + + // read the LASzip VLR payload + + // U16 compressor 2 bytes + // U32 coder 2 bytes + // U8 version_major 1 byte + // U8 version_minor 1 byte + // U16 version_revision 2 bytes + // U32 options 4 bytes + // I32 chunk_size 4 bytes + // I64 number_of_special_evlrs 8 bytes + // I64 offset_to_special_evlrs 8 bytes + // U16 num_items 2 bytes + // U16 type 2 bytes * num_items + // U16 size 2 bytes * num_items + // U16 version 2 bytes * num_items + // which totals 34+6*num_items + + try { demzip_dll->streamin->get16bitsLE((U8*)&(laszip->compressor)); } catch(...) + { + sprintf(demzip_dll->error, "reading compressor %d", (I32)laszip->compressor); + return 1; + } + try { demzip_dll->streamin->get16bitsLE((U8*)&(laszip->coder)); } catch(...) + { + sprintf(demzip_dll->error, "reading coder %d", (I32)laszip->coder); + return 1; + } + try { demzip_dll->streamin->getBytes((U8*)&(laszip->version_major), 1); } catch(...) + { + sprintf(demzip_dll->error, "reading version_major %d", (I32)laszip->version_major); + return 1; + } + try { demzip_dll->streamin->getBytes((U8*)&(laszip->version_minor), 1); } catch(...) + { + sprintf(demzip_dll->error, "reading version_minor %d", (I32)laszip->version_minor); + return 1; + } + try { demzip_dll->streamin->get16bitsLE((U8*)&(laszip->version_revision)); } catch(...) + { + sprintf(demzip_dll->error, "reading version_revision %d", (I32)laszip->version_revision); + return 1; + } + try { demzip_dll->streamin->get32bitsLE((U8*)&(laszip->options)); } catch(...) + { + sprintf(demzip_dll->error, "reading options %u", laszip->options); + return 1; + } + try { demzip_dll->streamin->get32bitsLE((U8*)&(laszip->chunk_size)); } catch(...) + { + sprintf(demzip_dll->error, "reading chunk_size %u", laszip->chunk_size); + return 1; + } + try { demzip_dll->streamin->get64bitsLE((U8*)&(laszip->number_of_special_evlrs)); } catch(...) + { + sprintf(demzip_dll->error, "reading number_of_special_evlrs %d", (I32)laszip->number_of_special_evlrs); + return 1; + } + try { demzip_dll->streamin->get64bitsLE((U8*)&(laszip->offset_to_special_evlrs)); } catch(...) + { + sprintf(demzip_dll->error, "reading offset_to_special_evlrs %d", (I32)laszip->offset_to_special_evlrs); + return 1; + } + try { demzip_dll->streamin->get16bitsLE((U8*)&(laszip->num_items)); } catch(...) + { + sprintf(demzip_dll->error, "reading num_items %d", (I32)laszip->num_items); + return 1; + } + laszip->items = new LASitem[laszip->num_items]; + U32 j; + for (j = 0; j < laszip->num_items; j++) + { + U16 type; + try { demzip_dll->streamin->get16bitsLE((U8*)&type); } catch(...) + { + sprintf(demzip_dll->error, "reading type of item %u", j); + return 1; + } + laszip->items[j].type = (LASitem::Type)type; + try { demzip_dll->streamin->get16bitsLE((U8*)&(laszip->items[j].size)); } catch(...) + { + sprintf(demzip_dll->error, "reading size of item %u", j); + return 1; + } + try { demzip_dll->streamin->get16bitsLE((U8*)&(laszip->items[j].version)); } catch(...) + { + sprintf(demzip_dll->error, "reading version of item %u", j); + return 1; + } + } + } + else + { + demzip_dll->header.vlrs[i].data = new U8[demzip_dll->header.vlrs[i].record_length_after_header]; + + try { demzip_dll->streamin->getBytes(demzip_dll->header.vlrs[i].data, demzip_dll->header.vlrs[i].record_length_after_header); } catch(...) + { + sprintf(demzip_dll->error, "reading %d bytes of data into header.vlrs[%u].data", (I32)demzip_dll->header.vlrs[i].record_length_after_header, i); + return 1; + } + } + } + else + { + demzip_dll->header.vlrs[i].data = 0; + } + + // keep track on the number of bytes we have read so far + + vlrs_size += demzip_dll->header.vlrs[i].record_length_after_header; + + // special handling for LASzip VLR + + if ((strcmp(demzip_dll->header.vlrs[i].user_id, "laszip encoded") == 0) && (demzip_dll->header.vlrs[i].record_id == 22204)) + { + // we take our the VLR for LASzip away + demzip_dll->header.offset_to_point_data -= (54+demzip_dll->header.vlrs[i].record_length_after_header); + vlrs_size -= (54+demzip_dll->header.vlrs[i].record_length_after_header); + i--; + demzip_dll->header.number_of_variable_length_records--; + // free or resize the VLR array + if (demzip_dll->header.number_of_variable_length_records == 0) + { + free(demzip_dll->header.vlrs); + demzip_dll->header.vlrs = 0; + } + else + { + demzip_dll->header.vlrs = (demzip_vlr*)realloc(demzip_dll->header.vlrs, sizeof(demzip_vlr)*demzip_dll->header.number_of_variable_length_records); + } + } + } + } + + // load any number of user-defined bytes that might have been added after the header + + demzip_dll->header.user_data_after_header_size = (I32)demzip_dll->header.offset_to_point_data - vlrs_size - demzip_dll->header.header_size; + if (demzip_dll->header.user_data_after_header_size) + { + if (demzip_dll->header.user_data_after_header) + { + delete [] demzip_dll->header.user_data_after_header; + } + demzip_dll->header.user_data_after_header = new U8[demzip_dll->header.user_data_after_header_size]; + + try { demzip_dll->streamin->getBytes((U8*)demzip_dll->header.user_data_after_header, demzip_dll->header.user_data_after_header_size); } catch(...) + { + sprintf(demzip_dll->error, "reading %u bytes of data into header.user_data_after_header", demzip_dll->header.user_data_after_header_size); + return 1; + } + } + + // remove extra bits in point data type + + if ((demzip_dll->header.point_data_format & 128) || (demzip_dll->header.point_data_format & 64)) + { + if (!laszip) + { + sprintf(demzip_dll->error, "this file was compressed with an experimental version of LASzip. contact 'martin.isenburg@rapidlasso.com' for assistance"); + return 1; + } + demzip_dll->header.point_data_format &= 127; + } + + // check if file is compressed + + if (laszip) + { + // yes. check the compressor state + *is_compressed = 1; + if (!laszip->check(demzip_dll->header.point_data_record_length)) + { + sprintf(demzip_dll->error, "%s upgrade to the latest release of LASzip or contact 'martin.isenburg@rapidlasso.com' for assistance", laszip->get_error()); + return 1; + } + } + else + { + // no. setup an un-compressed read + *is_compressed = 0; + laszip = new LASzip; + if (laszip == 0) + { + sprintf(demzip_dll->error, "could not alloc LASzip"); + return 1; + } + if (!laszip->setup(demzip_dll->header.point_data_format, demzip_dll->header.point_data_record_length, LASZIP_COMPRESSOR_NONE)) + { + sprintf(demzip_dll->error, "invalid combination of point_data_format %d and point_data_record_length %d", (I32)demzip_dll->header.point_data_format, (I32)demzip_dll->header.point_data_record_length); + return 1; + } + } + + // create point's item pointers + + if (demzip_dll->point_items) + { + delete [] demzip_dll->point_items; + } + + demzip_dll->point_items = new U8*[laszip->num_items]; + + if (demzip_dll->point_items == 0) + { + sprintf(demzip_dll->error, "could not alloc point_items"); + return 1; + } + + for (i = 0; i < laszip->num_items; i++) + { + switch (laszip->items[i].type) + { + case LASitem::POINT10: + case LASitem::POINT14: + demzip_dll->point_items[i] = (U8*)&(demzip_dll->point.X); + break; + case LASitem::GPSTIME11: + demzip_dll->point_items[i] = (U8*)&(demzip_dll->point.gps_time); + break; + case LASitem::RGB12: + case LASitem::RGB14: + case LASitem::RGBNIR14: + demzip_dll->point_items[i] = (U8*)demzip_dll->point.rgb; + break; + case LASitem::BYTE: + case LASitem::BYTE14: + demzip_dll->point.num_extra_bytes = laszip->items[i].size; + if (demzip_dll->point.extra_bytes) delete [] demzip_dll->point.extra_bytes; + demzip_dll->point.extra_bytes = new U8[demzip_dll->point.num_extra_bytes]; + demzip_dll->point_items[i] = demzip_dll->point.extra_bytes; + break; + case LASitem::WAVEPACKET13: + case LASitem::WAVEPACKET14: + demzip_dll->point_items[i] = (U8*)&(demzip_dll->point.wave_packet); + break; + default: + sprintf(demzip_dll->error, "unknown LASitem type %d", (I32)laszip->items[i].type); + return 1; + } + } + + // did the user request to recode the compatibility mode points? + + demzip_dll->compatibility_mode = FALSE; + + if (demzip_dll->request_compatibility_mode && (demzip_dll->header.version_minor < 4)) + { + // does this file contain compatibility mode recoded LAS 1.4 content + + struct demzip_vlr* compatibility_VLR = 0; + + if (demzip_dll->header.point_data_format == 1 || demzip_dll->header.point_data_format == 3 || demzip_dll->header.point_data_format == 4 || demzip_dll->header.point_data_format == 5) + { + // if we find the compatibility VLR + + for (i = 0; i < demzip_dll->header.number_of_variable_length_records; i++) + { + if ((strncmp(demzip_dll->header.vlrs[i].user_id, "lascompatible\0\0", 16) == 0) && (demzip_dll->header.vlrs[i].record_id == 22204)) + { + if (demzip_dll->header.vlrs[i].record_length_after_header == 2+2+4+148) + { + compatibility_VLR = &(demzip_dll->header.vlrs[i]); + break; + } + } + } + + if (compatibility_VLR) + { + // and we also find the extra bytes VLR with the right attributes + + LASattributer attributer; + for (i = 0; i < demzip_dll->header.number_of_variable_length_records; i++) + { + if ((strncmp(demzip_dll->header.vlrs[i].user_id, "LASF_Spec\0\0\0\0\0\0", 16) == 0) && (demzip_dll->header.vlrs[i].record_id == 4)) + { + attributer.init_attributes(demzip_dll->header.vlrs[i].record_length_after_header/192, (LASattribute*)demzip_dll->header.vlrs[i].data); + demzip_dll->start_scan_angle = attributer.get_attribute_start("LAS 1.4 scan angle"); + demzip_dll->start_extended_returns = attributer.get_attribute_start("LAS 1.4 extended returns"); + demzip_dll->start_classification = attributer.get_attribute_start("LAS 1.4 classification"); + demzip_dll->start_flags_and_channel = attributer.get_attribute_start("LAS 1.4 flags and channel"); + demzip_dll->start_NIR_band = attributer.get_attribute_start("LAS 1.4 NIR band"); + break; + } + } + + // can we do it ... ? + + if ((demzip_dll->start_scan_angle != -1) && (demzip_dll->start_extended_returns != -1) && (demzip_dll->start_classification != -1) && (demzip_dll->start_flags_and_channel != -1)) + { + // yes ... so let's fix the header (using the content from the compatibility VLR) + + ByteStreamInArray* in; + if (IS_LITTLE_ENDIAN()) + in = new ByteStreamInArrayLE(compatibility_VLR->data, compatibility_VLR->record_length_after_header); + else + in = new ByteStreamInArrayBE(compatibility_VLR->data, compatibility_VLR->record_length_after_header); + // read control info + U16 demzip_version; + in->get16bitsLE((U8*)&demzip_version); + U16 compatible_version; + in->get16bitsLE((U8*)&compatible_version); + U32 unused; + in->get32bitsLE((U8*)&unused); + // read the 148 bytes of the extended LAS 1.4 header + U64 start_of_waveform_data_packet_record; + in->get64bitsLE((U8*)&start_of_waveform_data_packet_record); + if (start_of_waveform_data_packet_record != 0) + { +#ifdef _WIN32 + fprintf(stderr,"WARNING: start_of_waveform_data_packet_record is %I64d. reading 0 instead.\n", start_of_waveform_data_packet_record); +#else + fprintf(stderr,"WARNING: start_of_waveform_data_packet_record is %llu. reading 0 instead.\n", start_of_waveform_data_packet_record); +#endif + } + demzip_dll->header.start_of_waveform_data_packet_record = 0; + U64 start_of_first_extended_variable_length_record; + in->get64bitsLE((U8*)&start_of_first_extended_variable_length_record); + if (start_of_first_extended_variable_length_record != 0) + { +#ifdef _WIN32 + fprintf(stderr,"WARNING: EVLRs not supported. start_of_first_extended_variable_length_record is %I64d. reading 0 instead.\n", start_of_first_extended_variable_length_record); +#else + fprintf(stderr,"WARNING: EVLRs not supported. start_of_first_extended_variable_length_record is %llu. reading 0 instead.\n", start_of_first_extended_variable_length_record); +#endif + } + demzip_dll->header.start_of_first_extended_variable_length_record = 0; + U32 number_of_extended_variable_length_records ; + in->get32bitsLE((U8*)&number_of_extended_variable_length_records); + if (number_of_extended_variable_length_records != 0) + { + fprintf(stderr,"WARNING: EVLRs not supported. number_of_extended_variable_length_records is %u. reading 0 instead.\n", number_of_extended_variable_length_records); + } + demzip_dll->header.number_of_extended_variable_length_records = 0; + U64 extended_number_of_point_records = 0; + in->get64bitsLE((U8*)&extended_number_of_point_records); + if (demzip_dll->header.number_of_point_records != 0 && ((U64)(demzip_dll->header.number_of_point_records)) != extended_number_of_point_records) + { +#ifdef _WIN32 + fprintf(stderr,"WARNING: number_of_point_records is %u. but extended_number_of_point_records is %I64u.\n", demzip_dll->header.number_of_point_records, extended_number_of_point_records); +#else + fprintf(stderr,"WARNING: number_of_point_records is %u. but extended_number_of_point_records is %llu.\n", demzip_dll->header.number_of_point_records, extended_number_of_point_records); +#endif + } + demzip_dll->header.extended_number_of_point_records = extended_number_of_point_records; + U64 extended_number_of_points_by_return; + for (U32 r = 0; r < 15; r++) + { + in->get64bitsLE((U8*)&extended_number_of_points_by_return); + if ((r < 5) && demzip_dll->header.number_of_points_by_return[r] != 0 && ((U64)(demzip_dll->header.number_of_points_by_return[r])) != extended_number_of_points_by_return) + { +#ifdef _WIN32 + fprintf(stderr,"WARNING: number_of_points_by_return[%u] is %u. but extended_number_of_points_by_return[%u] is %I64u.\n", r, demzip_dll->header.number_of_points_by_return[r], r, extended_number_of_points_by_return); +#else + fprintf(stderr,"WARNING: number_of_points_by_return[%u] is %u. but extended_number_of_points_by_return[%u] is %llu.\n", r, demzip_dll->header.number_of_points_by_return[r], r, extended_number_of_points_by_return); +#endif + } + demzip_dll->header.extended_number_of_points_by_return[r] = extended_number_of_points_by_return; + } + delete in; + + // remove the compatibility VLR + + if (demzip_remove_vlr(demzip_dll, "lascompatible\0\0", 22204)) + { + sprintf(demzip_dll->error, "removing the compatibility VLR"); + return 1; + } + + // remove the LAS 1.4 attributes from the "extra bytes" description + + if (demzip_dll->start_NIR_band != -1) attributer.remove_attribute("LAS 1.4 NIR band"); + attributer.remove_attribute("LAS 1.4 flags and channel"); + attributer.remove_attribute("LAS 1.4 classification"); + attributer.remove_attribute("LAS 1.4 extended returns"); + attributer.remove_attribute("LAS 1.4 scan angle"); + + // either rewrite or remove the "extra bytes" VLR + + if (attributer.number_attributes) + { + if (demzip_add_vlr(demzip_dll, "LASF_Spec\0\0\0\0\0\0", 4, (demzip_U16)(attributer.number_attributes*sizeof(LASattribute)), 0, (demzip_U8*)attributer.attributes)) + { + sprintf(demzip_dll->error, "rewriting the extra bytes VLR without 'LAS 1.4 compatibility mode' attributes"); + return 1; + } + } + else + { + if (demzip_remove_vlr(demzip_dll, "LASF_Spec\0\0\0\0\0\0", 4)) + { + sprintf(demzip_dll->error, "removing the LAS 1.4 attribute VLR"); + return 1; + } + } + + // upgrade to LAS 1.4 + if (demzip_dll->header.version_minor < 3) + { + // LAS 1.2 header is 148 bytes less than LAS 1.4+ header + demzip_dll->header.header_size += 148; + demzip_dll->header.offset_to_point_data += 148; + } + else + { + // LAS 1.3 header is 140 bytes less than LAS 1.4+ header + demzip_dll->header.header_size += 140; + demzip_dll->header.offset_to_point_data += 140; + } + demzip_dll->header.version_minor = 4; + + // maybe turn on the bit indicating the presence of the OGC WKT + for (i = 0; i < demzip_dll->header.number_of_variable_length_records; i++) + { + if ((strncmp(demzip_dll->header.vlrs[i].user_id, "LASF_Projection", 16) == 0) && (demzip_dll->header.vlrs[i].record_id == 2112)) + { + demzip_dll->header.global_encoding |= (1<<4); + break; + } + } + + // update point type and size + + demzip_dll->point.extended_point_type = 1; + + if (demzip_dll->header.point_data_format == 1) + { + demzip_dll->header.point_data_format = 6; + demzip_dll->header.point_data_record_length += (2 - 5); // record is 2 bytes larger but minus 5 extra bytes + } + else if (demzip_dll->header.point_data_format == 3) + { + if (demzip_dll->start_NIR_band == -1) + { + demzip_dll->header.point_data_format = 7; + demzip_dll->header.point_data_record_length += (2 - 5); // record is 2 bytes larger but minus 5 extra bytes + } + else + { + demzip_dll->header.point_data_format = 8; + demzip_dll->header.point_data_record_length += (4 - 7); // record is 4 bytes larger but minus 7 extra bytes + } + } + else + { + if (demzip_dll->start_NIR_band == -1) + { + demzip_dll->header.point_data_format = 9; + demzip_dll->header.point_data_record_length += (2 - 5); + } + else + { + demzip_dll->header.point_data_format = 10; + demzip_dll->header.point_data_record_length += (4 - 7); + } + } + + // we are operating in compatibility mode + + demzip_dll->compatibility_mode = TRUE; + } + } + } + } + else if (demzip_dll->header.point_data_format > 5) + { + demzip_dll->point.extended_point_type = 1; + } + + // create the point reader + + demzip_dll->reader = new LASreadPoint(demzip_dll->las14_decompress_selective); + if (demzip_dll->reader == 0) + { + sprintf(demzip_dll->error, "could not alloc LASreadPoint"); + return 1; + } + + if (!demzip_dll->reader->setup(laszip->num_items, laszip->items, laszip)) + { + sprintf(demzip_dll->error, "setup of LASreadPoint failed"); + return 1; + } + + if (!demzip_dll->reader->init(demzip_dll->streamin)) + { + sprintf(demzip_dll->error, "init of LASreadPoint failed"); + return 1; + } + + delete laszip; + + // set the point number and point count + + demzip_dll->npoints = (demzip_dll->header.number_of_point_records ? demzip_dll->header.number_of_point_records : demzip_dll->header.extended_number_of_point_records); + demzip_dll->p_count = 0; + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_open_reader( + demzip_POINTER pointer + , const demzip_CHAR* file_name + , demzip_BOOL* is_compressed +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (file_name == 0) + { + sprintf(demzip_dll->error, "demzip_CHAR pointer 'file_name' is zero"); + return 1; + } + + if (is_compressed == 0) + { + sprintf(demzip_dll->error, "demzip_BOOL pointer 'is_compressed' is zero"); + return 1; + } + + if (demzip_dll->writer) + { + sprintf(demzip_dll->error, "writer is already open"); + return 1; + } + + if (demzip_dll->reader) + { + sprintf(demzip_dll->error, "reader is already open"); + return 1; + } + + // open the file + + demzip_dll->file = fopen(file_name, "rb"); + + if (demzip_dll->file == 0) + { + sprintf(demzip_dll->error, "cannot open file '%s'", file_name); + return 1; + } + + if (setvbuf(demzip_dll->file, NULL, _IOFBF, 262144) != 0) + { + sprintf(demzip_dll->warning, "setvbuf() failed with buffer size 262144\n"); + } + + if (IS_LITTLE_ENDIAN()) + demzip_dll->streamin = new ByteStreamInFileLE(demzip_dll->file); + else + demzip_dll->streamin = new ByteStreamInFileBE(demzip_dll->file); + + if (demzip_dll->streamin == 0) + { + sprintf(demzip_dll->error, "could not alloc ByteStreamInFile"); + return 1; + } + + // read the header variable after variable + + if (demzip_read_header(demzip_dll, is_compressed)) + { + return 1; + } + + // should we try to exploit existing spatial indexing information + + if (demzip_dll->lax_exploit) + { + demzip_dll->lax_index = new LASindex(); + + if (!demzip_dll->lax_index->read(file_name)) + { + delete demzip_dll->lax_index; + demzip_dll->lax_index = 0; + } + } + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_open_reader"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_has_spatial_index( + demzip_POINTER pointer + , demzip_BOOL* is_indexed + , demzip_BOOL* is_appended +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (is_indexed == 0) + { + sprintf(demzip_dll->error, "demzip_BOOL pointer 'is_indexed' is zero"); + return 1; + } + + if (demzip_dll->reader == 0) + { + sprintf(demzip_dll->error, "reader is not open"); + return 1; + } + + if (demzip_dll->writer) + { + sprintf(demzip_dll->error, "writer is already open"); + return 1; + } + + if (demzip_dll->lax_exploit == 0) + { + sprintf(demzip_dll->error, "exploiting of spatial indexing not enabled before opening reader"); + return 1; + } + + // check if reader found spatial indexing information when opening file + + if (demzip_dll->lax_index) + { + *is_indexed = 1; + } + else + { + *is_indexed = 0; + } + + // optional: inform whether spatial index is appended to LAZ file or in separate LAX file + + if (is_appended) + { + *is_appended = 0; + } + + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_have_spatial_index"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_inside_rectangle( + demzip_POINTER pointer + , const demzip_F64 r_min_x + , const demzip_F64 r_min_y + , const demzip_F64 r_max_x + , const demzip_F64 r_max_y + , demzip_BOOL* is_empty +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (demzip_dll->reader == 0) + { + sprintf(demzip_dll->error, "reader is not open"); + return 1; + } + + if (is_empty == 0) + { + sprintf(demzip_dll->error, "demzip_BOOL pointer 'is_empty' is zero"); + return 1; + } + + if (demzip_dll->lax_exploit == FALSE) + { + sprintf(demzip_dll->error, "exploiting of spatial indexing not enabled before opening reader"); + return 1; + } + + demzip_dll->lax_r_min_x = r_min_x; + demzip_dll->lax_r_min_y = r_min_y; + demzip_dll->lax_r_max_x = r_max_x; + demzip_dll->lax_r_max_y = r_max_y; + + if (demzip_dll->lax_index) + { + if (demzip_dll->lax_index->intersect_rectangle(r_min_x, r_min_y, r_max_x, r_max_y)) + { + *is_empty = 0; + } + else + { + // no overlap between spatial indexing cells and query reactangle + *is_empty = 1; + } + } + else + { + if ((demzip_dll->header.min_x > r_max_x) || (demzip_dll->header.min_y > r_max_y) || (demzip_dll->header.max_x < r_min_x) || (demzip_dll->header.max_y < r_min_y)) + { + // no overlap between header bouding box and query reactangle + *is_empty = 1; + } + else + { + *is_empty = 0; + } + } + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_inside_rectangle"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_seek_point( + demzip_POINTER pointer + , demzip_I64 index +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + // seek to the point + if (!demzip_dll->reader->seek((U32)demzip_dll->p_count, (U32)index)) + { +#ifdef _WIN32 + sprintf(demzip_dll->error, "seeking from index %I64d to index %I64d for file with %I64d points", demzip_dll->p_count, index, demzip_dll->npoints); +#else + sprintf(demzip_dll->error, "seeking from index %lld to index %lld for file with %lld points", demzip_dll->p_count, index, demzip_dll->npoints); +#endif + return 1; + } + demzip_dll->p_count = index; + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_seek_point"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_read_point( + demzip_POINTER pointer +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + // read the point + if (!demzip_dll->reader->read(demzip_dll->point_items)) + { +#ifdef _WIN32 + sprintf(demzip_dll->error, "reading point %I64d of %I64d total points", demzip_dll->p_count, demzip_dll->npoints); +#else + sprintf(demzip_dll->error, "reading point %lld of %lld total points", demzip_dll->p_count, demzip_dll->npoints); +#endif + return 1; + } + + // special recoding of points (in compatibility mode only) + + if (demzip_dll->compatibility_mode) + { + I16 scan_angle_remainder; + U8 extended_returns; + U8 classification; + U8 flags_and_channel; + I32 return_number_increment; + I32 number_of_returns_increment; + I32 overlap_bit; + I32 scanner_channel; + + // instill extended attributes + struct demzip_point* point = &demzip_dll->point; + + // get extended attributes from extra bytes + scan_angle_remainder = *((I16*)(point->extra_bytes + demzip_dll->start_scan_angle)); + extended_returns = point->extra_bytes[demzip_dll->start_extended_returns]; + classification = point->extra_bytes[demzip_dll->start_classification]; + flags_and_channel = point->extra_bytes[demzip_dll->start_flags_and_channel]; + if (demzip_dll->start_NIR_band != -1) + { + point->rgb[3] = *((U16*)(point->extra_bytes + demzip_dll->start_NIR_band)); + } + + // decompose into individual attributes + return_number_increment = (extended_returns >> 4) & 0x0F; + number_of_returns_increment = extended_returns & 0x0F; + scanner_channel = (flags_and_channel >> 1) & 0x03; + overlap_bit = flags_and_channel & 0x01; + + // instill into point + point->extended_scan_angle = scan_angle_remainder + I16_QUANTIZE(((F32)point->scan_angle_rank) / 0.006f); + point->extended_return_number = return_number_increment + point->return_number; + point->extended_number_of_returns = number_of_returns_increment + point->number_of_returns; + point->extended_classification = classification + point->classification; + point->extended_scanner_channel = scanner_channel; + point->extended_classification_flags = (overlap_bit << 3) | ((point->withheld_flag) << 2) | ((point->keypoint_flag) << 1) | (point->synthetic_flag); + } + + demzip_dll->p_count++; + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_read_point"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_read_inside_point( + demzip_POINTER pointer + , demzip_BOOL* is_done +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + demzip_F64 xy; + + *is_done = 1; + + if (demzip_dll->lax_index) + { + while (demzip_dll->lax_index->seek_next(demzip_dll->reader, demzip_dll->p_count)) + { + if (demzip_dll->reader->read(demzip_dll->point_items)) + { + demzip_dll->p_count++; + xy = demzip_dll->header.x_scale_factor*demzip_dll->point.X+demzip_dll->header.x_offset; + if (xy < demzip_dll->lax_r_min_x || xy >= demzip_dll->lax_r_max_x) continue; + xy = demzip_dll->header.y_scale_factor*demzip_dll->point.Y+demzip_dll->header.y_offset; + if (xy < demzip_dll->lax_r_min_y || xy >= demzip_dll->lax_r_max_y) continue; + *is_done = 0; + break; + } + } + } + else + { + while (demzip_dll->reader->read(demzip_dll->point_items)) + { + demzip_dll->p_count++; + xy = demzip_dll->header.x_scale_factor*demzip_dll->point.X+demzip_dll->header.x_offset; + if (xy < demzip_dll->lax_r_min_x || xy >= demzip_dll->lax_r_max_x) continue; + xy = demzip_dll->header.y_scale_factor*demzip_dll->point.Y+demzip_dll->header.y_offset; + if (xy < demzip_dll->lax_r_min_y || xy >= demzip_dll->lax_r_max_y) continue; + *is_done = 0; + break; + } + + if (*is_done) + { + if (demzip_dll->p_count < demzip_dll->npoints) + { +#ifdef _WIN32 + sprintf(demzip_dll->error, "reading point %I64d of %I64d total points", demzip_dll->p_count, demzip_dll->npoints); +#else + sprintf(demzip_dll->error, "reading point %lld of %lld total points", demzip_dll->p_count, demzip_dll->npoints); +#endif + return 1; + } + } + } + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_read_inside_point"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_close_reader( + demzip_POINTER pointer +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + try + { + if (demzip_dll->reader == 0) + { + sprintf(demzip_dll->error, "closing reader before it was opened"); + return 1; + } + + if (!demzip_dll->reader->done()) + { + sprintf(demzip_dll->error, "done of LASreadPoint failed"); + return 1; + } + + delete demzip_dll->reader; + demzip_dll->reader = 0; + + delete [] demzip_dll->point_items; + demzip_dll->point_items = 0; + + delete demzip_dll->streamin; + demzip_dll->streamin = 0; + + if (demzip_dll->lax_index) + { + delete demzip_dll->lax_index; + demzip_dll->lax_index = 0; + } + + if (demzip_dll->file) + { + fclose(demzip_dll->file); + demzip_dll->file = 0; + } + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_close_reader"); + return 1; + } + + demzip_dll->error[0] = '\0'; + return 0; +} + +#ifdef __cplusplus + +/*---------------------------------------------------------------------------*/ +DEMZIP_API demzip_I32 +demzip_open_reader_stream( + demzip_POINTER pointer + , istream& stream + , demzip_BOOL* is_compressed +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (is_compressed == 0) + { + sprintf(demzip_dll->error, "demzip_BOOL pointer 'is_compressed' is zero"); + return 1; + } + + if (demzip_dll->writer) + { + sprintf(demzip_dll->error, "writer is already open"); + return 1; + } + + if (demzip_dll->reader) + { + sprintf(demzip_dll->error, "reader is already open"); + return 1; + } + + // open the file + + if (IS_LITTLE_ENDIAN()) + demzip_dll->streamin = new ByteStreamInIstreamLE(stream); + else + demzip_dll->streamin = new ByteStreamInIstreamBE(stream); + + if (demzip_dll->streamin == 0) + { + sprintf(demzip_dll->error, "could not alloc ByteStreamInIstream"); + return 1; + } + + return demzip_read_header(demzip_dll, is_compressed); + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_open_reader"); + return 1; + } +} + +/*---------------------------------------------------------------------------*/ +// The stream writer also supports software that writes the LAS header on its +// own simply by setting the BOOL 'do_not_write_header' to TRUE. This function +// should then be called just prior to writing points as data is then written +// to the current stream position +DEMZIP_API demzip_I32 +demzip_open_writer_stream( + demzip_POINTER pointer + , ostream& stream + , demzip_BOOL compress + , demzip_BOOL do_not_write_header +) +{ + if (pointer == 0) return 1; + demzip_dll_struct* demzip_dll = (demzip_dll_struct*)pointer; + + try + { + if (demzip_dll->writer) + { + sprintf(demzip_dll->error, "writer is already open"); + return 1; + } + + if (demzip_dll->reader) + { + sprintf(demzip_dll->error, "reader is already open"); + return 1; + } + + // create the outstream + + if (IS_LITTLE_ENDIAN()) + demzip_dll->streamout = new ByteStreamOutOstreamLE(stream); + else + demzip_dll->streamout = new ByteStreamOutOstreamBE(stream); + + if (demzip_dll->streamout == 0) + { + sprintf(demzip_dll->error, "could not alloc ByteStreamOutOstream"); + return 1; + } + + // setup the items that make up the point + + LASzip laszip; + if (setup_demzip_items(demzip_dll, &laszip, compress)) + { + return 1; + } + + // this supports software that writes the LAS header on its own + + if (do_not_write_header == FALSE) + { + // prepare header + + if (demzip_prepare_header_for_write(demzip_dll)) + { + return 1; + } + + // prepare point + + if (demzip_prepare_point_for_write(demzip_dll, compress)) + { + return 1; + } + + // prepare VLRs + + if (demzip_prepare_vlrs_for_write(demzip_dll)) + { + return 1; + } + + // write header variable after variable + + if (demzip_write_header(demzip_dll, &laszip, compress)) + { + return 1; + } + } + + // create the point writer + + if (create_point_writer(demzip_dll, &laszip)) + { + return 1; + } + + // set the point number and point count + + demzip_dll->npoints = (demzip_dll->header.number_of_point_records ? demzip_dll->header.number_of_point_records : demzip_dll->header.extended_number_of_point_records); + demzip_dll->p_count = 0; + } + catch (...) + { + sprintf(demzip_dll->error, "internal error in demzip_open_writer_stream."); + return 1; + } + demzip_dll->error[0] = '\0'; + return 0; +} + +/*---------------------------------------------------------------------------*/ +// creates complete LASzip VLR for currently selected point type and compression +// The VLR data is valid until the demzip_dll pointer is destroyed. +DEMZIP_API demzip_I32 +demzip_create_demzip_vlr( + demzip_POINTER pointer + , demzip_U8** vlr + , demzip_U32* vlr_size +) +{ + if (pointer == 0) return 1; + demzip_dll_struct *demzip_dll = (demzip_dll_struct *)pointer; + + LASzip laszip; + if (setup_demzip_items(demzip_dll, &laszip, TRUE)) + { + return 1; + } + + ByteStreamOutArray* out = 0; + + if (IS_LITTLE_ENDIAN()) + out = new ByteStreamOutArrayLE(); + else + out = new ByteStreamOutArrayBE(); + + if (out == 0) + { + sprintf(demzip_dll->error, "could not alloc ByteStreamOutArray"); + return 1; + } + + if (write_demzip_vlr_header(demzip_dll, &laszip, out)) + { + return 1; + } + + if (write_demzip_vlr_payload(demzip_dll, &laszip, out)) + { + return 1; + } + + *vlr = (demzip_U8*)malloc(out->getSize()); + *vlr_size = (U32)out->getSize(); + demzip_dll->buffers.push_back(*vlr); + memcpy(*vlr, out->getData(), out->getSize()); + + delete out; + + demzip_dll->error[0] = '\0'; + return 0; +} + +#endif // __cplusplus diff --git a/src/LASzip/integercompressor.cpp b/src/LASzip/integercompressor.cpp index 92c1cd1..1a81b63 100644 --- a/src/LASzip/integercompressor.cpp +++ b/src/LASzip/integercompressor.cpp @@ -205,12 +205,12 @@ IntegerCompressor::~IntegerCompressor() entropy -= log(prob)*prob/log(2.0); } } - REprintf( "k: %d number: %d different: %d entropy: %lg raw: %1.1f\n",k,number,different,entropy, (float)(k?k:1)); + fprintf(stderr, "k: %d number: %d different: %d entropy: %lg raw: %1.1f\n",k,number,different,entropy, (float)(k?k:1)); total_number += number; total_entropy += (entropy*number); total_raw += ((k?k:1)*number); } - REprintf( "TOTAL: number: %d entropy: %lg raw: %lg\n",total_number,total_entropy/total_number,total_raw/total_number); + fprintf(stderr, "TOTAL: number: %d entropy: %lg raw: %lg\n",total_number,total_entropy/total_number,total_raw/total_number); } #endif } diff --git a/inst/include/integercompressor.hpp b/src/LASzip/integercompressor.hpp similarity index 100% rename from inst/include/integercompressor.hpp rename to src/LASzip/integercompressor.hpp diff --git a/inst/include/lasattributer.hpp b/src/LASzip/lasattributer.hpp similarity index 98% rename from inst/include/lasattributer.hpp rename to src/LASzip/lasattributer.hpp index 09534d2..cbcc066 100644 --- a/inst/include/lasattributer.hpp +++ b/src/LASzip/lasattributer.hpp @@ -2,10 +2,10 @@ =============================================================================== FILE: lasattributer.hpp - + CONTENTS: - - This class assists with handling the "extra bytes" that allow storing + + This class assists with handling the "extra bytes" that allow storing additional per point attributes. PROGRAMMERS: @@ -22,12 +22,12 @@ This software is distributed WITHOUT ANY WARRANTY and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - + CHANGE HISTORY: - + 13 September 2018 -- removed tuples and triple support from attributes 19 July 2015 -- created after FOSS4GE in the train back from Lake Como - + =============================================================================== */ #ifndef LAS_ATTRIBUTER_HPP @@ -76,13 +76,8 @@ class LASattribute memset(this, 0, sizeof(LASattribute)); scale[0] = scale[1] = scale[2] = 1.0; this->data_type = type+1; - int len = 0 ; while(*(name+len) != '\0' && len < 32) len++; - memcpy(this->name, name, len); - if (description) - { - int len = 0 ; while(*(description+len) != '\0' && len < 32) len++; - memcpy(this->description, description, len); - } + strncpy(this->name, name, 32); + if (description) strncpy(this->description, description, 32); }; inline BOOL set_no_data(U8 no_data) { if (0 == get_type()) { this->no_data[0].u64 = no_data; options |= 0x01; return TRUE; } return FALSE; }; @@ -275,7 +270,7 @@ class LASattribute { return ((I32)data_type - 1)%10; }; - inline I32 get_dim() const // compute dimension of deprecated tuple and triple attributes + inline I32 get_dim() const // compute dimension of deprecated tuple and triple attributes { return ((I32)data_type - 1)/10 + 1; }; @@ -557,7 +552,7 @@ class LASattributer { I32 index = get_attribute_index(name); if (index != -1) - { + { return remove_attribute(index); } return FALSE; diff --git a/src/LASzip/lasindex.cpp b/src/LASzip/lasindex.cpp index 66860a1..7e2af6f 100644 --- a/src/LASzip/lasindex.cpp +++ b/src/LASzip/lasindex.cpp @@ -45,7 +45,7 @@ #include "bytestreamout_file.hpp" #ifdef UNORDERED -// Figure out whether is in tr1 + // Figure out whether is in tr1 # ifdef __has_include # if __has_include() # include @@ -53,16 +53,23 @@ # define UNORDERED_FOUND # endif # endif -# ifndef UNORDERED_FOUND -# include +# ifdef HAVE_UNORDERED_MAP +# include + using namespace std; +# elif defined(UNORDERED_FOUND) +# include using namespace std; using namespace tr1; -# endif -typedef unordered_map my_cell_hash; -#else +# endif +typedef std::unordered_map my_cell_hash; +#elif defined(LZ_WIN32_VC6) #include using namespace std; typedef hash_map my_cell_hash; +#else +#include +using namespace std; +typedef unordered_map my_cell_hash; #endif LASindex::LASindex() @@ -101,7 +108,7 @@ void LASindex::complete(U32 minimum_points, I32 maximum_intervals, const BOOL ve { if (verbose) { - REprintf("before complete %d %d\n", minimum_points, maximum_intervals); + fprintf(stderr,"before complete %d %d\n", minimum_points, maximum_intervals); print(FALSE); } if (minimum_points) @@ -173,7 +180,7 @@ void LASindex::complete(U32 minimum_points, I32 maximum_intervals, const BOOL ve } if (verbose) { - REprintf("after minimum_points %d\n", minimum_points); + fprintf(stderr,"after minimum_points %d\n", minimum_points); print(FALSE); } } @@ -186,7 +193,7 @@ void LASindex::complete(U32 minimum_points, I32 maximum_intervals, const BOOL ve interval->merge_intervals(maximum_intervals, verbose); if (verbose) { - REprintf("after maximum_intervals %d\n", maximum_intervals); + fprintf(stderr,"after maximum_intervals %d\n", maximum_intervals); print(FALSE); } } @@ -212,15 +219,15 @@ void LASindex::print(BOOL verbose) } if (total_check != interval->total) { - REprintf("ERROR: total_check %d != interval->total %d\n", total_check, interval->total); + fprintf(stderr,"ERROR: total_check %d != interval->total %d\n", total_check, interval->total); } - if (verbose) REprintf("cell %d intervals %d full %d total %d (%.2f)\n", interval->index, intervals, interval->full, interval->total, 100.0f*interval->full/interval->total); + if (verbose) fprintf(stderr,"cell %d intervals %d full %d total %d (%.2f)\n", interval->index, intervals, interval->full, interval->total, 100.0f*interval->full/interval->total); total_cells++; total_full += interval->full; total_total += interval->total; total_intervals += intervals; } - if (verbose) REprintf("total cells/intervals %d/%d full %d (%.2f)\n", total_cells, total_intervals, total_full, 100.0f*total_full/total_total); + if (verbose) fprintf(stderr,"total cells/intervals %d/%d full %d (%.2f)\n", total_cells, total_intervals, total_full, 100.0f*total_full/total_total); } LASquadtree* LASindex::get_spatial() const @@ -237,7 +244,6 @@ BOOL LASindex::intersect_rectangle(const F64 r_min_x, const F64 r_min_y, const F { have_interval = FALSE; cells = spatial->intersect_rectangle(r_min_x, r_min_y, r_max_x, r_max_y); -// REprintf("%d cells of %g/%g %g/%g intersect rect %g/%g %g/%g\n", num_cells, spatial->get_min_x(), spatial->get_min_y(), spatial->get_max_x(), spatial->get_max_y(), r_min_x, r_min_y, r_max_x, r_max_y); if (cells) return merge_intervals(); return FALSE; @@ -247,7 +253,7 @@ BOOL LASindex::intersect_tile(const F32 ll_x, const F32 ll_y, const F32 size) { have_interval = FALSE; cells = spatial->intersect_tile(ll_x, ll_y, size); -// REprintf("%d cells of %g/%g %g/%g intersect tile %g/%g/%g\n", num_cells, spatial->get_min_x(), spatial->get_min_y(), spatial->get_max_x(), spatial->get_max_y(), ll_x, ll_y, size); +// fprintf(stderr,"%d cells of %g/%g %g/%g intersect tile %g/%g/%g\n", num_cells, spatial->get_min_x(), spatial->get_min_y(), spatial->get_max_x(), spatial->get_max_y(), ll_x, ll_y, size); if (cells) return merge_intervals(); return FALSE; @@ -257,7 +263,7 @@ BOOL LASindex::intersect_circle(const F64 center_x, const F64 center_y, const F6 { have_interval = FALSE; cells = spatial->intersect_circle(center_x, center_y, radius); -// REprintf("%d cells of %g/%g %g/%g intersect circle %g/%g/%g\n", num_cells, spatial->get_min_x(), spatial->get_min_y(), spatial->get_max_x(), spatial->get_max_y(), center_x, center_y, radius); +// fprintf(stderr,"%d cells of %g/%g %g/%g intersect circle %g/%g/%g\n", num_cells, spatial->get_min_x(), spatial->get_min_y(), spatial->get_max_x(), spatial->get_max_y(), center_x, center_y, radius); if (cells) return merge_intervals(); return FALSE; @@ -335,7 +341,17 @@ BOOL LASindex::read(const char* file_name) name[strlen(name)-2] = 'a'; name[strlen(name)-1] = 'x'; } +#ifdef _MSC_VER FILE* file = fopen(name, "rb"); + if (file == 0) + { + wchar_t* utf16_name = UTF8toUTF16(name); + file = _wfopen(utf16_name, L"rb"); + delete [] utf16_name; + } +#else + FILE* file = fopen(name, "rb"); +#endif if (file == 0) { free(name); @@ -343,7 +359,7 @@ BOOL LASindex::read(const char* file_name) } if (!read(file)) { - REprintf("ERROR (LASindex): cannot read '%s'\n", name); + fprintf(stderr,"ERROR (LASindex): cannot read '%s'\n", name); fclose(file); free(name); return FALSE; @@ -372,7 +388,21 @@ BOOL LASindex::append(const char* file_name) const lasreader->close(); +#ifdef _MSC_VER + FILE* file = fopen(file_name, "rb"); + if (file == 0) + { + wchar_t* utf16_file_name = UTF8toUTF16(file_name); + file = _wfopen(utf16_file_name, L"rb"); + if (file == 0) + { + fprintf(stderr, "ERROR: cannot open file '%ws'\n", utf16_file_name); + } + delete [] utf16_file_name; + } +#else FILE* file = fopen(file_name, "rb"); +#endif ByteStreamIn* bytestreamin = 0; if (IS_LITTLE_ENDIAN()) bytestreamin = new ByteStreamInFileLE(file); @@ -406,7 +436,7 @@ BOOL LASindex::append(const char* file_name) const CHAR user_id[16]; try { bytestreamin->getBytes((U8*)user_id, 16); } catch(...) { - REprintf("ERROR: reading header.vlrs[%d].user_id\n", u); + fprintf(stderr,"ERROR: reading header.vlrs[%d].user_id\n", u); return FALSE; } if (strcmp(user_id, "laszip encoded") == 0) @@ -417,13 +447,13 @@ BOOL LASindex::append(const char* file_name) const U16 record_id; try { bytestreamin->get16bitsLE((U8*)&record_id); } catch(...) { - REprintf("ERROR: reading header.vlrs[%d].record_id\n", u); + fprintf(stderr,"ERROR: reading header.vlrs[%d].record_id\n", u); return FALSE; } U16 record_length_after_header; try { bytestreamin->get16bitsLE((U8*)&record_length_after_header); } catch(...) { - REprintf("ERROR: reading header.vlrs[%d].record_length_after_header\n", u); + fprintf(stderr,"ERROR: reading header.vlrs[%d].record_length_after_header\n", u); return FALSE; } total += (54 + record_length_after_header); @@ -436,7 +466,21 @@ BOOL LASindex::append(const char* file_name) const fclose(file); ByteStreamOut* bytestreamout; +#ifdef _MSC_VER file = fopen(file_name, "rb+"); + if (file == 0) + { + wchar_t* utf16_file_name = UTF8toUTF16(file_name); + file = _wfopen(utf16_file_name, L"rb+"); + if (file == 0) + { + fprintf(stderr, "ERROR: cannot open file '%ws'\n", utf16_file_name); + } + delete [] utf16_file_name; + } +#else + file = fopen(file_name, "rb+"); +#endif if (IS_LITTLE_ENDIAN()) bytestreamout = new ByteStreamOutFileLE(file); else @@ -456,7 +500,7 @@ BOOL LASindex::append(const char* file_name) const if (!write(bytestreamout)) { - REprintf("ERROR (LASindex): cannot append LAX to '%s'\n", file_name); + fprintf(stderr,"ERROR (LASindex): cannot append LAX to '%s'\n", file_name); delete bytestreamout; fclose(file); delete lasreader; @@ -510,16 +554,30 @@ BOOL LASindex::write(const char* file_name) const name[strlen(name)-2] = 'a'; name[strlen(name)-1] = 'x'; } +#ifdef _MSC_VER FILE* file = fopen(name, "wb"); if (file == 0) { - REprintf("ERROR (LASindex): cannot open '%s' for write\n", name); + wchar_t* utf16_file_name = UTF8toUTF16(name); + file = _wfopen(utf16_file_name, L"wb"); + if (file == 0) + { + fprintf(stderr, "ERROR (LASindex): cannot open file '%ws' for write\n", utf16_file_name); + } + delete [] utf16_file_name; + } +#else + FILE* file = fopen(name, "wb"); +#endif + if (file == 0) + { + fprintf(stderr,"ERROR (LASindex): cannot open file '%s' for write\n", name); free(name); return FALSE; } if (!write(file)) { - REprintf("ERROR (LASindex): cannot write '%s'\n", name); + fprintf(stderr,"ERROR (LASindex): cannot write file '%s'\n", name); fclose(file); free(name); return FALSE; @@ -544,32 +602,32 @@ BOOL LASindex::read(ByteStreamIn* stream) char signature[4]; try { stream->getBytes((U8*)signature, 4); } catch (...) { - REprintf("ERROR (LASindex): reading signature\n"); + fprintf(stderr,"ERROR (LASindex): reading signature\n"); return FALSE; } if (strncmp(signature, "LASX", 4) != 0) { - REprintf("ERROR (LASindex): wrong signature %4s instead of 'LASX'\n", signature); + fprintf(stderr,"ERROR (LASindex): wrong signature %4s instead of 'LASX'\n", signature); return FALSE; } U32 version; try { stream->get32bitsLE((U8*)&version); } catch (...) { - REprintf("ERROR (LASindex): reading version\n"); + fprintf(stderr,"ERROR (LASindex): reading version\n"); return FALSE; } // read spatial quadtree spatial = new LASquadtree(); if (!spatial->read(stream)) { - REprintf("ERROR (LASindex): cannot read LASspatial (LASquadtree)\n"); + fprintf(stderr,"ERROR (LASindex): cannot read LASspatial (LASquadtree)\n"); return FALSE; } // read interval interval = new LASinterval(); if (!interval->read(stream)) { - REprintf("ERROR (LASindex): reading LASinterval\n"); + fprintf(stderr,"ERROR (LASindex): reading LASinterval\n"); return FALSE; } // tell spatial about the existing cells @@ -585,25 +643,25 @@ BOOL LASindex::write(ByteStreamOut* stream) const { if (!stream->putBytes((const U8*)"LASX", 4)) { - REprintf("ERROR (LASindex): writing signature\n"); + fprintf(stderr,"ERROR (LASindex): writing signature\n"); return FALSE; } U32 version = 0; if (!stream->put32bitsLE((const U8*)&version)) { - REprintf("ERROR (LASindex): writing version\n"); + fprintf(stderr,"ERROR (LASindex): writing version\n"); return FALSE; } // write spatial quadtree if (!spatial->write(stream)) { - REprintf("ERROR (LASindex): cannot write LASspatial (LASquadtree)\n"); + fprintf(stderr,"ERROR (LASindex): cannot write LASspatial (LASquadtree)\n"); return FALSE; } // write interval if (!interval->write(stream)) { - REprintf("ERROR (LASindex): writing LASinterval\n"); + fprintf(stderr,"ERROR (LASindex): writing LASinterval\n"); return FALSE; } return TRUE; @@ -656,7 +714,7 @@ BOOL LASindex::merge_intervals() used_cells++; } } -// REprintf("LASindex: used %d cells of total %d\n", used_cells, interval->get_number_cells()); + if (used_cells) { BOOL r = interval->merge(); diff --git a/inst/include/lasindex.hpp b/src/LASzip/lasindex.hpp similarity index 99% rename from inst/include/lasindex.hpp rename to src/LASzip/lasindex.hpp index 0024631..4890f17 100644 --- a/inst/include/lasindex.hpp +++ b/src/LASzip/lasindex.hpp @@ -53,7 +53,7 @@ class LASreader; class ByteStreamIn; class ByteStreamOut; -class LASindex +class LASLIB_DLL LASindex { public: LASindex(); diff --git a/src/LASzip/lasinterval.cpp b/src/LASzip/lasinterval.cpp index eb73145..a664e10 100644 --- a/src/LASzip/lasinterval.cpp +++ b/src/LASzip/lasinterval.cpp @@ -52,16 +52,23 @@ using namespace std; # define UNORDERED_FOUND # endif # endif -# ifndef UNORDERED_FOUND -# include +# ifdef HAVE_UNORDERED_MAP +# include + using namespace std; +# elif defined(UNORDERED_FOUND) +# include using namespace std; using namespace tr1; -# endif -typedef unordered_map my_cell_hash; -#else +# endif +typedef std::unordered_map my_cell_hash; +#elif defined(LZ_WIN32_VC6) #include using namespace std; typedef hash_map my_cell_hash; +#else +#include +using namespace std; +typedef unordered_map my_cell_hash; #endif typedef multimap my_cell_map; @@ -239,12 +246,12 @@ void LASinterval::merge_intervals(U32 maximum_intervals, const BOOL verbose) { if (map.size() == 0) { - REprintf("maximum_intervals: %u number of interval gaps: 0 \n", maximum_intervals); + fprintf(stderr,"maximum_intervals: %u number of interval gaps: 0 \n", maximum_intervals); } else { diff = (*(map.begin())).first; - REprintf("maximum_intervals: %u number of interval gaps: %u next largest interval gap %u\n", maximum_intervals, (U32)map.size(), diff); + fprintf(stderr,"maximum_intervals: %u number of interval gaps: %u next largest interval gap %u\n", maximum_intervals, (U32)map.size(), diff); } } return; @@ -294,7 +301,7 @@ void LASinterval::merge_intervals(U32 maximum_intervals, const BOOL verbose) } map_element++; } - REprintf("largest interval gap increased to %u\n", diff); + if (verbose) fprintf(stderr,"largest interval gap increased to %u\n", diff); // update totals @@ -542,7 +549,7 @@ LASinterval::~LASinterval() previous_cell = cell; cell = cell->next; } - delete ((LASintervalStartCell*)previous_cell); + delete previous_cell; hash_element++; } delete ((my_cell_hash*)cells); @@ -571,25 +578,25 @@ BOOL LASinterval::read(ByteStreamIn* stream) char signature[4]; try { stream->getBytes((U8*)signature, 4); } catch (...) { - REprintf("ERROR (LASinterval): reading signature\n"); + fprintf(stderr,"ERROR (LASinterval): reading signature\n"); return FALSE; } if (strncmp(signature, "LASV", 4) != 0) { - REprintf("ERROR (LASinterval): wrong signature %4s instead of 'LASV'\n", signature); + fprintf(stderr,"ERROR (LASinterval): wrong signature %4s instead of 'LASV'\n", signature); return FALSE; } U32 version; try { stream->get32bitsLE((U8*)&version); } catch (...) { - REprintf("ERROR (LASinterval): reading version\n"); + fprintf(stderr,"ERROR (LASinterval): reading version\n"); return FALSE; } // read number of cells U32 number_cells; try { stream->get32bitsLE((U8*)&number_cells); } catch (...) { - REprintf("ERROR (LASinterval): reading number of cells\n"); + fprintf(stderr,"ERROR (LASinterval): reading number of cells\n"); return FALSE; } // loop over all cells @@ -599,7 +606,7 @@ BOOL LASinterval::read(ByteStreamIn* stream) I32 cell_index; try { stream->get32bitsLE((U8*)&cell_index); } catch (...) { - REprintf("ERROR (LASinterval): reading cell index\n"); + fprintf(stderr,"ERROR (LASinterval): reading cell index\n"); return FALSE; } // create cell and insert into hash @@ -610,14 +617,14 @@ BOOL LASinterval::read(ByteStreamIn* stream) U32 number_intervals; try { stream->get32bitsLE((U8*)&number_intervals); } catch (...) { - REprintf("ERROR (LASinterval): reading number of intervals in cell\n"); + fprintf(stderr,"ERROR (LASinterval): reading number of intervals in cell\n"); return FALSE; } // read number of points in cell U32 number_points; try { stream->get32bitsLE((U8*)&number_points); } catch (...) { - REprintf("ERROR (LASinterval): reading number of points in cell\n"); + fprintf(stderr,"ERROR (LASinterval): reading number of points in cell\n"); return FALSE; } start_cell->full = number_points; @@ -627,13 +634,13 @@ BOOL LASinterval::read(ByteStreamIn* stream) // read start of interval try { stream->get32bitsLE((U8*)&(cell->start)); } catch (...) { - REprintf("ERROR (LASinterval): reading start %d of interval\n", cell->start); + fprintf(stderr,"ERROR (LASinterval): reading start %d of interval\n", cell->start); return FALSE; } // read end of interval try { stream->get32bitsLE((U8*)&(cell->end)); } catch (...) { - REprintf("ERROR (LASinterval): reading end %d of interval\n", cell->end); + fprintf(stderr,"ERROR (LASinterval): reading end %d of interval\n", cell->end); return FALSE; } start_cell->total += (cell->end - cell->start + 1); @@ -654,20 +661,20 @@ BOOL LASinterval::write(ByteStreamOut* stream) const { if (!stream->putBytes((const U8*)"LASV", 4)) { - REprintf("ERROR (LASinterval): writing signature\n"); + fprintf(stderr,"ERROR (LASinterval): writing signature\n"); return FALSE; } U32 version = 0; if (!stream->put32bitsLE((const U8*)&version)) { - REprintf("ERROR (LASinterval): writing version\n"); + fprintf(stderr,"ERROR (LASinterval): writing version\n"); return FALSE; } // write number of cells U32 number_cells = (U32)((my_cell_hash*)cells)->size(); if (!stream->put32bitsLE((const U8*)&number_cells)) { - REprintf("ERROR (LASinterval): writing number of cells %d\n", number_cells); + fprintf(stderr,"ERROR (LASinterval): writing number of cells %d\n", number_cells); return FALSE; } // loop over all cells @@ -687,19 +694,19 @@ BOOL LASinterval::write(ByteStreamOut* stream) const I32 cell_index = (*hash_element).first; if (!stream->put32bitsLE((const U8*)&cell_index)) { - REprintf("ERROR (LASinterval): writing cell index %d\n", cell_index); + fprintf(stderr,"ERROR (LASinterval): writing cell index %d\n", cell_index); return FALSE; } // write number of intervals in cell if (!stream->put32bitsLE((const U8*)&number_intervals)) { - REprintf("ERROR (LASinterval): writing number of intervals %d in cell\n", number_intervals); + fprintf(stderr,"ERROR (LASinterval): writing number of intervals %d in cell\n", number_intervals); return FALSE; } // write number of points in cell if (!stream->put32bitsLE((const U8*)&number_points)) { - REprintf("ERROR (LASinterval): writing number of points %d in cell\n", number_points); + fprintf(stderr,"ERROR (LASinterval): writing number of points %d in cell\n", number_points); return FALSE; } // write intervals @@ -709,13 +716,13 @@ BOOL LASinterval::write(ByteStreamOut* stream) const // write start of interval if (!stream->put32bitsLE((const U8*)&(cell->start))) { - REprintf("ERROR (LASinterval): writing start %d of interval\n", cell->start); + fprintf(stderr,"ERROR (LASinterval): writing start %d of interval\n", cell->start); return FALSE; } // write end of interval if (!stream->put32bitsLE((const U8*)&(cell->end))) { - REprintf("ERROR (LASinterval): writing end %d of interval\n", cell->end); + fprintf(stderr,"ERROR (LASinterval): writing end %d of interval\n", cell->end); return FALSE; } cell = cell->next; diff --git a/inst/include/lasinterval.hpp b/src/LASzip/lasinterval.hpp similarity index 100% rename from inst/include/lasinterval.hpp rename to src/LASzip/lasinterval.hpp diff --git a/inst/include/laspoint.hpp b/src/LASzip/laspoint.hpp similarity index 93% rename from inst/include/laspoint.hpp rename to src/LASzip/laspoint.hpp index 8c966d0..f7caff5 100644 --- a/inst/include/laspoint.hpp +++ b/src/LASzip/laspoint.hpp @@ -25,6 +25,7 @@ CHANGE HISTORY: + 10 May 2019 -- checking for overflows in X, Y, Z of I32 of fixed-point LAS 15 June 2018 -- fix in flag copy from legacy (0-5) to extended (6-10) type 10 March 2017 -- fix in copy_to() and copy_from() new LAS 1.4 point types 10 October 2016 -- small fixes for NIR and extended scanner channel @@ -181,7 +182,14 @@ class LASpoint } if (other.extra_bytes && extra_bytes) { - memcpy(extra_bytes, other.extra_bytes, extra_bytes_number); + if (other.extra_bytes_number >= extra_bytes_number) + { + memcpy(extra_bytes, other.extra_bytes, extra_bytes_number); + } + else + { + memcpy(extra_bytes, other.extra_bytes, other.extra_bytes_number); + } } if (other.extended_point_type) { @@ -274,7 +282,7 @@ class LASpoint if (!LASzip().setup(&num_items, &items, point_type, point_size, LASZIP_COMPRESSOR_NONE)) { - REprintf("ERROR: unknown point type %d with point size %d\n", (I32)point_type, (I32)point_size); + fprintf(stderr,"ERROR: unknown point type %d with point size %d\n", (I32)point_type, (I32)point_size); return FALSE; } @@ -314,6 +322,7 @@ class LASpoint case LASitem::BYTE14: extra_bytes_number = items[i].size; extra_bytes = new U8[extra_bytes_number]; + memset(extra_bytes, 0, extra_bytes_number); this->point[i] = extra_bytes; break; default: @@ -373,6 +382,7 @@ class LASpoint case LASitem::BYTE14: extra_bytes_number = items[i].size; extra_bytes = new U8[extra_bytes_number]; + memset(extra_bytes, 0, extra_bytes_number); this->point[i] = extra_bytes; break; default: @@ -435,36 +445,6 @@ class LASpoint return TRUE; } - BOOL is_zero() const - { - if (((U32*)&(this->X))[0] || ((U32*)&(this->X))[1] || ((U32*)&(this->X))[2] || ((U32*)&(this->X))[3] || ((U32*)&(this->X))[4]) - { - return FALSE; - } - if (have_gps_time) - { - if (this->gps_time) - { - return FALSE; - } - } - if (have_rgb) - { - if (this->rgb[0] || this->rgb[1] || this->rgb[2]) - { - return FALSE; - } - if (have_nir) - { - if (this->rgb[3]) - { - return FALSE; - } - } - } - return TRUE; - } - void zero() { X = 0; @@ -546,6 +526,7 @@ class LASpoint inline I32 get_X() const { return X; }; inline I32 get_Y() const { return Y; }; inline I32 get_Z() const { return Z; }; + inline const I32* get_XYZ() const { return &X; }; inline U16 get_intensity() const { return intensity; }; inline U8 get_return_number() const { return return_number; }; inline U8 get_number_of_returns() const { return number_of_returns; }; @@ -560,7 +541,9 @@ class LASpoint inline U16 get_point_source_ID() const { return point_source_ID; }; inline U8 get_deleted_flag() const { return deleted_flag; }; inline F64 get_gps_time() const { return gps_time; }; - inline const U16* get_rgb() const { return rgb; }; + inline const U16* get_RGB() const { return rgb; }; + inline const U16* get_RGBI() const { return rgb; }; + inline U16 get_RGBI(const U32 band) const { return rgb[band]; }; inline U16 get_R() const { return rgb[0]; }; inline U16 get_G() const { return rgb[1]; }; inline U16 get_B() const { return rgb[2]; }; @@ -586,6 +569,7 @@ class LASpoint inline void set_gps_time(const F64 gps_time) { this->gps_time = gps_time; }; inline void set_RGB(const U16* rgb) { memcpy(this->rgb, rgb, sizeof(U16) * 3); }; inline void set_RGBI(const U16* rgb) { memcpy(this->rgb, rgb, sizeof(U16) * 4); }; + inline void set_RGBI(const U32 band, const U16 value) { rgb[band] = value; }; inline void set_R(const U16 R) { this->rgb[0] = R; }; inline void set_G(const U16 G) { this->rgb[1] = G; }; inline void set_B(const U16 B) { this->rgb[2] = B; }; @@ -596,9 +580,9 @@ class LASpoint inline F64 get_y() const { return quantizer->get_y(Y); }; inline F64 get_z() const { return quantizer->get_z(Z); }; - inline void set_x(const F64 x) { this->X = quantizer->get_X(x); }; - inline void set_y(const F64 y) { this->Y = quantizer->get_Y(y); }; - inline void set_z(const F64 z) { this->Z = quantizer->get_Z(z); }; + inline BOOL set_x(const F64 x) { I64 X = quantizer->get_X(x); this->X = (I32)(X); return I32_FITS_IN_RANGE(X); }; + inline BOOL set_y(const F64 y) { I64 Y = quantizer->get_Y(y); this->Y = (I32)(Y); return I32_FITS_IN_RANGE(Y); }; + inline BOOL set_z(const F64 z) { I64 Z = quantizer->get_Z(z); this->Z = (I32)(Z); return I32_FITS_IN_RANGE(Z); }; inline BOOL is_extended_point_type() const { return extended_point_type; }; @@ -628,18 +612,23 @@ class LASpoint coordinates[2] = get_z(); }; - inline void compute_XYZ() + inline BOOL compute_XYZ() { - set_x(coordinates[0]); - set_y(coordinates[1]); - set_z(coordinates[2]); + BOOL retX = set_x(coordinates[0]); + BOOL retY = set_y(coordinates[1]); + BOOL retZ = set_z(coordinates[2]); + return (retX && retY && retZ); }; - inline void compute_XYZ(const LASquantizer* quantizer) + inline BOOL compute_XYZ(const LASquantizer* quantizer) { - X = quantizer->get_X(coordinates[0]); - Y = quantizer->get_Y(coordinates[1]); - Z = quantizer->get_Z(coordinates[2]); + I64 X = quantizer->get_X(coordinates[0]); + I64 Y = quantizer->get_Y(coordinates[1]); + I64 Z = quantizer->get_Z(coordinates[2]); + this->X = (I32)(X); + this->Y = (I32)(Y); + this->Z = (I32)(Z); + return (I32_FITS_IN_RANGE(X) && I32_FITS_IN_RANGE(Y) && I32_FITS_IN_RANGE(Z)); }; // generic functions for attributes in extra bytes diff --git a/src/LASzip/lasquadtree.cpp b/src/LASzip/lasquadtree.cpp index 39408ee..67a8e98 100644 --- a/src/LASzip/lasquadtree.cpp +++ b/src/LASzip/lasquadtree.cpp @@ -2,11 +2,11 @@ =============================================================================== FILE: lasquadtree.cpp - + CONTENTS: - + see corresponding header file - + PROGRAMMERS: martin.isenburg@rapidlasso.com - http://rapidlasso.com @@ -21,11 +21,11 @@ This software is distributed WITHOUT ANY WARRANTY and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - + CHANGE HISTORY: - + see corresponding header file - + =============================================================================== */ #include "lasquadtree.hpp" @@ -108,7 +108,7 @@ void LASquadtree::get_cell_bounding_box(const F64 x, const F64 y, U32 level, F32 volatile float cell_mid_y; float cell_min_x, cell_max_x; float cell_min_y, cell_max_y; - + cell_min_x = min_x; cell_max_x = max_x; cell_min_y = min_y; @@ -161,7 +161,7 @@ void LASquadtree::get_cell_bounding_box(U32 level_index, U32 level, F32* min, F3 volatile F32 cell_mid_y; F32 cell_min_x, cell_max_x; F32 cell_min_y, cell_max_y; - + cell_min_x = min_x; cell_max_x = max_x; cell_min_y = min_y; @@ -210,7 +210,7 @@ void LASquadtree::get_cell_bounding_box(U32 level_index, U32 level, F64* min, F6 volatile F64 cell_mid_y; F64 cell_min_x, cell_max_x; F64 cell_min_y, cell_max_y; - + cell_min_x = min_x; cell_max_x = max_x; cell_min_y = min_y; @@ -279,7 +279,7 @@ U32 LASquadtree::get_level_index(const F64 x, const F64 y, U32 level) const volatile float cell_mid_y; float cell_min_x, cell_max_x; float cell_min_y, cell_max_y; - + cell_min_x = min_x; cell_max_x = max_x; cell_min_y = min_y; @@ -331,7 +331,7 @@ U32 LASquadtree::get_level_index(const F64 x, const F64 y, U32 level, F32* min, volatile float cell_mid_y; float cell_min_x, cell_max_x; float cell_min_y, cell_max_y; - + cell_min_x = min_x; cell_max_x = max_x; cell_min_y = min_y; @@ -577,45 +577,45 @@ U32* LASquadtree::raster_occupancy(BOOL(*does_cell_exist)(I32)) const BOOL LASquadtree::read(ByteStreamIn* stream) { // read data in the following order - // U32 levels 4 bytes + // U32 levels 4 bytes // U32 level_index 4 bytes (default 0) // U32 implicit_levels 4 bytes (only used when level_index != 0)) - // F32 min_x 4 bytes - // F32 max_x 4 bytes - // F32 min_y 4 bytes - // F32 max_y 4 bytes + // F32 min_x 4 bytes + // F32 max_x 4 bytes + // F32 min_y 4 bytes + // F32 max_y 4 bytes // which totals 28 bytes char signature[4]; try { stream->getBytes((U8*)signature, 4); } catch(...) { - REprintf("ERROR (LASquadtree): reading LASspatial signature\n"); + fprintf(stderr,"ERROR (LASquadtree): reading LASspatial signature\n"); return FALSE; } if (strncmp(signature, "LASS", 4) != 0) { - REprintf("ERROR (LASquadtree): wrong LASspatial signature %4s instead of 'LASS'\n", signature); + fprintf(stderr,"ERROR (LASquadtree): wrong LASspatial signature %4s instead of 'LASS'\n", signature); return FALSE; } U32 type; try { stream->getBytes((U8*)&type, 4); } catch(...) { - REprintf("ERROR (LASquadtree): reading LASspatial type\n"); + fprintf(stderr,"ERROR (LASquadtree): reading LASspatial type\n"); return 0; } if (type != LAS_SPATIAL_QUAD_TREE) { - REprintf("ERROR (LASquadtree): unknown LASspatial type %u\n", type); + fprintf(stderr,"ERROR (LASquadtree): unknown LASspatial type %u\n", type); return 0; } try { stream->getBytes((U8*)signature, 4); } catch(...) { - REprintf("ERROR (LASquadtree): reading signature\n"); + fprintf(stderr,"ERROR (LASquadtree): reading signature\n"); return FALSE; } if (strncmp(signature, "LASQ", 4) != 0) { -// REprintf("ERROR (LASquadtree): wrong signature %4s instead of 'LASV'\n", signature); +// fprintf(stderr,"ERROR (LASquadtree): wrong signature %4s instead of 'LASV'\n", signature); // return FALSE; levels = ((U32*)signature)[0]; } @@ -624,45 +624,45 @@ BOOL LASquadtree::read(ByteStreamIn* stream) U32 version; try { stream->get32bitsLE((U8*)&version); } catch(...) { - REprintf("ERROR (LASquadtree): reading version\n"); + fprintf(stderr,"ERROR (LASquadtree): reading version\n"); return FALSE; } try { stream->get32bitsLE((U8*)&levels); } catch(...) { - REprintf("ERROR (LASquadtree): reading levels\n"); + fprintf(stderr,"ERROR (LASquadtree): reading levels\n"); return FALSE; } } U32 level_index; try { stream->get32bitsLE((U8*)&level_index); } catch(...) { - REprintf("ERROR (LASquadtree): reading level_index\n"); + fprintf(stderr,"ERROR (LASquadtree): reading level_index\n"); return FALSE; } U32 implicit_levels; try { stream->get32bitsLE((U8*)&implicit_levels); } catch(...) { - REprintf("ERROR (LASquadtree): reading implicit_levels\n"); + fprintf(stderr,"ERROR (LASquadtree): reading implicit_levels\n"); return FALSE; } try { stream->get32bitsLE((U8*)&min_x); } catch(...) { - REprintf("ERROR (LASquadtree): reading min_x\n"); + fprintf(stderr,"ERROR (LASquadtree): reading min_x\n"); return FALSE; } try { stream->get32bitsLE((U8*)&max_x); } catch(...) { - REprintf("ERROR (LASquadtree): reading max_x\n"); + fprintf(stderr,"ERROR (LASquadtree): reading max_x\n"); return FALSE; } try { stream->get32bitsLE((U8*)&min_y); } catch(...) { - REprintf("ERROR (LASquadtree): reading min_y\n"); + fprintf(stderr,"ERROR (LASquadtree): reading min_y\n"); return FALSE; } try { stream->get32bitsLE((U8*)&max_y); } catch(...) { - REprintf("ERROR (LASquadtree): reading max_y\n"); + fprintf(stderr,"ERROR (LASquadtree): reading max_y\n"); return FALSE; } return TRUE; @@ -671,82 +671,82 @@ BOOL LASquadtree::read(ByteStreamIn* stream) BOOL LASquadtree::write(ByteStreamOut* stream) const { // which totals 28 bytes - // U32 levels 4 bytes + // U32 levels 4 bytes // U32 level_index 4 bytes (default 0) // U32 implicit_levels 4 bytes (only used when level_index != 0)) - // F32 min_x 4 bytes - // F32 max_x 4 bytes - // F32 min_y 4 bytes - // F32 max_y 4 bytes + // F32 min_x 4 bytes + // F32 max_x 4 bytes + // F32 min_y 4 bytes + // F32 max_y 4 bytes // which totals 28 bytes if (!stream->putBytes((const U8*)"LASS", 4)) { - REprintf("ERROR (LASquadtree): writing LASspatial signature\n"); + fprintf(stderr,"ERROR (LASquadtree): writing LASspatial signature\n"); return FALSE; } U32 type = LAS_SPATIAL_QUAD_TREE; if (!stream->put32bitsLE((U8*)&type)) { - REprintf("ERROR (LASquadtree): writing LASspatial type %u\n", type); + fprintf(stderr,"ERROR (LASquadtree): writing LASspatial type %u\n", type); return FALSE; } if (!stream->putBytes((const U8*)"LASQ", 4)) { - REprintf("ERROR (LASquadtree): writing signature\n"); + fprintf(stderr,"ERROR (LASquadtree): writing signature\n"); return FALSE; } U32 version = 0; if (!stream->put32bitsLE((const U8*)&version)) { - REprintf("ERROR (LASquadtree): writing version\n"); + fprintf(stderr,"ERROR (LASquadtree): writing version\n"); return FALSE; } if (!stream->put32bitsLE((const U8*)&levels)) { - REprintf("ERROR (LASquadtree): writing levels %u\n", levels); + fprintf(stderr,"ERROR (LASquadtree): writing levels %u\n", levels); return FALSE; } U32 level_index = 0; if (!stream->put32bitsLE((const U8*)&level_index)) { - REprintf("ERROR (LASquadtree): writing level_index %u\n", level_index); + fprintf(stderr,"ERROR (LASquadtree): writing level_index %u\n", level_index); return FALSE; } U32 implicit_levels = 0; if (!stream->put32bitsLE((const U8*)&implicit_levels)) { - REprintf("ERROR (LASquadtree): writing implicit_levels %u\n", implicit_levels); + fprintf(stderr,"ERROR (LASquadtree): writing implicit_levels %u\n", implicit_levels); return FALSE; } if (!stream->put32bitsLE((const U8*)&min_x)) { - REprintf("ERROR (LASquadtree): writing min_x %g\n", min_x); + fprintf(stderr,"ERROR (LASquadtree): writing min_x %g\n", min_x); return FALSE; } if (!stream->put32bitsLE((const U8*)&max_x)) { - REprintf("ERROR (LASquadtree): writing max_x %g\n", max_x); + fprintf(stderr,"ERROR (LASquadtree): writing max_x %g\n", max_x); return FALSE; } if (!stream->put32bitsLE((const U8*)&min_y)) { - REprintf("ERROR (LASquadtree): writing min_y %g\n", min_y); + fprintf(stderr,"ERROR (LASquadtree): writing min_y %g\n", min_y); return FALSE; } if (!stream->put32bitsLE((const U8*)&max_y)) { - REprintf("ERROR (LASquadtree): writing max_y %g\n", max_y); + fprintf(stderr,"ERROR (LASquadtree): writing max_y %g\n", max_y); return FALSE; } return TRUE; } -// create or finalize the cell (in the spatial hierarchy) +// create or finalize the cell (in the spatial hierarchy) BOOL LASquadtree::manage_cell(const U32 cell_index, const BOOL finalize) { U32 adaptive_pos = cell_index/32; @@ -869,8 +869,8 @@ U32 LASquadtree::intersect_circle(const F64 center_x, const F64 center_y, const ((my_cell_vector*)current_cells)->clear(); } - F64 r_min_x = center_x - radius; - F64 r_min_y = center_y - radius; + F64 r_min_x = center_x - radius; + F64 r_min_y = center_y - radius; F64 r_max_x = center_x + radius; F64 r_max_y = center_y + radius; @@ -1532,7 +1532,7 @@ BOOL LASquadtree::setup(F64 bb_min_x, F64 bb_max_x, F64 bb_min_y, F64 bb_max_y, if (cells_x == 0 || cells_y == 0) { - REprintf( "ERROR: cells_x %d cells_y %d\n", cells_x, cells_y); + fprintf(stderr, "ERROR: cells_x %d cells_y %d\n", cells_x, cells_y); return FALSE; } @@ -1583,7 +1583,7 @@ BOOL LASquadtree::setup(F64 bb_min_x, F64 bb_max_x, F64 bb_min_y, F64 bb_max_y, if (cells_x == 0 || cells_y == 0) { - REprintf( "ERROR: cells_x %d cells_y %d\n", cells_x, cells_y); + fprintf(stderr, "ERROR: cells_x %d cells_y %d\n", cells_x, cells_y); return FALSE; } @@ -1659,10 +1659,7 @@ LASquadtree::LASquadtree() level_offset[0] = 0; for (l = 0; l < 23; l++) { - if (l < 16) - level_offset[l+1] = level_offset[l] + ((1<= x_offset) return (I32)((x-x_offset)/x_scale_factor+0.5); else return (I32)((x-x_offset)/x_scale_factor-0.5); }; - inline I32 get_Y(const F64 y) const { if (y >= y_offset) return (I32)((y-y_offset)/y_scale_factor+0.5); else return (I32)((y-y_offset)/y_scale_factor-0.5); }; - inline I32 get_Z(const F64 z) const { if (z >= z_offset) return (I32)((z-z_offset)/z_scale_factor+0.5); else return (I32)((z-z_offset)/z_scale_factor-0.5); }; + inline I64 get_X(const F64 x) const { if (x >= x_offset) return (I64)(((x-x_offset)/x_scale_factor)+0.5); else return (I64)(((x-x_offset)/x_scale_factor)-0.5); }; + inline I64 get_Y(const F64 y) const { if (y >= y_offset) return (I64)(((y-y_offset)/y_scale_factor)+0.5); else return (I64)(((y-y_offset)/y_scale_factor)-0.5); }; + inline I64 get_Z(const F64 z) const { if (z >= z_offset) return (I64)(((z-z_offset)/z_scale_factor)+0.5); else return (I64)(((z-z_offset)/z_scale_factor)-0.5); }; LASquantizer() { diff --git a/inst/include/lasreaditem.hpp b/src/LASzip/lasreaditem.hpp similarity index 100% rename from inst/include/lasreaditem.hpp rename to src/LASzip/lasreaditem.hpp diff --git a/inst/include/lasreaditemcompressed_v1.hpp b/src/LASzip/lasreaditemcompressed_v1.hpp similarity index 100% rename from inst/include/lasreaditemcompressed_v1.hpp rename to src/LASzip/lasreaditemcompressed_v1.hpp diff --git a/inst/include/lasreaditemcompressed_v2.hpp b/src/LASzip/lasreaditemcompressed_v2.hpp similarity index 100% rename from inst/include/lasreaditemcompressed_v2.hpp rename to src/LASzip/lasreaditemcompressed_v2.hpp diff --git a/src/LASzip/lasreaditemcompressed_v3.cpp b/src/LASzip/lasreaditemcompressed_v3.cpp index b60ddc2..48df564 100644 --- a/src/LASzip/lasreaditemcompressed_v3.cpp +++ b/src/LASzip/lasreaditemcompressed_v3.cpp @@ -375,7 +375,7 @@ inline BOOL LASreadItemCompressed_POINT14_v3::createAndInitModelsAndDecompressor memcpy(contexts[context].last_item, item, sizeof(LASpoint14)); ((LASpoint14*)contexts[context].last_item)->gps_time_change = FALSE; -// REprintf( "INIT: current_context %d last item %.14g %d %d %d %d %d %d\n", current_context, ((LASpoint14*)item)->gps_time, ((LASpoint14*)item)->X, ((LASpoint14*)item)->Y, ((LASpoint14*)item)->Z, ((LASpoint14*)item)->intensity, ((LASpoint14*)item)->return_number, ((LASpoint14*)item)->number_of_returns); +// fprintf(stderr, "INIT: current_context %d last item %.14g %d %d %d %d %d %d\n", current_context, ((LASpoint14*)item)->gps_time, ((LASpoint14*)item)->X, ((LASpoint14*)item)->Y, ((LASpoint14*)item)->Z, ((LASpoint14*)item)->intensity, ((LASpoint14*)item)->return_number, ((LASpoint14*)item)->number_of_returns); contexts[context].unused = FALSE; @@ -2133,7 +2133,14 @@ LASreadItemCompressed_BYTE14_v3::LASreadItemCompressed_BYTE14_v3(ArithmeticDecod changed_Bytes[i] = FALSE; - requested_Bytes[i] = (decompress_selective & (LASZIP_DECOMPRESS_SELECTIVE_BYTE0 << i) ? TRUE : FALSE); + if (i > 15) // currently only the first 16 extra bytes can be selectively decompressed + { + requested_Bytes[i] = TRUE; + } + else + { + requested_Bytes[i] = (decompress_selective & (LASZIP_DECOMPRESS_SELECTIVE_BYTE0 << i) ? TRUE : FALSE); + } } /* init the bytes buffer to zero */ diff --git a/inst/include/lasreaditemcompressed_v3.hpp b/src/LASzip/lasreaditemcompressed_v3.hpp similarity index 100% rename from inst/include/lasreaditemcompressed_v3.hpp rename to src/LASzip/lasreaditemcompressed_v3.hpp diff --git a/src/LASzip/lasreaditemcompressed_v4.cpp b/src/LASzip/lasreaditemcompressed_v4.cpp index 1ecd988..f729362 100644 --- a/src/LASzip/lasreaditemcompressed_v4.cpp +++ b/src/LASzip/lasreaditemcompressed_v4.cpp @@ -375,7 +375,7 @@ inline BOOL LASreadItemCompressed_POINT14_v4::createAndInitModelsAndDecompressor memcpy(contexts[context].last_item, item, sizeof(LASpoint14)); ((LASpoint14*)contexts[context].last_item)->gps_time_change = FALSE; -// REprintf( "INIT: current_context %d last item %.14g %d %d %d %d %d %d\n", current_context, ((LASpoint14*)item)->gps_time, ((LASpoint14*)item)->X, ((LASpoint14*)item)->Y, ((LASpoint14*)item)->Z, ((LASpoint14*)item)->intensity, ((LASpoint14*)item)->return_number, ((LASpoint14*)item)->number_of_returns); +// fprintf(stderr, "INIT: current_context %d last item %.14g %d %d %d %d %d %d\n", current_context, ((LASpoint14*)item)->gps_time, ((LASpoint14*)item)->X, ((LASpoint14*)item)->Y, ((LASpoint14*)item)->Z, ((LASpoint14*)item)->intensity, ((LASpoint14*)item)->return_number, ((LASpoint14*)item)->number_of_returns); contexts[context].unused = FALSE; @@ -2133,7 +2133,14 @@ LASreadItemCompressed_BYTE14_v4::LASreadItemCompressed_BYTE14_v4(ArithmeticDecod changed_Bytes[i] = FALSE; - requested_Bytes[i] = (decompress_selective & (LASZIP_DECOMPRESS_SELECTIVE_BYTE0 << i) ? TRUE : FALSE); + if (i > 15) // currently only the first 16 extra bytes can be selectively decompressed + { + requested_Bytes[i] = TRUE; + } + else + { + requested_Bytes[i] = (decompress_selective & (LASZIP_DECOMPRESS_SELECTIVE_BYTE0 << i) ? TRUE : FALSE); + } } /* init the bytes buffer to zero */ diff --git a/inst/include/lasreaditemcompressed_v4.hpp b/src/LASzip/lasreaditemcompressed_v4.hpp similarity index 100% rename from inst/include/lasreaditemcompressed_v4.hpp rename to src/LASzip/lasreaditemcompressed_v4.hpp diff --git a/inst/include/lasreaditemraw.hpp b/src/LASzip/lasreaditemraw.hpp similarity index 100% rename from inst/include/lasreaditemraw.hpp rename to src/LASzip/lasreaditemraw.hpp diff --git a/src/LASzip/lasreadpoint.cpp b/src/LASzip/lasreadpoint.cpp index e880cdc..660b943 100644 --- a/src/LASzip/lasreadpoint.cpp +++ b/src/LASzip/lasreadpoint.cpp @@ -432,7 +432,7 @@ BOOL LASreadPoint::read(U8* const * point) init_dec(); if (current_chunk == tabled_chunks) // no or incomplete chunk table? { - if (current_chunk == number_chunks) + if (current_chunk >= number_chunks) { number_chunks += 256; chunk_starts = (I64*)realloc(chunk_starts, sizeof(I64)*(number_chunks+1)); @@ -477,7 +477,7 @@ BOOL LASreadPoint::read(U8* const * point) { ((LASreadItemCompressed*)(readers_compressed[i]))->init(point[i], context); } - if (DEBUG_OUTPUT_NUM_BYTES_DETAILS) REprintf( "\n"); + if (DEBUG_OUTPUT_NUM_BYTES_DETAILS) fprintf(stderr, "\n"); } else { @@ -545,11 +545,11 @@ BOOL LASreadPoint::check_end() if (current_chunk < tabled_chunks) { I64 here = instream->tell(); - if (chunk_starts[current_chunk] != here) + if (chunk_starts[current_chunk] != here) // then last chunk was corrupt { // create error string if (last_error == 0) last_error = new CHAR[128]; - // last chunk was corrupt + // report error sprintf(last_error, "chunk with index %u of %u is corrupt", current_chunk, tabled_chunks); return FALSE; } @@ -603,6 +603,10 @@ BOOL LASreadPoint::read_chunk_table() // no choice but to fail if adaptive chunking was used if (chunk_size == U32_MAX) { + // create error string + if (last_error == 0) last_error = new CHAR[128]; + // report error + sprintf(last_error, "compressor was interrupted before writing adaptive chunk table of LAZ file"); return FALSE; } // otherwise we build the chunk table as we read the file @@ -614,6 +618,10 @@ BOOL LASreadPoint::read_chunk_table() } chunk_starts[0] = chunks_start; tabled_chunks = 1; + // create warning string + if (last_warning == 0) last_warning = new CHAR[128]; + // report warning + sprintf(last_warning, "compressor was interrupted before writing chunk table of LAZ file"); return TRUE; } @@ -647,9 +655,17 @@ BOOL LASreadPoint::read_chunk_table() // read the chunk table try { + // seek to where the chunk table instream->seek(chunk_table_start_position); + // fail if we did not manage to seek there + I64 where_are_we_now = instream->tell(); + if (where_are_we_now != chunk_table_start_position) + { + throw 1; + } U32 version; instream->get32bitsLE((U8*)&version); + // fail if the version is wrong if (version != 0) { throw 1; @@ -733,8 +749,32 @@ BOOL LASreadPoint::read_chunk_table() } // create warning string if (last_warning == 0) last_warning = new CHAR[128]; - // report warning - sprintf(last_warning, "corrupt chunk table"); + // first seek to the end of the file + instream->seekEnd(); + // get position of last byte + I64 last_position = instream->tell(); + // warn if last byte position is before chunk table start position + if (last_position <= chunk_table_start_position) + { + // report warning + if (last_position == chunk_table_start_position) + { + sprintf(last_warning, "chunk table is missing. improper use of LAZ compressor?"); + } + else + { +#ifdef _WIN32 + sprintf(last_warning, "chunk table and %I64d bytes are missing. LAZ file truncated during copy or transfer?", chunk_table_start_position - last_position); +#else + sprintf(last_warning, "chunk table and %lld bytes are missing. LAZ file truncated during copy or transfer?", chunk_table_start_position - last_position); +#endif + } + } + else + { + // report warning + sprintf(last_warning, "corrupt chunk table"); + } } if (!instream->seek(chunks_start)) { diff --git a/inst/include/lasreadpoint.hpp b/src/LASzip/lasreadpoint.hpp similarity index 95% rename from inst/include/lasreadpoint.hpp rename to src/LASzip/lasreadpoint.hpp index a105544..070c480 100644 --- a/inst/include/lasreadpoint.hpp +++ b/src/LASzip/lasreadpoint.hpp @@ -13,7 +13,7 @@ COPYRIGHT: - (c) 2007-2017, martin isenburg, rapidlasso - fast tools to catch reality + (c) 2007-2020, martin isenburg, rapidlasso - fast tools to catch reality This is free software; you can redistribute and/or modify it under the terms of the GNU Lesser General Licence as published by the Free Software @@ -24,6 +24,7 @@ CHANGE HISTORY: + 23 September 2020 -- rare fix for bit-corrupted LAZ files where chunk table is zeroed 28 August 2017 -- moving 'context' from global development hack to interface 18 July 2017 -- bug fix for spatial-indexed reading of native compressed LAS 1.4 19 April 2017 -- support for selective decompression for new LAS 1.4 points diff --git a/src/LASzip/lasunzipper.cpp b/src/LASzip/lasunzipper.cpp deleted file mode 100644 index 2e8bc75..0000000 --- a/src/LASzip/lasunzipper.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/* -=============================================================================== - - FILE: lasunzipper.cpp - - CONTENTS: - - see corresponding header file - - PROGRAMMERS: - - martin.isenburg@rapidlasso.com - http://rapidlasso.com - - COPYRIGHT: - - (c) 2007-2013, martin isenburg, rapidlasso - fast tools to catch reality - - This is free software; you can redistribute and/or modify it under the - terms of the GNU Lesser General Licence as published by the Free Software - Foundation. See the COPYING file for more information. - - This software is distributed WITHOUT ANY WARRANTY and without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - - CHANGE HISTORY: - - see corresponding header file - -=============================================================================== -*/ -#include "lasunzipper.hpp" - -#include -#include - -#include "bytestreamin_file.hpp" -#include "bytestreamin_istream.hpp" -#include "lasreadpoint.hpp" - -bool LASunzipper::open(FILE* infile, const LASzip* laszip) -{ - if (!infile) return return_error("FILE* infile pointer is NULL"); - if (!laszip) return return_error("const LASzip* laszip pointer is NULL"); - count = 0; - if (reader) delete reader; - reader = new LASreadPoint(); - if (!reader) return return_error("alloc of LASreadPoint failed"); - if (!reader->setup(laszip->num_items, laszip->items, laszip)) return return_error("setup() of LASreadPoint failed"); - if (stream) delete stream; - if (IS_LITTLE_ENDIAN()) - stream = new ByteStreamInFileLE(infile); - else - stream = new ByteStreamInFileBE(infile); - if (!stream) return return_error("alloc of ByteStreamInFile failed"); - if (!reader->init(stream)) return return_error("init() of LASreadPoint failed"); - return true; -} - -bool LASunzipper::open(istream& instream, const LASzip* laszip) -{ - if (!laszip) return return_error("const LASzip* laszip pointer is NULL"); - count = 0; - if (reader) delete reader; - reader = new LASreadPoint(); - if (!reader) return return_error("alloc of LASreadPoint failed"); - if (!reader->setup(laszip->num_items, laszip->items, laszip)) return return_error("setup() of LASreadPoint failed"); - if (stream) delete stream; - if (IS_LITTLE_ENDIAN()) - stream = new ByteStreamInIstreamLE(instream); - else - stream = new ByteStreamInIstreamBE(instream); - if (!stream) return return_error("alloc of ByteStreamInStream failed"); - if (!reader->init(stream)) return return_error("init() of LASreadPoint failed"); - return true; -} - -bool LASunzipper::seek(const unsigned int position) -{ - if (!reader->seek(count, position)) return return_error("seek() of LASreadPoint failed"); - count = position; - return true; -} - -unsigned int LASunzipper::tell() const -{ - return count; -} - -bool LASunzipper::read(unsigned char * const * point) -{ - count++; - return (reader->read(point) == TRUE); -} - -bool LASunzipper::close() -{ - BOOL done = TRUE; - if (reader) - { - done = reader->done(); - delete reader; - reader = 0; - } - if (stream) - { - delete stream; - stream = 0; - } - if (!done) return return_error("done() of LASreadPoint failed"); - return true; -} - -const char* LASunzipper::get_error() const -{ - return error_string; -} - -bool LASunzipper::return_error(const char* error) -{ - char err[256]; - sprintf(err, "%s (LASzip v%d.%dr%d)", error, LASZIP_VERSION_MAJOR, LASZIP_VERSION_MINOR, LASZIP_VERSION_REVISION); - if (error_string) free(error_string); - error_string = LASCopyString(err); - return false; -} - -LASunzipper::LASunzipper() -{ - error_string = 0; - count = 0; - stream = 0; - reader = 0; -} - -LASunzipper::~LASunzipper() -{ - if (error_string) free(error_string); - if (reader || stream) close(); -} diff --git a/inst/include/laswriteitem.hpp b/src/LASzip/laswriteitem.hpp similarity index 100% rename from inst/include/laswriteitem.hpp rename to src/LASzip/laswriteitem.hpp diff --git a/inst/include/laswriteitemcompressed_v1.hpp b/src/LASzip/laswriteitemcompressed_v1.hpp similarity index 100% rename from inst/include/laswriteitemcompressed_v1.hpp rename to src/LASzip/laswriteitemcompressed_v1.hpp diff --git a/inst/include/laswriteitemcompressed_v2.hpp b/src/LASzip/laswriteitemcompressed_v2.hpp similarity index 100% rename from inst/include/laswriteitemcompressed_v2.hpp rename to src/LASzip/laswriteitemcompressed_v2.hpp diff --git a/src/LASzip/laswriteitemcompressed_v3.cpp b/src/LASzip/laswriteitemcompressed_v3.cpp index 0acda31..12440f2 100644 --- a/src/LASzip/laswriteitemcompressed_v3.cpp +++ b/src/LASzip/laswriteitemcompressed_v3.cpp @@ -2,11 +2,11 @@ =============================================================================== FILE: laswriteitemcompressed_v3.cpp - + CONTENTS: - + see corresponding header file - + PROGRAMMERS: martin.isenburg@rapidlasso.com - http://rapidlasso.com @@ -21,11 +21,11 @@ This software is distributed WITHOUT ANY WARRANTY and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - + CHANGE HISTORY: - + see corresponding header file - + =============================================================================== */ @@ -84,7 +84,7 @@ typedef struct LASpoint14 #define LASZIP_GPSTIME_MULTI_MINUS -10 #define LASZIP_GPSTIME_MULTI_CODE_FULL (LASZIP_GPSTIME_MULTI - LASZIP_GPSTIME_MULTI_MINUS + 1) -#define LASZIP_GPSTIME_MULTI_TOTAL (LASZIP_GPSTIME_MULTI - LASZIP_GPSTIME_MULTI_MINUS + 5) +#define LASZIP_GPSTIME_MULTI_TOTAL (LASZIP_GPSTIME_MULTI - LASZIP_GPSTIME_MULTI_MINUS + 5) LASwriteItemCompressed_POINT14_v3::LASwriteItemCompressed_POINT14_v3(ArithmeticEncoder* enc) { @@ -125,7 +125,7 @@ LASwriteItemCompressed_POINT14_v3::LASwriteItemCompressed_POINT14_v3(ArithmeticE current_context = 0; /* number of bytes per layer */ - + num_bytes_channel_returns_XY = 0; num_bytes_Z = 0; num_bytes_classification = 0; @@ -204,6 +204,8 @@ LASwriteItemCompressed_POINT14_v3::~LASwriteItemCompressed_POINT14_v3() delete outstream_point_source; delete outstream_gps_time; } + +// fprintf(stderr, "%u %u %u %u %u %u %u %u %u\n", num_bytes_channel_returns_XY, num_bytes_Z, num_bytes_classification, num_bytes_flags, num_bytes_intensity, num_bytes_scan_angle, num_bytes_user_data, num_bytes_point_source, num_bytes_gps_time); } inline BOOL LASwriteItemCompressed_POINT14_v3::createAndInitModelsAndCompressors(U32 context, const U8* item) @@ -299,7 +301,7 @@ inline BOOL LASwriteItemCompressed_POINT14_v3::createAndInitModelsAndCompressors contexts[context].last_X_diff_median5[i].init(); contexts[context].last_Y_diff_median5[i].init(); } - + /* for the Z layer */ contexts[context].ic_Z->initCompressor(); @@ -471,7 +473,7 @@ inline BOOL LASwriteItemCompressed_POINT14_v3::write(const U8* item, U32& contex U8* last_item = contexts[current_context].last_item; //////////////////////////////////////// - // compress returns_XY layer + // compress returns_XY layer //////////////////////////////////////// // create single (3) / first (1) / last (2) / intermediate (0) context from last point return @@ -633,7 +635,7 @@ inline BOOL LASwriteItemCompressed_POINT14_v3::write(const U8* item, U32& contex contexts[current_context].last_Y_diff_median5[(m<<1) | gps_time_change].add(diff); //////////////////////////////////////// - // compress Z layer + // compress Z layer //////////////////////////////////////// k_bits = (contexts[current_context].ic_dX->getK() + contexts[current_context].ic_dY->getK()) / 2; @@ -641,7 +643,7 @@ inline BOOL LASwriteItemCompressed_POINT14_v3::write(const U8* item, U32& contex contexts[current_context].last_Z[l] = ((LASpoint14*)item)->Z; //////////////////////////////////////// - // compress classifications layer + // compress classifications layer //////////////////////////////////////// U32 last_classification = ((LASpoint14*)last_item)->classification; @@ -661,7 +663,7 @@ inline BOOL LASwriteItemCompressed_POINT14_v3::write(const U8* item, U32& contex enc_classification->encodeSymbol(contexts[current_context].m_classification[ccc], classification); //////////////////////////////////////// - // compress flags layer + // compress flags layer //////////////////////////////////////// U32 last_flags = (((LASpoint14*)last_item)->edge_of_flight_line << 5) | (((LASpoint14*)last_item)->scan_direction_flag << 4) | ((LASpoint14*)last_item)->classification_flags; @@ -680,7 +682,7 @@ inline BOOL LASwriteItemCompressed_POINT14_v3::write(const U8* item, U32& contex enc_flags->encodeSymbol(contexts[current_context].m_flags[last_flags], flags); //////////////////////////////////////// - // compress intensity layer + // compress intensity layer //////////////////////////////////////// if (((LASpoint14*)item)->intensity != ((LASpoint14*)last_item)->intensity) @@ -689,9 +691,9 @@ inline BOOL LASwriteItemCompressed_POINT14_v3::write(const U8* item, U32& contex } contexts[current_context].ic_intensity->compress(contexts[current_context].last_intensity[(cpr<<1) | gps_time_change], ((LASpoint14*)item)->intensity, cpr); contexts[current_context].last_intensity[(cpr<<1) | gps_time_change] = ((LASpoint14*)item)->intensity; - + //////////////////////////////////////// - // compress scan_angle layer + // compress scan_angle layer //////////////////////////////////////// if (scan_angle_change) @@ -701,7 +703,7 @@ inline BOOL LASwriteItemCompressed_POINT14_v3::write(const U8* item, U32& contex } //////////////////////////////////////// - // compress user_data layer + // compress user_data layer //////////////////////////////////////// if (((LASpoint14*)item)->user_data != ((LASpoint14*)last_item)->user_data) @@ -716,7 +718,7 @@ inline BOOL LASwriteItemCompressed_POINT14_v3::write(const U8* item, U32& contex enc_user_data->encodeSymbol(contexts[current_context].m_user_data[((LASpoint14*)last_item)->user_data/4], ((LASpoint14*)item)->user_data); //////////////////////////////////////// - // compress point_source layer + // compress point_source layer //////////////////////////////////////// if (point_source_change) @@ -726,7 +728,7 @@ inline BOOL LASwriteItemCompressed_POINT14_v3::write(const U8* item, U32& contex } //////////////////////////////////////// - // compress gps_time layer + // compress gps_time layer //////////////////////////////////////// if (gps_time_change) // if the GPS time has changed @@ -973,7 +975,7 @@ void LASwriteItemCompressed_POINT14_v3::write_gps_time(const U64I64F64 gps_time) enc_gps_time->encodeSymbol(contexts[current_context].m_gpstime_0diff, 0); // the difference can be represented with 32 bits contexts[current_context].ic_gpstime->compress(0, curr_gpstime_diff, 0); contexts[current_context].last_gpstime_diff[contexts[current_context].last] = curr_gpstime_diff; - contexts[current_context].multi_extreme_counter[contexts[current_context].last] = 0; + contexts[current_context].multi_extreme_counter[contexts[current_context].last] = 0; } else // the difference is huge { @@ -985,20 +987,20 @@ void LASwriteItemCompressed_POINT14_v3::write_gps_time(const U64I64F64 gps_time) I32 other_gpstime_diff = (I32)other_gpstime_diff_64; if (other_gpstime_diff_64 == (I64)(other_gpstime_diff)) { - enc_gps_time->encodeSymbol(contexts[current_context].m_gpstime_0diff, i+1); // it belongs to another sequence + enc_gps_time->encodeSymbol(contexts[current_context].m_gpstime_0diff, i+1); // it belongs to another sequence contexts[current_context].last = (contexts[current_context].last+i)&3; write_gps_time(gps_time); return; } } // no other sequence found. start new sequence. - enc_gps_time->encodeSymbol(contexts[current_context].m_gpstime_0diff, 1); + enc_gps_time->encodeSymbol(contexts[current_context].m_gpstime_0diff, 1); contexts[current_context].ic_gpstime->compress((I32)(contexts[current_context].last_gpstime[contexts[current_context].last].u64 >> 32), (I32)(gps_time.u64 >> 32), 8); enc_gps_time->writeInt((U32)(gps_time.u64)); contexts[current_context].next = (contexts[current_context].next+1)&3; contexts[current_context].last = contexts[current_context].next; contexts[current_context].last_gpstime_diff[contexts[current_context].last] = 0; - contexts[current_context].multi_extreme_counter[contexts[current_context].last] = 0; + contexts[current_context].multi_extreme_counter[contexts[current_context].last] = 0; } contexts[current_context].last_gpstime[contexts[current_context].last].i64 = gps_time.i64; } @@ -1021,7 +1023,7 @@ void LASwriteItemCompressed_POINT14_v3::write_gps_time(const U64I64F64 gps_time) // this is the case we assume we get most often for regular spaced pulses enc_gps_time->encodeSymbol(contexts[current_context].m_gpstime_multi, 1); contexts[current_context].ic_gpstime->compress(contexts[current_context].last_gpstime_diff[contexts[current_context].last], curr_gpstime_diff, 1); - contexts[current_context].multi_extreme_counter[contexts[current_context].last] = 0; + contexts[current_context].multi_extreme_counter[contexts[current_context].last] = 0; } else if (multi > 0) { @@ -1086,7 +1088,7 @@ void LASwriteItemCompressed_POINT14_v3::write_gps_time(const U64I64F64 gps_time) I32 other_gpstime_diff = (I32)other_gpstime_diff_64; if (other_gpstime_diff_64 == (I64)(other_gpstime_diff)) { - // it belongs to this sequence + // it belongs to this sequence enc_gps_time->encodeSymbol(contexts[current_context].m_gpstime_multi, LASZIP_GPSTIME_MULTI_CODE_FULL+i); contexts[current_context].last = (contexts[current_context].last+i)&3; write_gps_time(gps_time); @@ -1100,7 +1102,7 @@ void LASwriteItemCompressed_POINT14_v3::write_gps_time(const U64I64F64 gps_time) contexts[current_context].next = (contexts[current_context].next+1)&3; contexts[current_context].last = contexts[current_context].next; contexts[current_context].last_gpstime_diff[contexts[current_context].last] = 0; - contexts[current_context].multi_extreme_counter[contexts[current_context].last] = 0; + contexts[current_context].multi_extreme_counter[contexts[current_context].last] = 0; } contexts[current_context].last_gpstime[contexts[current_context].last].i64 = gps_time.i64; } @@ -1235,7 +1237,7 @@ BOOL LASwriteItemCompressed_RGB14_v3::init(const U8* item, U32& context) outstream_RGB->seek(0); } - + /* init layer encoders */ enc_RGB->init(outstream_RGB); @@ -1530,7 +1532,7 @@ BOOL LASwriteItemCompressed_RGBNIR14_v3::init(const U8* item, U32& context) outstream_RGB->seek(0); outstream_NIR->seek(0); } - + /* init layer encoders */ enc_RGB->init(outstream_RGB); @@ -1648,7 +1650,7 @@ inline BOOL LASwriteItemCompressed_RGBNIR14_v3::write(const U8* item, U32& conte { changed_NIR = TRUE; } - + memcpy(last_item, item, 8); return TRUE; } @@ -1857,7 +1859,7 @@ BOOL LASwriteItemCompressed_WAVEPACKET14_v3::init(const U8* item, U32& context) outstream_wavepacket->seek(0); } - + /* init layer encoders */ enc_wavepacket->init(outstream_wavepacket); @@ -2024,7 +2026,7 @@ LASwriteItemCompressed_BYTE14_v3::LASwriteItemCompressed_BYTE14_v3(ArithmeticEnc enc_Bytes = 0; /* number of bytes per layer */ - + num_bytes_Bytes = new U32[number]; changed_Bytes = new BOOL[number]; @@ -2177,7 +2179,7 @@ BOOL LASwriteItemCompressed_BYTE14_v3::init(const U8* item, U32& context) outstream_Bytes[i]->seek(0); } } - + /* init layer encoders */ for (i = 0; i < number; i++) diff --git a/inst/include/laswriteitemcompressed_v3.hpp b/src/LASzip/laswriteitemcompressed_v3.hpp similarity index 100% rename from inst/include/laswriteitemcompressed_v3.hpp rename to src/LASzip/laswriteitemcompressed_v3.hpp diff --git a/src/LASzip/laswriteitemcompressed_v4.cpp b/src/LASzip/laswriteitemcompressed_v4.cpp index 2b3d4e4..c967006 100644 --- a/src/LASzip/laswriteitemcompressed_v4.cpp +++ b/src/LASzip/laswriteitemcompressed_v4.cpp @@ -2,11 +2,11 @@ =============================================================================== FILE: laswriteitemcompressed_v4.cpp - + CONTENTS: - + see corresponding header file - + PROGRAMMERS: martin.isenburg@rapidlasso.com - http://rapidlasso.com @@ -21,11 +21,11 @@ This software is distributed WITHOUT ANY WARRANTY and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - + CHANGE HISTORY: - + see corresponding header file - + =============================================================================== */ @@ -84,7 +84,7 @@ typedef struct LASpoint14 #define LASZIP_GPSTIME_MULTI_MINUS -10 #define LASZIP_GPSTIME_MULTI_CODE_FULL (LASZIP_GPSTIME_MULTI - LASZIP_GPSTIME_MULTI_MINUS + 1) -#define LASZIP_GPSTIME_MULTI_TOTAL (LASZIP_GPSTIME_MULTI - LASZIP_GPSTIME_MULTI_MINUS + 5) +#define LASZIP_GPSTIME_MULTI_TOTAL (LASZIP_GPSTIME_MULTI - LASZIP_GPSTIME_MULTI_MINUS + 5) LASwriteItemCompressed_POINT14_v4::LASwriteItemCompressed_POINT14_v4(ArithmeticEncoder* enc) { @@ -125,7 +125,7 @@ LASwriteItemCompressed_POINT14_v4::LASwriteItemCompressed_POINT14_v4(ArithmeticE current_context = 0; /* number of bytes per layer */ - + num_bytes_channel_returns_XY = 0; num_bytes_Z = 0; num_bytes_classification = 0; @@ -299,7 +299,7 @@ inline BOOL LASwriteItemCompressed_POINT14_v4::createAndInitModelsAndCompressors contexts[context].last_X_diff_median5[i].init(); contexts[context].last_Y_diff_median5[i].init(); } - + /* for the Z layer */ contexts[context].ic_Z->initCompressor(); @@ -471,7 +471,7 @@ inline BOOL LASwriteItemCompressed_POINT14_v4::write(const U8* item, U32& contex U8* last_item = contexts[current_context].last_item; //////////////////////////////////////// - // compress returns_XY layer + // compress returns_XY layer //////////////////////////////////////// // create single (3) / first (1) / last (2) / intermediate (0) context from last point return @@ -633,7 +633,7 @@ inline BOOL LASwriteItemCompressed_POINT14_v4::write(const U8* item, U32& contex contexts[current_context].last_Y_diff_median5[(m<<1) | gps_time_change].add(diff); //////////////////////////////////////// - // compress Z layer + // compress Z layer //////////////////////////////////////// k_bits = (contexts[current_context].ic_dX->getK() + contexts[current_context].ic_dY->getK()) / 2; @@ -641,7 +641,7 @@ inline BOOL LASwriteItemCompressed_POINT14_v4::write(const U8* item, U32& contex contexts[current_context].last_Z[l] = ((LASpoint14*)item)->Z; //////////////////////////////////////// - // compress classifications layer + // compress classifications layer //////////////////////////////////////// U32 last_classification = ((LASpoint14*)last_item)->classification; @@ -661,7 +661,7 @@ inline BOOL LASwriteItemCompressed_POINT14_v4::write(const U8* item, U32& contex enc_classification->encodeSymbol(contexts[current_context].m_classification[ccc], classification); //////////////////////////////////////// - // compress flags layer + // compress flags layer //////////////////////////////////////// U32 last_flags = (((LASpoint14*)last_item)->edge_of_flight_line << 5) | (((LASpoint14*)last_item)->scan_direction_flag << 4) | ((LASpoint14*)last_item)->classification_flags; @@ -680,7 +680,7 @@ inline BOOL LASwriteItemCompressed_POINT14_v4::write(const U8* item, U32& contex enc_flags->encodeSymbol(contexts[current_context].m_flags[last_flags], flags); //////////////////////////////////////// - // compress intensity layer + // compress intensity layer //////////////////////////////////////// if (((LASpoint14*)item)->intensity != ((LASpoint14*)last_item)->intensity) @@ -689,9 +689,9 @@ inline BOOL LASwriteItemCompressed_POINT14_v4::write(const U8* item, U32& contex } contexts[current_context].ic_intensity->compress(contexts[current_context].last_intensity[(cpr<<1) | gps_time_change], ((LASpoint14*)item)->intensity, cpr); contexts[current_context].last_intensity[(cpr<<1) | gps_time_change] = ((LASpoint14*)item)->intensity; - + //////////////////////////////////////// - // compress scan_angle layer + // compress scan_angle layer //////////////////////////////////////// if (scan_angle_change) @@ -701,7 +701,7 @@ inline BOOL LASwriteItemCompressed_POINT14_v4::write(const U8* item, U32& contex } //////////////////////////////////////// - // compress user_data layer + // compress user_data layer //////////////////////////////////////// if (((LASpoint14*)item)->user_data != ((LASpoint14*)last_item)->user_data) @@ -716,7 +716,7 @@ inline BOOL LASwriteItemCompressed_POINT14_v4::write(const U8* item, U32& contex enc_user_data->encodeSymbol(contexts[current_context].m_user_data[((LASpoint14*)last_item)->user_data/4], ((LASpoint14*)item)->user_data); //////////////////////////////////////// - // compress point_source layer + // compress point_source layer //////////////////////////////////////// if (point_source_change) @@ -726,7 +726,7 @@ inline BOOL LASwriteItemCompressed_POINT14_v4::write(const U8* item, U32& contex } //////////////////////////////////////// - // compress gps_time layer + // compress gps_time layer //////////////////////////////////////// if (gps_time_change) // if the GPS time has changed @@ -973,7 +973,7 @@ void LASwriteItemCompressed_POINT14_v4::write_gps_time(const U64I64F64 gps_time) enc_gps_time->encodeSymbol(contexts[current_context].m_gpstime_0diff, 0); // the difference can be represented with 32 bits contexts[current_context].ic_gpstime->compress(0, curr_gpstime_diff, 0); contexts[current_context].last_gpstime_diff[contexts[current_context].last] = curr_gpstime_diff; - contexts[current_context].multi_extreme_counter[contexts[current_context].last] = 0; + contexts[current_context].multi_extreme_counter[contexts[current_context].last] = 0; } else // the difference is huge { @@ -985,20 +985,20 @@ void LASwriteItemCompressed_POINT14_v4::write_gps_time(const U64I64F64 gps_time) I32 other_gpstime_diff = (I32)other_gpstime_diff_64; if (other_gpstime_diff_64 == (I64)(other_gpstime_diff)) { - enc_gps_time->encodeSymbol(contexts[current_context].m_gpstime_0diff, i+1); // it belongs to another sequence + enc_gps_time->encodeSymbol(contexts[current_context].m_gpstime_0diff, i+1); // it belongs to another sequence contexts[current_context].last = (contexts[current_context].last+i)&3; write_gps_time(gps_time); return; } } // no other sequence found. start new sequence. - enc_gps_time->encodeSymbol(contexts[current_context].m_gpstime_0diff, 1); + enc_gps_time->encodeSymbol(contexts[current_context].m_gpstime_0diff, 1); contexts[current_context].ic_gpstime->compress((I32)(contexts[current_context].last_gpstime[contexts[current_context].last].u64 >> 32), (I32)(gps_time.u64 >> 32), 8); enc_gps_time->writeInt((U32)(gps_time.u64)); contexts[current_context].next = (contexts[current_context].next+1)&3; contexts[current_context].last = contexts[current_context].next; contexts[current_context].last_gpstime_diff[contexts[current_context].last] = 0; - contexts[current_context].multi_extreme_counter[contexts[current_context].last] = 0; + contexts[current_context].multi_extreme_counter[contexts[current_context].last] = 0; } contexts[current_context].last_gpstime[contexts[current_context].last].i64 = gps_time.i64; } @@ -1021,7 +1021,7 @@ void LASwriteItemCompressed_POINT14_v4::write_gps_time(const U64I64F64 gps_time) // this is the case we assume we get most often for regular spaced pulses enc_gps_time->encodeSymbol(contexts[current_context].m_gpstime_multi, 1); contexts[current_context].ic_gpstime->compress(contexts[current_context].last_gpstime_diff[contexts[current_context].last], curr_gpstime_diff, 1); - contexts[current_context].multi_extreme_counter[contexts[current_context].last] = 0; + contexts[current_context].multi_extreme_counter[contexts[current_context].last] = 0; } else if (multi > 0) { @@ -1086,7 +1086,7 @@ void LASwriteItemCompressed_POINT14_v4::write_gps_time(const U64I64F64 gps_time) I32 other_gpstime_diff = (I32)other_gpstime_diff_64; if (other_gpstime_diff_64 == (I64)(other_gpstime_diff)) { - // it belongs to this sequence + // it belongs to this sequence enc_gps_time->encodeSymbol(contexts[current_context].m_gpstime_multi, LASZIP_GPSTIME_MULTI_CODE_FULL+i); contexts[current_context].last = (contexts[current_context].last+i)&3; write_gps_time(gps_time); @@ -1100,7 +1100,7 @@ void LASwriteItemCompressed_POINT14_v4::write_gps_time(const U64I64F64 gps_time) contexts[current_context].next = (contexts[current_context].next+1)&3; contexts[current_context].last = contexts[current_context].next; contexts[current_context].last_gpstime_diff[contexts[current_context].last] = 0; - contexts[current_context].multi_extreme_counter[contexts[current_context].last] = 0; + contexts[current_context].multi_extreme_counter[contexts[current_context].last] = 0; } contexts[current_context].last_gpstime[contexts[current_context].last].i64 = gps_time.i64; } @@ -1235,7 +1235,7 @@ BOOL LASwriteItemCompressed_RGB14_v4::init(const U8* item, U32& context) outstream_RGB->seek(0); } - + /* init layer encoders */ enc_RGB->init(outstream_RGB); @@ -1530,7 +1530,7 @@ BOOL LASwriteItemCompressed_RGBNIR14_v4::init(const U8* item, U32& context) outstream_RGB->seek(0); outstream_NIR->seek(0); } - + /* init layer encoders */ enc_RGB->init(outstream_RGB); @@ -1648,7 +1648,7 @@ inline BOOL LASwriteItemCompressed_RGBNIR14_v4::write(const U8* item, U32& conte { changed_NIR = TRUE; } - + memcpy(last_item, item, 8); return TRUE; } @@ -1857,7 +1857,7 @@ BOOL LASwriteItemCompressed_WAVEPACKET14_v4::init(const U8* item, U32& context) outstream_wavepacket->seek(0); } - + /* init layer encoders */ enc_wavepacket->init(outstream_wavepacket); @@ -2024,7 +2024,7 @@ LASwriteItemCompressed_BYTE14_v4::LASwriteItemCompressed_BYTE14_v4(ArithmeticEnc enc_Bytes = 0; /* number of bytes per layer */ - + num_bytes_Bytes = new U32[number]; changed_Bytes = new BOOL[number]; @@ -2177,7 +2177,7 @@ BOOL LASwriteItemCompressed_BYTE14_v4::init(const U8* item, U32& context) outstream_Bytes[i]->seek(0); } } - + /* init layer encoders */ for (i = 0; i < number; i++) diff --git a/inst/include/laswriteitemcompressed_v4.hpp b/src/LASzip/laswriteitemcompressed_v4.hpp similarity index 100% rename from inst/include/laswriteitemcompressed_v4.hpp rename to src/LASzip/laswriteitemcompressed_v4.hpp diff --git a/inst/include/laswriteitemraw.hpp b/src/LASzip/laswriteitemraw.hpp similarity index 100% rename from inst/include/laswriteitemraw.hpp rename to src/LASzip/laswriteitemraw.hpp diff --git a/inst/include/laswritepoint.hpp b/src/LASzip/laswritepoint.hpp similarity index 100% rename from inst/include/laswritepoint.hpp rename to src/LASzip/laswritepoint.hpp diff --git a/src/LASzip/laszip.cpp b/src/LASzip/laszip.cpp index 1374952..3c938e8 100644 --- a/src/LASzip/laszip.cpp +++ b/src/LASzip/laszip.cpp @@ -13,7 +13,7 @@ COPYRIGHT: - (c) 2007-2013, martin isenburg, rapidlasso - fast tools to catch reality + (c) 2007-2019, martin isenburg, rapidlasso - fast tools to catch reality This is free software; you can redistribute and/or modify it under the terms of the GNU Lesser General Licence as published by the Free Software @@ -29,7 +29,9 @@ =============================================================================== */ #include "laszip.hpp" + #include "mydefs.hpp" + #include #include @@ -494,7 +496,7 @@ bool LASzip::setup(U16* num_items, LASitem** items, const U8 point_type, const U if (extra_bytes_number < 0) { - REprintf( "WARNING: point size %d too small by %d bytes for point type %d. assuming point_size of %d\n", point_size, -extra_bytes_number, point_type, point_size-extra_bytes_number); + fprintf(stderr, "WARNING: point size %d too small by %d bytes for point type %d. assuming point_size of %d\n", point_size, -extra_bytes_number, point_type, point_size-extra_bytes_number); extra_bytes_number = 0; } @@ -1001,3 +1003,4 @@ const char* LASitem::get_name() const } return 0; } + diff --git a/inst/include/laszip.hpp b/src/LASzip/laszip.hpp similarity index 97% rename from inst/include/laszip.hpp rename to src/LASzip/laszip.hpp index 7946a0b..0e70503 100644 --- a/inst/include/laszip.hpp +++ b/src/LASzip/laszip.hpp @@ -65,8 +65,7 @@ typedef __int64 SIGNED_INT64; typedef long long SIGNED_INT64; #endif -#if defined(_MSC_VER) && \ - (_MSC_FULL_VER >= 150000000) +#if defined(_MSC_VER) && (_MSC_FULL_VER >= 150000000) #define LASCopyString _strdup #else #define LASCopyString strdup @@ -74,8 +73,8 @@ typedef long long SIGNED_INT64; #define LASZIP_VERSION_MAJOR 3 #define LASZIP_VERSION_MINOR 4 -#define LASZIP_VERSION_REVISION 1 -#define LASZIP_VERSION_BUILD_DATE 190411 +#define LASZIP_VERSION_REVISION 3 +#define LASZIP_VERSION_BUILD_DATE 191111 #define LASZIP_COMPRESSOR_NONE 0 #define LASZIP_COMPRESSOR_POINTWISE 1 diff --git a/inst/include/laszip_common_v1.hpp b/src/LASzip/laszip_common_v1.hpp similarity index 100% rename from inst/include/laszip_common_v1.hpp rename to src/LASzip/laszip_common_v1.hpp diff --git a/inst/include/laszip_common_v2.hpp b/src/LASzip/laszip_common_v2.hpp similarity index 100% rename from inst/include/laszip_common_v2.hpp rename to src/LASzip/laszip_common_v2.hpp diff --git a/inst/include/laszip_common_v3.hpp b/src/LASzip/laszip_common_v3.hpp similarity index 100% rename from inst/include/laszip_common_v3.hpp rename to src/LASzip/laszip_common_v3.hpp diff --git a/inst/include/laszip_decompress_selective_v3.hpp b/src/LASzip/laszip_decompress_selective_v3.hpp similarity index 100% rename from inst/include/laszip_decompress_selective_v3.hpp rename to src/LASzip/laszip_decompress_selective_v3.hpp diff --git a/src/LASzip/laszipper.cpp b/src/LASzip/laszipper.cpp deleted file mode 100644 index 9c5dfa8..0000000 --- a/src/LASzip/laszipper.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* -=============================================================================== - - FILE: laszipper.cpp - - CONTENTS: - - see corresponding header file - - PROGRAMMERS: - - martin.isenburg@rapidlasso.com - http://rapidlasso.com - - COPYRIGHT: - - (c) 2007-2013, martin isenburg, rapidlasso - fast tools to catch reality - - This is free software; you can redistribute and/or modify it under the - terms of the GNU Lesser General Licence as published by the Free Software - Foundation. See the COPYING file for more information. - - This software is distributed WITHOUT ANY WARRANTY and without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - - CHANGE HISTORY: - - see corresponding header file - -=============================================================================== -*/ -#include "laszipper.hpp" - -#include -#include - -#include "bytestreamout_file.hpp" -#include "bytestreamout_ostream.hpp" -#include "laswritepoint.hpp" - -bool LASzipper::open(FILE* outfile, const LASzip* laszip) -{ - if (!outfile) return return_error("FILE* outfile pointer is NULL"); - if (!laszip) return return_error("const LASzip* laszip pointer is NULL"); - count = 0; - if (writer) delete writer; - writer = new LASwritePoint(); - if (!writer) return return_error("alloc of LASwritePoint failed"); - if (!writer->setup(laszip->num_items, laszip->items, laszip)) return return_error("setup() of LASwritePoint failed"); - if (stream) delete stream; - if (IS_LITTLE_ENDIAN()) - stream = new ByteStreamOutFileLE(outfile); - else - stream = new ByteStreamOutFileBE(outfile); - if (!stream) return return_error("alloc of ByteStreamOutFile failed"); - if (!writer->init(stream)) return return_error("init() of LASwritePoint failed"); - return true; -} - -bool LASzipper::open(ostream& outstream, const LASzip* laszip) -{ - if (!laszip) return return_error("const LASzip* laszip pointer is NULL"); - count = 0; - if (writer) delete writer; - writer = new LASwritePoint(); - if (!writer) return return_error("alloc of LASwritePoint failed"); - if (!writer->setup(laszip->num_items, laszip->items, laszip)) return return_error("setup() of LASwritePoint failed"); - if (stream) delete stream; - if (IS_LITTLE_ENDIAN()) - stream = new ByteStreamOutOstreamLE(outstream); - else - stream = new ByteStreamOutOstreamBE(outstream); - if (!stream) return return_error("alloc of ByteStreamOutStream failed"); - if (!writer->init(stream)) return return_error("init() of LASwritePoint failed"); - return true; -} - -bool LASzipper::write(const unsigned char * const * point) -{ - count++; - return (writer->write(point) == TRUE); -} - -bool LASzipper::chunk() -{ - if (!writer->chunk()) return return_error("chunk() of LASwritePoint failed"); - return true; -} - -bool LASzipper::close() -{ - BOOL done = TRUE; - if (writer) - { - done = writer->done(); - delete writer; - writer = 0; - } - if (stream) - { - delete stream; - stream = 0; - } - if (!done) return return_error("done() of LASwritePoint failed"); - return true; -} - -const char* LASzipper::get_error() const -{ - return error_string; -} - -bool LASzipper::return_error(const char* error) -{ - char err[256]; - sprintf(err, "%s (LASzip v%d.%dr%d)", error, LASZIP_VERSION_MAJOR, LASZIP_VERSION_MINOR, LASZIP_VERSION_REVISION); - if (error_string) free(error_string); - error_string = LASCopyString(err); - return false; -} - -LASzipper::LASzipper() -{ - error_string = 0; - count = 0; - stream = 0; - writer = 0; -} - -LASzipper::~LASzipper() -{ - if (error_string) free(error_string); - if (writer || stream) close(); -} diff --git a/src/LASzip/mydefs.cpp b/src/LASzip/mydefs.cpp new file mode 100644 index 0000000..0051eca --- /dev/null +++ b/src/LASzip/mydefs.cpp @@ -0,0 +1,46 @@ +/* +=============================================================================== + + FILE: mydefs.cpp + + CONTENTS: + + see corresponding header file + + PROGRAMMERS: + + martin.isenburg@rapidlasso.com - http://rapidlasso.com + + COPYRIGHT: + + (c) 2011-2019, martin isenburg, rapidlasso - fast tools to catch reality + + This is free software; you can redistribute and/or modify it under the + terms of the GNU Lesser General Licence as published by the Free Software + Foundation. See the LICENSE.txt file for more information. + + This software is distributed WITHOUT ANY WARRANTY and without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + CHANGE HISTORY: + + see corresponding header file + +=============================================================================== +*/ +#include "mydefs.hpp" + +#if defined(_MSC_VER) +#include +wchar_t* UTF8toUTF16(const char* utf8) +{ + wchar_t* utf16 = 0; + int len = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, 0, 0); + if (len > 0) + { + utf16 = new wchar_t[len]; + MultiByteToWideChar(CP_UTF8, 0, utf8, -1, utf16, len); + } + return utf16; +} +#endif diff --git a/inst/include/mydefs.hpp b/src/LASzip/mydefs.hpp similarity index 90% rename from inst/include/mydefs.hpp rename to src/LASzip/mydefs.hpp index 240c08c..dfcd004 100644 --- a/inst/include/mydefs.hpp +++ b/src/LASzip/mydefs.hpp @@ -2,11 +2,11 @@ =============================================================================== FILE: mydefs.hpp - + CONTENTS: Basic data type definitions and operations to be robust across platforms. - + PROGRAMMERS: martin.isenburg@rapidlasso.com - http://rapidlasso.com @@ -21,19 +21,15 @@ This software is distributed WITHOUT ANY WARRANTY and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - + CHANGE HISTORY: - + 28 October 2015 -- adding DLL bindings via 'COMPILE_AS_DLL' and 'USE_AS_DLL' 10 January 2011 -- licensing change for LGPL release and libLAS integration 13 July 2005 -- created after returning with many mosquito bites from OBX - + =============================================================================== */ - -#define STRICT_R_HEADERS -#include - #ifndef MYDEFS_HPP #define MYDEFS_HPP @@ -59,10 +55,10 @@ typedef unsigned int U32; typedef unsigned short U16; typedef unsigned char U8; -#if defined(_WIN32) && ! defined (__MINGW32__) // 64 byte integer under Windows +#if defined(_WIN32) && ! defined (__MINGW32__) // 64 byte integer under Windows typedef unsigned __int64 U64; typedef __int64 I64; -#else // 64 byte integer elsewhere ... +#else // 64 byte integer elsewhere ... typedef unsigned long long U64; typedef long long I64; #endif @@ -99,9 +95,9 @@ typedef union I64U32I32F32 { I64 i64; U32 u32[2]; I32 i32[2]; F32 f32[2]; } I64U #define U32_MIN ((U32)0x0) // 0 #define U32_MAX ((U32)0xFFFFFFFF) // 4294967295 #define U32_MAX_MINUS_ONE ((U32)0xFFFFFFFE) // 4294967294 -#if defined(WIN32) // 64 byte unsigned int constant under Windows +#if defined(WIN32) // 64 byte unsigned int constant under Windows #define U32_MAX_PLUS_ONE 0x0000000100000000 // 4294967296 -#else // 64 byte unsigned int constant elsewhere ... +#else // 64 byte unsigned int constant elsewhere ... #define U32_MAX_PLUS_ONE 0x0000000100000000ull // 4294967296 #endif @@ -128,17 +124,17 @@ typedef union I64U32I32F32 { I64 i64; U32 u32[2]; I32 i32[2]; F32 f32[2]; } I64U #define I32_CLAMP(n) (((n) <= I32_MIN) ? I32_MIN : (((n) >= I32_MAX) ? I32_MAX : ((I32)(n)))) #define U32_CLAMP(n) (((n) <= U32_MIN) ? U32_MIN : (((n) >= U32_MAX) ? U32_MAX : ((U32)(n)))) -#define I8_QUANTIZE(n) (((n) >= 0) ? (I8)((n)+0.5f) : (I8)((n)-0.5f)) -#define U8_QUANTIZE(n) (((n) >= 0) ? (U8)((n)+0.5f) : (U8)(0)) +#define I8_QUANTIZE(n) (((n) >= 0) ? (I8)((n)+0.5) : (I8)((n)-0.5)) +#define U8_QUANTIZE(n) (((n) >= 0) ? (U8)((n)+0.5) : (U8)(0)) -#define I16_QUANTIZE(n) (((n) >= 0) ? (I16)((n)+0.5f) : (I16)((n)-0.5f)) -#define U16_QUANTIZE(n) (((n) >= 0) ? (U16)((n)+0.5f) : (U16)(0)) +#define I16_QUANTIZE(n) (((n) >= 0) ? (I16)((n)+0.5) : (I16)((n)-0.5)) +#define U16_QUANTIZE(n) (((n) >= 0) ? (U16)((n)+0.5) : (U16)(0)) -#define I32_QUANTIZE(n) (((n) >= 0) ? (I32)((n)+0.5f) : (I32)((n)-0.5f)) -#define U32_QUANTIZE(n) (((n) >= 0) ? (U32)((n)+0.5f) : (U32)(0)) +#define I32_QUANTIZE(n) (((n) >= 0) ? (I32)((n)+0.5) : (I32)((n)-0.5)) +#define U32_QUANTIZE(n) (((n) >= 0) ? (U32)((n)+0.5) : (U32)(0)) -#define I64_QUANTIZE(n) (((n) >= 0) ? (I64)((n)+0.5f) : (I64)((n)-0.5f)) -#define U64_QUANTIZE(n) (((n) >= 0) ? (U64)((n)+0.5f) : (U64)(0)) +#define I64_QUANTIZE(n) (((n) >= 0) ? (I64)((n)+0.5) : (I64)((n)-0.5)) +#define U64_QUANTIZE(n) (((n) >= 0) ? (U64)((n)+0.5) : (U64)(0)) #define I16_FLOOR(n) ((((I16)(n)) > (n)) ? (((I16)(n))-1) : ((I16)(n))) #define I32_FLOOR(n) ((((I32)(n)) > (n)) ? (((I32)(n))-1) : ((I32)(n))) @@ -250,4 +246,9 @@ inline void ENDIAN_SWAP_64(const U8* from, U8* to) to[7] = from[0]; } +#if defined(_MSC_VER) +#include +wchar_t* UTF8toUTF16(const char* utf8); +#endif + #endif diff --git a/src/Makevars b/src/Makevars index 3c85248..16e459f 100644 --- a/src/Makevars +++ b/src/Makevars @@ -1,4 +1,4 @@ -PKG_CPPFLAGS = -DNDEBUG -DUNORDERED -I. -I../inst/include/ +PKG_CPPFLAGS = -DNDEBUG -DUNORDERED -DHAVE_UNORDERED_MAP -I./ -I./LASlib/ -I./LASzip/ SOURCES = LASlib/lasreader_txt.cpp \ LASlib/fopen_compressed.cpp \ @@ -18,6 +18,8 @@ SOURCES = LASlib/lasreader_txt.cpp \ LASlib/lasutility.cpp \ LASlib/lasreader_dtm.cpp \ LASlib/lasfilter.cpp \ + LASlib/lasignore.cpp \ + LASlib/laskdtree.cpp \ LASlib/laswriter_qfit.cpp \ LASlib/lasreader_qfit.cpp \ LASlib/laswriter.cpp \ @@ -43,10 +45,8 @@ SOURCES = LASlib/lasreader_txt.cpp \ LASzip/lasquadtree.cpp \ LASzip/laswritepoint.cpp \ LASzip/lasreadpoint.cpp \ - LASzip/lasunzipper.cpp \ LASzip/integercompressor.cpp \ LASzip/lasinterval.cpp \ - LASzip/laszipper.cpp \ ./rlasstreamer.cpp \ ./rlasextrabytesattributes.cpp \ ./readLAS.cpp \ diff --git a/src/Makevars.win b/src/Makevars.win index 3c85248..16e459f 100644 --- a/src/Makevars.win +++ b/src/Makevars.win @@ -1,4 +1,4 @@ -PKG_CPPFLAGS = -DNDEBUG -DUNORDERED -I. -I../inst/include/ +PKG_CPPFLAGS = -DNDEBUG -DUNORDERED -DHAVE_UNORDERED_MAP -I./ -I./LASlib/ -I./LASzip/ SOURCES = LASlib/lasreader_txt.cpp \ LASlib/fopen_compressed.cpp \ @@ -18,6 +18,8 @@ SOURCES = LASlib/lasreader_txt.cpp \ LASlib/lasutility.cpp \ LASlib/lasreader_dtm.cpp \ LASlib/lasfilter.cpp \ + LASlib/lasignore.cpp \ + LASlib/laskdtree.cpp \ LASlib/laswriter_qfit.cpp \ LASlib/lasreader_qfit.cpp \ LASlib/laswriter.cpp \ @@ -43,10 +45,8 @@ SOURCES = LASlib/lasreader_txt.cpp \ LASzip/lasquadtree.cpp \ LASzip/laswritepoint.cpp \ LASzip/lasreadpoint.cpp \ - LASzip/lasunzipper.cpp \ LASzip/integercompressor.cpp \ LASzip/lasinterval.cpp \ - LASzip/laszipper.cpp \ ./rlasstreamer.cpp \ ./rlasextrabytesattributes.cpp \ ./readLAS.cpp \ diff --git a/inst/include/rlasextrabytesattributes.h b/src/rlasextrabytesattributes.h similarity index 100% rename from inst/include/rlasextrabytesattributes.h rename to src/rlasextrabytesattributes.h diff --git a/inst/include/rlasstreamer.h b/src/rlasstreamer.h similarity index 100% rename from inst/include/rlasstreamer.h rename to src/rlasstreamer.h From f7bf14cc853d89cca59fd8e13c37bce959fdccff Mon Sep 17 00:00:00 2001 From: Jean-Romain Date: Tue, 2 Mar 2021 14:27:18 -0500 Subject: [PATCH 02/20] off64_t --- src/LASzip/bytestreamin_file.hpp | 536 +++++++++++++++---------------- 1 file changed, 268 insertions(+), 268 deletions(-) diff --git a/src/LASzip/bytestreamin_file.hpp b/src/LASzip/bytestreamin_file.hpp index fffe9b4..e015794 100644 --- a/src/LASzip/bytestreamin_file.hpp +++ b/src/LASzip/bytestreamin_file.hpp @@ -1,268 +1,268 @@ -/* -=============================================================================== - - FILE: bytestreamin_file.hpp - - CONTENTS: - - Class for FILE*-based input streams with endian handling. - - PROGRAMMERS: - - martin.isenburg@rapidlasso.com - http://rapidlasso.com - - COPYRIGHT: - - (c) 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality - - This is free software; you can redistribute and/or modify it under the - terms of the GNU Lesser General Licence as published by the Free Software - Foundation. See the COPYING file for more information. - - This software is distributed WITHOUT ANY WARRANTY and without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - - CHANGE HISTORY: - - 1 October 2011 -- added 64 bit file support in MSVC 6.0 at McCafe at Hbf Linz - 10 January 2011 -- licensing change for LGPL release and liblas integration - 12 December 2010 -- created from ByteStreamOutFile after Howard got pushy (-; - -=============================================================================== -*/ -#ifndef BYTE_STREAM_IN_FILE_H -#define BYTE_STREAM_IN_FILE_H - -#include "bytestreamin.hpp" - -#include - -#if defined(_MSC_VER) && (_MSC_VER < 1300) -extern "C" __int64 _cdecl _ftelli64(FILE*); -extern "C" int _cdecl _fseeki64(FILE*, __int64, int); -#endif - -class ByteStreamInFile : public ByteStreamIn -{ -public: - ByteStreamInFile(FILE* file); -/* read a single byte */ - U32 getByte(); -/* read an array of bytes */ - void getBytes(U8* bytes, const U32 num_bytes); -/* is the stream seekable (e.g. stdin is not) */ - BOOL isSeekable() const; -/* get current position of stream */ - I64 tell() const; -/* seek to this position in the stream */ - BOOL seek(const I64 position); -/* seek to the end of the file */ - BOOL seekEnd(const I64 distance=0); -/* destructor */ - ~ByteStreamInFile(){}; -protected: - FILE* file; -}; - -class ByteStreamInFileLE : public ByteStreamInFile -{ -public: - ByteStreamInFileLE(FILE* file); -/* read 16 bit low-endian field */ - void get16bitsLE(U8* bytes); -/* read 32 bit low-endian field */ - void get32bitsLE(U8* bytes); -/* read 64 bit low-endian field */ - void get64bitsLE(U8* bytes); -/* read 16 bit big-endian field */ - void get16bitsBE(U8* bytes); -/* read 32 bit big-endian field */ - void get32bitsBE(U8* bytes); -/* read 64 bit big-endian field */ - void get64bitsBE(U8* bytes); -private: - U8 swapped[8]; -}; - -class ByteStreamInFileBE : public ByteStreamInFile -{ -public: - ByteStreamInFileBE(FILE* file); -/* read 16 bit low-endian field */ - void get16bitsLE(U8* bytes); -/* read 32 bit low-endian field */ - void get32bitsLE(U8* bytes); -/* read 64 bit low-endian field */ - void get64bitsLE(U8* bytes); -/* read 16 bit big-endian field */ - void get16bitsBE(U8* bytes); -/* read 32 bit big-endian field */ - void get32bitsBE(U8* bytes); -/* read 64 bit big-endian field */ - void get64bitsBE(U8* bytes); -private: - U8 swapped[8]; -}; - -inline ByteStreamInFile::ByteStreamInFile(FILE* file) -{ - this->file = file; -} - -inline U32 ByteStreamInFile::getByte() -{ - int byte = getc(file); - if (byte == EOF) - { - throw EOF; - } - return (U32)byte; -} - -inline void ByteStreamInFile::getBytes(U8* bytes, const U32 num_bytes) -{ - if (fread(bytes, 1, num_bytes, file) != num_bytes) - { - throw EOF; - } -} - -inline BOOL ByteStreamInFile::isSeekable() const -{ - return (file != stdin); -} - -inline I64 ByteStreamInFile::tell() const -{ -#if defined _WIN32 && ! defined (__MINGW32__) - return _ftelli64(file); -#elif defined (__MINGW32__) - return (I64)ftello64(file); -#else - return (I64)ftello(file); -#endif -} - -inline BOOL ByteStreamInFile::seek(const I64 position) -{ - if (tell() != position) - { -#if defined _WIN32 && ! defined (__MINGW32__) - return !(_fseeki64(file, position, SEEK_SET)); -#elif defined (__MINGW32__) - return !(fseeko64(file, (off_t)position, SEEK_SET)); -#else - return !(fseeko(file, (off_t)position, SEEK_SET)); -#endif - } - return TRUE; -} - -inline BOOL ByteStreamInFile::seekEnd(const I64 distance) -{ -#if defined _WIN32 && ! defined (__MINGW32__) - return !(_fseeki64(file, -distance, SEEK_END)); -#elif defined (__MINGW32__) - return !(fseeko64(file, (off_t)-distance, SEEK_END)); -#else - return !(fseeko(file, (off_t)-distance, SEEK_END)); -#endif -} - -inline ByteStreamInFileLE::ByteStreamInFileLE(FILE* file) : ByteStreamInFile(file) -{ -} - -inline void ByteStreamInFileLE::get16bitsLE(U8* bytes) -{ - getBytes(bytes, 2); -} - -inline void ByteStreamInFileLE::get32bitsLE(U8* bytes) -{ - getBytes(bytes, 4); -} - -inline void ByteStreamInFileLE::get64bitsLE(U8* bytes) -{ - getBytes(bytes, 8); -} - -inline void ByteStreamInFileLE::get16bitsBE(U8* bytes) -{ - getBytes(swapped, 2); - bytes[0] = swapped[1]; - bytes[1] = swapped[0]; -} - -inline void ByteStreamInFileLE::get32bitsBE(U8* bytes) -{ - getBytes(swapped, 4); - bytes[0] = swapped[3]; - bytes[1] = swapped[2]; - bytes[2] = swapped[1]; - bytes[3] = swapped[0]; -} - -inline void ByteStreamInFileLE::get64bitsBE(U8* bytes) -{ - getBytes(swapped, 8); - bytes[0] = swapped[7]; - bytes[1] = swapped[6]; - bytes[2] = swapped[5]; - bytes[3] = swapped[4]; - bytes[4] = swapped[3]; - bytes[5] = swapped[2]; - bytes[6] = swapped[1]; - bytes[7] = swapped[0]; -} - -inline ByteStreamInFileBE::ByteStreamInFileBE(FILE* file) : ByteStreamInFile(file) -{ -} - -inline void ByteStreamInFileBE::get16bitsLE(U8* bytes) -{ - getBytes(swapped, 2); - bytes[0] = swapped[1]; - bytes[1] = swapped[0]; -} - -inline void ByteStreamInFileBE::get32bitsLE(U8* bytes) -{ - getBytes(swapped, 4); - bytes[0] = swapped[3]; - bytes[1] = swapped[2]; - bytes[2] = swapped[1]; - bytes[3] = swapped[0]; -} - -inline void ByteStreamInFileBE::get64bitsLE(U8* bytes) -{ - getBytes(swapped, 8); - bytes[0] = swapped[7]; - bytes[1] = swapped[6]; - bytes[2] = swapped[5]; - bytes[3] = swapped[4]; - bytes[4] = swapped[3]; - bytes[5] = swapped[2]; - bytes[6] = swapped[1]; - bytes[7] = swapped[0]; -} - -inline void ByteStreamInFileBE::get16bitsBE(U8* bytes) -{ - getBytes(bytes, 2); -} - -inline void ByteStreamInFileBE::get32bitsBE(U8* bytes) -{ - getBytes(bytes, 4); -} - -inline void ByteStreamInFileBE::get64bitsBE(U8* bytes) -{ - getBytes(bytes, 8); -} - -#endif +/* +=============================================================================== + + FILE: bytestreamin_file.hpp + + CONTENTS: + + Class for FILE*-based input streams with endian handling. + + PROGRAMMERS: + + martin.isenburg@rapidlasso.com - http://rapidlasso.com + + COPYRIGHT: + + (c) 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality + + This is free software; you can redistribute and/or modify it under the + terms of the GNU Lesser General Licence as published by the Free Software + Foundation. See the COPYING file for more information. + + This software is distributed WITHOUT ANY WARRANTY and without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + CHANGE HISTORY: + + 1 October 2011 -- added 64 bit file support in MSVC 6.0 at McCafe at Hbf Linz + 10 January 2011 -- licensing change for LGPL release and liblas integration + 12 December 2010 -- created from ByteStreamOutFile after Howard got pushy (-; + +=============================================================================== +*/ +#ifndef BYTE_STREAM_IN_FILE_H +#define BYTE_STREAM_IN_FILE_H + +#include "bytestreamin.hpp" + +#include + +#if defined(_MSC_VER) && (_MSC_VER < 1300) +extern "C" __int64 _cdecl _ftelli64(FILE*); +extern "C" int _cdecl _fseeki64(FILE*, __int64, int); +#endif + +class ByteStreamInFile : public ByteStreamIn +{ +public: + ByteStreamInFile(FILE* file); +/* read a single byte */ + U32 getByte(); +/* read an array of bytes */ + void getBytes(U8* bytes, const U32 num_bytes); +/* is the stream seekable (e.g. stdin is not) */ + BOOL isSeekable() const; +/* get current position of stream */ + I64 tell() const; +/* seek to this position in the stream */ + BOOL seek(const I64 position); +/* seek to the end of the file */ + BOOL seekEnd(const I64 distance=0); +/* destructor */ + ~ByteStreamInFile(){}; +protected: + FILE* file; +}; + +class ByteStreamInFileLE : public ByteStreamInFile +{ +public: + ByteStreamInFileLE(FILE* file); +/* read 16 bit low-endian field */ + void get16bitsLE(U8* bytes); +/* read 32 bit low-endian field */ + void get32bitsLE(U8* bytes); +/* read 64 bit low-endian field */ + void get64bitsLE(U8* bytes); +/* read 16 bit big-endian field */ + void get16bitsBE(U8* bytes); +/* read 32 bit big-endian field */ + void get32bitsBE(U8* bytes); +/* read 64 bit big-endian field */ + void get64bitsBE(U8* bytes); +private: + U8 swapped[8]; +}; + +class ByteStreamInFileBE : public ByteStreamInFile +{ +public: + ByteStreamInFileBE(FILE* file); +/* read 16 bit low-endian field */ + void get16bitsLE(U8* bytes); +/* read 32 bit low-endian field */ + void get32bitsLE(U8* bytes); +/* read 64 bit low-endian field */ + void get64bitsLE(U8* bytes); +/* read 16 bit big-endian field */ + void get16bitsBE(U8* bytes); +/* read 32 bit big-endian field */ + void get32bitsBE(U8* bytes); +/* read 64 bit big-endian field */ + void get64bitsBE(U8* bytes); +private: + U8 swapped[8]; +}; + +inline ByteStreamInFile::ByteStreamInFile(FILE* file) +{ + this->file = file; +} + +inline U32 ByteStreamInFile::getByte() +{ + int byte = getc(file); + if (byte == EOF) + { + throw EOF; + } + return (U32)byte; +} + +inline void ByteStreamInFile::getBytes(U8* bytes, const U32 num_bytes) +{ + if (fread(bytes, 1, num_bytes, file) != num_bytes) + { + throw EOF; + } +} + +inline BOOL ByteStreamInFile::isSeekable() const +{ + return (file != stdin); +} + +inline I64 ByteStreamInFile::tell() const +{ +#if defined _WIN32 && ! defined (__MINGW32__) + return _ftelli64(file); +#elif defined (__MINGW32__) + return (I64)ftello64(file); +#else + return (I64)ftello(file); +#endif +} + +inline BOOL ByteStreamInFile::seek(const I64 position) +{ + if (tell() != position) + { +#if defined _WIN32 && ! defined (__MINGW32__) + return !(_fseeki64(file, position, SEEK_SET)); +#elif defined (__MINGW32__) + return !(fseeko64(file, (off64_t)position, SEEK_SET)); +#else + return !(fseeko(file, (off_t)position, SEEK_SET)); +#endif + } + return TRUE; +} + +inline BOOL ByteStreamInFile::seekEnd(const I64 distance) +{ +#if defined _WIN32 && ! defined (__MINGW32__) + return !(_fseeki64(file, -distance, SEEK_END)); +#elif defined (__MINGW32__) + return !(fseeko64(file, (off64_t)-distance, SEEK_END)); +#else + return !(fseeko(file, (off_t)-distance, SEEK_END)); +#endif +} + +inline ByteStreamInFileLE::ByteStreamInFileLE(FILE* file) : ByteStreamInFile(file) +{ +} + +inline void ByteStreamInFileLE::get16bitsLE(U8* bytes) +{ + getBytes(bytes, 2); +} + +inline void ByteStreamInFileLE::get32bitsLE(U8* bytes) +{ + getBytes(bytes, 4); +} + +inline void ByteStreamInFileLE::get64bitsLE(U8* bytes) +{ + getBytes(bytes, 8); +} + +inline void ByteStreamInFileLE::get16bitsBE(U8* bytes) +{ + getBytes(swapped, 2); + bytes[0] = swapped[1]; + bytes[1] = swapped[0]; +} + +inline void ByteStreamInFileLE::get32bitsBE(U8* bytes) +{ + getBytes(swapped, 4); + bytes[0] = swapped[3]; + bytes[1] = swapped[2]; + bytes[2] = swapped[1]; + bytes[3] = swapped[0]; +} + +inline void ByteStreamInFileLE::get64bitsBE(U8* bytes) +{ + getBytes(swapped, 8); + bytes[0] = swapped[7]; + bytes[1] = swapped[6]; + bytes[2] = swapped[5]; + bytes[3] = swapped[4]; + bytes[4] = swapped[3]; + bytes[5] = swapped[2]; + bytes[6] = swapped[1]; + bytes[7] = swapped[0]; +} + +inline ByteStreamInFileBE::ByteStreamInFileBE(FILE* file) : ByteStreamInFile(file) +{ +} + +inline void ByteStreamInFileBE::get16bitsLE(U8* bytes) +{ + getBytes(swapped, 2); + bytes[0] = swapped[1]; + bytes[1] = swapped[0]; +} + +inline void ByteStreamInFileBE::get32bitsLE(U8* bytes) +{ + getBytes(swapped, 4); + bytes[0] = swapped[3]; + bytes[1] = swapped[2]; + bytes[2] = swapped[1]; + bytes[3] = swapped[0]; +} + +inline void ByteStreamInFileBE::get64bitsLE(U8* bytes) +{ + getBytes(swapped, 8); + bytes[0] = swapped[7]; + bytes[1] = swapped[6]; + bytes[2] = swapped[5]; + bytes[3] = swapped[4]; + bytes[4] = swapped[3]; + bytes[5] = swapped[2]; + bytes[6] = swapped[1]; + bytes[7] = swapped[0]; +} + +inline void ByteStreamInFileBE::get16bitsBE(U8* bytes) +{ + getBytes(bytes, 2); +} + +inline void ByteStreamInFileBE::get32bitsBE(U8* bytes) +{ + getBytes(bytes, 4); +} + +inline void ByteStreamInFileBE::get64bitsBE(U8* bytes) +{ + getBytes(bytes, 8); +} + +#endif From 9ecb170ecc4a69922c29fe5cc593f853fc48bb03 Mon Sep 17 00:00:00 2001 From: Jean-Romain Date: Tue, 2 Mar 2021 15:05:27 -0500 Subject: [PATCH 03/20] Replace fprintf --- src/LASlib/fopen_compressed.cpp | 52 +- src/LASlib/lasdefinitions.hpp | 16 +- src/LASlib/lasfilter.cpp | 844 ++++++++-------- src/LASlib/lasignore.cpp | 38 +- src/LASlib/laskdtree.cpp | 4 +- src/LASlib/lasreader.cpp | 340 +++---- src/LASlib/lasreader_asc.cpp | 60 +- src/LASlib/lasreader_bil.cpp | 128 +-- src/LASlib/lasreader_bin.cpp | 24 +- src/LASlib/lasreader_dtm.cpp | 106 +- src/LASlib/lasreader_las.cpp | 350 +++---- src/LASlib/lasreader_ply.cpp | 146 +-- src/LASlib/lasreader_qfit.cpp | 28 +- src/LASlib/lasreader_shp.cpp | 40 +- src/LASlib/lasreader_txt.cpp | 288 +++--- src/LASlib/lasreaderbuffered.cpp | 32 +- src/LASlib/lasreadermerged.cpp | 228 ++--- src/LASlib/lasreaderpipeon.cpp | 6 +- src/LASlib/lasreaderstored.cpp | 18 +- src/LASlib/lastransform.cpp | 1130 +++++++++++----------- src/LASlib/lasutility.cpp | 98 +- src/LASlib/lasvlrpayload.hpp | 52 +- src/LASlib/laswaveform13reader.cpp | 40 +- src/LASlib/laswaveform13writer.cpp | 38 +- src/LASlib/laswriter.cpp | 88 +- src/LASlib/laswriter_bin.cpp | 18 +- src/LASlib/laswriter_las.cpp | 306 +++--- src/LASlib/laswriter_qfit.cpp | 28 +- src/LASlib/laswriter_txt.cpp | 90 +- src/LASlib/laswriter_wrl.cpp | 8 +- src/LASlib/laswritercompatible.cpp | 36 +- src/LASzip/demzip_dll.cpp | 28 +- src/LASzip/integercompressor.cpp | 4 +- src/LASzip/lasindex.cpp | 54 +- src/LASzip/lasinterval.cpp | 40 +- src/LASzip/laspoint.hpp | 2 +- src/LASzip/lasquadtree.cpp | 54 +- src/LASzip/lasreaditemcompressed_v3.cpp | 2 +- src/LASzip/lasreaditemcompressed_v4.cpp | 2 +- src/LASzip/lasreadpoint.cpp | 2 +- src/LASzip/laswriteitemcompressed_v3.cpp | 2 +- src/LASzip/laszip.cpp | 2 +- 42 files changed, 2436 insertions(+), 2436 deletions(-) diff --git a/src/LASlib/fopen_compressed.cpp b/src/LASlib/fopen_compressed.cpp index b1941fd..43c0323 100644 --- a/src/LASlib/fopen_compressed.cpp +++ b/src/LASlib/fopen_compressed.cpp @@ -53,7 +53,7 @@ static FILE* fopen7zipped(const char* filename, const char* mode) int hPipe[2]; if (_pipe(hPipe, 2048, ((mode[1] =='b') ? _O_BINARY : _O_TEXT) | _O_NOINHERIT) == -1) { - fprintf(stderr, "could not create pipe\n"); + REprintf( "could not create pipe\n"); return NULL; } @@ -63,14 +63,14 @@ static FILE* fopen7zipped(const char* filename, const char* mode) // make the write end of pipe go to stdout if (_dup2(hPipe[WRITE_HANDLE], _fileno(stdout)) != 0) { - fprintf(stderr, "could not set pipe output\n"); + REprintf( "could not set pipe output\n"); return NULL; } // redirect read end of pipe to input file if (_dup2(hPipe[READ_HANDLE], _fileno(stdin)) != 0) { - fprintf(stderr, "could not redirect input file\n"); + REprintf( "could not redirect input file\n"); return NULL; } @@ -83,7 +83,7 @@ static FILE* fopen7zipped(const char* filename, const char* mode) // redirect stdout back into stdout if (_dup2(hStdOut, _fileno(stdout)) != 0) { - fprintf(stderr, "could not reconstruct stdout\n"); + REprintf( "could not reconstruct stdout\n"); return NULL; } @@ -105,7 +105,7 @@ static FILE* fopenZIPped(const char* filename, const char* mode) int hPipe[2]; if (_pipe(hPipe, 2048, ((mode[1] =='b') ? _O_BINARY : _O_TEXT) | _O_NOINHERIT) == -1) { - fprintf(stderr, "could not create pipe\n"); + REprintf( "could not create pipe\n"); return NULL; } @@ -115,14 +115,14 @@ static FILE* fopenZIPped(const char* filename, const char* mode) // make the write end of pipe go to stdout if (_dup2(hPipe[WRITE_HANDLE], _fileno(stdout)) != 0) { - fprintf(stderr, "could not set pipe output\n"); + REprintf( "could not set pipe output\n"); return NULL; } // redirect read end of pipe to input file if (_dup2(hPipe[READ_HANDLE], _fileno(stdin)) != 0) { - fprintf(stderr, "could not redirect input file\n"); + REprintf( "could not redirect input file\n"); return NULL; } @@ -135,7 +135,7 @@ static FILE* fopenZIPped(const char* filename, const char* mode) // redirect stdout back into stdout if (_dup2(hStdOut, _fileno(stdout)) != 0) { - fprintf(stderr, "could not reconstruct stdout\n"); + REprintf( "could not reconstruct stdout\n"); return NULL; } @@ -161,7 +161,7 @@ static FILE* fopenGzipped(const char* filename, const char* mode) int hPipe[2]; if (_pipe(hPipe, 2048, ((mode[1] =='b') ? _O_BINARY : _O_TEXT) | _O_NOINHERIT) == -1) { - fprintf(stderr, "could not create pipe\n"); + REprintf( "could not create pipe\n"); return NULL; } @@ -170,7 +170,7 @@ static FILE* fopenGzipped(const char* filename, const char* mode) // redirect stdin to input file if (_dup2(_fileno(gzipInput), _fileno(stdin)) != 0) { - fprintf(stderr, "could not redirect stdin\n"); + REprintf( "could not redirect stdin\n"); return NULL; } @@ -179,7 +179,7 @@ static FILE* fopenGzipped(const char* filename, const char* mode) // redirect stdout to write end of pipe if (_dup2(hPipe[WRITE_HANDLE], _fileno(stdout)) != 0) { - fprintf(stderr, "could not set pipe output\n"); + REprintf( "could not set pipe output\n"); return NULL; } @@ -189,7 +189,7 @@ static FILE* fopenGzipped(const char* filename, const char* mode) // redirect read end of pipe to input file if (_dup2(hPipe[READ_HANDLE], _fileno(gzipInput)) != 0) { - fprintf(stderr, "could not redirect input file\n"); + REprintf( "could not redirect input file\n"); return NULL; } @@ -202,14 +202,14 @@ static FILE* fopenGzipped(const char* filename, const char* mode) // redirect stdin back into stdin if (_dup2(hStdIn, _fileno(stdin)) != 0) { - fprintf(stderr, "could not reconstruct stdin\n"); + REprintf( "could not reconstruct stdin\n"); return NULL; } // redirect stdout back into stdout if (_dup2(hStdOut, _fileno(stdout)) != 0) { - fprintf(stderr, "could not reconstruct stdout\n"); + REprintf( "could not reconstruct stdout\n"); return NULL; } @@ -231,7 +231,7 @@ static FILE* fopenGzippedNew(const char* filename, const char* mode) int hPipe[2]; if (_pipe(hPipe, 2048, ((mode[1] =='b') ? _O_BINARY : _O_TEXT) | _O_NOINHERIT) == -1) { - fprintf(stderr, "could not create pipe\n"); + REprintf( "could not create pipe\n"); return NULL; } @@ -241,14 +241,14 @@ static FILE* fopenGzippedNew(const char* filename, const char* mode) // make the write end of pipe go to stdout if (_dup2(hPipe[WRITE_HANDLE], _fileno(stdout)) != 0) { - fprintf(stderr, "could not set pipe output\n"); + REprintf( "could not set pipe output\n"); return NULL; } // redirect read end of pipe to input file if (_dup2(hPipe[READ_HANDLE], _fileno(stdin)) != 0) { - fprintf(stderr, "could not redirect input file\n"); + REprintf( "could not redirect input file\n"); return NULL; } @@ -261,7 +261,7 @@ static FILE* fopenGzippedNew(const char* filename, const char* mode) // redirect stdout back into stdout if (_dup2(hStdOut, _fileno(stdout)) != 0) { - fprintf(stderr, "could not reconstruct stdout\n"); + REprintf( "could not reconstruct stdout\n"); return NULL; } @@ -283,7 +283,7 @@ static FILE* fopenRARed(const char* filename, const char* mode) int hPipe[2]; if (_pipe(hPipe, 2048, ((mode[1] =='b') ? _O_BINARY : _O_TEXT) | _O_NOINHERIT) == -1) { - fprintf(stderr, "could not create pipe\n"); + REprintf( "could not create pipe\n"); return NULL; } @@ -293,14 +293,14 @@ static FILE* fopenRARed(const char* filename, const char* mode) // make the write end of pipe go to stdout if (_dup2(hPipe[WRITE_HANDLE], _fileno(stdout)) != 0) { - fprintf(stderr, "could not set pipe output\n"); + REprintf( "could not set pipe output\n"); return NULL; } // redirect read end of pipe to input file if (_dup2(hPipe[READ_HANDLE], _fileno(stdin)) != 0) { - fprintf(stderr, "could not redirect input file\n"); + REprintf( "could not redirect input file\n"); return NULL; } @@ -313,7 +313,7 @@ static FILE* fopenRARed(const char* filename, const char* mode) // redirect stdout back into stdout if (_dup2(hStdOut, _fileno(stdout)) != 0) { - fprintf(stderr, "could not reconstruct stdout\n"); + REprintf( "could not reconstruct stdout\n"); return NULL; } @@ -341,7 +341,7 @@ FILE* fopen_compressed(const char* filename, const char* mode, bool* piped) file = fopenGzipped(filename, mode); if (piped) *piped = true; #else - fprintf(stderr, "ERROR: no support for gzipped input\n"); + REprintf( "ERROR: no support for gzipped input\n"); return 0; #endif } @@ -351,7 +351,7 @@ FILE* fopen_compressed(const char* filename, const char* mode, bool* piped) file = fopenZIPped(filename, mode); if (piped) *piped = true; #else - fprintf(stderr, "ERROR: no support for ZIPped input\n"); + REprintf( "ERROR: no support for ZIPped input\n"); return 0; #endif } @@ -361,7 +361,7 @@ FILE* fopen_compressed(const char* filename, const char* mode, bool* piped) file = fopen7zipped(filename, mode); if (piped) *piped = true; #else - fprintf(stderr, "ERROR: no support for 7zipped input\n"); + REprintf( "ERROR: no support for 7zipped input\n"); return 0; #endif } @@ -371,7 +371,7 @@ FILE* fopen_compressed(const char* filename, const char* mode, bool* piped) file = fopenRARed(filename, mode); if (piped) *piped = true; #else - fprintf(stderr, "ERROR: no support for RARed input\n"); + REprintf( "ERROR: no support for RARed input\n"); return 0; #endif } diff --git a/src/LASlib/lasdefinitions.hpp b/src/LASlib/lasdefinitions.hpp index d188e19..71080dc 100644 --- a/src/LASlib/lasdefinitions.hpp +++ b/src/LASlib/lasdefinitions.hpp @@ -434,40 +434,40 @@ class LASheader : public LASquantizer, public LASattributer { if (strncmp(file_signature, "LASF", 4) != 0) { - fprintf(stderr,"ERROR: wrong file signature '%4s'\n", file_signature); + REprintf("ERROR: wrong file signature '%4s'\n", file_signature); return FALSE; } if ((version_major != 1) || (version_minor > 4)) { - fprintf(stderr,"WARNING: unknown version %d.%d (should be 1.0 or 1.1 or 1.2 or 1.3 or 1.4)\n", version_major, version_minor); + REprintf("WARNING: unknown version %d.%d (should be 1.0 or 1.1 or 1.2 or 1.3 or 1.4)\n", version_major, version_minor); } if (header_size < 227) { - fprintf(stderr,"ERROR: header size is %d but should be at least 227\n", header_size); + REprintf("ERROR: header size is %d but should be at least 227\n", header_size); return FALSE; } if (offset_to_point_data < header_size) { - fprintf(stderr,"ERROR: offset to point data %d is smaller than header size %d\n", offset_to_point_data, header_size); + REprintf("ERROR: offset to point data %d is smaller than header size %d\n", offset_to_point_data, header_size); return FALSE; } if (x_scale_factor == 0) { - fprintf(stderr,"WARNING: x scale factor is zero.\n"); + REprintf("WARNING: x scale factor is zero.\n"); } if (y_scale_factor == 0) { - fprintf(stderr,"WARNING: y scale factor is zero.\n"); + REprintf("WARNING: y scale factor is zero.\n"); } if (z_scale_factor == 0) { - fprintf(stderr,"WARNING: z scale factor is zero.\n"); + REprintf("WARNING: z scale factor is zero.\n"); } if (max_x < min_x || max_y < min_y || max_z < min_z) { if (number_of_point_records || extended_number_of_point_records) { - fprintf(stderr,"WARNING: invalid bounding box [ %g %g %g / %g %g %g ]\n", min_x, min_y, min_z, max_x, max_y, max_z); + REprintf("WARNING: invalid bounding box [ %g %g %g / %g %g %g ]\n", min_x, min_y, min_z, max_x, max_y, max_z); } } return TRUE; diff --git a/src/LASlib/lasfilter.cpp b/src/LASlib/lasfilter.cpp index 4e9dddb..08797bc 100644 --- a/src/LASlib/lasfilter.cpp +++ b/src/LASlib/lasfilter.cpp @@ -1620,111 +1620,111 @@ void LASfilter::clean() void LASfilter::usage() const { - fprintf(stderr,"Filter points based on their coordinates.\n"); - fprintf(stderr," -keep_tile 631000 4834000 1000 (ll_x ll_y size)\n"); - fprintf(stderr," -keep_circle 630250.00 4834750.00 100 (x y radius)\n"); - fprintf(stderr," -keep_xy 630000 4834000 631000 4836000 (min_x min_y max_x max_y)\n"); - fprintf(stderr," -drop_xy 630000 4834000 631000 4836000 (min_x min_y max_x max_y)\n"); - fprintf(stderr," -keep_x 631500.50 631501.00 (min_x max_x)\n"); - fprintf(stderr," -drop_x 631500.50 631501.00 (min_x max_x)\n"); - fprintf(stderr," -drop_x_below 630000.50 (min_x)\n"); - fprintf(stderr," -drop_x_above 630500.50 (max_x)\n"); - fprintf(stderr," -keep_y 4834500.25 4834550.25 (min_y max_y)\n"); - fprintf(stderr," -drop_y 4834500.25 4834550.25 (min_y max_y)\n"); - fprintf(stderr," -drop_y_below 4834500.25 (min_y)\n"); - fprintf(stderr," -drop_y_above 4836000.75 (max_y)\n"); - fprintf(stderr," -keep_z 11.125 130.725 (min_z max_z)\n"); - fprintf(stderr," -drop_z 11.125 130.725 (min_z max_z)\n"); - fprintf(stderr," -drop_z_below 11.125 (min_z)\n"); - fprintf(stderr," -drop_z_above 130.725 (max_z)\n"); - fprintf(stderr," -keep_xyz 620000 4830000 100 621000 4831000 200 (min_x min_y min_z max_x max_y max_z)\n"); - fprintf(stderr," -drop_xyz 620000 4830000 100 621000 4831000 200 (min_x min_y min_z max_x max_y max_z)\n"); - fprintf(stderr,"Filter points based on their return numbering.\n"); - fprintf(stderr," -keep_first -first_only -drop_first\n"); - fprintf(stderr," -keep_last -last_only -drop_last\n"); - fprintf(stderr," -keep_second_last -drop_second_last\n"); - fprintf(stderr," -keep_first_of_many -keep_last_of_many\n"); - fprintf(stderr," -drop_first_of_many -drop_last_of_many\n"); - fprintf(stderr," -keep_middle -drop_middle\n"); - fprintf(stderr," -keep_return 1 2 3\n"); - fprintf(stderr," -drop_return 3 4\n"); - fprintf(stderr," -keep_single -drop_single\n"); - fprintf(stderr," -keep_double -drop_double\n"); - fprintf(stderr," -keep_triple -drop_triple\n"); - fprintf(stderr," -keep_quadruple -drop_quadruple\n"); - fprintf(stderr," -keep_number_of_returns 5\n"); - fprintf(stderr," -drop_number_of_returns 0\n"); - fprintf(stderr,"Filter points based on the scanline flags.\n"); - fprintf(stderr," -drop_scan_direction 0\n"); - fprintf(stderr," -keep_scan_direction_change\n"); - fprintf(stderr," -keep_edge_of_flight_line\n"); - fprintf(stderr,"Filter points based on their intensity.\n"); - fprintf(stderr," -keep_intensity 20 380\n"); - fprintf(stderr," -drop_intensity_below 20\n"); - fprintf(stderr," -drop_intensity_above 380\n"); - fprintf(stderr," -drop_intensity_between 4000 5000\n"); - fprintf(stderr,"Filter points based on classifications or flags.\n"); - fprintf(stderr," -keep_class 1 3 7\n"); - fprintf(stderr," -drop_class 4 2\n"); - fprintf(stderr," -keep_extended_class 43\n"); - fprintf(stderr," -drop_extended_class 129 135\n"); - fprintf(stderr," -drop_synthetic -keep_synthetic\n"); - fprintf(stderr," -drop_keypoint -keep_keypoint\n"); - fprintf(stderr," -drop_withheld -keep_withheld\n"); - fprintf(stderr," -drop_overlap -keep_overlap\n"); - fprintf(stderr,"Filter points based on their user data.\n"); - fprintf(stderr," -keep_user_data 1\n"); - fprintf(stderr," -drop_user_data 255\n"); - fprintf(stderr," -keep_user_data_below 50\n"); - fprintf(stderr," -keep_user_data_above 150\n"); - fprintf(stderr," -keep_user_data_between 10 20\n"); - fprintf(stderr," -drop_user_data_below 1\n"); - fprintf(stderr," -drop_user_data_above 100\n"); - fprintf(stderr," -drop_user_data_between 10 40\n"); - fprintf(stderr,"Filter points based on their point source ID.\n"); - fprintf(stderr," -keep_point_source 3\n"); - fprintf(stderr," -keep_point_source_between 2 6\n"); - fprintf(stderr," -drop_point_source 27\n"); - fprintf(stderr," -drop_point_source_below 6\n"); - fprintf(stderr," -drop_point_source_above 15\n"); - fprintf(stderr," -drop_point_source_between 17 21\n"); - fprintf(stderr,"Filter points based on their scan angle.\n"); - fprintf(stderr," -keep_scan_angle -15 15\n"); - fprintf(stderr," -drop_abs_scan_angle_above 15\n"); - fprintf(stderr," -drop_abs_scan_angle_below 1\n"); - fprintf(stderr," -drop_scan_angle_below -15\n"); - fprintf(stderr," -drop_scan_angle_above 15\n"); - fprintf(stderr," -drop_scan_angle_between -25 -23\n"); - fprintf(stderr,"Filter points based on their gps time.\n"); - fprintf(stderr," -keep_gps_time 11.125 130.725\n"); - fprintf(stderr," -drop_gps_time_below 11.125\n"); - fprintf(stderr," -drop_gps_time_above 130.725\n"); - fprintf(stderr," -drop_gps_time_between 22.0 48.0\n"); - fprintf(stderr,"Filter points based on their RGB/CIR/NIR channels.\n"); - fprintf(stderr," -keep_RGB_red 1 1\n"); - fprintf(stderr," -drop_RGB_red 5000 20000\n"); - fprintf(stderr," -keep_RGB_green 30 100\n"); - fprintf(stderr," -drop_RGB_green 2000 10000\n"); - fprintf(stderr," -keep_RGB_blue 0 0\n"); - fprintf(stderr," -keep_RGB_nir 64 127\n"); - fprintf(stderr," -keep_RGB_greenness 200 65535\n"); - fprintf(stderr," -keep_NDVI 0.2 0.7 -keep_NDVI_from_CIR -0.1 0.5\n"); - fprintf(stderr," -keep_NDVI_intensity_is_NIR 0.4 0.8 -keep_NDVI_green_is_NIR -0.2 0.2\n"); - fprintf(stderr,"Filter points based on their wavepacket.\n"); - fprintf(stderr," -keep_wavepacket 0\n"); - fprintf(stderr," -drop_wavepacket 3\n"); - fprintf(stderr,"Filter points based on extra attributes.\n"); - fprintf(stderr," -keep_attribute_above 0 5.0\n"); - fprintf(stderr," -drop_attribute_below 1 1.5\n"); - fprintf(stderr,"Filter points with simple thinning.\n"); - fprintf(stderr," -keep_every_nth 2 -drop_every_nth 3\n"); - fprintf(stderr," -keep_random_fraction 0.1\n"); - fprintf(stderr," -keep_random_fraction 0.1 4711\n"); - fprintf(stderr," -thin_with_grid 1.0\n"); - fprintf(stderr," -thin_pulses_with_time 0.0001\n"); - fprintf(stderr," -thin_points_with_time 0.000001\n"); - fprintf(stderr,"Boolean combination of filters.\n"); - fprintf(stderr," -filter_and\n"); + REprintf("Filter points based on their coordinates.\n"); + REprintf(" -keep_tile 631000 4834000 1000 (ll_x ll_y size)\n"); + REprintf(" -keep_circle 630250.00 4834750.00 100 (x y radius)\n"); + REprintf(" -keep_xy 630000 4834000 631000 4836000 (min_x min_y max_x max_y)\n"); + REprintf(" -drop_xy 630000 4834000 631000 4836000 (min_x min_y max_x max_y)\n"); + REprintf(" -keep_x 631500.50 631501.00 (min_x max_x)\n"); + REprintf(" -drop_x 631500.50 631501.00 (min_x max_x)\n"); + REprintf(" -drop_x_below 630000.50 (min_x)\n"); + REprintf(" -drop_x_above 630500.50 (max_x)\n"); + REprintf(" -keep_y 4834500.25 4834550.25 (min_y max_y)\n"); + REprintf(" -drop_y 4834500.25 4834550.25 (min_y max_y)\n"); + REprintf(" -drop_y_below 4834500.25 (min_y)\n"); + REprintf(" -drop_y_above 4836000.75 (max_y)\n"); + REprintf(" -keep_z 11.125 130.725 (min_z max_z)\n"); + REprintf(" -drop_z 11.125 130.725 (min_z max_z)\n"); + REprintf(" -drop_z_below 11.125 (min_z)\n"); + REprintf(" -drop_z_above 130.725 (max_z)\n"); + REprintf(" -keep_xyz 620000 4830000 100 621000 4831000 200 (min_x min_y min_z max_x max_y max_z)\n"); + REprintf(" -drop_xyz 620000 4830000 100 621000 4831000 200 (min_x min_y min_z max_x max_y max_z)\n"); + REprintf("Filter points based on their return numbering.\n"); + REprintf(" -keep_first -first_only -drop_first\n"); + REprintf(" -keep_last -last_only -drop_last\n"); + REprintf(" -keep_second_last -drop_second_last\n"); + REprintf(" -keep_first_of_many -keep_last_of_many\n"); + REprintf(" -drop_first_of_many -drop_last_of_many\n"); + REprintf(" -keep_middle -drop_middle\n"); + REprintf(" -keep_return 1 2 3\n"); + REprintf(" -drop_return 3 4\n"); + REprintf(" -keep_single -drop_single\n"); + REprintf(" -keep_double -drop_double\n"); + REprintf(" -keep_triple -drop_triple\n"); + REprintf(" -keep_quadruple -drop_quadruple\n"); + REprintf(" -keep_number_of_returns 5\n"); + REprintf(" -drop_number_of_returns 0\n"); + REprintf("Filter points based on the scanline flags.\n"); + REprintf(" -drop_scan_direction 0\n"); + REprintf(" -keep_scan_direction_change\n"); + REprintf(" -keep_edge_of_flight_line\n"); + REprintf("Filter points based on their intensity.\n"); + REprintf(" -keep_intensity 20 380\n"); + REprintf(" -drop_intensity_below 20\n"); + REprintf(" -drop_intensity_above 380\n"); + REprintf(" -drop_intensity_between 4000 5000\n"); + REprintf("Filter points based on classifications or flags.\n"); + REprintf(" -keep_class 1 3 7\n"); + REprintf(" -drop_class 4 2\n"); + REprintf(" -keep_extended_class 43\n"); + REprintf(" -drop_extended_class 129 135\n"); + REprintf(" -drop_synthetic -keep_synthetic\n"); + REprintf(" -drop_keypoint -keep_keypoint\n"); + REprintf(" -drop_withheld -keep_withheld\n"); + REprintf(" -drop_overlap -keep_overlap\n"); + REprintf("Filter points based on their user data.\n"); + REprintf(" -keep_user_data 1\n"); + REprintf(" -drop_user_data 255\n"); + REprintf(" -keep_user_data_below 50\n"); + REprintf(" -keep_user_data_above 150\n"); + REprintf(" -keep_user_data_between 10 20\n"); + REprintf(" -drop_user_data_below 1\n"); + REprintf(" -drop_user_data_above 100\n"); + REprintf(" -drop_user_data_between 10 40\n"); + REprintf("Filter points based on their point source ID.\n"); + REprintf(" -keep_point_source 3\n"); + REprintf(" -keep_point_source_between 2 6\n"); + REprintf(" -drop_point_source 27\n"); + REprintf(" -drop_point_source_below 6\n"); + REprintf(" -drop_point_source_above 15\n"); + REprintf(" -drop_point_source_between 17 21\n"); + REprintf("Filter points based on their scan angle.\n"); + REprintf(" -keep_scan_angle -15 15\n"); + REprintf(" -drop_abs_scan_angle_above 15\n"); + REprintf(" -drop_abs_scan_angle_below 1\n"); + REprintf(" -drop_scan_angle_below -15\n"); + REprintf(" -drop_scan_angle_above 15\n"); + REprintf(" -drop_scan_angle_between -25 -23\n"); + REprintf("Filter points based on their gps time.\n"); + REprintf(" -keep_gps_time 11.125 130.725\n"); + REprintf(" -drop_gps_time_below 11.125\n"); + REprintf(" -drop_gps_time_above 130.725\n"); + REprintf(" -drop_gps_time_between 22.0 48.0\n"); + REprintf("Filter points based on their RGB/CIR/NIR channels.\n"); + REprintf(" -keep_RGB_red 1 1\n"); + REprintf(" -drop_RGB_red 5000 20000\n"); + REprintf(" -keep_RGB_green 30 100\n"); + REprintf(" -drop_RGB_green 2000 10000\n"); + REprintf(" -keep_RGB_blue 0 0\n"); + REprintf(" -keep_RGB_nir 64 127\n"); + REprintf(" -keep_RGB_greenness 200 65535\n"); + REprintf(" -keep_NDVI 0.2 0.7 -keep_NDVI_from_CIR -0.1 0.5\n"); + REprintf(" -keep_NDVI_intensity_is_NIR 0.4 0.8 -keep_NDVI_green_is_NIR -0.2 0.2\n"); + REprintf("Filter points based on their wavepacket.\n"); + REprintf(" -keep_wavepacket 0\n"); + REprintf(" -drop_wavepacket 3\n"); + REprintf("Filter points based on extra attributes.\n"); + REprintf(" -keep_attribute_above 0 5.0\n"); + REprintf(" -drop_attribute_below 1 1.5\n"); + REprintf("Filter points with simple thinning.\n"); + REprintf(" -keep_every_nth 2 -drop_every_nth 3\n"); + REprintf(" -keep_random_fraction 0.1\n"); + REprintf(" -keep_random_fraction 0.1 4711\n"); + REprintf(" -thin_with_grid 1.0\n"); + REprintf(" -thin_pulses_with_time 0.0001\n"); + REprintf(" -thin_points_with_time 0.000001\n"); + REprintf("Boolean combination of filters.\n"); + REprintf(" -filter_and\n"); } BOOL LASfilter::parse(int argc, char* argv[]) @@ -1789,7 +1789,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs at least 1 argument: classification\n", argv[i]); + REprintf("ERROR: '%s' needs at least 1 argument: classification\n", argv[i]); return FALSE; } int i_in = i; @@ -1801,12 +1801,12 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if (sscanf(argv[i], "%u", &classification) != 1) { - fprintf(stderr,"ERROR: '%s' needs at least 1 argument: classification but '%s' is no valid classification\n", argv[i_in], argv[i]); + REprintf("ERROR: '%s' needs at least 1 argument: classification but '%s' is no valid classification\n", argv[i_in], argv[i]); return FALSE; } if (classification > 31) { - fprintf(stderr,"ERROR: '%s' needs arguments between 0 and 31 but '%u' is out of range\n", argv[i_in], classification); + REprintf("ERROR: '%s' needs arguments between 0 and 31 but '%u' is out of range\n", argv[i_in], classification); return FALSE; } keep_classification_mask |= (1u << classification); @@ -1828,13 +1828,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: mask\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: mask\n", argv[i]); return FALSE; } U32 keep_classification_mask; if (sscanf(argv[i+1], "%u", &keep_classification_mask) != 1) { - fprintf(stderr,"ERROR: '%s' needs at least 1 argument: mask but '%s' is no valid mask\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs at least 1 argument: mask but '%s' is no valid mask\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionKeepClassifications(keep_classification_mask)); @@ -1847,7 +1847,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs at least a argument: classification\n", argv[i]); + REprintf("ERROR: '%s' needs at least a argument: classification\n", argv[i]); return FALSE; } *argv[i]='\0'; @@ -1857,12 +1857,12 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if (sscanf(argv[i], "%u", &extended_classification) != 1) { - fprintf(stderr,"ERROR: '-keep_extended_classification' needs at least 1 argument: classification but '%s' is no valid classification\n", argv[i]); + REprintf("ERROR: '-keep_extended_classification' needs at least 1 argument: classification but '%s' is no valid classification\n", argv[i]); return FALSE; } if (extended_classification > 255) { - fprintf(stderr,"ERROR: cannot keep extended classification %u because it is larger than 255\n", extended_classification); + REprintf("ERROR: cannot keep extended classification %u because it is larger than 255\n", extended_classification); return FALSE; } keep_extended_classification_mask[extended_classification/32] |= (1u << (extended_classification%32)); @@ -1878,31 +1878,31 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+4) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y\n", argv[i]); + REprintf("ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y\n", argv[i]); return FALSE; } F64 min_x; if (sscanf(argv[i+1], "%lf", &min_x) != 1) { - fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid min_x\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid min_x\n", argv[i], argv[i+1]); return FALSE; } F64 min_y; if (sscanf(argv[i+2], "%lf", &min_y) != 1) { - fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid min_y\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid min_y\n", argv[i], argv[i+2]); return FALSE; } F64 max_x; if (sscanf(argv[i+3], "%lf", &max_x) != 1) { - fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid max_x\n", argv[i], argv[i+3]); + REprintf("ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid max_x\n", argv[i], argv[i+3]); return FALSE; } F64 max_y; if (sscanf(argv[i+4], "%lf", &max_y) != 1) { - fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid max_y\n", argv[i], argv[i+4]); + REprintf("ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid max_y\n", argv[i], argv[i+4]); return FALSE; } add_criterion(new LAScriterionKeepxy(min_x, min_y, max_x, max_y)); @@ -1912,43 +1912,43 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+6) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z\n", argv[i]); + REprintf("ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z\n", argv[i]); return FALSE; } F64 min_x; if (sscanf(argv[i+1], "%lf", &min_x) != 1) { - fprintf(stderr,"ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid min_x\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid min_x\n", argv[i], argv[i+1]); return FALSE; } F64 min_y; if (sscanf(argv[i+2], "%lf", &min_y) != 1) { - fprintf(stderr,"ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid min_y\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid min_y\n", argv[i], argv[i+2]); return FALSE; } F64 min_z; if (sscanf(argv[i+3], "%lf", &min_z) != 1) { - fprintf(stderr,"ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid min_z\n", argv[i], argv[i+3]); + REprintf("ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid min_z\n", argv[i], argv[i+3]); return FALSE; } F64 max_x; if (sscanf(argv[i+4], "%lf", &max_x) != 1) { - fprintf(stderr,"ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid max_x\n", argv[i], argv[i+4]); + REprintf("ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid max_x\n", argv[i], argv[i+4]); return FALSE; } F64 max_y; if (sscanf(argv[i+5], "%lf", &max_y) != 1) { - fprintf(stderr,"ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid max_y\n", argv[i], argv[i+5]); + REprintf("ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid max_y\n", argv[i], argv[i+5]); return FALSE; } F64 max_z; if (sscanf(argv[i+6], "%lf", &max_z) != 1) { - fprintf(stderr,"ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid max_z\n", argv[i], argv[i+6]); + REprintf("ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid max_z\n", argv[i], argv[i+6]); return FALSE; } add_criterion(new LAScriterionKeepxyz(min_x, min_y, min_z, max_x, max_y, max_z)); @@ -1958,19 +1958,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_x max_x\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: min_x max_x\n", argv[i]); return FALSE; } F64 min_x; if (sscanf(argv[i+1], "%lf", &min_x) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_x max_x but '%s' is no valid min_x\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: min_x max_x but '%s' is no valid min_x\n", argv[i], argv[i+1]); return FALSE; } F64 max_x; if (sscanf(argv[i+2], "%lf", &max_x) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_x max_x but '%s' is no valid max_x\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: min_x max_x but '%s' is no valid max_x\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionKeepx(min_x, max_x)); @@ -1981,19 +1981,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_y max_y\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: min_y max_y\n", argv[i]); return FALSE; } F64 min_y; if (sscanf(argv[i+1], "%lf", &min_y) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_y max_y but '%s' is no valid min_y\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: min_y max_y but '%s' is no valid min_y\n", argv[i], argv[i+1]); return FALSE; } F64 max_y; if (sscanf(argv[i+2], "%lf", &max_y) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_y max_y but '%s' is no valid max_y\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: min_y max_y but '%s' is no valid max_y\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionKeepy(min_y, max_y)); @@ -2005,19 +2005,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_z max_z\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: min_z max_z\n", argv[i]); return FALSE; } F64 min_z; if (sscanf(argv[i+1], "%lf", &min_z) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_z max_z but '%s' is no valid min_z\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: min_z max_z but '%s' is no valid min_z\n", argv[i], argv[i+1]); return FALSE; } F64 max_z; if (sscanf(argv[i+2], "%lf", &max_z) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_z max_z but '%s' is no valid max_z\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: min_z max_z but '%s' is no valid max_z\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionKeepz(min_z, max_z)); @@ -2027,13 +2027,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: min_z\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: min_z\n", argv[i]); return FALSE; } F64 min_z; if (sscanf(argv[i+1], "%lf", &min_z) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: min_z but '%s' is no valid min_z\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: min_z but '%s' is no valid min_z\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropzBelow(min_z)); @@ -2043,13 +2043,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: max_z\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: max_z\n", argv[i]); return FALSE; } F64 max_z; if (sscanf(argv[i+1], "%lf", &max_z) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: max_z but '%s' is no valid max_z\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: max_z but '%s' is no valid max_z\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropzAbove(max_z)); @@ -2062,31 +2062,31 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+4) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_X min_Y max_X max_Y\n", argv[i]); + REprintf("ERROR: '%s' needs 4 arguments: min_X min_Y max_X max_Y\n", argv[i]); return FALSE; } I32 min_X; if (sscanf(argv[i+1], "%d", &min_X) != 1) { - fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_X min_Y max_X max_Y but '%s' is no valid min_X\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 4 arguments: min_X min_Y max_X max_Y but '%s' is no valid min_X\n", argv[i], argv[i+1]); return FALSE; } I32 min_Y; if (sscanf(argv[i+2], "%d", &min_Y) != 1) { - fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_X min_Y max_X max_Y but '%s' is no valid min_Y\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 4 arguments: min_X min_Y max_X max_Y but '%s' is no valid min_Y\n", argv[i], argv[i+2]); return FALSE; } I32 max_X; if (sscanf(argv[i+3], "%d", &max_X) != 1) { - fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_X min_Y max_X max_Y but '%s' is no valid max_X\n", argv[i], argv[i+3]); + REprintf("ERROR: '%s' needs 4 arguments: min_X min_Y max_X max_Y but '%s' is no valid max_X\n", argv[i], argv[i+3]); return FALSE; } I32 max_Y; if (sscanf(argv[i+4], "%d", &max_Y) != 1) { - fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_X min_Y max_X max_Y but '%s' is no valid max_Y\n", argv[i], argv[i+4]); + REprintf("ERROR: '%s' needs 4 arguments: min_X min_Y max_X max_Y but '%s' is no valid max_Y\n", argv[i], argv[i+4]); return FALSE; } add_criterion(new LAScriterionKeepXY(min_X, min_Y, max_X, max_Y)); @@ -2096,19 +2096,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_X max_X\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: min_X max_X\n", argv[i]); return FALSE; } I32 min_X; if (sscanf(argv[i+1], "%d", &min_X) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_X max_X but '%s' is no valid min_X\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: min_X max_X but '%s' is no valid min_X\n", argv[i], argv[i+1]); return FALSE; } I32 max_X; if (sscanf(argv[i+2], "%d", &max_X) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_X max_X but '%s' is no valid max_X\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: min_X max_X but '%s' is no valid max_X\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionKeepX(min_X, max_X)); @@ -2119,19 +2119,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_Y max_Y\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: min_Y max_Y\n", argv[i]); return FALSE; } I32 min_Y; if (sscanf(argv[i+1], "%d", &min_Y) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_Y max_Y but '%s' is no valid min_Y\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: min_Y max_Y but '%s' is no valid min_Y\n", argv[i], argv[i+1]); return FALSE; } I32 max_Y; if (sscanf(argv[i+2], "%d", &max_Y) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_Y max_Y but '%s' is no valid max_Y\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: min_Y max_Y but '%s' is no valid max_Y\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionKeepY(min_Y, max_Y)); @@ -2143,19 +2143,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_Z max_Z\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: min_Z max_Z\n", argv[i]); return FALSE; } I32 min_Z; if (sscanf(argv[i+1], "%d", &min_Z) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_Z max_Z but '%s' is no valid min_Z\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: min_Z max_Z but '%s' is no valid min_Z\n", argv[i], argv[i+1]); return FALSE; } I32 max_Z; if (sscanf(argv[i+2], "%d", &max_Z) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_Z max_Z but '%s' is no valid max_Z\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: min_Z max_Z but '%s' is no valid max_Z\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionKeepZ(min_Z, max_Z)); @@ -2165,13 +2165,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: min_Z\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: min_Z\n", argv[i]); return FALSE; } I32 min_Z; if (sscanf(argv[i+1], "%d", &min_Z) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: min_Z but '%s' is no valid min_Z\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: min_Z but '%s' is no valid min_Z\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropZBelow(min_Z)); @@ -2181,13 +2181,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: max_Z\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: max_Z\n", argv[i]); return FALSE; } I32 max_Z; if (sscanf(argv[i+1], "%d", &max_Z) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: max_Z but '%s' is no valid max_Z\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: max_Z but '%s' is no valid max_Z\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropZAbove(max_Z)); @@ -2198,25 +2198,25 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+3) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: llx lly size\n", argv[i]); + REprintf("ERROR: '%s' needs 3 arguments: llx lly size\n", argv[i]); return FALSE; } F32 llx; if (sscanf(argv[i+1], "%f", &llx) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: llx lly size but '%s' is no valid llx\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 3 arguments: llx lly size but '%s' is no valid llx\n", argv[i], argv[i+1]); return FALSE; } F32 lly; if (sscanf(argv[i+2], "%f", &lly) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: llx lly size but '%s' is no valid lly\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 3 arguments: llx lly size but '%s' is no valid lly\n", argv[i], argv[i+2]); return FALSE; } F32 size; if (sscanf(argv[i+3], "%f", &size) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: llx lly size but '%s' is no valid size\n", argv[i], argv[i+3]); + REprintf("ERROR: '%s' needs 3 arguments: llx lly size but '%s' is no valid size\n", argv[i], argv[i+3]); return FALSE; } add_criterion(new LAScriterionKeepTile(llx, lly, size)); @@ -2226,25 +2226,25 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+3) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: center_x center_y radius\n", argv[i]); + REprintf("ERROR: '%s' needs 3 arguments: center_x center_y radius\n", argv[i]); return FALSE; } F64 center_x; if (sscanf(argv[i+1], "%lf", ¢er_x) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: center_x center_y radius but '%s' is no valid center_x\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 3 arguments: center_x center_y radius but '%s' is no valid center_x\n", argv[i], argv[i+1]); return FALSE; } F64 center_y; if (sscanf(argv[i+2], "%lf", ¢er_y) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: center_x center_y radius but '%s' is no valid center_y\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 3 arguments: center_x center_y radius but '%s' is no valid center_y\n", argv[i], argv[i+2]); return FALSE; } F64 radius; if (sscanf(argv[i+3], "%lf", &radius) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: center_x center_y radius but '%s' is no valid radius\n", argv[i], argv[i+3]); + REprintf("ERROR: '%s' needs 3 arguments: center_x center_y radius but '%s' is no valid radius\n", argv[i], argv[i+3]); return FALSE; } add_criterion(new LAScriterionKeepCircle(center_x, center_y, radius)); @@ -2256,7 +2256,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs at least 1 argument: return_number\n", argv[i]); + REprintf("ERROR: '%s' needs at least 1 argument: return_number\n", argv[i]); return FALSE; } *argv[i]='\0'; @@ -2267,12 +2267,12 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if (sscanf(argv[i], "%u", &return_number) != 1) { - fprintf(stderr,"ERROR: '-keep_return' needs at least 1 argument: return_number but '%s' is no valid return_number\n", argv[i]); + REprintf("ERROR: '-keep_return' needs at least 1 argument: return_number but '%s' is no valid return_number\n", argv[i]); return FALSE; } if (return_number > 15) { - fprintf(stderr,"ERROR: cannot keep return_number %u because it is larger than 15\n", return_number); + REprintf("ERROR: cannot keep return_number %u because it is larger than 15\n", return_number); return FALSE; } keep_return_mask |= (1u << return_number); @@ -2294,18 +2294,18 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: return_mask\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: return_mask\n", argv[i]); return FALSE; } U32 keep_return_mask; if (sscanf(argv[i+1], "%u", &keep_return_mask) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: return_mask but '%s' is no valid return_mask\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: return_mask but '%s' is no valid return_mask\n", argv[i], argv[i+1]); return FALSE; } if (keep_return_mask > U16_MAX) { - fprintf(stderr,"ERROR: '%s' needs a return_mask between 0 and %u but return_mask is %u\n", argv[i], U16_MAX, keep_return_mask); + REprintf("ERROR: '%s' needs a return_mask between 0 and %u but return_mask is %u\n", argv[i], U16_MAX, keep_return_mask); return FALSE; } add_criterion(new LAScriterionKeepReturns((U16)keep_return_mask)); @@ -2316,13 +2316,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: number_of_returns\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: number_of_returns\n", argv[i]); return FALSE; } U32 number_of_returns; if (sscanf(argv[i+1], "%u", &number_of_returns) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: number_of_returns but '%s' is no valid number_of_returns\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: number_of_returns but '%s' is no valid number_of_returns\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionKeepSpecificNumberOfReturns(number_of_returns)); @@ -2359,29 +2359,29 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: min max\n", argv[i]); return FALSE; } U32 min; if (sscanf(argv[i+1], "%u", &min) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); return FALSE; } U32 max; if (sscanf(argv[i+2], "%u", &max) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); return FALSE; } if (min > U16_MAX) { - fprintf(stderr,"ERROR: cannot keep intensity because min of %u is larger than %u\n", min, U16_MAX); + REprintf("ERROR: cannot keep intensity because min of %u is larger than %u\n", min, U16_MAX); return FALSE; } if (max > U16_MAX) { - fprintf(stderr,"ERROR: cannot keep intensity because max of %u is larger than %u\n", max, U16_MAX); + REprintf("ERROR: cannot keep intensity because max of %u is larger than %u\n", max, U16_MAX); return FALSE; } add_criterion(new LAScriterionKeepIntensity((U16)min, (U16)max)); @@ -2391,18 +2391,18 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: max\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: max\n", argv[i]); return FALSE; } U32 max; if (sscanf(argv[i+1], "%u", &max) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: max but '%s' is no valid max\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: max but '%s' is no valid max\n", argv[i], argv[i+1]); return FALSE; } if (max > U16_MAX) { - fprintf(stderr,"ERROR: cannot keep intensity above max of %u because it is larger than %u\n", max, U16_MAX); + REprintf("ERROR: cannot keep intensity above max of %u because it is larger than %u\n", max, U16_MAX); return FALSE; } add_criterion(new LAScriterionKeepIntensityAbove((U16)max)); @@ -2412,18 +2412,18 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: min\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: min\n", argv[i]); return FALSE; } U32 min; if (sscanf(argv[i+1], "%u", &min) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: min but '%s' is no valid min\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: min but '%s' is no valid min\n", argv[i], argv[i+1]); return FALSE; } if (min > U16_MAX) { - fprintf(stderr,"ERROR: cannot keep intensity below min of %u because it is larger than %u\n", min, U16_MAX); + REprintf("ERROR: cannot keep intensity below min of %u because it is larger than %u\n", min, U16_MAX); return FALSE; } add_criterion(new LAScriterionKeepIntensityBelow((U16)min)); @@ -2434,19 +2434,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: min max\n", argv[i]); return FALSE; } I32 min; if (sscanf(argv[i+1], "%d", &min) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); return FALSE; } I32 max; if (sscanf(argv[i+2], "%d", &max) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); return FALSE; } if (strcmp(argv[i]+10,"red") == 0) @@ -2479,19 +2479,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: min max\n", argv[i]); return FALSE; } F32 min; if (sscanf(argv[i+1], "%f", &min) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); return FALSE; } F32 max; if (sscanf(argv[i+2], "%f", &max) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); return FALSE; } if (strcmp(argv[i]+10,"") == 0) @@ -2526,19 +2526,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: min max\n", argv[i]); return FALSE; } I32 min; if (sscanf(argv[i+1], "%d", &min) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); return FALSE; } I32 max; if (sscanf(argv[i+2], "%d", &max) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionKeepScanAngle(min, max)); @@ -2569,7 +2569,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index\n", argv[i]); return FALSE; } *argv[i]='\0'; @@ -2583,13 +2583,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: value\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: value\n", argv[i]); return FALSE; } I32 value; if (sscanf(argv[i+1], "%d", &value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionKeepUserData(value)); @@ -2599,13 +2599,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: value\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: value\n", argv[i]); return FALSE; } I32 value; if (sscanf(argv[i+1], "%d", &value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionKeepUserDataBelow(value)); @@ -2615,13 +2615,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: value\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: value\n", argv[i]); return FALSE; } I32 value; if (sscanf(argv[i+1], "%d", &value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionKeepUserDataAbove(value)); @@ -2631,19 +2631,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: min max\n", argv[i]); return FALSE; } I32 min; if (sscanf(argv[i+1], "%d", &min) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); return FALSE; } I32 max; if (sscanf(argv[i+2], "%d", &max) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionKeepUserDataBetween(min, max)); @@ -2656,18 +2656,18 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs at least 1 argument: ID\n", argv[i]); + REprintf("ERROR: '%s' needs at least 1 argument: ID\n", argv[i]); return FALSE; } U32 ID; if (sscanf(argv[i+1], "%u", &ID) != 1) { - fprintf(stderr,"ERROR: '%s' needs at least 1 argument: ID but '%s' is no valid ID\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs at least 1 argument: ID but '%s' is no valid ID\n", argv[i], argv[i+1]); return FALSE; } if (ID > U16_MAX) { - fprintf(stderr,"ERROR: cannot keep_point_source ID %u because it is larger than %u\n", ID, U16_MAX); + REprintf("ERROR: cannot keep_point_source ID %u because it is larger than %u\n", ID, U16_MAX); return FALSE; } add_criterion(new LAScriterionKeepPointSource(ID)); @@ -2676,12 +2676,12 @@ BOOL LASfilter::parse(int argc, char* argv[]) *argv[i]='\0'; if (sscanf(argv[i+2], "%d", &ID) != 1) { - fprintf(stderr,"ERROR: '-keep_point_source' takes one or more IDs but '%s' is no valid ID\n", argv[i+2]); + REprintf("ERROR: '-keep_point_source' takes one or more IDs but '%s' is no valid ID\n", argv[i+2]); return FALSE; } if (ID > U16_MAX) { - fprintf(stderr,"ERROR: cannot keep_point_source ID %u because it is larger than %u\n", ID, U16_MAX); + REprintf("ERROR: cannot keep_point_source ID %u because it is larger than %u\n", ID, U16_MAX); return FALSE; } add_criterion(new LAScriterionKeepPointSource(ID)); @@ -2699,29 +2699,29 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_ID max_ID\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: min_ID max_ID\n", argv[i]); return FALSE; } U32 min_ID; if (sscanf(argv[i+1], "%u", &min_ID) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_ID max_ID but '%s' is no valid min_ID\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: min_ID max_ID but '%s' is no valid min_ID\n", argv[i], argv[i+1]); return FALSE; } U32 max_ID; if (sscanf(argv[i+2], "%u", &max_ID) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_ID max_ID but '%s' is no valid max_ID\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: min_ID max_ID but '%s' is no valid max_ID\n", argv[i], argv[i+2]); return FALSE; } if (min_ID > U16_MAX) { - fprintf(stderr,"ERROR: cannot keep point source because min_ID of %u is larger than %u\n", min_ID, U16_MAX); + REprintf("ERROR: cannot keep point source because min_ID of %u is larger than %u\n", min_ID, U16_MAX); return FALSE; } if (max_ID > U16_MAX) { - fprintf(stderr,"ERROR: cannot keep point source because max_ID of %u is larger than %u\n", max_ID, U16_MAX); + REprintf("ERROR: cannot keep point source because max_ID of %u is larger than %u\n", max_ID, U16_MAX); return FALSE; } add_criterion(new LAScriterionKeepPointSourceBetween((U16)min_ID, (U16)max_ID)); @@ -2734,19 +2734,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: start end\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: start end\n", argv[i]); return FALSE; } F64 start = 0.0; if (sscanf(argv[i+1], "%lf", &start) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: start end but '%s' is no valid start\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: start end but '%s' is no valid start\n", argv[i], argv[i+1]); return FALSE; } F64 end = 0.0; if (sscanf(argv[i+2], "%lf", &end) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: start end but '%s' is no valid end\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: start end but '%s' is no valid end\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionKeepGpsTime(start, end)); @@ -2756,13 +2756,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: time\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: time\n", argv[i]); return FALSE; } F64 time = 0.0; if (sscanf(argv[i+1], "%lf", &time) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: time but '%s' is no valid time\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: time but '%s' is no valid time\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropGpsTimeBelow(time)); @@ -2772,13 +2772,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: time\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: time\n", argv[i]); return FALSE; } F64 time = 0.0; if (sscanf(argv[i+1], "%lf", &time) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: time but '%s' is no valid time\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: time but '%s' is no valid time\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropGpsTimeAbove(time)); @@ -2791,19 +2791,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: index value\n", argv[i]); return FALSE; } I32 index; if (sscanf(argv[i+1], "%d", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: index value but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } F64 value; if (sscanf(argv[i+2], "%lf", &value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid value\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid value\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionKeepAttributeBelow(index, value)); @@ -2813,19 +2813,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: index value\n", argv[i]); return FALSE; } I32 index; if (sscanf(argv[i+1], "%d", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: index value but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } F64 value; if (sscanf(argv[i+2], "%lf", &value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid value\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid value\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionKeepAttributeAbove(index, value)); @@ -2835,25 +2835,25 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+3) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: index min max\n", argv[i]); + REprintf("ERROR: '%s' needs 3 arguments: index min max\n", argv[i]); return FALSE; } I32 index; if (sscanf(argv[i+1], "%d", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: index min max but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 3 arguments: index min max but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } F64 min; if (sscanf(argv[i+2], "%lf", &min) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: index min max but '%s' is no valid min\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 3 arguments: index min max but '%s' is no valid min\n", argv[i], argv[i+2]); return FALSE; } F64 max; if (sscanf(argv[i+3], "%lf", &max) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: index min max but '%s' is no valid max\n", argv[i], argv[i+3]); + REprintf("ERROR: '%s' needs 3 arguments: index min max but '%s' is no valid max\n", argv[i], argv[i+3]); return FALSE; } add_criterion(new LAScriterionKeepAttributeBetween(index, min, max)); @@ -2864,18 +2864,18 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: nth\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: nth\n", argv[i]); return FALSE; } U32 nth; if (sscanf(argv[i+1], "%u", &nth) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: nth but '%s' is no valid nth\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: nth but '%s' is no valid nth\n", argv[i], argv[i+1]); return FALSE; } if (nth == 0) { - fprintf(stderr,"ERROR: %u is no valid nth for '%s'\n", nth, argv[i]); + REprintf("ERROR: %u is no valid nth for '%s'\n", nth, argv[i]); return FALSE; } add_criterion(new LAScriterionKeepEveryNth(nth)); @@ -2885,13 +2885,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: fraction\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: fraction\n", argv[i]); return FALSE; } F32 fraction; if (sscanf(argv[i+1], "%f", &fraction) != 1) { - fprintf(stderr,"ERROR: '%s' needs at least 1 argument: fraction [seed] but '%s' is no valid fraction\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs at least 1 argument: fraction [seed] but '%s' is no valid fraction\n", argv[i], argv[i+1]); return FALSE; } if (((i+2) < argc) && ('0' <= argv[i+2][0]) && (argv[i+2][0] <= '9')) // maybe a seed was specified @@ -2899,7 +2899,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) U32 seed; if (sscanf(argv[i+2], "%u", &seed) != 1) { - fprintf(stderr,"ERROR: '%s' takes seed as second argument but '%s' is no valid seed\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' takes seed as second argument but '%s' is no valid seed\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionKeepRandomFraction(seed, fraction)); @@ -2925,18 +2925,18 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: number\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: number\n", argv[i]); return FALSE; } I32 number; if (sscanf(argv[i+1], "%d", &number) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: number but '%s' is no valid number\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: number but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } if ((number < 0) || (number > 3)) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: number between 0 and 3 so '%s' is not valid\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: number between 0 and 3 so '%s' is not valid\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionKeepScannerChannel(number)); @@ -2987,7 +2987,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs at least 1 argument: classification\n", argv[i]); + REprintf("ERROR: '%s' needs at least 1 argument: classification\n", argv[i]); return FALSE; } *argv[i]='\0'; @@ -2998,12 +2998,12 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if (sscanf(argv[i], "%u", &classification) != 1) { - fprintf(stderr,"ERROR: '-drop_classification' needs at least 1 argument: classification but '%s' is no valid classification\n", argv[i]); + REprintf("ERROR: '-drop_classification' needs at least 1 argument: classification but '%s' is no valid classification\n", argv[i]); return FALSE; } if (classification > 31) { - fprintf(stderr,"ERROR: cannot drop classification %u because it is larger than 31\n", classification); + REprintf("ERROR: cannot drop classification %u because it is larger than 31\n", classification); return FALSE; } drop_classification_mask |= (1u << classification); @@ -3025,13 +3025,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: mask\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: mask\n", argv[i]); return FALSE; } U32 drop_classification_mask; if (sscanf(argv[i+1], "%u", &drop_classification_mask) != 1) { - fprintf(stderr,"ERROR: '%s' needs at least 1 argument: mask but '%s' is no valid mask\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs at least 1 argument: mask but '%s' is no valid mask\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropClassifications(drop_classification_mask)); @@ -3044,7 +3044,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs at least 1 argument: classification\n", argv[i]); + REprintf("ERROR: '%s' needs at least 1 argument: classification\n", argv[i]); return FALSE; } *argv[i]='\0'; @@ -3054,12 +3054,12 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if (sscanf(argv[i], "%u", &extended_classification) != 1) { - fprintf(stderr,"ERROR: '-drop_extended_classification' needs at least 1 argument: classification but '%s' is no valid classification\n", argv[i]); + REprintf("ERROR: '-drop_extended_classification' needs at least 1 argument: classification but '%s' is no valid classification\n", argv[i]); return FALSE; } if (extended_classification > 255) { - fprintf(stderr,"ERROR: cannot drop extended classification %u because it is larger than 255\n", extended_classification); + REprintf("ERROR: cannot drop extended classification %u because it is larger than 255\n", extended_classification); return FALSE; } drop_extended_classification_mask[extended_classification/32] |= (1u << (extended_classification%32)); @@ -3072,55 +3072,55 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+8) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 8 arguments: mask7 mask6 mask5 mask4 mask3 mask2 mask1 mask0\n", argv[i]); + REprintf("ERROR: '%s' needs 8 arguments: mask7 mask6 mask5 mask4 mask3 mask2 mask1 mask0\n", argv[i]); return FALSE; } if (sscanf(argv[i+1], "%u", &(drop_extended_classification_mask[7])) != 1) { - fprintf(stderr,"ERROR: '%s' needs 8 arguments: mask7 mask6 mask5 mask4 mask3 mask2 mask1 mask0\n", argv[i]); - fprintf(stderr," but '%s' is a bad argument for mask7\n", argv[i+1]); + REprintf("ERROR: '%s' needs 8 arguments: mask7 mask6 mask5 mask4 mask3 mask2 mask1 mask0\n", argv[i]); + REprintf(" but '%s' is a bad argument for mask7\n", argv[i+1]); return FALSE; } if (sscanf(argv[i+2], "%u", &(drop_extended_classification_mask[6])) != 1) { - fprintf(stderr,"ERROR: '%s' needs 8 arguments: mask7 mask6 mask5 mask4 mask3 mask2 mask1 mask0\n", argv[i]); - fprintf(stderr," but '%s' is a bad argument for mask6\n", argv[i+2]); + REprintf("ERROR: '%s' needs 8 arguments: mask7 mask6 mask5 mask4 mask3 mask2 mask1 mask0\n", argv[i]); + REprintf(" but '%s' is a bad argument for mask6\n", argv[i+2]); return FALSE; } if (sscanf(argv[i+3], "%u", &(drop_extended_classification_mask[5])) != 1) { - fprintf(stderr,"ERROR: '%s' needs 8 arguments: mask7 mask6 mask5 mask4 mask3 mask2 mask1 mask0\n", argv[i]); - fprintf(stderr," but '%s' is a bad argument for mask5\n", argv[i+3]); + REprintf("ERROR: '%s' needs 8 arguments: mask7 mask6 mask5 mask4 mask3 mask2 mask1 mask0\n", argv[i]); + REprintf(" but '%s' is a bad argument for mask5\n", argv[i+3]); return FALSE; } if (sscanf(argv[i+4], "%u", &(drop_extended_classification_mask[4])) != 1) { - fprintf(stderr,"ERROR: '%s' needs 8 arguments: mask7 mask6 mask5 mask4 mask3 mask2 mask1 mask0\n", argv[i]); - fprintf(stderr," but '%s' is a bad argument for mask4\n", argv[i+4]); + REprintf("ERROR: '%s' needs 8 arguments: mask7 mask6 mask5 mask4 mask3 mask2 mask1 mask0\n", argv[i]); + REprintf(" but '%s' is a bad argument for mask4\n", argv[i+4]); return FALSE; } if (sscanf(argv[i+5], "%u", &(drop_extended_classification_mask[3])) != 1) { - fprintf(stderr,"ERROR: '%s' needs 8 arguments: mask7 mask6 mask5 mask4 mask3 mask2 mask1 mask0\n", argv[i]); - fprintf(stderr," but '%s' is a bad argument for mask3\n", argv[i+5]); + REprintf("ERROR: '%s' needs 8 arguments: mask7 mask6 mask5 mask4 mask3 mask2 mask1 mask0\n", argv[i]); + REprintf(" but '%s' is a bad argument for mask3\n", argv[i+5]); return FALSE; } if (sscanf(argv[i+6], "%u", &(drop_extended_classification_mask[2])) != 1) { - fprintf(stderr,"ERROR: '%s' needs 8 arguments: mask7 mask6 mask5 mask4 mask3 mask2 mask1 mask0\n", argv[i]); - fprintf(stderr," but '%s' is a bad argument for mask2\n", argv[i+6]); + REprintf("ERROR: '%s' needs 8 arguments: mask7 mask6 mask5 mask4 mask3 mask2 mask1 mask0\n", argv[i]); + REprintf(" but '%s' is a bad argument for mask2\n", argv[i+6]); return FALSE; } if (sscanf(argv[i+7], "%u", &(drop_extended_classification_mask[1])) != 1) { - fprintf(stderr,"ERROR: '%s' needs 8 arguments: mask7 mask6 mask5 mask4 mask3 mask2 mask1 mask0\n", argv[i]); - fprintf(stderr," but '%s' is a bad argument for mask1\n", argv[i+7]); + REprintf("ERROR: '%s' needs 8 arguments: mask7 mask6 mask5 mask4 mask3 mask2 mask1 mask0\n", argv[i]); + REprintf(" but '%s' is a bad argument for mask1\n", argv[i+7]); return FALSE; } if (sscanf(argv[i+8], "%u", &(drop_extended_classification_mask[0])) != 1) { - fprintf(stderr,"ERROR: '%s' needs 8 arguments: mask7 mask6 mask5 mask4 mask3 mask2 mask1 mask0\n", argv[i]); - fprintf(stderr," but '%s' is a bad argument for mask0\n", argv[i+8]); + REprintf("ERROR: '%s' needs 8 arguments: mask7 mask6 mask5 mask4 mask3 mask2 mask1 mask0\n", argv[i]); + REprintf(" but '%s' is a bad argument for mask0\n", argv[i+8]); return FALSE; } *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; *argv[i+5]='\0'; *argv[i+6]='\0'; *argv[i+7]='\0'; *argv[i+8]='\0'; i+=8; @@ -3132,31 +3132,31 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+4) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y\n", argv[i]); + REprintf("ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y\n", argv[i]); return FALSE; } F64 min_x; if (sscanf(argv[i+1], "%lf", &min_x) != 1) { - fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid min_x\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid min_x\n", argv[i], argv[i+1]); return FALSE; } F64 min_y; if (sscanf(argv[i+2], "%lf", &min_y) != 1) { - fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid min_y\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid min_y\n", argv[i], argv[i+2]); return FALSE; } F64 max_x; if (sscanf(argv[i+3], "%lf", &max_x) != 1) { - fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid max_x\n", argv[i], argv[i+3]); + REprintf("ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid max_x\n", argv[i], argv[i+3]); return FALSE; } F64 max_y; if (sscanf(argv[i+4], "%lf", &max_y) != 1) { - fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid max_y\n", argv[i], argv[i+4]); + REprintf("ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y but '%s' is no valid max_y\n", argv[i], argv[i+4]); return FALSE; } add_criterion(new LAScriterionDropxy(min_x, min_y, max_x, max_y)); @@ -3166,43 +3166,43 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+6) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z\n", argv[i]); + REprintf("ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z\n", argv[i]); return FALSE; } F64 min_x; if (sscanf(argv[i+1], "%lf", &min_x) != 1) { - fprintf(stderr,"ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid min_x\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid min_x\n", argv[i], argv[i+1]); return FALSE; } F64 min_y; if (sscanf(argv[i+2], "%lf", &min_y) != 1) { - fprintf(stderr,"ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid min_y\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid min_y\n", argv[i], argv[i+2]); return FALSE; } F64 min_z; if (sscanf(argv[i+3], "%lf", &min_z) != 1) { - fprintf(stderr,"ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid min_z\n", argv[i], argv[i+3]); + REprintf("ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid min_z\n", argv[i], argv[i+3]); return FALSE; } F64 max_x; if (sscanf(argv[i+4], "%lf", &max_x) != 1) { - fprintf(stderr,"ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid max_x\n", argv[i], argv[i+4]); + REprintf("ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid max_x\n", argv[i], argv[i+4]); return FALSE; } F64 max_y; if (sscanf(argv[i+5], "%lf", &max_y) != 1) { - fprintf(stderr,"ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid max_y\n", argv[i], argv[i+5]); + REprintf("ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid max_y\n", argv[i], argv[i+5]); return FALSE; } F64 max_z; if (sscanf(argv[i+6], "%lf", &max_z) != 1) { - fprintf(stderr,"ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid max_z\n", argv[i], argv[i+6]); + REprintf("ERROR: '%s' needs 6 arguments: min_x min_y min_z max_x max_y max_z but '%s' is no valid max_z\n", argv[i], argv[i+6]); return FALSE; } add_criterion(new LAScriterionDropxyz(min_x, min_y, min_z, max_x, max_y, max_z)); @@ -3212,19 +3212,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_x max_x\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: min_x max_x\n", argv[i]); return FALSE; } F64 min_x; if (sscanf(argv[i+1], "%lf", &min_x) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_x max_x but '%s' is no valid min_x\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: min_x max_x but '%s' is no valid min_x\n", argv[i], argv[i+1]); return FALSE; } F64 max_x; if (sscanf(argv[i+2], "%lf", &max_x) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_x max_x but '%s' is no valid max_x\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: min_x max_x but '%s' is no valid max_x\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionDropx(min_x, max_x)); @@ -3234,13 +3234,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: min_x\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: min_x\n", argv[i]); return FALSE; } F64 min_x; if (sscanf(argv[i+1], "%lf", &min_x) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: min_x but '%s' is no valid min_x\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: min_x but '%s' is no valid min_x\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropxBelow(min_x)); @@ -3250,13 +3250,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: max_x\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: max_x\n", argv[i]); return FALSE; } F64 max_x; if (sscanf(argv[i+1], "%lf", &max_x) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: max_x but '%s' is no valid max_x\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: max_x but '%s' is no valid max_x\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropxAbove(max_x)); @@ -3269,19 +3269,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_y max_y\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: min_y max_y\n", argv[i]); return FALSE; } F64 min_y; if (sscanf(argv[i+1], "%lf", &min_y) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_y max_y but '%s' is no valid min_y\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: min_y max_y but '%s' is no valid min_y\n", argv[i], argv[i+1]); return FALSE; } F64 max_y; if (sscanf(argv[i+2], "%lf", &max_y) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_y max_y but '%s' is no valid max_y\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: min_y max_y but '%s' is no valid max_y\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionDropy(min_y, max_y)); @@ -3291,13 +3291,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: min_y\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: min_y\n", argv[i]); return FALSE; } F64 min_y; if (sscanf(argv[i+1], "%lf", &min_y) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: min_y but '%s' is no valid min_y\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: min_y but '%s' is no valid min_y\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropyBelow(min_y)); @@ -3307,13 +3307,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: max_y\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: max_y\n", argv[i]); return FALSE; } F64 max_y; if (sscanf(argv[i+1], "%lf", &max_y) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: max_y but '%s' is no valid max_y\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: max_y but '%s' is no valid max_y\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropyAbove(max_y)); @@ -3326,19 +3326,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_z max_z\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: min_z max_z\n", argv[i]); return FALSE; } F64 min_z; if (sscanf(argv[i+1], "%lf", &min_z) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_z max_z but '%s' is no valid min_z\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: min_z max_z but '%s' is no valid min_z\n", argv[i], argv[i+1]); return FALSE; } F64 max_z; if (sscanf(argv[i+2], "%lf", &max_z) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_z max_z but '%s' is no valid max_z\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: min_z max_z but '%s' is no valid max_z\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionDropz(min_z, max_z)); @@ -3348,13 +3348,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: min_z\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: min_z\n", argv[i]); return FALSE; } F64 min_z; if (sscanf(argv[i+1], "%lf", &min_z) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: min_z but '%s' is no valid min_z\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: min_z but '%s' is no valid min_z\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropzBelow(min_z)); @@ -3364,13 +3364,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: max_z\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: max_z\n", argv[i]); return FALSE; } F64 max_z; if (sscanf(argv[i+1], "%lf", &max_z) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: max_z but '%s' is no valid max_z\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: max_z but '%s' is no valid max_z\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropzAbove(max_z)); @@ -3383,19 +3383,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_X max_X\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: min_X max_X\n", argv[i]); return FALSE; } I32 min; if (sscanf(argv[i+1], "%d", &min) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_X max_X but '%s' is no valid min_X\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: min_X max_X but '%s' is no valid min_X\n", argv[i], argv[i+1]); return FALSE; } I32 max; if (sscanf(argv[i+2], "%d", &max) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_X max_X but '%s' is no valid max_X\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: min_X max_X but '%s' is no valid max_X\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionDropX(min, max)); @@ -3405,13 +3405,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: min_X\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: min_X\n", argv[i]); return FALSE; } I32 min; if (sscanf(argv[i+1], "%d", &min) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: min_X but '%s' is no valid min_X\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: min_X but '%s' is no valid min_X\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropXBelow(min)); @@ -3421,13 +3421,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: max_X\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: max_X\n", argv[i]); return FALSE; } I32 max; if (sscanf(argv[i+1], "%d", &max) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: max_X but '%s' is no valid max_X\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: max_X but '%s' is no valid max_X\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropXAbove(max)); @@ -3440,19 +3440,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_Y max_Y\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: min_Y max_Y\n", argv[i]); return FALSE; } I32 min; if (sscanf(argv[i+1], "%d", &min) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_Y max_Y but '%s' is no valid min_Y\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: min_Y max_Y but '%s' is no valid min_Y\n", argv[i], argv[i+1]); return FALSE; } I32 max; if (sscanf(argv[i+2], "%d", &max) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_Y max_Y but '%s' is no valid max_Y\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: min_Y max_Y but '%s' is no valid max_Y\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionDropY(min, max)); @@ -3462,13 +3462,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: min_Y\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: min_Y\n", argv[i]); return FALSE; } I32 min; if (sscanf(argv[i+1], "%d", &min) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: min_Y but '%s' is no valid min_Y\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: min_Y but '%s' is no valid min_Y\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropYBelow(min)); @@ -3478,13 +3478,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: max_Y\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: max_Y\n", argv[i]); return FALSE; } I32 max; if (sscanf(argv[i+1], "%d", &max) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: max_Y but '%s' is no valid max_Y\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: max_Y but '%s' is no valid max_Y\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropYAbove(max)); @@ -3497,19 +3497,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_Z max_Z\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: min_Z max_Z\n", argv[i]); return FALSE; } I32 min; if (sscanf(argv[i+1], "%d", &min) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_Z max_Z but '%s' is no valid min_Z\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: min_Z max_Z but '%s' is no valid min_Z\n", argv[i], argv[i+1]); return FALSE; } I32 max; if (sscanf(argv[i+2], "%d", &max) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_Z max_Z but '%s' is no valid max_Z\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: min_Z max_Z but '%s' is no valid max_Z\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionDropZ(min, max)); @@ -3519,13 +3519,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: min_Z\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: min_Z\n", argv[i]); return FALSE; } I32 min; if (sscanf(argv[i+1], "%d", &min) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: min_Z but '%s' is no valid min_Z\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: min_Z but '%s' is no valid min_Z\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropZBelow(min)); @@ -3535,13 +3535,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: max_Z\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: max_Z\n", argv[i]); return FALSE; } I32 max; if (sscanf(argv[i+1], "%d", &max) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: max_Z but '%s' is no valid max_Z\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: max_Z but '%s' is no valid max_Z\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropZAbove(max)); @@ -3554,7 +3554,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs at least 1 argument: return_number\n", argv[i]); + REprintf("ERROR: '%s' needs at least 1 argument: return_number\n", argv[i]); return FALSE; } *argv[i]='\0'; @@ -3565,12 +3565,12 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if (sscanf(argv[i], "%u", &return_number) != 1) { - fprintf(stderr,"ERROR: '-drop_return' needs at least 1 argument: return_number but '%s' is no valid return_number\n", argv[i]); + REprintf("ERROR: '-drop_return' needs at least 1 argument: return_number but '%s' is no valid return_number\n", argv[i]); return FALSE; } if (return_number > 15) { - fprintf(stderr,"ERROR: cannot drop return_number %u because it is larger than 15\n", return_number); + REprintf("ERROR: cannot drop return_number %u because it is larger than 15\n", return_number); return FALSE; } drop_return_mask |= (1u << return_number); @@ -3592,18 +3592,18 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: return_mask\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: return_mask\n", argv[i]); return FALSE; } U32 drop_return_mask; if (sscanf(argv[i+1], "%u", &drop_return_mask) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: return_mask but '%s' is no valid return_mask\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: return_mask but '%s' is no valid return_mask\n", argv[i], argv[i+1]); return FALSE; } if (drop_return_mask > U16_MAX) { - fprintf(stderr,"ERROR: '%s' needs a return_mask between 0 and %u but return_mask is %u\n", argv[i], U16_MAX, drop_return_mask); + REprintf("ERROR: '%s' needs a return_mask between 0 and %u but return_mask is %u\n", argv[i], U16_MAX, drop_return_mask); return FALSE; } add_criterion(new LAScriterionDropReturns((U16)drop_return_mask)); @@ -3614,18 +3614,18 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: number of returns\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: number of returns\n", argv[i]); return FALSE; } U32 number_of_returns; if (sscanf(argv[i+1], "%u", &number_of_returns) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: number of returns but '%s' is no valid value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: number of returns but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } if (number_of_returns > 15) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: number of returns but '%u' is no valid value\n", argv[i], number_of_returns); + REprintf("ERROR: '%s' needs 1 argument: number of returns but '%u' is no valid value\n", argv[i], number_of_returns); return FALSE; } add_criterion(new LAScriterionDropSpecificNumberOfReturns(number_of_returns)); @@ -3660,18 +3660,18 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: scan direction\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: scan direction\n", argv[i]); return FALSE; } U32 scan_direction; if (sscanf(argv[i+1], "%u", &scan_direction) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: scan direction but '%s' is no valid value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: scan direction but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } if (scan_direction > 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: scan direction but '%u' is no valid value\n", argv[i], scan_direction); + REprintf("ERROR: '%s' needs 1 argument: scan direction but '%u' is no valid value\n", argv[i], scan_direction); return FALSE; } add_criterion(new LAScriterionDropScanDirection(scan_direction)); @@ -3683,13 +3683,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: max\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: max\n", argv[i]); return FALSE; } I32 max; if (sscanf(argv[i+1], "%d", &max) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: max but '%s' is no valid max\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: max but '%s' is no valid max\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropIntensityAbove(max)); @@ -3699,13 +3699,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: min\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: min\n", argv[i]); return FALSE; } I32 min; if (sscanf(argv[i+1], "%d", &min) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: min but '%s' is no valid min\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: min but '%s' is no valid min\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropIntensityBelow(min)); @@ -3715,19 +3715,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: min max\n", argv[i]); return FALSE; } I32 min; if (sscanf(argv[i+1], "%d", &min) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); return FALSE; } I32 max; if (sscanf(argv[i+2], "%d", &max) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionDropIntensityBetween(min, max)); @@ -3738,19 +3738,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: min max\n", argv[i]); return FALSE; } I32 min; if (sscanf(argv[i+1], "%d", &min) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); return FALSE; } I32 max; if (sscanf(argv[i+2], "%d", &max) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); return FALSE; } if (strcmp(argv[i]+10,"red") == 0) @@ -3780,13 +3780,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: max\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: max\n", argv[i]); return FALSE; } I32 max; if (sscanf(argv[i+1], "%d", &max) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: max but '%s' is no valid max\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: max but '%s' is no valid max\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionKeepScanAngle(-max, max)); @@ -3796,13 +3796,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: min\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: min\n", argv[i]); return FALSE; } I32 min; if (sscanf(argv[i+1], "%d", &min) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: min but '%s' is no valid min\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: min but '%s' is no valid min\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropScanAngleBetween(-min+1, min-1)); @@ -3815,13 +3815,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: max\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: max\n", argv[i]); return FALSE; } I32 max; if (sscanf(argv[i+1], "%d", &max) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: max but '%s' is no valid max\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: max but '%s' is no valid max\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropScanAngleAbove(max)); @@ -3831,13 +3831,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: min\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: min\n", argv[i]); return FALSE; } I32 min; if (sscanf(argv[i+1], "%d", &min) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: min but '%s' is no valid min\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: min but '%s' is no valid min\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropScanAngleBelow(min)); @@ -3847,19 +3847,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: min max\n", argv[i]); return FALSE; } I32 min; if (sscanf(argv[i+1], "%d", &min) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); return FALSE; } I32 max; if (sscanf(argv[i+2], "%d", &max) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionDropScanAngleBetween(min, max)); @@ -3890,7 +3890,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index\n", argv[i]); return FALSE; } *argv[i]='\0'; @@ -3904,7 +3904,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs at least 1 argument: value\n", argv[i]); + REprintf("ERROR: '%s' needs at least 1 argument: value\n", argv[i]); return FALSE; } *argv[i]='\0'; @@ -3914,12 +3914,12 @@ BOOL LASfilter::parse(int argc, char* argv[]) U32 user_data; if (sscanf(argv[i], "%u", &user_data) != 1) { - fprintf(stderr,"ERROR: '-drop_user_data' needs at least 1 argument: value but '%s' is no valid value\n", argv[i]); + REprintf("ERROR: '-drop_user_data' needs at least 1 argument: value but '%s' is no valid value\n", argv[i]); return FALSE; } if (user_data > 255) { - fprintf(stderr,"ERROR: cannot drop user data %u because it is larger than 255\n", user_data); + REprintf("ERROR: cannot drop user data %u because it is larger than 255\n", user_data); return FALSE; } add_criterion(new LAScriterionDropUserData(user_data)); @@ -3932,18 +3932,18 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: below\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: below\n", argv[i]); return FALSE; } U32 min; if (sscanf(argv[i+1], "%u", &min) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: below but '%s' is no valid value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: below but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } if (min > 255) { - fprintf(stderr,"ERROR: cannot drop user data below %u because it is larger than 255\n", min); + REprintf("ERROR: cannot drop user data below %u because it is larger than 255\n", min); return FALSE; } add_criterion(new LAScriterionDropUserDataBelow(min)); @@ -3953,18 +3953,18 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: above\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: above\n", argv[i]); return FALSE; } U32 max; if (sscanf(argv[i+1], "%u", &max) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: above but '%s' is no valid value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: above but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } if (max > 255) { - fprintf(stderr,"ERROR: cannot drop user data above %u because it is larger than 255\n", max); + REprintf("ERROR: cannot drop user data above %u because it is larger than 255\n", max); return FALSE; } add_criterion(new LAScriterionDropUserDataAbove(max)); @@ -3974,29 +3974,29 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: min max\n", argv[i]); return FALSE; } U32 min; if (sscanf(argv[i+1], "%u", &min) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); return FALSE; } if (min > 255) { - fprintf(stderr,"ERROR: cannot drop user data between min and max because min of %u is larger than 255\n", min); + REprintf("ERROR: cannot drop user data between min and max because min of %u is larger than 255\n", min); return FALSE; } U32 max; if (sscanf(argv[i+2], "%u", &max) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); return FALSE; } if (max > 255) { - fprintf(stderr,"ERROR: cannot drop user data between min and max because max of %u is larger than 255\n", max); + REprintf("ERROR: cannot drop user data between min and max because max of %u is larger than 255\n", max); return FALSE; } add_criterion(new LAScriterionDropUserDataBetween(min, max)); @@ -4009,7 +4009,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs at least 1 argument: ID\n", argv[i]); + REprintf("ERROR: '%s' needs at least 1 argument: ID\n", argv[i]); return FALSE; } *argv[i]='\0'; @@ -4019,12 +4019,12 @@ BOOL LASfilter::parse(int argc, char* argv[]) U32 ID; if (sscanf(argv[i], "%u", &ID) != 1) { - fprintf(stderr,"ERROR: '-drop_point_source' needs at least 1 argument: ID but '%s' is no valid ID\n", argv[i]); + REprintf("ERROR: '-drop_point_source' needs at least 1 argument: ID but '%s' is no valid ID\n", argv[i]); return FALSE; } if (ID > U16_MAX) { - fprintf(stderr,"ERROR: cannot drop_point_source ID %u because it is larger than %u\n", ID, U16_MAX); + REprintf("ERROR: cannot drop_point_source ID %u because it is larger than %u\n", ID, U16_MAX); return FALSE; } add_criterion(new LAScriterionDropPointSource(ID)); @@ -4037,18 +4037,18 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: min_ID\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: min_ID\n", argv[i]); return FALSE; } U32 min_ID; if (sscanf(argv[i+1], "%u", &min_ID) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: min_ID max_ID but '%s' is no valid min_ID\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: min_ID max_ID but '%s' is no valid min_ID\n", argv[i], argv[i+1]); return FALSE; } if (min_ID > U16_MAX) { - fprintf(stderr,"ERROR: cannot drop point source below min_ID of %u because it is larger than %u\n", min_ID, U16_MAX); + REprintf("ERROR: cannot drop point source below min_ID of %u because it is larger than %u\n", min_ID, U16_MAX); return FALSE; } add_criterion(new LAScriterionDropPointSourceBelow((U16)min_ID)); @@ -4058,18 +4058,18 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: max_ID\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: max_ID\n", argv[i]); return FALSE; } U32 max_ID; if (sscanf(argv[i+1], "%u", &max_ID) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: max_ID but '%s' is no valid max_ID\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: max_ID but '%s' is no valid max_ID\n", argv[i], argv[i+1]); return FALSE; } if (max_ID > U16_MAX) { - fprintf(stderr,"ERROR: cannot drop point source above max_ID of %u because it is larger than %u\n", max_ID, U16_MAX); + REprintf("ERROR: cannot drop point source above max_ID of %u because it is larger than %u\n", max_ID, U16_MAX); return FALSE; } add_criterion(new LAScriterionDropPointSourceAbove((U16)max_ID)); @@ -4079,29 +4079,29 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_ID max_ID\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: min_ID max_ID\n", argv[i]); return FALSE; } U32 min_ID; if (sscanf(argv[i+1], "%u", &min_ID) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_ID max_ID but '%s' is no valid min_ID\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: min_ID max_ID but '%s' is no valid min_ID\n", argv[i], argv[i+1]); return FALSE; } U32 max_ID; if (sscanf(argv[i+2], "%d", &max_ID) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min_ID max_ID but '%s' is no valid max_ID\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: min_ID max_ID but '%s' is no valid max_ID\n", argv[i], argv[i+2]); return FALSE; } if (min_ID > U16_MAX) { - fprintf(stderr,"ERROR: cannot drop point source because min_ID of %u is larger than %u\n", min_ID, U16_MAX); + REprintf("ERROR: cannot drop point source because min_ID of %u is larger than %u\n", min_ID, U16_MAX); return FALSE; } if (max_ID > U16_MAX) { - fprintf(stderr,"ERROR: cannot drop point source because max_ID of %u is larger than %u\n", max_ID, U16_MAX); + REprintf("ERROR: cannot drop point source because max_ID of %u is larger than %u\n", max_ID, U16_MAX); return FALSE; } add_criterion(new LAScriterionDropPointSourceBetween((U16)min_ID, (U16)max_ID)); @@ -4114,13 +4114,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: max_gps_time\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: max_gps_time\n", argv[i]); return FALSE; } F64 max_gps_time; if (sscanf(argv[i+1], "%lf", &max_gps_time) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: max_gps_time but '%s' is no valid max_gps_time\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: max_gps_time but '%s' is no valid max_gps_time\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropGpsTimeAbove(max_gps_time)); @@ -4130,13 +4130,13 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: min_gps_time\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: min_gps_time\n", argv[i]); return FALSE; } F64 min_gps_time; if (sscanf(argv[i+1], "%lf", &min_gps_time) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: min_gps_time but '%s' is no valid min_gps_time\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: min_gps_time but '%s' is no valid min_gps_time\n", argv[i], argv[i+1]); return FALSE; } add_criterion(new LAScriterionDropGpsTimeBelow(min_gps_time)); @@ -4146,19 +4146,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: min max\n", argv[i]); return FALSE; } F64 min; if (sscanf(argv[i+1], "%lf", &min) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid min\n", argv[i], argv[i+1]); return FALSE; } F64 max; if (sscanf(argv[i+2], "%lf", &max) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: min max but '%s' is no valid max\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionDropGpsTimeBetween(min, max)); @@ -4171,19 +4171,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: index value\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: index value but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } F64 value; if (sscanf(argv[i+2], "%lf", &value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value '%s' is no valid value\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: index value '%s' is no valid value\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionDropAttributeBelow(index, value)); @@ -4193,19 +4193,19 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: index value\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: index value but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } F64 value; if (sscanf(argv[i+2], "%lf", &value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value '%s' is no valid value\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: index value '%s' is no valid value\n", argv[i], argv[i+2]); return FALSE; } add_criterion(new LAScriterionDropAttributeAbove(index, value)); @@ -4215,25 +4215,25 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+3) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: index below above\n", argv[i]); + REprintf("ERROR: '%s' needs 3 arguments: index below above\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: index below above but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 3 arguments: index below above but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } F64 below; if (sscanf(argv[i+2], "%lf", &below) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: index below above but '%s' is no valid below\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 3 arguments: index below above but '%s' is no valid below\n", argv[i], argv[i+2]); return FALSE; } F64 above; if (sscanf(argv[i+3], "%lf", &above) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: index below above but '%s' is no valid above\n", argv[i], argv[i+3]); + REprintf("ERROR: '%s' needs 3 arguments: index below above but '%s' is no valid above\n", argv[i], argv[i+3]); return FALSE; } add_criterion(new LAScriterionDropAttributeBetween(index, below, above)); @@ -4244,18 +4244,18 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: nth\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: nth\n", argv[i]); return FALSE; } U32 nth; if (sscanf(argv[i+1], "%u", &nth) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument nth but '%s' is no valid nth\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument nth but '%s' is no valid nth\n", argv[i], argv[i+1]); return FALSE; } if (nth == 0) { - fprintf(stderr,"ERROR: %u is no valid nth for '%s'\n", nth, argv[i]); + REprintf("ERROR: %u is no valid nth for '%s'\n", nth, argv[i]); return FALSE; } add_criterion(new LAScriterionDropEveryNth(nth)); @@ -4265,18 +4265,18 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: number\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: number\n", argv[i]); return FALSE; } U32 scanner_channel; if (sscanf(argv[i+1], "%u", &scanner_channel) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument channel but '%s' is no valid value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument channel but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } if (scanner_channel > 3) { - fprintf(stderr,"ERROR: %u is no valid value for '%s'\n", scanner_channel, argv[i]); + REprintf("ERROR: %u is no valid value for '%s'\n", scanner_channel, argv[i]); return FALSE; } add_criterion(new LAScriterionDropScannerChannel(scanner_channel)); @@ -4299,18 +4299,18 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: grid spacing\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: grid spacing\n", argv[i]); return FALSE; } F32 step; if (sscanf(argv[i+1], "%f", &step) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: grid spacing but '%s' is no valid value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: grid spacing but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } if (step <= 0.0f) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: grid spacing but '%g' is no valid value\n", argv[i], step); + REprintf("ERROR: '%s' needs 1 argument: grid spacing but '%g' is no valid value\n", argv[i], step); return FALSE; } add_criterion(new LAScriterionThinWithGrid(step)); @@ -4320,18 +4320,18 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: time spacing\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: time spacing\n", argv[i]); return FALSE; } F64 step; if (sscanf(argv[i+1], "%lf", &step) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: time spacing but '%s' is no valid value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: time spacing but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } if (step <= 0.0) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: time spacing but '%g' is no valid value\n", argv[i], step); + REprintf("ERROR: '%s' needs 1 argument: time spacing but '%g' is no valid value\n", argv[i], step); return FALSE; } add_criterion(new LAScriterionThinPulsesWithTime(step)); @@ -4341,18 +4341,18 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: time spacing\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: time spacing\n", argv[i]); return FALSE; } F64 step; if (sscanf(argv[i+1], "%lf", &step) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: time spacing but '%s' is no valid value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: time spacing but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } if (step <= 0.0) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: time spacing but '%g' is no valid value\n", argv[i], step); + REprintf("ERROR: '%s' needs 1 argument: time spacing but '%g' is no valid value\n", argv[i], step); return FALSE; } add_criterion(new LAScriterionThinPointsWithTime(step)); @@ -4365,7 +4365,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if (num_criteria < 2) { - fprintf(stderr,"ERROR: '%s' needs to be preceeded by at least two filters\n", argv[i]); + REprintf("ERROR: '%s' needs to be preceeded by at least two filters\n", argv[i]); return FALSE; } LAScriterion* filter_criterion = new LAScriterionAnd(criteria[num_criteria-2], criteria[num_criteria-1]); @@ -4380,7 +4380,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if (num_criteria < 2) { - fprintf(stderr,"ERROR: '%s' needs to be preceeded by at least two filters\n", argv[i]); + REprintf("ERROR: '%s' needs to be preceeded by at least two filters\n", argv[i]); return FALSE; } LAScriterion* filter_criterion = new LAScriterionOr(criteria[num_criteria-2], criteria[num_criteria-1]); @@ -4394,14 +4394,14 @@ BOOL LASfilter::parse(int argc, char* argv[]) } else if (strncmp(argv[i],"-clip_", 6) == 0) { - fprintf(stderr,"ERROR: '%s' is no longer recognized. check documentation with '-h'.\n", argv[i]); - fprintf(stderr," rename '-clip' to '-keep_xy'.\n"); - fprintf(stderr," rename '-clip_box' to '-keep_xyz'.\n"); - fprintf(stderr," rename '-clip_tile' to '-keep_tile'.\n"); - fprintf(stderr," rename '-clip_z_below' to '-drop_z_below'.\n"); - fprintf(stderr," rename '-clip_z_above' to '-drop_z_above'.\n"); - fprintf(stderr," rename '-clip_z_between' to '-drop_z'.\n"); - fprintf(stderr," etc ...\n"); + REprintf("ERROR: '%s' is no longer recognized. check documentation with '-h'.\n", argv[i]); + REprintf(" rename '-clip' to '-keep_xy'.\n"); + REprintf(" rename '-clip_box' to '-keep_xyz'.\n"); + REprintf(" rename '-clip_tile' to '-keep_tile'.\n"); + REprintf(" rename '-clip_z_below' to '-drop_z_below'.\n"); + REprintf(" rename '-clip_z_above' to '-drop_z_above'.\n"); + REprintf(" rename '-clip_z_between' to '-drop_z'.\n"); + REprintf(" etc ...\n"); return FALSE; } } @@ -4410,7 +4410,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) { if (drop_extended_classification_mask[0] || drop_extended_classification_mask[1] || drop_extended_classification_mask[2] || drop_extended_classification_mask[3] || drop_extended_classification_mask[4] || drop_extended_classification_mask[5] || drop_extended_classification_mask[6] || drop_extended_classification_mask[7]) { - fprintf(stderr,"ERROR: cannot use '-drop_extended_class' and '-keep_extended_class' simultaneously\n"); + REprintf("ERROR: cannot use '-drop_extended_class' and '-keep_extended_class' simultaneously\n"); return FALSE; } else diff --git a/src/LASlib/lasignore.cpp b/src/LASlib/lasignore.cpp index 30fff8b..ce4efd6 100644 --- a/src/LASlib/lasignore.cpp +++ b/src/LASlib/lasignore.cpp @@ -34,17 +34,17 @@ void LASignore::usage() const { - fprintf(stderr,"Ignore points based on classifications.\n"); - fprintf(stderr," -ignore_class 7\n"); - fprintf(stderr," -ignore_class 0 1 7 33\n"); - fprintf(stderr,"Ignore points based on return type.\n"); - fprintf(stderr," -ignore_first -ignore_first_of_many\n"); - fprintf(stderr," -ignore_last -ignore_last_of_many\n"); - fprintf(stderr," -ignore_intermediate\n"); - fprintf(stderr," -ignore_single\n"); - fprintf(stderr,"Ignore points based on flags.\n"); - fprintf(stderr," -ignore_synthetic -ignore_keypoint\n"); - fprintf(stderr," -ignore_withheld -ignore_overlap\n"); + REprintf("Ignore points based on classifications.\n"); + REprintf(" -ignore_class 7\n"); + REprintf(" -ignore_class 0 1 7 33\n"); + REprintf("Ignore points based on return type.\n"); + REprintf(" -ignore_first -ignore_first_of_many\n"); + REprintf(" -ignore_last -ignore_last_of_many\n"); + REprintf(" -ignore_intermediate\n"); + REprintf(" -ignore_single\n"); + REprintf("Ignore points based on flags.\n"); + REprintf(" -ignore_synthetic -ignore_keypoint\n"); + REprintf(" -ignore_withheld -ignore_overlap\n"); } void LASignore::ignore_class(U8 classification) @@ -72,7 +72,7 @@ BOOL LASignore::parse(int& i, int argc, char *argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 at least argument: classification\n", argv[i]); + REprintf("ERROR: '%s' needs 1 at least argument: classification\n", argv[i]); return FALSE; } int i_in = i; @@ -83,12 +83,12 @@ BOOL LASignore::parse(int& i, int argc, char *argv[]) U32 classification; if (sscanf(argv[i], "%u", &classification) != 1) { - fprintf(stderr,"ERROR: '%s' needs arguments between 0 and 255 but '%s' is no valid code\n", argv[i_in], argv[i]); + REprintf("ERROR: '%s' needs arguments between 0 and 255 but '%s' is no valid code\n", argv[i_in], argv[i]); return FALSE; } if (classification > 255) { - fprintf(stderr,"ERROR: '%s' needs arguments between 0 and 255 but '%u' is out of range\n", argv[i_in], classification); + REprintf("ERROR: '%s' needs arguments between 0 and 255 but '%u' is out of range\n", argv[i_in], classification); return FALSE; } ignore_mask |= (1u << (classification >> 5)); @@ -102,23 +102,23 @@ BOOL LASignore::parse(int& i, int argc, char *argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: mask\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: mask\n", argv[i]); return FALSE; } U32 classification_mask; if (sscanf(argv[i+1], "%u", &classification_mask) != 1) { - fprintf(stderr,"ERROR: '%s' needs argument between 0x00000000 and 0xFFFFFFFF but '%s' is no valid mask\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs argument between 0x00000000 and 0xFFFFFFFF but '%s' is no valid mask\n", argv[i], argv[i+1]); return FALSE; } if (classification_mask == 0x00000000) { - fprintf(stderr,"ERROR: '%s' needs argument between 0x00000000 and 0xFFFFFFFF but %u makes no sense\n", argv[i], classification_mask); + REprintf("ERROR: '%s' needs argument between 0x00000000 and 0xFFFFFFFF but %u makes no sense\n", argv[i], classification_mask); return FALSE; } if (classification_mask == 0xFFFFFFFF) { - fprintf(stderr,"ERROR: '%s' needs argument between 0x00000000 and 0xFFFFFFFF but %u makes no sense\n", argv[i], classification_mask); + REprintf("ERROR: '%s' needs argument between 0x00000000 and 0xFFFFFFFF but %u makes no sense\n", argv[i], classification_mask); return FALSE; } ignore_mask |= 1; @@ -179,7 +179,7 @@ BOOL LASignore::parse(int& i, int argc, char *argv[]) } else { - fprintf(stderr, "ERROR: cannot understand argument '%s'\n", argv[i]); + REprintf( "ERROR: cannot understand argument '%s'\n", argv[i]); return FALSE; } return TRUE; diff --git a/src/LASlib/laskdtree.cpp b/src/LASlib/laskdtree.cpp index c2a8642..688046d 100644 --- a/src/LASlib/laskdtree.cpp +++ b/src/LASlib/laskdtree.cpp @@ -326,7 +326,7 @@ void LASkdtreeRectangles::overlap_rectangles(LASkdtreeRectanglesNode* node, I32 void LASkdtreeRectangles::print_overlap() { - fprintf(stderr, "overlap elements: %u\n", (U32)overlap_set->size()); + REprintf( "overlap elements: %u\n", (U32)overlap_set->size()); my_index_set::iterator set_element = overlap_set->begin(); while (TRUE) { @@ -337,7 +337,7 @@ void LASkdtreeRectangles::print_overlap() U32 idx = (*set_element); - fprintf(stderr, "overlap %u\n", idx); + REprintf( "overlap %u\n", idx); set_element++; } diff --git a/src/LASlib/lasreader.cpp b/src/LASlib/lasreader.cpp index c5db8d9..fb9a19d 100644 --- a/src/LASlib/lasreader.cpp +++ b/src/LASlib/lasreader.cpp @@ -567,7 +567,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth } if (!lasreadermerged->open()) { - fprintf(stderr,"ERROR: cannot open lasreadermerged with %d file names\n", file_name_number); + REprintf("ERROR: cannot open lasreadermerged with %d file names\n", file_name_number); delete lasreadermerged; return 0; } @@ -585,7 +585,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderStored* lasreaderstored = new LASreaderStored(); if (!lasreaderstored->open(lasreadermerged)) { - fprintf(stderr, "ERROR: could not open lasreaderstored with lasreadermerged\n"); + REprintf( "ERROR: could not open lasreaderstored with lasreadermerged\n"); delete lasreaderstored; return 0; } @@ -600,7 +600,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderPipeOn* lasreaderpipeon = new LASreaderPipeOn(); if (!lasreaderpipeon->open(lasreader)) { - fprintf(stderr,"ERROR: cannot open lasreaderpipeon with lasreadermerged\n"); + REprintf("ERROR: cannot open lasreaderpipeon with lasreadermerged\n"); delete lasreaderpipeon; return 0; } @@ -723,7 +723,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth if (ignore) lasreaderbuffered->set_ignore(ignore); if (!lasreaderbuffered->open()) { - fprintf(stderr,"ERROR: cannot open lasreaderbuffered with %d file names\n", file_name_number+neighbor_file_name_number); + REprintf("ERROR: cannot open lasreaderbuffered with %d file names\n", file_name_number+neighbor_file_name_number); delete lasreaderbuffered; return 0; } @@ -736,7 +736,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderStored* lasreaderstored = new LASreaderStored(); if (!lasreaderstored->open(lasreaderbuffered)) { - fprintf(stderr, "ERROR: could not open lasreaderstored with lasreaderbuffered\n"); + REprintf( "ERROR: could not open lasreaderstored with lasreaderbuffered\n"); delete lasreaderstored; return 0; } @@ -751,7 +751,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderPipeOn* lasreaderpipeon = new LASreaderPipeOn(); if (!lasreaderpipeon->open(lasreader)) { - fprintf(stderr,"ERROR: cannot open lasreaderpipeon with lasreaderbuffered\n"); + REprintf("ERROR: cannot open lasreaderpipeon with lasreaderbuffered\n"); delete lasreaderpipeon; return 0; } @@ -804,7 +804,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth lasreaderlas = new LASreaderLASrescalereoffset(scale_factor[0], scale_factor[1], scale_factor[2], offset[0], offset[1], offset[2]); if (!lasreaderlas->open(file_name, io_ibuffer_size, FALSE, decompress_selective)) { - fprintf(stderr,"ERROR: cannot open lasreaderlas with file name '%s'\n", file_name); + REprintf("ERROR: cannot open lasreaderlas with file name '%s'\n", file_name); delete lasreaderlas; return 0; } @@ -833,7 +833,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderStored* lasreaderstored = new LASreaderStored(); if (!lasreaderstored->open(lasreaderlas)) { - fprintf(stderr, "ERROR: could not open lasreaderstored with lasreaderlas\n"); + REprintf( "ERROR: could not open lasreaderstored with lasreaderlas\n"); delete lasreaderstored; return 0; } @@ -848,7 +848,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderPipeOn* lasreaderpipeon = new LASreaderPipeOn(); if (!lasreaderpipeon->open(lasreader)) { - fprintf(stderr,"ERROR: cannot open lasreaderpipeon with lasreaderlas\n"); + REprintf("ERROR: cannot open lasreaderpipeon with lasreaderlas\n"); delete lasreaderpipeon; return 0; } @@ -872,7 +872,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth lasreaderbin = new LASreaderBINrescalereoffset(scale_factor[0], scale_factor[1], scale_factor[2], offset[0], offset[1], offset[2]); if (!lasreaderbin->open(file_name)) { - fprintf(stderr,"ERROR: cannot open lasreaderbin with file name '%s'\n", file_name); + REprintf("ERROR: cannot open lasreaderbin with file name '%s'\n", file_name); delete lasreaderbin; return 0; } @@ -894,7 +894,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderStored* lasreaderstored = new LASreaderStored(); if (!lasreaderstored->open(lasreaderbin)) { - fprintf(stderr, "ERROR: could not open lasreaderstored with lasreaderbin\n"); + REprintf( "ERROR: could not open lasreaderstored with lasreaderbin\n"); delete lasreaderstored; return 0; } @@ -909,7 +909,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderPipeOn* lasreaderpipeon = new LASreaderPipeOn(); if (!lasreaderpipeon->open(lasreader)) { - fprintf(stderr,"ERROR: cannot open lasreaderpipeon with lasreaderbin\n"); + REprintf("ERROR: cannot open lasreaderpipeon with lasreaderbin\n"); delete lasreaderpipeon; return 0; } @@ -933,7 +933,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth lasreadershp = new LASreaderSHPrescalereoffset(scale_factor[0], scale_factor[1], scale_factor[2], offset[0], offset[1], offset[2]); if (!lasreadershp->open(file_name)) { - fprintf(stderr,"ERROR: cannot open lasreadershp with file name '%s'\n", file_name); + REprintf("ERROR: cannot open lasreadershp with file name '%s'\n", file_name); delete lasreadershp; return 0; } @@ -950,7 +950,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderStored* lasreaderstored = new LASreaderStored(); if (!lasreaderstored->open(lasreadershp)) { - fprintf(stderr, "ERROR: could not open lasreaderstored with lasreadershp\n"); + REprintf( "ERROR: could not open lasreaderstored with lasreadershp\n"); delete lasreaderstored; return 0; } @@ -965,7 +965,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderPipeOn* lasreaderpipeon = new LASreaderPipeOn(); if (!lasreaderpipeon->open(lasreader)) { - fprintf(stderr,"ERROR: cannot open lasreaderpipeon with lasreadershp\n"); + REprintf("ERROR: cannot open lasreaderpipeon with lasreadershp\n"); delete lasreaderpipeon; return 0; } @@ -989,7 +989,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth lasreaderasc = new LASreaderASCrescalereoffset(scale_factor[0], scale_factor[1], scale_factor[2], offset[0], offset[1], offset[2]); if (!lasreaderasc->open(file_name, comma_not_point)) { - fprintf(stderr,"ERROR: cannot open lasreaderasc with file name '%s'\n", file_name); + REprintf("ERROR: cannot open lasreaderasc with file name '%s'\n", file_name); delete lasreaderasc; return 0; } @@ -1006,7 +1006,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderStored* lasreaderstored = new LASreaderStored(); if (!lasreaderstored->open(lasreaderasc)) { - fprintf(stderr, "ERROR: could not open lasreaderstored with lasreaderasc\n"); + REprintf( "ERROR: could not open lasreaderstored with lasreaderasc\n"); delete lasreaderstored; return 0; } @@ -1021,7 +1021,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderPipeOn* lasreaderpipeon = new LASreaderPipeOn(); if (!lasreaderpipeon->open(lasreader)) { - fprintf(stderr,"ERROR: cannot open lasreaderpipeon with lasreaderasc\n"); + REprintf("ERROR: cannot open lasreaderpipeon with lasreaderasc\n"); delete lasreaderpipeon; return 0; } @@ -1045,7 +1045,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth lasreaderbil = new LASreaderBILrescalereoffset(scale_factor[0], scale_factor[1], scale_factor[2], offset[0], offset[1], offset[2]); if (!lasreaderbil->open(file_name)) { - fprintf(stderr,"ERROR: cannot open lasreaderbil with file name '%s'\n", file_name); + REprintf("ERROR: cannot open lasreaderbil with file name '%s'\n", file_name); delete lasreaderbil; return 0; } @@ -1062,7 +1062,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderStored* lasreaderstored = new LASreaderStored(); if (!lasreaderstored->open(lasreaderbil)) { - fprintf(stderr, "ERROR: could not open lasreaderstored with lasreaderbil\n"); + REprintf( "ERROR: could not open lasreaderstored with lasreaderbil\n"); delete lasreaderstored; return 0; } @@ -1077,7 +1077,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderPipeOn* lasreaderpipeon = new LASreaderPipeOn(); if (!lasreaderpipeon->open(lasreader)) { - fprintf(stderr,"ERROR: cannot open lasreaderpipeon with lasreaderbil\n"); + REprintf("ERROR: cannot open lasreaderpipeon with lasreaderbil\n"); delete lasreaderpipeon; return 0; } @@ -1101,7 +1101,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth lasreaderdtm = new LASreaderDTMrescalereoffset(scale_factor[0], scale_factor[1], scale_factor[2], offset[0], offset[1], offset[2]); if (!lasreaderdtm->open(file_name)) { - fprintf(stderr,"ERROR: cannot open lasreaderdtm with file name '%s'\n", file_name); + REprintf("ERROR: cannot open lasreaderdtm with file name '%s'\n", file_name); delete lasreaderdtm; return 0; } @@ -1118,7 +1118,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderStored* lasreaderstored = new LASreaderStored(); if (!lasreaderstored->open(lasreaderdtm)) { - fprintf(stderr, "ERROR: could not open lasreaderstored with lasreaderdtm\n"); + REprintf( "ERROR: could not open lasreaderstored with lasreaderdtm\n"); delete lasreaderstored; return 0; } @@ -1133,7 +1133,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderPipeOn* lasreaderpipeon = new LASreaderPipeOn(); if (!lasreaderpipeon->open(lasreader)) { - fprintf(stderr,"ERROR: cannot open lasreaderpipeon with lasreaderdtm\n"); + REprintf("ERROR: cannot open lasreaderpipeon with lasreaderdtm\n"); delete lasreaderpipeon; return 0; } @@ -1153,7 +1153,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth lasreaderply->set_offset(offset); if (!lasreaderply->open(file_name, point_type, populate_header)) { - fprintf(stderr,"ERROR: cannot open lasreaderply with file name '%s'\n", file_name); + REprintf("ERROR: cannot open lasreaderply with file name '%s'\n", file_name); delete lasreaderply; return 0; } @@ -1170,7 +1170,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderStored* lasreaderstored = new LASreaderStored(); if (!lasreaderstored->open(lasreaderply)) { - fprintf(stderr, "ERROR: could not open lasreaderstored with lasreaderply\n"); + REprintf( "ERROR: could not open lasreaderstored with lasreaderply\n"); delete lasreaderstored; return 0; } @@ -1185,7 +1185,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderPipeOn* lasreaderpipeon = new LASreaderPipeOn(); if (!lasreaderpipeon->open(lasreader)) { - fprintf(stderr,"ERROR: cannot open lasreaderpipeon with lasreaderply\n"); + REprintf("ERROR: cannot open lasreaderpipeon with lasreaderply\n"); delete lasreaderpipeon; return 0; } @@ -1209,7 +1209,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth lasreaderqfit = new LASreaderQFITrescalereoffset(scale_factor[0], scale_factor[1], scale_factor[2], offset[0], offset[1], offset[2]); if (!lasreaderqfit->open(file_name)) { - fprintf(stderr,"ERROR: cannot open lasreaderqfit with file name '%s'\n", file_name); + REprintf("ERROR: cannot open lasreaderqfit with file name '%s'\n", file_name); delete lasreaderqfit; return 0; } @@ -1231,7 +1231,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderStored* lasreaderstored = new LASreaderStored(); if (!lasreaderstored->open(lasreaderqfit)) { - fprintf(stderr, "ERROR: could not open lasreaderstored with lasreaderqfit\n"); + REprintf( "ERROR: could not open lasreaderstored with lasreaderqfit\n"); delete lasreaderstored; return 0; } @@ -1246,7 +1246,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderPipeOn* lasreaderpipeon = new LASreaderPipeOn(); if (!lasreaderpipeon->open(lasreader)) { - fprintf(stderr,"ERROR: cannot open lasreaderpipeon with lasreaderqfit\n"); + REprintf("ERROR: cannot open lasreaderpipeon with lasreaderqfit\n"); delete lasreaderpipeon; return 0; } @@ -1277,7 +1277,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth } if (!lasreadertxt->open(file_name, point_type, parse_string, skip_lines, populate_header)) { - fprintf(stderr,"ERROR: cannot open lasreadertxt with file name '%s'\n", file_name); + REprintf("ERROR: cannot open lasreadertxt with file name '%s'\n", file_name); delete lasreadertxt; return 0; } @@ -1294,7 +1294,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderStored* lasreaderstored = new LASreaderStored(); if (!lasreaderstored->open(lasreadertxt)) { - fprintf(stderr, "ERROR: could not open lasreaderstored with lasreadertxt\n"); + REprintf( "ERROR: could not open lasreaderstored with lasreadertxt\n"); delete lasreaderstored; return 0; } @@ -1309,7 +1309,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderPipeOn* lasreaderpipeon = new LASreaderPipeOn(); if (!lasreaderpipeon->open(lasreader)) { - fprintf(stderr,"ERROR: cannot open lasreaderpipeon with lasreadertxt\n"); + REprintf("ERROR: cannot open lasreaderpipeon with lasreadertxt\n"); delete lasreaderpipeon; return 0; } @@ -1345,7 +1345,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth } if (!lasreadertxt->open(stdin, 0, point_type, parse_string, skip_lines, FALSE)) { - fprintf(stderr,"ERROR: cannot open lasreadertxt with file name '%s'\n", file_name); + REprintf("ERROR: cannot open lasreadertxt with file name '%s'\n", file_name); delete lasreadertxt; return 0; } @@ -1362,7 +1362,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderStored* lasreaderstored = new LASreaderStored(); if (!lasreaderstored->open(lasreadertxt)) { - fprintf(stderr, "ERROR: could not open lasreaderstored with lasreadertxt\n"); + REprintf( "ERROR: could not open lasreaderstored with lasreadertxt\n"); delete lasreaderstored; return 0; } @@ -1377,7 +1377,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderPipeOn* lasreaderpipeon = new LASreaderPipeOn(); if (!lasreaderpipeon->open(lasreader)) { - fprintf(stderr,"ERROR: cannot open lasreaderpipeon with lasreadertxt\n"); + REprintf("ERROR: cannot open lasreaderpipeon with lasreadertxt\n"); delete lasreaderpipeon; return 0; } @@ -1401,7 +1401,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth lasreaderlas = new LASreaderLASrescalereoffset(scale_factor[0], scale_factor[1], scale_factor[2], offset[0], offset[1], offset[2]); if (!lasreaderlas->open(stdin)) { - fprintf(stderr,"ERROR: cannot open lasreaderlas from stdin \n"); + REprintf("ERROR: cannot open lasreaderlas from stdin \n"); delete lasreaderlas; return 0; } @@ -1417,7 +1417,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderStored* lasreaderstored = new LASreaderStored(); if (!lasreaderstored->open(lasreaderlas)) { - fprintf(stderr, "ERROR: could not open lasreaderstored with lasreaderlas\n"); + REprintf( "ERROR: could not open lasreaderstored with lasreaderlas\n"); delete lasreaderstored; return 0; } @@ -1432,7 +1432,7 @@ LASreader* LASreadOpener::open(const CHAR* other_file_name, BOOL reset_after_oth LASreaderPipeOn* lasreaderpipeon = new LASreaderPipeOn(); if (!lasreaderpipeon->open(lasreader)) { - fprintf(stderr,"ERROR: cannot open lasreaderpipeon with lasreaderlas from stdin\n"); + REprintf("ERROR: cannot open lasreaderpipeon with lasreaderlas from stdin\n"); delete lasreaderpipeon; return 0; } @@ -1454,7 +1454,7 @@ BOOL LASreadOpener::reopen(LASreader* lasreader, BOOL remain_buffered) { if (lasreader == 0) { - fprintf(stderr,"ERROR: pointer to LASreader is NULL\n"); + REprintf("ERROR: pointer to LASreader is NULL\n"); } // make sure the LASreader was closed @@ -1476,7 +1476,7 @@ BOOL LASreadOpener::reopen(LASreader* lasreader, BOOL remain_buffered) LASreaderStored* lasreaderstored = (LASreaderStored*)lasreader; if (!lasreaderstored->reopen()) { - fprintf(stderr, "ERROR: could not reopen lasreaderstored for stored input\n"); + REprintf( "ERROR: could not reopen lasreaderstored for stored input\n"); return FALSE; } return TRUE; @@ -1488,7 +1488,7 @@ BOOL LASreadOpener::reopen(LASreader* lasreader, BOOL remain_buffered) LASreaderMerged* lasreadermerged = (LASreaderMerged*)lasreader; if (!lasreadermerged->reopen()) { - fprintf(stderr,"ERROR: cannot reopen lasreadermerged\n"); + REprintf("ERROR: cannot reopen lasreadermerged\n"); return FALSE; } if (inside_rectangle || inside_tile || inside_circle) @@ -1505,7 +1505,7 @@ BOOL LASreadOpener::reopen(LASreader* lasreader, BOOL remain_buffered) LASreaderBuffered* lasreaderbuffered = (LASreaderBuffered*)lasreader; if (!lasreaderbuffered->reopen()) { - fprintf(stderr,"ERROR: cannot reopen lasreaderbuffered\n"); + REprintf("ERROR: cannot reopen lasreaderbuffered\n"); return FALSE; } if (inside_rectangle || inside_tile || inside_circle) @@ -1526,7 +1526,7 @@ BOOL LASreadOpener::reopen(LASreader* lasreader, BOOL remain_buffered) LASreaderLAS* lasreaderlas = (LASreaderLAS*)lasreader; if (!lasreaderlas->open(file_name, io_ibuffer_size, FALSE, decompress_selective)) { - fprintf(stderr,"ERROR: cannot reopen lasreaderlas with file name '%s'\n", file_name); + REprintf("ERROR: cannot reopen lasreaderlas with file name '%s'\n", file_name); return FALSE; } if (inside_rectangle || inside_tile || inside_circle) @@ -1543,7 +1543,7 @@ BOOL LASreadOpener::reopen(LASreader* lasreader, BOOL remain_buffered) LASreaderBIN* lasreaderbin = (LASreaderBIN*)lasreader; if (!lasreaderbin->open(file_name)) { - fprintf(stderr,"ERROR: cannot reopen lasreaderbin with file name '%s'\n", file_name); + REprintf("ERROR: cannot reopen lasreaderbin with file name '%s'\n", file_name); return FALSE; } if (inside_rectangle || inside_tile || inside_circle) @@ -1560,7 +1560,7 @@ BOOL LASreadOpener::reopen(LASreader* lasreader, BOOL remain_buffered) LASreaderSHP* lasreadershp = (LASreaderSHP*)lasreader; if (!lasreadershp->reopen(file_name)) { - fprintf(stderr,"ERROR: cannot reopen lasreadershp with file name '%s'\n", file_name); + REprintf("ERROR: cannot reopen lasreadershp with file name '%s'\n", file_name); return FALSE; } if (inside_rectangle || inside_tile || inside_circle) @@ -1577,7 +1577,7 @@ BOOL LASreadOpener::reopen(LASreader* lasreader, BOOL remain_buffered) LASreaderQFIT* lasreaderqfit = (LASreaderQFIT*)lasreader; if (!lasreaderqfit->reopen(file_name)) { - fprintf(stderr,"ERROR: cannot reopen lasreaderqfit with file name '%s'\n", file_name); + REprintf("ERROR: cannot reopen lasreaderqfit with file name '%s'\n", file_name); return FALSE; } if (inside_rectangle || inside_tile || inside_circle) @@ -1594,7 +1594,7 @@ BOOL LASreadOpener::reopen(LASreader* lasreader, BOOL remain_buffered) LASreaderASC* lasreaderasc = (LASreaderASC*)lasreader; if (!lasreaderasc->reopen(file_name)) { - fprintf(stderr,"ERROR: cannot reopen lasreaderasc with file name '%s'\n", file_name); + REprintf("ERROR: cannot reopen lasreaderasc with file name '%s'\n", file_name); return FALSE; } if (inside_rectangle || inside_tile || inside_circle) @@ -1611,7 +1611,7 @@ BOOL LASreadOpener::reopen(LASreader* lasreader, BOOL remain_buffered) LASreaderBIL* lasreaderbil = (LASreaderBIL*)lasreader; if (!lasreaderbil->reopen(file_name)) { - fprintf(stderr,"ERROR: cannot reopen lasreaderbil with file name '%s'\n", file_name); + REprintf("ERROR: cannot reopen lasreaderbil with file name '%s'\n", file_name); return FALSE; } if (inside_rectangle || inside_tile || inside_circle) @@ -1628,7 +1628,7 @@ BOOL LASreadOpener::reopen(LASreader* lasreader, BOOL remain_buffered) LASreaderDTM* lasreaderdtm = (LASreaderDTM*)lasreader; if (!lasreaderdtm->reopen(file_name)) { - fprintf(stderr,"ERROR: cannot reopen lasreaderdtm with file name '%s'\n", file_name); + REprintf("ERROR: cannot reopen lasreaderdtm with file name '%s'\n", file_name); return FALSE; } if (inside_rectangle || inside_tile || inside_circle) @@ -1645,7 +1645,7 @@ BOOL LASreadOpener::reopen(LASreader* lasreader, BOOL remain_buffered) LASreaderTXT* lasreadertxt = (LASreaderTXT*)lasreader; if (!lasreadertxt->reopen(file_name)) { - fprintf(stderr,"ERROR: cannot reopen lasreadertxt with file name '%s'\n", file_name); + REprintf("ERROR: cannot reopen lasreadertxt with file name '%s'\n", file_name); return FALSE; } if (inside_rectangle || inside_tile || inside_circle) @@ -1661,7 +1661,7 @@ BOOL LASreadOpener::reopen(LASreader* lasreader, BOOL remain_buffered) } else { - fprintf(stderr,"ERROR: no lasreader input specified\n"); + REprintf("ERROR: no lasreader input specified\n"); return FALSE; } } @@ -1693,27 +1693,27 @@ LASwaveform13reader* LASreadOpener::open_waveform13(const LASheader* lasheader) void LASreadOpener::usage() const { - fprintf(stderr,"Supported LAS Inputs\n"); - fprintf(stderr," -i lidar.las\n"); - fprintf(stderr," -i lidar.laz\n"); - fprintf(stderr," -i lidar1.las lidar2.las lidar3.las -merged\n"); - fprintf(stderr," -i *.las - merged\n"); - fprintf(stderr," -i flight0??.laz flight1??.laz\n"); - fprintf(stderr," -i terrasolid.bin\n"); - fprintf(stderr," -i esri.shp\n"); - fprintf(stderr," -i nasa.qi\n"); - fprintf(stderr," -i lidar.txt -iparse xyzti -iskip 2 (on-the-fly from ASCII)\n"); - fprintf(stderr," -i lidar.txt -iparse xyzi -itranslate_intensity 1024\n"); - fprintf(stderr," -lof file_list.txt\n"); - fprintf(stderr," -stdin (pipe from stdin)\n"); - fprintf(stderr," -rescale 0.01 0.01 0.001\n"); - fprintf(stderr," -rescale_xy 0.01 0.01\n"); - fprintf(stderr," -rescale_z 0.01\n"); - fprintf(stderr," -reoffset 600000 4000000 0\n"); - fprintf(stderr,"Fast AOI Queries for LAS/LAZ with spatial indexing LAX files\n"); - fprintf(stderr," -inside min_x min_y max_x max_y\n"); - fprintf(stderr," -inside_tile ll_x ll_y size\n"); - fprintf(stderr," -inside_circle center_x center_y radius\n"); + REprintf("Supported LAS Inputs\n"); + REprintf(" -i lidar.las\n"); + REprintf(" -i lidar.laz\n"); + REprintf(" -i lidar1.las lidar2.las lidar3.las -merged\n"); + REprintf(" -i *.las - merged\n"); + REprintf(" -i flight0??.laz flight1??.laz\n"); + REprintf(" -i terrasolid.bin\n"); + REprintf(" -i esri.shp\n"); + REprintf(" -i nasa.qi\n"); + REprintf(" -i lidar.txt -iparse xyzti -iskip 2 (on-the-fly from ASCII)\n"); + REprintf(" -i lidar.txt -iparse xyzi -itranslate_intensity 1024\n"); + REprintf(" -lof file_list.txt\n"); + REprintf(" -stdin (pipe from stdin)\n"); + REprintf(" -rescale 0.01 0.01 0.001\n"); + REprintf(" -rescale_xy 0.01 0.01\n"); + REprintf(" -rescale_z 0.01\n"); + REprintf(" -reoffset 600000 4000000 0\n"); + REprintf("Fast AOI Queries for LAS/LAZ with spatial indexing LAX files\n"); + REprintf(" -inside min_x min_y max_x max_y\n"); + REprintf(" -inside_tile ll_x ll_y size\n"); + REprintf(" -inside_circle center_x center_y radius\n"); } BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) @@ -1739,7 +1739,7 @@ BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs at least 1 argument: file_name or wild_card\n", argv[i]); + REprintf("ERROR: '%s' needs at least 1 argument: file_name or wild_card\n", argv[i]); return FALSE; } *argv[i]='\0'; @@ -1769,7 +1769,7 @@ BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) } else { - fprintf(stderr,"ERROR: this tool does not process '-ignore_xxxx' options\n"); + REprintf("ERROR: this tool does not process '-ignore_xxxx' options\n"); return FALSE; } } @@ -1779,30 +1779,30 @@ BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) { if ((i+3) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: ll_x ll_y size\n", argv[i]); + REprintf("ERROR: '%s' needs 3 arguments: ll_x ll_y size\n", argv[i]); return FALSE; } F32 ll_x; if (sscanf(argv[i+1], "%f", &ll_x) != 1) { - fprintf(stderr, "ERROR: '%s' needs 3 arguments: ll_x ll_y size, but '%s' is not a valid ll_x.\n", argv[i], argv[i+1]); + REprintf( "ERROR: '%s' needs 3 arguments: ll_x ll_y size, but '%s' is not a valid ll_x.\n", argv[i], argv[i+1]); return FALSE; } F32 ll_y; if (sscanf(argv[i+2], "%f", &ll_y) != 1) { - fprintf(stderr, "ERROR: '%s' needs 3 arguments: ll_x ll_y size, but '%s' is not a valid ll_y.\n", argv[i], argv[i+2]); + REprintf( "ERROR: '%s' needs 3 arguments: ll_x ll_y size, but '%s' is not a valid ll_y.\n", argv[i], argv[i+2]); return FALSE; } F32 size; if (sscanf(argv[i+3], "%f", &size) != 1) { - fprintf(stderr, "ERROR: '%s' needs 3 arguments: ll_x ll_y size, but '%s' is not a valid size.\n", argv[i], argv[i+3]); + REprintf( "ERROR: '%s' needs 3 arguments: ll_x ll_y size, but '%s' is not a valid size.\n", argv[i], argv[i+3]); return FALSE; } if (size <= 0.0f) { - fprintf(stderr, "ERROR: '%s' needs 3 arguments: ll_x ll_y size, but %f is not valid a size.\n", argv[i], size); + REprintf( "ERROR: '%s' needs 3 arguments: ll_x ll_y size, but %f is not valid a size.\n", argv[i], size); return FALSE; } set_inside_tile(ll_x, ll_y, size); @@ -1812,30 +1812,30 @@ BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) { if ((i+3) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: center_x center_y radius\n", argv[i]); + REprintf("ERROR: '%s' needs 3 arguments: center_x center_y radius\n", argv[i]); return FALSE; } F64 center_x; if (sscanf(argv[i+1], "%lf", ¢er_x) != 1) { - fprintf(stderr, "ERROR: '%s' needs 3 arguments: center_x center_y radius, but '%s' is not a valid center_x.\n", argv[i], argv[i+1]); + REprintf( "ERROR: '%s' needs 3 arguments: center_x center_y radius, but '%s' is not a valid center_x.\n", argv[i], argv[i+1]); return FALSE; } F64 center_y; if (sscanf(argv[i+2], "%lf", ¢er_y) != 1) { - fprintf(stderr, "ERROR: '%s' needs 3 arguments: center_x center_y radius, but '%s' is not a valid center_y.\n", argv[i], argv[i+2]); + REprintf( "ERROR: '%s' needs 3 arguments: center_x center_y radius, but '%s' is not a valid center_y.\n", argv[i], argv[i+2]); return FALSE; } F64 radius; if (sscanf(argv[i+3], "%lf", &radius) != 1) { - fprintf(stderr, "ERROR: '%s' needs 3 arguments: center_x center_y radius, but '%s' is not a valid radius.\n", argv[i], argv[i+3]); + REprintf( "ERROR: '%s' needs 3 arguments: center_x center_y radius, but '%s' is not a valid radius.\n", argv[i], argv[i+3]); return FALSE; } if (radius <= 0.0f) { - fprintf(stderr, "ERROR: '%s' needs 3 arguments: center_x center_y radius, but %lf is not valid a radius.\n", argv[i], radius); + REprintf( "ERROR: '%s' needs 3 arguments: center_x center_y radius, but %lf is not valid a radius.\n", argv[i], radius); return FALSE; } set_inside_circle(center_x, center_y, radius); @@ -1845,41 +1845,41 @@ BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) { if ((i+4) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y\n", argv[i]); + REprintf("ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y\n", argv[i]); return FALSE; } F64 min_x; if (sscanf(argv[i+1], "%lf", &min_x) != 1) { - fprintf(stderr, "ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y, but '%s' is not a valid min_x.\n", argv[i], argv[i+1]); + REprintf( "ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y, but '%s' is not a valid min_x.\n", argv[i], argv[i+1]); return FALSE; } F64 min_y; if (sscanf(argv[i+2], "%lf", &min_y) != 1) { - fprintf(stderr, "ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y, but '%s' is not a valid min_y.\n", argv[i], argv[i+2]); + REprintf( "ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y, but '%s' is not a valid min_y.\n", argv[i], argv[i+2]); return FALSE; } F64 max_x; if (sscanf(argv[i+3], "%lf", &max_x) != 1) { - fprintf(stderr, "ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y, but '%s' is not a valid max_x.\n", argv[i], argv[i+3]); + REprintf( "ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y, but '%s' is not a valid max_x.\n", argv[i], argv[i+3]); return FALSE; } F64 max_y; if (sscanf(argv[i+4], "%lf", &max_y) != 1) { - fprintf(stderr, "ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y, but '%s' is not a valid max_y.\n", argv[i], argv[i+4]); + REprintf( "ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y, but '%s' is not a valid max_y.\n", argv[i], argv[i+4]); return FALSE; } if (min_x >= max_x) { - fprintf(stderr, "ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y, but %lf / %lf are not a valid min_x / max_x pair.\n", argv[i], min_x, max_x); + REprintf( "ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y, but %lf / %lf are not a valid min_x / max_x pair.\n", argv[i], min_x, max_x); return FALSE; } if (min_y >= max_y) { - fprintf(stderr, "ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y, but %lf / %lf are not a valid min_y / max_y pair.\n", argv[i], min_y, max_y); + REprintf( "ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y, but %lf / %lf are not a valid min_y / max_y pair.\n", argv[i], min_y, max_y); return FALSE; } set_inside_rectangle(min_x, min_y, max_x, max_y); @@ -1887,7 +1887,7 @@ BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) } else { - fprintf(stderr,"ERROR: unknown '-inside' option '%s'\n", argv[i]); + REprintf("ERROR: unknown '-inside' option '%s'\n", argv[i]); return FALSE; } } @@ -1895,7 +1895,7 @@ BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) { if ((i+3) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: data_type name description\n", argv[i]); + REprintf("ERROR: '%s' needs 3 arguments: data_type name description\n", argv[i]); return FALSE; } if (((i+4) < argc) && (atof(argv[i+4]) != 0.0)) @@ -1945,7 +1945,7 @@ BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: string\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: string\n", argv[i]); return FALSE; } set_parse_string(argv[i+1]); @@ -1955,18 +1955,18 @@ BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: number_of_lines\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: number_of_lines\n", argv[i]); return FALSE; } U32 number_of_lines; if (sscanf(argv[i+1], "%u", &number_of_lines) != 1) { - fprintf(stderr, "ERROR: '%s' needs 1 argument: number_of_lines but '%s' is not a valid number.\n", argv[i], argv[i+1]); + REprintf( "ERROR: '%s' needs 1 argument: number_of_lines but '%s' is not a valid number.\n", argv[i], argv[i+1]); return FALSE; } if (number_of_lines == 0) { - fprintf(stderr, "ERROR: '%s' needs 1 argument: number_of_lines but %u is not valid.\n", argv[i], number_of_lines); + REprintf( "ERROR: '%s' needs 1 argument: number_of_lines but %u is not valid.\n", argv[i], number_of_lines); return FALSE; } set_skip_lines(number_of_lines); @@ -1976,18 +1976,18 @@ BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: size\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: size\n", argv[i]); return FALSE; } U32 buffer_size; if (sscanf(argv[i+1], "%u", &buffer_size) != 1) { - fprintf(stderr, "ERROR: '%s' needs 1 argument: size but '%s' is not a valid size.\n", argv[i], argv[i+1]); + REprintf( "ERROR: '%s' needs 1 argument: size but '%s' is not a valid size.\n", argv[i], argv[i+1]); return FALSE; } if (buffer_size == 0) { - fprintf(stderr, "ERROR: '%s' needs 1 argument: size but %u is not valid.\n", argv[i], buffer_size); + REprintf( "ERROR: '%s' needs 1 argument: size but %u is not valid.\n", argv[i], buffer_size); return FALSE; } set_io_ibuffer_size(buffer_size); @@ -1997,18 +1997,18 @@ BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: translation\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: translation\n", argv[i]); return FALSE; } F32 translation; if (sscanf(argv[i+1], "%f", &translation) != 1) { - fprintf(stderr, "ERROR: '%s' needs 1 argument: translation but '%s' is not valid.\n", argv[i], argv[i+1]); + REprintf( "ERROR: '%s' needs 1 argument: translation but '%s' is not valid.\n", argv[i], argv[i+1]); return FALSE; } if (translation == 0.0f) { - fprintf(stderr, "ERROR: '%s' needs 1 argument: translation but %f is not valid.\n", argv[i], translation); + REprintf( "ERROR: '%s' needs 1 argument: translation but %f is not valid.\n", argv[i], translation); return FALSE; } set_translate_intensity(translation); @@ -2018,18 +2018,18 @@ BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: scale\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: scale\n", argv[i]); return FALSE; } F32 scale; if (sscanf(argv[i+1], "%f", &scale) != 1) { - fprintf(stderr, "ERROR: '%s' needs 1 argument: scale but '%s' is not valid.\n", argv[i], argv[i+1]); + REprintf( "ERROR: '%s' needs 1 argument: scale but '%s' is not valid.\n", argv[i], argv[i+1]); return FALSE; } if (scale == 0.0f) { - fprintf(stderr, "ERROR: '%s' needs 1 argument: scale but %f is not valid.\n", argv[i], scale); + REprintf( "ERROR: '%s' needs 1 argument: scale but %f is not valid.\n", argv[i], scale); return FALSE; } set_scale_intensity(scale); @@ -2039,18 +2039,18 @@ BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: translation\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: translation\n", argv[i]); return FALSE; } F32 translation; if (sscanf(argv[i+1], "%f", &translation) != 1) { - fprintf(stderr, "ERROR: '%s' needs 1 argument: translation but '%s' is not valid.\n", argv[i], argv[i+1]); + REprintf( "ERROR: '%s' needs 1 argument: translation but '%s' is not valid.\n", argv[i], argv[i+1]); return FALSE; } if (translation == 0.0f) { - fprintf(stderr, "ERROR: '%s' needs 1 argument: translation but %f is not valid.\n", argv[i], translation); + REprintf( "ERROR: '%s' needs 1 argument: translation but %f is not valid.\n", argv[i], translation); return FALSE; } set_translate_scan_angle(translation); @@ -2060,18 +2060,18 @@ BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: scale\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: scale\n", argv[i]); return FALSE; } F32 scale; if (sscanf(argv[i+1], "%f", &scale) != 1) { - fprintf(stderr, "ERROR: '%s' needs 1 argument: scale but '%s' is not valid.\n", argv[i], argv[i+1]); + REprintf( "ERROR: '%s' needs 1 argument: scale but '%s' is not valid.\n", argv[i], argv[i+1]); return FALSE; } if (scale == 0.0f) { - fprintf(stderr, "ERROR: '%s' needs 1 argument: scale but %f is not valid.\n", argv[i], scale); + REprintf( "ERROR: '%s' needs 1 argument: scale but %f is not valid.\n", argv[i], scale); return FALSE; } set_scale_scan_angle(scale); @@ -2101,38 +2101,38 @@ BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) { if ((i+3) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: rescale_x rescale_y rescale_z\n", argv[i]); + REprintf("ERROR: '%s' needs 3 arguments: rescale_x rescale_y rescale_z\n", argv[i]); return FALSE; } F64 scale_factor[3]; if (sscanf(argv[i+1], "%lf", &(scale_factor[0])) != 1) { - fprintf(stderr, "ERROR: '%s' needs 3 arguments: rescale_x rescale_y rescale_z, but '%s' is not a valid rescale_x", argv[i], argv[i+1]); + REprintf( "ERROR: '%s' needs 3 arguments: rescale_x rescale_y rescale_z, but '%s' is not a valid rescale_x", argv[i], argv[i+1]); return FALSE; } if (scale_factor[0] == 0.0) { - fprintf(stderr, "ERROR: '%s' needs 3 arguments: rescale_x rescale_y rescale_z, but %lf is not a valid rescale_x", argv[i], scale_factor[0]); + REprintf( "ERROR: '%s' needs 3 arguments: rescale_x rescale_y rescale_z, but %lf is not a valid rescale_x", argv[i], scale_factor[0]); return FALSE; } if (sscanf(argv[i+2], "%lf", &(scale_factor[1])) != 1) { - fprintf(stderr, "ERROR: '%s' needs 3 arguments: rescale_x rescale_y rescale_z, but '%s' is not a valid rescale_y", argv[i], argv[i+2]); + REprintf( "ERROR: '%s' needs 3 arguments: rescale_x rescale_y rescale_z, but '%s' is not a valid rescale_y", argv[i], argv[i+2]); return FALSE; } if (scale_factor[1] == 0.0) { - fprintf(stderr, "ERROR: '%s' needs 3 arguments: rescale_x rescale_y rescale_z, but %lf is not a valid rescale_y", argv[i], scale_factor[1]); + REprintf( "ERROR: '%s' needs 3 arguments: rescale_x rescale_y rescale_z, but %lf is not a valid rescale_y", argv[i], scale_factor[1]); return FALSE; } if (sscanf(argv[i+3], "%lf", &(scale_factor[2])) != 1) { - fprintf(stderr, "ERROR: '%s' needs 3 arguments: rescale_x rescale_y rescale_z, but '%s' is not a valid rescale_z", argv[i], argv[i+3]); + REprintf( "ERROR: '%s' needs 3 arguments: rescale_x rescale_y rescale_z, but '%s' is not a valid rescale_z", argv[i], argv[i+3]); return FALSE; } if (scale_factor[2] == 0.0) { - fprintf(stderr, "ERROR: '%s' needs 3 arguments: rescale_x rescale_y rescale_z, but %lf is not a valid rescale_z", argv[i], scale_factor[2]); + REprintf( "ERROR: '%s' needs 3 arguments: rescale_x rescale_y rescale_z, but %lf is not a valid rescale_z", argv[i], scale_factor[2]); return FALSE; } set_scale_factor(scale_factor); @@ -2142,28 +2142,28 @@ BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 argument: rescale_x rescale_y\n", argv[i]); + REprintf("ERROR: '%s' needs 2 argument: rescale_x rescale_y\n", argv[i]); return FALSE; } F64 scale_factor[3]; if (sscanf(argv[i+1], "%lf", &(scale_factor[0])) != 1) { - fprintf(stderr, "ERROR: '%s' needs 3 arguments: rescale_x rescale_y, but '%s' is not a valid rescale_x", argv[i], argv[i+1]); + REprintf( "ERROR: '%s' needs 3 arguments: rescale_x rescale_y, but '%s' is not a valid rescale_x", argv[i], argv[i+1]); return FALSE; } if (scale_factor[0] == 0.0) { - fprintf(stderr, "ERROR: '%s' needs 3 arguments: rescale_x rescale_y, but %lf is not a valid rescale_x", argv[i], scale_factor[0]); + REprintf( "ERROR: '%s' needs 3 arguments: rescale_x rescale_y, but %lf is not a valid rescale_x", argv[i], scale_factor[0]); return FALSE; } if (sscanf(argv[i+2], "%lf", &(scale_factor[1])) != 1) { - fprintf(stderr, "ERROR: '%s' needs 3 arguments: rescale_x rescale_y, but '%s' is not a valid rescale_y", argv[i], argv[i+2]); + REprintf( "ERROR: '%s' needs 3 arguments: rescale_x rescale_y, but '%s' is not a valid rescale_y", argv[i], argv[i+2]); return FALSE; } if (scale_factor[1] == 0.0) { - fprintf(stderr, "ERROR: '%s' needs 3 arguments: rescale_x rescale_y, but %lf is not a valid rescale_y", argv[i], scale_factor[1]); + REprintf( "ERROR: '%s' needs 3 arguments: rescale_x rescale_y, but %lf is not a valid rescale_y", argv[i], scale_factor[1]); return FALSE; } scale_factor[2] = 0.0; @@ -2174,7 +2174,7 @@ BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: rescale_z\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: rescale_z\n", argv[i]); return FALSE; } F64 scale_factor[3]; @@ -2182,12 +2182,12 @@ BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) scale_factor[1] = 0.0; if (sscanf(argv[i+1], "%lf", &(scale_factor[2])) != 1) { - fprintf(stderr, "ERROR: '%s' needs 1 argument: rescale_z, but '%s' is not a valid rescale_z", argv[i], argv[i+1]); + REprintf( "ERROR: '%s' needs 1 argument: rescale_z, but '%s' is not a valid rescale_z", argv[i], argv[i+1]); return FALSE; } if (scale_factor[2] == 0.0) { - fprintf(stderr, "ERROR: '%s' needs 1 argument: rescale_z, but %lf is not a valid rescale_z", argv[i], scale_factor[2]); + REprintf( "ERROR: '%s' needs 1 argument: rescale_z, but %lf is not a valid rescale_z", argv[i], scale_factor[2]); return FALSE; } set_scale_factor(scale_factor); @@ -2197,23 +2197,23 @@ BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) { if ((i+3) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: reoffset_x, reoffset_y, reoffset_z\n", argv[i]); + REprintf("ERROR: '%s' needs 3 arguments: reoffset_x, reoffset_y, reoffset_z\n", argv[i]); return FALSE; } F64 offset[3]; if (sscanf(argv[i+1], "%lf", &(offset[0])) != 1) { - fprintf(stderr, "ERROR: '%s' needs 3 arguments: reoffset_x, reoffset_y, reoffset_z, but '%s' is not a valid reoffset_x", argv[i], argv[i+1]); + REprintf( "ERROR: '%s' needs 3 arguments: reoffset_x, reoffset_y, reoffset_z, but '%s' is not a valid reoffset_x", argv[i], argv[i+1]); return FALSE; } if (sscanf(argv[i+2], "%lf", &(offset[1])) != 1) { - fprintf(stderr, "ERROR: '%s' needs 3 arguments: reoffset_x, reoffset_y, reoffset_z, but '%s' is not a valid reoffset_y", argv[i], argv[i+2]); + REprintf( "ERROR: '%s' needs 3 arguments: reoffset_x, reoffset_y, reoffset_z, but '%s' is not a valid reoffset_y", argv[i], argv[i+2]); return FALSE; } if (sscanf(argv[i+3], "%lf", &(offset[2])) != 1) { - fprintf(stderr, "ERROR: '%s' needs 3 arguments: reoffset_x, reoffset_y, reoffset_z, but '%s' is not a valid reoffset_z", argv[i], argv[i+3]); + REprintf( "ERROR: '%s' needs 3 arguments: reoffset_x, reoffset_y, reoffset_z, but '%s' is not a valid reoffset_z", argv[i], argv[i+3]); return FALSE; } set_offset(offset); @@ -2247,12 +2247,12 @@ BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: list_of_files\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: list_of_files\n", argv[i]); return FALSE; } if (!add_list_of_files(argv[i+1], unique)) { - fprintf(stderr, "ERROR: cannot load list of files '%s'\n", argv[i+1]); + REprintf( "ERROR: cannot load list of files '%s'\n", argv[i+1]); return FALSE; } *argv[i]='\0'; *argv[i+1]='\0'; i+=1; @@ -2289,7 +2289,7 @@ BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index\n", argv[i]); return FALSE; } set_files_are_flightlines_index(atoi(argv[i+1])); @@ -2305,18 +2305,18 @@ BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: buffer_size\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: buffer_size\n", argv[i]); return FALSE; } F32 buffer_size; if (sscanf(argv[i+1], "%f", &buffer_size) != 1) { - fprintf(stderr, "ERROR: '%s' needs 1 argument: buffer_size. but '%s' is not a valid buffer_size", argv[i], argv[i+1]); + REprintf( "ERROR: '%s' needs 1 argument: buffer_size. but '%s' is not a valid buffer_size", argv[i], argv[i+1]); return FALSE; } if (buffer_size <= 0.0f) { - fprintf(stderr, "ERROR: '%s' needs 1 argument: buffer_size, but %f is not valid", argv[i], buffer_size); + REprintf( "ERROR: '%s' needs 1 argument: buffer_size, but %f is not valid", argv[i], buffer_size); return FALSE; } set_buffer_size(buffer_size); @@ -2326,7 +2326,7 @@ BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: base name\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: base name\n", argv[i]); return FALSE; } temp_file_base = LASCopyString(argv[i+1]); @@ -2338,7 +2338,7 @@ BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs at least 1 argument: file_name or wild_card\n", argv[i]); + REprintf("ERROR: '%s' needs at least 1 argument: file_name or wild_card\n", argv[i]); return FALSE; } *argv[i]='\0'; @@ -2355,12 +2355,12 @@ BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs at least 1 argument: file_name\n", argv[i]); + REprintf("ERROR: '%s' needs at least 1 argument: file_name\n", argv[i]); return FALSE; } if (!add_neighbor_list_of_files(argv[i+1], unique)) { - fprintf(stderr, "ERROR: cannot load neighbor list of files '%s'\n", argv[i+1]); + REprintf( "ERROR: cannot load neighbor list of files '%s'\n", argv[i+1]); return FALSE; } *argv[i]='\0'; *argv[i+1]='\0'; i+=1; @@ -2392,12 +2392,12 @@ BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) { if (file_name_number > 1) { - fprintf(stderr, "ERROR: neighbors only supported for one buffered input file, not for %d\n", file_name_number); + REprintf( "ERROR: neighbors only supported for one buffered input file, not for %d\n", file_name_number); return FALSE; } if (buffer_size == 0.0f) { - fprintf(stderr, "ERROR: neighbors only make sense when used with '-buffered 50' or similar\n"); + REprintf( "ERROR: neighbors only make sense when used with '-buffered 50' or similar\n"); return FALSE; } } @@ -2428,7 +2428,7 @@ BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) { if (transform->filtered()) { - fprintf(stderr, "WARNING: no LAStransform specified. '-filtered_transform' has no effect.\n"); + REprintf( "WARNING: no LAStransform specified. '-filtered_transform' has no effect.\n"); } delete transform; transform = 0; @@ -2437,7 +2437,7 @@ BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) { if (filter == 0) { - fprintf(stderr, "WARNING: no LASfilter specified. '-filtered_transform' has no effect.\n"); + REprintf( "WARNING: no LASfilter specified. '-filtered_transform' has no effect.\n"); } else { @@ -2694,11 +2694,11 @@ void LASreadOpener::set_files_are_flightlines(const I32 files_are_flightlines) this->files_are_flightlines = files_are_flightlines; if (files_are_flightlines > (I32)(U16_MAX)) { - fprintf(stderr, "WARNING: files_are_flightlines start value %d is too large\n", files_are_flightlines); + REprintf( "WARNING: files_are_flightlines start value %d is too large\n", files_are_flightlines); } else if ((files_are_flightlines + files_are_flightlines_index) > (I32)(U16_MAX)) { - fprintf(stderr, "WARNING: files_are_flightlines start value %d plus index %d is too large\n", files_are_flightlines, files_are_flightlines_index); + REprintf( "WARNING: files_are_flightlines start value %d plus index %d is too large\n", files_are_flightlines, files_are_flightlines_index); } } @@ -2707,11 +2707,11 @@ void LASreadOpener::set_files_are_flightlines_index(const I32 files_are_flightli this->files_are_flightlines_index = files_are_flightlines_index-1; if (files_are_flightlines_index > (I32)(U16_MAX)) { - fprintf(stderr, "WARNING: files_are_flightlines_index index value %d is too large\n", files_are_flightlines_index); + REprintf( "WARNING: files_are_flightlines_index index value %d is too large\n", files_are_flightlines_index); } else if ((files_are_flightlines + files_are_flightlines_index) > (I32)(U16_MAX)) { - fprintf(stderr, "WARNING: files_are_flightlines start value %d plus index %d is too large\n", files_are_flightlines, files_are_flightlines_index); + REprintf( "WARNING: files_are_flightlines start value %d plus index %d is too large\n", files_are_flightlines, files_are_flightlines_index); } } @@ -2798,7 +2798,7 @@ BOOL LASreadOpener::add_file_name(const CHAR* file_name, BOOL unique) } if (file_names == 0) { - fprintf(stderr, "ERROR: alloc for file_names pointer array failed at %d\n", file_name_allocated); + REprintf( "ERROR: alloc for file_names pointer array failed at %d\n", file_name_allocated); } } file_names[file_name_number] = LASCopyString(file_name); @@ -2835,12 +2835,12 @@ BOOL LASreadOpener::add_file_name(const CHAR* file_name, U32 ID, BOOL unique) } if (file_names == 0) { - fprintf(stderr, "ERROR: alloc for file_names pointer array failed at %d\n", file_name_allocated); + REprintf( "ERROR: alloc for file_names pointer array failed at %d\n", file_name_allocated); return FALSE; } if (file_names_ID == 0) { - fprintf(stderr, "ERROR: alloc for file_names_ID array failed at %d\n", file_name_allocated); + REprintf( "ERROR: alloc for file_names_ID array failed at %d\n", file_name_allocated); return FALSE; } } @@ -2891,7 +2891,7 @@ BOOL LASreadOpener::add_file_name(const CHAR* file_name, U32 ID, I64 npoints, F6 kdtree_rectangles = new LASkdtreeRectangles(); if (kdtree_rectangles == 0) { - fprintf(stderr, "ERROR: alloc for LASkdtreeRectangles failed\n"); + REprintf( "ERROR: alloc for LASkdtreeRectangles failed\n"); return FALSE; } } @@ -2899,37 +2899,37 @@ BOOL LASreadOpener::add_file_name(const CHAR* file_name, U32 ID, I64 npoints, F6 } if (file_names == 0) { - fprintf(stderr, "ERROR: alloc for file_names pointer array failed at %d\n", file_name_allocated); + REprintf( "ERROR: alloc for file_names pointer array failed at %d\n", file_name_allocated); return FALSE; } if (file_names_ID == 0) { - fprintf(stderr, "ERROR: alloc for file_names_ID array failed at %d\n", file_name_allocated); + REprintf( "ERROR: alloc for file_names_ID array failed at %d\n", file_name_allocated); return FALSE; } if (file_names_npoints == 0) { - fprintf(stderr, "ERROR: alloc for file_names_npoints array failed at %d\n", file_name_allocated); + REprintf( "ERROR: alloc for file_names_npoints array failed at %d\n", file_name_allocated); return FALSE; } if (file_names_min_x == 0) { - fprintf(stderr, "ERROR: alloc for file_names_min_x array failed at %d\n", file_name_allocated); + REprintf( "ERROR: alloc for file_names_min_x array failed at %d\n", file_name_allocated); return FALSE; } if (file_names_min_y == 0) { - fprintf(stderr, "ERROR: alloc for file_names_min_y array failed at %d\n", file_name_allocated); + REprintf( "ERROR: alloc for file_names_min_y array failed at %d\n", file_name_allocated); return FALSE; } if (file_names_max_x == 0) { - fprintf(stderr, "ERROR: alloc for file_names_max_x array failed at %d\n", file_name_allocated); + REprintf( "ERROR: alloc for file_names_max_x array failed at %d\n", file_name_allocated); return FALSE; } if (file_names_max_y == 0) { - fprintf(stderr, "ERROR: alloc for file_names_max_y array failed at %d\n", file_name_allocated); + REprintf( "ERROR: alloc for file_names_max_y array failed at %d\n", file_name_allocated); return FALSE; } } @@ -2950,7 +2950,7 @@ BOOL LASreadOpener::add_list_of_files(const CHAR* list_of_files, BOOL unique) FILE* file = fopen(list_of_files, "r"); if (file == 0) { - fprintf(stderr, "ERROR: cannot open '%s'\n", list_of_files); + REprintf( "ERROR: cannot open '%s'\n", list_of_files); return FALSE; } CHAR line[2048]; @@ -3062,7 +3062,7 @@ BOOL LASreadOpener::add_neighbor_file_name(const CHAR* neighbor_file_name, I64 n neighbor_kdtree_rectangles = new LASkdtreeRectangles(); if (neighbor_kdtree_rectangles == 0) { - fprintf(stderr, "ERROR: alloc for neighbor LASkdtreeRectangles failed\n"); + REprintf( "ERROR: alloc for neighbor LASkdtreeRectangles failed\n"); return FALSE; } } @@ -3070,27 +3070,27 @@ BOOL LASreadOpener::add_neighbor_file_name(const CHAR* neighbor_file_name, I64 n } if (neighbor_file_names == 0) { - fprintf(stderr, "ERROR: alloc for neighbor_file_names pointer array failed at %d\n", neighbor_file_name_allocated); + REprintf( "ERROR: alloc for neighbor_file_names pointer array failed at %d\n", neighbor_file_name_allocated); return FALSE; } if (neighbor_file_names_min_x == 0) { - fprintf(stderr, "ERROR: alloc for neighbor_file_names_min_x array failed at %d\n", neighbor_file_name_allocated); + REprintf( "ERROR: alloc for neighbor_file_names_min_x array failed at %d\n", neighbor_file_name_allocated); return FALSE; } if (neighbor_file_names_min_y == 0) { - fprintf(stderr, "ERROR: alloc for neighbor_file_names_min_y array failed at %d\n", neighbor_file_name_allocated); + REprintf( "ERROR: alloc for neighbor_file_names_min_y array failed at %d\n", neighbor_file_name_allocated); return FALSE; } if (neighbor_file_names_max_x == 0) { - fprintf(stderr, "ERROR: alloc for neighbor_file_names_max_x array failed at %d\n", neighbor_file_name_allocated); + REprintf( "ERROR: alloc for neighbor_file_names_max_x array failed at %d\n", neighbor_file_name_allocated); return FALSE; } if (neighbor_file_names_max_y == 0) { - fprintf(stderr, "ERROR: alloc for neighbor_file_names_max_y array failed at %d\n", neighbor_file_name_allocated); + REprintf( "ERROR: alloc for neighbor_file_names_max_y array failed at %d\n", neighbor_file_name_allocated); return FALSE; } } @@ -3110,7 +3110,7 @@ BOOL LASreadOpener::add_neighbor_list_of_files(const CHAR* neighbor_list_of_file FILE* file = fopen(neighbor_list_of_files, "r"); if (file == 0) { - fprintf(stderr, "ERROR: cannot open '%s'\n", neighbor_list_of_files); + REprintf( "ERROR: cannot open '%s'\n", neighbor_list_of_files); return FALSE; } CHAR line[2048]; @@ -3263,7 +3263,7 @@ BOOL LASreadOpener::add_neighbor_file_name(const CHAR* neighbor_file_name, BOOL } if (neighbor_file_names == 0) { - fprintf(stderr, "ERROR: alloc for neighbor_file_names pointer array failed at %d\n", neighbor_file_name_allocated); + REprintf( "ERROR: alloc for neighbor_file_names pointer array failed at %d\n", neighbor_file_name_allocated); } } neighbor_file_names[neighbor_file_name_number] = LASCopyString(neighbor_file_name); diff --git a/src/LASlib/lasreader_asc.cpp b/src/LASlib/lasreader_asc.cpp index 615acc7..19403ab 100644 --- a/src/LASlib/lasreader_asc.cpp +++ b/src/LASlib/lasreader_asc.cpp @@ -45,7 +45,7 @@ BOOL LASreaderASC::open(const CHAR* file_name, BOOL comma_not_point) { if (file_name == 0) { - fprintf(stderr,"ERROR: file name pointer is zero\n"); + REprintf("ERROR: file name pointer is zero\n"); return FALSE; } @@ -55,13 +55,13 @@ BOOL LASreaderASC::open(const CHAR* file_name, BOOL comma_not_point) file = fopen_compressed(file_name, "r", &piped); if (file == 0) { - fprintf(stderr, "ERROR: cannot open file '%s'\n", file_name); + REprintf( "ERROR: cannot open file '%s'\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, 10*LAS_TOOLS_IO_IBUFFER_SIZE) != 0) { - fprintf(stderr, "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); + REprintf( "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); } // clean the header @@ -215,7 +215,7 @@ BOOL LASreaderASC::open(const CHAR* file_name, BOOL comma_not_point) if (!complete) { - fprintf(stderr,"ERROR: was not able to find header\n"); + REprintf("ERROR: was not able to find header\n"); return FALSE; } @@ -254,9 +254,9 @@ BOOL LASreaderASC::open(const CHAR* file_name, BOOL comma_not_point) if (!fgets(line, line_size, file)) { #ifdef _WIN32 - fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); + REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); #else - fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); + REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); #endif } @@ -311,7 +311,7 @@ BOOL LASreaderASC::open(const CHAR* file_name, BOOL comma_not_point) } else { - fprintf(stderr,"WARNING: ASC raster contains only no data values\n"); + REprintf("WARNING: ASC raster contains only no data values\n"); header.min_z = 0; header.max_z = 0; } @@ -387,9 +387,9 @@ BOOL LASreaderASC::read_point_default() if (!fgets(line, line_size, file)) { #ifdef _WIN32 - fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); + REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); #else - fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); + REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); #endif npoints = p_count; return FALSE; @@ -458,27 +458,27 @@ void LASreaderASC::close(BOOL close_stream) if (overflow_I32_x) { #ifdef _WIN32 - fprintf(stderr, "WARNING: total of %I64d integer overflows in x\n", overflow_I32_x); + REprintf( "WARNING: total of %I64d integer overflows in x\n", overflow_I32_x); #else - fprintf(stderr, "WARNING: total of %lld integer overflows in x\n", overflow_I32_x); + REprintf( "WARNING: total of %lld integer overflows in x\n", overflow_I32_x); #endif overflow_I32_x = 0; } if (overflow_I32_y) { #ifdef _WIN32 - fprintf(stderr, "WARNING: total of %I64d integer overflows in y\n", overflow_I32_y); + REprintf( "WARNING: total of %I64d integer overflows in y\n", overflow_I32_y); #else - fprintf(stderr, "WARNING: total of %lld integer overflows in y\n", overflow_I32_y); + REprintf( "WARNING: total of %lld integer overflows in y\n", overflow_I32_y); #endif overflow_I32_y = 0; } if (overflow_I32_z) { #ifdef _WIN32 - fprintf(stderr, "WARNING: total of %I64d integer overflows in z\n", overflow_I32_z); + REprintf( "WARNING: total of %I64d integer overflows in z\n", overflow_I32_z); #else - fprintf(stderr, "WARNING: total of %lld integer overflows in z\n", overflow_I32_z); + REprintf( "WARNING: total of %lld integer overflows in z\n", overflow_I32_z); #endif overflow_I32_z = 0; } @@ -494,20 +494,20 @@ BOOL LASreaderASC::reopen(const CHAR* file_name) { if (file_name == 0) { - fprintf(stderr,"ERROR: file name pointer is zero\n"); + REprintf("ERROR: file name pointer is zero\n"); return FALSE; } file = fopen_compressed(file_name, "r", &piped); if (file == 0) { - fprintf(stderr, "ERROR: cannot reopen file '%s'\n", file_name); + REprintf( "ERROR: cannot reopen file '%s'\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, 10*LAS_TOOLS_IO_IBUFFER_SIZE) != 0) { - fprintf(stderr, "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); + REprintf( "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); } // read the header lines @@ -658,8 +658,8 @@ void LASreaderASC::populate_bounding_box() if ((header.min_x > 0) != (dequant_min_x > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for min_x from %g to %g.\n", header.min_x, dequant_min_x); - fprintf(stderr, " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); + REprintf( "WARNING: quantization sign flip for min_x from %g to %g.\n", header.min_x, dequant_min_x); + REprintf( " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); } else { @@ -667,8 +667,8 @@ void LASreaderASC::populate_bounding_box() } if ((header.max_x > 0) != (dequant_max_x > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for max_x from %g to %g.\n", header.max_x, dequant_max_x); - fprintf(stderr, " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); + REprintf( "WARNING: quantization sign flip for max_x from %g to %g.\n", header.max_x, dequant_max_x); + REprintf( " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); } else { @@ -676,8 +676,8 @@ void LASreaderASC::populate_bounding_box() } if ((header.min_y > 0) != (dequant_min_y > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for min_y from %g to %g.\n", header.min_y, dequant_min_y); - fprintf(stderr, " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); + REprintf( "WARNING: quantization sign flip for min_y from %g to %g.\n", header.min_y, dequant_min_y); + REprintf( " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); } else { @@ -685,8 +685,8 @@ void LASreaderASC::populate_bounding_box() } if ((header.max_y > 0) != (dequant_max_y > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for max_y from %g to %g.\n", header.max_y, dequant_max_y); - fprintf(stderr, " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); + REprintf( "WARNING: quantization sign flip for max_y from %g to %g.\n", header.max_y, dequant_max_y); + REprintf( " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); } else { @@ -694,8 +694,8 @@ void LASreaderASC::populate_bounding_box() } if ((header.min_z > 0) != (dequant_min_z > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for min_z from %g to %g.\n", header.min_z, dequant_min_z); - fprintf(stderr, " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); + REprintf( "WARNING: quantization sign flip for min_z from %g to %g.\n", header.min_z, dequant_min_z); + REprintf( " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); } else { @@ -703,8 +703,8 @@ void LASreaderASC::populate_bounding_box() } if ((header.max_z > 0) != (dequant_max_z > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for max_z from %g to %g.\n", header.max_z, dequant_max_z); - fprintf(stderr, " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); + REprintf( "WARNING: quantization sign flip for max_z from %g to %g.\n", header.max_z, dequant_max_z); + REprintf( " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); } else { diff --git a/src/LASlib/lasreader_bil.cpp b/src/LASlib/lasreader_bil.cpp index e8298a7..c680ff5 100644 --- a/src/LASlib/lasreader_bil.cpp +++ b/src/LASlib/lasreader_bil.cpp @@ -43,7 +43,7 @@ BOOL LASreaderBIL::open(const CHAR* file_name) { if (file_name == 0) { - fprintf(stderr,"ERROR: file name pointer is zero\n"); + REprintf("ERROR: file name pointer is zero\n"); return FALSE; } @@ -55,7 +55,7 @@ BOOL LASreaderBIL::open(const CHAR* file_name) if (!read_hdr_file(file_name)) { - fprintf(stderr,"ERROR: reading the *.hdr file for '%s'\n", file_name); + REprintf("ERROR: reading the *.hdr file for '%s'\n", file_name); return FALSE; } @@ -63,7 +63,7 @@ BOOL LASreaderBIL::open(const CHAR* file_name) if (!read_blw_file(file_name)) { - fprintf(stderr,"WARNING: reading the *.blw file for '%s'\n", file_name); + REprintf("WARNING: reading the *.blw file for '%s'\n", file_name); } // check that we have all the needed info @@ -71,25 +71,25 @@ BOOL LASreaderBIL::open(const CHAR* file_name) if (xdim <= 0) { xdim = 1; - fprintf(stderr,"WARNING: xdim was not set. setting to %g\n", xdim); + REprintf("WARNING: xdim was not set. setting to %g\n", xdim); } if (ydim <= 0) { ydim = 1; - fprintf(stderr,"WARNING: ydim was not set. setting to %g\n", ydim); + REprintf("WARNING: ydim was not set. setting to %g\n", ydim); } if (ulxcenter == F64_MAX) { ulxcenter = 0.5*xdim; - fprintf(stderr,"WARNING: ulxcenter was not set. setting to %g\n", ulxcenter); + REprintf("WARNING: ulxcenter was not set. setting to %g\n", ulxcenter); } if (ulycenter == F64_MAX) { ulycenter = (-0.5+nrows)*ydim; - fprintf(stderr,"WARNING: ulycenter was not set. setting to %g\n", ulycenter); + REprintf("WARNING: ulycenter was not set. setting to %g\n", ulycenter); } // open the BIL file @@ -97,13 +97,13 @@ BOOL LASreaderBIL::open(const CHAR* file_name) file = fopen(file_name, "rb"); if (file == 0) { - fprintf(stderr, "ERROR: cannot open file '%s'\n", file_name); + REprintf( "ERROR: cannot open file '%s'\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, 2*LAS_TOOLS_IO_IBUFFER_SIZE) != 0) { - fprintf(stderr, "WARNING: setvbuf() failed with buffer size %d\n", 2*LAS_TOOLS_IO_IBUFFER_SIZE); + REprintf( "WARNING: setvbuf() failed with buffer size %d\n", 2*LAS_TOOLS_IO_IBUFFER_SIZE); } // populate the header as much as it makes sense @@ -329,7 +329,7 @@ BOOL LASreaderBIL::open(const CHAR* file_name) } else { - fprintf(stderr,"WARNING: BIL raster contains only no data values\n"); + REprintf("WARNING: BIL raster contains only no data values\n"); header.min_z = 0; header.max_z = 0; } @@ -362,7 +362,7 @@ BOOL LASreaderBIL::read_hdr_file(const CHAR* file_name) { if (file_name == 0) { - fprintf(stderr,"ERROR: file name pointer is zero\n"); + REprintf("ERROR: file name pointer is zero\n"); return FALSE; } @@ -375,7 +375,7 @@ BOOL LASreaderBIL::read_hdr_file(const CHAR* file_name) if ((len == 0) && (file_name_hdr[len] != '.')) { - fprintf(stderr,"ERROR: file name '%s' is not a valid BIL file\n", file_name); + REprintf("ERROR: file name '%s' is not a valid BIL file\n", file_name); return FALSE; } @@ -397,7 +397,7 @@ BOOL LASreaderBIL::read_hdr_file(const CHAR* file_name) if (file == 0) { file_name_hdr[len] = '\0'; - fprintf(stderr, "ERROR: cannot open files '%s.hdr' or '%s.HDR'\n", file_name_hdr, file_name_hdr); + REprintf( "ERROR: cannot open files '%s.hdr' or '%s.HDR'\n", file_name_hdr, file_name_hdr); return FALSE; } } @@ -450,12 +450,12 @@ BOOL LASreaderBIL::read_hdr_file(const CHAR* file_name) { if (strcmp(layout, "bil") && strcmp(layout, "BIL")) { - fprintf(stderr, "WARNING: %s '%s' not recognized by LASreader_bil\n", dummy, layout); + REprintf( "WARNING: %s '%s' not recognized by LASreader_bil\n", dummy, layout); } } else { - fprintf(stderr, "WARNING: argument of %s missing for LASreader_bil\n", dummy); + REprintf( "WARNING: argument of %s missing for LASreader_bil\n", dummy); } } else if (strstr(line, "pixeltype") || strstr(line, "PIXELTYPE")) @@ -472,7 +472,7 @@ BOOL LASreaderBIL::read_hdr_file(const CHAR* file_name) } else { - fprintf(stderr, "WARNING: pixeltype '%s' not recognized by LASreader_bil\n", pixeltype); + REprintf( "WARNING: pixeltype '%s' not recognized by LASreader_bil\n", pixeltype); } } else if (strstr(line, "nodata") || strstr(line, "NODATA")) @@ -485,7 +485,7 @@ BOOL LASreaderBIL::read_hdr_file(const CHAR* file_name) sscanf(line, "%s %s", dummy, byteorder); if (strcmp(byteorder, "i") && strcmp(byteorder, "I")) { - fprintf(stderr, "WARNING: byteorder '%s' not recognized by LASreader_bil\n", byteorder); + REprintf( "WARNING: byteorder '%s' not recognized by LASreader_bil\n", byteorder); } } else if (strstr(line, "ulxmap") || strstr(line, "ULXMAP")) @@ -520,11 +520,11 @@ BOOL LASreaderBIL::read_hdr_file(const CHAR* file_name) if ((ncols <= 0) || (nrows <= 0) || (nbands <= 0) || (nbits <= 0)) { - fprintf(stderr,"WARNING: not able to find all entries in HDR file\n"); - fprintf(stderr," ncols = %d\n", ncols); - fprintf(stderr," nrows = %d\n", nrows); - fprintf(stderr," nbands = %d\n", nbands); - fprintf(stderr," nbits = %d\n", nbits); + REprintf("WARNING: not able to find all entries in HDR file\n"); + REprintf(" ncols = %d\n", ncols); + REprintf(" nrows = %d\n", nrows); + REprintf(" nbands = %d\n", nbands); + REprintf(" nbits = %d\n", nbits); return FALSE; } @@ -535,7 +535,7 @@ BOOL LASreaderBIL::read_blw_file(const CHAR* file_name) { if (file_name == 0) { - fprintf(stderr,"ERROR: file name pointer is zero\n"); + REprintf("ERROR: file name pointer is zero\n"); return FALSE; } @@ -548,7 +548,7 @@ BOOL LASreaderBIL::read_blw_file(const CHAR* file_name) if ((len == 0) && (file_name_bwl[len] != '.')) { - fprintf(stderr,"ERROR: file name '%s' is not a valid BIL file\n", file_name); + REprintf("ERROR: file name '%s' is not a valid BIL file\n", file_name); return FALSE; } @@ -569,7 +569,7 @@ BOOL LASreaderBIL::read_blw_file(const CHAR* file_name) if (file == 0) { file_name_bwl[len] = '\0'; - fprintf(stderr, "WARNING: cannot open files '%s.blw' or '%s.BLW'\n", file_name_bwl, file_name_bwl); + REprintf( "WARNING: cannot open files '%s.blw' or '%s.BLW'\n", file_name_bwl, file_name_bwl); free(file_name_bwl); return FALSE; } @@ -581,36 +581,36 @@ BOOL LASreaderBIL::read_blw_file(const CHAR* file_name) if (!fgets(line, 256, file)) { - fprintf(stderr, "WARNING: corrupt world file\n"); + REprintf( "WARNING: corrupt world file\n"); return FALSE; } sscanf(line, "%f", &xdim); if (!fgets(line, 256, file)) { - fprintf(stderr, "WARNING: corrupt world file\n"); + REprintf( "WARNING: corrupt world file\n"); return FALSE; } if (!fgets(line, 256, file)) { - fprintf(stderr, "WARNING: corrupt world file\n"); + REprintf( "WARNING: corrupt world file\n"); return FALSE; } if (!fgets(line, 256, file)) { - fprintf(stderr, "WARNING: corrupt world file\n"); + REprintf( "WARNING: corrupt world file\n"); return FALSE; } sscanf(line, "%f", &ydim); ydim = -1*ydim; if (!fgets(line, 256, file)) { - fprintf(stderr, "WARNING: corrupt world file\n"); + REprintf( "WARNING: corrupt world file\n"); return FALSE; } sscanf(line, "%lf", &ulxcenter); if (!fgets(line, 256, file)) { - fprintf(stderr, "WARNING: corrupt world file\n"); + REprintf( "WARNING: corrupt world file\n"); return FALSE; } sscanf(line, "%lf", &ulycenter); @@ -676,9 +676,9 @@ BOOL LASreaderBIL::read_point_default() if (fread((void*)&elevation, 4, 1, file) != 1) { #ifdef _WIN32 - fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); + REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); #else - fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); + REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); #endif npoints = p_count; return FALSE; @@ -690,9 +690,9 @@ BOOL LASreaderBIL::read_point_default() if (fread((void*)&elev, 4, 1, file) != 1) { #ifdef _WIN32 - fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); + REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); #else - fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); + REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); #endif npoints = p_count; return FALSE; @@ -708,9 +708,9 @@ BOOL LASreaderBIL::read_point_default() if (fread((void*)&elev, 2, 1, file) != 1) { #ifdef _WIN32 - fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); + REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); #else - fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); + REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); #endif npoints = p_count; return FALSE; @@ -723,9 +723,9 @@ BOOL LASreaderBIL::read_point_default() if (fread((void*)&elev, 2, 1, file) != 1) { #ifdef _WIN32 - fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); + REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); #else - fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); + REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); #endif npoints = p_count; return FALSE; @@ -741,9 +741,9 @@ BOOL LASreaderBIL::read_point_default() if (fread((void*)rgb, 1, nbands, file) != (U32)nbands) { #ifdef _WIN32 - fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); + REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); #else - fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); + REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); #endif npoints = p_count; return FALSE; @@ -756,9 +756,9 @@ BOOL LASreaderBIL::read_point_default() if (fread((void*)rgb, 1, nbands, file) != (U32)nbands) { #ifdef _WIN32 - fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); + REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); #else - fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); + REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); #endif npoints = p_count; return FALSE; @@ -803,27 +803,27 @@ void LASreaderBIL::close(BOOL close_stream) if (overflow_I32_x) { #ifdef _WIN32 - fprintf(stderr, "WARNING: total of %I64d integer overflows in x\n", overflow_I32_x); + REprintf( "WARNING: total of %I64d integer overflows in x\n", overflow_I32_x); #else - fprintf(stderr, "WARNING: total of %lld integer overflows in x\n", overflow_I32_x); + REprintf( "WARNING: total of %lld integer overflows in x\n", overflow_I32_x); #endif overflow_I32_x = 0; } if (overflow_I32_y) { #ifdef _WIN32 - fprintf(stderr, "WARNING: total of %I64d integer overflows in y\n", overflow_I32_y); + REprintf( "WARNING: total of %I64d integer overflows in y\n", overflow_I32_y); #else - fprintf(stderr, "WARNING: total of %lld integer overflows in y\n", overflow_I32_y); + REprintf( "WARNING: total of %lld integer overflows in y\n", overflow_I32_y); #endif overflow_I32_y = 0; } if (overflow_I32_z) { #ifdef _WIN32 - fprintf(stderr, "WARNING: total of %I64d integer overflows in z\n", overflow_I32_z); + REprintf( "WARNING: total of %I64d integer overflows in z\n", overflow_I32_z); #else - fprintf(stderr, "WARNING: total of %lld integer overflows in z\n", overflow_I32_z); + REprintf( "WARNING: total of %lld integer overflows in z\n", overflow_I32_z); #endif overflow_I32_z = 0; } @@ -838,20 +838,20 @@ BOOL LASreaderBIL::reopen(const CHAR* file_name) { if (file_name == 0) { - fprintf(stderr,"ERROR: file name pointer is zero\n"); + REprintf("ERROR: file name pointer is zero\n"); return FALSE; } file = fopen(file_name, "rb"); if (file == 0) { - fprintf(stderr, "ERROR: cannot reopen file '%s'\n", file_name); + REprintf( "ERROR: cannot reopen file '%s'\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, 2*LAS_TOOLS_IO_IBUFFER_SIZE) != 0) { - fprintf(stderr, "WARNING: setvbuf() failed with buffer size %d\n", 2*LAS_TOOLS_IO_IBUFFER_SIZE); + REprintf( "WARNING: setvbuf() failed with buffer size %d\n", 2*LAS_TOOLS_IO_IBUFFER_SIZE); } col = 0; @@ -988,8 +988,8 @@ void LASreaderBIL::populate_bounding_box() if ((header.min_x > 0) != (dequant_min_x > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for min_x from %g to %g.\n", header.min_x, dequant_min_x); - fprintf(stderr, " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); + REprintf( "WARNING: quantization sign flip for min_x from %g to %g.\n", header.min_x, dequant_min_x); + REprintf( " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); } else { @@ -997,8 +997,8 @@ void LASreaderBIL::populate_bounding_box() } if ((header.max_x > 0) != (dequant_max_x > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for max_x from %g to %g.\n", header.max_x, dequant_max_x); - fprintf(stderr, " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); + REprintf( "WARNING: quantization sign flip for max_x from %g to %g.\n", header.max_x, dequant_max_x); + REprintf( " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); } else { @@ -1006,8 +1006,8 @@ void LASreaderBIL::populate_bounding_box() } if ((header.min_y > 0) != (dequant_min_y > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for min_y from %g to %g.\n", header.min_y, dequant_min_y); - fprintf(stderr, " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); + REprintf( "WARNING: quantization sign flip for min_y from %g to %g.\n", header.min_y, dequant_min_y); + REprintf( " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); } else { @@ -1015,8 +1015,8 @@ void LASreaderBIL::populate_bounding_box() } if ((header.max_y > 0) != (dequant_max_y > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for max_y from %g to %g.\n", header.max_y, dequant_max_y); - fprintf(stderr, " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); + REprintf( "WARNING: quantization sign flip for max_y from %g to %g.\n", header.max_y, dequant_max_y); + REprintf( " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); } else { @@ -1024,8 +1024,8 @@ void LASreaderBIL::populate_bounding_box() } if ((header.min_z > 0) != (dequant_min_z > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for min_z from %g to %g.\n", header.min_z, dequant_min_z); - fprintf(stderr, " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); + REprintf( "WARNING: quantization sign flip for min_z from %g to %g.\n", header.min_z, dequant_min_z); + REprintf( " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); } else { @@ -1033,8 +1033,8 @@ void LASreaderBIL::populate_bounding_box() } if ((header.max_z > 0) != (dequant_max_z > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for max_z from %g to %g.\n", header.max_z, dequant_max_z); - fprintf(stderr, " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); + REprintf( "WARNING: quantization sign flip for max_z from %g to %g.\n", header.max_z, dequant_max_z); + REprintf( " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); } else { diff --git a/src/LASlib/lasreader_bin.cpp b/src/LASlib/lasreader_bin.cpp index a8f5226..401c958 100644 --- a/src/LASlib/lasreader_bin.cpp +++ b/src/LASlib/lasreader_bin.cpp @@ -82,7 +82,7 @@ BOOL LASreaderBIN::open(const char* file_name) { if (file_name == 0) { - fprintf(stderr,"ERROR: file name pointer is zero\n"); + REprintf("ERROR: file name pointer is zero\n"); return FALSE; } @@ -91,13 +91,13 @@ BOOL LASreaderBIN::open(const char* file_name) file = fopen(file_name, "rb"); if (file == 0) { - fprintf(stderr, "ERROR: cannot open file '%s'\n", file_name); + REprintf( "ERROR: cannot open file '%s'\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, 2*LAS_TOOLS_IO_IBUFFER_SIZE) != 0) { - fprintf(stderr, "WARNING: setvbuf() failed with buffer size %d\n", 2*LAS_TOOLS_IO_IBUFFER_SIZE); + REprintf( "WARNING: setvbuf() failed with buffer size %d\n", 2*LAS_TOOLS_IO_IBUFFER_SIZE); } // create input stream @@ -138,7 +138,7 @@ BOOL LASreaderBIN::open(ByteStreamIn* stream) if (stream == 0) { - fprintf(stderr,"ERROR: ByteStreamIn* pointer is zero\n"); + REprintf("ERROR: ByteStreamIn* pointer is zero\n"); return FALSE; } @@ -149,7 +149,7 @@ BOOL LASreaderBIN::open(ByteStreamIn* stream) TSheader tsheader; try { stream->getBytes((U8*)&tsheader, sizeof(TSheader)); } catch(...) { - fprintf(stderr,"ERROR: reading terrasolid header\n"); + REprintf("ERROR: reading terrasolid header\n"); return FALSE; } @@ -157,19 +157,19 @@ BOOL LASreaderBIN::open(ByteStreamIn* stream) if (tsheader.size != sizeof(TSheader)) { - fprintf(stderr,"ERROR: corrupt terrasolid header. size != 56.\n"); + REprintf("ERROR: corrupt terrasolid header. size != 56.\n"); return FALSE; } if (tsheader.recog_val != 970401) { - fprintf(stderr,"ERROR: corrupt terrasolid header. recog_val != 979401.\n"); + REprintf("ERROR: corrupt terrasolid header. recog_val != 979401.\n"); return FALSE; } if (strncmp(tsheader.recog_str, "CXYZ", 4) != 0) { - fprintf(stderr,"ERROR: corrupt terrasolid header. recog_str != CXYZ.\n"); + REprintf("ERROR: corrupt terrasolid header. recog_str != CXYZ.\n"); return FALSE; } @@ -279,7 +279,7 @@ BOOL LASreaderBIN::read_point_default() TSpoint tspoint; try { stream->getBytes((U8*)&tspoint, sizeof(TSpoint)); } catch(...) { - fprintf(stderr,"ERROR: reading terrasolid point after %u of %u\n", (U32)p_count, (U32)npoints); + REprintf("ERROR: reading terrasolid point after %u of %u\n", (U32)p_count, (U32)npoints); return FALSE; } point.set_X(tspoint.x); @@ -295,7 +295,7 @@ BOOL LASreaderBIN::read_point_default() TSrow tsrow; try { stream->getBytes((U8*)&tsrow, sizeof(TSrow)); } catch(...) { - fprintf(stderr,"ERROR: reading terrasolid row after %u of %u\n", (U32)p_count, (U32)npoints); + REprintf("ERROR: reading terrasolid row after %u of %u\n", (U32)p_count, (U32)npoints); return FALSE; } point.set_X(tsrow.x); @@ -344,7 +344,7 @@ BOOL LASreaderBIN::read_point_default() U32 time; try { stream->getBytes((U8*)&time, sizeof(U32)); } catch(...) { - fprintf(stderr,"ERROR: reading terrasolid time\n"); + REprintf("ERROR: reading terrasolid time\n"); return FALSE; } point.gps_time = 0.0002*time; @@ -355,7 +355,7 @@ BOOL LASreaderBIN::read_point_default() U8 rgba[4]; try { stream->getBytes((U8*)rgba, sizeof(U8)*4); } catch(...) { - fprintf(stderr,"ERROR: reading terrasolid color\n"); + REprintf("ERROR: reading terrasolid color\n"); return FALSE; } point.rgb[0] = 256*rgba[0]; diff --git a/src/LASlib/lasreader_dtm.cpp b/src/LASlib/lasreader_dtm.cpp index 1a8ff17..b053d58 100644 --- a/src/LASlib/lasreader_dtm.cpp +++ b/src/LASlib/lasreader_dtm.cpp @@ -291,7 +291,7 @@ BOOL LASreaderDTM::open(const CHAR* file_name) { if (file_name == 0) { - fprintf(stderr,"ERROR: file name pointer is zero\n"); + REprintf("ERROR: file name pointer is zero\n"); return FALSE; } @@ -304,13 +304,13 @@ BOOL LASreaderDTM::open(const CHAR* file_name) file = fopen(file_name, "rb"); if (file == 0) { - fprintf(stderr, "ERROR: cannot open file '%s'\n", file_name); + REprintf( "ERROR: cannot open file '%s'\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, 2*LAS_TOOLS_IO_IBUFFER_SIZE) != 0) { - fprintf(stderr, "WARNING: setvbuf() failed with buffer size %d\n", 2*LAS_TOOLS_IO_IBUFFER_SIZE); + REprintf( "WARNING: setvbuf() failed with buffer size %d\n", 2*LAS_TOOLS_IO_IBUFFER_SIZE); } // read the 200 byte header @@ -318,7 +318,7 @@ BOOL LASreaderDTM::open(const CHAR* file_name) CHAR signature[21]; if (fread(signature, 1, 21, file) != 21) { - fprintf(stderr, "ERROR: reading 21 byte signature for '%s'\n", file_name); + REprintf( "ERROR: reading 21 byte signature for '%s'\n", file_name); return FALSE; } @@ -326,7 +326,7 @@ BOOL LASreaderDTM::open(const CHAR* file_name) if (strncmp(signature, "PLANS-PC BINARY .DTM", 21) != 0) { - fprintf(stderr, "ERROR: cannot open DTM file '%s', wrong signature '%21s'\n", file_name, signature); + REprintf( "ERROR: cannot open DTM file '%s', wrong signature '%21s'\n", file_name, signature); return FALSE; } @@ -335,7 +335,7 @@ BOOL LASreaderDTM::open(const CHAR* file_name) CHAR description[61]; if (fread(description, 1, 61, file) != 61) { - fprintf(stderr, "ERROR: reading 61 byte description for '%s'\n", file_name); + REprintf( "ERROR: reading 61 byte description for '%s'\n", file_name); return FALSE; } @@ -344,7 +344,7 @@ BOOL LASreaderDTM::open(const CHAR* file_name) F32 version; if (fread(&version, 4, 1, file) != 1) { - fprintf(stderr, "ERROR: reading 4 byte version for '%s'\n", file_name); + REprintf( "ERROR: reading 4 byte version for '%s'\n", file_name); return FALSE; } @@ -352,7 +352,7 @@ BOOL LASreaderDTM::open(const CHAR* file_name) if (version != 3.1f) { - fprintf(stderr, "WARNING: expected 3.1 but version is %1.1f\n", version); + REprintf( "WARNING: expected 3.1 but version is %1.1f\n", version); } // read lower left x @@ -392,7 +392,7 @@ BOOL LASreaderDTM::open(const CHAR* file_name) if (rotation != 0.0) { - fprintf(stderr, "WARNING: expected 0.0 but rotation is %g\n", rotation); + REprintf( "WARNING: expected 0.0 but rotation is %g\n", rotation); } F64 column_spacing; @@ -428,43 +428,43 @@ BOOL LASreaderDTM::open(const CHAR* file_name) if (fread(&horizontal_units, 2, 1, file) != 1) { - fprintf(stderr, "ERROR: reading 2 byte horizontal_units for '%s'\n", file_name); + REprintf( "ERROR: reading 2 byte horizontal_units for '%s'\n", file_name); return FALSE; } if (fread(&vertical_units, 2, 1, file) != 1) { - fprintf(stderr, "ERROR: reading 2 byte vertical_units for '%s'\n", file_name); + REprintf( "ERROR: reading 2 byte vertical_units for '%s'\n", file_name); return FALSE; } if (fread(&data_type, 2, 1, file) != 1) { - fprintf(stderr, "ERROR: reading 2 byte data_type for '%s'\n", file_name); + REprintf( "ERROR: reading 2 byte data_type for '%s'\n", file_name); return FALSE; } if (fread(&coordinate_system, 2, 1, file) != 1) { - fprintf(stderr, "ERROR: reading 2 byte horizontal_units for '%s'\n", file_name); + REprintf( "ERROR: reading 2 byte horizontal_units for '%s'\n", file_name); return FALSE; } if (fread(&coordinate_zone, 2, 1, file) != 1) { - fprintf(stderr, "ERROR: reading 2 byte coordinate_zone for '%s'\n", file_name); + REprintf( "ERROR: reading 2 byte coordinate_zone for '%s'\n", file_name); return FALSE; } if (fread(&horizontal_datum, 2, 1, file) != 1) { - fprintf(stderr, "ERROR: reading 2 byte horizontal_datum for '%s'\n", file_name); + REprintf( "ERROR: reading 2 byte horizontal_datum for '%s'\n", file_name); return FALSE; } if (fread(&vertical_datum, 2, 1, file) != 1) { - fprintf(stderr, "ERROR: reading 2 byte vertical_datum for '%s'\n", file_name); + REprintf( "ERROR: reading 2 byte vertical_datum for '%s'\n", file_name); return FALSE; } @@ -483,7 +483,7 @@ BOOL LASreaderDTM::open(const CHAR* file_name) } else { - fprintf(stderr, "UTM zone %d for NAD27 out-of-range\n", (int)coordinate_zone); + REprintf( "UTM zone %d for NAD27 out-of-range\n", (int)coordinate_zone); } } else if (horizontal_datum == 2) // GEO_DATUM_NAD83 @@ -498,7 +498,7 @@ BOOL LASreaderDTM::open(const CHAR* file_name) } else { - fprintf(stderr, "UTM zone %d for NAD83 out-of-range\n", (int)coordinate_zone); + REprintf( "UTM zone %d for NAD83 out-of-range\n", (int)coordinate_zone); } } else if (horizontal_datum == 3) // GEO_DATUM_WGS84 @@ -904,7 +904,7 @@ BOOL LASreaderDTM::open(const CHAR* file_name) geokey = PCS_NAD83_Puerto_Rico; break; default: - fprintf(stderr, "state plane NAD83 zone %d not implemented\n", (int)coordinate_zone); + REprintf( "state plane NAD83 zone %d not implemented\n", (int)coordinate_zone); } } @@ -984,14 +984,14 @@ BOOL LASreaderDTM::open(const CHAR* file_name) if (xdim <= 0) { - fprintf(stderr,"WARNING: xdim was %g. setting to 1.0\n", xdim); + REprintf("WARNING: xdim was %g. setting to 1.0\n", xdim); xdim = 1; } if (ydim <= 0) { ydim = 1; - fprintf(stderr,"WARNING: ydim was %g. setting to 1.0\n", ydim); + REprintf("WARNING: ydim was %g. setting to 1.0\n", ydim); } // populate the header as much as it makes sense @@ -1136,7 +1136,7 @@ BOOL LASreaderDTM::open(const CHAR* file_name) } else { - fprintf(stderr,"ERROR: unknown data type %d\n", (I32)data_type); + REprintf("ERROR: unknown data type %d\n", (I32)data_type); return FALSE; } @@ -1156,7 +1156,7 @@ BOOL LASreaderDTM::open(const CHAR* file_name) } else { - fprintf(stderr,"WARNING: DTM raster contains only no data values\n"); + REprintf("WARNING: DTM raster contains only no data values\n"); header.min_z = 0; header.max_z = 0; } @@ -1239,9 +1239,9 @@ BOOL LASreaderDTM::read_point_default() if (fread((void*)&elevation, 4, 1, file) != 1) { #ifdef _WIN32 - fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); + REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); #else - fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); + REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); #endif npoints = p_count; return FALSE; @@ -1253,9 +1253,9 @@ BOOL LASreaderDTM::read_point_default() if (fread((void*)&elev, 4, 1, file) != 1) { #ifdef _WIN32 - fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); + REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); #else - fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); + REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); #endif npoints = p_count; return FALSE; @@ -1268,9 +1268,9 @@ BOOL LASreaderDTM::read_point_default() if (fread((void*)&elev, 2, 1, file) != 1) { #ifdef _WIN32 - fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); + REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); #else - fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); + REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); #endif npoints = p_count; return FALSE; @@ -1283,9 +1283,9 @@ BOOL LASreaderDTM::read_point_default() if (fread((void*)&elev, 8, 1, file) != 1) { #ifdef _WIN32 - fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); + REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %I64d points\n", row, nrows, col, ncols, p_count); #else - fprintf(stderr,"WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); + REprintf("WARNING: end-of-file after %d of %d rows and %d of %d cols. read %lld points\n", row, nrows, col, ncols, p_count); #endif npoints = p_count; return FALSE; @@ -1294,7 +1294,7 @@ BOOL LASreaderDTM::read_point_default() } else { - fprintf(stderr,"ERROR: unknown data type %d\n", (I32)data_type); + REprintf("ERROR: unknown data type %d\n", (I32)data_type); return FALSE; } @@ -1334,27 +1334,27 @@ void LASreaderDTM::close(BOOL close_stream) if (overflow_I32_x) { #ifdef _WIN32 - fprintf(stderr, "WARNING: total of %I64d integer overflows in x\n", overflow_I32_x); + REprintf( "WARNING: total of %I64d integer overflows in x\n", overflow_I32_x); #else - fprintf(stderr, "WARNING: total of %lld integer overflows in x\n", overflow_I32_x); + REprintf( "WARNING: total of %lld integer overflows in x\n", overflow_I32_x); #endif overflow_I32_x = 0; } if (overflow_I32_y) { #ifdef _WIN32 - fprintf(stderr, "WARNING: total of %I64d integer overflows in y\n", overflow_I32_y); + REprintf( "WARNING: total of %I64d integer overflows in y\n", overflow_I32_y); #else - fprintf(stderr, "WARNING: total of %lld integer overflows in y\n", overflow_I32_y); + REprintf( "WARNING: total of %lld integer overflows in y\n", overflow_I32_y); #endif overflow_I32_y = 0; } if (overflow_I32_z) { #ifdef _WIN32 - fprintf(stderr, "WARNING: total of %I64d integer overflows in z\n", overflow_I32_z); + REprintf( "WARNING: total of %I64d integer overflows in z\n", overflow_I32_z); #else - fprintf(stderr, "WARNING: total of %lld integer overflows in z\n", overflow_I32_z); + REprintf( "WARNING: total of %lld integer overflows in z\n", overflow_I32_z); #endif overflow_I32_z = 0; } @@ -1369,7 +1369,7 @@ BOOL LASreaderDTM::reopen(const CHAR* file_name) { if (file_name == 0) { - fprintf(stderr,"ERROR: file name pointer is zero\n"); + REprintf("ERROR: file name pointer is zero\n"); return FALSE; } @@ -1384,13 +1384,13 @@ BOOL LASreaderDTM::reopen(const CHAR* file_name) file = fopen(file_name, "rb"); if (file == 0) { - fprintf(stderr, "ERROR: cannot reopen file '%s'\n", file_name); + REprintf( "ERROR: cannot reopen file '%s'\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, 2*LAS_TOOLS_IO_IBUFFER_SIZE) != 0) { - fprintf(stderr, "WARNING: setvbuf() failed with buffer size %d\n", 2*LAS_TOOLS_IO_IBUFFER_SIZE); + REprintf( "WARNING: setvbuf() failed with buffer size %d\n", 2*LAS_TOOLS_IO_IBUFFER_SIZE); } col = 0; @@ -1518,8 +1518,8 @@ void LASreaderDTM::populate_bounding_box() if ((header.min_x > 0) != (dequant_min_x > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for min_x from %g to %g.\n", header.min_x, dequant_min_x); - fprintf(stderr, " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); + REprintf( "WARNING: quantization sign flip for min_x from %g to %g.\n", header.min_x, dequant_min_x); + REprintf( " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); } else { @@ -1527,8 +1527,8 @@ void LASreaderDTM::populate_bounding_box() } if ((header.max_x > 0) != (dequant_max_x > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for max_x from %g to %g.\n", header.max_x, dequant_max_x); - fprintf(stderr, " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); + REprintf( "WARNING: quantization sign flip for max_x from %g to %g.\n", header.max_x, dequant_max_x); + REprintf( " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); } else { @@ -1536,8 +1536,8 @@ void LASreaderDTM::populate_bounding_box() } if ((header.min_y > 0) != (dequant_min_y > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for min_y from %g to %g.\n", header.min_y, dequant_min_y); - fprintf(stderr, " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); + REprintf( "WARNING: quantization sign flip for min_y from %g to %g.\n", header.min_y, dequant_min_y); + REprintf( " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); } else { @@ -1545,8 +1545,8 @@ void LASreaderDTM::populate_bounding_box() } if ((header.max_y > 0) != (dequant_max_y > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for max_y from %g to %g.\n", header.max_y, dequant_max_y); - fprintf(stderr, " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); + REprintf( "WARNING: quantization sign flip for max_y from %g to %g.\n", header.max_y, dequant_max_y); + REprintf( " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); } else { @@ -1554,8 +1554,8 @@ void LASreaderDTM::populate_bounding_box() } if ((header.min_z > 0) != (dequant_min_z > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for min_z from %g to %g.\n", header.min_z, dequant_min_z); - fprintf(stderr, " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); + REprintf( "WARNING: quantization sign flip for min_z from %g to %g.\n", header.min_z, dequant_min_z); + REprintf( " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); } else { @@ -1563,8 +1563,8 @@ void LASreaderDTM::populate_bounding_box() } if ((header.max_z > 0) != (dequant_max_z > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for max_z from %g to %g.\n", header.max_z, dequant_max_z); - fprintf(stderr, " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); + REprintf( "WARNING: quantization sign flip for max_z from %g to %g.\n", header.max_z, dequant_max_z); + REprintf( " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); } else { diff --git a/src/LASlib/lasreader_las.cpp b/src/LASlib/lasreader_las.cpp index be76a41..a3f43fb 100644 --- a/src/LASlib/lasreader_las.cpp +++ b/src/LASlib/lasreader_las.cpp @@ -48,7 +48,7 @@ BOOL LASreaderLAS::open(const char* file_name, I32 io_buffer_size, BOOL peek_onl { if (file_name == 0) { - fprintf(stderr,"ERROR: file name pointer is zero\n"); + REprintf("ERROR: file name pointer is zero\n"); return FALSE; } @@ -60,7 +60,7 @@ BOOL LASreaderLAS::open(const char* file_name, I32 io_buffer_size, BOOL peek_onl file = _wfopen(utf16_file_name, L"rb"); if (file == 0) { - fprintf(stderr, "ERROR: cannot open file '%ws' for read\n", utf16_file_name); + REprintf( "ERROR: cannot open file '%ws' for read\n", utf16_file_name); } delete [] utf16_file_name; } @@ -70,7 +70,7 @@ BOOL LASreaderLAS::open(const char* file_name, I32 io_buffer_size, BOOL peek_onl if (file == 0) { - fprintf(stderr, "ERROR: cannot open file '%s' for read\n", file_name); + REprintf( "ERROR: cannot open file '%s' for read\n", file_name); return FALSE; } @@ -85,7 +85,7 @@ BOOL LASreaderLAS::open(const char* file_name, I32 io_buffer_size, BOOL peek_onl if (setvbuf(file, NULL, _IOFBF, io_buffer_size) != 0) { - fprintf(stderr, "WARNING: setvbuf() failed with buffer size %d\n", io_buffer_size); + REprintf( "WARNING: setvbuf() failed with buffer size %d\n", io_buffer_size); } // create input @@ -102,7 +102,7 @@ BOOL LASreaderLAS::open(FILE* file, BOOL peek_only, U32 decompress_selective) { if (file == 0) { - fprintf(stderr,"ERROR: file pointer is zero\n"); + REprintf("ERROR: file pointer is zero\n"); return FALSE; } @@ -111,7 +111,7 @@ BOOL LASreaderLAS::open(FILE* file, BOOL peek_only, U32 decompress_selective) { if(_setmode( _fileno( stdin ), _O_BINARY ) == -1 ) { - fprintf(stderr, "ERROR: cannot set stdin to binary (untranslated) mode\n"); + REprintf( "ERROR: cannot set stdin to binary (untranslated) mode\n"); return FALSE; } } @@ -145,7 +145,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel if (stream == 0) { - fprintf(stderr,"ERROR: ByteStreamIn* pointer is zero\n"); + REprintf("ERROR: ByteStreamIn* pointer is zero\n"); return FALSE; } @@ -159,165 +159,165 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel try { stream->getBytes((U8*)header.file_signature, 4); } catch(...) { - fprintf(stderr,"ERROR: reading header.file_signature\n"); + REprintf("ERROR: reading header.file_signature\n"); return FALSE; } try { stream->get16bitsLE((U8*)&(header.file_source_ID)); } catch(...) { - fprintf(stderr,"ERROR: reading header.file_source_ID\n"); + REprintf("ERROR: reading header.file_source_ID\n"); return FALSE; } try { stream->get16bitsLE((U8*)&(header.global_encoding)); } catch(...) { - fprintf(stderr,"ERROR: reading header.global_encoding\n"); + REprintf("ERROR: reading header.global_encoding\n"); return FALSE; } try { stream->get32bitsLE((U8*)&(header.project_ID_GUID_data_1)); } catch(...) { - fprintf(stderr,"ERROR: reading header.project_ID_GUID_data_1\n"); + REprintf("ERROR: reading header.project_ID_GUID_data_1\n"); return FALSE; } try { stream->get16bitsLE((U8*)&(header.project_ID_GUID_data_2)); } catch(...) { - fprintf(stderr,"ERROR: reading header.project_ID_GUID_data_2\n"); + REprintf("ERROR: reading header.project_ID_GUID_data_2\n"); return FALSE; } try { stream->get16bitsLE((U8*)&(header.project_ID_GUID_data_3)); } catch(...) { - fprintf(stderr,"ERROR: reading header.project_ID_GUID_data_3\n"); + REprintf("ERROR: reading header.project_ID_GUID_data_3\n"); return FALSE; } try { stream->getBytes((U8*)header.project_ID_GUID_data_4, 8); } catch(...) { - fprintf(stderr,"ERROR: reading header.project_ID_GUID_data_4\n"); + REprintf("ERROR: reading header.project_ID_GUID_data_4\n"); return FALSE; } try { stream->getBytes((U8*)&(header.version_major), 1); } catch(...) { - fprintf(stderr,"ERROR: reading header.version_major\n"); + REprintf("ERROR: reading header.version_major\n"); return FALSE; } try { stream->getBytes((U8*)&(header.version_minor), 1); } catch(...) { - fprintf(stderr,"ERROR: reading header.version_minor\n"); + REprintf("ERROR: reading header.version_minor\n"); return FALSE; } try { stream->getBytes((U8*)header.system_identifier, 32); } catch(...) { - fprintf(stderr,"ERROR: reading header.system_identifier\n"); + REprintf("ERROR: reading header.system_identifier\n"); return FALSE; } try { stream->getBytes((U8*)header.generating_software, 32); } catch(...) { - fprintf(stderr,"ERROR: reading header.generating_software\n"); + REprintf("ERROR: reading header.generating_software\n"); return FALSE; } try { stream->get16bitsLE((U8*)&(header.file_creation_day)); } catch(...) { - fprintf(stderr,"ERROR: reading header.file_creation_day\n"); + REprintf("ERROR: reading header.file_creation_day\n"); return FALSE; } try { stream->get16bitsLE((U8*)&(header.file_creation_year)); } catch(...) { - fprintf(stderr,"ERROR: reading header.file_creation_year\n"); + REprintf("ERROR: reading header.file_creation_year\n"); return FALSE; } try { stream->get16bitsLE((U8*)&(header.header_size)); } catch(...) { - fprintf(stderr,"ERROR: reading header.header_size\n"); + REprintf("ERROR: reading header.header_size\n"); return FALSE; } try { stream->get32bitsLE((U8*)&(header.offset_to_point_data)); } catch(...) { - fprintf(stderr,"ERROR: reading header.offset_to_point_data\n"); + REprintf("ERROR: reading header.offset_to_point_data\n"); return FALSE; } try { stream->get32bitsLE((U8*)&(header.number_of_variable_length_records)); } catch(...) { - fprintf(stderr,"ERROR: reading header.number_of_variable_length_records\n"); + REprintf("ERROR: reading header.number_of_variable_length_records\n"); return FALSE; } try { stream->getBytes((U8*)&(header.point_data_format), 1); } catch(...) { - fprintf(stderr,"ERROR: reading header.point_data_format\n"); + REprintf("ERROR: reading header.point_data_format\n"); return FALSE; } try { stream->get16bitsLE((U8*)&(header.point_data_record_length)); } catch(...) { - fprintf(stderr,"ERROR: reading header.point_data_record_length\n"); + REprintf("ERROR: reading header.point_data_record_length\n"); return FALSE; } try { stream->get32bitsLE((U8*)&(header.number_of_point_records)); } catch(...) { - fprintf(stderr,"ERROR: reading header.number_of_point_records\n"); + REprintf("ERROR: reading header.number_of_point_records\n"); return FALSE; } for (i = 0; i < 5; i++) { try { stream->get32bitsLE((U8*)&(header.number_of_points_by_return[i])); } catch(...) { - fprintf(stderr,"ERROR: reading header.number_of_points_by_return %d\n", i); + REprintf("ERROR: reading header.number_of_points_by_return %d\n", i); return FALSE; } } try { stream->get64bitsLE((U8*)&(header.x_scale_factor)); } catch(...) { - fprintf(stderr,"ERROR: reading header.x_scale_factor\n"); + REprintf("ERROR: reading header.x_scale_factor\n"); return FALSE; } try { stream->get64bitsLE((U8*)&(header.y_scale_factor)); } catch(...) { - fprintf(stderr,"ERROR: reading header.y_scale_factor\n"); + REprintf("ERROR: reading header.y_scale_factor\n"); return FALSE; } try { stream->get64bitsLE((U8*)&(header.z_scale_factor)); } catch(...) { - fprintf(stderr,"ERROR: reading header.z_scale_factor\n"); + REprintf("ERROR: reading header.z_scale_factor\n"); return FALSE; } try { stream->get64bitsLE((U8*)&(header.x_offset)); } catch(...) { - fprintf(stderr,"ERROR: reading header.x_offset\n"); + REprintf("ERROR: reading header.x_offset\n"); return FALSE; } try { stream->get64bitsLE((U8*)&(header.y_offset)); } catch(...) { - fprintf(stderr,"ERROR: reading header.y_offset\n"); + REprintf("ERROR: reading header.y_offset\n"); return FALSE; } try { stream->get64bitsLE((U8*)&(header.z_offset)); } catch(...) { - fprintf(stderr,"ERROR: reading header.z_offset\n"); + REprintf("ERROR: reading header.z_offset\n"); return FALSE; } try { stream->get64bitsLE((U8*)&(header.max_x)); } catch(...) { - fprintf(stderr,"ERROR: reading header.max_x\n"); + REprintf("ERROR: reading header.max_x\n"); return FALSE; } try { stream->get64bitsLE((U8*)&(header.min_x)); } catch(...) { - fprintf(stderr,"ERROR: reading header.min_x\n"); + REprintf("ERROR: reading header.min_x\n"); return FALSE; } try { stream->get64bitsLE((U8*)&(header.max_y)); } catch(...) { - fprintf(stderr,"ERROR: reading header.max_y\n"); + REprintf("ERROR: reading header.max_y\n"); return FALSE; } try { stream->get64bitsLE((U8*)&(header.min_y)); } catch(...) { - fprintf(stderr,"ERROR: reading header.min_y\n"); + REprintf("ERROR: reading header.min_y\n"); return FALSE; } try { stream->get64bitsLE((U8*)&(header.max_z)); } catch(...) { - fprintf(stderr,"ERROR: reading header.max_z\n"); + REprintf("ERROR: reading header.max_z\n"); return FALSE; } try { stream->get64bitsLE((U8*)&(header.min_z)); } catch(...) { - fprintf(stderr,"ERROR: reading header.min_z\n"); + REprintf("ERROR: reading header.min_z\n"); return FALSE; } @@ -332,14 +332,14 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (header.header_size < 235) { - fprintf(stderr,"WARNING: for LAS 1.%d header_size should at least be 235 but it is only %d\n", header.version_minor, header.header_size); + REprintf("WARNING: for LAS 1.%d header_size should at least be 235 but it is only %d\n", header.version_minor, header.header_size); header.user_data_in_header_size = header.header_size - 227; } else { try { stream->get64bitsLE((U8*)&(header.start_of_waveform_data_packet_record)); } catch(...) { - fprintf(stderr,"ERROR: reading header.start_of_waveform_data_packet_record\n"); + REprintf("ERROR: reading header.start_of_waveform_data_packet_record\n"); return FALSE; } header.user_data_in_header_size = header.header_size - 235; @@ -355,31 +355,31 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (header.header_size < 375) { - fprintf(stderr,"ERROR: for LAS 1.%d header_size should at least be 375 but it is only %d\n", header.version_minor, header.header_size); + REprintf("ERROR: for LAS 1.%d header_size should at least be 375 but it is only %d\n", header.version_minor, header.header_size); return FALSE; } else { try { stream->get64bitsLE((U8*)&(header.start_of_first_extended_variable_length_record)); } catch(...) { - fprintf(stderr,"ERROR: reading header.start_of_first_extended_variable_length_record\n"); + REprintf("ERROR: reading header.start_of_first_extended_variable_length_record\n"); return FALSE; } try { stream->get32bitsLE((U8*)&(header.number_of_extended_variable_length_records)); } catch(...) { - fprintf(stderr,"ERROR: reading header.number_of_extended_variable_length_records\n"); + REprintf("ERROR: reading header.number_of_extended_variable_length_records\n"); return FALSE; } try { stream->get64bitsLE((U8*)&(header.extended_number_of_point_records)); } catch(...) { - fprintf(stderr,"ERROR: reading header.extended_number_of_point_records\n"); + REprintf("ERROR: reading header.extended_number_of_point_records\n"); return FALSE; } for (i = 0; i < 15; i++) { try { stream->get64bitsLE((U8*)&(header.extended_number_of_points_by_return[i])); } catch(...) { - fprintf(stderr,"ERROR: reading header.extended_number_of_points_by_return[%d]\n", i); + REprintf("ERROR: reading header.extended_number_of_points_by_return[%d]\n", i); return FALSE; } } @@ -394,7 +394,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel try { stream->getBytes((U8*)header.user_data_in_header, header.user_data_in_header_size); } catch(...) { - fprintf(stderr,"ERROR: reading %d bytes of data into header.user_data_in_header\n", header.user_data_in_header_size); + REprintf("ERROR: reading %d bytes of data into header.user_data_in_header\n", header.user_data_in_header_size); return FALSE; } } @@ -423,7 +423,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel if (((int)header.offset_to_point_data - vlrs_size - header.header_size) < 54) { - fprintf(stderr,"WARNING: only %d bytes until point block after reading %d of %d vlrs. skipping remaining vlrs ...\n", (int)header.offset_to_point_data - vlrs_size - header.header_size, i, header.number_of_variable_length_records); + REprintf("WARNING: only %d bytes until point block after reading %d of %d vlrs. skipping remaining vlrs ...\n", (int)header.offset_to_point_data - vlrs_size - header.header_size, i, header.number_of_variable_length_records); header.number_of_variable_length_records = i; break; } @@ -432,28 +432,28 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel try { stream->get16bitsLE((U8*)&(header.vlrs[i].reserved)); } catch(...) { - fprintf(stderr,"ERROR: reading header.vlrs[%d].reserved\n", i); + REprintf("ERROR: reading header.vlrs[%d].reserved\n", i); return FALSE; } try { stream->getBytes((U8*)header.vlrs[i].user_id, 16); } catch(...) { - fprintf(stderr,"ERROR: reading header.vlrs[%d].user_id\n", i); + REprintf("ERROR: reading header.vlrs[%d].user_id\n", i); return FALSE; } try { stream->get16bitsLE((U8*)&(header.vlrs[i].record_id)); } catch(...) { - fprintf(stderr,"ERROR: reading header.vlrs[%d].record_id\n", i); + REprintf("ERROR: reading header.vlrs[%d].record_id\n", i); return FALSE; } try { stream->get16bitsLE((U8*)&(header.vlrs[i].record_length_after_header)); } catch(...) { - fprintf(stderr,"ERROR: reading header.vlrs[%d].record_length_after_header\n", i); + REprintf("ERROR: reading header.vlrs[%d].record_length_after_header\n", i); return FALSE; } try { stream->getBytes((U8*)header.vlrs[i].description, 32); } catch(...) { - fprintf(stderr,"ERROR: reading header.vlrs[%d].description\n", i); + REprintf("ERROR: reading header.vlrs[%d].description\n", i); return FALSE; } @@ -466,7 +466,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel /* if (header.vlrs[i].reserved != 0xAABB) { - fprintf(stderr,"WARNING: wrong header.vlrs[%d].reserved: %d != 0xAABB\n", i, header.vlrs[i].reserved); + REprintf("WARNING: wrong header.vlrs[%d].reserved: %d != 0xAABB\n", i, header.vlrs[i].reserved); } */ @@ -474,7 +474,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel if (((int)header.offset_to_point_data - vlrs_size - header.header_size) < header.vlrs[i].record_length_after_header) { - fprintf(stderr,"WARNING: only %d bytes until point block when trying to read %d bytes into header.vlrs[%d].data\n", (int)header.offset_to_point_data - vlrs_size - header.header_size, header.vlrs[i].record_length_after_header, i); + REprintf("WARNING: only %d bytes until point block when trying to read %d bytes into header.vlrs[%d].data\n", (int)header.offset_to_point_data - vlrs_size - header.header_size, header.vlrs[i].record_length_after_header, i); header.vlrs[i].record_length_after_header = (int)header.offset_to_point_data - vlrs_size - header.header_size; } @@ -504,52 +504,52 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel try { stream->get16bitsLE((U8*)&(header.laszip->compressor)); } catch(...) { - fprintf(stderr,"ERROR: reading compressor %d\n", (I32)header.laszip->compressor); + REprintf("ERROR: reading compressor %d\n", (I32)header.laszip->compressor); return FALSE; } try { stream->get16bitsLE((U8*)&(header.laszip->coder)); } catch(...) { - fprintf(stderr,"ERROR: reading coder %d\n", (I32)header.laszip->coder); + REprintf("ERROR: reading coder %d\n", (I32)header.laszip->coder); return FALSE; } try { stream->getBytes((U8*)&(header.laszip->version_major), 1); } catch(...) { - fprintf(stderr,"ERROR: reading version_major %d\n", header.laszip->version_major); + REprintf("ERROR: reading version_major %d\n", header.laszip->version_major); return FALSE; } try { stream->getBytes((U8*)&(header.laszip->version_minor), 1); } catch(...) { - fprintf(stderr,"ERROR: reading version_minor %d\n", header.laszip->version_minor); + REprintf("ERROR: reading version_minor %d\n", header.laszip->version_minor); return FALSE; } try { stream->get16bitsLE((U8*)&(header.laszip->version_revision)); } catch(...) { - fprintf(stderr,"ERROR: reading version_revision %d\n", header.laszip->version_revision); + REprintf("ERROR: reading version_revision %d\n", header.laszip->version_revision); return FALSE; } try { stream->get32bitsLE((U8*)&(header.laszip->options)); } catch(...) { - fprintf(stderr,"ERROR: reading options %d\n", (I32)header.laszip->options); + REprintf("ERROR: reading options %d\n", (I32)header.laszip->options); return FALSE; } try { stream->get32bitsLE((U8*)&(header.laszip->chunk_size)); } catch(...) { - fprintf(stderr,"ERROR: reading chunk_size %d\n", header.laszip->chunk_size); + REprintf("ERROR: reading chunk_size %d\n", header.laszip->chunk_size); return FALSE; } try { stream->get64bitsLE((U8*)&(header.laszip->number_of_special_evlrs)); } catch(...) { - fprintf(stderr,"ERROR: reading number_of_special_evlrs %d\n", (I32)header.laszip->number_of_special_evlrs); + REprintf("ERROR: reading number_of_special_evlrs %d\n", (I32)header.laszip->number_of_special_evlrs); return FALSE; } try { stream->get64bitsLE((U8*)&(header.laszip->offset_to_special_evlrs)); } catch(...) { - fprintf(stderr,"ERROR: reading offset_to_special_evlrs %d\n", (I32)header.laszip->offset_to_special_evlrs); + REprintf("ERROR: reading offset_to_special_evlrs %d\n", (I32)header.laszip->offset_to_special_evlrs); return FALSE; } try { stream->get16bitsLE((U8*)&(header.laszip->num_items)); } catch(...) { - fprintf(stderr,"ERROR: reading num_items %d\n", header.laszip->num_items); + REprintf("ERROR: reading num_items %d\n", header.laszip->num_items); return FALSE; } header.laszip->items = new LASitem[header.laszip->num_items]; @@ -558,17 +558,17 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel U16 type, size, version; try { stream->get16bitsLE((U8*)&type); } catch(...) { - fprintf(stderr,"ERROR: reading type %d of item %d\n", type, j); + REprintf("ERROR: reading type %d of item %d\n", type, j); return FALSE; } try { stream->get16bitsLE((U8*)&size); } catch(...) { - fprintf(stderr,"ERROR: reading size %d of item %d\n", size, j); + REprintf("ERROR: reading size %d of item %d\n", size, j); return FALSE; } try { stream->get16bitsLE((U8*)&version); } catch(...) { - fprintf(stderr,"ERROR: reading version %d of item %d\n", version, j); + REprintf("ERROR: reading version %d of item %d\n", version, j); return FALSE; } header.laszip->items[j].type = (LASitem::Type)type; @@ -594,43 +594,43 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { try { stream->get32bitsLE((U8*)&(header.vlr_lastiling->level)); } catch(...) { - fprintf(stderr,"ERROR: reading vlr_lastiling->level %u\n", header.vlr_lastiling->level); + REprintf("ERROR: reading vlr_lastiling->level %u\n", header.vlr_lastiling->level); return FALSE; } try { stream->get32bitsLE((U8*)&(header.vlr_lastiling->level_index)); } catch(...) { - fprintf(stderr,"ERROR: reading vlr_lastiling->level_index %u\n", header.vlr_lastiling->level_index); + REprintf("ERROR: reading vlr_lastiling->level_index %u\n", header.vlr_lastiling->level_index); return FALSE; } try { stream->get32bitsLE(((U8*)header.vlr_lastiling)+8); } catch(...) { - fprintf(stderr,"ERROR: reading vlr_lastiling->implicit_levels %u\n", header.vlr_lastiling->implicit_levels); + REprintf("ERROR: reading vlr_lastiling->implicit_levels %u\n", header.vlr_lastiling->implicit_levels); return FALSE; } try { stream->get32bitsLE((U8*)&(header.vlr_lastiling->min_x)); } catch(...) { - fprintf(stderr,"ERROR: reading vlr_lastiling->min_x %g\n", header.vlr_lastiling->min_x); + REprintf("ERROR: reading vlr_lastiling->min_x %g\n", header.vlr_lastiling->min_x); return FALSE; } try { stream->get32bitsLE((U8*)&(header.vlr_lastiling->max_x)); } catch(...) { - fprintf(stderr,"ERROR: reading vlr_lastiling->max_x %g\n", header.vlr_lastiling->max_x); + REprintf("ERROR: reading vlr_lastiling->max_x %g\n", header.vlr_lastiling->max_x); return FALSE; } try { stream->get32bitsLE((U8*)&(header.vlr_lastiling->min_y)); } catch(...) { - fprintf(stderr,"ERROR: reading vlr_lastiling->min_y %g\n", header.vlr_lastiling->min_y); + REprintf("ERROR: reading vlr_lastiling->min_y %g\n", header.vlr_lastiling->min_y); return FALSE; } try { stream->get32bitsLE((U8*)&(header.vlr_lastiling->max_y)); } catch(...) { - fprintf(stderr,"ERROR: reading vlr_lastiling->max_y %g\n", header.vlr_lastiling->max_y); + REprintf("ERROR: reading vlr_lastiling->max_y %g\n", header.vlr_lastiling->max_y); return FALSE; } } else { - fprintf(stderr,"ERROR: record_length_after_header of VLR %s (%d) is %d instead of 28\n", header.vlrs[i].user_id, header.vlrs[i].record_id, header.vlrs[i].record_length_after_header); + REprintf("ERROR: record_length_after_header of VLR %s (%d) is %d instead of 28\n", header.vlrs[i].user_id, header.vlrs[i].record_id, header.vlrs[i].record_length_after_header); return FALSE; } } @@ -645,51 +645,51 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { try { stream->get64bitsLE((U8*)&(header.vlr_lasoriginal->number_of_point_records)); } catch(...) { - fprintf(stderr,"ERROR: reading vlr_lasoriginal->number_of_point_records %u\n", (U32)header.vlr_lasoriginal->number_of_point_records); + REprintf("ERROR: reading vlr_lasoriginal->number_of_point_records %u\n", (U32)header.vlr_lasoriginal->number_of_point_records); return FALSE; } for (j = 0; j < 15; j++) { try { stream->get64bitsLE((U8*)&(header.vlr_lasoriginal->number_of_points_by_return[j])); } catch(...) { - fprintf(stderr,"ERROR: reading vlr_lasoriginal->number_of_points_by_return[%d] %u\n", j, (U32)header.vlr_lasoriginal->number_of_points_by_return[j]); + REprintf("ERROR: reading vlr_lasoriginal->number_of_points_by_return[%d] %u\n", j, (U32)header.vlr_lasoriginal->number_of_points_by_return[j]); return FALSE; } } try { stream->get64bitsLE((U8*)&(header.vlr_lasoriginal->min_x)); } catch(...) { - fprintf(stderr,"ERROR: reading vlr_lasoriginal->min_x %g\n", header.vlr_lasoriginal->min_x); + REprintf("ERROR: reading vlr_lasoriginal->min_x %g\n", header.vlr_lasoriginal->min_x); return FALSE; } try { stream->get64bitsLE((U8*)&(header.vlr_lasoriginal->max_x)); } catch(...) { - fprintf(stderr,"ERROR: reading vlr_lasoriginal->max_x %g\n", header.vlr_lasoriginal->max_x); + REprintf("ERROR: reading vlr_lasoriginal->max_x %g\n", header.vlr_lasoriginal->max_x); return FALSE; } try { stream->get64bitsLE((U8*)&(header.vlr_lasoriginal->min_y)); } catch(...) { - fprintf(stderr,"ERROR: reading vlr_lasoriginal->min_y %g\n", header.vlr_lasoriginal->min_y); + REprintf("ERROR: reading vlr_lasoriginal->min_y %g\n", header.vlr_lasoriginal->min_y); return FALSE; } try { stream->get64bitsLE((U8*)&(header.vlr_lasoriginal->max_y)); } catch(...) { - fprintf(stderr,"ERROR: reading vlr_lasoriginal->max_y %g\n", header.vlr_lasoriginal->max_y); + REprintf("ERROR: reading vlr_lasoriginal->max_y %g\n", header.vlr_lasoriginal->max_y); return FALSE; } try { stream->get64bitsLE((U8*)&(header.vlr_lasoriginal->min_z)); } catch(...) { - fprintf(stderr,"ERROR: reading vlr_lasoriginal->min_z %g\n", header.vlr_lasoriginal->min_z); + REprintf("ERROR: reading vlr_lasoriginal->min_z %g\n", header.vlr_lasoriginal->min_z); return FALSE; } try { stream->get64bitsLE((U8*)&(header.vlr_lasoriginal->max_z)); } catch(...) { - fprintf(stderr,"ERROR: reading vlr_lasoriginal->max_z %g\n", header.vlr_lasoriginal->max_z); + REprintf("ERROR: reading vlr_lasoriginal->max_z %g\n", header.vlr_lasoriginal->max_z); return FALSE; } } else { - fprintf(stderr,"ERROR: record_length_after_header of VLR %s (%d) is %d instead of 176\n", header.vlrs[i].user_id, header.vlrs[i].record_id, header.vlrs[i].record_length_after_header); + REprintf("ERROR: record_length_after_header of VLR %s (%d) is %d instead of 176\n", header.vlrs[i].user_id, header.vlrs[i].record_id, header.vlrs[i].record_length_after_header); return FALSE; } } @@ -699,7 +699,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel try { stream->getBytes(header.vlrs[i].data, header.vlrs[i].record_length_after_header); } catch(...) { - fprintf(stderr,"ERROR: reading %d bytes of data into header.vlrs[%d].data\n", header.vlrs[i].record_length_after_header, i); + REprintf("ERROR: reading %d bytes of data into header.vlrs[%d].data\n", header.vlrs[i].record_length_after_header, i); return FALSE; } } @@ -723,7 +723,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (header.vlr_geo_keys) { - fprintf(stderr,"WARNING: variable length records contain more than one GeoKeyDirectoryTag\n"); + REprintf("WARNING: variable length records contain more than one GeoKeyDirectoryTag\n"); } header.vlr_geo_keys = (LASvlr_geo_keys*)header.vlrs[i].data; @@ -731,15 +731,15 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel if (header.vlr_geo_keys->key_directory_version != 1) { - fprintf(stderr,"WARNING: wrong vlr_geo_keys->key_directory_version: %d != 1\n",header.vlr_geo_keys->key_directory_version); + REprintf("WARNING: wrong vlr_geo_keys->key_directory_version: %d != 1\n",header.vlr_geo_keys->key_directory_version); } if (header.vlr_geo_keys->key_revision != 1) { - fprintf(stderr,"WARNING: wrong vlr_geo_keys->key_revision: %d != 1\n",header.vlr_geo_keys->key_revision); + REprintf("WARNING: wrong vlr_geo_keys->key_revision: %d != 1\n",header.vlr_geo_keys->key_revision); } if (header.vlr_geo_keys->minor_revision != 0) { - fprintf(stderr,"WARNING: wrong vlr_geo_keys->minor_revision: %d != 0\n",header.vlr_geo_keys->minor_revision); + REprintf("WARNING: wrong vlr_geo_keys->minor_revision: %d != 0\n",header.vlr_geo_keys->minor_revision); } header.vlr_geo_key_entries = (LASvlr_key_entry*)&header.vlr_geo_keys[1]; } @@ -747,7 +747,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (header.vlr_geo_double_params) { - fprintf(stderr,"WARNING: variable length records contain more than one GeoDoubleParamsTag\n"); + REprintf("WARNING: variable length records contain more than one GeoDoubleParamsTag\n"); } header.vlr_geo_double_params = (F64*)header.vlrs[i].data; } @@ -755,7 +755,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (header.vlr_geo_ascii_params) { - fprintf(stderr,"WARNING: variable length records contain more than one GeoAsciiParamsTag\n"); + REprintf("WARNING: variable length records contain more than one GeoAsciiParamsTag\n"); } header.vlr_geo_ascii_params = (CHAR*)header.vlrs[i].data; } @@ -763,7 +763,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (header.vlr_geo_ogc_wkt_math) { - fprintf(stderr,"WARNING: variable length records contain more than one WKT OGC MATH TRANSFORM\n"); + REprintf("WARNING: variable length records contain more than one WKT OGC MATH TRANSFORM\n"); } header.vlr_geo_ogc_wkt_math = (CHAR*)header.vlrs[i].data; } @@ -771,18 +771,18 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (header.vlr_geo_ogc_wkt) { - fprintf(stderr,"WARNING: variable length records contain more than one WKT OGC COORDINATE SYSTEM\n"); + REprintf("WARNING: variable length records contain more than one WKT OGC COORDINATE SYSTEM\n"); } header.vlr_geo_ogc_wkt = (CHAR*)header.vlrs[i].data; } else { - fprintf(stderr,"WARNING: unknown LASF_Projection VLR with record_id %d.\n", header.vlrs[i].record_id); + REprintf("WARNING: unknown LASF_Projection VLR with record_id %d.\n", header.vlrs[i].record_id); } } else { - fprintf(stderr,"WARNING: no payload for LASF_Projection VLR with record_id %d.\n", header.vlrs[i].record_id); + REprintf("WARNING: no payload for LASF_Projection VLR with record_id %d.\n", header.vlrs[i].record_id); } } else if (strcmp(header.vlrs[i].user_id, "LASF_Spec") == 0) @@ -793,7 +793,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (header.vlr_classification) { - fprintf(stderr,"WARNING: variable length records contain more than one ClassificationLookup\n"); + REprintf("WARNING: variable length records contain more than one ClassificationLookup\n"); } header.vlr_classification = (LASvlr_classification*)header.vlrs[i].data; } @@ -810,7 +810,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (header.attributes[j].data_type > 10) { - fprintf(stderr,"WARNING: data type %d of attribute %d ('%s') is deprecated\n", header.attributes[j].data_type, j, header.attributes[j].name); + REprintf("WARNING: data type %d of attribute %d ('%s') is deprecated\n", header.attributes[j].data_type, j, header.attributes[j].name); } } } @@ -825,28 +825,28 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel } if (header.vlr_wave_packet_descr[idx]) { - fprintf(stderr,"WARNING: variable length records defines wave packet descr %d more than once\n", idx); + REprintf("WARNING: variable length records defines wave packet descr %d more than once\n", idx); } if (header.vlrs[i].record_length_after_header != 26) { - fprintf(stderr,"WARNING: variable length record payload for wave packet descr %d is %d instead of 26 bytes\n", idx, (I32)header.vlrs[i].record_length_after_header); + REprintf("WARNING: variable length record payload for wave packet descr %d is %d instead of 26 bytes\n", idx, (I32)header.vlrs[i].record_length_after_header); } header.vlr_wave_packet_descr[idx] = (LASvlr_wave_packet_descr*)header.vlrs[i].data; if ((header.vlr_wave_packet_descr[idx]->getBitsPerSample() != 8) && (header.vlr_wave_packet_descr[idx]->getBitsPerSample() != 16)) { - fprintf(stderr,"WARNING: bits per sample for wave packet descr %d is %d instead of 8 or 16\n", idx, (I32)header.vlr_wave_packet_descr[idx]->getBitsPerSample()); + REprintf("WARNING: bits per sample for wave packet descr %d is %d instead of 8 or 16\n", idx, (I32)header.vlr_wave_packet_descr[idx]->getBitsPerSample()); } if (header.vlr_wave_packet_descr[idx]->getNumberOfSamples() == 0) { - fprintf(stderr,"WARNING: number of samples for wave packet descr %d is zero\n", idx); + REprintf("WARNING: number of samples for wave packet descr %d is zero\n", idx); } if (header.vlr_wave_packet_descr[idx]->getNumberOfSamples() > 8096) { - fprintf(stderr,"WARNING: number of samples of %u for wave packet descr %d is with unusually large\n", header.vlr_wave_packet_descr[idx]->getNumberOfSamples(), idx); + REprintf("WARNING: number of samples of %u for wave packet descr %d is with unusually large\n", header.vlr_wave_packet_descr[idx]->getNumberOfSamples(), idx); } if (header.vlr_wave_packet_descr[idx]->getTemporalSpacing() == 0) { - fprintf(stderr,"WARNING: temporal spacing for wave packet descr %d is zero\n", idx); + REprintf("WARNING: temporal spacing for wave packet descr %d is zero\n", idx); } /* // fix for RiPROCESS export error @@ -862,7 +862,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel } else { - fprintf(stderr,"WARNING: no payload for LASF_Spec (not specification-conform).\n"); + REprintf("WARNING: no payload for LASF_Spec (not specification-conform).\n"); } } else if ((strcmp(header.vlrs[i].user_id, "laszip encoded") == 0) || ((strcmp(header.vlrs[i].user_id, "LAStools") == 0) && (header.vlrs[i].record_id < 2000)) || (strcmp(header.vlrs[i].user_id, "lastools tile") == 0)) @@ -885,7 +885,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel try { stream->getBytes((U8*)header.user_data_after_header, header.user_data_after_header_size); } catch(...) { - fprintf(stderr,"ERROR: reading %d bytes of data into header.user_data_after_header\n", header.user_data_after_header_size); + REprintf("ERROR: reading %d bytes of data into header.user_data_after_header\n", header.user_data_after_header_size); return FALSE; } } @@ -897,7 +897,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (!stream->isSeekable()) { - fprintf(stderr,"WARNING: LAS %d.%d file has %d EVLRs but stream is not seekable ...\n", header.version_major, header.version_minor, header.number_of_extended_variable_length_records); + REprintf("WARNING: LAS %d.%d file has %d EVLRs but stream is not seekable ...\n", header.version_major, header.version_minor, header.number_of_extended_variable_length_records); } else { @@ -916,27 +916,27 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel try { stream->get16bitsLE((U8*)&(header.evlrs[i].reserved)); } catch(...) { - fprintf(stderr,"ERROR: reading header.evlrs[%d].reserved\n", i); + REprintf("ERROR: reading header.evlrs[%d].reserved\n", i); return FALSE; } try { stream->getBytes((U8*)header.evlrs[i].user_id, 16); } catch(...) { - fprintf(stderr,"ERROR: reading header.evlrs[%d].user_id\n", i); + REprintf("ERROR: reading header.evlrs[%d].user_id\n", i); return FALSE; } try { stream->get16bitsLE((U8*)&(header.evlrs[i].record_id)); } catch(...) { - fprintf(stderr,"ERROR: reading header.evlrs[%d].record_id\n", i); + REprintf("ERROR: reading header.evlrs[%d].record_id\n", i); return FALSE; } try { stream->get64bitsLE((U8*)&(header.evlrs[i].record_length_after_header)); } catch(...) { - fprintf(stderr,"ERROR: reading header.evlrs[%d].record_length_after_header\n", i); + REprintf("ERROR: reading header.evlrs[%d].record_length_after_header\n", i); return FALSE; } try { stream->getBytes((U8*)header.evlrs[i].description, 32); } catch(...) { - fprintf(stderr,"ERROR: reading header.evlrs[%d].description\n", i); + REprintf("ERROR: reading header.evlrs[%d].description\n", i); return FALSE; } @@ -949,7 +949,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel /* if (header.evlrs[i].reserved != 0) { - fprintf(stderr,"WARNING: wrong header.evlrs[%d].reserved: %d != 0\n", i, header.evlrs[i].reserved); + REprintf("WARNING: wrong header.evlrs[%d].reserved: %d != 0\n", i, header.evlrs[i].reserved); } */ @@ -979,52 +979,52 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel try { stream->get16bitsLE((U8*)&(header.laszip->compressor)); } catch(...) { - fprintf(stderr,"ERROR: reading compressor %d\n", (I32)header.laszip->compressor); + REprintf("ERROR: reading compressor %d\n", (I32)header.laszip->compressor); return FALSE; } try { stream->get16bitsLE((U8*)&(header.laszip->coder)); } catch(...) { - fprintf(stderr,"ERROR: reading coder %d\n", (I32)header.laszip->coder); + REprintf("ERROR: reading coder %d\n", (I32)header.laszip->coder); return FALSE; } try { stream->getBytes((U8*)&(header.laszip->version_major), 1); } catch(...) { - fprintf(stderr,"ERROR: reading version_major %d\n", header.laszip->version_major); + REprintf("ERROR: reading version_major %d\n", header.laszip->version_major); return FALSE; } try { stream->getBytes((U8*)&(header.laszip->version_minor), 1); } catch(...) { - fprintf(stderr,"ERROR: reading version_minor %d\n", header.laszip->version_minor); + REprintf("ERROR: reading version_minor %d\n", header.laszip->version_minor); return FALSE; } try { stream->get16bitsLE((U8*)&(header.laszip->version_revision)); } catch(...) { - fprintf(stderr,"ERROR: reading version_revision %d\n", header.laszip->version_revision); + REprintf("ERROR: reading version_revision %d\n", header.laszip->version_revision); return FALSE; } try { stream->get32bitsLE((U8*)&(header.laszip->options)); } catch(...) { - fprintf(stderr,"ERROR: reading options %d\n", (I32)header.laszip->options); + REprintf("ERROR: reading options %d\n", (I32)header.laszip->options); return FALSE; } try { stream->get32bitsLE((U8*)&(header.laszip->chunk_size)); } catch(...) { - fprintf(stderr,"ERROR: reading chunk_size %d\n", header.laszip->chunk_size); + REprintf("ERROR: reading chunk_size %d\n", header.laszip->chunk_size); return FALSE; } try { stream->get64bitsLE((U8*)&(header.laszip->number_of_special_evlrs)); } catch(...) { - fprintf(stderr,"ERROR: reading number_of_special_evlrs %d\n", (I32)header.laszip->number_of_special_evlrs); + REprintf("ERROR: reading number_of_special_evlrs %d\n", (I32)header.laszip->number_of_special_evlrs); return FALSE; } try { stream->get64bitsLE((U8*)&(header.laszip->offset_to_special_evlrs)); } catch(...) { - fprintf(stderr,"ERROR: reading offset_to_special_evlrs %d\n", (I32)header.laszip->offset_to_special_evlrs); + REprintf("ERROR: reading offset_to_special_evlrs %d\n", (I32)header.laszip->offset_to_special_evlrs); return FALSE; } try { stream->get16bitsLE((U8*)&(header.laszip->num_items)); } catch(...) { - fprintf(stderr,"ERROR: reading num_items %d\n", header.laszip->num_items); + REprintf("ERROR: reading num_items %d\n", header.laszip->num_items); return FALSE; } header.laszip->items = new LASitem[header.laszip->num_items]; @@ -1033,17 +1033,17 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel U16 type, size, version; try { stream->get16bitsLE((U8*)&type); } catch(...) { - fprintf(stderr,"ERROR: reading type %d of item %d\n", type, j); + REprintf("ERROR: reading type %d of item %d\n", type, j); return FALSE; } try { stream->get16bitsLE((U8*)&size); } catch(...) { - fprintf(stderr,"ERROR: reading size %d of item %d\n", size, j); + REprintf("ERROR: reading size %d of item %d\n", size, j); return FALSE; } try { stream->get16bitsLE((U8*)&version); } catch(...) { - fprintf(stderr,"ERROR: reading version %d of item %d\n", version, j); + REprintf("ERROR: reading version %d of item %d\n", version, j); return FALSE; } header.laszip->items[j].type = (LASitem::Type)type; @@ -1069,43 +1069,43 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { try { stream->get32bitsLE((U8*)&(header.vlr_lastiling->level)); } catch(...) { - fprintf(stderr,"ERROR: reading vlr_lastiling->level %u\n", header.vlr_lastiling->level); + REprintf("ERROR: reading vlr_lastiling->level %u\n", header.vlr_lastiling->level); return FALSE; } try { stream->get32bitsLE((U8*)&(header.vlr_lastiling->level_index)); } catch(...) { - fprintf(stderr,"ERROR: reading vlr_lastiling->level_index %u\n", header.vlr_lastiling->level_index); + REprintf("ERROR: reading vlr_lastiling->level_index %u\n", header.vlr_lastiling->level_index); return FALSE; } try { stream->get32bitsLE(((U8*)header.vlr_lastiling)+8); } catch(...) { - fprintf(stderr,"ERROR: reading vlr_lastiling->implicit_levels %u\n", header.vlr_lastiling->implicit_levels); + REprintf("ERROR: reading vlr_lastiling->implicit_levels %u\n", header.vlr_lastiling->implicit_levels); return FALSE; } try { stream->get32bitsLE((U8*)&(header.vlr_lastiling->min_x)); } catch(...) { - fprintf(stderr,"ERROR: reading vlr_lastiling->min_x %g\n", header.vlr_lastiling->min_x); + REprintf("ERROR: reading vlr_lastiling->min_x %g\n", header.vlr_lastiling->min_x); return FALSE; } try { stream->get32bitsLE((U8*)&(header.vlr_lastiling->max_x)); } catch(...) { - fprintf(stderr,"ERROR: reading vlr_lastiling->max_x %g\n", header.vlr_lastiling->max_x); + REprintf("ERROR: reading vlr_lastiling->max_x %g\n", header.vlr_lastiling->max_x); return FALSE; } try { stream->get32bitsLE((U8*)&(header.vlr_lastiling->min_y)); } catch(...) { - fprintf(stderr,"ERROR: reading vlr_lastiling->min_y %g\n", header.vlr_lastiling->min_y); + REprintf("ERROR: reading vlr_lastiling->min_y %g\n", header.vlr_lastiling->min_y); return FALSE; } try { stream->get32bitsLE((U8*)&(header.vlr_lastiling->max_y)); } catch(...) { - fprintf(stderr,"ERROR: reading vlr_lastiling->max_y %g\n", header.vlr_lastiling->max_y); + REprintf("ERROR: reading vlr_lastiling->max_y %g\n", header.vlr_lastiling->max_y); return FALSE; } } else { - fprintf(stderr,"ERROR: record_length_after_header of EVLR %s (%d) is %u instead of 28\n", header.evlrs[i].user_id, header.evlrs[i].record_id, (U32)header.evlrs[i].record_length_after_header); + REprintf("ERROR: record_length_after_header of EVLR %s (%d) is %u instead of 28\n", header.evlrs[i].user_id, header.evlrs[i].record_id, (U32)header.evlrs[i].record_length_after_header); return FALSE; } } @@ -1115,7 +1115,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel try { stream->getBytes(header.evlrs[i].data, (U32)header.evlrs[i].record_length_after_header); } catch(...) { - fprintf(stderr,"ERROR: reading %d bytes of data into header.evlrs[%d].data\n", (I32)header.evlrs[i].record_length_after_header, i); + REprintf("ERROR: reading %d bytes of data into header.evlrs[%d].data\n", (I32)header.evlrs[i].record_length_after_header, i); return FALSE; } } @@ -1137,7 +1137,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (header.vlr_geo_keys) { - fprintf(stderr,"WARNING: extended variable length records contain more than one GeoKeyDirectoryTag\n"); + REprintf("WARNING: extended variable length records contain more than one GeoKeyDirectoryTag\n"); } header.vlr_geo_keys = (LASvlr_geo_keys*)header.evlrs[i].data; @@ -1145,15 +1145,15 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel if (header.vlr_geo_keys->key_directory_version != 1) { - fprintf(stderr,"WARNING: wrong evlr_geo_keys->key_directory_version: %d != 1\n",header.vlr_geo_keys->key_directory_version); + REprintf("WARNING: wrong evlr_geo_keys->key_directory_version: %d != 1\n",header.vlr_geo_keys->key_directory_version); } if (header.vlr_geo_keys->key_revision != 1) { - fprintf(stderr,"WARNING: wrong evlr_geo_keys->key_revision: %d != 1\n",header.vlr_geo_keys->key_revision); + REprintf("WARNING: wrong evlr_geo_keys->key_revision: %d != 1\n",header.vlr_geo_keys->key_revision); } if (header.vlr_geo_keys->minor_revision != 0) { - fprintf(stderr,"WARNING: wrong evlr_geo_keys->minor_revision: %d != 0\n",header.vlr_geo_keys->minor_revision); + REprintf("WARNING: wrong evlr_geo_keys->minor_revision: %d != 0\n",header.vlr_geo_keys->minor_revision); } header.vlr_geo_key_entries = (LASvlr_key_entry*)&header.vlr_geo_keys[1]; } @@ -1161,7 +1161,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (header.vlr_geo_double_params) { - fprintf(stderr,"WARNING: extended variable length records contain more than one GeoF64ParamsTag\n"); + REprintf("WARNING: extended variable length records contain more than one GeoF64ParamsTag\n"); } header.vlr_geo_double_params = (F64*)header.evlrs[i].data; } @@ -1169,7 +1169,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (header.vlr_geo_ascii_params) { - fprintf(stderr,"WARNING: extended variable length records contain more than one GeoAsciiParamsTag\n"); + REprintf("WARNING: extended variable length records contain more than one GeoAsciiParamsTag\n"); } header.vlr_geo_ascii_params = (CHAR*)header.evlrs[i].data; } @@ -1177,7 +1177,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (header.vlr_geo_ogc_wkt_math) { - fprintf(stderr,"WARNING: extended variable length records contain more than one WKT OGC MATH TRANSFORM\n"); + REprintf("WARNING: extended variable length records contain more than one WKT OGC MATH TRANSFORM\n"); } header.vlr_geo_ogc_wkt_math = (CHAR*)header.evlrs[i].data; } @@ -1185,13 +1185,13 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (header.vlr_geo_ogc_wkt) { - fprintf(stderr,"WARNING: extended variable length records contain more than one WKT OGC COORDINATE SYSTEM\n"); + REprintf("WARNING: extended variable length records contain more than one WKT OGC COORDINATE SYSTEM\n"); } header.vlr_geo_ogc_wkt = (CHAR*)header.evlrs[i].data; } else { - fprintf(stderr,"WARNING: unknown LASF_Projection EVLR with record_id %d.\n", header.evlrs[i].record_id); + REprintf("WARNING: unknown LASF_Projection EVLR with record_id %d.\n", header.evlrs[i].record_id); } } else if (strcmp(header.evlrs[i].user_id, "LASF_Spec") == 0) @@ -1200,7 +1200,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (header.vlr_classification) { - fprintf(stderr,"WARNING: extended variable length records contain more than one ClassificationLookup\n"); + REprintf("WARNING: extended variable length records contain more than one ClassificationLookup\n"); } header.vlr_classification = (LASvlr_classification*)header.evlrs[i].data; } @@ -1225,7 +1225,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel } if (header.vlr_wave_packet_descr[idx]) { - fprintf(stderr,"WARNING: extended variable length records defines wave packet descr %d more than once\n", idx); + REprintf("WARNING: extended variable length records defines wave packet descr %d more than once\n", idx); } header.vlr_wave_packet_descr[idx] = (LASvlr_wave_packet_descr*)header.evlrs[i].data; } @@ -1249,9 +1249,9 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (!header.laszip->check(header.point_data_record_length)) { - fprintf(stderr,"ERROR: %s\n", header.laszip->get_error()); - fprintf(stderr," please upgrade to the latest release of LAStools (with LASzip)\n"); - fprintf(stderr," or contact 'martin.isenburg@rapidlasso.com' for assistance.\n"); + REprintf("ERROR: %s\n", header.laszip->get_error()); + REprintf(" please upgrade to the latest release of LAStools (with LASzip)\n"); + REprintf(" or contact 'martin.isenburg@rapidlasso.com' for assistance.\n"); return FALSE; } } @@ -1262,8 +1262,8 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel { if (!header.laszip) { - fprintf(stderr,"ERROR: this file was compressed with an experimental version of laszip\n"); - fprintf(stderr,"ERROR: please contact 'martin.isenburg@rapidlasso.com' for assistance.\n"); + REprintf("ERROR: this file was compressed with an experimental version of laszip\n"); + REprintf("ERROR: please contact 'martin.isenburg@rapidlasso.com' for assistance.\n"); return FALSE; } header.point_data_format &= 127; @@ -1327,7 +1327,7 @@ BOOL LASreaderLAS::open(ByteStreamIn* stream, BOOL peek_only, U32 decompress_sel } catch(...) { - fprintf(stderr,"ERROR: trying to read %u internal EVLRs. ignoring ...\n", (U32)header.laszip->number_of_special_evlrs); + REprintf("ERROR: trying to read %u internal EVLRs. ignoring ...\n", (U32)header.laszip->number_of_special_evlrs); } stream->seek(here); } @@ -1372,15 +1372,15 @@ BOOL LASreaderLAS::read_point_default() { if (reader->warning()) { - fprintf(stderr,"WARNING: '%s' for '%s'\n", reader->warning(), file_name); + REprintf("WARNING: '%s' for '%s'\n", reader->warning(), file_name); } if (reader->error()) { - fprintf(stderr,"ERROR: '%s' after %u of %u points for '%s'\n", reader->error(), (U32)p_count, (U32)npoints, file_name); + REprintf("ERROR: '%s' after %u of %u points for '%s'\n", reader->error(), (U32)p_count, (U32)npoints, file_name); } else { - fprintf(stderr,"WARNING: end-of-file after %u of %u points for '%s'\n", (U32)p_count, (U32)npoints, file_name); + REprintf("WARNING: end-of-file after %u of %u points for '%s'\n", (U32)p_count, (U32)npoints, file_name); } return FALSE; } @@ -1416,12 +1416,12 @@ BOOL LASreaderLAS::read_point_default() { if (reader->check_end() == FALSE) { - fprintf(stderr,"ERROR: '%s' when reaching end of encoding\n", reader->error()); + REprintf("ERROR: '%s' when reaching end of encoding\n", reader->error()); p_count--; } if (reader->warning()) { - fprintf(stderr,"WARNING: '%s'\n", reader->warning()); + REprintf("WARNING: '%s'\n", reader->warning()); } checked_end = TRUE; } @@ -1547,14 +1547,14 @@ BOOL LASreaderLASrescale::open(ByteStreamIn* stream, BOOL peek_only, U32 decompr temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - fprintf(stderr,"WARNING: rescaling from %g to %g causes LAS integer overflow for min_x\n", orig_x_scale_factor, header.x_scale_factor); + REprintf("WARNING: rescaling from %g to %g causes LAS integer overflow for min_x\n", orig_x_scale_factor, header.x_scale_factor); } // make sure rescale does not cause integer overflow for max_x temp_f = (orig_x_scale_factor*quantizer.get_X(header.max_x))/header.x_scale_factor; temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - fprintf(stderr,"WARNING: rescaling from %g to %g causes LAS integer overflow for max_x\n", orig_x_scale_factor, header.x_scale_factor); + REprintf("WARNING: rescaling from %g to %g causes LAS integer overflow for max_x\n", orig_x_scale_factor, header.x_scale_factor); } } @@ -1565,14 +1565,14 @@ BOOL LASreaderLASrescale::open(ByteStreamIn* stream, BOOL peek_only, U32 decompr temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - fprintf(stderr,"WARNING: rescaling from %g to %g causes LAS integer overflow for min_y\n", orig_y_scale_factor, header.y_scale_factor); + REprintf("WARNING: rescaling from %g to %g causes LAS integer overflow for min_y\n", orig_y_scale_factor, header.y_scale_factor); } // make sure rescale does not cause integer overflow for max_y temp_f = (orig_y_scale_factor*quantizer.get_Y(header.max_y))/header.y_scale_factor; temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - fprintf(stderr,"WARNING: rescaling from %g to %g causes LAS integer overflow for max_y\n", orig_y_scale_factor, header.y_scale_factor); + REprintf("WARNING: rescaling from %g to %g causes LAS integer overflow for max_y\n", orig_y_scale_factor, header.y_scale_factor); } } @@ -1583,14 +1583,14 @@ BOOL LASreaderLASrescale::open(ByteStreamIn* stream, BOOL peek_only, U32 decompr temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - fprintf(stderr,"WARNING: rescaling from %g to %g causes LAS integer overflow for min_z\n", orig_z_scale_factor, header.z_scale_factor); + REprintf("WARNING: rescaling from %g to %g causes LAS integer overflow for min_z\n", orig_z_scale_factor, header.z_scale_factor); } // make sure rescale does not cause integer overflow for max_z temp_f = (orig_z_scale_factor*quantizer.get_Z(header.max_z))/header.z_scale_factor; temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - fprintf(stderr,"WARNING: rescaling from %g to %g causes LAS integer overflow for max_z\n", orig_z_scale_factor, header.z_scale_factor); + REprintf("WARNING: rescaling from %g to %g causes LAS integer overflow for max_z\n", orig_z_scale_factor, header.z_scale_factor); } } } @@ -1687,14 +1687,14 @@ BOOL LASreaderLASreoffset::open(ByteStreamIn* stream, BOOL peek_only, U32 decomp temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - fprintf(stderr,"WARNING: reoffsetting from %g to %g causes LAS integer overflow for min_x\n", orig_x_offset, header.x_offset); + REprintf("WARNING: reoffsetting from %g to %g causes LAS integer overflow for min_x\n", orig_x_offset, header.x_offset); } // make sure reoffset_x does not cause integer overflow for max_x temp_f = ((header.x_scale_factor*quantizer.get_X(header.max_x))+orig_x_offset-header.x_offset)/header.x_scale_factor; temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - fprintf(stderr,"WARNING: reoffsetting from %g to %g causes LAS integer overflow for max_x\n", orig_x_offset, header.x_offset); + REprintf("WARNING: reoffsetting from %g to %g causes LAS integer overflow for max_x\n", orig_x_offset, header.x_offset); } } @@ -1705,14 +1705,14 @@ BOOL LASreaderLASreoffset::open(ByteStreamIn* stream, BOOL peek_only, U32 decomp temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - fprintf(stderr,"WARNING: reoffsetting from %g to %g causes LAS integer overflow for min_y\n", orig_y_offset, header.y_offset); + REprintf("WARNING: reoffsetting from %g to %g causes LAS integer overflow for min_y\n", orig_y_offset, header.y_offset); } // make sure reoffset_y does not cause integer overflow for max_y temp_f = ((header.y_scale_factor*quantizer.get_Y(header.max_y))+orig_y_offset-header.y_offset)/header.y_scale_factor; temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - fprintf(stderr,"WARNING: reoffsetting from %g to %g causes LAS integer overflow for max_y\n", orig_y_offset, header.y_offset); + REprintf("WARNING: reoffsetting from %g to %g causes LAS integer overflow for max_y\n", orig_y_offset, header.y_offset); } } @@ -1723,14 +1723,14 @@ BOOL LASreaderLASreoffset::open(ByteStreamIn* stream, BOOL peek_only, U32 decomp temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - fprintf(stderr,"WARNING: reoffsetting from %g to %g causes LAS integer overflow for min_z\n", orig_z_offset, header.z_offset); + REprintf("WARNING: reoffsetting from %g to %g causes LAS integer overflow for min_z\n", orig_z_offset, header.z_offset); } // make sure rescale does not cause integer overflow for max_z temp_f = ((header.z_scale_factor*quantizer.get_Z(header.max_z))+orig_z_offset-header.z_offset)/header.z_scale_factor; temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - fprintf(stderr,"WARNING: reoffsetting from %g to %g causes LAS integer overflow for max_z\n", orig_z_offset, header.z_offset); + REprintf("WARNING: reoffsetting from %g to %g causes LAS integer overflow for max_z\n", orig_z_offset, header.z_offset); } } @@ -1843,7 +1843,7 @@ BOOL LASreaderLASrescalereoffset::open(ByteStreamIn* stream, BOOL peek_only, U32 temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - fprintf(stderr,"WARNING: rescaling from %g to %g and reoffsetting from %g to %g causes LAS integer overflow for min_x\n", orig_x_scale_factor, header.x_scale_factor, orig_x_offset, header.x_offset); + REprintf("WARNING: rescaling from %g to %g and reoffsetting from %g to %g causes LAS integer overflow for min_x\n", orig_x_scale_factor, header.x_scale_factor, orig_x_offset, header.x_offset); } // make sure rescale & reoffset do not cause integer overflow for max_x @@ -1858,7 +1858,7 @@ BOOL LASreaderLASrescalereoffset::open(ByteStreamIn* stream, BOOL peek_only, U32 temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - fprintf(stderr,"WARNING: rescaling from %g to %g and reoffsetting from %g to %g causes LAS integer overflow for max_x\n", orig_x_scale_factor, header.x_scale_factor, orig_x_offset, header.x_offset); + REprintf("WARNING: rescaling from %g to %g and reoffsetting from %g to %g causes LAS integer overflow for max_x\n", orig_x_scale_factor, header.x_scale_factor, orig_x_offset, header.x_offset); } } @@ -1876,7 +1876,7 @@ BOOL LASreaderLASrescalereoffset::open(ByteStreamIn* stream, BOOL peek_only, U32 temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - fprintf(stderr,"WARNING: rescaling from %g to %g and reoffsetting from %g to %g causes LAS integer overflow for min_y\n", orig_y_scale_factor, header.y_scale_factor, orig_y_offset, header.y_offset); + REprintf("WARNING: rescaling from %g to %g and reoffsetting from %g to %g causes LAS integer overflow for min_y\n", orig_y_scale_factor, header.y_scale_factor, orig_y_offset, header.y_offset); } // make sure rescale & reoffset do not cause integer overflow for max_y @@ -1891,7 +1891,7 @@ BOOL LASreaderLASrescalereoffset::open(ByteStreamIn* stream, BOOL peek_only, U32 temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - fprintf(stderr,"WARNING: rescaling from %g to %g and reoffsetting from %g to %g causes LAS integer overflow for max_y\n", orig_y_scale_factor, header.y_scale_factor, orig_y_offset, header.y_offset); + REprintf("WARNING: rescaling from %g to %g and reoffsetting from %g to %g causes LAS integer overflow for max_y\n", orig_y_scale_factor, header.y_scale_factor, orig_y_offset, header.y_offset); } } @@ -1909,7 +1909,7 @@ BOOL LASreaderLASrescalereoffset::open(ByteStreamIn* stream, BOOL peek_only, U32 temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - fprintf(stderr,"WARNING: rescaling from %g to %g and reoffsetting from %g to %g causes LAS integer overflow for min_z\n", orig_z_scale_factor, header.z_scale_factor, orig_z_offset, header.z_offset); + REprintf("WARNING: rescaling from %g to %g and reoffsetting from %g to %g causes LAS integer overflow for min_z\n", orig_z_scale_factor, header.z_scale_factor, orig_z_offset, header.z_offset); } // make sure rescale & reoffset do not cause integer overflow for max_z @@ -1924,7 +1924,7 @@ BOOL LASreaderLASrescalereoffset::open(ByteStreamIn* stream, BOOL peek_only, U32 temp_i = I64_QUANTIZE(temp_f); if (I32_FITS_IN_RANGE(temp_i) == FALSE) { - fprintf(stderr,"WARNING: rescaling from %g to %g and reoffsetting from %g to %g causes LAS integer overflow for max_z\n", orig_z_scale_factor, header.z_scale_factor, orig_z_offset, header.z_offset); + REprintf("WARNING: rescaling from %g to %g and reoffsetting from %g to %g causes LAS integer overflow for max_z\n", orig_z_scale_factor, header.z_scale_factor, orig_z_offset, header.z_offset); } } diff --git a/src/LASlib/lasreader_ply.cpp b/src/LASlib/lasreader_ply.cpp index 1576826..03d04da 100644 --- a/src/LASlib/lasreader_ply.cpp +++ b/src/LASlib/lasreader_ply.cpp @@ -45,20 +45,20 @@ BOOL LASreaderPLY::open(const CHAR* file_name, U8 point_type, BOOL populate_head { if (file_name == 0) { - fprintf(stderr,"ERROR: file name pointer is zero\n"); + REprintf("ERROR: file name pointer is zero\n"); return FALSE; } FILE* file = fopen_compressed(file_name, "rb", &piped); if (file == 0) { - fprintf(stderr, "ERROR: cannot open file '%s'\n", file_name); + REprintf( "ERROR: cannot open file '%s'\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, 10*LAS_TOOLS_IO_IBUFFER_SIZE) != 0) { - fprintf(stderr, "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); + REprintf( "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); } return open(file, file_name, point_type, populate_header); @@ -70,7 +70,7 @@ BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL p if (file == 0) { - fprintf(stderr,"ERROR: file pointer is zero\n"); + REprintf("ERROR: file pointer is zero\n"); return FALSE; } @@ -249,7 +249,7 @@ BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL p header.add_attribute(attribute); } catch(...) { - fprintf(stderr,"ERROR: initializing attribute %s\n", attribute_descriptions[i]); + REprintf("ERROR: initializing attribute %s\n", attribute_descriptions[i]); return FALSE; } } @@ -287,7 +287,7 @@ BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL p else { line[strlen(line)-1] = '\0'; - fprintf(stderr, "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_string); + REprintf( "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_string); } } @@ -295,7 +295,7 @@ BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL p if (!found) { - fprintf(stderr, "ERROR: could not parse any lines with '%s'\n", parse_string); + REprintf( "ERROR: could not parse any lines with '%s'\n", parse_string); fclose(file); file = 0; return FALSE; @@ -354,7 +354,7 @@ BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL p else { line[strlen(line)-1] = '\0'; - fprintf(stderr, "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_string); + REprintf( "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_string); } } } @@ -422,13 +422,13 @@ BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL p file = fopen_compressed(file_name, "rb", &piped); if (file == 0) { - fprintf(stderr, "ERROR: could not open '%s' for second pass\n", file_name); + REprintf( "ERROR: could not open '%s' for second pass\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, 10*LAS_TOOLS_IO_IBUFFER_SIZE) != 0) { - fprintf(stderr, "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); + REprintf( "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); } // set the file pointer @@ -464,7 +464,7 @@ BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL p else { line[strlen(line)-1] = '\0'; - fprintf(stderr, "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_string); + REprintf( "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_string); } } @@ -472,7 +472,7 @@ BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL p if (i != 1) { - fprintf(stderr, "ERROR: could not parse any lines with '%s'\n", parse_string); + REprintf( "ERROR: could not parse any lines with '%s'\n", parse_string); fclose(this->file); this->file = 0; free(parse_string); @@ -605,13 +605,13 @@ BOOL LASreaderPLY::seek(const I64 p_index) else { line[strlen(line)-1] = '\0'; - fprintf(stderr, "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_string); + REprintf( "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_string); } } // did we manage to parse a line if (i != 1) { - fprintf(stderr, "ERROR: could not parse any lines with '%s'\n", parse_string); + REprintf( "ERROR: could not parse any lines with '%s'\n", parse_string); fclose(file); file = 0; free(parse_string); @@ -652,7 +652,7 @@ BOOL LASreaderPLY::read_point_default() else { line[strlen(line)-1] = '\0'; - fprintf(stderr, "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_string); + REprintf( "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_string); } } else @@ -660,9 +660,9 @@ BOOL LASreaderPLY::read_point_default() if (p_count != npoints) { #ifdef _WIN32 - fprintf(stderr,"WARNING: end-of-file after %I64d of %I64d points\n", p_count, npoints); + REprintf("WARNING: end-of-file after %I64d of %I64d points\n", p_count, npoints); #else - fprintf(stderr,"WARNING: end-of-file after %lld of %lld points\n", p_count, npoints); + REprintf("WARNING: end-of-file after %lld of %lld points\n", p_count, npoints); #endif npoints = p_count; @@ -738,20 +738,20 @@ BOOL LASreaderPLY::reopen(const char* file_name) if (file_name == 0) { - fprintf(stderr,"ERROR: file name pointer is zero\n"); + REprintf("ERROR: file name pointer is zero\n"); return FALSE; } file = fopen_compressed(file_name, "r", &piped); if (file == 0) { - fprintf(stderr, "ERROR: cannot reopen file '%s'\n", file_name); + REprintf( "ERROR: cannot reopen file '%s'\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, 10*LAS_TOOLS_IO_IBUFFER_SIZE) != 0) { - fprintf(stderr, "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); + REprintf( "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); } // read the first line with full parse_string @@ -768,7 +768,7 @@ BOOL LASreaderPLY::reopen(const char* file_name) else { line[strlen(line)-1] = '\0'; - fprintf(stderr, "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_string); + REprintf( "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_string); } } @@ -776,7 +776,7 @@ BOOL LASreaderPLY::reopen(const char* file_name) if (i != 1) { - fprintf(stderr, "ERROR: could not parse any lines with '%s'\n", parse_string); + REprintf( "ERROR: could not parse any lines with '%s'\n", parse_string); fclose(file); file = 0; return FALSE; @@ -869,7 +869,7 @@ BOOL LASreaderPLY::set_attribute(I32 index, F64 value) } if (temp_i < U8_MIN || temp_i > U8_MAX) { - fprintf(stderr, "WARNING: attribute %d of type U8 is %d. clamped to [%d %d] range.\n", index, temp_i, U8_MIN, U8_MAX); + REprintf( "WARNING: attribute %d of type U8 is %d. clamped to [%d %d] range.\n", index, temp_i, U8_MIN, U8_MAX); point.set_attribute(header.attribute_starts[index], U8_CLAMP(temp_i)); } else @@ -894,7 +894,7 @@ BOOL LASreaderPLY::set_attribute(I32 index, F64 value) } if (temp_i < I8_MIN || temp_i > I8_MAX) { - fprintf(stderr, "WARNING: attribute %d of type I8 is %d. clamped to [%d %d] range.\n", index, temp_i, I8_MIN, I8_MAX); + REprintf( "WARNING: attribute %d of type I8 is %d. clamped to [%d %d] range.\n", index, temp_i, I8_MIN, I8_MAX); point.set_attribute(header.attribute_starts[index], I8_CLAMP(temp_i)); } else @@ -919,7 +919,7 @@ BOOL LASreaderPLY::set_attribute(I32 index, F64 value) } if (temp_i < U16_MIN || temp_i > U16_MAX) { - fprintf(stderr, "WARNING: attribute %d of type U16 is %d. clamped to [%d %d] range.\n", index, temp_i, U16_MIN, U16_MAX); + REprintf( "WARNING: attribute %d of type U16 is %d. clamped to [%d %d] range.\n", index, temp_i, U16_MIN, U16_MAX); point.set_attribute(header.attribute_starts[index], U16_CLAMP(temp_i)); } else @@ -944,7 +944,7 @@ BOOL LASreaderPLY::set_attribute(I32 index, F64 value) } if (temp_i < I16_MIN || temp_i > I16_MAX) { - fprintf(stderr, "WARNING: attribute %d of type I16 is %d. clamped to [%d %d] range.\n", index, temp_i, I16_MIN, I16_MAX); + REprintf( "WARNING: attribute %d of type I16 is %d. clamped to [%d %d] range.\n", index, temp_i, I16_MIN, I16_MAX); point.set_attribute(header.attribute_starts[index], I16_CLAMP(temp_i)); } else @@ -997,7 +997,7 @@ BOOL LASreaderPLY::set_attribute(I32 index, F64 value) } else { - fprintf(stderr, "WARNING: attribute %d not (yet) implemented.\n", index); + REprintf( "WARNING: attribute %d not (yet) implemented.\n", index); return FALSE; } return TRUE; @@ -1104,19 +1104,19 @@ BOOL LASreaderPLY::read_binary_point() { if (translate_intensity != 0.0f) value = value+translate_intensity; if (scale_intensity != 1.0f) value = value*scale_intensity; - if (value < 0.0 || value >= 65535.5) fprintf(stderr, "WARNING: intensity %g is out of range of unsigned short\n", value); + if (value < 0.0 || value >= 65535.5) REprintf( "WARNING: intensity %g is out of range of unsigned short\n", value); point.set_intensity(U16_QUANTIZE(value)); } else if (p[0] == 'n') // we expect the number of returns of given pulse { if (point_type > 5) { - if ((value < 0) || (value > 15)) fprintf(stderr, "WARNING: number of returns of given pulse %g is out of range of four bits\n", value); + if ((value < 0) || (value > 15)) REprintf( "WARNING: number of returns of given pulse %g is out of range of four bits\n", value); point.set_extended_number_of_returns(U8_QUANTIZE(value) & 15); } else { - if ((value < 0) || (value > 7)) fprintf(stderr, "WARNING: number of returns of given pulse %g is out of range of three bits\n", value); + if ((value < 0) || (value > 7)) REprintf( "WARNING: number of returns of given pulse %g is out of range of three bits\n", value); point.set_number_of_returns(U8_QUANTIZE(value) & 7); } } @@ -1124,12 +1124,12 @@ BOOL LASreaderPLY::read_binary_point() { if (point_type > 5) { - if ((value < 0) || (value > 15)) fprintf(stderr, "WARNING: return number %g is out of range of four bits\n", value); + if ((value < 0) || (value > 15)) REprintf( "WARNING: return number %g is out of range of four bits\n", value); point.set_extended_return_number(U8_QUANTIZE(value) & 15); } else { - if ((value < 0) || (value > 7)) fprintf(stderr, "WARNING: return number %g is out of range of three bits\n", value); + if ((value < 0) || (value > 7)) REprintf( "WARNING: return number %g is out of range of three bits\n", value); point.set_return_number(U8_QUANTIZE(value) & 7); } } @@ -1137,23 +1137,23 @@ BOOL LASreaderPLY::read_binary_point() { if (point_type > 5) { - if ((value < 0) || (value > 255)) fprintf(stderr, "WARNING: classification %g is out of range of eight bits\n", value); + if ((value < 0) || (value > 255)) REprintf( "WARNING: classification %g is out of range of eight bits\n", value); point.set_extended_classification(U8_QUANTIZE(value)); } else { - if ((value < 0) || (value > 31)) fprintf(stderr, "WARNING: classification %g is out of range of five bits\n", value); + if ((value < 0) || (value > 31)) REprintf( "WARNING: classification %g is out of range of five bits\n", value); point.set_classification(U8_QUANTIZE(value) & 31); } } else if (p[0] == 'u') // we expect the user data { - if ((value < 0) || (value > 255)) fprintf(stderr, "WARNING: user data %g is out of range of eight bits\n", value); + if ((value < 0) || (value > 255)) REprintf( "WARNING: user data %g is out of range of eight bits\n", value); point.set_user_data(U8_QUANTIZE(value)); } else if (p[0] == 'p') // we expect the point source ID { - if ((value < 0) || (value > 65535)) fprintf(stderr, "WARNING: point source ID %g is out of range of sixteen bits\n", value); + if ((value < 0) || (value > 65535)) REprintf( "WARNING: point source ID %g is out of range of sixteen bits\n", value); point.set_point_source_ID(U16_QUANTIZE(value)); } else if ((p[0] >= '0') && (p[0] <= '9')) // we expect attribute number 0 to 9 @@ -1174,7 +1174,7 @@ BOOL LASreaderPLY::read_binary_point() } else { - fprintf(stderr, "ERROR: unknown symbol '%c' in parse string\n", p[0]); + REprintf( "ERROR: unknown symbol '%c' in parse string\n", p[0]); } p++; t++; @@ -1272,7 +1272,7 @@ BOOL LASreaderPLY::parse(const char* parse_string) if (sscanf(l, "%f", &temp_f) != 1) return FALSE; if (translate_intensity != 0.0f) temp_f = temp_f+translate_intensity; if (scale_intensity != 1.0f) temp_f = temp_f*scale_intensity; - if (temp_f < 0.0f || temp_f >= 65535.5f) fprintf(stderr, "WARNING: intensity %g is out of range of unsigned short\n", temp_f); + if (temp_f < 0.0f || temp_f >= 65535.5f) REprintf( "WARNING: intensity %g is out of range of unsigned short\n", temp_f); point.set_intensity(U16_QUANTIZE(temp_f)); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1281,7 +1281,7 @@ BOOL LASreaderPLY::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%f", &temp_f) != 1) return FALSE; - if (temp_f < -128.0f || temp_f > 127.0f) fprintf(stderr, "WARNING: scan angle %g is out of range of char\n", temp_f); + if (temp_f < -128.0f || temp_f > 127.0f) REprintf( "WARNING: scan angle %g is out of range of char\n", temp_f); point.set_scan_angle(temp_f); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1292,12 +1292,12 @@ BOOL LASreaderPLY::parse(const char* parse_string) if (sscanf(l, "%d", &temp_i) != 1) return FALSE; if (point_type > 5) { - if (temp_i < 0 || temp_i > 15) fprintf(stderr, "WARNING: number of returns of given pulse %d is out of range of four bits\n", temp_i); + if (temp_i < 0 || temp_i > 15) REprintf( "WARNING: number of returns of given pulse %d is out of range of four bits\n", temp_i); point.set_extended_number_of_returns(temp_i & 15); } else { - if (temp_i < 0 || temp_i > 7) fprintf(stderr, "WARNING: number of returns of given pulse %d is out of range of three bits\n", temp_i); + if (temp_i < 0 || temp_i > 7) REprintf( "WARNING: number of returns of given pulse %d is out of range of three bits\n", temp_i); point.set_number_of_returns(temp_i & 7); } while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space @@ -1309,12 +1309,12 @@ BOOL LASreaderPLY::parse(const char* parse_string) if (sscanf(l, "%d", &temp_i) != 1) return FALSE; if (point_type > 5) { - if (temp_i < 0 || temp_i > 15) fprintf(stderr, "WARNING: return number %d is out of range of four bits\n", temp_i); + if (temp_i < 0 || temp_i > 15) REprintf( "WARNING: return number %d is out of range of four bits\n", temp_i); point.set_extended_return_number(temp_i & 15); } else { - if (temp_i < 0 || temp_i > 7) fprintf(stderr, "WARNING: return number %d is out of range of three bits\n", temp_i); + if (temp_i < 0 || temp_i > 7) REprintf( "WARNING: return number %d is out of range of three bits\n", temp_i); point.set_return_number(temp_i & 7); } while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space @@ -1324,7 +1324,7 @@ BOOL LASreaderPLY::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 1) fprintf(stderr, "WARNING: withheld flag %d is out of range of single bit\n", temp_i); + if (temp_i < 0 || temp_i > 1) REprintf( "WARNING: withheld flag %d is out of range of single bit\n", temp_i); point.set_withheld_flag(temp_i ? 1 : 0); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1333,7 +1333,7 @@ BOOL LASreaderPLY::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 1) fprintf(stderr, "WARNING: keypoint flag %d is out of range of single bit\n", temp_i); + if (temp_i < 0 || temp_i > 1) REprintf( "WARNING: keypoint flag %d is out of range of single bit\n", temp_i); point.set_keypoint_flag(temp_i ? 1 : 0); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1342,7 +1342,7 @@ BOOL LASreaderPLY::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 1) fprintf(stderr, "WARNING: keypoint flag %d is out of range of single bit\n", temp_i); + if (temp_i < 0 || temp_i > 1) REprintf( "WARNING: keypoint flag %d is out of range of single bit\n", temp_i); point.set_synthetic_flag(temp_i ? 1 : 0); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1351,7 +1351,7 @@ BOOL LASreaderPLY::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 1) fprintf(stderr, "WARNING: overlap flag %d is out of range of single bit\n", temp_i); + if (temp_i < 0 || temp_i > 1) REprintf( "WARNING: overlap flag %d is out of range of single bit\n", temp_i); point.set_extended_overlap_flag(temp_i ? 1 : 0); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1360,7 +1360,7 @@ BOOL LASreaderPLY::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 3) fprintf(stderr, "WARNING: scanner channel %d is out of range of two bits\n", temp_i); + if (temp_i < 0 || temp_i > 3) REprintf( "WARNING: scanner channel %d is out of range of two bits\n", temp_i); point.extended_scanner_channel = temp_i & 3; while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1369,7 +1369,7 @@ BOOL LASreaderPLY::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 3) fprintf(stderr, "WARNING: terrasolid echo encoding %d is out of range of 0 to 3\n", temp_i); + if (temp_i < 0 || temp_i > 3) REprintf( "WARNING: terrasolid echo encoding %d is out of range of 0 to 3\n", temp_i); if (temp_i == 0) // only echo { point.number_of_returns = 1; @@ -1399,7 +1399,7 @@ BOOL LASreaderPLY::parse(const char* parse_string) if (sscanf(l, "%d", &temp_i) != 1) return FALSE; if (temp_i < 0 || temp_i > 255) { - fprintf(stderr, "WARNING: classification %d is out of range of unsigned char\n", temp_i); + REprintf( "WARNING: classification %d is out of range of unsigned char\n", temp_i); point.set_classification(U8_CLAMP(temp_i)); } else @@ -1415,7 +1415,7 @@ BOOL LASreaderPLY::parse(const char* parse_string) if (sscanf(l, "%d", &temp_i) != 1) return FALSE; if (temp_i < 0 || temp_i > 255) { - fprintf(stderr, "WARNING: user data %d is out of range of unsigned char\n", temp_i); + REprintf( "WARNING: user data %d is out of range of unsigned char\n", temp_i); point.set_user_data(U8_CLAMP(temp_i)); } else @@ -1431,7 +1431,7 @@ BOOL LASreaderPLY::parse(const char* parse_string) if (sscanf(l, "%d", &temp_i) != 1) return FALSE; if (temp_i < 0 || temp_i > 65535) { - fprintf(stderr, "WARNING: point source ID %d is out of range of unsigned short\n", temp_i); + REprintf( "WARNING: point source ID %d is out of range of unsigned short\n", temp_i); point.set_point_source_ID(U16_CLAMP(temp_i)); } else @@ -1445,7 +1445,7 @@ BOOL LASreaderPLY::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 1) fprintf(stderr, "WARNING: edge of flight line flag %d is out of range of boolean flag\n", temp_i); + if (temp_i < 0 || temp_i > 1) REprintf( "WARNING: edge of flight line flag %d is out of range of boolean flag\n", temp_i); point.edge_of_flight_line = (temp_i ? 1 : 0); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1454,7 +1454,7 @@ BOOL LASreaderPLY::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 1) fprintf(stderr, "WARNING: direction of scan flag %d is out of range of boolean flag\n", temp_i); + if (temp_i < 0 || temp_i > 1) REprintf( "WARNING: direction of scan flag %d is out of range of boolean flag\n", temp_i); point.scan_direction_flag = (temp_i ? 1 : 0); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1510,7 +1510,7 @@ BOOL LASreaderPLY::parse(const char* parse_string) } else { - fprintf(stderr, "ERROR: unknown symbol '%c' in parse string\n", p[0]); + REprintf( "ERROR: unknown symbol '%c' in parse string\n", p[0]); } p++; } @@ -1571,7 +1571,7 @@ BOOL LASreaderPLY::parse_header(BOOL quiet) } else { - fprintf(stderr, "format: %snot implemented. contact martin@rapidlasso.com\n", &line[7]); + REprintf( "format: %snot implemented. contact martin@rapidlasso.com\n", &line[7]); return FALSE; } } @@ -1593,13 +1593,13 @@ BOOL LASreaderPLY::parse_header(BOOL quiet) if (sscanf(&line[15], "%lld", &npoints) != 1) #endif { - fprintf(stderr, "element vertex: %scannot parse number of points. contact martin@rapidlasso.com\n", &line[15]); + REprintf( "element vertex: %scannot parse number of points. contact martin@rapidlasso.com\n", &line[15]); return FALSE; } } else { - if (!quiet) fprintf(stderr, "not supported: %sskipping remaining header ...\n", line); + if (!quiet) REprintf( "not supported: %sskipping remaining header ...\n", line); skip_remaining = TRUE; continue; } @@ -1817,16 +1817,16 @@ BOOL LASreaderPLY::parse_header(BOOL quiet) } else { - fprintf(stderr, "unknown property type: %snot implemented. contact martin@rapidlasso.com\n", &line[9]); + REprintf( "unknown property type: %snot implemented. contact martin@rapidlasso.com\n", &line[9]); return FALSE; } } else { - fprintf(stderr, "unknown header item: %snot implemented. contact martin@rapidlasso.com", line); + REprintf( "unknown header item: %snot implemented. contact martin@rapidlasso.com", line); } - if (!quiet) fprintf(stderr, "parsed: %s", line); + if (!quiet) REprintf( "parsed: %s", line); } return TRUE; @@ -1898,8 +1898,8 @@ void LASreaderPLY::populate_bounding_box() if ((header.min_x > 0) != (dequant_min_x > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for min_x from %g to %g.\n", header.min_x, dequant_min_x); - fprintf(stderr, " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); + REprintf( "WARNING: quantization sign flip for min_x from %g to %g.\n", header.min_x, dequant_min_x); + REprintf( " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); } else { @@ -1907,8 +1907,8 @@ void LASreaderPLY::populate_bounding_box() } if ((header.max_x > 0) != (dequant_max_x > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for max_x from %g to %g.\n", header.max_x, dequant_max_x); - fprintf(stderr, " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); + REprintf( "WARNING: quantization sign flip for max_x from %g to %g.\n", header.max_x, dequant_max_x); + REprintf( " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); } else { @@ -1916,8 +1916,8 @@ void LASreaderPLY::populate_bounding_box() } if ((header.min_y > 0) != (dequant_min_y > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for min_y from %g to %g.\n", header.min_y, dequant_min_y); - fprintf(stderr, " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); + REprintf( "WARNING: quantization sign flip for min_y from %g to %g.\n", header.min_y, dequant_min_y); + REprintf( " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); } else { @@ -1925,8 +1925,8 @@ void LASreaderPLY::populate_bounding_box() } if ((header.max_y > 0) != (dequant_max_y > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for max_y from %g to %g.\n", header.max_y, dequant_max_y); - fprintf(stderr, " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); + REprintf( "WARNING: quantization sign flip for max_y from %g to %g.\n", header.max_y, dequant_max_y); + REprintf( " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); } else { @@ -1934,8 +1934,8 @@ void LASreaderPLY::populate_bounding_box() } if ((header.min_z > 0) != (dequant_min_z > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for min_z from %g to %g.\n", header.min_z, dequant_min_z); - fprintf(stderr, " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); + REprintf( "WARNING: quantization sign flip for min_z from %g to %g.\n", header.min_z, dequant_min_z); + REprintf( " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); } else { @@ -1943,8 +1943,8 @@ void LASreaderPLY::populate_bounding_box() } if ((header.max_z > 0) != (dequant_max_z > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for max_z from %g to %g.\n", header.max_z, dequant_max_z); - fprintf(stderr, " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); + REprintf( "WARNING: quantization sign flip for max_z from %g to %g.\n", header.max_z, dequant_max_z); + REprintf( " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); } else { diff --git a/src/LASlib/lasreader_qfit.cpp b/src/LASlib/lasreader_qfit.cpp index db14c1e..9124c42 100644 --- a/src/LASlib/lasreader_qfit.cpp +++ b/src/LASlib/lasreader_qfit.cpp @@ -44,7 +44,7 @@ BOOL LASreaderQFIT::open(const char* file_name) { if (file_name == 0) { - fprintf(stderr,"ERROR: file name pointer is zero\n"); + REprintf("ERROR: file name pointer is zero\n"); return FALSE; } @@ -53,7 +53,7 @@ BOOL LASreaderQFIT::open(const char* file_name) file = fopen(file_name, "rb"); if (file == 0) { - fprintf(stderr, "ERROR: cannot open file '%s'\n", file_name); + REprintf( "ERROR: cannot open file '%s'\n", file_name); return FALSE; } @@ -125,7 +125,7 @@ BOOL LASreaderQFIT::open(ByteStreamIn* stream) if (stream == 0) { - fprintf(stderr,"ERROR: ByteStreamIn* pointer is zero\n"); + REprintf("ERROR: ByteStreamIn* pointer is zero\n"); return FALSE; } @@ -135,7 +135,7 @@ BOOL LASreaderQFIT::open(ByteStreamIn* stream) try { stream->get32bitsLE((U8*)&version); } catch(...) { - fprintf(stderr,"ERROR: reading QFIT header\n"); + REprintf("ERROR: reading QFIT header\n"); return FALSE; } @@ -156,7 +156,7 @@ BOOL LASreaderQFIT::open(ByteStreamIn* stream) } else { - fprintf(stderr,"ERROR: corrupt QFIT header.\n"); + REprintf("ERROR: corrupt QFIT header.\n"); return FALSE; } } @@ -165,7 +165,7 @@ BOOL LASreaderQFIT::open(ByteStreamIn* stream) try { stream->getBytes((U8*)buffer, version); } catch(...) { - fprintf(stderr,"ERROR: reading %d bytes until point start offset from QFIT header\n", version); + REprintf("ERROR: reading %d bytes until point start offset from QFIT header\n", version); return FALSE; } @@ -173,7 +173,7 @@ BOOL LASreaderQFIT::open(ByteStreamIn* stream) try { if (little_endian) stream->get32bitsLE((U8*)&offset); else stream->get32bitsBE((U8*)&offset); } catch(...) { - fprintf(stderr,"ERROR: reading point start offset from QFIT header\n"); + REprintf("ERROR: reading point start offset from QFIT header\n"); return FALSE; } @@ -212,7 +212,7 @@ BOOL LASreaderQFIT::open(ByteStreamIn* stream) header.add_attribute(scan_azimuth); } catch(...) { - fprintf(stderr,"ERROR: initializing attribute scan_azimuth\n"); + REprintf("ERROR: initializing attribute scan_azimuth\n"); return FALSE; } @@ -225,7 +225,7 @@ BOOL LASreaderQFIT::open(ByteStreamIn* stream) header.add_attribute(pitch); } catch(...) { - fprintf(stderr,"ERROR: initializing attribute pitch\n"); + REprintf("ERROR: initializing attribute pitch\n"); return FALSE; } @@ -238,7 +238,7 @@ BOOL LASreaderQFIT::open(ByteStreamIn* stream) header.add_attribute(roll); } catch(...) { - fprintf(stderr,"ERROR: initializing attribute roll\n"); + REprintf("ERROR: initializing attribute roll\n"); return FALSE; } @@ -249,7 +249,7 @@ BOOL LASreaderQFIT::open(ByteStreamIn* stream) header.add_attribute(pulse_width); } catch(...) { - fprintf(stderr,"ERROR: initializing attribute pulse width\n"); + REprintf("ERROR: initializing attribute pulse width\n"); return FALSE; } } @@ -314,7 +314,7 @@ BOOL LASreaderQFIT::read_point_default() { try { stream->getBytes((U8*)buffer, version); } catch(...) { - fprintf(stderr,"ERROR: reading QFIT point after %u of %u\n", (U32)p_count, (U32)npoints); + REprintf("ERROR: reading QFIT point after %u of %u\n", (U32)p_count, (U32)npoints); return FALSE; } @@ -402,7 +402,7 @@ BOOL LASreaderQFIT::reopen(const char* file_name) { if (file_name == 0) { - fprintf(stderr,"ERROR: file name pointer is zero\n"); + REprintf("ERROR: file name pointer is zero\n"); return FALSE; } @@ -411,7 +411,7 @@ BOOL LASreaderQFIT::reopen(const char* file_name) file = fopen(file_name, "rb"); if (file == 0) { - fprintf(stderr, "ERROR: cannot open file '%s'\n", file_name); + REprintf( "ERROR: cannot open file '%s'\n", file_name); return FALSE; } diff --git a/src/LASlib/lasreader_shp.cpp b/src/LASlib/lasreader_shp.cpp index b652457..b418401 100644 --- a/src/LASlib/lasreader_shp.cpp +++ b/src/LASlib/lasreader_shp.cpp @@ -105,7 +105,7 @@ BOOL LASreaderSHP::open(const char* file_name) { if (file_name == 0) { - fprintf(stderr,"ERROR: file name pointer is zero\n"); + REprintf("ERROR: file name pointer is zero\n"); return FALSE; } @@ -114,7 +114,7 @@ BOOL LASreaderSHP::open(const char* file_name) file = fopen_compressed(file_name, "rb", &piped); if (file == 0) { - fprintf(stderr, "ERROR: cannot open file '%s'\n", file_name); + REprintf( "ERROR: cannot open file '%s'\n", file_name); return FALSE; } @@ -158,7 +158,7 @@ BOOL LASreaderSHP::open(const char* file_name) from_big_endian(&int_input); if (int_input != 9994) { - fprintf(stderr, "ERROR: wrong shapefile code %d != 9994\n", int_input); + REprintf( "ERROR: wrong shapefile code %d != 9994\n", int_input); return FALSE; } if (fread(&int_input, sizeof(int), 1, file) != 1) return false; // unused (BIG) @@ -173,7 +173,7 @@ BOOL LASreaderSHP::open(const char* file_name) from_little_endian(&int_input); if (int_input != 1000) { - fprintf(stderr, "ERROR: wrong shapefile version %d != 1000\n", int_input); + REprintf( "ERROR: wrong shapefile version %d != 1000\n", int_input); return FALSE; } if (fread(&int_input, sizeof(int), 1, file) != 1) return false; // shape type (LITTLE) @@ -181,7 +181,7 @@ BOOL LASreaderSHP::open(const char* file_name) shape_type = int_input; if (shape_type != 1 && shape_type != 11 && shape_type != 21 && shape_type != 8 && shape_type != 18 && shape_type != 28) { - fprintf(stderr, "ERROR: wrong shape type %d != 1,11,21,8,18,28\n", shape_type); + REprintf( "ERROR: wrong shape type %d != 1,11,21,8,18,28\n", shape_type); return FALSE; } double double_input; @@ -298,7 +298,7 @@ BOOL LASreaderSHP::read_point_default() from_little_endian(&int_input); if (int_input != shape_type) { - fprintf(stderr, "WARNING: wrong shape type %d != %d in record\n", int_input, shape_type); + REprintf( "WARNING: wrong shape type %d != %d in record\n", int_input, shape_type); } double double_input; if (shape_type == 8 || shape_type == 18 || shape_type == 28) // Multipoint @@ -416,14 +416,14 @@ BOOL LASreaderSHP::reopen(const char* file_name) { if (file_name == 0) { - fprintf(stderr,"ERROR: file name pointer is zero\n"); + REprintf("ERROR: file name pointer is zero\n"); return FALSE; } file = fopen_compressed(file_name, "rb", &piped); if (file == 0) { - fprintf(stderr, "ERROR: cannot reopen file '%s'\n", file_name); + REprintf( "ERROR: cannot reopen file '%s'\n", file_name); return FALSE; } @@ -566,8 +566,8 @@ void LASreaderSHP::populate_bounding_box() if ((header.min_x > 0) != (dequant_min_x > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for min_x from %g to %g.\n", header.min_x, dequant_min_x); - fprintf(stderr, " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); + REprintf( "WARNING: quantization sign flip for min_x from %g to %g.\n", header.min_x, dequant_min_x); + REprintf( " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); } else { @@ -575,8 +575,8 @@ void LASreaderSHP::populate_bounding_box() } if ((header.max_x > 0) != (dequant_max_x > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for max_x from %g to %g.\n", header.max_x, dequant_max_x); - fprintf(stderr, " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); + REprintf( "WARNING: quantization sign flip for max_x from %g to %g.\n", header.max_x, dequant_max_x); + REprintf( " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); } else { @@ -584,8 +584,8 @@ void LASreaderSHP::populate_bounding_box() } if ((header.min_y > 0) != (dequant_min_y > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for min_y from %g to %g.\n", header.min_y, dequant_min_y); - fprintf(stderr, " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); + REprintf( "WARNING: quantization sign flip for min_y from %g to %g.\n", header.min_y, dequant_min_y); + REprintf( " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); } else { @@ -593,8 +593,8 @@ void LASreaderSHP::populate_bounding_box() } if ((header.max_y > 0) != (dequant_max_y > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for max_y from %g to %g.\n", header.max_y, dequant_max_y); - fprintf(stderr, " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); + REprintf( "WARNING: quantization sign flip for max_y from %g to %g.\n", header.max_y, dequant_max_y); + REprintf( " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); } else { @@ -602,8 +602,8 @@ void LASreaderSHP::populate_bounding_box() } if ((header.min_z > 0) != (dequant_min_z > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for min_z from %g to %g.\n", header.min_z, dequant_min_z); - fprintf(stderr, " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); + REprintf( "WARNING: quantization sign flip for min_z from %g to %g.\n", header.min_z, dequant_min_z); + REprintf( " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); } else { @@ -611,8 +611,8 @@ void LASreaderSHP::populate_bounding_box() } if ((header.max_z > 0) != (dequant_max_z > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for max_z from %g to %g.\n", header.max_z, dequant_max_z); - fprintf(stderr, " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); + REprintf( "WARNING: quantization sign flip for max_z from %g to %g.\n", header.max_z, dequant_max_z); + REprintf( " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); } else { diff --git a/src/LASlib/lasreader_txt.cpp b/src/LASlib/lasreader_txt.cpp index 9560489..15b2164 100644 --- a/src/LASlib/lasreader_txt.cpp +++ b/src/LASlib/lasreader_txt.cpp @@ -43,20 +43,20 @@ BOOL LASreaderTXT::open(const CHAR* file_name, U8 point_type, const CHAR* parse_ { if (file_name == 0) { - fprintf(stderr,"ERROR: file name pointer is zero\n"); + REprintf("ERROR: file name pointer is zero\n"); return FALSE; } FILE* file = fopen_compressed(file_name, "r", &piped); if (file == 0) { - fprintf(stderr, "ERROR: cannot open file '%s'\n", file_name); + REprintf( "ERROR: cannot open file '%s'\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, 10*LAS_TOOLS_IO_IBUFFER_SIZE) != 0) { - fprintf(stderr, "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); + REprintf( "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); } return open(file, file_name, point_type, parse_string, skip_lines, populate_header); @@ -68,7 +68,7 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const if (file == 0) { - fprintf(stderr,"ERROR: file pointer is zero\n"); + REprintf("ERROR: file pointer is zero\n"); return FALSE; } @@ -108,7 +108,7 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const header.add_attribute(attribute); } catch(...) { - fprintf(stderr,"ERROR: initializing attribute %s\n", attribute_descriptions[i]); + REprintf("ERROR: initializing attribute %s\n", attribute_descriptions[i]); return FALSE; } } @@ -288,19 +288,19 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const if (sscanf(line, "%lld", &npoints) != 1) #endif { - fprintf(stderr, "ERROR: parsing number of points for '-itps'\n"); + REprintf( "ERROR: parsing number of points for '-itps'\n"); return FALSE; } #ifdef _WIN32 - fprintf(stderr, "PTS header states %I64d points. ignoring ...\n", npoints); + REprintf( "PTS header states %I64d points. ignoring ...\n", npoints); #else - fprintf(stderr, "PTS header states %lld points. ignoring ...\n", npoints); + REprintf( "PTS header states %lld points. ignoring ...\n", npoints); #endif npoints = 0; } else { - fprintf(stderr, "ERROR: reading PTS header for '-itps'\n"); + REprintf( "ERROR: reading PTS header for '-itps'\n"); return FALSE; } } @@ -311,13 +311,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%d", &ncols) != 1) { - fprintf(stderr, "ERROR: parsing number of cols\n"); + REprintf( "ERROR: parsing number of cols\n"); return FALSE; } } else { - fprintf(stderr, "ERROR: reading line with number of cols\n"); + REprintf( "ERROR: reading line with number of cols\n"); return FALSE; } I32 nrows; @@ -325,33 +325,33 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%d", &nrows) != 1) { - fprintf(stderr, "ERROR: parsing number of rows\n"); + REprintf( "ERROR: parsing number of rows\n"); return FALSE; } } else { - fprintf(stderr, "ERROR: reading line with number of rows\n"); + REprintf( "ERROR: reading line with number of rows\n"); return FALSE; } npoints = (I64)ncols*(I64)nrows; #ifdef _WIN32 - fprintf(stderr, "PTX header states %d cols by %d rows aka %I64d points. ignoring ...\n", ncols, nrows, npoints); + REprintf( "PTX header states %d cols by %d rows aka %I64d points. ignoring ...\n", ncols, nrows, npoints); #else - fprintf(stderr, "PTX header states %d cols by %d rows aka %lld points. ignoring ...\n", ncols, nrows, npoints); + REprintf( "PTX header states %d cols by %d rows aka %lld points. ignoring ...\n", ncols, nrows, npoints); #endif F64 translation[3]; if (fgets(line, 512, file)) { if (sscanf(line, "%lf %lf %lf", &(translation[0]), &(translation[1]), &(translation[2])) != 3) { - fprintf(stderr, "ERROR: parsing translation\n"); + REprintf( "ERROR: parsing translation\n"); return FALSE; } } else { - fprintf(stderr, "ERROR: reading line with translation\n"); + REprintf( "ERROR: reading line with translation\n"); return FALSE; } F64 rotation_row_0[3]; @@ -359,13 +359,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%lf %lf %lf", &(rotation_row_0[0]), &(rotation_row_0[1]), &(rotation_row_0[2])) != 3) { - fprintf(stderr, "ERROR: parsing rotation row 0\n"); + REprintf( "ERROR: parsing rotation row 0\n"); return FALSE; } } else { - fprintf(stderr, "ERROR: reading line with rotation row 0\n"); + REprintf( "ERROR: reading line with rotation row 0\n"); return FALSE; } F64 rotation_row_1[3]; @@ -373,13 +373,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%lf %lf %lf", &(rotation_row_1[0]), &(rotation_row_1[1]), &(rotation_row_1[2])) != 3) { - fprintf(stderr, "ERROR: parsing rotation row 1\n"); + REprintf( "ERROR: parsing rotation row 1\n"); return FALSE; } } else { - fprintf(stderr, "ERROR: reading line with rotation row 1\n"); + REprintf( "ERROR: reading line with rotation row 1\n"); return FALSE; } F64 rotation_row_2[3]; @@ -387,13 +387,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%lf %lf %lf", &(rotation_row_2[0]), &(rotation_row_2[1]), &(rotation_row_2[2])) != 3) { - fprintf(stderr, "ERROR: parsing rotation row 2\n"); + REprintf( "ERROR: parsing rotation row 2\n"); return FALSE; } } else { - fprintf(stderr, "ERROR: reading line with rotation row 2\n"); + REprintf( "ERROR: reading line with rotation row 2\n"); return FALSE; } F64 transformation_row_0[4]; @@ -401,13 +401,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%lf %lf %lf %lf", &(transformation_row_0[0]), &(transformation_row_0[1]), &(transformation_row_0[2]), &(transformation_row_0[3])) != 4) { - fprintf(stderr, "ERROR: parsing transformation row 0\n"); + REprintf( "ERROR: parsing transformation row 0\n"); return FALSE; } } else { - fprintf(stderr, "ERROR: reading line with transformation row 0\n"); + REprintf( "ERROR: reading line with transformation row 0\n"); return FALSE; } F64 transformation_row_1[4]; @@ -415,13 +415,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%lf %lf %lf %lf", &(transformation_row_1[0]), &(transformation_row_1[1]), &(transformation_row_1[2]), &(transformation_row_1[3])) != 4) { - fprintf(stderr, "ERROR: parsing transformation row 1\n"); + REprintf( "ERROR: parsing transformation row 1\n"); return FALSE; } } else { - fprintf(stderr, "ERROR: reading line with transformation row 1\n"); + REprintf( "ERROR: reading line with transformation row 1\n"); return FALSE; } F64 transformation_row_2[4]; @@ -429,13 +429,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%lf %lf %lf %lf", &(transformation_row_2[0]), &(transformation_row_2[1]), &(transformation_row_2[2]), &(transformation_row_2[3])) != 4) { - fprintf(stderr, "ERROR: parsing transformation row 2\n"); + REprintf( "ERROR: parsing transformation row 2\n"); return FALSE; } } else { - fprintf(stderr, "ERROR: reading line with transformation row 2\n"); + REprintf( "ERROR: reading line with transformation row 2\n"); return FALSE; } F64 transformation_row_3[4]; @@ -443,13 +443,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%lf %lf %lf %lf", &(transformation_row_3[0]), &(transformation_row_3[1]), &(transformation_row_3[2]), &(transformation_row_3[3])) != 4) { - fprintf(stderr, "ERROR: parsing transformation row 3\n"); + REprintf( "ERROR: parsing transformation row 3\n"); return FALSE; } } else { - fprintf(stderr, "ERROR: reading line with transformation row 3\n"); + REprintf( "ERROR: reading line with transformation row 3\n"); return FALSE; } npoints = 0; @@ -469,7 +469,7 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const else { line[strlen(line)-1] = '\0'; - fprintf(stderr, "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_less); + REprintf( "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_less); } } @@ -477,7 +477,7 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const if (npoints == 0) { - fprintf(stderr, "ERROR: could not parse any lines with '%s'\n", parse_less); + REprintf( "ERROR: could not parse any lines with '%s'\n", parse_less); fclose(file); file = 0; free(parse_less); @@ -549,14 +549,14 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const else { line[strlen(line)-1] = '\0'; - fprintf(stderr, "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_less); + REprintf( "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_less); } } #ifdef _WIN32 - fprintf(stderr, "counted %I64d points in populate pass.\n", npoints); + REprintf( "counted %I64d points in populate pass.\n", npoints); #else - fprintf(stderr, "counted %lld points in populate pass.\n", npoints); + REprintf( "counted %lld points in populate pass.\n", npoints); #endif if (point.extended_point_type || (npoints > U32_MAX) || header.extended_number_of_points_by_return[5] || header.extended_number_of_points_by_return[6] || header.extended_number_of_points_by_return[7] || header.extended_number_of_points_by_return[8] || header.extended_number_of_points_by_return[9] || header.extended_number_of_points_by_return[10] || header.extended_number_of_points_by_return[11] || header.extended_number_of_points_by_return[12] || header.extended_number_of_points_by_return[13] || header.extended_number_of_points_by_return[14]) @@ -616,13 +616,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const file = fopen_compressed(file_name, "r", &piped); if (file == 0) { - fprintf(stderr, "ERROR: could not open '%s' for second pass\n", file_name); + REprintf( "ERROR: could not open '%s' for second pass\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, 10*LAS_TOOLS_IO_IBUFFER_SIZE) != 0) { - fprintf(stderr, "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); + REprintf( "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); } } @@ -654,7 +654,7 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const if (sscanf(line, "%lld", &npoints) != 1) #endif { - fprintf(stderr, "ERROR: parsing number of points for '-itps'\n"); + REprintf( "ERROR: parsing number of points for '-itps'\n"); return FALSE; } } @@ -685,7 +685,7 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const } else { - fprintf(stderr, "ERROR: reading PTS header for '-itps'\n"); + REprintf( "ERROR: reading PTS header for '-itps'\n"); return FALSE; } @@ -705,13 +705,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%d", &ncols) != 1) { - fprintf(stderr, "ERROR: parsing number of cols\n"); + REprintf( "ERROR: parsing number of cols\n"); return FALSE; } } else { - fprintf(stderr, "ERROR: reading line with number of cols\n"); + REprintf( "ERROR: reading line with number of cols\n"); return FALSE; } I32 nrows; @@ -719,13 +719,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%d", &nrows) != 1) { - fprintf(stderr, "ERROR: parsing number of rows\n"); + REprintf( "ERROR: parsing number of rows\n"); return FALSE; } } else { - fprintf(stderr, "ERROR: reading line with number of rows\n"); + REprintf( "ERROR: reading line with number of rows\n"); return FALSE; } npoints = (I64)ncols*(I64)nrows; @@ -758,13 +758,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%lf %lf %lf", &(translation[0]), &(translation[1]), &(translation[2])) != 3) { - fprintf(stderr, "ERROR: parsing translation\n"); + REprintf( "ERROR: parsing translation\n"); return FALSE; } } else { - fprintf(stderr, "ERROR: reading line with translation\n"); + REprintf( "ERROR: reading line with translation\n"); return FALSE; } F64 rotation_row_0[3]; @@ -772,13 +772,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%lf %lf %lf", &(rotation_row_0[0]), &(rotation_row_0[1]), &(rotation_row_0[2])) != 3) { - fprintf(stderr, "ERROR: parsing rotation row 0\n"); + REprintf( "ERROR: parsing rotation row 0\n"); return FALSE; } } else { - fprintf(stderr, "ERROR: reading line with rotation row 0\n"); + REprintf( "ERROR: reading line with rotation row 0\n"); return FALSE; } F64 rotation_row_1[3]; @@ -786,13 +786,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%lf %lf %lf", &(rotation_row_1[0]), &(rotation_row_1[1]), &(rotation_row_1[2])) != 3) { - fprintf(stderr, "ERROR: parsing rotation row 1\n"); + REprintf( "ERROR: parsing rotation row 1\n"); return FALSE; } } else { - fprintf(stderr, "ERROR: reading line with rotation row 1\n"); + REprintf( "ERROR: reading line with rotation row 1\n"); return FALSE; } F64 rotation_row_2[3]; @@ -800,13 +800,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%lf %lf %lf", &(rotation_row_2[0]), &(rotation_row_2[1]), &(rotation_row_2[2])) != 3) { - fprintf(stderr, "ERROR: parsing rotation row 2\n"); + REprintf( "ERROR: parsing rotation row 2\n"); return FALSE; } } else { - fprintf(stderr, "ERROR: reading line with rotation row 2\n"); + REprintf( "ERROR: reading line with rotation row 2\n"); return FALSE; } F64 transformation_row_0[4]; @@ -814,13 +814,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%lf %lf %lf %lf", &(transformation_row_0[0]), &(transformation_row_0[1]), &(transformation_row_0[2]), &(transformation_row_0[3])) != 4) { - fprintf(stderr, "ERROR: parsing transformation row 0\n"); + REprintf( "ERROR: parsing transformation row 0\n"); return FALSE; } } else { - fprintf(stderr, "ERROR: reading line with transformation row 0\n"); + REprintf( "ERROR: reading line with transformation row 0\n"); return FALSE; } F64 transformation_row_1[4]; @@ -828,13 +828,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%lf %lf %lf %lf", &(transformation_row_1[0]), &(transformation_row_1[1]), &(transformation_row_1[2]), &(transformation_row_1[3])) != 4) { - fprintf(stderr, "ERROR: parsing transformation row 1\n"); + REprintf( "ERROR: parsing transformation row 1\n"); return FALSE; } } else { - fprintf(stderr, "ERROR: reading line with transformation row 1\n"); + REprintf( "ERROR: reading line with transformation row 1\n"); return FALSE; } F64 transformation_row_2[4]; @@ -842,13 +842,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%lf %lf %lf %lf", &(transformation_row_2[0]), &(transformation_row_2[1]), &(transformation_row_2[2]), &(transformation_row_2[3])) != 4) { - fprintf(stderr, "ERROR: parsing transformation row 2\n"); + REprintf( "ERROR: parsing transformation row 2\n"); return FALSE; } } else { - fprintf(stderr, "ERROR: reading line with transformation row 2\n"); + REprintf( "ERROR: reading line with transformation row 2\n"); return FALSE; } F64 transformation_row_3[4]; @@ -856,13 +856,13 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const { if (sscanf(line, "%lf %lf %lf %lf", &(transformation_row_3[0]), &(transformation_row_3[1]), &(transformation_row_3[2]), &(transformation_row_3[3])) != 4) { - fprintf(stderr, "ERROR: parsing transformation row 3\n"); + REprintf( "ERROR: parsing transformation row 3\n"); return FALSE; } } else { - fprintf(stderr, "ERROR: reading line with transformation row 3\n"); + REprintf( "ERROR: reading line with transformation row 3\n"); return FALSE; } @@ -942,7 +942,7 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const else { line[strlen(line)-1] = '\0'; - fprintf(stderr, "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, this->parse_string); + REprintf( "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, this->parse_string); } } @@ -950,7 +950,7 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const if (i != 1) { - fprintf(stderr, "ERROR: could not parse any lines with '%s'\n", this->parse_string); + REprintf( "ERROR: could not parse any lines with '%s'\n", this->parse_string); fclose(this->file); this->file = 0; free(this->parse_string); @@ -1109,13 +1109,13 @@ BOOL LASreaderTXT::seek(const I64 p_index) else { line[strlen(line)-1] = '\0'; - fprintf(stderr, "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, this->parse_string); + REprintf( "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, this->parse_string); } } // did we manage to parse a line if (i != 1) { - fprintf(stderr, "ERROR: could not parse any lines with '%s'\n", this->parse_string); + REprintf( "ERROR: could not parse any lines with '%s'\n", this->parse_string); fclose(file); file = 0; free(this->parse_string); @@ -1148,7 +1148,7 @@ BOOL LASreaderTXT::read_point_default() else { line[strlen(line)-1] = '\0'; - fprintf(stderr, "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, this->parse_string); + REprintf( "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, this->parse_string); } } else @@ -1158,9 +1158,9 @@ BOOL LASreaderTXT::read_point_default() if (p_count != npoints) { #ifdef _WIN32 - fprintf(stderr,"WARNING: end-of-file after %I64d of %I64d points\n", p_count, npoints); + REprintf("WARNING: end-of-file after %I64d of %I64d points\n", p_count, npoints); #else - fprintf(stderr,"WARNING: end-of-file after %lld of %lld points\n", p_count, npoints); + REprintf("WARNING: end-of-file after %lld of %lld points\n", p_count, npoints); #endif } } @@ -1171,9 +1171,9 @@ BOOL LASreaderTXT::read_point_default() if (p_count != npoints) { #ifdef _WIN32 - fprintf(stderr,"WARNING: end-of-file after %I64d of %I64d points\n", p_count, npoints); + REprintf("WARNING: end-of-file after %I64d of %I64d points\n", p_count, npoints); #else - fprintf(stderr,"WARNING: end-of-file after %lld of %lld points\n", p_count, npoints); + REprintf("WARNING: end-of-file after %lld of %lld points\n", p_count, npoints); #endif } } @@ -1246,20 +1246,20 @@ BOOL LASreaderTXT::reopen(const char* file_name) if (file_name == 0) { - fprintf(stderr,"ERROR: file name pointer is zero\n"); + REprintf("ERROR: file name pointer is zero\n"); return FALSE; } file = fopen_compressed(file_name, "r", &piped); if (file == 0) { - fprintf(stderr, "ERROR: cannot reopen file '%s'\n", file_name); + REprintf( "ERROR: cannot reopen file '%s'\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, 10*LAS_TOOLS_IO_IBUFFER_SIZE) != 0) { - fprintf(stderr, "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); + REprintf( "WARNING: setvbuf() failed with buffer size %d\n", 10*LAS_TOOLS_IO_IBUFFER_SIZE); } // skip lines if we have to @@ -1280,7 +1280,7 @@ BOOL LASreaderTXT::reopen(const char* file_name) else { line[strlen(line)-1] = '\0'; - fprintf(stderr, "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_string); + REprintf( "WARNING: cannot parse '%s' with '%s'. skipping ...\n", line, parse_string); } } @@ -1288,7 +1288,7 @@ BOOL LASreaderTXT::reopen(const char* file_name) if (i != 1) { - fprintf(stderr, "ERROR: could not parse any lines with '%s'\n", parse_string); + REprintf( "ERROR: could not parse any lines with '%s'\n", parse_string); fclose(file); file = 0; return FALSE; @@ -1381,7 +1381,7 @@ BOOL LASreaderTXT::parse_attribute(const char* l, I32 index) } if (temp_i < U8_MIN || temp_i > U8_MAX) { - fprintf(stderr, "WARNING: attribute %d of type U8 is %d. clamped to [%d %d] range.\n", index, temp_i, U8_MIN, U8_MAX); + REprintf( "WARNING: attribute %d of type U8 is %d. clamped to [%d %d] range.\n", index, temp_i, U8_MIN, U8_MAX); point.set_attribute(attribute_starts[index], U8_CLAMP(temp_i)); } else @@ -1406,7 +1406,7 @@ BOOL LASreaderTXT::parse_attribute(const char* l, I32 index) } if (temp_i < I8_MIN || temp_i > I8_MAX) { - fprintf(stderr, "WARNING: attribute %d of type I8 is %d. clamped to [%d %d] range.\n", index, temp_i, I8_MIN, I8_MAX); + REprintf( "WARNING: attribute %d of type I8 is %d. clamped to [%d %d] range.\n", index, temp_i, I8_MIN, I8_MAX); point.set_attribute(attribute_starts[index], I8_CLAMP(temp_i)); } else @@ -1431,7 +1431,7 @@ BOOL LASreaderTXT::parse_attribute(const char* l, I32 index) } if (temp_i < U16_MIN || temp_i > U16_MAX) { - fprintf(stderr, "WARNING: attribute %d of type U16 is %d. clamped to [%d %d] range.\n", index, temp_i, U16_MIN, U16_MAX); + REprintf( "WARNING: attribute %d of type U16 is %d. clamped to [%d %d] range.\n", index, temp_i, U16_MIN, U16_MAX); point.set_attribute(attribute_starts[index], U16_CLAMP(temp_i)); } else @@ -1456,7 +1456,7 @@ BOOL LASreaderTXT::parse_attribute(const char* l, I32 index) } if (temp_i < I16_MIN || temp_i > I16_MAX) { - fprintf(stderr, "WARNING: attribute %d of type I16 is %d. clamped to [%d %d] range.\n", index, temp_i, I16_MIN, I16_MAX); + REprintf( "WARNING: attribute %d of type I16 is %d. clamped to [%d %d] range.\n", index, temp_i, I16_MIN, I16_MAX); point.set_attribute(attribute_starts[index], I16_CLAMP(temp_i)); } else @@ -1509,7 +1509,7 @@ BOOL LASreaderTXT::parse_attribute(const char* l, I32 index) } else { - fprintf(stderr, "WARNING: attribute %d not (yet) implemented.\n", index); + REprintf( "WARNING: attribute %d not (yet) implemented.\n", index); return FALSE; } return TRUE; @@ -1597,7 +1597,7 @@ BOOL LASreaderTXT::parse(const char* parse_string) if (sscanf(l, "%f", &temp_f) != 1) return FALSE; if (translate_intensity != 0.0f) temp_f = temp_f+translate_intensity; if (scale_intensity != 1.0f) temp_f = temp_f*scale_intensity; - if (temp_f < 0.0f || temp_f >= 65535.5f) fprintf(stderr, "WARNING: intensity %g is out of range of unsigned short\n", temp_f); + if (temp_f < 0.0f || temp_f >= 65535.5f) REprintf( "WARNING: intensity %g is out of range of unsigned short\n", temp_f); point.set_intensity(U16_QUANTIZE(temp_f)); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1608,7 +1608,7 @@ BOOL LASreaderTXT::parse(const char* parse_string) if (sscanf(l, "%f", &temp_f) != 1) return FALSE; if (translate_scan_angle != 0.0f) temp_f = temp_f+translate_scan_angle; if (scale_scan_angle != 1.0f) temp_f = temp_f*scale_scan_angle; - if (temp_f < -128.0f || temp_f > 127.0f) fprintf(stderr, "WARNING: scan angle %g is out of range of char\n", temp_f); + if (temp_f < -128.0f || temp_f > 127.0f) REprintf( "WARNING: scan angle %g is out of range of char\n", temp_f); point.set_scan_angle(temp_f); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1619,12 +1619,12 @@ BOOL LASreaderTXT::parse(const char* parse_string) if (sscanf(l, "%d", &temp_i) != 1) return FALSE; if (point_type > 5) { - if (temp_i < 0 || temp_i > 15) fprintf(stderr, "WARNING: number of returns of given pulse %d is out of range of four bits\n", temp_i); + if (temp_i < 0 || temp_i > 15) REprintf( "WARNING: number of returns of given pulse %d is out of range of four bits\n", temp_i); point.set_extended_number_of_returns(temp_i & 15); } else { - if (temp_i < 0 || temp_i > 7) fprintf(stderr, "WARNING: number of returns of given pulse %d is out of range of three bits\n", temp_i); + if (temp_i < 0 || temp_i > 7) REprintf( "WARNING: number of returns of given pulse %d is out of range of three bits\n", temp_i); point.set_number_of_returns(temp_i & 7); } while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space @@ -1636,12 +1636,12 @@ BOOL LASreaderTXT::parse(const char* parse_string) if (sscanf(l, "%d", &temp_i) != 1) return FALSE; if (point_type > 5) { - if (temp_i < 0 || temp_i > 15) fprintf(stderr, "WARNING: return number %d is out of range of four bits\n", temp_i); + if (temp_i < 0 || temp_i > 15) REprintf( "WARNING: return number %d is out of range of four bits\n", temp_i); point.set_extended_return_number(temp_i & 15); } else { - if (temp_i < 0 || temp_i > 7) fprintf(stderr, "WARNING: return number %d is out of range of three bits\n", temp_i); + if (temp_i < 0 || temp_i > 7) REprintf( "WARNING: return number %d is out of range of three bits\n", temp_i); point.set_return_number(temp_i & 7); } while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space @@ -1651,7 +1651,7 @@ BOOL LASreaderTXT::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 1) fprintf(stderr, "WARNING: withheld flag %d is out of range of single bit\n", temp_i); + if (temp_i < 0 || temp_i > 1) REprintf( "WARNING: withheld flag %d is out of range of single bit\n", temp_i); point.set_withheld_flag(temp_i ? 1 : 0); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1660,7 +1660,7 @@ BOOL LASreaderTXT::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 1) fprintf(stderr, "WARNING: keypoint flag %d is out of range of single bit\n", temp_i); + if (temp_i < 0 || temp_i > 1) REprintf( "WARNING: keypoint flag %d is out of range of single bit\n", temp_i); point.set_keypoint_flag(temp_i ? 1 : 0); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1669,7 +1669,7 @@ BOOL LASreaderTXT::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 1) fprintf(stderr, "WARNING: keypoint flag %d is out of range of single bit\n", temp_i); + if (temp_i < 0 || temp_i > 1) REprintf( "WARNING: keypoint flag %d is out of range of single bit\n", temp_i); point.set_synthetic_flag(temp_i ? 1 : 0); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1678,7 +1678,7 @@ BOOL LASreaderTXT::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 1) fprintf(stderr, "WARNING: overlap flag %d is out of range of single bit\n", temp_i); + if (temp_i < 0 || temp_i > 1) REprintf( "WARNING: overlap flag %d is out of range of single bit\n", temp_i); point.set_extended_overlap_flag(temp_i ? 1 : 0); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1687,7 +1687,7 @@ BOOL LASreaderTXT::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 3) fprintf(stderr, "WARNING: scanner channel %d is out of range of two bits\n", temp_i); + if (temp_i < 0 || temp_i > 3) REprintf( "WARNING: scanner channel %d is out of range of two bits\n", temp_i); point.extended_scanner_channel = temp_i & 3; while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1696,7 +1696,7 @@ BOOL LASreaderTXT::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 3) fprintf(stderr, "WARNING: terrasolid echo encoding %d is out of range of 0 to 3\n", temp_i); + if (temp_i < 0 || temp_i > 3) REprintf( "WARNING: terrasolid echo encoding %d is out of range of 0 to 3\n", temp_i); if (temp_i == 0) // only echo { point.number_of_returns = 1; @@ -1726,7 +1726,7 @@ BOOL LASreaderTXT::parse(const char* parse_string) if (sscanf(l, "%d", &temp_i) != 1) return FALSE; if (temp_i < 0) { - fprintf(stderr, "WARNING: classification %d is negative. zeroing ...\n", temp_i); + REprintf( "WARNING: classification %d is negative. zeroing ...\n", temp_i); point.set_classification(0); point.set_extended_classification(0); } @@ -1734,7 +1734,7 @@ BOOL LASreaderTXT::parse(const char* parse_string) { if (temp_i > 255) { - fprintf(stderr, "WARNING: extended classification %d is larger than 255. clamping ...\n", temp_i); + REprintf( "WARNING: extended classification %d is larger than 255. clamping ...\n", temp_i); point.set_extended_classification(255); } else @@ -1746,7 +1746,7 @@ BOOL LASreaderTXT::parse(const char* parse_string) { if (temp_i > 31) { - fprintf(stderr, "WARNING: classification %d is larger than 31. clamping ...\n", temp_i); + REprintf( "WARNING: classification %d is larger than 31. clamping ...\n", temp_i); point.set_classification(31); } else @@ -1763,7 +1763,7 @@ BOOL LASreaderTXT::parse(const char* parse_string) if (sscanf(l, "%d", &temp_i) != 1) return FALSE; if (temp_i < 0 || temp_i > 255) { - fprintf(stderr, "WARNING: user data %d is out of range of unsigned char\n", temp_i); + REprintf( "WARNING: user data %d is out of range of unsigned char\n", temp_i); point.set_user_data(U8_CLAMP(temp_i)); } else @@ -1779,7 +1779,7 @@ BOOL LASreaderTXT::parse(const char* parse_string) if (sscanf(l, "%d", &temp_i) != 1) return FALSE; if (temp_i < 0 || temp_i > 65535) { - fprintf(stderr, "WARNING: point source ID %d is out of range of unsigned short\n", temp_i); + REprintf( "WARNING: point source ID %d is out of range of unsigned short\n", temp_i); point.set_point_source_ID(U16_CLAMP(temp_i)); } else @@ -1793,7 +1793,7 @@ BOOL LASreaderTXT::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 1) fprintf(stderr, "WARNING: edge of flight line flag %d is out of range of boolean flag\n", temp_i); + if (temp_i < 0 || temp_i > 1) REprintf( "WARNING: edge of flight line flag %d is out of range of boolean flag\n", temp_i); point.edge_of_flight_line = (temp_i ? 1 : 0); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1802,7 +1802,7 @@ BOOL LASreaderTXT::parse(const char* parse_string) while (l[0] && (l[0] == ' ' || l[0] == ',' || l[0] == '\t' || l[0] == ';')) l++; // first skip white spaces if (l[0] == 0) return FALSE; if (sscanf(l, "%d", &temp_i) != 1) return FALSE; - if (temp_i < 0 || temp_i > 1) fprintf(stderr, "WARNING: direction of scan flag %d is out of range of boolean flag\n", temp_i); + if (temp_i < 0 || temp_i > 1) REprintf( "WARNING: direction of scan flag %d is out of range of boolean flag\n", temp_i); point.scan_direction_flag = (temp_i ? 1 : 0); while (l[0] && l[0] != ' ' && l[0] != ',' && l[0] != '\t' && l[0] != ';') l++; // then advance to next white space } @@ -1858,7 +1858,7 @@ BOOL LASreaderTXT::parse(const char* parse_string) } else { - fprintf(stderr, "ERROR: unknown symbol '%c' in parse string\n", p[0]); + REprintf( "ERROR: unknown symbol '%c' in parse string\n", p[0]); } p++; } @@ -1902,7 +1902,7 @@ BOOL LASreaderTXT::check_parse_string(const char* parse_string) I32 index = (I32)(p[0] - '0'); if (index >= header.number_attributes) { - fprintf(stderr, "ERROR: extra bytes attribute '%d' was not described.\n", index); + REprintf( "ERROR: extra bytes attribute '%d' was not described.\n", index); return FALSE; } attribute_starts[index] = header.get_attribute_start(index); @@ -1920,53 +1920,53 @@ BOOL LASreaderTXT::check_parse_string(const char* parse_string) } if (index >= header.number_attributes) { - fprintf(stderr, "ERROR: extra bytes attribute '%d' was not described.\n", index); + REprintf( "ERROR: extra bytes attribute '%d' was not described.\n", index); return FALSE; } if (p[0] != ')') { - fprintf(stderr, "ERROR: extra bytes attribute '%d' misses closing bracket.\n", index); + REprintf( "ERROR: extra bytes attribute '%d' misses closing bracket.\n", index); return FALSE; } attribute_starts[index] = header.get_attribute_start(index); } else { - fprintf(stderr, "ERROR: parse string opening bracket '(' misses extra bytes index.\n"); + REprintf( "ERROR: parse string opening bracket '(' misses extra bytes index.\n"); return FALSE; } } else { - fprintf(stderr, "ERROR: unknown symbol '%c' in parse string. valid are\n", p[0]); - fprintf(stderr, " 'x' : the coordinate\n"); - fprintf(stderr, " 'y' : the coordinate\n"); - fprintf(stderr, " 'z' : the coordinate\n"); - fprintf(stderr, " 't' : the gps ime\n"); - fprintf(stderr, " 'R' : the ed channel of the RGB field\n"); - fprintf(stderr, " 'G' : the reen channel of the RGB field\n"); - fprintf(stderr, " 'B' : the lue channel of the RGB field\n"); - fprintf(stderr, " 'I' : the NR channel of LAS 1.4 point type 8\n"); - fprintf(stderr, " 's' : kip a string or a number that we don't care about\n"); - fprintf(stderr, " 'i' : the ntensity\n"); - fprintf(stderr, " 'a' : the scan ngle\n"); - fprintf(stderr, " 'n' : the umber of returns of that given pulse\n"); - fprintf(stderr, " 'r' : the number of the eturn\n"); - fprintf(stderr, " 'h' : the witheld flag\n"); - fprintf(stderr, " 'k' : the eypoint flag\n"); - fprintf(stderr, " 'g' : the synthetic fla\n"); - fprintf(stderr, " 'o' : the verlap flag of LAS 1.4 point types 6, 7, 8\n"); - fprintf(stderr, " 'l' : the scanner channe of LAS 1.4 point types 6, 7, 8\n"); - fprintf(stderr, " 'E' : terrasolid hco Encoding\n"); - fprintf(stderr, " 'c' : the lassification\n"); - fprintf(stderr, " 'u' : the ser data\n"); - fprintf(stderr, " 'p' : the

oint source ID\n"); - fprintf(stderr, " 'e' : the dge of flight line flag\n"); - fprintf(stderr, " 'd' : the irection of scan flag\n"); - fprintf(stderr, " '0'-'9' : additional attributes described as extra bytes (0 through 9)\n"); - fprintf(stderr, " '(13)' : additional attributes described as extra bytes (10 and up)\n"); - fprintf(stderr, " 'H' : a hexadecimal string encoding the RGB color\n"); - fprintf(stderr, " 'J' : a hexadecimal string encoding the intensity\n"); + REprintf( "ERROR: unknown symbol '%c' in parse string. valid are\n", p[0]); + REprintf( " 'x' : the coordinate\n"); + REprintf( " 'y' : the coordinate\n"); + REprintf( " 'z' : the coordinate\n"); + REprintf( " 't' : the gps ime\n"); + REprintf( " 'R' : the ed channel of the RGB field\n"); + REprintf( " 'G' : the reen channel of the RGB field\n"); + REprintf( " 'B' : the lue channel of the RGB field\n"); + REprintf( " 'I' : the NR channel of LAS 1.4 point type 8\n"); + REprintf( " 's' : kip a string or a number that we don't care about\n"); + REprintf( " 'i' : the ntensity\n"); + REprintf( " 'a' : the scan ngle\n"); + REprintf( " 'n' : the umber of returns of that given pulse\n"); + REprintf( " 'r' : the number of the eturn\n"); + REprintf( " 'h' : the witheld flag\n"); + REprintf( " 'k' : the eypoint flag\n"); + REprintf( " 'g' : the synthetic fla\n"); + REprintf( " 'o' : the verlap flag of LAS 1.4 point types 6, 7, 8\n"); + REprintf( " 'l' : the scanner channe of LAS 1.4 point types 6, 7, 8\n"); + REprintf( " 'E' : terrasolid hco Encoding\n"); + REprintf( " 'c' : the lassification\n"); + REprintf( " 'u' : the ser data\n"); + REprintf( " 'p' : the

oint source ID\n"); + REprintf( " 'e' : the dge of flight line flag\n"); + REprintf( " 'd' : the irection of scan flag\n"); + REprintf( " '0'-'9' : additional attributes described as extra bytes (0 through 9)\n"); + REprintf( " '(13)' : additional attributes described as extra bytes (10 and up)\n"); + REprintf( " 'H' : a hexadecimal string encoding the RGB color\n"); + REprintf( " 'J' : a hexadecimal string encoding the intensity\n"); return FALSE; } } @@ -2040,8 +2040,8 @@ void LASreaderTXT::populate_bounding_box() if ((header.min_x > 0) != (dequant_min_x > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for min_x from %g to %g.\n", header.min_x, dequant_min_x); - fprintf(stderr, " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); + REprintf( "WARNING: quantization sign flip for min_x from %g to %g.\n", header.min_x, dequant_min_x); + REprintf( " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); } else { @@ -2049,8 +2049,8 @@ void LASreaderTXT::populate_bounding_box() } if ((header.max_x > 0) != (dequant_max_x > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for max_x from %g to %g.\n", header.max_x, dequant_max_x); - fprintf(stderr, " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); + REprintf( "WARNING: quantization sign flip for max_x from %g to %g.\n", header.max_x, dequant_max_x); + REprintf( " set scale factor for x coarser than %g with '-rescale'\n", header.x_scale_factor); } else { @@ -2058,8 +2058,8 @@ void LASreaderTXT::populate_bounding_box() } if ((header.min_y > 0) != (dequant_min_y > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for min_y from %g to %g.\n", header.min_y, dequant_min_y); - fprintf(stderr, " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); + REprintf( "WARNING: quantization sign flip for min_y from %g to %g.\n", header.min_y, dequant_min_y); + REprintf( " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); } else { @@ -2067,8 +2067,8 @@ void LASreaderTXT::populate_bounding_box() } if ((header.max_y > 0) != (dequant_max_y > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for max_y from %g to %g.\n", header.max_y, dequant_max_y); - fprintf(stderr, " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); + REprintf( "WARNING: quantization sign flip for max_y from %g to %g.\n", header.max_y, dequant_max_y); + REprintf( " set scale factor for y coarser than %g with '-rescale'\n", header.y_scale_factor); } else { @@ -2076,8 +2076,8 @@ void LASreaderTXT::populate_bounding_box() } if ((header.min_z > 0) != (dequant_min_z > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for min_z from %g to %g.\n", header.min_z, dequant_min_z); - fprintf(stderr, " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); + REprintf( "WARNING: quantization sign flip for min_z from %g to %g.\n", header.min_z, dequant_min_z); + REprintf( " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); } else { @@ -2085,8 +2085,8 @@ void LASreaderTXT::populate_bounding_box() } if ((header.max_z > 0) != (dequant_max_z > 0)) { - fprintf(stderr, "WARNING: quantization sign flip for max_z from %g to %g.\n", header.max_z, dequant_max_z); - fprintf(stderr, " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); + REprintf( "WARNING: quantization sign flip for max_z from %g to %g.\n", header.max_z, dequant_max_z); + REprintf( " set scale factor for z coarser than %g with '-rescale'\n", header.z_scale_factor); } else { diff --git a/src/LASlib/lasreaderbuffered.cpp b/src/LASlib/lasreaderbuffered.cpp index 6ebc025..71ac57f 100644 --- a/src/LASlib/lasreaderbuffered.cpp +++ b/src/LASlib/lasreaderbuffered.cpp @@ -96,14 +96,14 @@ BOOL LASreaderBuffered::set_file_name(const char* file_name) // do we have a file name if (file_name == 0) { - fprintf(stderr, "ERROR: file name pointer is NULL\n"); + REprintf( "ERROR: file name pointer is NULL\n"); return FALSE; } // does the file exist FILE* file = fopen(file_name, "r"); if (file == 0) { - fprintf(stderr, "ERROR: file '%s' cannot be opened\n", file_name); + REprintf( "ERROR: file '%s' cannot be opened\n", file_name); return FALSE; } fclose(file); @@ -117,14 +117,14 @@ BOOL LASreaderBuffered::add_neighbor_file_name(const char* file_name) // do we have a file name if (file_name == 0) { - fprintf(stderr, "ERROR: file name pointer is NULL\n"); + REprintf( "ERROR: file name pointer is NULL\n"); return FALSE; } // does the file exist FILE* file = fopen(file_name, "r"); if (file == 0) { - fprintf(stderr, "ERROR: file '%s' cannot be opened\n", file_name); + REprintf( "ERROR: file '%s' cannot be opened\n", file_name); return FALSE; } fclose(file); @@ -142,7 +142,7 @@ BOOL LASreaderBuffered::open() { if (!lasreadopener.active()) { - fprintf(stderr, "ERROR: no input name\n"); + REprintf( "ERROR: no input name\n"); return FALSE; } @@ -151,7 +151,7 @@ BOOL LASreaderBuffered::open() lasreader = lasreadopener.open(); if (lasreader == 0) { - fprintf(stderr, "ERROR: opening '%s'\n", lasreadopener.get_file_name()); + REprintf( "ERROR: opening '%s'\n", lasreadopener.get_file_name()); return FALSE; } @@ -204,20 +204,20 @@ BOOL LASreaderBuffered::open() LASreader* lasreader_neighbor = lasreadopener_neighbors.open(); if (lasreader_neighbor == 0) { - fprintf(stderr, "ERROR: opening neighbor '%s'\n", lasreadopener_neighbors.get_file_name()); + REprintf( "ERROR: opening neighbor '%s'\n", lasreadopener_neighbors.get_file_name()); return FALSE; } // a point type change could be problematic if (header.point_data_format != lasreader_neighbor->header.point_data_format) { - if (!point_type_change) fprintf(stderr, "WARNING: files have different point types: %d vs %d\n", header.point_data_format, lasreader_neighbor->header.point_data_format); + if (!point_type_change) REprintf( "WARNING: files have different point types: %d vs %d\n", header.point_data_format, lasreader_neighbor->header.point_data_format); point_type_change = TRUE; } // a point size change could be problematic if (header.point_data_record_length != lasreader_neighbor->header.point_data_record_length) { - if (!point_size_change) fprintf(stderr, "WARNING: files have different point sizes: %d vs %d\n", header.point_data_record_length, lasreader_neighbor->header.point_data_record_length); + if (!point_size_change) REprintf( "WARNING: files have different point sizes: %d vs %d\n", header.point_data_record_length, lasreader_neighbor->header.point_data_record_length); point_size_change = TRUE; } @@ -271,7 +271,7 @@ BOOL LASreaderBuffered::open() header.extended_number_of_point_records += buffered_points; } - fprintf(stderr, "LASreaderBuffered: adding %u buffer points.\n", buffered_points); + REprintf( "LASreaderBuffered: adding %u buffer points.\n", buffered_points); } // check if the header can support the enlarged bounding box @@ -289,14 +289,14 @@ BOOL LASreaderBuffered::open() } if (header.x_scale_factor != x_scale_factor) { - fprintf(stderr, "WARNING: i changed x_scale_factor from %g to %g to accommodate enlarged bounding box\n", header.x_scale_factor, x_scale_factor); + REprintf( "WARNING: i changed x_scale_factor from %g to %g to accommodate enlarged bounding box\n", header.x_scale_factor, x_scale_factor); header.x_scale_factor = x_scale_factor; rescale = TRUE; } // maybe we changed the resolution ... so do we really need to adjuste the offset if ((((header.max_x - header.x_offset) / x_scale_factor) > I32_MAX) || (((header.min_x - header.x_offset) / x_scale_factor) < I32_MIN)) { - fprintf(stderr, "WARNING: i changed x_offset from %g to %g to accommodate enlarged bounding box\n", header.x_offset, x_offset); + REprintf( "WARNING: i changed x_offset from %g to %g to accommodate enlarged bounding box\n", header.x_offset, x_offset); header.x_offset = x_offset; reoffset = TRUE; } @@ -315,14 +315,14 @@ BOOL LASreaderBuffered::open() } if (header.y_scale_factor != y_scale_factor) { - fprintf(stderr, "WARNING: i changed y_scale_factor from %g to %g to accommodate enlarged bounding box\n", header.y_scale_factor, y_scale_factor); + REprintf( "WARNING: i changed y_scale_factor from %g to %g to accommodate enlarged bounding box\n", header.y_scale_factor, y_scale_factor); header.y_scale_factor = y_scale_factor; rescale = TRUE; } // maybe we changed the resolution ... so do we really need to adjuste the offset if ((((header.max_y - header.y_offset) / y_scale_factor) > I32_MAX) || (((header.min_y - header.y_offset) / y_scale_factor) < I32_MIN)) { - fprintf(stderr, "WARNING: i changed y_offset from %g to %g to accommodate enlarged bounding box\n", header.y_offset, y_offset); + REprintf( "WARNING: i changed y_offset from %g to %g to accommodate enlarged bounding box\n", header.y_offset, y_offset); header.y_offset = y_offset; reoffset = TRUE; } @@ -341,14 +341,14 @@ BOOL LASreaderBuffered::open() } if (header.z_scale_factor != z_scale_factor) { - fprintf(stderr, "WARNING: i changed z_scale_factor from %g to %g to accommodate enlarged bounding box\n", header.z_scale_factor, z_scale_factor); + REprintf( "WARNING: i changed z_scale_factor from %g to %g to accommodate enlarged bounding box\n", header.z_scale_factor, z_scale_factor); header.z_scale_factor = z_scale_factor; rescale = TRUE; } // maybe we changed the resolution ... so do we really need to adjuste the offset if ((((header.max_z - header.z_offset) / z_scale_factor) > I32_MAX) || (((header.min_z - header.z_offset) / z_scale_factor) < I32_MIN)) { - fprintf(stderr, "WARNING: i changed z_offset from %g to %g to accommodate enlarged bounding box\n", header.z_offset, z_offset); + REprintf( "WARNING: i changed z_offset from %g to %g to accommodate enlarged bounding box\n", header.z_offset, z_offset); header.z_offset = z_offset; reoffset = TRUE; } diff --git a/src/LASlib/lasreadermerged.cpp b/src/LASlib/lasreadermerged.cpp index 09f0e17..08ea47c 100644 --- a/src/LASlib/lasreadermerged.cpp +++ b/src/LASlib/lasreadermerged.cpp @@ -47,14 +47,14 @@ BOOL LASreaderMerged::add_file_name(const CHAR* file_name) // do we have a file name if (file_name == 0) { - fprintf(stderr, "ERROR: file name pointer is NULL\n"); + REprintf( "ERROR: file name pointer is NULL\n"); return FALSE; } // does the file exist FILE* file = fopen(file_name, "r"); if (file == 0) { - fprintf(stderr, "ERROR: file '%s' cannot be opened\n", file_name); + REprintf( "ERROR: file '%s' cannot be opened\n", file_name); return FALSE; } fclose(file); @@ -63,42 +63,42 @@ BOOL LASreaderMerged::add_file_name(const CHAR* file_name) { if (lasreaderbin) { - fprintf(stderr, "ERROR: cannot mix BIN with LAS. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix BIN with LAS. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadershp) { - fprintf(stderr, "ERROR: cannot mix SHP with LAS. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix SHP with LAS. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderasc) { - fprintf(stderr, "ERROR: cannot mix ASC with LAS. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix ASC with LAS. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbil) { - fprintf(stderr, "ERROR: cannot mix BIL with LAS. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix BIL with LAS. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderdtm) { - fprintf(stderr, "ERROR: cannot mix DTM with LAS. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix DTM with LAS. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderply) { - fprintf(stderr, "ERROR: cannot mix PLY with LAS. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix PLY with LAS. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderqfit) { - fprintf(stderr, "ERROR: cannot mix QFIT with LAS. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix QFIT with LAS. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadertxt) { - fprintf(stderr, "ERROR: cannot mix TXT with LAS. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix TXT with LAS. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderlas == 0) @@ -110,42 +110,42 @@ BOOL LASreaderMerged::add_file_name(const CHAR* file_name) { if (lasreaderlas) { - fprintf(stderr, "ERROR: cannot mix LAS with BIN. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix LAS with BIN. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadershp) { - fprintf(stderr, "ERROR: cannot mix SHP with BIN. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix SHP with BIN. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderasc) { - fprintf(stderr, "ERROR: cannot mix ASC with BIN. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix ASC with BIN. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbil) { - fprintf(stderr, "ERROR: cannot mix BIL with BIN. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix BIL with BIN. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderdtm) { - fprintf(stderr, "ERROR: cannot mix DTM with BIN. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix DTM with BIN. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderply) { - fprintf(stderr, "ERROR: cannot mix PLY with BIN. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix PLY with BIN. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderqfit) { - fprintf(stderr, "ERROR: cannot mix QFIT with BIN. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix QFIT with BIN. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadertxt) { - fprintf(stderr, "ERROR: cannot mix TXT with BIN. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix TXT with BIN. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbin == 0) @@ -157,42 +157,42 @@ BOOL LASreaderMerged::add_file_name(const CHAR* file_name) { if (lasreaderlas) { - fprintf(stderr, "ERROR: cannot mix LAS with SHP. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix LAS with SHP. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbin) { - fprintf(stderr, "ERROR: cannot mix BIN with SHP. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix BIN with SHP. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderasc) { - fprintf(stderr, "ERROR: cannot mix ASC with SHP. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix ASC with SHP. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbil) { - fprintf(stderr, "ERROR: cannot mix BIL with SHP. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix BIL with SHP. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderdtm) { - fprintf(stderr, "ERROR: cannot mix DTM with SHP. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix DTM with SHP. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderply) { - fprintf(stderr, "ERROR: cannot mix PLY with SHP. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix PLY with SHP. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderqfit) { - fprintf(stderr, "ERROR: cannot mix QFIT with SHP. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix QFIT with SHP. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadertxt) { - fprintf(stderr, "ERROR: cannot mix TXT with SHP. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix TXT with SHP. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadershp == 0) @@ -204,42 +204,42 @@ BOOL LASreaderMerged::add_file_name(const CHAR* file_name) { if (lasreaderlas) { - fprintf(stderr, "ERROR: cannot mix LAS with ASC. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix LAS with ASC. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbin) { - fprintf(stderr, "ERROR: cannot mix BIN with ASC. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix BIN with ASC. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadershp) { - fprintf(stderr, "ERROR: cannot mix SHP with ASC. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix SHP with ASC. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbil) { - fprintf(stderr, "ERROR: cannot mix BIL with ASC. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix BIL with ASC. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderdtm) { - fprintf(stderr, "ERROR: cannot mix DTM with ASC. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix DTM with ASC. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderply) { - fprintf(stderr, "ERROR: cannot mix PLY with ASC. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix PLY with ASC. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderqfit) { - fprintf(stderr, "ERROR: cannot mix QFIT with ASC. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix QFIT with ASC. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadertxt) { - fprintf(stderr, "ERROR: cannot mix TXT with ASC. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix TXT with ASC. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderasc == 0) @@ -251,42 +251,42 @@ BOOL LASreaderMerged::add_file_name(const CHAR* file_name) { if (lasreaderlas) { - fprintf(stderr, "ERROR: cannot mix LAS with BIL. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix LAS with BIL. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbin) { - fprintf(stderr, "ERROR: cannot mix BIN with BIL. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix BIN with BIL. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadershp) { - fprintf(stderr, "ERROR: cannot mix SHP with BIL. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix SHP with BIL. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderdtm) { - fprintf(stderr, "ERROR: cannot mix DTM with BIL. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix DTM with BIL. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderasc) { - fprintf(stderr, "ERROR: cannot mix ASC with BIL. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix ASC with BIL. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderply) { - fprintf(stderr, "ERROR: cannot mix PLY with BIL. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix PLY with BIL. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderqfit) { - fprintf(stderr, "ERROR: cannot mix QFIT with BIL. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix QFIT with BIL. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadertxt) { - fprintf(stderr, "ERROR: cannot mix TXT with BIL. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix TXT with BIL. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbil == 0) @@ -298,42 +298,42 @@ BOOL LASreaderMerged::add_file_name(const CHAR* file_name) { if (lasreaderlas) { - fprintf(stderr, "ERROR: cannot mix LAS with DTM. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix LAS with DTM. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbin) { - fprintf(stderr, "ERROR: cannot mix BIN with DTM. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix BIN with DTM. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadershp) { - fprintf(stderr, "ERROR: cannot mix SHP with DTM. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix SHP with DTM. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbil) { - fprintf(stderr, "ERROR: cannot mix BIL with DTM. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix BIL with DTM. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderasc) { - fprintf(stderr, "ERROR: cannot mix ASC with DTM. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix ASC with DTM. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderply) { - fprintf(stderr, "ERROR: cannot mix PLY with DTM. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix PLY with DTM. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderqfit) { - fprintf(stderr, "ERROR: cannot mix QFIT with DTM. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix QFIT with DTM. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadertxt) { - fprintf(stderr, "ERROR: cannot mix TXT with DTM. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix TXT with DTM. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderdtm == 0) @@ -345,42 +345,42 @@ BOOL LASreaderMerged::add_file_name(const CHAR* file_name) { if (lasreaderlas) { - fprintf(stderr, "ERROR: cannot mix LAS with PLY. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix LAS with PLY. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbin) { - fprintf(stderr, "ERROR: cannot mix BIN with PLY. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix BIN with PLY. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadershp) { - fprintf(stderr, "ERROR: cannot mix SHP with PLY. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix SHP with PLY. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderasc) { - fprintf(stderr, "ERROR: cannot mix ASC with PLY. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix ASC with PLY. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbil) { - fprintf(stderr, "ERROR: cannot mix BIL with PLY. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix BIL with PLY. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderdtm) { - fprintf(stderr, "ERROR: cannot mix DTM with PLY. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix DTM with PLY. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderqfit) { - fprintf(stderr, "ERROR: cannot mix QFIT with PLY. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix QFIT with PLY. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadertxt) { - fprintf(stderr, "ERROR: cannot mix TXT with PLY. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix TXT with PLY. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderply == 0) @@ -392,42 +392,42 @@ BOOL LASreaderMerged::add_file_name(const CHAR* file_name) { if (lasreaderlas) { - fprintf(stderr, "ERROR: cannot mix LAS with QFIT. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix LAS with QFIT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbin) { - fprintf(stderr, "ERROR: cannot mix BIN with QFIT. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix BIN with QFIT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadershp) { - fprintf(stderr, "ERROR: cannot mix SHP with QFIT. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix SHP with QFIT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderasc) { - fprintf(stderr, "ERROR: cannot mix ASC with QFIT. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix ASC with QFIT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbil) { - fprintf(stderr, "ERROR: cannot mix BIL with QFIT. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix BIL with QFIT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderdtm) { - fprintf(stderr, "ERROR: cannot mix DTM with QFIT. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix DTM with QFIT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderply) { - fprintf(stderr, "ERROR: cannot mix PLY with QFIT. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix PLY with QFIT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadertxt) { - fprintf(stderr, "ERROR: cannot mix TXT with QFIT. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix TXT with QFIT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderqfit == 0) @@ -439,42 +439,42 @@ BOOL LASreaderMerged::add_file_name(const CHAR* file_name) { if (lasreaderlas) { - fprintf(stderr, "ERROR: cannot mix LAS with TXT. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix LAS with TXT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbin) { - fprintf(stderr, "ERROR: cannot mix BIN with TXT. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix BIN with TXT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadershp) { - fprintf(stderr, "ERROR: cannot mix SHP with TXT. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix SHP with TXT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderasc) { - fprintf(stderr, "ERROR: cannot mix ASC with TXT. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix ASC with TXT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderbil) { - fprintf(stderr, "ERROR: cannot mix BIL with TXT. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix BIL with TXT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderdtm) { - fprintf(stderr, "ERROR: cannot mix DTM with TXT. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix DTM with TXT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderply) { - fprintf(stderr, "ERROR: cannot mix PLY with TXT. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix PLY with TXT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreaderqfit) { - fprintf(stderr, "ERROR: cannot mix QFIT with TXT. skipping '%s' ...\n", file_name); + REprintf( "ERROR: cannot mix QFIT with TXT. skipping '%s' ...\n", file_name); return FALSE; } if (lasreadertxt == 0) @@ -494,7 +494,7 @@ BOOL LASreaderMerged::add_file_name(const CHAR* file_name) file_names_ID = (U32*)realloc(file_names_ID, sizeof(U32)*file_name_allocated); if (file_names_ID == 0) { - fprintf(stderr, "ERROR: alloc for file_names_ID array failed at %d\n", file_name_allocated); + REprintf( "ERROR: alloc for file_names_ID array failed at %d\n", file_name_allocated); return FALSE; } } @@ -505,7 +505,7 @@ BOOL LASreaderMerged::add_file_name(const CHAR* file_name) } if (file_names == 0) { - fprintf(stderr, "ERROR: alloc for file_names pointer array failed at %d\n", file_name_allocated); + REprintf( "ERROR: alloc for file_names pointer array failed at %d\n", file_name_allocated); return FALSE; } } @@ -523,7 +523,7 @@ BOOL LASreaderMerged::add_file_name(const CHAR* file_name, U32 ID) file_names_ID = (U32*)malloc(sizeof(U32)*file_name_allocated); if (file_names_ID == 0) { - fprintf(stderr, "ERROR: alloc for file_names_ID array failed at %d\n", file_name_allocated); + REprintf( "ERROR: alloc for file_names_ID array failed at %d\n", file_name_allocated); return FALSE; } } @@ -637,7 +637,7 @@ BOOL LASreaderMerged::open() { if (file_name_number == 0) { - fprintf(stderr, "ERROR: no valid file names\n"); + REprintf( "ERROR: no valid file names\n"); return FALSE; } @@ -661,7 +661,7 @@ BOOL LASreaderMerged::open() { if (!lasreaderlas->open(file_names[i], 512, (first == FALSE) && (attributes == FALSE))) // starting from second just "peek" into file to get bounding box and count { - fprintf(stderr, "ERROR: could not open lasreaderlas for file '%s'\n", file_names[i]); + REprintf( "ERROR: could not open lasreaderlas for file '%s'\n", file_names[i]); return FALSE; } } @@ -669,7 +669,7 @@ BOOL LASreaderMerged::open() { if (!lasreaderbin->open(file_names[i])) { - fprintf(stderr, "ERROR: could not open lasreaderbin for file '%s'\n", file_names[i]); + REprintf( "ERROR: could not open lasreaderbin for file '%s'\n", file_names[i]); return FALSE; } } @@ -677,7 +677,7 @@ BOOL LASreaderMerged::open() { if (!lasreadershp->open(file_names[i])) { - fprintf(stderr, "ERROR: could not open lasreadershp for file '%s'\n", file_names[i]); + REprintf( "ERROR: could not open lasreadershp for file '%s'\n", file_names[i]); return FALSE; } } @@ -685,7 +685,7 @@ BOOL LASreaderMerged::open() { if (!lasreaderasc->open(file_names[i])) { - fprintf(stderr, "ERROR: could not open lasreaderasc for file '%s'\n", file_names[i]); + REprintf( "ERROR: could not open lasreaderasc for file '%s'\n", file_names[i]); return FALSE; } } @@ -693,7 +693,7 @@ BOOL LASreaderMerged::open() { if (!lasreaderbil->open(file_names[i])) { - fprintf(stderr, "ERROR: could not open lasreaderbil for file '%s'\n", file_names[i]); + REprintf( "ERROR: could not open lasreaderbil for file '%s'\n", file_names[i]); return FALSE; } } @@ -701,7 +701,7 @@ BOOL LASreaderMerged::open() { if (!lasreaderdtm->open(file_names[i])) { - fprintf(stderr, "ERROR: could not open lasreaderdtm for file '%s'\n", file_names[i]); + REprintf( "ERROR: could not open lasreaderdtm for file '%s'\n", file_names[i]); return FALSE; } } @@ -709,7 +709,7 @@ BOOL LASreaderMerged::open() { if (!lasreaderply->open(file_names[i])) { - fprintf(stderr, "ERROR: could not open lasreaderply for file '%s'\n", file_names[i]); + REprintf( "ERROR: could not open lasreaderply for file '%s'\n", file_names[i]); return FALSE; } } @@ -717,7 +717,7 @@ BOOL LASreaderMerged::open() { if (!lasreaderqfit->open(file_names[i])) { - fprintf(stderr, "ERROR: could not open lasreaderqfit for file '%s'\n", file_names[i]); + REprintf( "ERROR: could not open lasreaderqfit for file '%s'\n", file_names[i]); return FALSE; } } @@ -731,7 +731,7 @@ BOOL LASreaderMerged::open() lasreadertxt->set_offset(offset); if (!lasreadertxt->open(file_names[i], 0, parse_string, skip_lines, populate_header)) { - fprintf(stderr, "ERROR: could not open lasreadertxt for file '%s'\n", file_names[i]); + REprintf( "ERROR: could not open lasreadertxt for file '%s'\n", file_names[i]); return FALSE; } } @@ -761,7 +761,7 @@ BOOL LASreaderMerged::open() { if (lasreader->header.vlr_lastiling->buffer) { - fprintf(stderr, "WARNING: first file is a buffered tile. maybe remove buffers first?\n"); + REprintf( "WARNING: first file is a buffered tile. maybe remove buffers first?\n"); } } // maybe we should keep the tiling @@ -769,7 +769,7 @@ BOOL LASreaderMerged::open() { if (lasreader->header.vlr_lastiling == 0) { - fprintf(stderr, "WARNING: first file has no LAStiling VLR cannot '-keep_lastiling' ...\n"); + REprintf( "WARNING: first file has no LAStiling VLR cannot '-keep_lastiling' ...\n"); } } else @@ -884,32 +884,32 @@ BOOL LASreaderMerged::open() header.y_scale_factor != lasreader->header.y_scale_factor || header.z_scale_factor != lasreader->header.z_scale_factor) { - // if (!rescale) fprintf(stderr, "WARNING: files have different scale factors: %g %g %g vs %g %g %g\n", header.x_scale_factor, header.y_scale_factor, header.z_scale_factor, lasreader->header.x_scale_factor, lasreader->header.y_scale_factor, lasreader->header.z_scale_factor); + // if (!rescale) REprintf( "WARNING: files have different scale factors: %g %g %g vs %g %g %g\n", header.x_scale_factor, header.y_scale_factor, header.z_scale_factor, lasreader->header.x_scale_factor, lasreader->header.y_scale_factor, lasreader->header.z_scale_factor); rescale = TRUE; } if (header.x_offset != lasreader->header.x_offset || header.y_offset != lasreader->header.y_offset || header.z_offset != lasreader->header.z_offset) { - // if (!reoffset) fprintf(stderr, "WARNING: files have different offsets: %g %g %g vs %g %g %g\n", header.x_offset, header.y_offset, header.z_offset, lasreader->header.x_offset, lasreader->header.y_offset, lasreader->header.z_offset); + // if (!reoffset) REprintf( "WARNING: files have different offsets: %g %g %g vs %g %g %g\n", header.x_offset, header.y_offset, header.z_offset, lasreader->header.x_offset, lasreader->header.y_offset, lasreader->header.z_offset); reoffset = TRUE; } // a point type change could be problematic if (header.point_data_format != lasreader->header.point_data_format) { - if (!point_type_change) fprintf(stderr, "WARNING: files have different point types: %d vs %d\n", header.point_data_format, lasreader->header.point_data_format); + if (!point_type_change) REprintf( "WARNING: files have different point types: %d vs %d\n", header.point_data_format, lasreader->header.point_data_format); point_type_change = TRUE; } // a point size change could be problematic if (header.point_data_record_length != lasreader->header.point_data_record_length) { - if (!point_size_change) fprintf(stderr, "WARNING: files have different point sizes: %d vs %d\n", header.point_data_record_length, lasreader->header.point_data_record_length); + if (!point_size_change) REprintf( "WARNING: files have different point sizes: %d vs %d\n", header.point_data_record_length, lasreader->header.point_data_record_length); point_size_change = TRUE; } // a change in additional attributes (in the extra bytes) could be problematic if (header.number_attributes != lasreader->header.number_attributes) { - if (!additional_attribute_change) fprintf(stderr, "WARNING: files have different number of attributes: %d vs %d\n", header.number_attributes, lasreader->header.number_attributes); + if (!additional_attribute_change) REprintf( "WARNING: files have different number of attributes: %d vs %d\n", header.number_attributes, lasreader->header.number_attributes); additional_attribute_change = TRUE; } else if (header.number_attributes) @@ -918,7 +918,7 @@ BOOL LASreaderMerged::open() { if (memcmp((const void*)&(header.attributes[j]), (const void*)&(lasreader->header.attributes[j]), 192)) { - if (!additional_attribute_change) fprintf(stderr, "WARNING: files have different attribute %d\n", j); + if (!additional_attribute_change) REprintf( "WARNING: files have different attribute %d\n", j); additional_attribute_change = TRUE; } } @@ -933,9 +933,9 @@ BOOL LASreaderMerged::open() if (0) // (auto_upgrade) { #ifdef _WIN32 - fprintf(stderr,"WARNING: on-the-fly merged LAS 1.%d files contain too many points (%I64d). upgrading to LAS 1.4\n", header.version_minor, npoints); + REprintf("WARNING: on-the-fly merged LAS 1.%d files contain too many points (%I64d). upgrading to LAS 1.4\n", header.version_minor, npoints); #else - fprintf(stderr,"WARNING: on-the-fly merged LAS 1.%d files contain too many points (%lld). upgrading to LAS 1.4\n", header.version_minor, npoints); + REprintf("WARNING: on-the-fly merged LAS 1.%d files contain too many points (%lld). upgrading to LAS 1.4\n", header.version_minor, npoints); #endif if (header.version_minor == 3) { @@ -952,9 +952,9 @@ BOOL LASreaderMerged::open() else { #ifdef _WIN32 - fprintf(stderr,"WARNING: on-the-fly merged LAS 1.%d files contain too many points (%I64d) for single LAS 1.%d file.\n", header.version_minor, npoints, header.version_minor); + REprintf("WARNING: on-the-fly merged LAS 1.%d files contain too many points (%I64d) for single LAS 1.%d file.\n", header.version_minor, npoints, header.version_minor); #else - fprintf(stderr,"WARNING: on-the-fly merged LAS 1.%d files contain too many points (%lld) for single LAS 1.%d file.\n", header.version_minor, npoints, header.version_minor); + REprintf("WARNING: on-the-fly merged LAS 1.%d files contain too many points (%lld) for single LAS 1.%d file.\n", header.version_minor, npoints, header.version_minor); #endif } } @@ -1024,14 +1024,14 @@ BOOL LASreaderMerged::open() } if (header.x_scale_factor != x_scale_factor) { - fprintf(stderr, "WARNING: i changed x_scale_factor from %g to %g to accommodate enlarged bounding box\n", header.x_scale_factor, x_scale_factor); + REprintf( "WARNING: i changed x_scale_factor from %g to %g to accommodate enlarged bounding box\n", header.x_scale_factor, x_scale_factor); header.x_scale_factor = x_scale_factor; rescale = TRUE; } // maybe we changed the resolution ... so do we really need to adjuste the offset if ((((header.max_x - header.x_offset) / x_scale_factor) > I32_MAX) || (((header.min_x - header.x_offset) / x_scale_factor) < I32_MIN)) { - fprintf(stderr, "WARNING: i changed x_offset from %g to %g to accommodate enlarged bounding box\n", header.x_offset, x_offset); + REprintf( "WARNING: i changed x_offset from %g to %g to accommodate enlarged bounding box\n", header.x_offset, x_offset); header.x_offset = x_offset; reoffset = TRUE; } @@ -1050,14 +1050,14 @@ BOOL LASreaderMerged::open() } if (header.y_scale_factor != y_scale_factor) { - fprintf(stderr, "WARNING: i changed y_scale_factor from %g to %g to accommodate enlarged bounding box\n", header.y_scale_factor, y_scale_factor); + REprintf( "WARNING: i changed y_scale_factor from %g to %g to accommodate enlarged bounding box\n", header.y_scale_factor, y_scale_factor); header.y_scale_factor = y_scale_factor; rescale = TRUE; } // maybe we changed the resolution ... so do we really need to adjuste the offset if ((((header.max_y - header.y_offset) / y_scale_factor) > I32_MAX) || (((header.min_y - header.y_offset) / y_scale_factor) < I32_MIN)) { - fprintf(stderr, "WARNING: i changed y_offset from %g to %g to accommodate enlarged bounding box\n", header.y_offset, y_offset); + REprintf( "WARNING: i changed y_offset from %g to %g to accommodate enlarged bounding box\n", header.y_offset, y_offset); header.y_offset = y_offset; reoffset = TRUE; } @@ -1076,14 +1076,14 @@ BOOL LASreaderMerged::open() } if (header.z_scale_factor != z_scale_factor) { - fprintf(stderr, "WARNING: i changed z_scale_factor from %g to %g to accommodate enlarged bounding box\n", header.z_scale_factor, z_scale_factor); + REprintf( "WARNING: i changed z_scale_factor from %g to %g to accommodate enlarged bounding box\n", header.z_scale_factor, z_scale_factor); header.z_scale_factor = z_scale_factor; rescale = TRUE; } // maybe we changed the resolution ... so do we really need to adjuste the offset if ((((header.max_z - header.z_offset) / z_scale_factor) > I32_MAX) || (((header.min_z - header.z_offset) / z_scale_factor) < I32_MIN)) { - fprintf(stderr, "WARNING: i changed z_offset from %g to %g to accommodate enlarged bounding box\n", header.z_offset, z_offset); + REprintf( "WARNING: i changed z_offset from %g to %g to accommodate enlarged bounding box\n", header.z_offset, z_offset); header.z_offset = z_offset; reoffset = TRUE; } @@ -1494,7 +1494,7 @@ BOOL LASreaderMerged::open_next_file() { if (!lasreaderlas->open(file_names[file_name_current], io_ibuffer_size)) { - fprintf(stderr, "ERROR: could not open lasreaderlas for file '%s'\n", file_names[file_name_current]); + REprintf( "ERROR: could not open lasreaderlas for file '%s'\n", file_names[file_name_current]); return FALSE; } LASindex* index = new LASindex; @@ -1507,7 +1507,7 @@ BOOL LASreaderMerged::open_next_file() { if (!lasreaderbin->open(file_names[file_name_current])) { - fprintf(stderr, "ERROR: could not open lasreaderbin for file '%s'\n", file_names[file_name_current]); + REprintf( "ERROR: could not open lasreaderbin for file '%s'\n", file_names[file_name_current]); return FALSE; } LASindex* index = new LASindex; @@ -1520,7 +1520,7 @@ BOOL LASreaderMerged::open_next_file() { if (!lasreadershp->open(file_names[file_name_current])) { - fprintf(stderr, "ERROR: could not open lasreadershp for file '%s'\n", file_names[file_name_current]); + REprintf( "ERROR: could not open lasreadershp for file '%s'\n", file_names[file_name_current]); return FALSE; } } @@ -1528,7 +1528,7 @@ BOOL LASreaderMerged::open_next_file() { if (!lasreaderasc->open(file_names[file_name_current])) { - fprintf(stderr, "ERROR: could not open lasreaderasc for file '%s'\n", file_names[file_name_current]); + REprintf( "ERROR: could not open lasreaderasc for file '%s'\n", file_names[file_name_current]); return FALSE; } } @@ -1536,7 +1536,7 @@ BOOL LASreaderMerged::open_next_file() { if (!lasreaderbil->open(file_names[file_name_current])) { - fprintf(stderr, "ERROR: could not open lasreaderbil for file '%s'\n", file_names[file_name_current]); + REprintf( "ERROR: could not open lasreaderbil for file '%s'\n", file_names[file_name_current]); return FALSE; } LASindex* index = new LASindex; @@ -1549,7 +1549,7 @@ BOOL LASreaderMerged::open_next_file() { if (!lasreaderdtm->open(file_names[file_name_current])) { - fprintf(stderr, "ERROR: could not open lasreaderdtm for file '%s'\n", file_names[file_name_current]); + REprintf( "ERROR: could not open lasreaderdtm for file '%s'\n", file_names[file_name_current]); return FALSE; } LASindex* index = new LASindex; @@ -1562,7 +1562,7 @@ BOOL LASreaderMerged::open_next_file() { if (!lasreaderply->open(file_names[file_name_current])) { - fprintf(stderr, "ERROR: could not open lasreaderply for file '%s'\n", file_names[file_name_current]); + REprintf( "ERROR: could not open lasreaderply for file '%s'\n", file_names[file_name_current]); return FALSE; } LASindex* index = new LASindex; @@ -1575,7 +1575,7 @@ BOOL LASreaderMerged::open_next_file() { if (!lasreaderqfit->open(file_names[file_name_current])) { - fprintf(stderr, "ERROR: could not open lasreaderqfit for file '%s'\n", file_names[file_name_current]); + REprintf( "ERROR: could not open lasreaderqfit for file '%s'\n", file_names[file_name_current]); return FALSE; } LASindex* index = new LASindex; @@ -1588,7 +1588,7 @@ BOOL LASreaderMerged::open_next_file() { if (!lasreadertxt->open(file_names[file_name_current], 0, parse_string, skip_lines, populate_header)) { - fprintf(stderr, "ERROR: could not open lasreadertxt for file '%s'\n", file_names[file_name_current]); + REprintf( "ERROR: could not open lasreadertxt for file '%s'\n", file_names[file_name_current]); return FALSE; } } diff --git a/src/LASlib/lasreaderpipeon.cpp b/src/LASlib/lasreaderpipeon.cpp index bd7715b..329eab2 100644 --- a/src/LASlib/lasreaderpipeon.cpp +++ b/src/LASlib/lasreaderpipeon.cpp @@ -43,7 +43,7 @@ BOOL LASreaderPipeOn::open(LASreader* lasreader) { if (lasreader == 0) { - fprintf(stderr, "ERROR: no lasreader\n"); + REprintf( "ERROR: no lasreader\n"); return FALSE; } @@ -89,14 +89,14 @@ BOOL LASreaderPipeOn::open(LASreader* lasreader) if (laswriterlas == 0) { - fprintf(stderr, "ERROR: allocating laswriterlas\n"); + REprintf( "ERROR: allocating laswriterlas\n"); return FALSE; } if (!laswriterlas->open(stdout, &header)) { delete laswriterlas; - fprintf(stderr, "ERROR: opening laswriterlas to stdout\n"); + REprintf( "ERROR: opening laswriterlas to stdout\n"); return FALSE; } diff --git a/src/LASlib/lasreaderstored.cpp b/src/LASlib/lasreaderstored.cpp index 743e3e4..f619701 100644 --- a/src/LASlib/lasreaderstored.cpp +++ b/src/LASlib/lasreaderstored.cpp @@ -44,7 +44,7 @@ BOOL LASreaderStored::open(LASreader* lasreader) { if (lasreader == 0) { - fprintf(stderr, "ERROR: no lasreader\n"); + REprintf( "ERROR: no lasreader\n"); return FALSE; } @@ -88,7 +88,7 @@ BOOL LASreaderStored::open(LASreader* lasreader) if (streamoutarray == 0) { - fprintf(stderr, "ERROR: allocating streamoutarray\n"); + REprintf( "ERROR: allocating streamoutarray\n"); return FALSE; } @@ -101,7 +101,7 @@ BOOL LASreaderStored::open(LASreader* lasreader) if (laswriterlas == 0) { - fprintf(stderr, "ERROR: allocating laswriterlas\n"); + REprintf( "ERROR: allocating laswriterlas\n"); return FALSE; } @@ -109,7 +109,7 @@ BOOL LASreaderStored::open(LASreader* lasreader) { delete laswriterlas; laswriterlas = 0; - fprintf(stderr, "ERROR: opening laswriterlas to streamoutarray\n"); + REprintf( "ERROR: opening laswriterlas to streamoutarray\n"); return FALSE; } @@ -133,13 +133,13 @@ BOOL LASreaderStored::reopen() { if (streamoutarray == 0) { - fprintf(stderr, "ERROR: no streamoutarray\n"); + REprintf( "ERROR: no streamoutarray\n"); return FALSE; } if (streamoutarray->getSize() == 0) { - fprintf(stderr, "ERROR: nothing stored in streamoutarray\n"); + REprintf( "ERROR: nothing stored in streamoutarray\n"); return FALSE; } @@ -150,7 +150,7 @@ BOOL LASreaderStored::reopen() if (streaminarray == 0) { - fprintf(stderr, "ERROR: creating streaminarray\n"); + REprintf( "ERROR: creating streaminarray\n"); return FALSE; } } @@ -164,7 +164,7 @@ BOOL LASreaderStored::reopen() if (lasreaderlas == 0) { - fprintf(stderr, "ERROR: allocating lasreaderlas\n"); + REprintf( "ERROR: allocating lasreaderlas\n"); return FALSE; } @@ -172,7 +172,7 @@ BOOL LASreaderStored::reopen() { delete lasreaderlas; lasreaderlas = 0; - fprintf(stderr, "ERROR: opening lasreaderlas from streaminarray\n"); + REprintf( "ERROR: opening lasreaderlas from streaminarray\n"); return FALSE; } diff --git a/src/LASlib/lastransform.cpp b/src/LASlib/lastransform.cpp index 2cad3d2..73adcea 100644 --- a/src/LASlib/lastransform.cpp +++ b/src/LASlib/lastransform.cpp @@ -2523,9 +2523,9 @@ void LAStransform::check_for_overflow() const CHAR command[256]; operations[i]->get_command(command); #ifdef _WIN32 - fprintf(stderr, "WARNING: total of %I64d overflows caused by '%s'\n", operations[i]->get_overflow(), command); + REprintf( "WARNING: total of %I64d overflows caused by '%s'\n", operations[i]->get_overflow(), command); #else - fprintf(stderr, "WARNING: total of %lld overflows caused by '%s'\n", operations[i]->get_overflow(), command); + REprintf( "WARNING: total of %lld overflows caused by '%s'\n", operations[i]->get_overflow(), command); #endif } } @@ -2552,143 +2552,143 @@ void LAStransform::clean() void LAStransform::usage() const { - fprintf(stderr,"Transform coordinates.\n"); - fprintf(stderr," -translate_x -2.5\n"); - fprintf(stderr," -scale_z 0.3048\n"); - fprintf(stderr," -rotate_xy 15.0 620000 4100000 (angle + origin)\n"); - fprintf(stderr," -translate_xyz 0.5 0.5 0\n"); - fprintf(stderr," -translate_then_scale_y -0.5 1.001\n"); - fprintf(stderr," -transform_helmert -199.87,74.79,246.62\n"); - fprintf(stderr," -transform_helmert 598.1,73.7,418.2,0.202,0.045,-2.455,6.7\n"); - fprintf(stderr," -transform_affine 0.9999652,0.903571,171.67,736.26\n"); - fprintf(stderr," -switch_x_y -switch_x_z -switch_y_z\n"); - fprintf(stderr," -clamp_z_below 70.5\n"); - fprintf(stderr," -clamp_z 70.5 72.5\n"); - fprintf(stderr," -copy_attribute_into_z 0\n"); - fprintf(stderr," -add_attribute_to_z 1\n"); - fprintf(stderr," -add_scaled_attribute_to_z 1 -1.2\n"); - fprintf(stderr," -copy_intensity_into_z\n"); - fprintf(stderr," -copy_user_data_into_z\n"); - fprintf(stderr,"Transform raw xyz integers.\n"); - fprintf(stderr," -translate_raw_z 20\n"); - fprintf(stderr," -translate_raw_xyz 1 1 0\n"); - fprintf(stderr," -translate_raw_xy_at_random 2 2\n"); - fprintf(stderr," -clamp_raw_z 500 800\n"); - fprintf(stderr,"Transform intensity.\n"); - fprintf(stderr," -set_intensity 0\n"); - fprintf(stderr," -scale_intensity 2.5\n"); - fprintf(stderr," -translate_intensity 50\n"); - fprintf(stderr," -translate_then_scale_intensity 0.5 3.1\n"); - fprintf(stderr," -clamp_intensity 0 255\n"); - fprintf(stderr," -clamp_intensity_above 255\n"); - fprintf(stderr," -map_intensity map_file.txt\n"); - fprintf(stderr," -copy_RGB_into_intensity\n"); - fprintf(stderr," -copy_NIR_into_intensity\n"); - fprintf(stderr," -copy_attribute_into_intensity 0\n"); - fprintf(stderr," -bin_gps_time_into_intensity 0.5\n"); - fprintf(stderr,"Transform scan_angle.\n"); - fprintf(stderr," -set_scan_angle 0.0\n"); - fprintf(stderr," -scale_scan_angle 1.944445\n"); - fprintf(stderr," -translate_scan_angle -5\n"); - fprintf(stderr," -translate_then_scale_scan_angle -0.5 2.1\n"); - fprintf(stderr,"Change the return number or return count of points.\n"); - fprintf(stderr," -repair_zero_returns\n"); - fprintf(stderr," -set_return_number 1\n"); - fprintf(stderr," -set_extended_return_number 10\n"); - fprintf(stderr," -change_return_number_from_to 2 1\n"); - fprintf(stderr," -change_extended_return_number_from_to 2 8\n"); - fprintf(stderr," -set_number_of_returns 2\n"); - fprintf(stderr," -set_extended_number_of_returns 15\n"); - fprintf(stderr," -change_number_of_returns_from_to 0 2\n"); - fprintf(stderr," -change_extended_number_of_returns_from_to 8 10\n"); - fprintf(stderr,"Modify the classification.\n"); - fprintf(stderr," -set_classification 2\n"); - fprintf(stderr," -set_extended_classification 41\n"); - fprintf(stderr," -change_classification_from_to 2 4\n"); - fprintf(stderr," -classify_z_below_as -5.0 7\n"); - fprintf(stderr," -classify_z_above_as 70.0 7\n"); - fprintf(stderr," -classify_z_between_as 2.0 5.0 4\n"); - fprintf(stderr," -classify_intensity_above_as 200 9\n"); - fprintf(stderr," -classify_intensity_below_as 30 11 \n"); - fprintf(stderr," -classify_intensity_between_as 500 900 15\n"); - fprintf(stderr," -classify_attribute_below_as 0 -5.0 7\n"); - fprintf(stderr," -classify_attribute_above_as 1 70.0 7\n"); - fprintf(stderr," -classify_attribute_between_as 1 2.0 5.0 4\n"); - fprintf(stderr," -change_extended_classification_from_to 6 46\n"); - fprintf(stderr," -move_ancient_to_extended_classification\n"); - fprintf(stderr," -copy_user_data_into_classification\n"); - fprintf(stderr,"Change the flags.\n"); - fprintf(stderr," -set_withheld_flag 0\n"); - fprintf(stderr," -set_synthetic_flag 1\n"); - fprintf(stderr," -set_keypoint_flag 0\n"); - fprintf(stderr," -set_overlap_flag 1\n"); - fprintf(stderr,"Modify the extended scanner channel.\n"); - fprintf(stderr," -set_scanner_channel 2\n"); - fprintf(stderr," -copy_user_data_into_scanner_channel\n"); - fprintf(stderr,"Modify the user data.\n"); - fprintf(stderr," -set_user_data 0\n"); - fprintf(stderr," -scale_user_data 1.5\n"); - fprintf(stderr," -change_user_data_from_to 23 26\n"); - fprintf(stderr," -change_user_data_from_to 23 26\n"); - fprintf(stderr," -map_user_data map_file.txt\n"); - fprintf(stderr," -copy_scanner_channel_into_user_data\n"); - fprintf(stderr," -copy_attribute_into_user_data 1\n"); - fprintf(stderr," -add_scaled_attribute_to_user_data 0 10.0\n"); - fprintf(stderr,"Modify the point source ID.\n"); - fprintf(stderr," -set_point_source 500\n"); - fprintf(stderr," -change_point_source_from_to 1023 1024\n"); - fprintf(stderr," -map_point_source map_file.txt\n"); - fprintf(stderr," -copy_user_data_into_point_source\n"); - fprintf(stderr," -copy_scanner_channel_into_point_source\n"); - fprintf(stderr," -copy_attribute_into_point_source 0\n"); - fprintf(stderr," -merge_scanner_channel_into_point_source\n"); - fprintf(stderr," -split_scanner_channel_from_point_source\n"); - fprintf(stderr," -bin_Z_into_point_source 200\n"); - fprintf(stderr," -bin_abs_scan_angle_into_point_source 2\n"); - fprintf(stderr," -bin_gps_time_into_point_source 5.0\n"); - fprintf(stderr,"Transform gps_time.\n"); - fprintf(stderr," -set_gps_time 113556962.005715\n"); - fprintf(stderr," -translate_gps_time 40.50\n"); - fprintf(stderr," -adjusted_to_week\n"); - fprintf(stderr," -week_to_adjusted 1671\n"); - fprintf(stderr,"Transform RGB/NIR colors.\n"); - fprintf(stderr," -set_RGB 255 0 127\n"); - fprintf(stderr," -set_RGB_of_class 9 0 0 255\n"); - fprintf(stderr," -scale_RGB 2 4 2\n"); - fprintf(stderr," -scale_RGB_down (by 256)\n"); - fprintf(stderr," -scale_RGB_up (by 256)\n"); - fprintf(stderr," -scale_RGB_to_8bit (only scales down 16 bit values)\n"); - fprintf(stderr," -scale_RGB_to_16bit (only scales up 8 bit values)\n"); - fprintf(stderr," -scale_NIR 2\n"); - fprintf(stderr," -scale_NIR_down (by 256)\n"); - fprintf(stderr," -scale_NIR_up (by 256)\n"); - fprintf(stderr," -scale_NIR_to_8bit (only scales down 16 bit values)\n"); - fprintf(stderr," -scale_NIR_to_16bit (only scales up 8 bit values)\n"); - fprintf(stderr," -switch_R_G -switch_R_B -switch_B_G\n"); - fprintf(stderr," -copy_R_into_NIR -copy_R_into_intensity\n"); - fprintf(stderr," -copy_G_into_NIR -copy_G_into_intensity\n"); - fprintf(stderr," -copy_B_into_NIR -copy_B_into_intensity\n"); - fprintf(stderr," -copy_intensity_into_NIR\n"); - fprintf(stderr," -switch_RGBI_into_CIR\n"); - fprintf(stderr," -switch_RGB_intensity_into_CIR\n"); - fprintf(stderr,"Transform attributes in \"Extra Bytes\".\n"); - fprintf(stderr," -scale_attribute 0 1.5\n"); - fprintf(stderr," -translate_attribute 1 0.2\n"); - fprintf(stderr," -copy_user_data_into_attribute 0\n"); - fprintf(stderr," -copy_z_into_attribute 0\n"); - fprintf(stderr," -map_attribute_into_RGB 0 map_height_to_RGB.txt\n"); - fprintf(stderr,"Transform using \"LASregisters\".\n"); - fprintf(stderr," -copy_attribute_into_register 0 0\n"); - fprintf(stderr," -scale_register 0 1.5\n"); - fprintf(stderr," -translate_register 1 10.7\n"); - fprintf(stderr," -add_registers 0 1 3\n"); - fprintf(stderr," -multiply_registers 0 1 2\n"); - fprintf(stderr," -copy_intensity_into_register 0\n"); - fprintf(stderr," -copy_R_into_register 1\n"); - fprintf(stderr," -copy_G_into_register 2\n"); - fprintf(stderr," -copy_B_into_register 3\n"); - fprintf(stderr," -copy_NIR_into_register 4\n"); - fprintf(stderr," -copy_register_into_intensity 1\n"); + REprintf("Transform coordinates.\n"); + REprintf(" -translate_x -2.5\n"); + REprintf(" -scale_z 0.3048\n"); + REprintf(" -rotate_xy 15.0 620000 4100000 (angle + origin)\n"); + REprintf(" -translate_xyz 0.5 0.5 0\n"); + REprintf(" -translate_then_scale_y -0.5 1.001\n"); + REprintf(" -transform_helmert -199.87,74.79,246.62\n"); + REprintf(" -transform_helmert 598.1,73.7,418.2,0.202,0.045,-2.455,6.7\n"); + REprintf(" -transform_affine 0.9999652,0.903571,171.67,736.26\n"); + REprintf(" -switch_x_y -switch_x_z -switch_y_z\n"); + REprintf(" -clamp_z_below 70.5\n"); + REprintf(" -clamp_z 70.5 72.5\n"); + REprintf(" -copy_attribute_into_z 0\n"); + REprintf(" -add_attribute_to_z 1\n"); + REprintf(" -add_scaled_attribute_to_z 1 -1.2\n"); + REprintf(" -copy_intensity_into_z\n"); + REprintf(" -copy_user_data_into_z\n"); + REprintf("Transform raw xyz integers.\n"); + REprintf(" -translate_raw_z 20\n"); + REprintf(" -translate_raw_xyz 1 1 0\n"); + REprintf(" -translate_raw_xy_at_random 2 2\n"); + REprintf(" -clamp_raw_z 500 800\n"); + REprintf("Transform intensity.\n"); + REprintf(" -set_intensity 0\n"); + REprintf(" -scale_intensity 2.5\n"); + REprintf(" -translate_intensity 50\n"); + REprintf(" -translate_then_scale_intensity 0.5 3.1\n"); + REprintf(" -clamp_intensity 0 255\n"); + REprintf(" -clamp_intensity_above 255\n"); + REprintf(" -map_intensity map_file.txt\n"); + REprintf(" -copy_RGB_into_intensity\n"); + REprintf(" -copy_NIR_into_intensity\n"); + REprintf(" -copy_attribute_into_intensity 0\n"); + REprintf(" -bin_gps_time_into_intensity 0.5\n"); + REprintf("Transform scan_angle.\n"); + REprintf(" -set_scan_angle 0.0\n"); + REprintf(" -scale_scan_angle 1.944445\n"); + REprintf(" -translate_scan_angle -5\n"); + REprintf(" -translate_then_scale_scan_angle -0.5 2.1\n"); + REprintf("Change the return number or return count of points.\n"); + REprintf(" -repair_zero_returns\n"); + REprintf(" -set_return_number 1\n"); + REprintf(" -set_extended_return_number 10\n"); + REprintf(" -change_return_number_from_to 2 1\n"); + REprintf(" -change_extended_return_number_from_to 2 8\n"); + REprintf(" -set_number_of_returns 2\n"); + REprintf(" -set_extended_number_of_returns 15\n"); + REprintf(" -change_number_of_returns_from_to 0 2\n"); + REprintf(" -change_extended_number_of_returns_from_to 8 10\n"); + REprintf("Modify the classification.\n"); + REprintf(" -set_classification 2\n"); + REprintf(" -set_extended_classification 41\n"); + REprintf(" -change_classification_from_to 2 4\n"); + REprintf(" -classify_z_below_as -5.0 7\n"); + REprintf(" -classify_z_above_as 70.0 7\n"); + REprintf(" -classify_z_between_as 2.0 5.0 4\n"); + REprintf(" -classify_intensity_above_as 200 9\n"); + REprintf(" -classify_intensity_below_as 30 11 \n"); + REprintf(" -classify_intensity_between_as 500 900 15\n"); + REprintf(" -classify_attribute_below_as 0 -5.0 7\n"); + REprintf(" -classify_attribute_above_as 1 70.0 7\n"); + REprintf(" -classify_attribute_between_as 1 2.0 5.0 4\n"); + REprintf(" -change_extended_classification_from_to 6 46\n"); + REprintf(" -move_ancient_to_extended_classification\n"); + REprintf(" -copy_user_data_into_classification\n"); + REprintf("Change the flags.\n"); + REprintf(" -set_withheld_flag 0\n"); + REprintf(" -set_synthetic_flag 1\n"); + REprintf(" -set_keypoint_flag 0\n"); + REprintf(" -set_overlap_flag 1\n"); + REprintf("Modify the extended scanner channel.\n"); + REprintf(" -set_scanner_channel 2\n"); + REprintf(" -copy_user_data_into_scanner_channel\n"); + REprintf("Modify the user data.\n"); + REprintf(" -set_user_data 0\n"); + REprintf(" -scale_user_data 1.5\n"); + REprintf(" -change_user_data_from_to 23 26\n"); + REprintf(" -change_user_data_from_to 23 26\n"); + REprintf(" -map_user_data map_file.txt\n"); + REprintf(" -copy_scanner_channel_into_user_data\n"); + REprintf(" -copy_attribute_into_user_data 1\n"); + REprintf(" -add_scaled_attribute_to_user_data 0 10.0\n"); + REprintf("Modify the point source ID.\n"); + REprintf(" -set_point_source 500\n"); + REprintf(" -change_point_source_from_to 1023 1024\n"); + REprintf(" -map_point_source map_file.txt\n"); + REprintf(" -copy_user_data_into_point_source\n"); + REprintf(" -copy_scanner_channel_into_point_source\n"); + REprintf(" -copy_attribute_into_point_source 0\n"); + REprintf(" -merge_scanner_channel_into_point_source\n"); + REprintf(" -split_scanner_channel_from_point_source\n"); + REprintf(" -bin_Z_into_point_source 200\n"); + REprintf(" -bin_abs_scan_angle_into_point_source 2\n"); + REprintf(" -bin_gps_time_into_point_source 5.0\n"); + REprintf("Transform gps_time.\n"); + REprintf(" -set_gps_time 113556962.005715\n"); + REprintf(" -translate_gps_time 40.50\n"); + REprintf(" -adjusted_to_week\n"); + REprintf(" -week_to_adjusted 1671\n"); + REprintf("Transform RGB/NIR colors.\n"); + REprintf(" -set_RGB 255 0 127\n"); + REprintf(" -set_RGB_of_class 9 0 0 255\n"); + REprintf(" -scale_RGB 2 4 2\n"); + REprintf(" -scale_RGB_down (by 256)\n"); + REprintf(" -scale_RGB_up (by 256)\n"); + REprintf(" -scale_RGB_to_8bit (only scales down 16 bit values)\n"); + REprintf(" -scale_RGB_to_16bit (only scales up 8 bit values)\n"); + REprintf(" -scale_NIR 2\n"); + REprintf(" -scale_NIR_down (by 256)\n"); + REprintf(" -scale_NIR_up (by 256)\n"); + REprintf(" -scale_NIR_to_8bit (only scales down 16 bit values)\n"); + REprintf(" -scale_NIR_to_16bit (only scales up 8 bit values)\n"); + REprintf(" -switch_R_G -switch_R_B -switch_B_G\n"); + REprintf(" -copy_R_into_NIR -copy_R_into_intensity\n"); + REprintf(" -copy_G_into_NIR -copy_G_into_intensity\n"); + REprintf(" -copy_B_into_NIR -copy_B_into_intensity\n"); + REprintf(" -copy_intensity_into_NIR\n"); + REprintf(" -switch_RGBI_into_CIR\n"); + REprintf(" -switch_RGB_intensity_into_CIR\n"); + REprintf("Transform attributes in \"Extra Bytes\".\n"); + REprintf(" -scale_attribute 0 1.5\n"); + REprintf(" -translate_attribute 1 0.2\n"); + REprintf(" -copy_user_data_into_attribute 0\n"); + REprintf(" -copy_z_into_attribute 0\n"); + REprintf(" -map_attribute_into_RGB 0 map_height_to_RGB.txt\n"); + REprintf("Transform using \"LASregisters\".\n"); + REprintf(" -copy_attribute_into_register 0 0\n"); + REprintf(" -scale_register 0 1.5\n"); + REprintf(" -translate_register 1 10.7\n"); + REprintf(" -add_registers 0 1 3\n"); + REprintf(" -multiply_registers 0 1 2\n"); + REprintf(" -copy_intensity_into_register 0\n"); + REprintf(" -copy_R_into_register 1\n"); + REprintf(" -copy_G_into_register 2\n"); + REprintf(" -copy_B_into_register 3\n"); + REprintf(" -copy_NIR_into_register 4\n"); + REprintf(" -copy_register_into_intensity 1\n"); } BOOL LAStransform::parse(int argc, char* argv[]) @@ -2712,13 +2712,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: offset\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: offset\n", argv[i]); return FALSE; } F64 offset; if (sscanf(argv[i+1], "%lf", &offset) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: offset but '%s' is no valid number\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: offset but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } transformed_fields |= LASTRANSFORM_X_COORDINATE; @@ -2729,13 +2729,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: offset\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: offset\n", argv[i]); return FALSE; } F64 offset; if (sscanf(argv[i+1], "%lf", &offset) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: offset but '%s' is no valid number\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: offset but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } transformed_fields |= LASTRANSFORM_Y_COORDINATE; @@ -2746,13 +2746,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: offset\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: offset\n", argv[i]); return FALSE; } F64 offset; if (sscanf(argv[i+1], "%lf", &offset) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: offset but '%s' is no valid number\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: offset but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } transformed_fields |= LASTRANSFORM_Z_COORDINATE; @@ -2763,25 +2763,25 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+3) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: offset_x offset_y offset_z\n", argv[i]); + REprintf("ERROR: '%s' needs 3 arguments: offset_x offset_y offset_z\n", argv[i]); return FALSE; } F64 offset_x; if (sscanf(argv[i+1], "%lf", &offset_x) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: offset_x offset_y offset_z but '%s' is no valid number\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 3 arguments: offset_x offset_y offset_z but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } F64 offset_y; if (sscanf(argv[i+2], "%lf", &offset_y) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: offset_x offset_y offset_z but '%s' is no valid number\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 3 arguments: offset_x offset_y offset_z but '%s' is no valid number\n", argv[i], argv[i+2]); return FALSE; } F64 offset_z; if (sscanf(argv[i+3], "%lf", &offset_z) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: offset_x offset_y offset_z but '%s' is no valid number\n", argv[i], argv[i+3]); + REprintf("ERROR: '%s' needs 3 arguments: offset_x offset_y offset_z but '%s' is no valid number\n", argv[i], argv[i+3]); return FALSE; } if (offset_x) transformed_fields |= LASTRANSFORM_X_COORDINATE; @@ -2794,19 +2794,19 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: offset scale\n", argv[i]); return FALSE; } F64 offset; if (sscanf(argv[i+1], "%lf", &offset) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid number\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } F64 scale; if (sscanf(argv[i+2], "%lf", &scale) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid number\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid number\n", argv[i], argv[i+2]); return FALSE; } transformed_fields |= LASTRANSFORM_X_COORDINATE; @@ -2817,19 +2817,19 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: offset scale\n", argv[i]); return FALSE; } F64 offset; if (sscanf(argv[i+1], "%lf", &offset) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid number\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } F64 scale; if (sscanf(argv[i+2], "%lf", &scale) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid number\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid number\n", argv[i], argv[i+2]); return FALSE; } transformed_fields |= LASTRANSFORM_Y_COORDINATE; @@ -2840,19 +2840,19 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: offset scale\n", argv[i]); return FALSE; } F64 offset; if (sscanf(argv[i+1], "%lf", &offset) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid number\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } F64 scale; if (sscanf(argv[i+2], "%lf", &scale) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid number\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid number\n", argv[i], argv[i+2]); return FALSE; } transformed_fields |= LASTRANSFORM_Z_COORDINATE; @@ -2865,13 +2865,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: raw_offset\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: raw_offset\n", argv[i]); return FALSE; } I32 raw_offset; if (sscanf(argv[i+1], "%d", &raw_offset) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: raw_offset but '%s' is no valid raw_offset\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: raw_offset but '%s' is no valid raw_offset\n", argv[i], argv[i+1]); return FALSE; } transformed_fields |= LASTRANSFORM_X_COORDINATE; @@ -2882,13 +2882,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: raw_offset\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: raw_offset\n", argv[i]); return FALSE; } I32 raw_offset; if (sscanf(argv[i+1], "%d", &raw_offset) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: raw_offset but '%s' is no valid raw_offset\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: raw_offset but '%s' is no valid raw_offset\n", argv[i], argv[i+1]); return FALSE; } transformed_fields |= LASTRANSFORM_Y_COORDINATE; @@ -2899,13 +2899,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: raw_offset\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: raw_offset\n", argv[i]); return FALSE; } I32 raw_offset; if (sscanf(argv[i+1], "%d", &raw_offset) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: raw_offset but '%s' is no valid raw_offset\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: raw_offset but '%s' is no valid raw_offset\n", argv[i], argv[i+1]); return FALSE; } transformed_fields |= LASTRANSFORM_Z_COORDINATE; @@ -2916,25 +2916,25 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+3) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: raw_offset_x raw_offset_y raw_offset_z\n", argv[i]); + REprintf("ERROR: '%s' needs 3 arguments: raw_offset_x raw_offset_y raw_offset_z\n", argv[i]); return FALSE; } I32 raw_offset_x; if (sscanf(argv[i+1], "%d", &raw_offset_x) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: raw_offset_x raw_offset_y raw_offset_z but '%s' is no valid raw_offset_x\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 3 arguments: raw_offset_x raw_offset_y raw_offset_z but '%s' is no valid raw_offset_x\n", argv[i], argv[i+1]); return FALSE; } I32 raw_offset_y; if (sscanf(argv[i+2], "%d", &raw_offset_y) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: raw_offset_x raw_offset_y raw_offset_z but '%s' is no valid raw_offset_y\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 3 arguments: raw_offset_x raw_offset_y raw_offset_z but '%s' is no valid raw_offset_y\n", argv[i], argv[i+2]); return FALSE; } I32 raw_offset_z; if (sscanf(argv[i+3], "%d", &raw_offset_z) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: raw_offset_x raw_offset_y raw_offset_z but '%s' is no valid raw_offset_z\n", argv[i], argv[i+3]); + REprintf("ERROR: '%s' needs 3 arguments: raw_offset_x raw_offset_y raw_offset_z but '%s' is no valid raw_offset_z\n", argv[i], argv[i+3]); return FALSE; } if (raw_offset_x) transformed_fields |= LASTRANSFORM_X_COORDINATE; @@ -2947,19 +2947,19 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: max_raw_offset_x max_raw_offset_y\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: max_raw_offset_x max_raw_offset_y\n", argv[i]); return FALSE; } I32 max_raw_offset_x; if (sscanf(argv[i+1], "%d", &max_raw_offset_x) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: max_raw_offset_x max_raw_offset_y but '%s' is no valid max_raw_offset_x\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: max_raw_offset_x max_raw_offset_y but '%s' is no valid max_raw_offset_x\n", argv[i], argv[i+1]); return FALSE; } I32 max_raw_offset_y; if (sscanf(argv[i+2], "%d", &max_raw_offset_y) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: max_raw_offset_x max_raw_offset_y but '%s' is no valid max_raw_offset_y\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: max_raw_offset_x max_raw_offset_y but '%s' is no valid max_raw_offset_y\n", argv[i], argv[i+2]); return FALSE; } if (max_raw_offset_x) transformed_fields |= LASTRANSFORM_X_COORDINATE; @@ -2972,13 +2972,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: offset\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: offset\n", argv[i]); return FALSE; } F32 offset; if (sscanf(argv[i+1], "%f", &offset) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: offset but '%s' is no valid offset\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: offset but '%s' is no valid offset\n", argv[i], argv[i+1]); return FALSE; } add_operation(new LASoperationTranslateIntensity(offset)); @@ -2988,19 +2988,19 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: offset scale\n", argv[i]); return FALSE; } F32 offset; if (sscanf(argv[i+1], "%f", &offset) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid offset\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid offset\n", argv[i], argv[i+1]); return FALSE; } F32 scale; if (sscanf(argv[i+2], "%f", &scale) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid scale\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid scale\n", argv[i], argv[i+2]); return FALSE; } add_operation(new LASoperationTranslateThenScaleIntensity(offset, scale)); @@ -3010,13 +3010,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: offset\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: offset\n", argv[i]); return FALSE; } F32 offset; if (sscanf(argv[i+1], "%f", &offset) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: offset but '%s' is no valid offset\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: offset but '%s' is no valid offset\n", argv[i], argv[i+1]); return FALSE; } add_operation(new LASoperationTranslateScanAngle(offset)); @@ -3026,19 +3026,19 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: offset scale\n", argv[i]); return FALSE; } F32 offset; if (sscanf(argv[i+1], "%f", &offset) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid offset\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid offset\n", argv[i], argv[i+1]); return FALSE; } F32 scale; if (sscanf(argv[i+2], "%f", &scale) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid scale\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: offset scale but '%s' is no valid scale\n", argv[i], argv[i+2]); return FALSE; } add_operation(new LASoperationTranslateThenScaleScanAngle(offset, scale)); @@ -3048,13 +3048,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: offset\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: offset\n", argv[i]); return FALSE; } F64 offset; if (sscanf(argv[i+1], "%lf", &offset) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: offset but '%s' is no valid offset\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: offset but '%s' is no valid offset\n", argv[i], argv[i+1]); return FALSE; } add_operation(new LASoperationTranslateGpsTime(offset)); @@ -3064,19 +3064,19 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index offset\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: index offset\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index offset but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: index offset but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } F64 offset; if (sscanf(argv[i+2], "%lf", &offset) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index offset but '%s' is no valid offset\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: index offset but '%s' is no valid offset\n", argv[i], argv[i+2]); return FALSE; } add_operation(new LASoperationTranslateAttribute(index, offset)); @@ -3086,19 +3086,19 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index offset\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: index offset\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index offset but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: index offset but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } F64 offset; if (sscanf(argv[i+2], "%lf", &offset) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index offset but '%s' is no valid offset\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: index offset but '%s' is no valid offset\n", argv[i], argv[i+2]); return FALSE; } add_operation(new LASoperationTranslateRegister(registers, index, offset)); @@ -3111,30 +3111,30 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+3) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_y\n", argv[i]); + REprintf("ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_y\n", argv[i]); return FALSE; } F64 angle; if (sscanf(argv[i+1], "%lf", &angle) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_y but '%s' is no valid angle\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_y but '%s' is no valid angle\n", argv[i], argv[i+1]); return FALSE; } if (angle == 0.0) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_y but %g is no valid angle\n", argv[i], angle); + REprintf("ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_y but %g is no valid angle\n", argv[i], angle); return FALSE; } F64 rot_center_x; if (sscanf(argv[i+2], "%lf", &rot_center_x) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_y but '%s' is no valid rot_center_x\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_y but '%s' is no valid rot_center_x\n", argv[i], argv[i+2]); return FALSE; } F64 rot_center_y; if (sscanf(argv[i+3], "%lf", &rot_center_y) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_y but '%s' is no valid rot_center_y\n", argv[i], argv[i+3]); + REprintf("ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_y but '%s' is no valid rot_center_y\n", argv[i], argv[i+3]); return FALSE; } transformed_fields |= LASTRANSFORM_X_COORDINATE; @@ -3146,30 +3146,30 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+3) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_z\n", argv[i]); + REprintf("ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_z\n", argv[i]); return FALSE; } F64 angle; if (sscanf(argv[i+1], "%lf", &angle) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_z but '%s' is no valid angle\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_z but '%s' is no valid angle\n", argv[i], argv[i+1]); return FALSE; } if (angle == 0.0) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_y but %g is no valid angle\n", argv[i], angle); + REprintf("ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_y but %g is no valid angle\n", argv[i], angle); return FALSE; } F64 rot_center_x; if (sscanf(argv[i+2], "%lf", &rot_center_x) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_z but '%s' is no valid rot_center_x\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_z but '%s' is no valid rot_center_x\n", argv[i], argv[i+2]); return FALSE; } F64 rot_center_z; if (sscanf(argv[i+3], "%lf", &rot_center_z) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_z but '%s' is no valid rot_center_z\n", argv[i], argv[i+3]); + REprintf("ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_z but '%s' is no valid rot_center_z\n", argv[i], argv[i+3]); return FALSE; } transformed_fields |= LASTRANSFORM_X_COORDINATE; @@ -3181,30 +3181,30 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+3) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle rot_center_y rot_center_z\n", argv[i]); + REprintf("ERROR: '%s' needs 3 arguments: angle rot_center_y rot_center_z\n", argv[i]); return FALSE; } F64 angle; if (sscanf(argv[i+1], "%lf", &angle) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle rot_center_y rot_center_z but '%s' is no valid angle\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 3 arguments: angle rot_center_y rot_center_z but '%s' is no valid angle\n", argv[i], argv[i+1]); return FALSE; } if (angle == 0.0) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_y but %g is no valid angle\n", argv[i], angle); + REprintf("ERROR: '%s' needs 3 arguments: angle rot_center_x rot_center_y but %g is no valid angle\n", argv[i], angle); return FALSE; } F64 rot_center_y; if (sscanf(argv[i+2], "%lf", &rot_center_y) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle rot_center_y rot_center_z but '%s' is no valid rot_center_y\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 3 arguments: angle rot_center_y rot_center_z but '%s' is no valid rot_center_y\n", argv[i], argv[i+2]); return FALSE; } F64 rot_center_z; if (sscanf(argv[i+3], "%lf", &rot_center_z) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: angle rot_center_y rot_center_z but '%s' is no valid rot_center_z\n", argv[i], argv[i+3]); + REprintf("ERROR: '%s' needs 3 arguments: angle rot_center_y rot_center_z but '%s' is no valid rot_center_z\n", argv[i], argv[i+3]); return FALSE; } transformed_fields |= LASTRANSFORM_Y_COORDINATE; @@ -3219,19 +3219,19 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: below above\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: below above\n", argv[i]); return FALSE; } F64 below; if (sscanf(argv[i+1], "%lf", &below) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: below above but '%s' is no valid below value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: below above but '%s' is no valid below value\n", argv[i], argv[i+1]); return FALSE; } F64 above; if (sscanf(argv[i+2], "%lf", &above) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: below above but '%s' is no valid above value\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: below above but '%s' is no valid above value\n", argv[i], argv[i+2]); return FALSE; } transformed_fields |= LASTRANSFORM_Z_COORDINATE; @@ -3242,13 +3242,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: below\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: below\n", argv[i]); return FALSE; } F64 below; if (sscanf(argv[i+1], "%lf", &below) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: below but '%s' is no valid below value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: below but '%s' is no valid below value\n", argv[i], argv[i+1]); return FALSE; } transformed_fields |= LASTRANSFORM_Z_COORDINATE; @@ -3259,13 +3259,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: above\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: above\n", argv[i]); return FALSE; } F64 above; if (sscanf(argv[i+1], "%lf", &above) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: above but '%s' is no valid above value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: above but '%s' is no valid above value\n", argv[i], argv[i+1]); return FALSE; } transformed_fields |= LASTRANSFORM_Z_COORDINATE; @@ -3276,29 +3276,29 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: below above\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: below above\n", argv[i]); return FALSE; } U32 below; if (sscanf(argv[i+1], "%u", &below) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: below above but '%s' is no valid below value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: below above but '%s' is no valid below value\n", argv[i], argv[i+1]); return FALSE; } U32 above; if (sscanf(argv[i+2], "%u", &above) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: below above but '%s' is no valid above value\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: below above but '%s' is no valid above value\n", argv[i], argv[i+2]); return FALSE; } if (below > U16_MAX) { - fprintf(stderr,"ERROR: cannot clamp intensity because below value of %u is larger than %u\n", below, U16_MAX); + REprintf("ERROR: cannot clamp intensity because below value of %u is larger than %u\n", below, U16_MAX); return FALSE; } if (above > U16_MAX) { - fprintf(stderr,"ERROR: cannot clamp intensity because above value of %u is larger than %u\n", above, U16_MAX); + REprintf("ERROR: cannot clamp intensity because above value of %u is larger than %u\n", above, U16_MAX); return FALSE; } add_operation(new LASoperationClampIntensity((U16)below, (U16)above)); @@ -3308,18 +3308,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: below\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: below\n", argv[i]); return FALSE; } U32 below; if (sscanf(argv[i+1], "%u", &below) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: below but '%s' is no valid below value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: below but '%s' is no valid below value\n", argv[i], argv[i+1]); return FALSE; } if (below > U16_MAX) { - fprintf(stderr,"ERROR: cannot clamp intensity because below value of %u is larger than %u\n", below, U16_MAX); + REprintf("ERROR: cannot clamp intensity because below value of %u is larger than %u\n", below, U16_MAX); return FALSE; } add_operation(new LASoperationClampIntensityBelow((U16)below)); @@ -3329,18 +3329,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: above\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: above\n", argv[i]); return FALSE; } U32 above; if (sscanf(argv[i+1], "%u", &above) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: above but '%s' is no valid above value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: above but '%s' is no valid above value\n", argv[i], argv[i+1]); return FALSE; } if (above > U16_MAX) { - fprintf(stderr,"ERROR: cannot clamp intensity because above value of %u is larger than %u\n", above, U16_MAX); + REprintf("ERROR: cannot clamp intensity because above value of %u is larger than %u\n", above, U16_MAX); return FALSE; } add_operation(new LASoperationClampIntensityAbove((U16)above)); @@ -3350,19 +3350,19 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: below above\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: below above\n", argv[i]); return FALSE; } I32 below; if (sscanf(argv[i+1], "%d", &below) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: below above but '%s' is no valid below value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: below above but '%s' is no valid below value\n", argv[i], argv[i+1]); return FALSE; } I32 above; if (sscanf(argv[i+2], "%d", &above) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: below above but '%s' is no valid above value\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: below above but '%s' is no valid above value\n", argv[i], argv[i+2]); return FALSE; } transformed_fields |= LASTRANSFORM_Z_COORDINATE; @@ -3378,13 +3378,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } transformed_fields |= LASTRANSFORM_X_COORDINATE; @@ -3395,13 +3395,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } transformed_fields |= LASTRANSFORM_Y_COORDINATE; @@ -3412,13 +3412,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } transformed_fields |= LASTRANSFORM_Z_COORDINATE; @@ -3429,13 +3429,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } add_operation(new LASoperationCopyAttributeIntoUserData(index)); @@ -3445,13 +3445,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } add_operation(new LASoperationCopyAttributeIntoIntensity(index)); @@ -3461,13 +3461,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } add_operation(new LASoperationCopyAttributeIntoPointSource(index)); @@ -3477,13 +3477,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } add_operation(new LASoperationCopyAttributeIntoRGBNIR(index, 0)); @@ -3493,13 +3493,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } add_operation(new LASoperationCopyAttributeIntoRGBNIR(index, 1)); @@ -3509,13 +3509,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } add_operation(new LASoperationCopyAttributeIntoRGBNIR(index, 2)); @@ -3525,13 +3525,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } add_operation(new LASoperationCopyAttributeIntoRGBNIR(index, 3)); @@ -3541,24 +3541,24 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index of attribute, index of register\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: index of attribute, index of register\n", argv[i]); return FALSE; } U32 index_attribute; if (sscanf(argv[i+1], "%u", &index_attribute) != 1) { - fprintf(stderr,"ERROR: '%s' 1st of 2 arguments index of attribute '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' 1st of 2 arguments index of attribute '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } U32 index_register; if (sscanf(argv[i+2], "%u", &index_register) != 1) { - fprintf(stderr,"ERROR: '%s' 2nd of 2 arguments index of register '%s' is no valid index\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' 2nd of 2 arguments index of register '%s' is no valid index\n", argv[i], argv[i+2]); return FALSE; } if (index_register >= 16) { - fprintf(stderr,"ERROR: '%s' 2nd of 2 arguments index of register %u is out of valid [0,15] range\n", argv[i], index_register); + REprintf("ERROR: '%s' 2nd of 2 arguments index of register %u is out of valid [0,15] range\n", argv[i], index_register); return FALSE; } add_operation(new LASoperationCopyAttributeIntoRegister(index_attribute, registers, index_register)); @@ -3571,18 +3571,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index of register\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index of register but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } if (index >= 16) { - fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + REprintf("ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); return FALSE; } transformed_fields |= LASTRANSFORM_X_COORDINATE; @@ -3593,18 +3593,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index of register\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index of register but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } if (index >= 16) { - fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + REprintf("ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); return FALSE; } transformed_fields |= LASTRANSFORM_Y_COORDINATE; @@ -3615,18 +3615,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index of register\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index of register but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } if (index >= 16) { - fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + REprintf("ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); return FALSE; } transformed_fields |= LASTRANSFORM_Z_COORDINATE; @@ -3637,18 +3637,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index of register\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index of register but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } if (index >= 16) { - fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + REprintf("ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); return FALSE; } add_operation(new LASoperationCopyRegisterIntoUserData(registers, index)); @@ -3658,18 +3658,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index of register\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index of register but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } if (index >= 16) { - fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + REprintf("ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); return FALSE; } add_operation(new LASoperationCopyRegisterIntoIntensity(registers, index)); @@ -3679,18 +3679,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index of register\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index of register but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } if (index >= 16) { - fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + REprintf("ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); return FALSE; } add_operation(new LASoperationCopyRegisterIntoPointSource(registers, index)); @@ -3700,18 +3700,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index of register\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index of register but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } if (index >= 16) { - fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + REprintf("ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); return FALSE; } add_operation(new LASoperationCopyRegisterIntoRGBNIR(registers, index, 0)); @@ -3721,18 +3721,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index of register\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index of register but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } if (index >= 16) { - fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + REprintf("ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); return FALSE; } add_operation(new LASoperationCopyRegisterIntoRGBNIR(registers, index, 1)); @@ -3742,18 +3742,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index of register\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index of register but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } if (index >= 16) { - fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + REprintf("ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); return FALSE; } add_operation(new LASoperationCopyRegisterIntoRGBNIR(registers, index, 2)); @@ -3763,18 +3763,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index of register\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of register but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index of register but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } if (index >= 16) { - fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + REprintf("ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); return FALSE; } add_operation(new LASoperationCopyRegisterIntoRGBNIR(registers, index, 3)); @@ -3784,24 +3784,24 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index of register, index of attribute\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: index of register, index of attribute\n", argv[i]); return FALSE; } U32 index_register; if (sscanf(argv[i+1], "%u", &index_register) != 1) { - fprintf(stderr,"ERROR: '%s' 1st of 2 arguments index of register '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' 1st of 2 arguments index of register '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } if (index_register >= 16) { - fprintf(stderr,"ERROR: '%s' 1st of 2 arguments index of register %u is out of valid [0,15] range\n", argv[i], index_register); + REprintf("ERROR: '%s' 1st of 2 arguments index of register %u is out of valid [0,15] range\n", argv[i], index_register); return FALSE; } U32 index_attribute; if (sscanf(argv[i+2], "%u", &index_attribute) != 1) { - fprintf(stderr,"ERROR: '%s' 2nd of 2 arguments index of attribute '%s' is no valid index\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' 2nd of 2 arguments index of attribute '%s' is no valid index\n", argv[i], argv[i+2]); return FALSE; } add_operation(new LASoperationCopyRegisterIntoAttribute(registers, index_register, index_attribute)); @@ -3834,13 +3834,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } add_operation(new LASoperationCopyUserDataIntoAttribute(index)); @@ -3850,18 +3850,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } if (index >= 16) { - fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + REprintf("ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); return FALSE; } add_operation(new LASoperationCopyUserDataIntoRegister(registers, index)); @@ -3874,18 +3874,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } if (index >= 16) { - fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + REprintf("ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); return FALSE; } add_operation(new LASoperationCopyPointSourceIntoRegister(registers, index)); @@ -3911,18 +3911,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } if (index >= 16) { - fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + REprintf("ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); return FALSE; } add_operation(new LASoperationCopyRBGNIRintoRegister(0, registers, index)); @@ -3950,18 +3950,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } if (index >= 16) { - fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + REprintf("ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); return FALSE; } add_operation(new LASoperationCopyRBGNIRintoRegister(1, registers, index)); @@ -3984,18 +3984,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } if (index >= 16) { - fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + REprintf("ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); return FALSE; } add_operation(new LASoperationCopyRBGNIRintoRegister(2, registers, index)); @@ -4018,18 +4018,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } if (index >= 16) { - fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + REprintf("ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); return FALSE; } add_operation(new LASoperationCopyRBGNIRintoRegister(3, registers, index)); @@ -4063,13 +4063,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } add_operation(new LASoperationCopyIntensityIntoAttribute(index)); @@ -4079,18 +4079,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } if (index >= 16) { - fprintf(stderr,"ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); + REprintf("ERROR: '%s' index of register %u is out of valid [0,15] range\n", argv[i], index); return FALSE; } add_operation(new LASoperationCopyIntensityIntoRegister(registers, index)); @@ -4116,13 +4116,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } add_operation(new LASoperationCopyZIntoAttribute(index)); @@ -4136,18 +4136,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: classification\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: classification\n", argv[i]); return FALSE; } U32 classification; if (sscanf(argv[i+1], "%u", &classification) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: classification but '%s' is no valid classification\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: classification but '%s' is no valid classification\n", argv[i], argv[i+1]); return FALSE; } if (classification > 255) { - fprintf(stderr,"ERROR: cannot set classification because classification of %u is larger than 255\n", classification); + REprintf("ERROR: cannot set classification because classification of %u is larger than 255\n", classification); return FALSE; } add_operation(new LASoperationSetClassification((U8)classification)); @@ -4157,18 +4157,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: value\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: value\n", argv[i]); return FALSE; } U32 value; if (sscanf(argv[i+1], "%u", &value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } if (value > U16_MAX) { - fprintf(stderr,"ERROR: cannot set intensity because value of %u is larger than %u\n", value, U16_MAX); + REprintf("ERROR: cannot set intensity because value of %u is larger than %u\n", value, U16_MAX); return FALSE; } add_operation(new LASoperationSetIntensity(U16_CLAMP(value))); @@ -4178,18 +4178,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' need 1 argument: value\n", argv[i]); + REprintf("ERROR: '%s' need 1 argument: value\n", argv[i]); return FALSE; } U32 value; if (sscanf(argv[i+1], "%u", &value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: value but '%s' is no valid flag\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: value but '%s' is no valid flag\n", argv[i], argv[i+1]); return FALSE; } if (value > 1) { - fprintf(stderr,"ERROR: cannot set withheld flag because value %u is larger than 1\n", value); + REprintf("ERROR: cannot set withheld flag because value %u is larger than 1\n", value); return FALSE; } add_operation(new LASoperationSetWithheldFlag((U8)value)); @@ -4199,18 +4199,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' need 1 argument: value\n", argv[i]); + REprintf("ERROR: '%s' need 1 argument: value\n", argv[i]); return FALSE; } U32 value; if (sscanf(argv[i+1], "%u", &value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: value but '%s' is no valid flag\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: value but '%s' is no valid flag\n", argv[i], argv[i+1]); return FALSE; } if (value > 1) { - fprintf(stderr,"ERROR: cannot set synthetic flag because value %u is larger than 1\n", value); + REprintf("ERROR: cannot set synthetic flag because value %u is larger than 1\n", value); return FALSE; } add_operation(new LASoperationSetSyntheticFlag((U8)value)); @@ -4220,18 +4220,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' need 1 argument: value\n", argv[i]); + REprintf("ERROR: '%s' need 1 argument: value\n", argv[i]); return FALSE; } U32 value; if (sscanf(argv[i+1], "%u", &value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: value but '%s' is no valid flag\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: value but '%s' is no valid flag\n", argv[i], argv[i+1]); return FALSE; } if (value > 1) { - fprintf(stderr,"ERROR: cannot set keypoint flag because value %u is larger than 1\n", value); + REprintf("ERROR: cannot set keypoint flag because value %u is larger than 1\n", value); return FALSE; } add_operation(new LASoperationSetKeypointFlag((U8)value)); @@ -4241,18 +4241,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' need 1 argument: value\n", argv[i]); + REprintf("ERROR: '%s' need 1 argument: value\n", argv[i]); return FALSE; } U32 value; if (sscanf(argv[i+1], "%u", &value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: value but '%s' is no valid flag\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: value but '%s' is no valid flag\n", argv[i], argv[i+1]); return FALSE; } if (value > 1) { - fprintf(stderr,"ERROR: cannot set overlap flag because value %u is larger than 1\n", value); + REprintf("ERROR: cannot set overlap flag because value %u is larger than 1\n", value); return FALSE; } add_operation(new LASoperationSetExtendedOverlapFlag((U8)value)); @@ -4262,18 +4262,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' need 1 argument: value\n", argv[i]); + REprintf("ERROR: '%s' need 1 argument: value\n", argv[i]); return FALSE; } U32 value; if (sscanf(argv[i+1], "%u", &value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } if (value > 3) { - fprintf(stderr,"ERROR: cannot set scanner channel because value %u is larger than 3\n", value); + REprintf("ERROR: cannot set scanner channel because value %u is larger than 3\n", value); return FALSE; } add_operation(new LASoperationSetExtendedScannerChannel((U8)value)); @@ -4283,18 +4283,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' need 1 argument: value\n", argv[i]); + REprintf("ERROR: '%s' need 1 argument: value\n", argv[i]); return FALSE; } U32 value; if (sscanf(argv[i+1], "%u", &value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } if (value > U8_MAX) { - fprintf(stderr,"ERROR: cannot set user data because value %u is larger than %d\n", value, U8_MAX); + REprintf("ERROR: cannot set user data because value %u is larger than %d\n", value, U8_MAX); return FALSE; } add_operation(new LASoperationSetUserData((U8)value)); @@ -4304,23 +4304,23 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' need 1 argument: value\n", argv[i]); + REprintf("ERROR: '%s' need 1 argument: value\n", argv[i]); return FALSE; } F32 value; if (sscanf(argv[i+1], "%g", &value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } if (value < -180.0f) { - fprintf(stderr,"ERROR: cannot set scan angle because value %g is smaller than -180\n", value); + REprintf("ERROR: cannot set scan angle because value %g is smaller than -180\n", value); return FALSE; } else if (value > 180.0f) { - fprintf(stderr,"ERROR: cannot set scan angle rank because value %g is larger than 180\n", value); + REprintf("ERROR: cannot set scan angle rank because value %g is larger than 180\n", value); return FALSE; } @@ -4331,18 +4331,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' need 1 argument: psid\n", argv[i]); + REprintf("ERROR: '%s' need 1 argument: psid\n", argv[i]); return FALSE; } U32 value; if (sscanf(argv[i+1], "%u", &value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: value but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } if (value > U16_MAX) { - fprintf(stderr,"ERROR: cannot set point source ID because value %u is larger than %d\n", value, U16_MAX); + REprintf("ERROR: cannot set point source ID because value %u is larger than %d\n", value, U16_MAX); return FALSE; } add_operation(new LASoperationSetPointSource((U16)value)); @@ -4352,18 +4352,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: return_number\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: return_number\n", argv[i]); return FALSE; } U32 return_number; if (sscanf(argv[i+1], "%u", &return_number) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: return_number but '%s' is no valid return_number\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: return_number but '%s' is no valid return_number\n", argv[i], argv[i+1]); return FALSE; } if (return_number > 7) { - fprintf(stderr,"ERROR: cannot set return_number because %u is larger than 7\n", return_number); + REprintf("ERROR: cannot set return_number because %u is larger than 7\n", return_number); return FALSE; } add_operation(new LASoperationSetReturnNumber((U8)return_number)); @@ -4373,18 +4373,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: extended_return_number\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: extended_return_number\n", argv[i]); return FALSE; } U32 extended_return_number; if (sscanf(argv[i+1], "%u", &extended_return_number) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: extended_return_number but '%s' is no valid extended_return_number\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: extended_return_number but '%s' is no valid extended_return_number\n", argv[i], argv[i+1]); return FALSE; } if (extended_return_number > 15) { - fprintf(stderr,"ERROR: cannot set extended_return_number because %u is larger than 15\n", extended_return_number); + REprintf("ERROR: cannot set extended_return_number because %u is larger than 15\n", extended_return_number); return FALSE; } add_operation(new LASoperationSetExtendedReturnNumber((U8)extended_return_number)); @@ -4394,18 +4394,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: number_of_returns\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: number_of_returns\n", argv[i]); return FALSE; } U32 number_of_returns; if (sscanf(argv[i+1], "%u", &number_of_returns) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: number_of_returns but '%s' is no valid number_of_returns\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: number_of_returns but '%s' is no valid number_of_returns\n", argv[i], argv[i+1]); return FALSE; } if (number_of_returns > 7) { - fprintf(stderr,"ERROR: cannot set number_of_returns because %u is larger than 7\n", number_of_returns); + REprintf("ERROR: cannot set number_of_returns because %u is larger than 7\n", number_of_returns); return FALSE; } add_operation(new LASoperationSetNumberOfReturns((U8)number_of_returns)); @@ -4415,18 +4415,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: extended_number_of_returns\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: extended_number_of_returns\n", argv[i]); return FALSE; } U32 extended_number_of_returns; if (sscanf(argv[i+1], "%u", &extended_number_of_returns) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: extended_number_of_returns but '%s' is no valid extended_return_number\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: extended_number_of_returns but '%s' is no valid extended_return_number\n", argv[i], argv[i+1]); return FALSE; } if (extended_number_of_returns > 15) { - fprintf(stderr,"ERROR: cannot set extended_number_of_returns because %u is larger than 15\n", extended_number_of_returns); + REprintf("ERROR: cannot set extended_number_of_returns because %u is larger than 15\n", extended_number_of_returns); return FALSE; } add_operation(new LASoperationSetExtendedNumberOfReturns((U8)extended_number_of_returns)); @@ -4436,13 +4436,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: gps_time\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: gps_time\n", argv[i]); return FALSE; } F64 gps_time; if (sscanf(argv[i+1], "%lf", &gps_time) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: gps_time but '%s' is no valid gps_time\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: gps_time but '%s' is no valid gps_time\n", argv[i], argv[i+1]); return FALSE; } add_operation(new LASoperationSetGpsTime(gps_time)); @@ -4452,19 +4452,19 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: index value\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: index value but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } F64 value; if (sscanf(argv[i+2], "%lf", &value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value but '%s' is no valid value\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: index value but '%s' is no valid value\n", argv[i], argv[i+2]); return FALSE; } add_operation(new LASoperationSetAttribute(index, value)); @@ -4474,19 +4474,19 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: index value\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: index value but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } F64 value; if (sscanf(argv[i+2], "%lf", &value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index value but '%s' is no valid value\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: index value but '%s' is no valid value\n", argv[i], argv[i+2]); return FALSE; } add_operation(new LASoperationSetRegister(registers, index, value)); @@ -4498,40 +4498,40 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+3) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: R G B\n", argv[i]); + REprintf("ERROR: '%s' needs 3 arguments: R G B\n", argv[i]); return FALSE; } U32 R; if (sscanf(argv[i+1], "%u", &R) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: R G B but '%s' is no valid R\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 3 arguments: R G B but '%s' is no valid R\n", argv[i], argv[i+1]); return FALSE; } if (R > U16_MAX) { - fprintf(stderr,"ERROR: cannot set RGB because R is %u, which is larger than %u\n", R, U16_MAX); + REprintf("ERROR: cannot set RGB because R is %u, which is larger than %u\n", R, U16_MAX); return FALSE; } U32 G; if (sscanf(argv[i+2], "%u", &G) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: R G B but '%s' is no valid G\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 3 arguments: R G B but '%s' is no valid G\n", argv[i], argv[i+2]); return FALSE; } if (G > U16_MAX) { - fprintf(stderr,"ERROR: cannot set RGB because G is %u, which is larger than %u\n", G, U16_MAX); + REprintf("ERROR: cannot set RGB because G is %u, which is larger than %u\n", G, U16_MAX); return FALSE; } U32 B; if (sscanf(argv[i+3], "%u", &B) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: R G B but '%s' is no valid B\n", argv[i], argv[i+3]); + REprintf("ERROR: '%s' needs 3 arguments: R G B but '%s' is no valid B\n", argv[i], argv[i+3]); return FALSE; } if (B > U16_MAX) { - fprintf(stderr,"ERROR: cannot set RGB because B is %u, which is larger than %u\n", B, U16_MAX); + REprintf("ERROR: cannot set RGB because B is %u, which is larger than %u\n", B, U16_MAX); return FALSE; } add_operation(new LASoperationSetRGB((U16)R, (U16)G, (U16)B)); @@ -4541,51 +4541,51 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+4) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 4 arguments: classification R G B\n", argv[i]); + REprintf("ERROR: '%s' needs 4 arguments: classification R G B\n", argv[i]); return FALSE; } U32 classification; if (sscanf(argv[i+1], "%u", &classification) != 1) { - fprintf(stderr,"ERROR: '%s' needs 4 arguments: classification R G B but '%s' is no valid classification\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 4 arguments: classification R G B but '%s' is no valid classification\n", argv[i], argv[i+1]); return FALSE; } if (classification > U8_MAX) { - fprintf(stderr,"ERROR: cannot set RGB because classification is %u, which is larger than %u\n", classification, U8_MAX); + REprintf("ERROR: cannot set RGB because classification is %u, which is larger than %u\n", classification, U8_MAX); return FALSE; } U32 R; if (sscanf(argv[i+2], "%u", &R) != 1) { - fprintf(stderr,"ERROR: '%s' needs 4 arguments: classification R G B but '%s' is no valid R\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 4 arguments: classification R G B but '%s' is no valid R\n", argv[i], argv[i+2]); return FALSE; } if (R > U16_MAX) { - fprintf(stderr,"ERROR: cannot set RGB because R is %u, which is larger than %u\n", R, U16_MAX); + REprintf("ERROR: cannot set RGB because R is %u, which is larger than %u\n", R, U16_MAX); return FALSE; } U32 G; if (sscanf(argv[i+3], "%u", &G) != 1) { - fprintf(stderr,"ERROR: '%s' needs 4 arguments: classification R G B but '%s' is no valid G\n", argv[i], argv[i+3]); + REprintf("ERROR: '%s' needs 4 arguments: classification R G B but '%s' is no valid G\n", argv[i], argv[i+3]); return FALSE; } if (G > U16_MAX) { - fprintf(stderr,"ERROR: cannot set RGB because G is %u, which is larger than %u\n", G, U16_MAX); + REprintf("ERROR: cannot set RGB because G is %u, which is larger than %u\n", G, U16_MAX); return FALSE; } U32 B; if (sscanf(argv[i+4], "%u", &B) != 1) { - fprintf(stderr,"ERROR: '%s' needs 4 arguments: classification R G B but '%s' is no valid B\n", argv[i], argv[i+4]); + REprintf("ERROR: '%s' needs 4 arguments: classification R G B but '%s' is no valid B\n", argv[i], argv[i+4]); return FALSE; } if (B > U16_MAX) { - fprintf(stderr,"ERROR: cannot set RGB because B is %u, which is larger than %u\n", B, U16_MAX); + REprintf("ERROR: cannot set RGB because B is %u, which is larger than %u\n", B, U16_MAX); return FALSE; } if (classification < 32) @@ -4603,18 +4603,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' need 1 argument: value\n", argv[i]); + REprintf("ERROR: '%s' need 1 argument: value\n", argv[i]); return FALSE; } U32 value; if (sscanf(argv[i+1], "%u", &value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: value but '%s' is no valid flag\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: value but '%s' is no valid flag\n", argv[i], argv[i+1]); return FALSE; } if (value > 1) { - fprintf(stderr,"ERROR: cannot set scan direction flag because value %u is larger than 1\n", value); + REprintf("ERROR: cannot set scan direction flag because value %u is larger than 1\n", value); return FALSE; } add_operation(new LASoperationSetScanDirectionFlag((U8)value)); @@ -4624,18 +4624,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' need 1 argument: value\n", argv[i]); + REprintf("ERROR: '%s' need 1 argument: value\n", argv[i]); return FALSE; } U32 value; if (sscanf(argv[i+1], "%u", &value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: value but '%s' is no valid flag\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: value but '%s' is no valid flag\n", argv[i], argv[i+1]); return FALSE; } if (value > 1) { - fprintf(stderr,"ERROR: cannot set edge of flight line because value %u is larger than 1\n", value); + REprintf("ERROR: cannot set edge of flight line because value %u is larger than 1\n", value); return FALSE; } add_operation(new LASoperationSetEdgeOfFlightLine((U8)value)); @@ -4648,29 +4648,29 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: from_value to_value\n", argv[i]); return FALSE; } U32 from_value; if (sscanf(argv[i+1], "%u", &from_value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid from_value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid from_value\n", argv[i], argv[i+1]); return FALSE; } if (from_value > U8_MAX) { - fprintf(stderr,"ERROR: cannot change classification because from_value %u is larger than %u\n", from_value, U8_MAX); + REprintf("ERROR: cannot change classification because from_value %u is larger than %u\n", from_value, U8_MAX); return FALSE; } U32 to_value; if (sscanf(argv[i+2], "%u", &to_value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid to_value\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid to_value\n", argv[i], argv[i+2]); return FALSE; } if (to_value > U8_MAX) { - fprintf(stderr,"ERROR: cannot change classification because to_value %u is larger than %u\n", to_value, U8_MAX); + REprintf("ERROR: cannot change classification because to_value %u is larger than %u\n", to_value, U8_MAX); return FALSE; } add_operation(new LASoperationChangeClassificationFromTo((U8)from_value, (U8)to_value)); @@ -4680,29 +4680,29 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: from_value to_value\n", argv[i]); return FALSE; } U32 from_value; if (sscanf(argv[i+1], "%u", &from_value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid from_value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid from_value\n", argv[i], argv[i+1]); return FALSE; } if (from_value > U8_MAX) { - fprintf(stderr,"ERROR: cannot change classification because from_value %u is larger than %u\n", from_value, U8_MAX); + REprintf("ERROR: cannot change classification because from_value %u is larger than %u\n", from_value, U8_MAX); return FALSE; } U32 to_value; if (sscanf(argv[i+2], "%u", &to_value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid to_value\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid to_value\n", argv[i], argv[i+2]); return FALSE; } if (to_value > U8_MAX) { - fprintf(stderr,"ERROR: cannot change classification because to_value %u is larger than %u\n", to_value, U8_MAX); + REprintf("ERROR: cannot change classification because to_value %u is larger than %u\n", to_value, U8_MAX); return FALSE; } add_operation(new LASoperationChangeUserDataFromTo(from_value, to_value)); @@ -4712,29 +4712,29 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: from_value to_value\n", argv[i]); return FALSE; } U32 from_value; if (sscanf(argv[i+1], "%u", &from_value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid from_value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid from_value\n", argv[i], argv[i+1]); return FALSE; } if (from_value > U16_MAX) { - fprintf(stderr,"ERROR: cannot change classification because from_value %u is larger than %u\n", from_value, U16_MAX); + REprintf("ERROR: cannot change classification because from_value %u is larger than %u\n", from_value, U16_MAX); return FALSE; } U32 to_value; if (sscanf(argv[i+2], "%u", &to_value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid to_value\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid to_value\n", argv[i], argv[i+2]); return FALSE; } if (to_value > U16_MAX) { - fprintf(stderr,"ERROR: cannot change classification because to_value %u is larger than %u\n", to_value, U16_MAX); + REprintf("ERROR: cannot change classification because to_value %u is larger than %u\n", to_value, U16_MAX); return FALSE; } add_operation(new LASoperationChangePointSourceFromTo((U16)from_value, (U16)to_value)); @@ -4744,29 +4744,29 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: from_value to_value\n", argv[i]); return FALSE; } U32 from_value; if (sscanf(argv[i+1], "%u", &from_value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid from_value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid from_value\n", argv[i], argv[i+1]); return FALSE; } if (from_value > 7) { - fprintf(stderr,"ERROR: cannot change return_number because from_value %u is larger than %u\n", from_value, 7); + REprintf("ERROR: cannot change return_number because from_value %u is larger than %u\n", from_value, 7); return FALSE; } U32 to_value; if (sscanf(argv[i+2], "%u", &to_value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid to_value\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid to_value\n", argv[i], argv[i+2]); return FALSE; } if (to_value > 7) { - fprintf(stderr,"ERROR: cannot change return_number because to_value %u is larger than %u\n", to_value, 7); + REprintf("ERROR: cannot change return_number because to_value %u is larger than %u\n", to_value, 7); return FALSE; } add_operation(new LASoperationChangeReturnNumberFromTo((U8)from_value, (U8)to_value)); @@ -4776,29 +4776,29 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: from_value to_value\n", argv[i]); return FALSE; } U32 from_value; if (sscanf(argv[i+1], "%u", &from_value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid from_value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid from_value\n", argv[i], argv[i+1]); return FALSE; } if (from_value > 7) { - fprintf(stderr,"ERROR: cannot change number_of_returns because from_value %u is larger than %u\n", from_value, 7); + REprintf("ERROR: cannot change number_of_returns because from_value %u is larger than %u\n", from_value, 7); return FALSE; } U32 to_value; if (sscanf(argv[i+2], "%u", &to_value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid to_value\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid to_value\n", argv[i], argv[i+2]); return FALSE; } if (to_value > 7) { - fprintf(stderr,"ERROR: cannot change number_of_returns because to_value %u is larger than %u\n", to_value, 7); + REprintf("ERROR: cannot change number_of_returns because to_value %u is larger than %u\n", to_value, 7); return FALSE; } add_operation(new LASoperationChangeNumberOfReturnsFromTo((U8)from_value, (U8)to_value)); @@ -4808,29 +4808,29 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: from_value to_value\n", argv[i]); return FALSE; } U32 from_value; if (sscanf(argv[i+1], "%u", &from_value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid from_value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid from_value\n", argv[i], argv[i+1]); return FALSE; } if (from_value > 15) { - fprintf(stderr,"ERROR: cannot change extended_return_number because from_value %u is larger than %u\n", from_value, 15); + REprintf("ERROR: cannot change extended_return_number because from_value %u is larger than %u\n", from_value, 15); return FALSE; } U32 to_value; if (sscanf(argv[i+2], "%u", &to_value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid to_value\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid to_value\n", argv[i], argv[i+2]); return FALSE; } if (to_value > 15) { - fprintf(stderr,"ERROR: cannot change extended_return_number because to_value %u is larger than %u\n", to_value, 15); + REprintf("ERROR: cannot change extended_return_number because to_value %u is larger than %u\n", to_value, 15); return FALSE; } add_operation(new LASoperationChangeExtendedReturnNumberFromTo((U8)from_value, (U8)to_value)); @@ -4840,29 +4840,29 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: from_value to_value\n", argv[i]); return FALSE; } U32 from_value; if (sscanf(argv[i+1], "%u", &from_value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid from_value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid from_value\n", argv[i], argv[i+1]); return FALSE; } if (from_value > 15) { - fprintf(stderr,"ERROR: cannot change extended_number_of_returns because from_value %u is larger than %u\n", from_value, 15); + REprintf("ERROR: cannot change extended_number_of_returns because from_value %u is larger than %u\n", from_value, 15); return FALSE; } U32 to_value; if (sscanf(argv[i+2], "%u", &to_value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid to_value\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: from_value to_value but '%s' is no valid to_value\n", argv[i], argv[i+2]); return FALSE; } if (to_value > 15) { - fprintf(stderr,"ERROR: cannot change extended_number_of_returns because to_value %u is larger than %u\n", to_value, 15); + REprintf("ERROR: cannot change extended_number_of_returns because to_value %u is larger than %u\n", to_value, 15); return FALSE; } add_operation(new LASoperationChangeExtendedNumberOfReturnsFromTo((U8)from_value, (U8)to_value)); @@ -4877,24 +4877,24 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: z_value classification\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: z_value classification\n", argv[i]); return FALSE; } F64 z_value; if (sscanf(argv[i+1], "%lf", &z_value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: z_value classification but '%s' is no valid z_value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: z_value classification but '%s' is no valid z_value\n", argv[i], argv[i+1]); return FALSE; } U32 classification; if (sscanf(argv[i+2], "%u", &classification) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: z_value classification but '%s' is no valid classification\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: z_value classification but '%s' is no valid classification\n", argv[i], argv[i+2]); return FALSE; } if (classification > 255) { - fprintf(stderr,"ERROR: cannot classify z_value because classification of %u is larger than 255\n", classification); + REprintf("ERROR: cannot classify z_value because classification of %u is larger than 255\n", classification); return FALSE; } add_operation(new LASoperationClassifyZbelowAs(z_value, U8_CLAMP(classification))); @@ -4904,24 +4904,24 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: z_value classification\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: z_value classification\n", argv[i]); return FALSE; } F64 z_value; if (sscanf(argv[i+1], "%lf", &z_value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: z_value classification but '%s' is no valid z_value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: z_value classification but '%s' is no valid z_value\n", argv[i], argv[i+1]); return FALSE; } U32 classification; if (sscanf(argv[i+2], "%u", &classification) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: z_value classification but '%s' is no valid classification\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: z_value classification but '%s' is no valid classification\n", argv[i], argv[i+2]); return FALSE; } if (classification > 255) { - fprintf(stderr,"ERROR: cannot classify z_value because classification of %u is larger than 255\n", classification); + REprintf("ERROR: cannot classify z_value because classification of %u is larger than 255\n", classification); return FALSE; } add_operation(new LASoperationClassifyZaboveAs(z_value, U8_CLAMP(classification))); @@ -4931,30 +4931,30 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+3) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: z_min z_max classification\n", argv[i]); + REprintf("ERROR: '%s' needs 3 arguments: z_min z_max classification\n", argv[i]); return FALSE; } F64 z_min; if (sscanf(argv[i+1], "%lf", &z_min) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: z_min z_max classification but '%s' is no valid z_min\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 3 arguments: z_min z_max classification but '%s' is no valid z_min\n", argv[i], argv[i+1]); return FALSE; } F64 z_max; if (sscanf(argv[i+2], "%lf", &z_max) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: z_min z_max classification but '%s' is no valid z_max\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 3 arguments: z_min z_max classification but '%s' is no valid z_max\n", argv[i], argv[i+2]); return FALSE; } U32 classification; if (sscanf(argv[i+3], "%u", &classification) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: z_min z_max classification but '%s' is no valid classification\n", argv[i], argv[i+3]); + REprintf("ERROR: '%s' needs 3 arguments: z_min z_max classification but '%s' is no valid classification\n", argv[i], argv[i+3]); return FALSE; } if (classification > 255) { - fprintf(stderr,"ERROR: cannot classify z_value because classification of %u is larger than 255\n", classification); + REprintf("ERROR: cannot classify z_value because classification of %u is larger than 255\n", classification); return FALSE; } add_operation(new LASoperationClassifyZbetweenAs(z_min, z_max, U8_CLAMP(classification))); @@ -4967,29 +4967,29 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: value classification\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: value classification\n", argv[i]); return FALSE; } U32 value; if (sscanf(argv[i+1], "%u", &value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: value classification but '%s' is no valid value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: value classification but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } U32 classification; if (sscanf(argv[i+2], "%u", &classification) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: value classification but '%s' is no valid classification\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: value classification but '%s' is no valid classification\n", argv[i], argv[i+2]); return FALSE; } if (value > U16_MAX) { - fprintf(stderr,"ERROR: cannot classify intensity because value of %u is larger than %u\n", value, U16_MAX); + REprintf("ERROR: cannot classify intensity because value of %u is larger than %u\n", value, U16_MAX); return FALSE; } if (classification > 255) { - fprintf(stderr,"ERROR: cannot classify intensity because classification of %u is larger than 255\n", classification); + REprintf("ERROR: cannot classify intensity because classification of %u is larger than 255\n", classification); return FALSE; } add_operation(new LASoperationClassifyIntensityBelowAs(value, classification)); @@ -4999,29 +4999,29 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: value classification\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: value classification\n", argv[i]); return FALSE; } U32 value; if (sscanf(argv[i+1], "%u", &value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: value classification but '%s' is no valid value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: value classification but '%s' is no valid value\n", argv[i], argv[i+1]); return FALSE; } U32 classification; if (sscanf(argv[i+2], "%u", &classification) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: value classification but '%s' is no valid classification\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: value classification but '%s' is no valid classification\n", argv[i], argv[i+2]); return FALSE; } if (value > U16_MAX) { - fprintf(stderr,"ERROR: cannot classify intensity because value of %u is larger than %u\n", value, U16_MAX); + REprintf("ERROR: cannot classify intensity because value of %u is larger than %u\n", value, U16_MAX); return FALSE; } if (classification > 255) { - fprintf(stderr,"ERROR: cannot classify intensity because classification of %u is larger than 255\n", classification); + REprintf("ERROR: cannot classify intensity because classification of %u is larger than 255\n", classification); return FALSE; } add_operation(new LASoperationClassifyIntensityAboveAs(value, classification)); @@ -5031,40 +5031,40 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+3) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: min_value max_value classification\n", argv[i]); + REprintf("ERROR: '%s' needs 3 arguments: min_value max_value classification\n", argv[i]); return FALSE; } U32 min_value; if (sscanf(argv[i+1], "%u", &min_value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: min_value max_value classification but '%s' is no valid min_value\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 3 arguments: min_value max_value classification but '%s' is no valid min_value\n", argv[i], argv[i+1]); return FALSE; } U32 max_value; if (sscanf(argv[i+2], "%u", &max_value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: min_value max_value classification but '%s' is no valid max_value\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 3 arguments: min_value max_value classification but '%s' is no valid max_value\n", argv[i], argv[i+2]); return FALSE; } U32 classification; if (sscanf(argv[i+3], "%u", &classification) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: min_value max_value classification but '%s' is no valid classification\n", argv[i], argv[i+3]); + REprintf("ERROR: '%s' needs 3 arguments: min_value max_value classification but '%s' is no valid classification\n", argv[i], argv[i+3]); return FALSE; } if (min_value > U16_MAX) { - fprintf(stderr,"ERROR: cannot classify intensity because min_value of %u is larger than %u\n", min_value, U16_MAX); + REprintf("ERROR: cannot classify intensity because min_value of %u is larger than %u\n", min_value, U16_MAX); return FALSE; } if (max_value > U16_MAX) { - fprintf(stderr,"ERROR: cannot classify intensity because max_value of %u is larger than %u\n", max_value, U16_MAX); + REprintf("ERROR: cannot classify intensity because max_value of %u is larger than %u\n", max_value, U16_MAX); return FALSE; } if (classification > 255) { - fprintf(stderr,"ERROR: cannot classify intensity because classification of %u is larger than 255\n", classification); + REprintf("ERROR: cannot classify intensity because classification of %u is larger than 255\n", classification); return FALSE; } add_operation(new LASoperationClassifyIntensityBetweenAs(min_value, max_value, classification)); @@ -5077,30 +5077,30 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+3) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: attribute_index value classification\n", argv[i]); + REprintf("ERROR: '%s' needs 3 arguments: attribute_index value classification\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: attribute_index value classification but '%s' is no valid attribute_index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 3 arguments: attribute_index value classification but '%s' is no valid attribute_index\n", argv[i], argv[i+1]); return FALSE; } F64 value; if (sscanf(argv[i+2], "%lf", &value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: attribute_index value classification but '%s' is no valid value\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 3 arguments: attribute_index value classification but '%s' is no valid value\n", argv[i], argv[i+2]); return FALSE; } U32 classification; if (sscanf(argv[i+3], "%u", &classification) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: attribute_index value classification but '%s' is no valid classification\n", argv[i], argv[i+3]); + REprintf("ERROR: '%s' needs 3 arguments: attribute_index value classification but '%s' is no valid classification\n", argv[i], argv[i+3]); return FALSE; } if (classification > 255) { - fprintf(stderr,"ERROR: cannot classify attribute below because classification of %u is larger than 255\n", classification); + REprintf("ERROR: cannot classify attribute below because classification of %u is larger than 255\n", classification); return FALSE; } add_operation(new LASoperationClassifyAttributeBelowAs(index, value, U8_CLAMP(classification))); @@ -5110,30 +5110,30 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+3) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: attribute_index value classification\n", argv[i]); + REprintf("ERROR: '%s' needs 3 arguments: attribute_index value classification\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: attribute_index value classification but '%s' is no valid attribute_index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 3 arguments: attribute_index value classification but '%s' is no valid attribute_index\n", argv[i], argv[i+1]); return FALSE; } F64 value; if (sscanf(argv[i+2], "%lf", &value) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: attribute_index value classification but '%s' is no valid value\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 3 arguments: attribute_index value classification but '%s' is no valid value\n", argv[i], argv[i+2]); return FALSE; } U32 classification; if (sscanf(argv[i+3], "%u", &classification) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: attribute_index value classification but '%s' is no valid classification\n", argv[i], argv[i+3]); + REprintf("ERROR: '%s' needs 3 arguments: attribute_index value classification but '%s' is no valid classification\n", argv[i], argv[i+3]); return FALSE; } if (classification > 255) { - fprintf(stderr,"ERROR: cannot classify attribute above because classification of %u is larger than 255\n", classification); + REprintf("ERROR: cannot classify attribute above because classification of %u is larger than 255\n", classification); return FALSE; } add_operation(new LASoperationClassifyAttributeAboveAs(index, value, U8_CLAMP(classification))); @@ -5143,36 +5143,36 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+4) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 4 arguments: attribute_index min max classification\n", argv[i]); + REprintf("ERROR: '%s' needs 4 arguments: attribute_index min max classification\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 4 arguments: attribute_index min max classification but '%s' is no valid attribute_index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 4 arguments: attribute_index min max classification but '%s' is no valid attribute_index\n", argv[i], argv[i+1]); return FALSE; } F64 min; if (sscanf(argv[i+2], "%lf", &min) != 1) { - fprintf(stderr,"ERROR: '%s' needs 4 arguments: attribute_index min max classification but '%s' is no valid min\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 4 arguments: attribute_index min max classification but '%s' is no valid min\n", argv[i], argv[i+2]); return FALSE; } F64 max; if (sscanf(argv[i+3], "%lf", &max) != 1) { - fprintf(stderr,"ERROR: '%s' needs 4 arguments: attribute_index min max classification but '%s' is no valid max\n", argv[i], argv[i+3]); + REprintf("ERROR: '%s' needs 4 arguments: attribute_index min max classification but '%s' is no valid max\n", argv[i], argv[i+3]); return FALSE; } U32 classification; if (sscanf(argv[i+4], "%u", &classification) != 1) { - fprintf(stderr,"ERROR: '%s' needs 4 arguments: attribute_index min max classification but '%s' is no valid classification\n", argv[i], argv[i+4]); + REprintf("ERROR: '%s' needs 4 arguments: attribute_index min max classification but '%s' is no valid classification\n", argv[i], argv[i+4]); return FALSE; } if (classification > 255) { - fprintf(stderr,"ERROR: cannot classify attribute between because classification of %u is larger than 255\n", classification); + REprintf("ERROR: cannot classify attribute between because classification of %u is larger than 255\n", classification); return FALSE; } add_operation(new LASoperationClassifyAttributeBetweenAs(index, min, max, U8_CLAMP(classification))); @@ -5186,13 +5186,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: scale\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: scale\n", argv[i]); return FALSE; } F64 scale_x; if (sscanf(argv[i+1], "%lf", &scale_x) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: scale_x but '%s' is no valid number\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: scale_x but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } if (scale_x != 1.0) transformed_fields |= LASTRANSFORM_X_COORDINATE; @@ -5203,13 +5203,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: scale\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: scale\n", argv[i]); return FALSE; } F64 scale_y; if (sscanf(argv[i+1], "%lf", &scale_y) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: scale_y but '%s' is no valid number\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: scale_y but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } if (scale_y != 1.0) transformed_fields |= LASTRANSFORM_Y_COORDINATE; @@ -5220,13 +5220,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: scale\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: scale\n", argv[i]); return FALSE; } F64 scale_z; if (sscanf(argv[i+1], "%lf", &scale_z) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: scale_z but '%s' is no valid number\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: scale_z but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } if (scale_z != 1.0) transformed_fields |= LASTRANSFORM_Z_COORDINATE; @@ -5237,25 +5237,25 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+3) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: scale_x scale_y scale_z\n", argv[i]); + REprintf("ERROR: '%s' needs 3 arguments: scale_x scale_y scale_z\n", argv[i]); return FALSE; } F64 scale_x; if (sscanf(argv[i+1], "%lf", &scale_x) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: scale_x scale_y scale_z but '%s' is no valid number\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 3 arguments: scale_x scale_y scale_z but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } F64 scale_y; if (sscanf(argv[i+2], "%lf", &scale_y) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: scale_x scale_y scale_z but '%s' is no valid number\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 3 arguments: scale_x scale_y scale_z but '%s' is no valid number\n", argv[i], argv[i+2]); return FALSE; } F64 scale_z; if (sscanf(argv[i+3], "%lf", &scale_z) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: scale_x scale_y scale_z but '%s' is no valid number\n", argv[i], argv[i+3]); + REprintf("ERROR: '%s' needs 3 arguments: scale_x scale_y scale_z but '%s' is no valid number\n", argv[i], argv[i+3]); return FALSE; } if (scale_x != 1.0) transformed_fields |= LASTRANSFORM_X_COORDINATE; @@ -5268,13 +5268,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: scale\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: scale\n", argv[i]); return FALSE; } F32 scale; if (sscanf(argv[i+1], "%f", &scale) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: scale but '%s' is no valid number\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: scale but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } add_operation(new LASoperationScaleIntensity(scale)); @@ -5284,13 +5284,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: scale\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: scale\n", argv[i]); return FALSE; } F32 scale; if (sscanf(argv[i+1], "%f", &scale) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: scale but '%s' is no valid number\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: scale but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } add_operation(new LASoperationScaleScanAngle(scale)); @@ -5300,13 +5300,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: scale\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: scale\n", argv[i]); return FALSE; } F32 scale; if (sscanf(argv[i+1], "%f", &scale) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: scale but '%s' is no valid number\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: scale but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } add_operation(new LASoperationScaleUserData(scale)); @@ -5318,25 +5318,25 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+3) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: scale_R scale_G scale_B\n", argv[i]); + REprintf("ERROR: '%s' needs 3 arguments: scale_R scale_G scale_B\n", argv[i]); return FALSE; } F32 scale_R; if (sscanf(argv[i+1], "%f", &scale_R) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: scale_R scale_G scale_B but '%s' is no valid number\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 3 arguments: scale_R scale_G scale_B but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } F32 scale_G; if (sscanf(argv[i+2], "%f", &scale_G) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: scale_R scale_G scale_B but '%s' is no valid number\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 3 arguments: scale_R scale_G scale_B but '%s' is no valid number\n", argv[i], argv[i+2]); return FALSE; } F32 scale_B; if (sscanf(argv[i+3], "%f", &scale_B) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: scale_R scale_G scale_B but '%s' is no valid number\n", argv[i], argv[i+3]); + REprintf("ERROR: '%s' needs 3 arguments: scale_R scale_G scale_B but '%s' is no valid number\n", argv[i], argv[i+3]); return FALSE; } add_operation(new LASoperationScaleRGB(scale_R, scale_G, scale_B)); @@ -5369,13 +5369,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: scale_NIR\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: scale_NIR\n", argv[i]); return FALSE; } F32 scale_NIR; if (sscanf(argv[i+1], "%f", &scale_NIR) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: scale_NIR but '%s' is no valid number\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: scale_NIR but '%s' is no valid number\n", argv[i], argv[i+1]); return FALSE; } add_operation(new LASoperationScaleNIR(scale_NIR)); @@ -5406,19 +5406,19 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index scale\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: index scale\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index scale but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: index scale but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } F32 scale; if (sscanf(argv[i+2], "%f", &scale) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index scale but '%s' is no valid scale\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: index scale but '%s' is no valid scale\n", argv[i], argv[i+2]); return FALSE; } add_operation(new LASoperationScaleAttribute(index, scale)); @@ -5428,19 +5428,19 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index scale\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: index scale\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index scale but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: index scale but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } F32 scale; if (sscanf(argv[i+2], "%f", &scale) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index scale but '%s' is no valid scale\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: index scale but '%s' is no valid scale\n", argv[i], argv[i+2]); return FALSE; } add_operation(new LASoperationScaleRegister(registers, index, scale)); @@ -5496,18 +5496,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: bin_size\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: bin_size\n", argv[i]); return FALSE; } U32 bin_size; if (sscanf(argv[i+1], "%u", &bin_size) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: bin_size but '%s' is no valid bin_size\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: bin_size but '%s' is no valid bin_size\n", argv[i], argv[i+1]); return FALSE; } if (bin_size == 0) { - fprintf(stderr,"ERROR: %u is no valid bin_size for '%s'\n", bin_size, argv[i]); + REprintf("ERROR: %u is no valid bin_size for '%s'\n", bin_size, argv[i]); return FALSE; } add_operation(new LASoperationBinZintoPointSource(bin_size)); @@ -5517,18 +5517,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: bin_size\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: bin_size\n", argv[i]); return FALSE; } F32 bin_size; if (sscanf(argv[i+1], "%f", &bin_size) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: bin_size but '%s' is no valid bin_size\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: bin_size but '%s' is no valid bin_size\n", argv[i], argv[i+1]); return FALSE; } if (bin_size <= 0.0f) { - fprintf(stderr,"ERROR: %f is no valid bin_size for '%s'\n", bin_size, argv[i]); + REprintf("ERROR: %f is no valid bin_size for '%s'\n", bin_size, argv[i]); return FALSE; } add_operation(new LASoperationBinAbsScanAngleIntoPointSource(bin_size)); @@ -5538,18 +5538,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: bin_size\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: bin_size\n", argv[i]); return FALSE; } F64 bin_size; if (sscanf(argv[i+1], "%lf", &bin_size) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: bin_size but '%s' is no valid bin_size\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: bin_size but '%s' is no valid bin_size\n", argv[i], argv[i+1]); return FALSE; } if (bin_size <= 0.0) { - fprintf(stderr,"ERROR: %g is no valid bin_size for '%s'\n", bin_size, argv[i]); + REprintf("ERROR: %g is no valid bin_size for '%s'\n", bin_size, argv[i]); return FALSE; } add_operation(new LASoperationBinGpsTimeIntoIntensity(bin_size)); @@ -5559,18 +5559,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: bin_size\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: bin_size\n", argv[i]); return FALSE; } F64 bin_size; if (sscanf(argv[i+1], "%lf", &bin_size) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: bin_size but '%s' is no valid bin_size\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: bin_size but '%s' is no valid bin_size\n", argv[i], argv[i+1]); return FALSE; } if (bin_size <= 0.0) { - fprintf(stderr,"ERROR: %g is no valid bin_size for '%s'\n", bin_size, argv[i]); + REprintf("ERROR: %g is no valid bin_size for '%s'\n", bin_size, argv[i]); return FALSE; } add_operation(new LASoperationBinGpsTimeIntoPointSource(bin_size)); @@ -5583,13 +5583,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: map_file_name.txt\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: map_file_name.txt\n", argv[i]); return FALSE; } FILE* file = fopen(argv[i+1], "r"); if (file == 0) { - fprintf(stderr,"ERROR: cannot '%s' needs text file with map but '%s' cannot be opened\n", argv[i], argv[i+1]); + REprintf("ERROR: cannot '%s' needs text file with map but '%s' cannot be opened\n", argv[i], argv[i+1]); return FALSE; } else @@ -5603,13 +5603,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: map_file_name.txt\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: map_file_name.txt\n", argv[i]); return FALSE; } FILE* file = fopen(argv[i+1], "r"); if (file == 0) { - fprintf(stderr,"ERROR: '%s' needs text file with map but '%s' cannot be opened\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs text file with map but '%s' cannot be opened\n", argv[i], argv[i+1]); return FALSE; } else @@ -5623,13 +5623,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: map_file_name.txt\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: map_file_name.txt\n", argv[i]); return FALSE; } FILE* file = fopen(argv[i+1], "r"); if (file == 0) { - fprintf(stderr,"ERROR: '%s' needs text file with map but '%s' cannot be opened\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs text file with map but '%s' cannot be opened\n", argv[i], argv[i+1]); return FALSE; } else @@ -5643,19 +5643,19 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: attribute_index map_file_name.txt\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: attribute_index map_file_name.txt\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: attribute_index map_file_name.txt but '%s' is no valid attribute_index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: attribute_index map_file_name.txt but '%s' is no valid attribute_index\n", argv[i], argv[i+1]); return FALSE; } FILE* file = fopen(argv[i+2], "r"); if (file == 0) { - fprintf(stderr,"ERROR: '%s' needs text file with map but '%s' cannot be opened\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs text file with map but '%s' cannot be opened\n", argv[i], argv[i+2]); return FALSE; } else @@ -5672,19 +5672,19 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: attribute_index attribute_file_name.txt\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: attribute_index attribute_file_name.txt\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: attribute_index attribute_file_name.txt but '%s' is no valid attribute_index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: attribute_index attribute_file_name.txt but '%s' is no valid attribute_index\n", argv[i], argv[i+1]); return FALSE; } FILE* file = fopen(argv[i+2], "r"); if (file == 0) { - fprintf(stderr,"ERROR: '%s' needs text file with attribute values but '%s' cannot be opened\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs text file with attribute values but '%s' cannot be opened\n", argv[i], argv[i+2]); return FALSE; } else @@ -5701,7 +5701,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: 3 or 7 comma separated parameters\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: 3 or 7 comma separated parameters\n", argv[i]); return FALSE; } F64 dx, dy, dz, rx, ry, rz, m, dummy; @@ -5716,7 +5716,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) } else { - fprintf(stderr,"ERROR: '%s' needs 3 or 7 comma separated parameters as argument\n", argv[i]); + REprintf("ERROR: '%s' needs 3 or 7 comma separated parameters as argument\n", argv[i]); return FALSE; } *argv[i]='\0'; *argv[i+1]='\0'; i+=1; @@ -5725,7 +5725,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: 4 comma separated parameters\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: 4 comma separated parameters\n", argv[i]); return FALSE; } F64 k, w, tx, ty, dummy; @@ -5736,7 +5736,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) } else { - fprintf(stderr,"ERROR: '%s' needs 4 comma separated parameters as argument\n", argv[i]); + REprintf("ERROR: '%s' needs 4 comma separated parameters as argument\n", argv[i]); return FALSE; } *argv[i]='\0'; *argv[i+1]='\0'; i+=1; @@ -5776,13 +5776,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: week\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: week\n", argv[i]); return FALSE; } U32 week; if (sscanf(argv[i+1], "%u", &week) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: week but '%s' is no valid week\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: week but '%s' is no valid week\n", argv[i], argv[i+1]); return FALSE; } add_operation(new LASoperationConvertWeekToAdjustedGps(week)); @@ -5799,40 +5799,40 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+3) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output\n", argv[i]); + REprintf("ERROR: '%s' needs 3 arguments: input1 input2 output\n", argv[i]); return FALSE; } U32 input1; if (sscanf(argv[i+1], "%u", &input1) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input1\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input1\n", argv[i], argv[i+1]); return FALSE; } if (input1 > 15) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for input1\n", argv[i], input1); + REprintf("ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for input1\n", argv[i], input1); return FALSE; } U32 input2; if (sscanf(argv[i+2], "%u", &input2) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input2\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input2\n", argv[i], argv[i+2]); return FALSE; } if (input2 > 15) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for input2\n", argv[i], input2); + REprintf("ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for input2\n", argv[i], input2); return FALSE; } U32 output; if (sscanf(argv[i+3], "%u", &output) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input3\n", argv[i], argv[i+3]); + REprintf("ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input3\n", argv[i], argv[i+3]); return FALSE; } if (output > 15) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for output\n", argv[i], output); + REprintf("ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for output\n", argv[i], output); return FALSE; } add_operation(new LASoperationAddRegisters(registers, input1, input2, output)); @@ -5844,24 +5844,24 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index scale\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: index scale\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index scale but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: index scale but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } F32 scale; if (sscanf(argv[i+2], "%f", &scale) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index scale but '%s' is no valid scale\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: index scale but '%s' is no valid scale\n", argv[i], argv[i+2]); return FALSE; } if (scale == 0.0f) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index scale but '%g' is no valid scale\n", argv[i], scale); + REprintf("ERROR: '%s' needs 2 arguments: index scale but '%g' is no valid scale\n", argv[i], scale); return FALSE; } transformed_fields |= LASTRANSFORM_Z_COORDINATE; @@ -5872,19 +5872,19 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index scale\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: index scale\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index scale but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 2 arguments: index scale but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } F32 scale; if (sscanf(argv[i+2], "%f", &scale) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: index scale but '%s' is no valid scale\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: index scale but '%s' is no valid scale\n", argv[i], argv[i+2]); return FALSE; } add_operation(new LASoperationAddScaledAttributeToUserData(index, scale)); @@ -5895,13 +5895,13 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: index of attribute\n", argv[i]); return FALSE; } U32 index; if (sscanf(argv[i+1], "%u", &index) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: index of attribute but '%s' is no valid index\n", argv[i], argv[i+1]); return FALSE; } transformed_fields |= LASTRANSFORM_Z_COORDINATE; @@ -5915,40 +5915,40 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+3) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output\n", argv[i]); + REprintf("ERROR: '%s' needs 3 arguments: input1 input2 output\n", argv[i]); return FALSE; } U32 input1; if (sscanf(argv[i+1], "%u", &input1) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input1\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input1\n", argv[i], argv[i+1]); return FALSE; } if (input1 > 15) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for input1\n", argv[i], input1); + REprintf("ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for input1\n", argv[i], input1); return FALSE; } U32 input2; if (sscanf(argv[i+2], "%u", &input2) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input2\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input2\n", argv[i], argv[i+2]); return FALSE; } if (input2 > 15) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for input2\n", argv[i], input2); + REprintf("ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for input2\n", argv[i], input2); return FALSE; } U32 output; if (sscanf(argv[i+3], "%u", &output) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input3\n", argv[i], argv[i+3]); + REprintf("ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input3\n", argv[i], argv[i+3]); return FALSE; } if (output > 15) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for output\n", argv[i], output); + REprintf("ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for output\n", argv[i], output); return FALSE; } add_operation(new LASoperationMultiplyRegisters(registers, input1, input2, output)); @@ -5958,18 +5958,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: scale\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: scale\n", argv[i]); return FALSE; } F32 scale; if (sscanf(argv[i+1], "%f", &scale) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: scale but '%s' is no valid scale\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: scale but '%s' is no valid scale\n", argv[i], argv[i+1]); return FALSE; } if (scale == 0.0f) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: scale but '%g' is no valid scale\n", argv[i], scale); + REprintf("ERROR: '%s' needs 1 argument: scale but '%g' is no valid scale\n", argv[i], scale); return FALSE; } if (strcmp(argv[i]+36,"red") == 0) @@ -6001,18 +6001,18 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: divisor \n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: divisor \n", argv[i]); return FALSE; } F32 divisor; if (sscanf(argv[i+1], "%f", &divisor) != 1) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: scale but '%s' is no valid divisor\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 1 argument: scale but '%s' is no valid divisor\n", argv[i], argv[i+1]); return FALSE; } if (divisor == 0.0f) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: scale but '%g' is no valid divisor\n", argv[i], divisor); + REprintf("ERROR: '%s' needs 1 argument: scale but '%g' is no valid divisor\n", argv[i], divisor); return FALSE; } F32 scale = 1.0f / divisor; @@ -6048,40 +6048,40 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+3) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output\n", argv[i]); + REprintf("ERROR: '%s' needs 3 arguments: input1 input2 output\n", argv[i]); return FALSE; } U32 input1; if (sscanf(argv[i+1], "%u", &input1) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input1\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input1\n", argv[i], argv[i+1]); return FALSE; } if (input1 > 15) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for input1\n", argv[i], input1); + REprintf("ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for input1\n", argv[i], input1); return FALSE; } U32 input2; if (sscanf(argv[i+2], "%u", &input2) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input2\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input2\n", argv[i], argv[i+2]); return FALSE; } if (input2 > 15) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for input2\n", argv[i], input2); + REprintf("ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for input2\n", argv[i], input2); return FALSE; } U32 output; if (sscanf(argv[i+3], "%u", &output) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input3\n", argv[i], argv[i+3]); + REprintf("ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input3\n", argv[i], argv[i+3]); return FALSE; } if (output > 15) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for output\n", argv[i], output); + REprintf("ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for output\n", argv[i], output); return FALSE; } add_operation(new LASoperationSubtractRegisters(registers, input1, input2, output)); @@ -6094,40 +6094,40 @@ BOOL LAStransform::parse(int argc, char* argv[]) { if ((i+3) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output\n", argv[i]); + REprintf("ERROR: '%s' needs 3 arguments: input1 input2 output\n", argv[i]); return FALSE; } U32 input1; if (sscanf(argv[i+1], "%u", &input1) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input1\n", argv[i], argv[i+1]); + REprintf("ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input1\n", argv[i], argv[i+1]); return FALSE; } if (input1 > 15) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for input1\n", argv[i], input1); + REprintf("ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for input1\n", argv[i], input1); return FALSE; } U32 input2; if (sscanf(argv[i+2], "%u", &input2) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input2\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input2\n", argv[i], argv[i+2]); return FALSE; } if (input2 > 15) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for input2\n", argv[i], input2); + REprintf("ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for input2\n", argv[i], input2); return FALSE; } U32 output; if (sscanf(argv[i+3], "%u", &output) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input3\n", argv[i], argv[i+3]); + REprintf("ERROR: '%s' needs 3 arguments: input1 input2 output but '%s' is no valid input3\n", argv[i], argv[i+3]); return FALSE; } if (output > 15) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for output\n", argv[i], output); + REprintf("ERROR: '%s' needs 3 arguments: input1 input2 output but %u is out-of-range for output\n", argv[i], output); return FALSE; } add_operation(new LASoperationDivideRegisters(registers, input1, input2, output)); diff --git a/src/LASlib/lasutility.cpp b/src/LASlib/lasutility.cpp index f666def..a00876f 100644 --- a/src/LASlib/lasutility.cpp +++ b/src/LASlib/lasutility.cpp @@ -483,8 +483,8 @@ void LASbin::add_to_bin(I32 bin) bins_pos = (U32*)malloc(sizeof(U32)*size_pos); if (bins_pos == 0) { - fprintf(stderr, "ERROR: allocating %u pos bins\012", size_pos); - exit(1); + REprintf( "ERROR: allocating %u pos bins\012", size_pos); + throw std::runtime_error("Internal error"); } for (i = 0; i < size_pos; i++) bins_pos[i] = 0; } @@ -494,8 +494,8 @@ void LASbin::add_to_bin(I32 bin) bins_pos = (U32*)realloc(bins_pos, sizeof(U32)*new_size); if (bins_pos == 0) { - fprintf(stderr, "ERROR: reallocating %u pos bins\012", new_size); - exit(1); + REprintf( "ERROR: reallocating %u pos bins\012", new_size); + throw std::runtime_error("Internal error"); } for (i = size_pos; i < new_size; i++) bins_pos[i] = 0; size_pos = new_size; @@ -515,8 +515,8 @@ void LASbin::add_to_bin(I32 bin) bins_neg = (U32*)malloc(sizeof(U32)*size_neg); if (bins_neg == 0) { - fprintf(stderr, "ERROR: allocating %u neg bins\012", size_neg); - exit(1); + REprintf( "ERROR: allocating %u neg bins\012", size_neg); + throw std::runtime_error("Internal error"); } for (i = 0; i < size_neg; i++) bins_neg[i] = 0; } @@ -526,8 +526,8 @@ void LASbin::add_to_bin(I32 bin) bins_neg = (U32*)realloc(bins_neg, sizeof(U32)*new_size); if (bins_neg == 0) { - fprintf(stderr, "ERROR: reallocating %u neg bins\012", new_size); - exit(1); + REprintf( "ERROR: reallocating %u neg bins\012", new_size); + throw std::runtime_error("Internal error"); } for (i = size_neg; i < new_size; i++) bins_neg[i] = 0; size_neg = new_size; @@ -560,13 +560,13 @@ void LASbin::add(I32 item, I32 value) values_pos = (F64*)malloc(sizeof(F64)*size_pos); if (bins_pos == 0) { - fprintf(stderr, "ERROR: allocating %u pos bins\012", size_pos); - exit(1); + REprintf( "ERROR: allocating %u pos bins\012", size_pos); + throw std::runtime_error("Internal error"); } if (values_pos == 0) { - fprintf(stderr, "ERROR: allocating %u pos values\012", size_pos); - exit(1); + REprintf( "ERROR: allocating %u pos values\012", size_pos); + throw std::runtime_error("Internal error"); } for (i = 0; i < size_pos; i++) { bins_pos[i] = 0; values_pos[i] = 0; } } @@ -577,13 +577,13 @@ void LASbin::add(I32 item, I32 value) values_pos = (F64*)realloc(values_pos, sizeof(F64)*new_size); if (bins_pos == 0) { - fprintf(stderr, "ERROR: reallocating %u pos bins\012", new_size); - exit(1); + REprintf( "ERROR: reallocating %u pos bins\012", new_size); + throw std::runtime_error("Internal error"); } if (values_pos == 0) { - fprintf(stderr, "ERROR: reallocating %u pos values\012", new_size); - exit(1); + REprintf( "ERROR: reallocating %u pos values\012", new_size); + throw std::runtime_error("Internal error"); } for (i = size_pos; i < new_size; i++) { bins_pos[i] = 0; values_pos[i] = 0; } size_pos = new_size; @@ -605,13 +605,13 @@ void LASbin::add(I32 item, I32 value) values_neg = (F64*)malloc(sizeof(F64)*size_neg); if (bins_neg == 0) { - fprintf(stderr, "ERROR: allocating %u neg bins\012", size_neg); - exit(1); + REprintf( "ERROR: allocating %u neg bins\012", size_neg); + throw std::runtime_error("Internal error"); } if (values_neg == 0) { - fprintf(stderr, "ERROR: allocating %u neg values\012", size_neg); - exit(1); + REprintf( "ERROR: allocating %u neg values\012", size_neg); + throw std::runtime_error("Internal error"); } for (i = 0; i < size_neg; i++) { bins_neg[i] = 0; values_neg[i] = 0; } } @@ -622,13 +622,13 @@ void LASbin::add(I32 item, I32 value) values_neg = (F64*)realloc(values_neg, sizeof(F64)*new_size); if (bins_neg == 0) { - fprintf(stderr, "ERROR: reallocating %u neg bins\012", new_size); - exit(1); + REprintf( "ERROR: reallocating %u neg bins\012", new_size); + throw std::runtime_error("Internal error"); } if (values_neg == 0) { - fprintf(stderr, "ERROR: reallocating %u neg values\012", new_size); - exit(1); + REprintf( "ERROR: reallocating %u neg values\012", new_size); + throw std::runtime_error("Internal error"); } for (i = size_neg; i < new_size; i++) { bins_neg[i] = 0; values_neg[i] = 0; } size_neg = new_size; @@ -662,13 +662,13 @@ void LASbin::add(F64 item, F64 value) values_pos = (F64*)malloc(sizeof(F64)*size_pos); if (bins_pos == 0) { - fprintf(stderr, "ERROR: allocating %u pos bins\012", size_pos); - exit(1); + REprintf( "ERROR: allocating %u pos bins\012", size_pos); + throw std::runtime_error("Internal error"); } if (values_pos == 0) { - fprintf(stderr, "ERROR: allocating %u pos values\012", size_pos); - exit(1); + REprintf( "ERROR: allocating %u pos values\012", size_pos); + throw std::runtime_error("Internal error"); } for (i = 0; i < size_pos; i++) { bins_pos[i] = 0; values_pos[i] = 0; } } @@ -679,13 +679,13 @@ void LASbin::add(F64 item, F64 value) values_pos = (F64*)realloc(values_pos, sizeof(F64)*new_size); if (bins_pos == 0) { - fprintf(stderr, "ERROR: reallocating %u pos bins\012", new_size); - exit(1); + REprintf( "ERROR: reallocating %u pos bins\012", new_size); + throw std::runtime_error("Internal error"); } if (values_pos == 0) { - fprintf(stderr, "ERROR: reallocating %u pos values\012", new_size); - exit(1); + REprintf( "ERROR: reallocating %u pos values\012", new_size); + throw std::runtime_error("Internal error"); } for (i = size_pos; i < new_size; i++) { bins_pos[i] = 0; values_pos[i] = 0; } size_pos = new_size; @@ -707,13 +707,13 @@ void LASbin::add(F64 item, F64 value) values_neg = (F64*)malloc(sizeof(F64)*size_neg); if (bins_neg == 0) { - fprintf(stderr, "ERROR: allocating %u neg bins\012", size_neg); - exit(1); + REprintf( "ERROR: allocating %u neg bins\012", size_neg); + throw std::runtime_error("Internal error"); } if (values_neg == 0) { - fprintf(stderr, "ERROR: allocating %u neg values\012", size_neg); - exit(1); + REprintf( "ERROR: allocating %u neg values\012", size_neg); + throw std::runtime_error("Internal error"); } for (i = 0; i < size_neg; i++) { bins_neg[i] = 0; values_neg[i] = 0; } } @@ -724,13 +724,13 @@ void LASbin::add(F64 item, F64 value) values_neg = (F64*)realloc(values_neg, sizeof(F64)*new_size); if (bins_neg == 0) { - fprintf(stderr, "ERROR: reallocating %u neg bins\012", new_size); - exit(1); + REprintf( "ERROR: reallocating %u neg bins\012", new_size); + throw std::runtime_error("Internal error"); } if (values_neg == 0) { - fprintf(stderr, "ERROR: reallocating %u neg values\012", new_size); - exit(1); + REprintf( "ERROR: reallocating %u neg values\012", new_size); + throw std::runtime_error("Internal error"); } for (i = size_neg; i < new_size; i++) { bins_neg[i] = 0; values_neg[i] = 0; } size_neg = new_size; @@ -993,13 +993,13 @@ BOOL LAShistogram::parse(int argc, char* argv[]) { if ((i+2) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: name step\n", argv[i]); + REprintf("ERROR: '%s' needs 2 arguments: name step\n", argv[i]); return FALSE; } F64 step = 0.0; if (sscanf(argv[i+2], "%lf", &step) != 1) { - fprintf(stderr,"ERROR: '%s' needs 2 arguments: name step but '%s' is no valid step\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 2 arguments: name step but '%s' is no valid step\n", argv[i], argv[i+2]); return FALSE; } if (!histo(argv[i+1], step)) return FALSE; @@ -1009,13 +1009,13 @@ BOOL LAShistogram::parse(int argc, char* argv[]) { if ((i+3) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: name step name_avg\n", argv[i]); + REprintf("ERROR: '%s' needs 3 arguments: name step name_avg\n", argv[i]); return FALSE; } F64 step = 0.0; if (sscanf(argv[i+2], "%lf", &step) != 1) { - fprintf(stderr,"ERROR: '%s' needs 3 arguments: name step name_avg but '%s' is no valid step\n", argv[i], argv[i+2]); + REprintf("ERROR: '%s' needs 3 arguments: name step name_avg but '%s' is no valid step\n", argv[i], argv[i+2]); return FALSE; } if (!histo_avg(argv[i+1], step, argv[i+3])) return FALSE; @@ -1137,7 +1137,7 @@ BOOL LAShistogram::histo(const CHAR* name, F64 step) wavepacket_location_bin = new LASbin(step); else { - fprintf(stderr,"ERROR: histogram of '%s' not implemented\n", name); + REprintf("ERROR: histogram of '%s' not implemented\n", name); return FALSE; } is_active = TRUE; @@ -1154,7 +1154,7 @@ BOOL LAShistogram::histo_avg(const CHAR* name, F64 step, const CHAR* name_avg) classification_bin_scan_angle = new LASbin(step); else { - fprintf(stderr,"ERROR: histogram of '%s' with '%s' averages not implemented\n", name, name_avg); + REprintf("ERROR: histogram of '%s' with '%s' averages not implemented\n", name, name_avg); return FALSE; } } @@ -1168,7 +1168,7 @@ BOOL LAShistogram::histo_avg(const CHAR* name, F64 step, const CHAR* name_avg) scan_angle_bin_intensity = new LASbin(step); else { - fprintf(stderr,"ERROR: histogram of '%s' with '%s' averages not implemented\n", name, name_avg); + REprintf("ERROR: histogram of '%s' with '%s' averages not implemented\n", name, name_avg); return FALSE; } } @@ -1178,13 +1178,13 @@ BOOL LAShistogram::histo_avg(const CHAR* name, F64 step, const CHAR* name_avg) return_map_bin_intensity = new LASbin(1); else { - fprintf(stderr,"ERROR: histogram of '%s' with '%s' averages not implemented\n", name, name_avg); + REprintf("ERROR: histogram of '%s' with '%s' averages not implemented\n", name, name_avg); return FALSE; } } else { - fprintf(stderr,"ERROR: histogram of '%s' not implemented\n", name); + REprintf("ERROR: histogram of '%s' not implemented\n", name); return FALSE; } is_active = TRUE; diff --git a/src/LASlib/lasvlrpayload.hpp b/src/LASlib/lasvlrpayload.hpp index a9ed0d0..0f65f8f 100644 --- a/src/LASlib/lasvlrpayload.hpp +++ b/src/LASlib/lasvlrpayload.hpp @@ -136,67 +136,67 @@ class LASvlrRasterLAZ : public LASvlrPayload { if (!stream->put32bitsLE((U8*)&nbands)) { - fprintf(stderr,"ERROR: writing LASvlrRasterLAZ.nbands\n"); + REprintf("ERROR: writing LASvlrRasterLAZ.nbands\n"); return FALSE; } if (!stream->put32bitsLE((U8*)&nbits)) { - fprintf(stderr,"ERROR: writing LASvlrRasterLAZ.nbits\n"); + REprintf("ERROR: writing LASvlrRasterLAZ.nbits\n"); return FALSE; } if (!stream->put32bitsLE((U8*)&ncols)) { - fprintf(stderr,"ERROR: writing LASvlrRasterLAZ.ncols\n"); + REprintf("ERROR: writing LASvlrRasterLAZ.ncols\n"); return FALSE; } if (!stream->put32bitsLE((U8*)&nrows)) { - fprintf(stderr,"ERROR: writing LASvlrRasterLAZ.nrows\n"); + REprintf("ERROR: writing LASvlrRasterLAZ.nrows\n"); return FALSE; } if (!stream->put32bitsLE((U8*)&reserved1)) { - fprintf(stderr,"ERROR: writing LASvlrRasterLAZ.reserved1\n"); + REprintf("ERROR: writing LASvlrRasterLAZ.reserved1\n"); return FALSE; } if (!stream->put32bitsLE((U8*)&reserved2)) { - fprintf(stderr,"ERROR: writing LASvlrRasterLAZ.reserved2\n"); + REprintf("ERROR: writing LASvlrRasterLAZ.reserved2\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&stepx)) { - fprintf(stderr,"ERROR: writing LASvlrRasterLAZ.stepx\n"); + REprintf("ERROR: writing LASvlrRasterLAZ.stepx\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&stepx_y)) { - fprintf(stderr,"ERROR: writing LASvlrRasterLAZ.stepx_y\n"); + REprintf("ERROR: writing LASvlrRasterLAZ.stepx_y\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&stepy)) { - fprintf(stderr,"ERROR: writing LASvlrRasterLAZ.stepy\n"); + REprintf("ERROR: writing LASvlrRasterLAZ.stepy\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&stepy_x)) { - fprintf(stderr,"ERROR: writing LASvlrRasterLAZ.stepy_x\n"); + REprintf("ERROR: writing LASvlrRasterLAZ.stepy_x\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&llx)) { - fprintf(stderr,"ERROR: writing LASvlrRasterLAZ.llx\n"); + REprintf("ERROR: writing LASvlrRasterLAZ.llx\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&lly)) { - fprintf(stderr,"ERROR: writing LASvlrRasterLAZ.lly\n"); + REprintf("ERROR: writing LASvlrRasterLAZ.lly\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&sigmaxy)) { - fprintf(stderr,"ERROR: writing LASvlrRasterLAZ.sigmaxy\n"); + REprintf("ERROR: writing LASvlrRasterLAZ.sigmaxy\n"); return FALSE; } return TRUE; @@ -205,67 +205,67 @@ class LASvlrRasterLAZ : public LASvlrPayload { try { stream->get32bitsLE((U8*)&nbands); } catch(...) { - fprintf(stderr,"ERROR: reading LASvlrRasterLAZ.nbands\n"); + REprintf("ERROR: reading LASvlrRasterLAZ.nbands\n"); return FALSE; } try { stream->get32bitsLE((U8*)&nbits); } catch(...) { - fprintf(stderr,"ERROR: reading LASvlrRasterLAZ.nbits\n"); + REprintf("ERROR: reading LASvlrRasterLAZ.nbits\n"); return FALSE; } try { stream->get32bitsLE((U8*)&ncols); } catch(...) { - fprintf(stderr,"ERROR: reading LASvlrRasterLAZ.ncols\n"); + REprintf("ERROR: reading LASvlrRasterLAZ.ncols\n"); return FALSE; } try { stream->get32bitsLE((U8*)&nrows); } catch(...) { - fprintf(stderr,"ERROR: reading LASvlrRasterLAZ.nrows\n"); + REprintf("ERROR: reading LASvlrRasterLAZ.nrows\n"); return FALSE; } try { stream->get32bitsLE((U8*)&reserved1); } catch(...) { - fprintf(stderr,"ERROR: reading LASvlrRasterLAZ.reserved1\n"); + REprintf("ERROR: reading LASvlrRasterLAZ.reserved1\n"); return FALSE; } try { stream->get32bitsLE((U8*)&reserved2); } catch(...) { - fprintf(stderr,"ERROR: reading LASvlrRasterLAZ.reserved2\n"); + REprintf("ERROR: reading LASvlrRasterLAZ.reserved2\n"); return FALSE; } try { stream->get64bitsLE((U8*)&stepx); } catch(...) { - fprintf(stderr,"ERROR: reading LASvlrRasterLAZ.stepx\n"); + REprintf("ERROR: reading LASvlrRasterLAZ.stepx\n"); return FALSE; } try { stream->get64bitsLE((U8*)&stepx_y); } catch(...) { - fprintf(stderr,"ERROR: reading LASvlrRasterLAZ.stepx_y\n"); + REprintf("ERROR: reading LASvlrRasterLAZ.stepx_y\n"); return FALSE; } try { stream->get64bitsLE((U8*)&stepy); } catch(...) { - fprintf(stderr,"ERROR: reading LASvlrRasterLAZ.stepy\n"); + REprintf("ERROR: reading LASvlrRasterLAZ.stepy\n"); return FALSE; } try { stream->get64bitsLE((U8*)&stepy_x); } catch(...) { - fprintf(stderr,"ERROR: reading LASvlrRasterLAZ.stepy_x\n"); + REprintf("ERROR: reading LASvlrRasterLAZ.stepy_x\n"); return FALSE; } try { stream->get64bitsLE((U8*)&llx); } catch(...) { - fprintf(stderr,"ERROR: reading LASvlrRasterLAZ.llx\n"); + REprintf("ERROR: reading LASvlrRasterLAZ.llx\n"); return FALSE; } try { stream->get64bitsLE((U8*)&lly); } catch(...) { - fprintf(stderr,"ERROR: reading LASvlrRasterLAZ.lly\n"); + REprintf("ERROR: reading LASvlrRasterLAZ.lly\n"); return FALSE; } try { stream->get64bitsLE((U8*)&sigmaxy); } catch(...) { - fprintf(stderr,"ERROR: reading LASvlrRasterLAZ.sigmax\n"); + REprintf("ERROR: reading LASvlrRasterLAZ.sigmax\n"); return FALSE; } return TRUE; diff --git a/src/LASlib/laswaveform13reader.cpp b/src/LASlib/laswaveform13reader.cpp index 5d4fae8..646d24e 100644 --- a/src/LASlib/laswaveform13reader.cpp +++ b/src/LASlib/laswaveform13reader.cpp @@ -81,7 +81,7 @@ BOOL LASwaveform13reader::open(const char* file_name, I64 start_of_waveform_data { if (file_name == 0) { - fprintf(stderr,"ERROR: file name pointer is zero\n"); + REprintf("ERROR: file name pointer is zero\n"); return FALSE; } @@ -89,7 +89,7 @@ BOOL LASwaveform13reader::open(const char* file_name, I64 start_of_waveform_data if (wave_packet_descr == 0) { - fprintf(stderr,"ERROR: wave packet descriptor pointer is zero\n"); + REprintf("ERROR: wave packet descriptor pointer is zero\n"); return FALSE; } @@ -97,7 +97,7 @@ BOOL LASwaveform13reader::open(const char* file_name, I64 start_of_waveform_data if (wave_packet_descr[0] != 0) { - fprintf(stderr,"ERROR: wave_packet_descr[0] with index 0 must be zero\n"); + REprintf("ERROR: wave_packet_descr[0] with index 0 must be zero\n"); return FALSE; } @@ -153,7 +153,7 @@ BOOL LASwaveform13reader::open(const char* file_name, I64 start_of_waveform_data if (file == 0) { - fprintf(stderr, "ERROR: cannot open waveform file '%s'\n", file_name); + REprintf( "ERROR: cannot open waveform file '%s'\n", file_name); return FALSE; } @@ -177,7 +177,7 @@ BOOL LASwaveform13reader::open(const char* file_name, I64 start_of_waveform_data char magic[25]; try { stream->getBytes((U8*)magic, 24); } catch(...) { - fprintf(stderr,"ERROR: reading waveform descriptor cross-check\n"); + REprintf("ERROR: reading waveform descriptor cross-check\n"); return FALSE; } @@ -188,7 +188,7 @@ BOOL LASwaveform13reader::open(const char* file_name, I64 start_of_waveform_data U16 i, number; try { stream->get16bitsLE((U8*)&number); } catch(...) { - fprintf(stderr,"ERROR: reading number of waveform descriptors\n"); + REprintf("ERROR: reading number of waveform descriptors\n"); return FALSE; } for (i = 0; i < number; i++) @@ -196,21 +196,21 @@ BOOL LASwaveform13reader::open(const char* file_name, I64 start_of_waveform_data U16 index; try { stream->get16bitsLE((U8*)&index); } catch(...) { - fprintf(stderr,"ERROR: reading index of waveform descriptor %d\n", i); + REprintf("ERROR: reading index of waveform descriptor %d\n", i); return FALSE; } if ((index == 0) || (index > 255)) { - fprintf(stderr,"ERROR: cross-check - index %d of waveform descriptor %d out-of-range\n", index, i); + REprintf("ERROR: cross-check - index %d of waveform descriptor %d out-of-range\n", index, i); return FALSE; } if (wave_packet_descr[index] == 0) { - fprintf(stderr,"WARNING: cross-check - waveform descriptor %d with index %d unknown\n", i, index); + REprintf("WARNING: cross-check - waveform descriptor %d with index %d unknown\n", i, index); I32 dummy; try { stream->get32bitsLE((U8*)&dummy); } catch(...) { - fprintf(stderr,"ERROR: cross-check - reading rest of waveform descriptor %d\n", i); + REprintf("ERROR: cross-check - reading rest of waveform descriptor %d\n", i); return FALSE; } continue; @@ -218,34 +218,34 @@ BOOL LASwaveform13reader::open(const char* file_name, I64 start_of_waveform_data U8 compression; try { stream->getBytes(&compression, 1); } catch(...) { - fprintf(stderr,"ERROR: reading compression of waveform descriptor %d\n", i); + REprintf("ERROR: reading compression of waveform descriptor %d\n", i); return FALSE; } if (compression != wave_packet_descr[index]->getCompressionType()) { - fprintf(stderr,"ERROR: cross-check - compression %d %d of waveform descriptor %d with index %d is different\n", compression, wave_packet_descr[index]->getCompressionType(), i, index); + REprintf("ERROR: cross-check - compression %d %d of waveform descriptor %d with index %d is different\n", compression, wave_packet_descr[index]->getCompressionType(), i, index); return FALSE; } U8 nbits; try { stream->getBytes(&nbits, 1); } catch(...) { - fprintf(stderr,"ERROR: reading nbits of waveform descriptor %d\n", i); + REprintf("ERROR: reading nbits of waveform descriptor %d\n", i); return FALSE; } if (nbits != wave_packet_descr[index]->getBitsPerSample()) { - fprintf(stderr,"ERROR: cross-check - nbits %d %d of waveform descriptor %d with index %d is different\n", nbits, wave_packet_descr[index]->getBitsPerSample(), i, index); + REprintf("ERROR: cross-check - nbits %d %d of waveform descriptor %d with index %d is different\n", nbits, wave_packet_descr[index]->getBitsPerSample(), i, index); return FALSE; } U16 nsamples; try { stream->get16bitsLE((U8*)&nsamples); } catch(...) { - fprintf(stderr,"ERROR: reading nsamples of waveform descriptor %d\n", i); + REprintf("ERROR: reading nsamples of waveform descriptor %d\n", i); return FALSE; } if (nsamples != wave_packet_descr[index]->getNumberOfSamples()) { - fprintf(stderr,"ERROR: cross-check - nsamples %d %d of waveform descriptor %d with index %d is different\n", nsamples, wave_packet_descr[index]->getNumberOfSamples(), i, index); + REprintf("ERROR: cross-check - nsamples %d %d of waveform descriptor %d with index %d is different\n", nsamples, wave_packet_descr[index]->getNumberOfSamples(), i, index); return FALSE; } } @@ -274,14 +274,14 @@ BOOL LASwaveform13reader::read_waveform(const LASpoint* point) if (wave_packet_descr[index] == 0) { - fprintf(stderr, "ERROR: wavepacket is indexing non-existant descriptor %u\n", index); + REprintf( "ERROR: wavepacket is indexing non-existant descriptor %u\n", index); return FALSE; } nbits = wave_packet_descr[index]->getBitsPerSample(); if ((nbits != 8) && (nbits != 16)) { - fprintf(stderr, "ERROR: waveform with %d bits per samples not supported yet\n", nbits); + REprintf( "ERROR: waveform with %d bits per samples not supported yet\n", nbits); return FALSE; } @@ -293,7 +293,7 @@ BOOL LASwaveform13reader::read_waveform(const LASpoint* point) if (nsamples == 0) { - fprintf(stderr, "ERROR: waveform has no samples\n"); + REprintf( "ERROR: waveform has no samples\n"); return FALSE; } @@ -327,7 +327,7 @@ BOOL LASwaveform13reader::read_waveform(const LASpoint* point) { try { stream->getBytes(samples, size); } catch(...) { - fprintf(stderr, "ERROR: cannot read %u bytes for waveform with %u samples of %u bits\n", size, nsamples, nbits); + REprintf( "ERROR: cannot read %u bytes for waveform with %u samples of %u bits\n", size, nsamples, nbits); return FALSE; } } diff --git a/src/LASlib/laswaveform13writer.cpp b/src/LASlib/laswaveform13writer.cpp index aa694de..2b21cd9 100644 --- a/src/LASlib/laswaveform13writer.cpp +++ b/src/LASlib/laswaveform13writer.cpp @@ -73,7 +73,7 @@ BOOL LASwaveform13writer::open(const char* file_name, const LASvlr_wave_packet_d { if (file_name == 0) { - fprintf(stderr,"ERROR: file name pointer is zero\n"); + REprintf("ERROR: file name pointer is zero\n"); return FALSE; } @@ -81,7 +81,7 @@ BOOL LASwaveform13writer::open(const char* file_name, const LASvlr_wave_packet_d if (wave_packet_descr == 0) { - fprintf(stderr,"ERROR: wave packet descriptor pointer is zero\n"); + REprintf("ERROR: wave packet descriptor pointer is zero\n"); return FALSE; } @@ -89,7 +89,7 @@ BOOL LASwaveform13writer::open(const char* file_name, const LASvlr_wave_packet_d if (wave_packet_descr[0] != 0) { - fprintf(stderr,"ERROR: wave_packet_descr[0] with index 0 must be zero\n"); + REprintf("ERROR: wave_packet_descr[0] with index 0 must be zero\n"); return FALSE; } @@ -149,7 +149,7 @@ BOOL LASwaveform13writer::open(const char* file_name, const LASvlr_wave_packet_d if (file == 0) { - fprintf(stderr, "ERROR: cannot open waveform file '%s'\n", file_name_temp); + REprintf( "ERROR: cannot open waveform file '%s'\n", file_name_temp); free(file_name_temp); return FALSE; } @@ -171,7 +171,7 @@ BOOL LASwaveform13writer::open(const char* file_name, const LASvlr_wave_packet_d U16 reserved = 0xAABB; if (!stream->put16bitsLE((U8*)&reserved)) { - fprintf(stderr,"ERROR: writing EVLR reserved\n"); + REprintf("ERROR: writing EVLR reserved\n"); return FALSE; } I8 user_id[16]; @@ -179,19 +179,19 @@ BOOL LASwaveform13writer::open(const char* file_name, const LASvlr_wave_packet_d strcpy(user_id, "LASF_Spec"); if (!stream->putBytes((U8*)user_id, 16)) { - fprintf(stderr,"ERROR: writing EVLR user_id\n"); + REprintf("ERROR: writing EVLR user_id\n"); return FALSE; } U16 record_id = 65535; if (!stream->put16bitsLE((U8*)&record_id)) { - fprintf(stderr,"ERROR: writing EVLR record_id\n"); + REprintf("ERROR: writing EVLR record_id\n"); return FALSE; } I64 record_length_after_header = 0; if (!stream->put64bitsLE((U8*)&record_length_after_header)) { - fprintf(stderr,"ERROR: writing EVLR record_length_after_header\n"); + REprintf("ERROR: writing EVLR record_length_after_header\n"); return FALSE; } I8 description[32]; @@ -199,7 +199,7 @@ BOOL LASwaveform13writer::open(const char* file_name, const LASvlr_wave_packet_d sprintf(description, "%s by LAStools (%d)", (compressed ? "compressed" : "created"), LAS_TOOLS_VERSION); if (!stream->putBytes((U8*)description, 32)) { - fprintf(stderr,"ERROR: writing EVLR description\n"); + REprintf("ERROR: writing EVLR description\n"); return FALSE; } @@ -210,13 +210,13 @@ BOOL LASwaveform13writer::open(const char* file_name, const LASvlr_wave_packet_d if (!stream->putBytes((U8*)magic, 24)) { - fprintf(stderr,"ERROR: writing waveform descriptor cross-check\n"); + REprintf("ERROR: writing waveform descriptor cross-check\n"); return FALSE; } if (!stream->put16bitsLE((U8*)&number)) { - fprintf(stderr,"ERROR: writing number of waveform descriptors\n"); + REprintf("ERROR: writing number of waveform descriptors\n"); return FALSE; } @@ -226,22 +226,22 @@ BOOL LASwaveform13writer::open(const char* file_name, const LASvlr_wave_packet_d { if (!stream->put16bitsLE((U8*)&i)) { - fprintf(stderr,"ERROR: writing index of waveform descriptor %d\n", i); + REprintf("ERROR: writing index of waveform descriptor %d\n", i); return FALSE; } if (!stream->putByte(waveforms[i]->compression)) { - fprintf(stderr,"ERROR: writing compression of waveform descriptor %d\n", i); + REprintf("ERROR: writing compression of waveform descriptor %d\n", i); return FALSE; } if (!stream->putByte(waveforms[i]->nbits)) { - fprintf(stderr,"ERROR: writing nbits of waveform descriptor %d\n", i); + REprintf("ERROR: writing nbits of waveform descriptor %d\n", i); return FALSE; } if (!stream->put16bitsLE((U8*)&(waveforms[i]->nsamples))) { - fprintf(stderr,"ERROR: writing nsamples of waveform descriptor %d\n", i); + REprintf("ERROR: writing nsamples of waveform descriptor %d\n", i); return FALSE; } } @@ -270,14 +270,14 @@ BOOL LASwaveform13writer::write_waveform(LASpoint* point, U8* samples) U32 nbits = waveforms[index]->nbits; if ((nbits != 8) && (nbits != 16)) { - fprintf(stderr, "ERROR: waveform with %d bits per samples not supported yet\n", nbits); + REprintf( "ERROR: waveform with %d bits per samples not supported yet\n", nbits); return FALSE; } U32 nsamples = waveforms[index]->nsamples; if (nsamples == 0) { - fprintf(stderr, "ERROR: waveform has no samples\n"); + REprintf( "ERROR: waveform has no samples\n"); return FALSE; } @@ -293,7 +293,7 @@ BOOL LASwaveform13writer::write_waveform(LASpoint* point, U8* samples) U32 size = ((nbits/8) * nsamples); if (!stream->putBytes(samples, size)) { - fprintf(stderr, "ERROR: cannot write %u bytes for waveform with %u samples of %u bits\n", size, nsamples, nbits); + REprintf( "ERROR: cannot write %u bytes for waveform with %u samples of %u bits\n", size, nsamples, nbits); return FALSE; } point->wavepacket.setSize(size); @@ -338,7 +338,7 @@ void LASwaveform13writer::close() stream->seek(18); if (!stream->put64bitsLE((U8*)&record_length_after_header)) { - fprintf(stderr,"ERROR: updating EVLR record_length_after_header\n"); + REprintf("ERROR: updating EVLR record_length_after_header\n"); } stream->seekEnd(); } diff --git a/src/LASlib/laswriter.cpp b/src/LASlib/laswriter.cpp index 87485b7..e48a590 100644 --- a/src/LASlib/laswriter.cpp +++ b/src/LASlib/laswriter.cpp @@ -64,7 +64,7 @@ LASwriter* LASwriteOpener::open(const LASheader* header) LASwriterLAS* laswriterlas = new LASwriterLAS(); if (!laswriterlas->open(header, (format == LAS_TOOLS_FORMAT_LAZ ? (native ? LASZIP_COMPRESSOR_LAYERED_CHUNKED : LASZIP_COMPRESSOR_CHUNKED) : LASZIP_COMPRESSOR_NONE), 2, chunk_size)) { - fprintf(stderr,"ERROR: cannot open laswriterlas to NULL\n"); + REprintf("ERROR: cannot open laswriterlas to NULL\n"); delete laswriterlas; return 0; } @@ -77,7 +77,7 @@ LASwriter* LASwriteOpener::open(const LASheader* header) LASwriterLAS* laswriterlas = new LASwriterLAS(); if (!laswriterlas->open(file_name, header, (format == LAS_TOOLS_FORMAT_LAZ ? (native ? LASZIP_COMPRESSOR_LAYERED_CHUNKED : LASZIP_COMPRESSOR_CHUNKED) : LASZIP_COMPRESSOR_NONE), 2, chunk_size, io_obuffer_size)) { - fprintf(stderr,"ERROR: cannot open laswriterlas with file name '%s'\n", file_name); + REprintf("ERROR: cannot open laswriterlas with file name '%s'\n", file_name); delete laswriterlas; return 0; } @@ -90,7 +90,7 @@ LASwriter* LASwriteOpener::open(const LASheader* header) else if (optx) laswritertxt->set_ptx(TRUE); if (!laswritertxt->open(file_name, header, parse_string, separator)) { - fprintf(stderr,"ERROR: cannot open laswritertxt with file name '%s'\n", file_name); + REprintf("ERROR: cannot open laswritertxt with file name '%s'\n", file_name); delete laswritertxt; return 0; } @@ -102,7 +102,7 @@ LASwriter* LASwriteOpener::open(const LASheader* header) LASwriterBIN* laswriterbin = new LASwriterBIN(); if (!laswriterbin->open(file_name, header, "ts8")) { - fprintf(stderr,"ERROR: cannot open laswriterbin with file name '%s'\n", file_name); + REprintf("ERROR: cannot open laswriterbin with file name '%s'\n", file_name); delete laswriterbin; return 0; } @@ -113,7 +113,7 @@ LASwriter* LASwriteOpener::open(const LASheader* header) LASwriterQFIT* laswriterqfit = new LASwriterQFIT(); if (!laswriterqfit->open(file_name, header, 40)) { - fprintf(stderr,"ERROR: cannot open laswriterqfit with file name '%s'\n", file_name); + REprintf("ERROR: cannot open laswriterqfit with file name '%s'\n", file_name); delete laswriterqfit; return 0; } @@ -124,7 +124,7 @@ LASwriter* LASwriteOpener::open(const LASheader* header) LASwriterWRL* laswriterwrl = new LASwriterWRL(); if (!laswriterwrl->open(file_name, header, parse_string)) { - fprintf(stderr,"ERROR: cannot open laswriterwrl with file name '%s'\n", file_name); + REprintf("ERROR: cannot open laswriterwrl with file name '%s'\n", file_name); delete laswriterwrl; return 0; } @@ -132,7 +132,7 @@ LASwriter* LASwriteOpener::open(const LASheader* header) } else { - fprintf(stderr,"ERROR: unknown format %d\n", format); + REprintf("ERROR: unknown format %d\n", format); return 0; } } @@ -143,7 +143,7 @@ LASwriter* LASwriteOpener::open(const LASheader* header) LASwriterLAS* laswriterlas = new LASwriterLAS(); if (!laswriterlas->open(stdout, header, (format == LAS_TOOLS_FORMAT_LAZ ? (native ? LASZIP_COMPRESSOR_LAYERED_CHUNKED : LASZIP_COMPRESSOR_CHUNKED) : LASZIP_COMPRESSOR_NONE), 2, chunk_size)) { - fprintf(stderr,"ERROR: cannot open laswriterlas to stdout\n"); + REprintf("ERROR: cannot open laswriterlas to stdout\n"); delete laswriterlas; return 0; } @@ -156,7 +156,7 @@ LASwriter* LASwriteOpener::open(const LASheader* header) else if (optx) laswritertxt->set_ptx(TRUE); if (!laswritertxt->open(stdout, header, parse_string, separator)) { - fprintf(stderr,"ERROR: cannot open laswritertxt to stdout\n"); + REprintf("ERROR: cannot open laswritertxt to stdout\n"); delete laswritertxt; return 0; } @@ -168,7 +168,7 @@ LASwriter* LASwriteOpener::open(const LASheader* header) LASwriterBIN* laswriterbin = new LASwriterBIN(); if (!laswriterbin->open(stdout, header, "ts8")) { - fprintf(stderr,"ERROR: cannot open laswriterbin to stdout\n"); + REprintf("ERROR: cannot open laswriterbin to stdout\n"); delete laswriterbin; return 0; } @@ -179,7 +179,7 @@ LASwriter* LASwriteOpener::open(const LASheader* header) LASwriterQFIT* laswriterqfit = new LASwriterQFIT(); if (!laswriterqfit->open(stdout, header, 40)) { - fprintf(stderr,"ERROR: cannot open laswriterbin to stdout\n"); + REprintf("ERROR: cannot open laswriterbin to stdout\n"); delete laswriterqfit; return 0; } @@ -190,7 +190,7 @@ LASwriter* LASwriteOpener::open(const LASheader* header) LASwriterWRL* laswriterwrl = new LASwriterWRL(); if (!laswriterwrl->open(stdout, header, parse_string)) { - fprintf(stderr,"ERROR: cannot open laswriterwrl with file name '%s'\n", file_name); + REprintf("ERROR: cannot open laswriterwrl with file name '%s'\n", file_name); delete laswriterwrl; return 0; } @@ -198,13 +198,13 @@ LASwriter* LASwriteOpener::open(const LASheader* header) } else { - fprintf(stderr,"ERROR: unknown format %d\n", format); + REprintf("ERROR: unknown format %d\n", format); return 0; } } else { - fprintf(stderr,"ERROR: no laswriter output specified\n"); + REprintf("ERROR: no laswriter output specified\n"); return 0; } } @@ -226,18 +226,18 @@ LASwaveform13writer* LASwriteOpener::open_waveform13(const LASheader* lasheader) void LASwriteOpener::usage() const { - fprintf(stderr,"Supported LAS Outputs\n"); - fprintf(stderr," -o lidar.las\n"); - fprintf(stderr," -o lidar.laz\n"); - fprintf(stderr," -o xyzta.txt -oparse xyzta (on-the-fly to ASCII)\n"); - fprintf(stderr," -o terrasolid.bin\n"); - fprintf(stderr," -o nasa.qi\n"); - fprintf(stderr," -odir C:%cdata%cground (specify output directory)\n", DIRECTORY_SLASH, DIRECTORY_SLASH); - fprintf(stderr," -odix _classified (specify file name appendix)\n"); - fprintf(stderr," -ocut 2 (cut the last two characters from name)\n"); - fprintf(stderr," -olas -olaz -otxt -obin -oqfit (specify format)\n"); - fprintf(stderr," -stdout (pipe to stdout)\n"); - fprintf(stderr," -nil (pipe to NULL)\n"); + REprintf("Supported LAS Outputs\n"); + REprintf(" -o lidar.las\n"); + REprintf(" -o lidar.laz\n"); + REprintf(" -o xyzta.txt -oparse xyzta (on-the-fly to ASCII)\n"); + REprintf(" -o terrasolid.bin\n"); + REprintf(" -o nasa.qi\n"); + REprintf(" -odir C:%cdata%cground (specify output directory)\n", DIRECTORY_SLASH, DIRECTORY_SLASH); + REprintf(" -odix _classified (specify file name appendix)\n"); + REprintf(" -ocut 2 (cut the last two characters from name)\n"); + REprintf(" -olas -olaz -otxt -obin -oqfit (specify format)\n"); + REprintf(" -stdout (pipe to stdout)\n"); + REprintf(" -nil (pipe to NULL)\n"); } BOOL LASwriteOpener::parse(int argc, char* argv[]) @@ -258,7 +258,7 @@ BOOL LASwriteOpener::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: file_name\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: file_name\n", argv[i]); return FALSE; } set_file_name(argv[i+1]); @@ -268,12 +268,12 @@ BOOL LASwriteOpener::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: directory\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: directory\n", argv[i]); return FALSE; } if (!set_directory(argv[i+1])) { - fprintf(stderr,"ERROR: '%s' is not a valid directory\n", argv[i+1]); + REprintf("ERROR: '%s' is not a valid directory\n", argv[i+1]); return FALSE; } *argv[i]='\0'; *argv[i+1]='\0'; i+=1; @@ -282,7 +282,7 @@ BOOL LASwriteOpener::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: appendix\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: appendix\n", argv[i]); return FALSE; } set_appendix(argv[i+1]); @@ -292,7 +292,7 @@ BOOL LASwriteOpener::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: number of characters to cut\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: number of characters to cut\n", argv[i]); return FALSE; } set_cut(atoi(argv[i+1])); @@ -360,7 +360,7 @@ BOOL LASwriteOpener::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: number_points\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: number_points\n", argv[i]); return FALSE; } set_chunk_size(atoi(argv[i+1])); @@ -370,7 +370,7 @@ BOOL LASwriteOpener::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: string\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: string\n", argv[i]); return FALSE; } set_parse_string(argv[i+1]); @@ -380,7 +380,7 @@ BOOL LASwriteOpener::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: separator\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: separator\n", argv[i]); return FALSE; } set_separator(argv[i+1]); @@ -390,7 +390,7 @@ BOOL LASwriteOpener::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: scale\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: scale\n", argv[i]); return FALSE; } set_scale_rgb((F32)atof(argv[i+1])); @@ -410,7 +410,7 @@ BOOL LASwriteOpener::parse(int argc, char* argv[]) { if ((i+1) >= argc) { - fprintf(stderr,"ERROR: '%s' needs 1 argument: size\n", argv[i]); + REprintf("ERROR: '%s' needs 1 argument: size\n", argv[i]); return FALSE; } set_io_obuffer_size((I32)atoi(argv[i+1])); @@ -432,10 +432,10 @@ BOOL LASwriteOpener::set_directory(const CHAR* directory) { if (strstr(directory, ";") || strstr(directory, "\"")) { - fprintf(stderr,"WARNING: specified '-odir' seems to contain a substring '\\\"' such\n"); - fprintf(stderr," as -odir \"D:\\\" or -odir \"..\\tiles\\\". this command will\n"); - fprintf(stderr," probably fail. please use -odir \"D:\" or -odir \"..\\tiles\"\n"); - fprintf(stderr," instead.\n"); + REprintf("WARNING: specified '-odir' seems to contain a substring '\\\"' such\n"); + REprintf(" as -odir \"D:\\\" or -odir \"..\\tiles\\\". this command will\n"); + REprintf(" probably fail. please use -odir \"D:\" or -odir \"..\\tiles\"\n"); + REprintf(" instead.\n"); } this->directory = LASCopyString(directory); I32 len = (I32)strlen(this->directory); @@ -819,7 +819,7 @@ void LASwriteOpener::make_file_name(const CHAR* file_name, I32 file_number) } if (file_num) { - fprintf(stderr,"WARNING: file name number %d too big to store in '%s'. use more digits.\n", file_number, this->file_name); + REprintf("WARNING: file name number %d too big to store in '%s'. use more digits.\n", file_number, this->file_name); } } else @@ -919,9 +919,9 @@ void LASwriteOpener::make_file_name(const CHAR* file_name, I32 file_number) { this->file_name = LASCopyString("temp.txt"); } - fprintf(stderr,"WARNING: generated output name '%s'\n", file_name); - fprintf(stderr," identical to input name. changed to '%s'.\n", this->file_name); - fprintf(stderr," you can override this safety measure with '-oforce'.\n"); + REprintf("WARNING: generated output name '%s'\n", file_name); + REprintf(" identical to input name. changed to '%s'.\n", this->file_name); + REprintf(" you can override this safety measure with '-oforce'.\n"); } } } diff --git a/src/LASlib/laswriter_bin.cpp b/src/LASlib/laswriter_bin.cpp index c7bd84f..e9c413a 100644 --- a/src/LASlib/laswriter_bin.cpp +++ b/src/LASlib/laswriter_bin.cpp @@ -89,7 +89,7 @@ BOOL LASwriterBIN::open(const char* file_name, const LASheader* header, const ch { if (file_name == 0) { - fprintf(stderr,"ERROR: file name pointer is zero\n"); + REprintf("ERROR: file name pointer is zero\n"); return FALSE; } @@ -97,13 +97,13 @@ BOOL LASwriterBIN::open(const char* file_name, const LASheader* header, const ch if (file == 0) { - fprintf(stderr, "ERROR: cannot open file '%s'\n", file_name); + REprintf( "ERROR: cannot open file '%s'\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, io_buffer_size) != 0) { - fprintf(stderr, "WARNING: setvbuf() failed with buffer size %u\n", io_buffer_size); + REprintf( "WARNING: setvbuf() failed with buffer size %u\n", io_buffer_size); } ByteStreamOut* out; @@ -119,7 +119,7 @@ BOOL LASwriterBIN::open(FILE* file, const LASheader* header, const char* version { if (file == 0) { - fprintf(stderr,"ERROR: file pointer is zero\n"); + REprintf("ERROR: file pointer is zero\n"); return FALSE; } @@ -128,7 +128,7 @@ BOOL LASwriterBIN::open(FILE* file, const LASheader* header, const char* version { if(_setmode( _fileno( stdout ), _O_BINARY ) == -1 ) { - fprintf(stderr, "ERROR: cannot set stdout to binary (untranslated) mode\n"); + REprintf( "ERROR: cannot set stdout to binary (untranslated) mode\n"); } } #endif @@ -146,14 +146,14 @@ BOOL LASwriterBIN::open(ByteStreamOut* stream, const LASheader* header, const ch { if (stream == 0) { - fprintf(stderr,"ERROR: ByteStreamOut pointer is zero\n"); + REprintf("ERROR: ByteStreamOut pointer is zero\n"); return FALSE; } this->stream = stream; if (header == 0) { - fprintf(stderr,"ERROR: LASheader pointer is zero\n"); + REprintf("ERROR: LASheader pointer is zero\n"); return FALSE; } @@ -258,9 +258,9 @@ I64 LASwriterBIN::close(BOOL update_npoints) if (!stream->isSeekable()) { #ifdef _WIN32 - fprintf(stderr, "ERROR: stream not seekable. cannot update header from %I64d to %I64d points.\n", npoints, p_count); + REprintf( "ERROR: stream not seekable. cannot update header from %I64d to %I64d points.\n", npoints, p_count); #else - fprintf(stderr, "ERROR: stream not seekable. cannot update header from %lld to %lld points.\n", npoints, p_count); + REprintf( "ERROR: stream not seekable. cannot update header from %lld to %lld points.\n", npoints, p_count); #endif } else diff --git a/src/LASlib/laswriter_las.cpp b/src/LASlib/laswriter_las.cpp index 83d7572..b5303bd 100644 --- a/src/LASlib/laswriter_las.cpp +++ b/src/LASlib/laswriter_las.cpp @@ -60,7 +60,7 @@ BOOL LASwriterLAS::open(const char* file_name, const LASheader* header, U32 comp { if (file_name == 0) { - fprintf(stderr,"ERROR: file name pointer is zero\n"); + REprintf("ERROR: file name pointer is zero\n"); return FALSE; } @@ -72,7 +72,7 @@ BOOL LASwriterLAS::open(const char* file_name, const LASheader* header, U32 comp file = _wfopen(utf16_file_name, L"wb"); if (file == 0) { - fprintf(stderr, "ERROR: cannot open file '%ws' for write\n", utf16_file_name); + REprintf( "ERROR: cannot open file '%ws' for write\n", utf16_file_name); } delete [] utf16_file_name; } @@ -82,13 +82,13 @@ BOOL LASwriterLAS::open(const char* file_name, const LASheader* header, U32 comp if (file == 0) { - fprintf(stderr, "ERROR: cannot open file '%s' for write\n", file_name); + REprintf( "ERROR: cannot open file '%s' for write\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, io_buffer_size) != 0) { - fprintf(stderr, "WARNING: setvbuf() failed with buffer size %d\n", io_buffer_size); + REprintf( "WARNING: setvbuf() failed with buffer size %d\n", io_buffer_size); } ByteStreamOut* out; @@ -104,7 +104,7 @@ BOOL LASwriterLAS::open(FILE* file, const LASheader* header, U32 compressor, I32 { if (file == 0) { - fprintf(stderr,"ERROR: file pointer is zero\n"); + REprintf("ERROR: file pointer is zero\n"); return FALSE; } @@ -113,7 +113,7 @@ BOOL LASwriterLAS::open(FILE* file, const LASheader* header, U32 compressor, I32 { if(_setmode( _fileno( stdout ), _O_BINARY ) == -1 ) { - fprintf(stderr, "ERROR: cannot set stdout to binary (untranslated) mode\n"); + REprintf( "ERROR: cannot set stdout to binary (untranslated) mode\n"); } } #endif @@ -144,14 +144,14 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp if (stream == 0) { - fprintf(stderr,"ERROR: ByteStreamOut pointer is zero\n"); + REprintf("ERROR: ByteStreamOut pointer is zero\n"); return FALSE; } this->stream = stream; if (header == 0) { - fprintf(stderr,"ERROR: LASheader pointer is zero\n"); + REprintf("ERROR: LASheader pointer is zero\n"); return FALSE; } @@ -190,7 +190,7 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp if (compressor && (point_data_format > 5) && (compressor != LASZIP_COMPRESSOR_LAYERED_CHUNKED)) { - fprintf(stderr,"ERROR: point type %d requires using \"native LAS 1.4 extension\" of LASzip\n", point_data_format); + REprintf("ERROR: point type %d requires using \"native LAS 1.4 extension\" of LASzip\n", point_data_format); return FALSE; } @@ -204,7 +204,7 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp laszip->setup(point.num_items, point.items, compressor); if (chunk_size > -1) laszip->set_chunk_size((U32)chunk_size); if (compressor == LASZIP_COMPRESSOR_NONE) laszip->request_version(0); - else if (chunk_size == 0 && (point_data_format <= 5)) { fprintf(stderr,"ERROR: adaptive chunking is depricated for point type %d.\n only available for new LAS 1.4 point types 6 or higher.\n", point_data_format); return FALSE; } + else if (chunk_size == 0 && (point_data_format <= 5)) { REprintf("ERROR: adaptive chunking is depricated for point type %d.\n only available for new LAS 1.4 point types 6 or higher.\n", point_data_format); return FALSE; } else if (requested_version) laszip->request_version(requested_version); else laszip->request_version(2); laszip_vlr_data_size = 34 + 6*laszip->num_items; @@ -217,7 +217,7 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp { if (!writer->setup(laszip->num_items, laszip->items, laszip)) { - fprintf(stderr,"ERROR: point type %d of size %d not supported (with LASzip)\n", header->point_data_format, header->point_data_record_length); + REprintf("ERROR: point type %d of size %d not supported (with LASzip)\n", header->point_data_format, header->point_data_record_length); return FALSE; } } @@ -225,7 +225,7 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp { if (!writer->setup(point.num_items, point.items)) { - fprintf(stderr,"ERROR: point type %d of size %d not supported\n", header->point_data_format, header->point_data_record_length); + REprintf("ERROR: point type %d of size %d not supported\n", header->point_data_format, header->point_data_record_length); return FALSE; } } @@ -238,86 +238,86 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp if (!stream->putBytes((U8*)&(header->file_signature), 4)) { - fprintf(stderr,"ERROR: writing header->file_signature\n"); + REprintf("ERROR: writing header->file_signature\n"); return FALSE; } if (!stream->put16bitsLE((U8*)&(header->file_source_ID))) { - fprintf(stderr,"ERROR: writing header->file_source_ID\n"); + REprintf("ERROR: writing header->file_source_ID\n"); return FALSE; } if (!stream->put16bitsLE((U8*)&(header->global_encoding))) { - fprintf(stderr,"ERROR: writing header->global_encoding\n"); + REprintf("ERROR: writing header->global_encoding\n"); return FALSE; } if (!stream->put32bitsLE((U8*)&(header->project_ID_GUID_data_1))) { - fprintf(stderr,"ERROR: writing header->project_ID_GUID_data_1\n"); + REprintf("ERROR: writing header->project_ID_GUID_data_1\n"); return FALSE; } if (!stream->put16bitsLE((U8*)&(header->project_ID_GUID_data_2))) { - fprintf(stderr,"ERROR: writing header->project_ID_GUID_data_2\n"); + REprintf("ERROR: writing header->project_ID_GUID_data_2\n"); return FALSE; } if (!stream->put16bitsLE((U8*)&(header->project_ID_GUID_data_3))) { - fprintf(stderr,"ERROR: writing header->project_ID_GUID_data_3\n"); + REprintf("ERROR: writing header->project_ID_GUID_data_3\n"); return FALSE; } if (!stream->putBytes((U8*)header->project_ID_GUID_data_4, 8)) { - fprintf(stderr,"ERROR: writing header->project_ID_GUID_data_4\n"); + REprintf("ERROR: writing header->project_ID_GUID_data_4\n"); return FALSE; } // check version major U8 version_major = header->version_major; if (header->version_major != 1) { - fprintf(stderr,"WARNING: header->version_major is %d. writing 1 instead.\n", header->version_major); + REprintf("WARNING: header->version_major is %d. writing 1 instead.\n", header->version_major); version_major = 1; } if (!stream->putByte(version_major)) { - fprintf(stderr,"ERROR: writing header->version_major\n"); + REprintf("ERROR: writing header->version_major\n"); return FALSE; } // check version minor U8 version_minor = header->version_minor; if (version_minor > 4) { - fprintf(stderr,"WARNING: header->version_minor is %d. writing 4 instead.\n", version_minor); + REprintf("WARNING: header->version_minor is %d. writing 4 instead.\n", version_minor); version_minor = 4; } if (!stream->putByte(version_minor)) { - fprintf(stderr,"ERROR: writing header->version_minor\n"); + REprintf("ERROR: writing header->version_minor\n"); return FALSE; } if (!stream->putBytes((U8*)header->system_identifier, 32)) { - fprintf(stderr,"ERROR: writing header->system_identifier\n"); + REprintf("ERROR: writing header->system_identifier\n"); return FALSE; } if (!stream->putBytes((U8*)header->generating_software, 32)) { - fprintf(stderr,"ERROR: writing header->generating_software\n"); + REprintf("ERROR: writing header->generating_software\n"); return FALSE; } if (!stream->put16bitsLE((U8*)&(header->file_creation_day))) { - fprintf(stderr,"ERROR: writing header->file_creation_day\n"); + REprintf("ERROR: writing header->file_creation_day\n"); return FALSE; } if (!stream->put16bitsLE((U8*)&(header->file_creation_year))) { - fprintf(stderr,"ERROR: writing header->file_creation_year\n"); + REprintf("ERROR: writing header->file_creation_year\n"); return FALSE; } if (!stream->put16bitsLE((U8*)&(header->header_size))) { - fprintf(stderr,"ERROR: writing header->header_size\n"); + REprintf("ERROR: writing header->header_size\n"); return FALSE; } U32 offset_to_point_data = header->offset_to_point_data; @@ -326,7 +326,7 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp if (header->vlr_lasoriginal) offset_to_point_data += (54 + 176); if (!stream->put32bitsLE((U8*)&offset_to_point_data)) { - fprintf(stderr,"ERROR: writing header->offset_to_point_data\n"); + REprintf("ERROR: writing header->offset_to_point_data\n"); return FALSE; } U32 number_of_variable_length_records = header->number_of_variable_length_records; @@ -335,91 +335,91 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp if (header->vlr_lasoriginal) number_of_variable_length_records++; if (!stream->put32bitsLE((U8*)&(number_of_variable_length_records))) { - fprintf(stderr,"ERROR: writing header->number_of_variable_length_records\n"); + REprintf("ERROR: writing header->number_of_variable_length_records\n"); return FALSE; } if (compressor) point_data_format |= 128; if (!stream->putByte(point_data_format)) { - fprintf(stderr,"ERROR: writing header->point_data_format\n"); + REprintf("ERROR: writing header->point_data_format\n"); return FALSE; } if (!stream->put16bitsLE((U8*)&(header->point_data_record_length))) { - fprintf(stderr,"ERROR: writing header->point_data_record_length\n"); + REprintf("ERROR: writing header->point_data_record_length\n"); return FALSE; } if (!stream->put32bitsLE((U8*)&(header->number_of_point_records))) { - fprintf(stderr,"ERROR: writing header->number_of_point_records\n"); + REprintf("ERROR: writing header->number_of_point_records\n"); return FALSE; } for (i = 0; i < 5; i++) { if (!stream->put32bitsLE((U8*)&(header->number_of_points_by_return[i]))) { - fprintf(stderr,"ERROR: writing header->number_of_points_by_return[%d]\n", i); + REprintf("ERROR: writing header->number_of_points_by_return[%d]\n", i); return FALSE; } } if (!stream->put64bitsLE((U8*)&(header->x_scale_factor))) { - fprintf(stderr,"ERROR: writing header->x_scale_factor\n"); + REprintf("ERROR: writing header->x_scale_factor\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->y_scale_factor))) { - fprintf(stderr,"ERROR: writing header->y_scale_factor\n"); + REprintf("ERROR: writing header->y_scale_factor\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->z_scale_factor))) { - fprintf(stderr,"ERROR: writing header->z_scale_factor\n"); + REprintf("ERROR: writing header->z_scale_factor\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->x_offset))) { - fprintf(stderr,"ERROR: writing header->x_offset\n"); + REprintf("ERROR: writing header->x_offset\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->y_offset))) { - fprintf(stderr,"ERROR: writing header->y_offset\n"); + REprintf("ERROR: writing header->y_offset\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->z_offset))) { - fprintf(stderr,"ERROR: writing header->z_offset\n"); + REprintf("ERROR: writing header->z_offset\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->max_x))) { - fprintf(stderr,"ERROR: writing header->max_x\n"); + REprintf("ERROR: writing header->max_x\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->min_x))) { - fprintf(stderr,"ERROR: writing header->min_x\n"); + REprintf("ERROR: writing header->min_x\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->max_y))) { - fprintf(stderr,"ERROR: writing header->max_y\n"); + REprintf("ERROR: writing header->max_y\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->min_y))) { - fprintf(stderr,"ERROR: writing header->min_y\n"); + REprintf("ERROR: writing header->min_y\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->max_z))) { - fprintf(stderr,"ERROR: writing header->max_z\n"); + REprintf("ERROR: writing header->max_z\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->min_z))) { - fprintf(stderr,"ERROR: writing header->min_z\n"); + REprintf("ERROR: writing header->min_z\n"); return FALSE; } @@ -430,15 +430,15 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp if (start_of_waveform_data_packet_record != 0) { #ifdef _WIN32 - fprintf(stderr,"WARNING: header->start_of_waveform_data_packet_record is %I64d. writing 0 instead.\n", start_of_waveform_data_packet_record); + REprintf("WARNING: header->start_of_waveform_data_packet_record is %I64d. writing 0 instead.\n", start_of_waveform_data_packet_record); #else - fprintf(stderr,"WARNING: header->start_of_waveform_data_packet_record is %lld. writing 0 instead.\n", start_of_waveform_data_packet_record); + REprintf("WARNING: header->start_of_waveform_data_packet_record is %lld. writing 0 instead.\n", start_of_waveform_data_packet_record); #endif start_of_waveform_data_packet_record = 0; } if (!stream->put64bitsLE((U8*)&start_of_waveform_data_packet_record)) { - fprintf(stderr,"ERROR: writing start_of_waveform_data_packet_record\n"); + REprintf("ERROR: writing start_of_waveform_data_packet_record\n"); return FALSE; } } @@ -458,13 +458,13 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp start_of_first_extended_variable_length_record = header->start_of_first_extended_variable_length_record; if (!stream->put64bitsLE((U8*)&(start_of_first_extended_variable_length_record))) { - fprintf(stderr,"ERROR: writing header->start_of_first_extended_variable_length_record\n"); + REprintf("ERROR: writing header->start_of_first_extended_variable_length_record\n"); return FALSE; } number_of_extended_variable_length_records = header->number_of_extended_variable_length_records; if (!stream->put32bitsLE((U8*)&(number_of_extended_variable_length_records))) { - fprintf(stderr,"ERROR: writing header->number_of_extended_variable_length_records\n"); + REprintf("ERROR: writing header->number_of_extended_variable_length_records\n"); return FALSE; } evlrs = header->evlrs; @@ -475,7 +475,7 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp extended_number_of_point_records = header->extended_number_of_point_records; if (!stream->put64bitsLE((U8*)&extended_number_of_point_records)) { - fprintf(stderr,"ERROR: writing header->extended_number_of_point_records\n"); + REprintf("ERROR: writing header->extended_number_of_point_records\n"); return FALSE; } U64 extended_number_of_points_by_return; @@ -487,7 +487,7 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp extended_number_of_points_by_return = header->extended_number_of_points_by_return[i]; if (!stream->put64bitsLE((U8*)&extended_number_of_points_by_return)) { - fprintf(stderr,"ERROR: writing header->extended_number_of_points_by_return[%d]\n", i); + REprintf("ERROR: writing header->extended_number_of_points_by_return[%d]\n", i); return FALSE; } } @@ -506,13 +506,13 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp { if (!stream->putBytes((U8*)header->user_data_in_header, header->user_data_in_header_size)) { - fprintf(stderr,"ERROR: writing %d bytes of data from header->user_data_in_header\n", header->user_data_in_header_size); + REprintf("ERROR: writing %d bytes of data from header->user_data_in_header\n", header->user_data_in_header_size); return FALSE; } } else { - fprintf(stderr,"ERROR: there should be %d bytes of data in header->user_data_in_header\n", header->user_data_in_header_size); + REprintf("ERROR: there should be %d bytes of data in header->user_data_in_header\n", header->user_data_in_header_size); return FALSE; } } @@ -525,34 +525,34 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp if (header->vlrs[i].reserved != 0xAABB) { -// fprintf(stderr,"WARNING: wrong header->vlrs[%d].reserved: %d != 0xAABB\n", i, header->vlrs[i].reserved); +// REprintf("WARNING: wrong header->vlrs[%d].reserved: %d != 0xAABB\n", i, header->vlrs[i].reserved); } // write variable length records variable after variable (to avoid alignment issues) if (!stream->put16bitsLE((U8*)&(header->vlrs[i].reserved))) { - fprintf(stderr,"ERROR: writing header->vlrs[%d].reserved\n", i); + REprintf("ERROR: writing header->vlrs[%d].reserved\n", i); return FALSE; } if (!stream->putBytes((U8*)header->vlrs[i].user_id, 16)) { - fprintf(stderr,"ERROR: writing header->vlrs[%d].user_id\n", i); + REprintf("ERROR: writing header->vlrs[%d].user_id\n", i); return FALSE; } if (!stream->put16bitsLE((U8*)&(header->vlrs[i].record_id))) { - fprintf(stderr,"ERROR: writing header->vlrs[%d].record_id\n", i); + REprintf("ERROR: writing header->vlrs[%d].record_id\n", i); return FALSE; } if (!stream->put16bitsLE((U8*)&(header->vlrs[i].record_length_after_header))) { - fprintf(stderr,"ERROR: writing header->vlrs[%d].record_length_after_header\n", i); + REprintf("ERROR: writing header->vlrs[%d].record_length_after_header\n", i); return FALSE; } if (!stream->putBytes((U8*)header->vlrs[i].description, 32)) { - fprintf(stderr,"ERROR: writing header->vlrs[%d].description\n", i); + REprintf("ERROR: writing header->vlrs[%d].description\n", i); return FALSE; } @@ -564,13 +564,13 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp { if (!stream->putBytes((U8*)header->vlrs[i].data, header->vlrs[i].record_length_after_header)) { - fprintf(stderr,"ERROR: writing %d bytes of data from header->vlrs[%d].data\n", header->vlrs[i].record_length_after_header, i); + REprintf("ERROR: writing %d bytes of data from header->vlrs[%d].data\n", header->vlrs[i].record_length_after_header, i); return FALSE; } } else { - fprintf(stderr,"ERROR: there should be %d bytes of data in header->vlrs[%d].data\n", header->vlrs[i].record_length_after_header, i); + REprintf("ERROR: there should be %d bytes of data in header->vlrs[%d].data\n", header->vlrs[i].record_length_after_header, i); return FALSE; } } @@ -585,25 +585,25 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp U16 reserved = 0xAABB; if (!stream->put16bitsLE((U8*)&(reserved))) { - fprintf(stderr,"ERROR: writing reserved %d\n", (I32)reserved); + REprintf("ERROR: writing reserved %d\n", (I32)reserved); return FALSE; } U8 user_id[16] = "laszip encoded\0"; if (!stream->putBytes((U8*)user_id, 16)) { - fprintf(stderr,"ERROR: writing user_id %s\n", user_id); + REprintf("ERROR: writing user_id %s\n", user_id); return FALSE; } U16 record_id = 22204; if (!stream->put16bitsLE((U8*)&(record_id))) { - fprintf(stderr,"ERROR: writing record_id %d\n", (I32)record_id); + REprintf("ERROR: writing record_id %d\n", (I32)record_id); return FALSE; } U16 record_length_after_header = laszip_vlr_data_size; if (!stream->put16bitsLE((U8*)&(record_length_after_header))) { - fprintf(stderr,"ERROR: writing record_length_after_header %d\n", (I32)record_length_after_header); + REprintf("ERROR: writing record_length_after_header %d\n", (I32)record_length_after_header); return FALSE; } char description[32]; @@ -611,7 +611,7 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp sprintf(description, "by laszip of LAStools (%d)", LAS_TOOLS_VERSION); if (!stream->putBytes((U8*)description, 32)) { - fprintf(stderr,"ERROR: writing description %s\n", description); + REprintf("ERROR: writing description %s\n", description); return FALSE; } // write the data following the header of the variable length record @@ -632,69 +632,69 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp if (!stream->put16bitsLE((U8*)&(laszip->compressor))) { - fprintf(stderr,"ERROR: writing compressor %d\n", (I32)compressor); + REprintf("ERROR: writing compressor %d\n", (I32)compressor); return FALSE; } if (!stream->put16bitsLE((U8*)&(laszip->coder))) { - fprintf(stderr,"ERROR: writing coder %d\n", (I32)laszip->coder); + REprintf("ERROR: writing coder %d\n", (I32)laszip->coder); return FALSE; } if (!stream->putByte(laszip->version_major)) { - fprintf(stderr,"ERROR: writing version_major %d\n", laszip->version_major); + REprintf("ERROR: writing version_major %d\n", laszip->version_major); return FALSE; } if (!stream->putByte(laszip->version_minor)) { - fprintf(stderr,"ERROR: writing version_minor %d\n", laszip->version_minor); + REprintf("ERROR: writing version_minor %d\n", laszip->version_minor); return FALSE; } if (!stream->put16bitsLE((U8*)&(laszip->version_revision))) { - fprintf(stderr,"ERROR: writing version_revision %d\n", laszip->version_revision); + REprintf("ERROR: writing version_revision %d\n", laszip->version_revision); return FALSE; } if (!stream->put32bitsLE((U8*)&(laszip->options))) { - fprintf(stderr,"ERROR: writing options %d\n", (I32)laszip->options); + REprintf("ERROR: writing options %d\n", (I32)laszip->options); return FALSE; } if (!stream->put32bitsLE((U8*)&(laszip->chunk_size))) { - fprintf(stderr,"ERROR: writing chunk_size %d\n", laszip->chunk_size); + REprintf("ERROR: writing chunk_size %d\n", laszip->chunk_size); return FALSE; } if (!stream->put64bitsLE((U8*)&(laszip->number_of_special_evlrs))) { - fprintf(stderr,"ERROR: writing number_of_special_evlrs %d\n", (I32)laszip->number_of_special_evlrs); + REprintf("ERROR: writing number_of_special_evlrs %d\n", (I32)laszip->number_of_special_evlrs); return FALSE; } if (!stream->put64bitsLE((U8*)&(laszip->offset_to_special_evlrs))) { - fprintf(stderr,"ERROR: writing offset_to_special_evlrs %d\n", (I32)laszip->offset_to_special_evlrs); + REprintf("ERROR: writing offset_to_special_evlrs %d\n", (I32)laszip->offset_to_special_evlrs); return FALSE; } if (!stream->put16bitsLE((U8*)&(laszip->num_items))) { - fprintf(stderr,"ERROR: writing num_items %d\n", laszip->num_items); + REprintf("ERROR: writing num_items %d\n", laszip->num_items); return FALSE; } for (i = 0; i < laszip->num_items; i++) { if (!stream->put16bitsLE((U8*)&(laszip->items[i].type))) { - fprintf(stderr,"ERROR: writing type %d of item %d\n", laszip->items[i].type, i); + REprintf("ERROR: writing type %d of item %d\n", laszip->items[i].type, i); return FALSE; } if (!stream->put16bitsLE((U8*)&(laszip->items[i].size))) { - fprintf(stderr,"ERROR: writing size %d of item %d\n", laszip->items[i].size, i); + REprintf("ERROR: writing size %d of item %d\n", laszip->items[i].size, i); return FALSE; } if (!stream->put16bitsLE((U8*)&(laszip->items[i].version))) { - fprintf(stderr,"ERROR: writing version %d of item %d\n", laszip->items[i].version, i); + REprintf("ERROR: writing version %d of item %d\n", laszip->items[i].version, i); return FALSE; } } @@ -712,32 +712,32 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp U16 reserved = 0xAABB; if (!stream->put16bitsLE((U8*)&(reserved))) { - fprintf(stderr,"ERROR: writing reserved %d\n", (I32)reserved); + REprintf("ERROR: writing reserved %d\n", (I32)reserved); return FALSE; } U8 user_id[16] = "LAStools\0\0\0\0\0\0\0"; if (!stream->putBytes((U8*)user_id, 16)) { - fprintf(stderr,"ERROR: writing user_id %s\n", user_id); + REprintf("ERROR: writing user_id %s\n", user_id); return FALSE; } U16 record_id = 10; if (!stream->put16bitsLE((U8*)&(record_id))) { - fprintf(stderr,"ERROR: writing record_id %d\n", (I32)record_id); + REprintf("ERROR: writing record_id %d\n", (I32)record_id); return FALSE; } U16 record_length_after_header = 28; if (!stream->put16bitsLE((U8*)&(record_length_after_header))) { - fprintf(stderr,"ERROR: writing record_length_after_header %d\n", (I32)record_length_after_header); + REprintf("ERROR: writing record_length_after_header %d\n", (I32)record_length_after_header); return FALSE; } CHAR description[33] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; sprintf(description, "tile %s buffer %s", (header->vlr_lastiling->buffer ? "with" : "without"), (header->vlr_lastiling->reversible ? ", reversible" : "")); if (!stream->putBytes((U8*)description, 32)) { - fprintf(stderr,"ERROR: writing description %s\n", description); + REprintf("ERROR: writing description %s\n", description); return FALSE; } @@ -752,37 +752,37 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp if (!stream->put32bitsLE((U8*)&(header->vlr_lastiling->level))) { - fprintf(stderr,"ERROR: writing header->vlr_lastiling->level %u\n", header->vlr_lastiling->level); + REprintf("ERROR: writing header->vlr_lastiling->level %u\n", header->vlr_lastiling->level); return FALSE; } if (!stream->put32bitsLE((U8*)&(header->vlr_lastiling->level_index))) { - fprintf(stderr,"ERROR: writing header->vlr_lastiling->level_index %u\n", header->vlr_lastiling->level_index); + REprintf("ERROR: writing header->vlr_lastiling->level_index %u\n", header->vlr_lastiling->level_index); return FALSE; } if (!stream->put32bitsLE(((U8*)header->vlr_lastiling)+8)) { - fprintf(stderr,"ERROR: writing header->vlr_lastiling->implicit_levels %u\n", header->vlr_lastiling->implicit_levels); + REprintf("ERROR: writing header->vlr_lastiling->implicit_levels %u\n", header->vlr_lastiling->implicit_levels); return FALSE; } if (!stream->put32bitsLE((U8*)&(header->vlr_lastiling->min_x))) { - fprintf(stderr,"ERROR: writing header->vlr_lastiling->min_x %g\n", header->vlr_lastiling->min_x); + REprintf("ERROR: writing header->vlr_lastiling->min_x %g\n", header->vlr_lastiling->min_x); return FALSE; } if (!stream->put32bitsLE((U8*)&(header->vlr_lastiling->max_x))) { - fprintf(stderr,"ERROR: writing header->vlr_lastiling->max_x %g\n", header->vlr_lastiling->max_x); + REprintf("ERROR: writing header->vlr_lastiling->max_x %g\n", header->vlr_lastiling->max_x); return FALSE; } if (!stream->put32bitsLE((U8*)&(header->vlr_lastiling->min_y))) { - fprintf(stderr,"ERROR: writing header->vlr_lastiling->min_y %g\n", header->vlr_lastiling->min_y); + REprintf("ERROR: writing header->vlr_lastiling->min_y %g\n", header->vlr_lastiling->min_y); return FALSE; } if (!stream->put32bitsLE((U8*)&(header->vlr_lastiling->max_y))) { - fprintf(stderr,"ERROR: writing header->vlr_lastiling->max_y %g\n", header->vlr_lastiling->max_y); + REprintf("ERROR: writing header->vlr_lastiling->max_y %g\n", header->vlr_lastiling->max_y); return FALSE; } } @@ -796,31 +796,31 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp U16 reserved = 0xAABB; if (!stream->put16bitsLE((U8*)&(reserved))) { - fprintf(stderr,"ERROR: writing reserved %d\n", (I32)reserved); + REprintf("ERROR: writing reserved %d\n", (I32)reserved); return FALSE; } U8 user_id[16] = "LAStools\0\0\0\0\0\0\0"; if (!stream->putBytes((U8*)user_id, 16)) { - fprintf(stderr,"ERROR: writing user_id %s\n", user_id); + REprintf("ERROR: writing user_id %s\n", user_id); return FALSE; } U16 record_id = 20; if (!stream->put16bitsLE((U8*)&(record_id))) { - fprintf(stderr,"ERROR: writing record_id %d\n", (I32)record_id); + REprintf("ERROR: writing record_id %d\n", (I32)record_id); return FALSE; } U16 record_length_after_header = 176; if (!stream->put16bitsLE((U8*)&(record_length_after_header))) { - fprintf(stderr,"ERROR: writing record_length_after_header %d\n", (I32)record_length_after_header); + REprintf("ERROR: writing record_length_after_header %d\n", (I32)record_length_after_header); return FALSE; } U8 description[32] = "counters and bbox of original\0\0"; if (!stream->putBytes((U8*)description, 32)) { - fprintf(stderr,"ERROR: writing description %s\n", description); + REprintf("ERROR: writing description %s\n", description); return FALSE; } @@ -832,45 +832,45 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp if (!stream->put64bitsLE((U8*)&(header->vlr_lasoriginal->number_of_point_records))) { - fprintf(stderr,"ERROR: writing header->vlr_lasoriginal->number_of_point_records %u\n", (U32)header->vlr_lasoriginal->number_of_point_records); + REprintf("ERROR: writing header->vlr_lasoriginal->number_of_point_records %u\n", (U32)header->vlr_lasoriginal->number_of_point_records); return FALSE; } for (j = 0; j < 15; j++) { if (!stream->put64bitsLE((U8*)&(header->vlr_lasoriginal->number_of_points_by_return[j]))) { - fprintf(stderr,"ERROR: writing header->vlr_lasoriginal->number_of_points_by_return[%u] %u\n", j, (U32)header->vlr_lasoriginal->number_of_points_by_return[j]); + REprintf("ERROR: writing header->vlr_lasoriginal->number_of_points_by_return[%u] %u\n", j, (U32)header->vlr_lasoriginal->number_of_points_by_return[j]); return FALSE; } } if (!stream->put64bitsLE((U8*)&(header->vlr_lasoriginal->min_x))) { - fprintf(stderr,"ERROR: writing header->vlr_lasoriginal->min_x %g\n", header->vlr_lasoriginal->min_x); + REprintf("ERROR: writing header->vlr_lasoriginal->min_x %g\n", header->vlr_lasoriginal->min_x); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->vlr_lasoriginal->max_x))) { - fprintf(stderr,"ERROR: writing header->vlr_lasoriginal->max_x %g\n", header->vlr_lasoriginal->max_x); + REprintf("ERROR: writing header->vlr_lasoriginal->max_x %g\n", header->vlr_lasoriginal->max_x); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->vlr_lasoriginal->min_y))) { - fprintf(stderr,"ERROR: writing header->vlr_lasoriginal->min_y %g\n", header->vlr_lasoriginal->min_y); + REprintf("ERROR: writing header->vlr_lasoriginal->min_y %g\n", header->vlr_lasoriginal->min_y); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->vlr_lasoriginal->max_y))) { - fprintf(stderr,"ERROR: writing header->vlr_lasoriginal->max_y %g\n", header->vlr_lasoriginal->max_y); + REprintf("ERROR: writing header->vlr_lasoriginal->max_y %g\n", header->vlr_lasoriginal->max_y); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->vlr_lasoriginal->min_z))) { - fprintf(stderr,"ERROR: writing header->vlr_lasoriginal->min_z %g\n", header->vlr_lasoriginal->min_z); + REprintf("ERROR: writing header->vlr_lasoriginal->min_z %g\n", header->vlr_lasoriginal->min_z); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->vlr_lasoriginal->max_z))) { - fprintf(stderr,"ERROR: writing header->vlr_lasoriginal->max_z %g\n", header->vlr_lasoriginal->max_z); + REprintf("ERROR: writing header->vlr_lasoriginal->max_z %g\n", header->vlr_lasoriginal->max_z); return FALSE; } } @@ -883,13 +883,13 @@ BOOL LASwriterLAS::open(ByteStreamOut* stream, const LASheader* header, U32 comp { if (!stream->putBytes((U8*)header->user_data_after_header, header->user_data_after_header_size)) { - fprintf(stderr,"ERROR: writing %d bytes of data from header->user_data_after_header\n", header->user_data_after_header_size); + REprintf("ERROR: writing %d bytes of data from header->user_data_after_header\n", header->user_data_after_header_size); return FALSE; } } else { - fprintf(stderr,"ERROR: there should be %d bytes of data in header->user_data_after_header\n", header->user_data_after_header_size); + REprintf("ERROR: there should be %d bytes of data in header->user_data_after_header\n", header->user_data_after_header_size); return FALSE; } } @@ -920,17 +920,17 @@ BOOL LASwriterLAS::update_header(const LASheader* header, BOOL use_inventory, BO I32 i; if (header == 0) { - fprintf(stderr,"ERROR: header pointer is zero\n"); + REprintf("ERROR: header pointer is zero\n"); return FALSE; } if (stream == 0) { - fprintf(stderr,"ERROR: stream pointer is zero\n"); + REprintf("ERROR: stream pointer is zero\n"); return FALSE; } if (!stream->isSeekable()) { - fprintf(stderr,"WARNING: stream not seekable. cannot update header.\n"); + REprintf("WARNING: stream not seekable. cannot update header.\n"); return FALSE; } if (use_inventory) @@ -949,7 +949,7 @@ BOOL LASwriterLAS::update_header(const LASheader* header, BOOL use_inventory, BO } else { - fprintf(stderr,"WARNING: too many points in LAS %d.%d file. limit is %u.\n", header->version_major, header->version_minor, U32_MAX); + REprintf("WARNING: too many points in LAS %d.%d file. limit is %u.\n", header->version_major, header->version_minor, U32_MAX); number = U32_MAX; } } @@ -959,7 +959,7 @@ BOOL LASwriterLAS::update_header(const LASheader* header, BOOL use_inventory, BO } if (!stream->put32bitsLE((U8*)&number)) { - fprintf(stderr,"ERROR: updating inventory.number_of_point_records\n"); + REprintf("ERROR: updating inventory.number_of_point_records\n"); return FALSE; } npoints = inventory.extended_number_of_point_records; @@ -986,7 +986,7 @@ BOOL LASwriterLAS::update_header(const LASheader* header, BOOL use_inventory, BO } if (!stream->put32bitsLE((U8*)&number)) { - fprintf(stderr,"ERROR: updating inventory.number_of_points_by_return[%d]\n", i); + REprintf("ERROR: updating inventory.number_of_points_by_return[%d]\n", i); return FALSE; } } @@ -995,37 +995,37 @@ BOOL LASwriterLAS::update_header(const LASheader* header, BOOL use_inventory, BO value = quantizer.get_x(inventory.max_X); if (!stream->put64bitsLE((U8*)&value)) { - fprintf(stderr,"ERROR: updating inventory.max_X\n"); + REprintf("ERROR: updating inventory.max_X\n"); return FALSE; } value = quantizer.get_x(inventory.min_X); if (!stream->put64bitsLE((U8*)&value)) { - fprintf(stderr,"ERROR: updating inventory.min_X\n"); + REprintf("ERROR: updating inventory.min_X\n"); return FALSE; } value = quantizer.get_y(inventory.max_Y); if (!stream->put64bitsLE((U8*)&value)) { - fprintf(stderr,"ERROR: updating inventory.max_Y\n"); + REprintf("ERROR: updating inventory.max_Y\n"); return FALSE; } value = quantizer.get_y(inventory.min_Y); if (!stream->put64bitsLE((U8*)&value)) { - fprintf(stderr,"ERROR: updating inventory.min_Y\n"); + REprintf("ERROR: updating inventory.min_Y\n"); return FALSE; } value = quantizer.get_z(inventory.max_Z); if (!stream->put64bitsLE((U8*)&value)) { - fprintf(stderr,"ERROR: updating inventory.max_Z\n"); + REprintf("ERROR: updating inventory.max_Z\n"); return FALSE; } value = quantizer.get_z(inventory.min_Z); if (!stream->put64bitsLE((U8*)&value)) { - fprintf(stderr,"ERROR: updating inventory.min_Z\n"); + REprintf("ERROR: updating inventory.min_Z\n"); return FALSE; } // special handling for LAS 1.4 or higher. @@ -1034,14 +1034,14 @@ BOOL LASwriterLAS::update_header(const LASheader* header, BOOL use_inventory, BO stream->seek(header_start_position+247); if (!stream->put64bitsLE((U8*)&(inventory.extended_number_of_point_records))) { - fprintf(stderr,"ERROR: updating header->extended_number_of_point_records\n"); + REprintf("ERROR: updating header->extended_number_of_point_records\n"); return FALSE; } for (i = 0; i < 15; i++) { if (!stream->put64bitsLE((U8*)&(inventory.extended_number_of_points_by_return[i+1]))) { - fprintf(stderr,"ERROR: updating header->extended_number_of_points_by_return[%d]\n", i); + REprintf("ERROR: updating header->extended_number_of_points_by_return[%d]\n", i); return FALSE; } } @@ -1061,7 +1061,7 @@ BOOL LASwriterLAS::update_header(const LASheader* header, BOOL use_inventory, BO } if (!stream->put32bitsLE((U8*)&number)) { - fprintf(stderr,"ERROR: updating header->number_of_point_records\n"); + REprintf("ERROR: updating header->number_of_point_records\n"); return FALSE; } npoints = header->number_of_point_records; @@ -1077,39 +1077,39 @@ BOOL LASwriterLAS::update_header(const LASheader* header, BOOL use_inventory, BO } if (!stream->put32bitsLE((U8*)&number)) { - fprintf(stderr,"ERROR: updating header->number_of_points_by_return[%d]\n", i); + REprintf("ERROR: updating header->number_of_points_by_return[%d]\n", i); return FALSE; } } stream->seek(header_start_position+179); if (!stream->put64bitsLE((U8*)&(header->max_x))) { - fprintf(stderr,"ERROR: updating header->max_x\n"); + REprintf("ERROR: updating header->max_x\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->min_x))) { - fprintf(stderr,"ERROR: updating header->min_x\n"); + REprintf("ERROR: updating header->min_x\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->max_y))) { - fprintf(stderr,"ERROR: updating header->max_y\n"); + REprintf("ERROR: updating header->max_y\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->min_y))) { - fprintf(stderr,"ERROR: updating header->min_y\n"); + REprintf("ERROR: updating header->min_y\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->max_z))) { - fprintf(stderr,"ERROR: updating header->max_z\n"); + REprintf("ERROR: updating header->max_z\n"); return FALSE; } if (!stream->put64bitsLE((U8*)&(header->min_z))) { - fprintf(stderr,"ERROR: updating header->min_z\n"); + REprintf("ERROR: updating header->min_z\n"); return FALSE; } // special handling for LAS 1.3 or higher. @@ -1119,14 +1119,14 @@ BOOL LASwriterLAS::update_header(const LASheader* header, BOOL use_inventory, BO if (header->start_of_waveform_data_packet_record != 0) { #ifdef _WIN32 - fprintf(stderr,"WARNING: header->start_of_waveform_data_packet_record is %I64d. writing 0 instead.\n", header->start_of_waveform_data_packet_record); + REprintf("WARNING: header->start_of_waveform_data_packet_record is %I64d. writing 0 instead.\n", header->start_of_waveform_data_packet_record); #else - fprintf(stderr,"WARNING: header->start_of_waveform_data_packet_record is %lld. writing 0 instead.\n", header->start_of_waveform_data_packet_record); + REprintf("WARNING: header->start_of_waveform_data_packet_record is %lld. writing 0 instead.\n", header->start_of_waveform_data_packet_record); #endif U64 start_of_waveform_data_packet_record = 0; if (!stream->put64bitsLE((U8*)&start_of_waveform_data_packet_record)) { - fprintf(stderr,"ERROR: updating start_of_waveform_data_packet_record\n"); + REprintf("ERROR: updating start_of_waveform_data_packet_record\n"); return FALSE; } } @@ -1134,7 +1134,7 @@ BOOL LASwriterLAS::update_header(const LASheader* header, BOOL use_inventory, BO { if (!stream->put64bitsLE((U8*)&(header->start_of_waveform_data_packet_record))) { - fprintf(stderr,"ERROR: updating header->start_of_waveform_data_packet_record\n"); + REprintf("ERROR: updating header->start_of_waveform_data_packet_record\n"); return FALSE; } } @@ -1145,12 +1145,12 @@ BOOL LASwriterLAS::update_header(const LASheader* header, BOOL use_inventory, BO stream->seek(header_start_position+235); if (!stream->put64bitsLE((U8*)&(header->start_of_first_extended_variable_length_record))) { - fprintf(stderr,"ERROR: updating header->start_of_first_extended_variable_length_record\n"); + REprintf("ERROR: updating header->start_of_first_extended_variable_length_record\n"); return FALSE; } if (!stream->put32bitsLE((U8*)&(header->number_of_extended_variable_length_records))) { - fprintf(stderr,"ERROR: updating header->number_of_extended_variable_length_records\n"); + REprintf("ERROR: updating header->number_of_extended_variable_length_records\n"); return FALSE; } U64 value; @@ -1160,7 +1160,7 @@ BOOL LASwriterLAS::update_header(const LASheader* header, BOOL use_inventory, BO value = header->extended_number_of_point_records; if (!stream->put64bitsLE((U8*)&value)) { - fprintf(stderr,"ERROR: updating header->extended_number_of_point_records\n"); + REprintf("ERROR: updating header->extended_number_of_point_records\n"); return FALSE; } for (i = 0; i < 15; i++) @@ -1171,7 +1171,7 @@ BOOL LASwriterLAS::update_header(const LASheader* header, BOOL use_inventory, BO value = header->extended_number_of_points_by_return[i]; if (!stream->put64bitsLE((U8*)&value)) { - fprintf(stderr,"ERROR: updating header->extended_number_of_points_by_return[%d]\n", i); + REprintf("ERROR: updating header->extended_number_of_points_by_return[%d]\n", i); return FALSE; } } @@ -1182,7 +1182,7 @@ BOOL LASwriterLAS::update_header(const LASheader* header, BOOL use_inventory, BO { if (header == 0) { - fprintf(stderr,"ERROR: header pointer is zero\n"); + REprintf("ERROR: header pointer is zero\n"); return FALSE; } if (header->number_attributes) @@ -1202,14 +1202,14 @@ BOOL LASwriterLAS::update_header(const LASheader* header, BOOL use_inventory, BO } if (i == (I32)header->number_of_variable_length_records) { - fprintf(stderr,"WARNING: could not find extra bytes VLR for update\n"); + REprintf("WARNING: could not find extra bytes VLR for update\n"); } else { stream->seek(start); if (!stream->putBytes((U8*)header->vlrs[i].data, header->vlrs[i].record_length_after_header)) { - fprintf(stderr,"ERROR: writing %d bytes of data from header->vlrs[%d].data\n", header->vlrs[i].record_length_after_header, i); + REprintf("ERROR: writing %d bytes of data from header->vlrs[%d].data\n", header->vlrs[i].record_length_after_header, i); return FALSE; } } @@ -1228,9 +1228,9 @@ I64 LASwriterLAS::close(BOOL update_npoints) if (npoints || !update_npoints) { #ifdef _WIN32 - fprintf(stderr,"WARNING: written %I64d points but expected %I64d points\n", p_count, npoints); + REprintf("WARNING: written %I64d points but expected %I64d points\n", p_count, npoints); #else - fprintf(stderr,"WARNING: written %lld points but expected %lld points\n", p_count, npoints); + REprintf("WARNING: written %lld points but expected %lld points\n", p_count, npoints); #endif } } @@ -1254,34 +1254,34 @@ I64 LASwriterLAS::close(BOOL update_npoints) if (evlrs[i].reserved != 0xAABB) { - // fprintf(stderr,"WARNING: wrong evlrs[%d].reserved: %d != 0xAABB\n", i, evlrs[i].reserved); + // REprintf("WARNING: wrong evlrs[%d].reserved: %d != 0xAABB\n", i, evlrs[i].reserved); } // write variable length records variable after variable (to avoid alignment issues) if (!stream->put16bitsLE((U8*)&(evlrs[i].reserved))) { - fprintf(stderr,"ERROR: writing evlrs[%d].reserved\n", i); + REprintf("ERROR: writing evlrs[%d].reserved\n", i); return FALSE; } if (!stream->putBytes((U8*)evlrs[i].user_id, 16)) { - fprintf(stderr,"ERROR: writing evlrs[%d].user_id\n", i); + REprintf("ERROR: writing evlrs[%d].user_id\n", i); return FALSE; } if (!stream->put16bitsLE((U8*)&(evlrs[i].record_id))) { - fprintf(stderr,"ERROR: writing evlrs[%d].record_id\n", i); + REprintf("ERROR: writing evlrs[%d].record_id\n", i); return FALSE; } if (!stream->put64bitsLE((U8*)&(evlrs[i].record_length_after_header))) { - fprintf(stderr,"ERROR: writing evlrs[%d].record_length_after_header\n", i); + REprintf("ERROR: writing evlrs[%d].record_length_after_header\n", i); return FALSE; } if (!stream->putBytes((U8*)evlrs[i].description, 32)) { - fprintf(stderr,"ERROR: writing evlrs[%d].description\n", i); + REprintf("ERROR: writing evlrs[%d].description\n", i); return FALSE; } @@ -1293,13 +1293,13 @@ I64 LASwriterLAS::close(BOOL update_npoints) { if (!stream->putBytes((U8*)evlrs[i].data, (U32)evlrs[i].record_length_after_header)) { - fprintf(stderr,"ERROR: writing %u bytes of data from evlrs[%d].data\n", (U32)evlrs[i].record_length_after_header, i); + REprintf("ERROR: writing %u bytes of data from evlrs[%d].data\n", (U32)evlrs[i].record_length_after_header, i); return FALSE; } } else { - fprintf(stderr,"ERROR: there should be %u bytes of data in evlrs[%d].data\n", (U32)evlrs[i].record_length_after_header, i); + REprintf("ERROR: there should be %u bytes of data in evlrs[%d].data\n", (U32)evlrs[i].record_length_after_header, i); return FALSE; } } @@ -1320,9 +1320,9 @@ I64 LASwriterLAS::close(BOOL update_npoints) if (!stream->isSeekable()) { #ifdef _WIN32 - fprintf(stderr, "WARNING: stream not seekable. cannot update header from %I64d to %I64d points.\n", npoints, p_count); + REprintf( "WARNING: stream not seekable. cannot update header from %I64d to %I64d points.\n", npoints, p_count); #else - fprintf(stderr, "WARNING: stream not seekable. cannot update header from %lld to %lld points.\n", npoints, p_count); + REprintf( "WARNING: stream not seekable. cannot update header from %lld to %lld points.\n", npoints, p_count); #endif } else diff --git a/src/LASlib/laswriter_qfit.cpp b/src/LASlib/laswriter_qfit.cpp index 2f713b9..329bd60 100644 --- a/src/LASlib/laswriter_qfit.cpp +++ b/src/LASlib/laswriter_qfit.cpp @@ -51,7 +51,7 @@ BOOL LASwriterQFIT::open(const char* file_name, const LASheader* header, I32 ver { if (file_name == 0) { - fprintf(stderr,"ERROR: file name pointer is zero\n"); + REprintf("ERROR: file name pointer is zero\n"); return FALSE; } @@ -59,13 +59,13 @@ BOOL LASwriterQFIT::open(const char* file_name, const LASheader* header, I32 ver if (file == 0) { - fprintf(stderr, "ERROR: cannot open file '%s'\n", file_name); + REprintf( "ERROR: cannot open file '%s'\n", file_name); return FALSE; } if (setvbuf(file, NULL, _IOFBF, io_buffer_size) != 0) { - fprintf(stderr, "WARNING: setvbuf() failed with buffer size %u\n", io_buffer_size); + REprintf( "WARNING: setvbuf() failed with buffer size %u\n", io_buffer_size); } return open(file, header, version); @@ -75,7 +75,7 @@ BOOL LASwriterQFIT::open(FILE* file, const LASheader* header, I32 version) { if (file == 0) { - fprintf(stderr,"ERROR: file pointer is zero\n"); + REprintf("ERROR: file pointer is zero\n"); return FALSE; } @@ -84,7 +84,7 @@ BOOL LASwriterQFIT::open(FILE* file, const LASheader* header, I32 version) { if(_setmode( _fileno( stdout ), _O_BINARY ) == -1 ) { - fprintf(stderr, "ERROR: cannot set stdout to binary (untranslated) mode\n"); + REprintf( "ERROR: cannot set stdout to binary (untranslated) mode\n"); } } #endif @@ -108,14 +108,14 @@ BOOL LASwriterQFIT::open(ByteStreamOut* stream, const LASheader* header, I32 ver { if (stream == 0) { - fprintf(stderr,"ERROR: ByteStreamOut pointer is zero\n"); + REprintf("ERROR: ByteStreamOut pointer is zero\n"); return FALSE; } this->stream = stream; if (header == 0) { - fprintf(stderr,"ERROR: LASheader pointer is zero\n"); + REprintf("ERROR: LASheader pointer is zero\n"); return FALSE; } @@ -123,7 +123,7 @@ BOOL LASwriterQFIT::open(ByteStreamOut* stream, const LASheader* header, I32 ver if (((-361 < header->min_x) && (-361 < header->min_y) && (header->max_x < 361) && (header->max_y < 361)) == FALSE) { - fprintf(stderr,"ERROR: bounding box (%g %g / %g %g) exceeds longitude / latitude\n", header->min_x, header->min_y, header->max_x, header->max_y); + REprintf("ERROR: bounding box (%g %g / %g %g) exceeds longitude / latitude\n", header->min_x, header->min_y, header->max_x, header->max_y); return FALSE; } @@ -166,7 +166,7 @@ BOOL LASwriterQFIT::open(ByteStreamOut* stream, const LASheader* header, I32 ver } else { - fprintf(stderr,"WARNING: version %d of QFIT unknown ... using 48\n", version); + REprintf("WARNING: version %d of QFIT unknown ... using 48\n", version); this->version = 48; } @@ -174,7 +174,7 @@ BOOL LASwriterQFIT::open(ByteStreamOut* stream, const LASheader* header, I32 ver if (!stream->put32bitsLE((U8*)&version)) { - fprintf(stderr,"ERROR: while writing version of QFIT header\n"); + REprintf("ERROR: while writing version of QFIT header\n"); return FALSE; } @@ -185,7 +185,7 @@ BOOL LASwriterQFIT::open(ByteStreamOut* stream, const LASheader* header, I32 ver if (!stream->putBytes((U8*)buffer, version-4)) { - fprintf(stderr,"ERROR: writing first header record of QFIT header\n"); + REprintf("ERROR: writing first header record of QFIT header\n"); return FALSE; } @@ -196,12 +196,12 @@ BOOL LASwriterQFIT::open(ByteStreamOut* stream, const LASheader* header, I32 ver if (!stream->put32bitsLE((U8*)&buffer[0])) { - fprintf(stderr,"ERROR: while writing -9000000 into QFIT header\n"); + REprintf("ERROR: while writing -9000000 into QFIT header\n"); return FALSE; } if (!stream->put32bitsLE((U8*)&buffer[1])) { - fprintf(stderr,"ERROR: while writing offset into QFIT header\n"); + REprintf("ERROR: while writing offset into QFIT header\n"); return FALSE; } @@ -211,7 +211,7 @@ BOOL LASwriterQFIT::open(ByteStreamOut* stream, const LASheader* header, I32 ver sprintf((char*)buffer, "LAStools by Martin Isenburg"); if (!stream->putBytes((U8*)buffer, version-8)) { - fprintf(stderr,"ERROR: writing second header record of QFIT header\n"); + REprintf("ERROR: writing second header record of QFIT header\n"); return FALSE; } diff --git a/src/LASlib/laswriter_txt.cpp b/src/LASlib/laswriter_txt.cpp index 75c5a16..bb4a04f 100644 --- a/src/LASlib/laswriter_txt.cpp +++ b/src/LASlib/laswriter_txt.cpp @@ -58,7 +58,7 @@ BOOL LASwriterTXT::open(const CHAR* file_name, const LASheader* header, const CH { if (file_name == 0) { - fprintf(stderr,"ERROR: file name pointer is zero\n"); + REprintf("ERROR: file name pointer is zero\n"); return FALSE; } @@ -66,7 +66,7 @@ BOOL LASwriterTXT::open(const CHAR* file_name, const LASheader* header, const CH if (file == 0) { - fprintf(stderr, "ERROR: cannot open file '%s'\n", file_name); + REprintf( "ERROR: cannot open file '%s'\n", file_name); return FALSE; } @@ -79,7 +79,7 @@ BOOL LASwriterTXT::open(FILE* file, const LASheader* header, const CHAR* parse_s { if (file == 0) { - fprintf(stderr,"ERROR: file pointer is zero\n"); + REprintf("ERROR: file pointer is zero\n"); return FALSE; } @@ -128,7 +128,7 @@ BOOL LASwriterTXT::open(FILE* file, const LASheader* header, const CHAR* parse_s } else { - fprintf(stderr, "ERROR: unknown seperator '%s'\n", separator); + REprintf( "ERROR: unknown seperator '%s'\n", separator); return FALSE; } } @@ -153,17 +153,17 @@ BOOL LASwriterTXT::open(FILE* file, const LASheader* header, const CHAR* parse_s } else if (ptsVLR) { - fprintf(stderr, "WARNING: found VLR for PTS with wrong payload size of %d.\n", ptsVLR->record_length_after_header); + REprintf( "WARNING: found VLR for PTS with wrong payload size of %d.\n", ptsVLR->record_length_after_header); } else if (ptxVLR) { - fprintf(stderr, "WARNING: found VLR for PTX with wrong payload size of %d.\n", ptxVLR->record_length_after_header); + REprintf( "WARNING: found VLR for PTX with wrong payload size of %d.\n", ptxVLR->record_length_after_header); } } } else { - fprintf(stderr, "WARNING: found no VLR with PTS or PTX info.\n"); + REprintf( "WARNING: found no VLR with PTS or PTX info.\n"); } if (header->version_minor >= 4) { @@ -179,11 +179,11 @@ BOOL LASwriterTXT::open(FILE* file, const LASheader* header, const CHAR* parse_s } if (this->parse_string && strcmp(this->parse_string, "xyz") && strcmp(this->parse_string, "xyzi") && strcmp(this->parse_string, "xyziRGB") && strcmp(this->parse_string, "xyzRGB")) { - fprintf(stderr, "WARNING: the parse string for PTS should be 'xyz', 'xyzi', 'xyziRGB', or 'xyzRGB'\n"); + REprintf( "WARNING: the parse string for PTS should be 'xyz', 'xyzi', 'xyziRGB', or 'xyzRGB'\n"); } if (separator_sign != ' ') { - fprintf(stderr, "WARNING: the separator for PTS should be 'space' not '%s'\n", separator); + REprintf( "WARNING: the separator for PTS should be 'space' not '%s'\n", separator); } } else if (optx) @@ -213,13 +213,13 @@ BOOL LASwriterTXT::open(FILE* file, const LASheader* header, const CHAR* parse_s { if (ptxVLR) { - fprintf(stderr, "WARNING: found VLR for PTX with wrong payload size of %d.\n", ptxVLR->record_length_after_header); + REprintf( "WARNING: found VLR for PTX with wrong payload size of %d.\n", ptxVLR->record_length_after_header); } else { - fprintf(stderr, "WARNING: found no VLR with PTX info.\n"); + REprintf( "WARNING: found no VLR with PTX info.\n"); } - fprintf(stderr, " outputting PTS instead ...\n"); + REprintf( " outputting PTS instead ...\n"); if (header->version_minor >= 4) { #ifdef _WIN32 @@ -235,11 +235,11 @@ BOOL LASwriterTXT::open(FILE* file, const LASheader* header, const CHAR* parse_s } if (this->parse_string && strcmp(this->parse_string, "xyz") && strcmp(this->parse_string, "xyzi") && strcmp(this->parse_string, "xyziRGB") && strcmp(this->parse_string, "xyzRGB")) { - fprintf(stderr, "WARNING: the parse string for PTX should be 'xyz', 'xyzi', 'xyziRGB', or 'xyzRGB'\n"); + REprintf( "WARNING: the parse string for PTX should be 'xyz', 'xyzi', 'xyziRGB', or 'xyzRGB'\n"); } if (separator_sign != ' ') { - fprintf(stderr, "WARNING: the separator for PTX should be 'space' not '%s'\n", separator); + REprintf( "WARNING: the separator for PTX should be 'space' not '%s'\n", separator); } } @@ -419,7 +419,7 @@ BOOL LASwriterTXT::unparse_attribute(const LASpoint* point, I32 index) } else { - fprintf(stderr, "WARNING: attribute %d not (yet) implemented.\n", index); + REprintf( "WARNING: attribute %d not (yet) implemented.\n", index); return FALSE; } return TRUE; @@ -649,42 +649,42 @@ BOOL LASwriterTXT::check_parse_string(const CHAR* parse_string) I32 index = (I32)(p[0] - '0'); if (index >= header->number_attributes) { - fprintf(stderr, "ERROR: extra bytes attribute '%d' does not exist.\n", index); + REprintf( "ERROR: extra bytes attribute '%d' does not exist.\n", index); return FALSE; } attribute_starts[index] = header->get_attribute_start(index); } else { - fprintf(stderr, "ERROR: unknown symbol '%c' in parse string. valid are\n", p[0]); - fprintf(stderr, " 'x' : the x coordinate\n"); - fprintf(stderr, " 'y' : the y coordinate\n"); - fprintf(stderr, " 'z' : the z coordinate\n"); - fprintf(stderr, " 't' : the gps time\n"); - fprintf(stderr, " 'R' : the red channel of the RGB field\n"); - fprintf(stderr, " 'G' : the green channel of the RGB field\n"); - fprintf(stderr, " 'B' : the blue channel of the RGB field\n"); - fprintf(stderr, " 's' : a string or a number that we don't care about\n"); - fprintf(stderr, " 'i' : the intensity\n"); - fprintf(stderr, " 'a' : the scan angle\n"); - fprintf(stderr, " 'n' : the number of returns of that given pulse\n"); - fprintf(stderr, " 'r' : the number of the return\n"); - fprintf(stderr, " 'c' : the classification\n"); - fprintf(stderr, " 'u' : the user data\n"); - fprintf(stderr, " 'p' : the point source ID\n"); - fprintf(stderr, " 'e' : the edge of flight line flag\n"); - fprintf(stderr, " 'd' : the direction of scan flag\n"); - fprintf(stderr, " 'h' : the withheld flag\n"); - fprintf(stderr, " 'k' : the keypoint flag\n"); - fprintf(stderr, " 'g' : the synthetic flag\n"); - fprintf(stderr, " 'o' : the overlap flag\n"); - fprintf(stderr, " 'l' : the scanner channel\n"); - fprintf(stderr, " 'M' : the index of the point\n"); - fprintf(stderr, " 'w' : the wavepacket descriptor index\n"); - fprintf(stderr, " 'W' : all wavepacket attributes\n"); - fprintf(stderr, " 'X' : the unscaled and unoffset integer x coordinate\n"); - fprintf(stderr, " 'Y' : the unscaled and unoffset integer y coordinate\n"); - fprintf(stderr, " 'Z' : the unscaled and unoffset integer z coordinate\n"); + REprintf( "ERROR: unknown symbol '%c' in parse string. valid are\n", p[0]); + REprintf( " 'x' : the x coordinate\n"); + REprintf( " 'y' : the y coordinate\n"); + REprintf( " 'z' : the z coordinate\n"); + REprintf( " 't' : the gps time\n"); + REprintf( " 'R' : the red channel of the RGB field\n"); + REprintf( " 'G' : the green channel of the RGB field\n"); + REprintf( " 'B' : the blue channel of the RGB field\n"); + REprintf( " 's' : a string or a number that we don't care about\n"); + REprintf( " 'i' : the intensity\n"); + REprintf( " 'a' : the scan angle\n"); + REprintf( " 'n' : the number of returns of that given pulse\n"); + REprintf( " 'r' : the number of the return\n"); + REprintf( " 'c' : the classification\n"); + REprintf( " 'u' : the user data\n"); + REprintf( " 'p' : the point source ID\n"); + REprintf( " 'e' : the edge of flight line flag\n"); + REprintf( " 'd' : the direction of scan flag\n"); + REprintf( " 'h' : the withheld flag\n"); + REprintf( " 'k' : the keypoint flag\n"); + REprintf( " 'g' : the synthetic flag\n"); + REprintf( " 'o' : the overlap flag\n"); + REprintf( " 'l' : the scanner channel\n"); + REprintf( " 'M' : the index of the point\n"); + REprintf( " 'w' : the wavepacket descriptor index\n"); + REprintf( " 'W' : all wavepacket attributes\n"); + REprintf( " 'X' : the unscaled and unoffset integer x coordinate\n"); + REprintf( " 'Y' : the unscaled and unoffset integer y coordinate\n"); + REprintf( " 'Z' : the unscaled and unoffset integer z coordinate\n"); return FALSE; } } diff --git a/src/LASlib/laswriter_wrl.cpp b/src/LASlib/laswriter_wrl.cpp index 77ab495..4ce47f8 100644 --- a/src/LASlib/laswriter_wrl.cpp +++ b/src/LASlib/laswriter_wrl.cpp @@ -38,7 +38,7 @@ BOOL LASwriterWRL::open(const CHAR* file_name, const LASheader* header, const CH { if (file_name == 0) { - fprintf(stderr,"ERROR: file name pointer is zero\n"); + REprintf("ERROR: file name pointer is zero\n"); return FALSE; } @@ -46,7 +46,7 @@ BOOL LASwriterWRL::open(const CHAR* file_name, const LASheader* header, const CH if (file == 0) { - fprintf(stderr, "ERROR: cannot open file '%s'\n", file_name); + REprintf( "ERROR: cannot open file '%s'\n", file_name); return FALSE; } @@ -59,7 +59,7 @@ BOOL LASwriterWRL::open(FILE* file, const LASheader* header, const CHAR* parse_s { if (file == 0) { - fprintf(stderr,"ERROR: file pointer is zero\n"); + REprintf("ERROR: file pointer is zero\n"); return FALSE; } @@ -80,7 +80,7 @@ BOOL LASwriterWRL::open(FILE* file, const LASheader* header, const CHAR* parse_s } else { - fprintf(stderr,"WARNING: points do not have RGB colors\n"); + REprintf("WARNING: points do not have RGB colors\n"); if (rgb) { rgb_alloc = 0; diff --git a/src/LASlib/laswritercompatible.cpp b/src/LASlib/laswritercompatible.cpp index 4105094..dc2e169 100644 --- a/src/LASlib/laswritercompatible.cpp +++ b/src/LASlib/laswritercompatible.cpp @@ -105,9 +105,9 @@ BOOL LASwriterCompatibleDown::open(LASheader* header, LASwriteOpener* laswriteop if (start_of_waveform_data_packet_record != 0) { #ifdef _WIN32 - fprintf(stderr,"WARNING: header->start_of_waveform_data_packet_record is %I64d. writing 0 instead.\n", start_of_waveform_data_packet_record); + REprintf("WARNING: header->start_of_waveform_data_packet_record is %I64d. writing 0 instead.\n", start_of_waveform_data_packet_record); #else - fprintf(stderr,"WARNING: header->start_of_waveform_data_packet_record is %lld. writing 0 instead.\n", start_of_waveform_data_packet_record); + REprintf("WARNING: header->start_of_waveform_data_packet_record is %lld. writing 0 instead.\n", start_of_waveform_data_packet_record); #endif start_of_waveform_data_packet_record = 0; } @@ -116,9 +116,9 @@ BOOL LASwriterCompatibleDown::open(LASheader* header, LASwriteOpener* laswriteop if (start_of_first_extended_variable_length_record != 0) { #ifdef _WIN32 - fprintf(stderr,"WARNING: EVLRs not supported. header->start_of_first_extended_variable_length_record is %I64d. writing 0 instead.\n", start_of_first_extended_variable_length_record); + REprintf("WARNING: EVLRs not supported. header->start_of_first_extended_variable_length_record is %I64d. writing 0 instead.\n", start_of_first_extended_variable_length_record); #else - fprintf(stderr,"WARNING: EVLRs not supported. header->start_of_first_extended_variable_length_record is %lld. writing 0 instead.\n", start_of_first_extended_variable_length_record); + REprintf("WARNING: EVLRs not supported. header->start_of_first_extended_variable_length_record is %lld. writing 0 instead.\n", start_of_first_extended_variable_length_record); #endif start_of_first_extended_variable_length_record = 0; } @@ -126,7 +126,7 @@ BOOL LASwriterCompatibleDown::open(LASheader* header, LASwriteOpener* laswriteop U32 number_of_extended_variable_length_records = header->number_of_extended_variable_length_records; if (number_of_extended_variable_length_records != 0) { - fprintf(stderr,"WARNING: EVLRs not supported. header->number_of_extended_variable_length_records is %u. writing 0 instead.\n", number_of_extended_variable_length_records); + REprintf("WARNING: EVLRs not supported. header->number_of_extended_variable_length_records is %u. writing 0 instead.\n", number_of_extended_variable_length_records); number_of_extended_variable_length_records = 0; } out->put32bitsLE((U8*)&number_of_extended_variable_length_records); @@ -134,7 +134,7 @@ BOOL LASwriterCompatibleDown::open(LASheader* header, LASwriteOpener* laswriteop if (header->number_of_point_records) { extended_number_of_point_records = header->number_of_point_records; - fprintf(stderr,"WARNING: legacy number_of_point_records in header of LAS 1.4 file should be zero.\n"); + REprintf("WARNING: legacy number_of_point_records in header of LAS 1.4 file should be zero.\n"); } else { @@ -150,7 +150,7 @@ BOOL LASwriterCompatibleDown::open(LASheader* header, LASwriteOpener* laswriteop if (header->number_of_points_by_return[i]) { extended_number_of_points_by_return = header->number_of_points_by_return[i]; - fprintf(stderr,"WARNING: legacy number_of_points_by_return[%d] in header of LAS 1.4 file should be zero.\n", i); + REprintf("WARNING: legacy number_of_points_by_return[%d] in header of LAS 1.4 file should be zero.\n", i); } else { @@ -229,9 +229,9 @@ BOOL LASwriterCompatibleDown::open(LASheader* header, LASwriteOpener* laswriteop else { #ifdef _WIN32 - fprintf(stderr,"large EVLR with user ID '%s' and record ID %d with payload size %I64d not moved to VLRs.\n", header->evlrs[i].user_id, header->evlrs[i].record_id, header->evlrs[i].record_length_after_header); + REprintf("large EVLR with user ID '%s' and record ID %d with payload size %I64d not moved to VLRs.\n", header->evlrs[i].user_id, header->evlrs[i].record_id, header->evlrs[i].record_length_after_header); #else - fprintf(stderr,"large EVLR with user ID '%s' and record ID %d with payload size %lld not moved to VLRs.\n", header->evlrs[i].user_id, header->evlrs[i].record_id, header->evlrs[i].record_length_after_header); + REprintf("large EVLR with user ID '%s' and record ID %d with payload size %lld not moved to VLRs.\n", header->evlrs[i].user_id, header->evlrs[i].record_id, header->evlrs[i].record_length_after_header); #endif } } @@ -269,7 +269,7 @@ BOOL LASwriterCompatibleDown::open(LASheader* header, LASwriteOpener* laswriteop } else { - fprintf(stderr,"unknown LASF_Projection EVLR with record ID %d not moved to VLRs.\n", header->evlrs[i].record_id); + REprintf("unknown LASF_Projection EVLR with record ID %d not moved to VLRs.\n", header->evlrs[i].record_id); } } } @@ -438,40 +438,40 @@ BOOL LASwriterCompatibleUp::open(LASheader* header, LASwriteOpener* laswriteopen const LASvlr* compatibility_vlr = header->get_vlr("lascompatible", 22204); if (compatibility_vlr == 0) { - fprintf(stderr, "ERROR: no compatibility VLR in header\n"); + REprintf( "ERROR: no compatibility VLR in header\n"); return FALSE; } // the compatibility VLR must have the right length if (compatibility_vlr->record_length_after_header != (2+2+4+148)) { - fprintf(stderr, "ERROR: compatibility VLR has %u instead of %u bytes in payload\n", compatibility_vlr->record_length_after_header, 2+2+4+148); + REprintf( "ERROR: compatibility VLR has %u instead of %u bytes in payload\n", compatibility_vlr->record_length_after_header, 2+2+4+148); return FALSE; } I32 index_scan_angle = header->get_attribute_index("LAS 1.4 scan angle"); if (index_scan_angle == -1) { - fprintf(stderr, "ERROR: attribute \"LAS 1.4 scan angle\" is not in EXTRA_BYTES\n"); + REprintf( "ERROR: attribute \"LAS 1.4 scan angle\" is not in EXTRA_BYTES\n"); return FALSE; } start_scan_angle = header->get_attribute_start(index_scan_angle); I32 index_extended_returns = header->get_attribute_index("LAS 1.4 extended returns"); if (index_extended_returns == -1) { - fprintf(stderr, "ERROR: attribute \"LAS 1.4 extended returns\" is not in EXTRA_BYTES\n"); + REprintf( "ERROR: attribute \"LAS 1.4 extended returns\" is not in EXTRA_BYTES\n"); return FALSE; } start_extended_returns = header->get_attribute_start(index_extended_returns); I32 index_classification = header->get_attribute_index("LAS 1.4 classification"); if (index_classification == -1) { - fprintf(stderr, "ERROR: attribute \"LAS 1.4 classification\" is not in EXTRA_BYTES\n"); + REprintf( "ERROR: attribute \"LAS 1.4 classification\" is not in EXTRA_BYTES\n"); return FALSE; } start_classification = header->get_attribute_start(index_classification); I32 index_flags_and_channel = header->get_attribute_index("LAS 1.4 flags and channel"); if (index_scan_angle == -1) { - fprintf(stderr, "ERROR: attribute \"LAS 1.4 flags and channel\" is not in EXTRA_BYTES\n"); + REprintf( "ERROR: attribute \"LAS 1.4 flags and channel\" is not in EXTRA_BYTES\n"); return FALSE; } start_flags_and_channel = header->get_attribute_start(index_flags_and_channel); @@ -517,14 +517,14 @@ BOOL LASwriterCompatibleUp::open(LASheader* header, LASwriteOpener* laswriteopen in->get16bitsLE((U8*)&compatible_version); if (compatible_version != 3) { - fprintf(stderr, "ERROR: compatibility mode version %u not implemented\n", compatible_version); + REprintf( "ERROR: compatibility mode version %u not implemented\n", compatible_version); return FALSE; } U32 unused; in->get32bitsLE((U8*)&unused); if (unused != 0) { - fprintf(stderr, "WARNING: unused is %u instead of 0\n", unused); + REprintf( "WARNING: unused is %u instead of 0\n", unused); } in->get64bitsLE((U8*)&(header->start_of_waveform_data_packet_record)); in->get64bitsLE((U8*)&(header->start_of_first_extended_variable_length_record)); diff --git a/src/LASzip/demzip_dll.cpp b/src/LASzip/demzip_dll.cpp index 8c2fbdc..a5e22d9 100644 --- a/src/LASzip/demzip_dll.cpp +++ b/src/LASzip/demzip_dll.cpp @@ -1987,9 +1987,9 @@ demzip_prepare_point_for_write( if (start_of_waveform_data_packet_record != 0) { #ifdef _WIN32 - fprintf(stderr,"WARNING: header->start_of_waveform_data_packet_record is %I64d. writing 0 instead.\n", start_of_waveform_data_packet_record); + REprintf("WARNING: header->start_of_waveform_data_packet_record is %I64d. writing 0 instead.\n", start_of_waveform_data_packet_record); #else - fprintf(stderr,"WARNING: header->start_of_waveform_data_packet_record is %llu. writing 0 instead.\n", start_of_waveform_data_packet_record); + REprintf("WARNING: header->start_of_waveform_data_packet_record is %llu. writing 0 instead.\n", start_of_waveform_data_packet_record); #endif start_of_waveform_data_packet_record = 0; } @@ -1998,9 +1998,9 @@ demzip_prepare_point_for_write( if (start_of_first_extended_variable_length_record != 0) { #ifdef _WIN32 - fprintf(stderr,"WARNING: EVLRs not supported. header->start_of_first_extended_variable_length_record is %I64d. writing 0 instead.\n", start_of_first_extended_variable_length_record); + REprintf("WARNING: EVLRs not supported. header->start_of_first_extended_variable_length_record is %I64d. writing 0 instead.\n", start_of_first_extended_variable_length_record); #else - fprintf(stderr,"WARNING: EVLRs not supported. header->start_of_first_extended_variable_length_record is %llu. writing 0 instead.\n", start_of_first_extended_variable_length_record); + REprintf("WARNING: EVLRs not supported. header->start_of_first_extended_variable_length_record is %llu. writing 0 instead.\n", start_of_first_extended_variable_length_record); #endif start_of_first_extended_variable_length_record = 0; } @@ -2008,7 +2008,7 @@ demzip_prepare_point_for_write( U32 number_of_extended_variable_length_records = demzip_dll->header.number_of_extended_variable_length_records; if (number_of_extended_variable_length_records != 0) { - fprintf(stderr,"WARNING: EVLRs not supported. header->number_of_extended_variable_length_records is %u. writing 0 instead.\n", number_of_extended_variable_length_records); + REprintf("WARNING: EVLRs not supported. header->number_of_extended_variable_length_records is %u. writing 0 instead.\n", number_of_extended_variable_length_records); number_of_extended_variable_length_records = 0; } out->put32bitsLE((U8*)&number_of_extended_variable_length_records); @@ -4078,9 +4078,9 @@ demzip_read_header( if (start_of_waveform_data_packet_record != 0) { #ifdef _WIN32 - fprintf(stderr,"WARNING: start_of_waveform_data_packet_record is %I64d. reading 0 instead.\n", start_of_waveform_data_packet_record); + REprintf("WARNING: start_of_waveform_data_packet_record is %I64d. reading 0 instead.\n", start_of_waveform_data_packet_record); #else - fprintf(stderr,"WARNING: start_of_waveform_data_packet_record is %llu. reading 0 instead.\n", start_of_waveform_data_packet_record); + REprintf("WARNING: start_of_waveform_data_packet_record is %llu. reading 0 instead.\n", start_of_waveform_data_packet_record); #endif } demzip_dll->header.start_of_waveform_data_packet_record = 0; @@ -4089,9 +4089,9 @@ demzip_read_header( if (start_of_first_extended_variable_length_record != 0) { #ifdef _WIN32 - fprintf(stderr,"WARNING: EVLRs not supported. start_of_first_extended_variable_length_record is %I64d. reading 0 instead.\n", start_of_first_extended_variable_length_record); + REprintf("WARNING: EVLRs not supported. start_of_first_extended_variable_length_record is %I64d. reading 0 instead.\n", start_of_first_extended_variable_length_record); #else - fprintf(stderr,"WARNING: EVLRs not supported. start_of_first_extended_variable_length_record is %llu. reading 0 instead.\n", start_of_first_extended_variable_length_record); + REprintf("WARNING: EVLRs not supported. start_of_first_extended_variable_length_record is %llu. reading 0 instead.\n", start_of_first_extended_variable_length_record); #endif } demzip_dll->header.start_of_first_extended_variable_length_record = 0; @@ -4099,7 +4099,7 @@ demzip_read_header( in->get32bitsLE((U8*)&number_of_extended_variable_length_records); if (number_of_extended_variable_length_records != 0) { - fprintf(stderr,"WARNING: EVLRs not supported. number_of_extended_variable_length_records is %u. reading 0 instead.\n", number_of_extended_variable_length_records); + REprintf("WARNING: EVLRs not supported. number_of_extended_variable_length_records is %u. reading 0 instead.\n", number_of_extended_variable_length_records); } demzip_dll->header.number_of_extended_variable_length_records = 0; U64 extended_number_of_point_records = 0; @@ -4107,9 +4107,9 @@ demzip_read_header( if (demzip_dll->header.number_of_point_records != 0 && ((U64)(demzip_dll->header.number_of_point_records)) != extended_number_of_point_records) { #ifdef _WIN32 - fprintf(stderr,"WARNING: number_of_point_records is %u. but extended_number_of_point_records is %I64u.\n", demzip_dll->header.number_of_point_records, extended_number_of_point_records); + REprintf("WARNING: number_of_point_records is %u. but extended_number_of_point_records is %I64u.\n", demzip_dll->header.number_of_point_records, extended_number_of_point_records); #else - fprintf(stderr,"WARNING: number_of_point_records is %u. but extended_number_of_point_records is %llu.\n", demzip_dll->header.number_of_point_records, extended_number_of_point_records); + REprintf("WARNING: number_of_point_records is %u. but extended_number_of_point_records is %llu.\n", demzip_dll->header.number_of_point_records, extended_number_of_point_records); #endif } demzip_dll->header.extended_number_of_point_records = extended_number_of_point_records; @@ -4120,9 +4120,9 @@ demzip_read_header( if ((r < 5) && demzip_dll->header.number_of_points_by_return[r] != 0 && ((U64)(demzip_dll->header.number_of_points_by_return[r])) != extended_number_of_points_by_return) { #ifdef _WIN32 - fprintf(stderr,"WARNING: number_of_points_by_return[%u] is %u. but extended_number_of_points_by_return[%u] is %I64u.\n", r, demzip_dll->header.number_of_points_by_return[r], r, extended_number_of_points_by_return); + REprintf("WARNING: number_of_points_by_return[%u] is %u. but extended_number_of_points_by_return[%u] is %I64u.\n", r, demzip_dll->header.number_of_points_by_return[r], r, extended_number_of_points_by_return); #else - fprintf(stderr,"WARNING: number_of_points_by_return[%u] is %u. but extended_number_of_points_by_return[%u] is %llu.\n", r, demzip_dll->header.number_of_points_by_return[r], r, extended_number_of_points_by_return); + REprintf("WARNING: number_of_points_by_return[%u] is %u. but extended_number_of_points_by_return[%u] is %llu.\n", r, demzip_dll->header.number_of_points_by_return[r], r, extended_number_of_points_by_return); #endif } demzip_dll->header.extended_number_of_points_by_return[r] = extended_number_of_points_by_return; diff --git a/src/LASzip/integercompressor.cpp b/src/LASzip/integercompressor.cpp index 1a81b63..92c1cd1 100644 --- a/src/LASzip/integercompressor.cpp +++ b/src/LASzip/integercompressor.cpp @@ -205,12 +205,12 @@ IntegerCompressor::~IntegerCompressor() entropy -= log(prob)*prob/log(2.0); } } - fprintf(stderr, "k: %d number: %d different: %d entropy: %lg raw: %1.1f\n",k,number,different,entropy, (float)(k?k:1)); + REprintf( "k: %d number: %d different: %d entropy: %lg raw: %1.1f\n",k,number,different,entropy, (float)(k?k:1)); total_number += number; total_entropy += (entropy*number); total_raw += ((k?k:1)*number); } - fprintf(stderr, "TOTAL: number: %d entropy: %lg raw: %lg\n",total_number,total_entropy/total_number,total_raw/total_number); + REprintf( "TOTAL: number: %d entropy: %lg raw: %lg\n",total_number,total_entropy/total_number,total_raw/total_number); } #endif } diff --git a/src/LASzip/lasindex.cpp b/src/LASzip/lasindex.cpp index 7e2af6f..6b70c22 100644 --- a/src/LASzip/lasindex.cpp +++ b/src/LASzip/lasindex.cpp @@ -108,7 +108,7 @@ void LASindex::complete(U32 minimum_points, I32 maximum_intervals, const BOOL ve { if (verbose) { - fprintf(stderr,"before complete %d %d\n", minimum_points, maximum_intervals); + REprintf("before complete %d %d\n", minimum_points, maximum_intervals); print(FALSE); } if (minimum_points) @@ -180,7 +180,7 @@ void LASindex::complete(U32 minimum_points, I32 maximum_intervals, const BOOL ve } if (verbose) { - fprintf(stderr,"after minimum_points %d\n", minimum_points); + REprintf("after minimum_points %d\n", minimum_points); print(FALSE); } } @@ -193,7 +193,7 @@ void LASindex::complete(U32 minimum_points, I32 maximum_intervals, const BOOL ve interval->merge_intervals(maximum_intervals, verbose); if (verbose) { - fprintf(stderr,"after maximum_intervals %d\n", maximum_intervals); + REprintf("after maximum_intervals %d\n", maximum_intervals); print(FALSE); } } @@ -219,15 +219,15 @@ void LASindex::print(BOOL verbose) } if (total_check != interval->total) { - fprintf(stderr,"ERROR: total_check %d != interval->total %d\n", total_check, interval->total); + REprintf("ERROR: total_check %d != interval->total %d\n", total_check, interval->total); } - if (verbose) fprintf(stderr,"cell %d intervals %d full %d total %d (%.2f)\n", interval->index, intervals, interval->full, interval->total, 100.0f*interval->full/interval->total); + if (verbose) REprintf("cell %d intervals %d full %d total %d (%.2f)\n", interval->index, intervals, interval->full, interval->total, 100.0f*interval->full/interval->total); total_cells++; total_full += interval->full; total_total += interval->total; total_intervals += intervals; } - if (verbose) fprintf(stderr,"total cells/intervals %d/%d full %d (%.2f)\n", total_cells, total_intervals, total_full, 100.0f*total_full/total_total); + if (verbose) REprintf("total cells/intervals %d/%d full %d (%.2f)\n", total_cells, total_intervals, total_full, 100.0f*total_full/total_total); } LASquadtree* LASindex::get_spatial() const @@ -253,7 +253,7 @@ BOOL LASindex::intersect_tile(const F32 ll_x, const F32 ll_y, const F32 size) { have_interval = FALSE; cells = spatial->intersect_tile(ll_x, ll_y, size); -// fprintf(stderr,"%d cells of %g/%g %g/%g intersect tile %g/%g/%g\n", num_cells, spatial->get_min_x(), spatial->get_min_y(), spatial->get_max_x(), spatial->get_max_y(), ll_x, ll_y, size); +// REprintf("%d cells of %g/%g %g/%g intersect tile %g/%g/%g\n", num_cells, spatial->get_min_x(), spatial->get_min_y(), spatial->get_max_x(), spatial->get_max_y(), ll_x, ll_y, size); if (cells) return merge_intervals(); return FALSE; @@ -263,7 +263,7 @@ BOOL LASindex::intersect_circle(const F64 center_x, const F64 center_y, const F6 { have_interval = FALSE; cells = spatial->intersect_circle(center_x, center_y, radius); -// fprintf(stderr,"%d cells of %g/%g %g/%g intersect circle %g/%g/%g\n", num_cells, spatial->get_min_x(), spatial->get_min_y(), spatial->get_max_x(), spatial->get_max_y(), center_x, center_y, radius); +// REprintf("%d cells of %g/%g %g/%g intersect circle %g/%g/%g\n", num_cells, spatial->get_min_x(), spatial->get_min_y(), spatial->get_max_x(), spatial->get_max_y(), center_x, center_y, radius); if (cells) return merge_intervals(); return FALSE; @@ -359,7 +359,7 @@ BOOL LASindex::read(const char* file_name) } if (!read(file)) { - fprintf(stderr,"ERROR (LASindex): cannot read '%s'\n", name); + REprintf("ERROR (LASindex): cannot read '%s'\n", name); fclose(file); free(name); return FALSE; @@ -396,7 +396,7 @@ BOOL LASindex::append(const char* file_name) const file = _wfopen(utf16_file_name, L"rb"); if (file == 0) { - fprintf(stderr, "ERROR: cannot open file '%ws'\n", utf16_file_name); + REprintf( "ERROR: cannot open file '%ws'\n", utf16_file_name); } delete [] utf16_file_name; } @@ -436,7 +436,7 @@ BOOL LASindex::append(const char* file_name) const CHAR user_id[16]; try { bytestreamin->getBytes((U8*)user_id, 16); } catch(...) { - fprintf(stderr,"ERROR: reading header.vlrs[%d].user_id\n", u); + REprintf("ERROR: reading header.vlrs[%d].user_id\n", u); return FALSE; } if (strcmp(user_id, "laszip encoded") == 0) @@ -447,13 +447,13 @@ BOOL LASindex::append(const char* file_name) const U16 record_id; try { bytestreamin->get16bitsLE((U8*)&record_id); } catch(...) { - fprintf(stderr,"ERROR: reading header.vlrs[%d].record_id\n", u); + REprintf("ERROR: reading header.vlrs[%d].record_id\n", u); return FALSE; } U16 record_length_after_header; try { bytestreamin->get16bitsLE((U8*)&record_length_after_header); } catch(...) { - fprintf(stderr,"ERROR: reading header.vlrs[%d].record_length_after_header\n", u); + REprintf("ERROR: reading header.vlrs[%d].record_length_after_header\n", u); return FALSE; } total += (54 + record_length_after_header); @@ -474,7 +474,7 @@ BOOL LASindex::append(const char* file_name) const file = _wfopen(utf16_file_name, L"rb+"); if (file == 0) { - fprintf(stderr, "ERROR: cannot open file '%ws'\n", utf16_file_name); + REprintf( "ERROR: cannot open file '%ws'\n", utf16_file_name); } delete [] utf16_file_name; } @@ -500,7 +500,7 @@ BOOL LASindex::append(const char* file_name) const if (!write(bytestreamout)) { - fprintf(stderr,"ERROR (LASindex): cannot append LAX to '%s'\n", file_name); + REprintf("ERROR (LASindex): cannot append LAX to '%s'\n", file_name); delete bytestreamout; fclose(file); delete lasreader; @@ -562,7 +562,7 @@ BOOL LASindex::write(const char* file_name) const file = _wfopen(utf16_file_name, L"wb"); if (file == 0) { - fprintf(stderr, "ERROR (LASindex): cannot open file '%ws' for write\n", utf16_file_name); + REprintf( "ERROR (LASindex): cannot open file '%ws' for write\n", utf16_file_name); } delete [] utf16_file_name; } @@ -571,13 +571,13 @@ BOOL LASindex::write(const char* file_name) const #endif if (file == 0) { - fprintf(stderr,"ERROR (LASindex): cannot open file '%s' for write\n", name); + REprintf("ERROR (LASindex): cannot open file '%s' for write\n", name); free(name); return FALSE; } if (!write(file)) { - fprintf(stderr,"ERROR (LASindex): cannot write file '%s'\n", name); + REprintf("ERROR (LASindex): cannot write file '%s'\n", name); fclose(file); free(name); return FALSE; @@ -602,32 +602,32 @@ BOOL LASindex::read(ByteStreamIn* stream) char signature[4]; try { stream->getBytes((U8*)signature, 4); } catch (...) { - fprintf(stderr,"ERROR (LASindex): reading signature\n"); + REprintf("ERROR (LASindex): reading signature\n"); return FALSE; } if (strncmp(signature, "LASX", 4) != 0) { - fprintf(stderr,"ERROR (LASindex): wrong signature %4s instead of 'LASX'\n", signature); + REprintf("ERROR (LASindex): wrong signature %4s instead of 'LASX'\n", signature); return FALSE; } U32 version; try { stream->get32bitsLE((U8*)&version); } catch (...) { - fprintf(stderr,"ERROR (LASindex): reading version\n"); + REprintf("ERROR (LASindex): reading version\n"); return FALSE; } // read spatial quadtree spatial = new LASquadtree(); if (!spatial->read(stream)) { - fprintf(stderr,"ERROR (LASindex): cannot read LASspatial (LASquadtree)\n"); + REprintf("ERROR (LASindex): cannot read LASspatial (LASquadtree)\n"); return FALSE; } // read interval interval = new LASinterval(); if (!interval->read(stream)) { - fprintf(stderr,"ERROR (LASindex): reading LASinterval\n"); + REprintf("ERROR (LASindex): reading LASinterval\n"); return FALSE; } // tell spatial about the existing cells @@ -643,25 +643,25 @@ BOOL LASindex::write(ByteStreamOut* stream) const { if (!stream->putBytes((const U8*)"LASX", 4)) { - fprintf(stderr,"ERROR (LASindex): writing signature\n"); + REprintf("ERROR (LASindex): writing signature\n"); return FALSE; } U32 version = 0; if (!stream->put32bitsLE((const U8*)&version)) { - fprintf(stderr,"ERROR (LASindex): writing version\n"); + REprintf("ERROR (LASindex): writing version\n"); return FALSE; } // write spatial quadtree if (!spatial->write(stream)) { - fprintf(stderr,"ERROR (LASindex): cannot write LASspatial (LASquadtree)\n"); + REprintf("ERROR (LASindex): cannot write LASspatial (LASquadtree)\n"); return FALSE; } // write interval if (!interval->write(stream)) { - fprintf(stderr,"ERROR (LASindex): writing LASinterval\n"); + REprintf("ERROR (LASindex): writing LASinterval\n"); return FALSE; } return TRUE; diff --git a/src/LASzip/lasinterval.cpp b/src/LASzip/lasinterval.cpp index a664e10..d89ed39 100644 --- a/src/LASzip/lasinterval.cpp +++ b/src/LASzip/lasinterval.cpp @@ -246,12 +246,12 @@ void LASinterval::merge_intervals(U32 maximum_intervals, const BOOL verbose) { if (map.size() == 0) { - fprintf(stderr,"maximum_intervals: %u number of interval gaps: 0 \n", maximum_intervals); + REprintf("maximum_intervals: %u number of interval gaps: 0 \n", maximum_intervals); } else { diff = (*(map.begin())).first; - fprintf(stderr,"maximum_intervals: %u number of interval gaps: %u next largest interval gap %u\n", maximum_intervals, (U32)map.size(), diff); + REprintf("maximum_intervals: %u number of interval gaps: %u next largest interval gap %u\n", maximum_intervals, (U32)map.size(), diff); } } return; @@ -301,7 +301,7 @@ void LASinterval::merge_intervals(U32 maximum_intervals, const BOOL verbose) } map_element++; } - if (verbose) fprintf(stderr,"largest interval gap increased to %u\n", diff); + if (verbose) REprintf("largest interval gap increased to %u\n", diff); // update totals @@ -578,25 +578,25 @@ BOOL LASinterval::read(ByteStreamIn* stream) char signature[4]; try { stream->getBytes((U8*)signature, 4); } catch (...) { - fprintf(stderr,"ERROR (LASinterval): reading signature\n"); + REprintf("ERROR (LASinterval): reading signature\n"); return FALSE; } if (strncmp(signature, "LASV", 4) != 0) { - fprintf(stderr,"ERROR (LASinterval): wrong signature %4s instead of 'LASV'\n", signature); + REprintf("ERROR (LASinterval): wrong signature %4s instead of 'LASV'\n", signature); return FALSE; } U32 version; try { stream->get32bitsLE((U8*)&version); } catch (...) { - fprintf(stderr,"ERROR (LASinterval): reading version\n"); + REprintf("ERROR (LASinterval): reading version\n"); return FALSE; } // read number of cells U32 number_cells; try { stream->get32bitsLE((U8*)&number_cells); } catch (...) { - fprintf(stderr,"ERROR (LASinterval): reading number of cells\n"); + REprintf("ERROR (LASinterval): reading number of cells\n"); return FALSE; } // loop over all cells @@ -606,7 +606,7 @@ BOOL LASinterval::read(ByteStreamIn* stream) I32 cell_index; try { stream->get32bitsLE((U8*)&cell_index); } catch (...) { - fprintf(stderr,"ERROR (LASinterval): reading cell index\n"); + REprintf("ERROR (LASinterval): reading cell index\n"); return FALSE; } // create cell and insert into hash @@ -617,14 +617,14 @@ BOOL LASinterval::read(ByteStreamIn* stream) U32 number_intervals; try { stream->get32bitsLE((U8*)&number_intervals); } catch (...) { - fprintf(stderr,"ERROR (LASinterval): reading number of intervals in cell\n"); + REprintf("ERROR (LASinterval): reading number of intervals in cell\n"); return FALSE; } // read number of points in cell U32 number_points; try { stream->get32bitsLE((U8*)&number_points); } catch (...) { - fprintf(stderr,"ERROR (LASinterval): reading number of points in cell\n"); + REprintf("ERROR (LASinterval): reading number of points in cell\n"); return FALSE; } start_cell->full = number_points; @@ -634,13 +634,13 @@ BOOL LASinterval::read(ByteStreamIn* stream) // read start of interval try { stream->get32bitsLE((U8*)&(cell->start)); } catch (...) { - fprintf(stderr,"ERROR (LASinterval): reading start %d of interval\n", cell->start); + REprintf("ERROR (LASinterval): reading start %d of interval\n", cell->start); return FALSE; } // read end of interval try { stream->get32bitsLE((U8*)&(cell->end)); } catch (...) { - fprintf(stderr,"ERROR (LASinterval): reading end %d of interval\n", cell->end); + REprintf("ERROR (LASinterval): reading end %d of interval\n", cell->end); return FALSE; } start_cell->total += (cell->end - cell->start + 1); @@ -661,20 +661,20 @@ BOOL LASinterval::write(ByteStreamOut* stream) const { if (!stream->putBytes((const U8*)"LASV", 4)) { - fprintf(stderr,"ERROR (LASinterval): writing signature\n"); + REprintf("ERROR (LASinterval): writing signature\n"); return FALSE; } U32 version = 0; if (!stream->put32bitsLE((const U8*)&version)) { - fprintf(stderr,"ERROR (LASinterval): writing version\n"); + REprintf("ERROR (LASinterval): writing version\n"); return FALSE; } // write number of cells U32 number_cells = (U32)((my_cell_hash*)cells)->size(); if (!stream->put32bitsLE((const U8*)&number_cells)) { - fprintf(stderr,"ERROR (LASinterval): writing number of cells %d\n", number_cells); + REprintf("ERROR (LASinterval): writing number of cells %d\n", number_cells); return FALSE; } // loop over all cells @@ -694,19 +694,19 @@ BOOL LASinterval::write(ByteStreamOut* stream) const I32 cell_index = (*hash_element).first; if (!stream->put32bitsLE((const U8*)&cell_index)) { - fprintf(stderr,"ERROR (LASinterval): writing cell index %d\n", cell_index); + REprintf("ERROR (LASinterval): writing cell index %d\n", cell_index); return FALSE; } // write number of intervals in cell if (!stream->put32bitsLE((const U8*)&number_intervals)) { - fprintf(stderr,"ERROR (LASinterval): writing number of intervals %d in cell\n", number_intervals); + REprintf("ERROR (LASinterval): writing number of intervals %d in cell\n", number_intervals); return FALSE; } // write number of points in cell if (!stream->put32bitsLE((const U8*)&number_points)) { - fprintf(stderr,"ERROR (LASinterval): writing number of points %d in cell\n", number_points); + REprintf("ERROR (LASinterval): writing number of points %d in cell\n", number_points); return FALSE; } // write intervals @@ -716,13 +716,13 @@ BOOL LASinterval::write(ByteStreamOut* stream) const // write start of interval if (!stream->put32bitsLE((const U8*)&(cell->start))) { - fprintf(stderr,"ERROR (LASinterval): writing start %d of interval\n", cell->start); + REprintf("ERROR (LASinterval): writing start %d of interval\n", cell->start); return FALSE; } // write end of interval if (!stream->put32bitsLE((const U8*)&(cell->end))) { - fprintf(stderr,"ERROR (LASinterval): writing end %d of interval\n", cell->end); + REprintf("ERROR (LASinterval): writing end %d of interval\n", cell->end); return FALSE; } cell = cell->next; diff --git a/src/LASzip/laspoint.hpp b/src/LASzip/laspoint.hpp index f7caff5..ca69d39 100644 --- a/src/LASzip/laspoint.hpp +++ b/src/LASzip/laspoint.hpp @@ -282,7 +282,7 @@ class LASpoint if (!LASzip().setup(&num_items, &items, point_type, point_size, LASZIP_COMPRESSOR_NONE)) { - fprintf(stderr,"ERROR: unknown point type %d with point size %d\n", (I32)point_type, (I32)point_size); + REprintf("ERROR: unknown point type %d with point size %d\n", (I32)point_type, (I32)point_size); return FALSE; } diff --git a/src/LASzip/lasquadtree.cpp b/src/LASzip/lasquadtree.cpp index 67a8e98..b768d6c 100644 --- a/src/LASzip/lasquadtree.cpp +++ b/src/LASzip/lasquadtree.cpp @@ -589,33 +589,33 @@ BOOL LASquadtree::read(ByteStreamIn* stream) char signature[4]; try { stream->getBytes((U8*)signature, 4); } catch(...) { - fprintf(stderr,"ERROR (LASquadtree): reading LASspatial signature\n"); + REprintf("ERROR (LASquadtree): reading LASspatial signature\n"); return FALSE; } if (strncmp(signature, "LASS", 4) != 0) { - fprintf(stderr,"ERROR (LASquadtree): wrong LASspatial signature %4s instead of 'LASS'\n", signature); + REprintf("ERROR (LASquadtree): wrong LASspatial signature %4s instead of 'LASS'\n", signature); return FALSE; } U32 type; try { stream->getBytes((U8*)&type, 4); } catch(...) { - fprintf(stderr,"ERROR (LASquadtree): reading LASspatial type\n"); + REprintf("ERROR (LASquadtree): reading LASspatial type\n"); return 0; } if (type != LAS_SPATIAL_QUAD_TREE) { - fprintf(stderr,"ERROR (LASquadtree): unknown LASspatial type %u\n", type); + REprintf("ERROR (LASquadtree): unknown LASspatial type %u\n", type); return 0; } try { stream->getBytes((U8*)signature, 4); } catch(...) { - fprintf(stderr,"ERROR (LASquadtree): reading signature\n"); + REprintf("ERROR (LASquadtree): reading signature\n"); return FALSE; } if (strncmp(signature, "LASQ", 4) != 0) { -// fprintf(stderr,"ERROR (LASquadtree): wrong signature %4s instead of 'LASV'\n", signature); +// REprintf("ERROR (LASquadtree): wrong signature %4s instead of 'LASV'\n", signature); // return FALSE; levels = ((U32*)signature)[0]; } @@ -624,45 +624,45 @@ BOOL LASquadtree::read(ByteStreamIn* stream) U32 version; try { stream->get32bitsLE((U8*)&version); } catch(...) { - fprintf(stderr,"ERROR (LASquadtree): reading version\n"); + REprintf("ERROR (LASquadtree): reading version\n"); return FALSE; } try { stream->get32bitsLE((U8*)&levels); } catch(...) { - fprintf(stderr,"ERROR (LASquadtree): reading levels\n"); + REprintf("ERROR (LASquadtree): reading levels\n"); return FALSE; } } U32 level_index; try { stream->get32bitsLE((U8*)&level_index); } catch(...) { - fprintf(stderr,"ERROR (LASquadtree): reading level_index\n"); + REprintf("ERROR (LASquadtree): reading level_index\n"); return FALSE; } U32 implicit_levels; try { stream->get32bitsLE((U8*)&implicit_levels); } catch(...) { - fprintf(stderr,"ERROR (LASquadtree): reading implicit_levels\n"); + REprintf("ERROR (LASquadtree): reading implicit_levels\n"); return FALSE; } try { stream->get32bitsLE((U8*)&min_x); } catch(...) { - fprintf(stderr,"ERROR (LASquadtree): reading min_x\n"); + REprintf("ERROR (LASquadtree): reading min_x\n"); return FALSE; } try { stream->get32bitsLE((U8*)&max_x); } catch(...) { - fprintf(stderr,"ERROR (LASquadtree): reading max_x\n"); + REprintf("ERROR (LASquadtree): reading max_x\n"); return FALSE; } try { stream->get32bitsLE((U8*)&min_y); } catch(...) { - fprintf(stderr,"ERROR (LASquadtree): reading min_y\n"); + REprintf("ERROR (LASquadtree): reading min_y\n"); return FALSE; } try { stream->get32bitsLE((U8*)&max_y); } catch(...) { - fprintf(stderr,"ERROR (LASquadtree): reading max_y\n"); + REprintf("ERROR (LASquadtree): reading max_y\n"); return FALSE; } return TRUE; @@ -682,65 +682,65 @@ BOOL LASquadtree::write(ByteStreamOut* stream) const if (!stream->putBytes((const U8*)"LASS", 4)) { - fprintf(stderr,"ERROR (LASquadtree): writing LASspatial signature\n"); + REprintf("ERROR (LASquadtree): writing LASspatial signature\n"); return FALSE; } U32 type = LAS_SPATIAL_QUAD_TREE; if (!stream->put32bitsLE((U8*)&type)) { - fprintf(stderr,"ERROR (LASquadtree): writing LASspatial type %u\n", type); + REprintf("ERROR (LASquadtree): writing LASspatial type %u\n", type); return FALSE; } if (!stream->putBytes((const U8*)"LASQ", 4)) { - fprintf(stderr,"ERROR (LASquadtree): writing signature\n"); + REprintf("ERROR (LASquadtree): writing signature\n"); return FALSE; } U32 version = 0; if (!stream->put32bitsLE((const U8*)&version)) { - fprintf(stderr,"ERROR (LASquadtree): writing version\n"); + REprintf("ERROR (LASquadtree): writing version\n"); return FALSE; } if (!stream->put32bitsLE((const U8*)&levels)) { - fprintf(stderr,"ERROR (LASquadtree): writing levels %u\n", levels); + REprintf("ERROR (LASquadtree): writing levels %u\n", levels); return FALSE; } U32 level_index = 0; if (!stream->put32bitsLE((const U8*)&level_index)) { - fprintf(stderr,"ERROR (LASquadtree): writing level_index %u\n", level_index); + REprintf("ERROR (LASquadtree): writing level_index %u\n", level_index); return FALSE; } U32 implicit_levels = 0; if (!stream->put32bitsLE((const U8*)&implicit_levels)) { - fprintf(stderr,"ERROR (LASquadtree): writing implicit_levels %u\n", implicit_levels); + REprintf("ERROR (LASquadtree): writing implicit_levels %u\n", implicit_levels); return FALSE; } if (!stream->put32bitsLE((const U8*)&min_x)) { - fprintf(stderr,"ERROR (LASquadtree): writing min_x %g\n", min_x); + REprintf("ERROR (LASquadtree): writing min_x %g\n", min_x); return FALSE; } if (!stream->put32bitsLE((const U8*)&max_x)) { - fprintf(stderr,"ERROR (LASquadtree): writing max_x %g\n", max_x); + REprintf("ERROR (LASquadtree): writing max_x %g\n", max_x); return FALSE; } if (!stream->put32bitsLE((const U8*)&min_y)) { - fprintf(stderr,"ERROR (LASquadtree): writing min_y %g\n", min_y); + REprintf("ERROR (LASquadtree): writing min_y %g\n", min_y); return FALSE; } if (!stream->put32bitsLE((const U8*)&max_y)) { - fprintf(stderr,"ERROR (LASquadtree): writing max_y %g\n", max_y); + REprintf("ERROR (LASquadtree): writing max_y %g\n", max_y); return FALSE; } return TRUE; @@ -1532,7 +1532,7 @@ BOOL LASquadtree::setup(F64 bb_min_x, F64 bb_max_x, F64 bb_min_y, F64 bb_max_y, if (cells_x == 0 || cells_y == 0) { - fprintf(stderr, "ERROR: cells_x %d cells_y %d\n", cells_x, cells_y); + REprintf( "ERROR: cells_x %d cells_y %d\n", cells_x, cells_y); return FALSE; } @@ -1583,7 +1583,7 @@ BOOL LASquadtree::setup(F64 bb_min_x, F64 bb_max_x, F64 bb_min_y, F64 bb_max_y, if (cells_x == 0 || cells_y == 0) { - fprintf(stderr, "ERROR: cells_x %d cells_y %d\n", cells_x, cells_y); + REprintf( "ERROR: cells_x %d cells_y %d\n", cells_x, cells_y); return FALSE; } diff --git a/src/LASzip/lasreaditemcompressed_v3.cpp b/src/LASzip/lasreaditemcompressed_v3.cpp index 48df564..3856652 100644 --- a/src/LASzip/lasreaditemcompressed_v3.cpp +++ b/src/LASzip/lasreaditemcompressed_v3.cpp @@ -375,7 +375,7 @@ inline BOOL LASreadItemCompressed_POINT14_v3::createAndInitModelsAndDecompressor memcpy(contexts[context].last_item, item, sizeof(LASpoint14)); ((LASpoint14*)contexts[context].last_item)->gps_time_change = FALSE; -// fprintf(stderr, "INIT: current_context %d last item %.14g %d %d %d %d %d %d\n", current_context, ((LASpoint14*)item)->gps_time, ((LASpoint14*)item)->X, ((LASpoint14*)item)->Y, ((LASpoint14*)item)->Z, ((LASpoint14*)item)->intensity, ((LASpoint14*)item)->return_number, ((LASpoint14*)item)->number_of_returns); +// REprintf( "INIT: current_context %d last item %.14g %d %d %d %d %d %d\n", current_context, ((LASpoint14*)item)->gps_time, ((LASpoint14*)item)->X, ((LASpoint14*)item)->Y, ((LASpoint14*)item)->Z, ((LASpoint14*)item)->intensity, ((LASpoint14*)item)->return_number, ((LASpoint14*)item)->number_of_returns); contexts[context].unused = FALSE; diff --git a/src/LASzip/lasreaditemcompressed_v4.cpp b/src/LASzip/lasreaditemcompressed_v4.cpp index f729362..eeae126 100644 --- a/src/LASzip/lasreaditemcompressed_v4.cpp +++ b/src/LASzip/lasreaditemcompressed_v4.cpp @@ -375,7 +375,7 @@ inline BOOL LASreadItemCompressed_POINT14_v4::createAndInitModelsAndDecompressor memcpy(contexts[context].last_item, item, sizeof(LASpoint14)); ((LASpoint14*)contexts[context].last_item)->gps_time_change = FALSE; -// fprintf(stderr, "INIT: current_context %d last item %.14g %d %d %d %d %d %d\n", current_context, ((LASpoint14*)item)->gps_time, ((LASpoint14*)item)->X, ((LASpoint14*)item)->Y, ((LASpoint14*)item)->Z, ((LASpoint14*)item)->intensity, ((LASpoint14*)item)->return_number, ((LASpoint14*)item)->number_of_returns); +// REprintf( "INIT: current_context %d last item %.14g %d %d %d %d %d %d\n", current_context, ((LASpoint14*)item)->gps_time, ((LASpoint14*)item)->X, ((LASpoint14*)item)->Y, ((LASpoint14*)item)->Z, ((LASpoint14*)item)->intensity, ((LASpoint14*)item)->return_number, ((LASpoint14*)item)->number_of_returns); contexts[context].unused = FALSE; diff --git a/src/LASzip/lasreadpoint.cpp b/src/LASzip/lasreadpoint.cpp index 660b943..bf6cc3e 100644 --- a/src/LASzip/lasreadpoint.cpp +++ b/src/LASzip/lasreadpoint.cpp @@ -477,7 +477,7 @@ BOOL LASreadPoint::read(U8* const * point) { ((LASreadItemCompressed*)(readers_compressed[i]))->init(point[i], context); } - if (DEBUG_OUTPUT_NUM_BYTES_DETAILS) fprintf(stderr, "\n"); + if (DEBUG_OUTPUT_NUM_BYTES_DETAILS) REprintf( "\n"); } else { diff --git a/src/LASzip/laswriteitemcompressed_v3.cpp b/src/LASzip/laswriteitemcompressed_v3.cpp index 12440f2..32dd563 100644 --- a/src/LASzip/laswriteitemcompressed_v3.cpp +++ b/src/LASzip/laswriteitemcompressed_v3.cpp @@ -205,7 +205,7 @@ LASwriteItemCompressed_POINT14_v3::~LASwriteItemCompressed_POINT14_v3() delete outstream_gps_time; } -// fprintf(stderr, "%u %u %u %u %u %u %u %u %u\n", num_bytes_channel_returns_XY, num_bytes_Z, num_bytes_classification, num_bytes_flags, num_bytes_intensity, num_bytes_scan_angle, num_bytes_user_data, num_bytes_point_source, num_bytes_gps_time); +// REprintf( "%u %u %u %u %u %u %u %u %u\n", num_bytes_channel_returns_XY, num_bytes_Z, num_bytes_classification, num_bytes_flags, num_bytes_intensity, num_bytes_scan_angle, num_bytes_user_data, num_bytes_point_source, num_bytes_gps_time); } inline BOOL LASwriteItemCompressed_POINT14_v3::createAndInitModelsAndCompressors(U32 context, const U8* item) diff --git a/src/LASzip/laszip.cpp b/src/LASzip/laszip.cpp index 3c938e8..0eaaf18 100644 --- a/src/LASzip/laszip.cpp +++ b/src/LASzip/laszip.cpp @@ -496,7 +496,7 @@ bool LASzip::setup(U16* num_items, LASitem** items, const U8 point_type, const U if (extra_bytes_number < 0) { - fprintf(stderr, "WARNING: point size %d too small by %d bytes for point type %d. assuming point_size of %d\n", point_size, -extra_bytes_number, point_type, point_size-extra_bytes_number); + REprintf( "WARNING: point size %d too small by %d bytes for point type %d. assuming point_size of %d\n", point_size, -extra_bytes_number, point_type, point_size-extra_bytes_number); extra_bytes_number = 0; } From c028b8a52387d6674b60a68fad035245587d8b80 Mon Sep 17 00:00:00 2001 From: Jean-Romain Date: Tue, 2 Mar 2021 15:11:43 -0500 Subject: [PATCH 04/20] Include R.h --- src/LASlib/fopen_compressed.cpp | 25 ++++++++++++++----------- src/LASzip/mydefs.hpp | 21 ++++++++++++--------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/LASlib/fopen_compressed.cpp b/src/LASlib/fopen_compressed.cpp index 43c0323..274aa7b 100644 --- a/src/LASlib/fopen_compressed.cpp +++ b/src/LASlib/fopen_compressed.cpp @@ -2,13 +2,13 @@ =============================================================================== FILE: fopen_compressed.cpp - + CONTENTS: - + PROGRAMMERS: - + martin.isenburg@rapidlasso.com - http://rapidlasso.com - + COPYRIGHT: (c) 2003-2018, martin isenburg, rapidlasso - fast tools to catch reality @@ -19,13 +19,13 @@ This software is distributed WITHOUT ANY WARRANTY and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - + CHANGE HISTORY: - + 27 December 2018 -- only act if the extension really is a file extension 20 March 2011 -- added capability for *.zip, *.rar, and *.7z on Windows 12 December 2003 -- adapted from Stefan Gumhold's SIGGRAPH submission hack - + =============================================================================== */ @@ -39,6 +39,9 @@ #include #endif +#define STRICT_R_HEADERS +#include + enum PIPES { READ_HANDLE, WRITE_HANDLE }; /* Constants 0 and 1 for READ and WRITE */ // open a 7zipped/ZIPped/gzipped/rarzipped file as if they were regular a file @@ -87,7 +90,7 @@ static FILE* fopen7zipped(const char* filename, const char* mode) return NULL; } - // return redirected stdin + // return redirected stdin return stdin; } else @@ -139,7 +142,7 @@ static FILE* fopenZIPped(const char* filename, const char* mode) return NULL; } - // return redirected stdin + // return redirected stdin return stdin; } else @@ -265,7 +268,7 @@ static FILE* fopenGzippedNew(const char* filename, const char* mode) return NULL; } - // return redirected stdin + // return redirected stdin return stdin; } else @@ -317,7 +320,7 @@ static FILE* fopenRARed(const char* filename, const char* mode) return NULL; } - // return redirected stdin + // return redirected stdin return stdin; } else diff --git a/src/LASzip/mydefs.hpp b/src/LASzip/mydefs.hpp index dfcd004..8d6bf68 100644 --- a/src/LASzip/mydefs.hpp +++ b/src/LASzip/mydefs.hpp @@ -2,11 +2,11 @@ =============================================================================== FILE: mydefs.hpp - + CONTENTS: Basic data type definitions and operations to be robust across platforms. - + PROGRAMMERS: martin.isenburg@rapidlasso.com - http://rapidlasso.com @@ -21,18 +21,21 @@ This software is distributed WITHOUT ANY WARRANTY and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - + CHANGE HISTORY: - + 28 October 2015 -- adding DLL bindings via 'COMPILE_AS_DLL' and 'USE_AS_DLL' 10 January 2011 -- licensing change for LGPL release and libLAS integration 13 July 2005 -- created after returning with many mosquito bites from OBX - + =============================================================================== */ #ifndef MYDEFS_HPP #define MYDEFS_HPP +#define STRICT_R_HEADERS +#include + #ifndef _WIN32 #define LASLIB_DLL #else // _WIN32 @@ -55,10 +58,10 @@ typedef unsigned int U32; typedef unsigned short U16; typedef unsigned char U8; -#if defined(_WIN32) && ! defined (__MINGW32__) // 64 byte integer under Windows +#if defined(_WIN32) && ! defined (__MINGW32__) // 64 byte integer under Windows typedef unsigned __int64 U64; typedef __int64 I64; -#else // 64 byte integer elsewhere ... +#else // 64 byte integer elsewhere ... typedef unsigned long long U64; typedef long long I64; #endif @@ -95,9 +98,9 @@ typedef union I64U32I32F32 { I64 i64; U32 u32[2]; I32 i32[2]; F32 f32[2]; } I64U #define U32_MIN ((U32)0x0) // 0 #define U32_MAX ((U32)0xFFFFFFFF) // 4294967295 #define U32_MAX_MINUS_ONE ((U32)0xFFFFFFFE) // 4294967294 -#if defined(WIN32) // 64 byte unsigned int constant under Windows +#if defined(WIN32) // 64 byte unsigned int constant under Windows #define U32_MAX_PLUS_ONE 0x0000000100000000 // 4294967296 -#else // 64 byte unsigned int constant elsewhere ... +#else // 64 byte unsigned int constant elsewhere ... #define U32_MAX_PLUS_ONE 0x0000000100000000ull // 4294967296 #endif From a4a24926ff2fbc75020f17004448aaa8bab4e4dd Mon Sep 17 00:00:00 2001 From: Jean-Romain Date: Tue, 2 Mar 2021 15:16:51 -0500 Subject: [PATCH 05/20] Comment unused code using stdout --- src/LASlib/lasreaderpipeon.cpp | 24 ++++++++++++------------ src/LASlib/laswriter.cpp | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/LASlib/lasreaderpipeon.cpp b/src/LASlib/lasreaderpipeon.cpp index 329eab2..7f01788 100644 --- a/src/LASlib/lasreaderpipeon.cpp +++ b/src/LASlib/lasreaderpipeon.cpp @@ -2,17 +2,17 @@ =============================================================================== FILE: lasreaderpipeon.cpp - + CONTENTS: - + see corresponding header file - + PROGRAMMERS: - + martin.isenburg@rapidlasso.com - http://rapidlasso.com - + COPYRIGHT: - + (c) 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality This is free software; you can redistribute and/or modify it under the @@ -21,11 +21,11 @@ This software is distributed WITHOUT ANY WARRANTY and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - + CHANGE HISTORY: - + see corresponding header file - + =============================================================================== */ #include "lasreaderpipeon.hpp" @@ -93,12 +93,12 @@ BOOL LASreaderPipeOn::open(LASreader* lasreader) return FALSE; } - if (!laswriterlas->open(stdout, &header)) + /*if (!laswriterlas->open(stdout, &header)) { delete laswriterlas; REprintf( "ERROR: opening laswriterlas to stdout\n"); return FALSE; - } + }*/ laswriter = laswriterlas; @@ -175,7 +175,7 @@ BOOL LASreaderPipeOn::read_point_default() void LASreaderPipeOn::close(BOOL close_stream) { - if (lasreader) + if (lasreader) { lasreader->close(close_stream); } diff --git a/src/LASlib/laswriter.cpp b/src/LASlib/laswriter.cpp index e48a590..c9721d9 100644 --- a/src/LASlib/laswriter.cpp +++ b/src/LASlib/laswriter.cpp @@ -136,7 +136,7 @@ LASwriter* LASwriteOpener::open(const LASheader* header) return 0; } } - else if (use_stdout) + /*else if (use_stdout) { if (format <= LAS_TOOLS_FORMAT_LAZ) { @@ -201,7 +201,7 @@ LASwriter* LASwriteOpener::open(const LASheader* header) REprintf("ERROR: unknown format %d\n", format); return 0; } - } + }*/ else { REprintf("ERROR: no laswriter output specified\n"); From e5b451929a0ccfd991ad80f592c11392d333482f Mon Sep 17 00:00:00 2001 From: Jean-Romain Date: Tue, 2 Mar 2021 15:21:04 -0500 Subject: [PATCH 06/20] strncpy -> memcpy --- src/LASlib/lasdefinitions.hpp | 28 +++++++++++++++------------- src/LASlib/laswriter.cpp | 2 +- src/LASlib/laswriter_bin.cpp | 22 +++++++++++----------- src/LASzip/lasattributer.hpp | 25 +++++++++++++++---------- 4 files changed, 42 insertions(+), 35 deletions(-) diff --git a/src/LASlib/lasdefinitions.hpp b/src/LASlib/lasdefinitions.hpp index 71080dc..80b85c6 100644 --- a/src/LASlib/lasdefinitions.hpp +++ b/src/LASlib/lasdefinitions.hpp @@ -2,9 +2,9 @@ =============================================================================== FILE: lasdefinitions.hpp - + CONTENTS: - + Contains the Header and Point classes for reading and writing LiDAR points in the LAS format @@ -28,22 +28,22 @@ This software is distributed WITHOUT ANY WARRANTY and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - + CHANGE HISTORY: - - 19 April 2017 -- support for selective decompression for new LAS 1.4 points + + 19 April 2017 -- support for selective decompression for new LAS 1.4 points 1 February 2017 -- better support for OGC WKT strings in VLRs or EVLRs 22 June 2016 -- set default of VLR header "reserved" to 0 instead of 0xAABB 1 August 2015 -- moving LASpoint, LASquantizer, and LASattributer to LASzip 9 December 2013 -- bug fix and improved writing of new LAS 1.4 point types - 21 December 2011 -- (limited) support for LAS 1.4 and attributed extra bytes + 21 December 2011 -- (limited) support for LAS 1.4 and attributed extra bytes 10 January 2011 -- licensing change for LGPL release and liblas integration 16 December 2010 -- updated to support generic LASitem point formats 3 December 2010 -- updated to (somewhat) support LAS format 1.3 - 7 September 2008 -- updated to support LAS format 1.2 + 7 September 2008 -- updated to support LAS format 1.2 11 June 2007 -- number of return / scan direction bitfield order was wrong 18 February 2007 -- created after repairing 2 vacuum cleaners in the garden - + =============================================================================== */ #ifndef LAS_DEFINITIONS_HPP @@ -88,7 +88,7 @@ class LASvlr { public: U16 reserved; - CHAR user_id[16]; + CHAR user_id[16]; U16 record_id; U16 record_length_after_header; CHAR description[32]; @@ -100,7 +100,7 @@ class LASevlr { public: U16 reserved; - CHAR user_id[16]; + CHAR user_id[16]; U16 record_id; I64 record_length_after_header; CHAR description[32]; @@ -500,7 +500,7 @@ class LASheader : public LASquantizer, public LASattributer }; // note that data needs to be allocated with new [] and not malloc and that LASheader - // will become the owner over this and manage its deallocation + // will become the owner over this and manage its deallocation BOOL add_vlr(const CHAR* user_id, const U16 record_id, const U16 record_length_after_header, U8* data, const BOOL keep_description=FALSE, const CHAR* description=0, const BOOL keep_existing=FALSE) { U32 i = 0; @@ -543,7 +543,9 @@ class LASheader : public LASquantizer, public LASattributer } memset(&(vlrs[i]), 0, sizeof(LASvlr)); vlrs[i].reserved = 0; // used to be 0xAABB - strncpy(vlrs[i].user_id, user_id, 16); + //strncpy(vlrs[i].user_id, user_id, 16); + int len = 0 ; while(*(user_id+len) != '\0' && len < 16) len++; + memcpy(vlrs[i].user_id, user_id, len); vlrs[i].record_id = record_id; vlrs[i].record_length_after_header = record_length_after_header; if (keep_description && found_description) @@ -629,7 +631,7 @@ class LASheader : public LASquantizer, public LASattributer }; // note that data needs to be allocated with new [] and not malloc and that LASheader - // will become the owner over this and manage its deallocation + // will become the owner over this and manage its deallocation void add_evlr(const CHAR* user_id, const U16 record_id, const I64 record_length_after_header, U8* data, const BOOL keep_description=FALSE, const CHAR* description=0, const BOOL keep_existing=FALSE) { U32 i = 0; diff --git a/src/LASlib/laswriter.cpp b/src/LASlib/laswriter.cpp index c9721d9..d8074dc 100644 --- a/src/LASlib/laswriter.cpp +++ b/src/LASlib/laswriter.cpp @@ -1137,7 +1137,7 @@ void LASwriteOpener::cut_characters(U32 cut) } else { - strncpy(new_file_name, file_name, len-cut); + memcpy(new_file_name, file_name, len-cut); sprintf(&(new_file_name[len-cut]), "%s", &(file_name[len])); } free(file_name); diff --git a/src/LASlib/laswriter_bin.cpp b/src/LASlib/laswriter_bin.cpp index e9c413a..7ddc7df 100644 --- a/src/LASlib/laswriter_bin.cpp +++ b/src/LASlib/laswriter_bin.cpp @@ -2,13 +2,13 @@ =============================================================================== FILE: laswriter_bin.cpp - + CONTENTS: - + see corresponding header file - + PROGRAMMERS: - + martin.isenburg@rapidlasso.com - http://rapidlasso.com COPYRIGHT: @@ -21,11 +21,11 @@ This software is distributed WITHOUT ANY WARRANTY and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - + CHANGE HISTORY: - + see corresponding header file - + =============================================================================== */ #include "laswriter_bin.hpp" @@ -170,11 +170,11 @@ BOOL LASwriterBIN::open(ByteStreamOut* stream, const LASheader* header, const ch tsheader.size = sizeof(TSheader); tsheader.version = this->version; tsheader.recog_val = 970401; - strncpy(tsheader.recog_str, "CXYZ", 4); + memcpy(tsheader.recog_str, "CXYZ", 4); tsheader.npoints = (header->number_of_point_records ? header->number_of_point_records : (U32)header->extended_number_of_point_records); double scale = header->x_scale_factor; - if (header->y_scale_factor < scale) scale = header->y_scale_factor; - if (header->z_scale_factor < scale) scale = header->z_scale_factor; + if (header->y_scale_factor < scale) scale = header->y_scale_factor; + if (header->z_scale_factor < scale) scale = header->z_scale_factor; units = tsheader.units = (I32)(1.0 / scale); origin_x = tsheader.origin_x = -header->x_offset/scale; origin_y = tsheader.origin_y = -header->y_offset/scale; @@ -250,7 +250,7 @@ BOOL LASwriterBIN::update_header(const LASheader* header, BOOL use_inventory, BO I64 LASwriterBIN::close(BOOL update_npoints) { I64 bytes = 0; - + if (stream) { if (update_npoints && p_count != npoints) diff --git a/src/LASzip/lasattributer.hpp b/src/LASzip/lasattributer.hpp index cbcc066..09534d2 100644 --- a/src/LASzip/lasattributer.hpp +++ b/src/LASzip/lasattributer.hpp @@ -2,10 +2,10 @@ =============================================================================== FILE: lasattributer.hpp - + CONTENTS: - - This class assists with handling the "extra bytes" that allow storing + + This class assists with handling the "extra bytes" that allow storing additional per point attributes. PROGRAMMERS: @@ -22,12 +22,12 @@ This software is distributed WITHOUT ANY WARRANTY and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - + CHANGE HISTORY: - + 13 September 2018 -- removed tuples and triple support from attributes 19 July 2015 -- created after FOSS4GE in the train back from Lake Como - + =============================================================================== */ #ifndef LAS_ATTRIBUTER_HPP @@ -76,8 +76,13 @@ class LASattribute memset(this, 0, sizeof(LASattribute)); scale[0] = scale[1] = scale[2] = 1.0; this->data_type = type+1; - strncpy(this->name, name, 32); - if (description) strncpy(this->description, description, 32); + int len = 0 ; while(*(name+len) != '\0' && len < 32) len++; + memcpy(this->name, name, len); + if (description) + { + int len = 0 ; while(*(description+len) != '\0' && len < 32) len++; + memcpy(this->description, description, len); + } }; inline BOOL set_no_data(U8 no_data) { if (0 == get_type()) { this->no_data[0].u64 = no_data; options |= 0x01; return TRUE; } return FALSE; }; @@ -270,7 +275,7 @@ class LASattribute { return ((I32)data_type - 1)%10; }; - inline I32 get_dim() const // compute dimension of deprecated tuple and triple attributes + inline I32 get_dim() const // compute dimension of deprecated tuple and triple attributes { return ((I32)data_type - 1)/10 + 1; }; @@ -552,7 +557,7 @@ class LASattributer { I32 index = get_attribute_index(name); if (index != -1) - { + { return remove_attribute(index); } return FALSE; From 9194504b8c8efafb163cb380a0cc47b7fedcd4aa Mon Sep 17 00:00:00 2001 From: Jean-Romain Date: Tue, 2 Mar 2021 15:27:38 -0500 Subject: [PATCH 07/20] cast pointer to void --- src/LASlib/lasdefinitions.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LASlib/lasdefinitions.hpp b/src/LASlib/lasdefinitions.hpp index 80b85c6..ba3f7f3 100644 --- a/src/LASlib/lasdefinitions.hpp +++ b/src/LASlib/lasdefinitions.hpp @@ -541,7 +541,7 @@ class LASheader : public LASquantizer, public LASattributer offset_to_point_data += 54; vlrs = (LASvlr*)malloc(sizeof(LASvlr)); } - memset(&(vlrs[i]), 0, sizeof(LASvlr)); + memset((void*)&(vlrs[i]), 0, sizeof(LASvlr)); vlrs[i].reserved = 0; // used to be 0xAABB //strncpy(vlrs[i].user_id, user_id, 16); int len = 0 ; while(*(user_id+len) != '\0' && len < 16) len++; From b9d7bb0b1276434519700c348f1ef3b3cde7d055 Mon Sep 17 00:00:00 2001 From: Jean-Romain Date: Tue, 2 Mar 2021 15:31:24 -0500 Subject: [PATCH 08/20] Force true to remove stdout --- src/LASzip/bytestreamout_file.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/LASzip/bytestreamout_file.hpp b/src/LASzip/bytestreamout_file.hpp index 43e6d2e..df45689 100644 --- a/src/LASzip/bytestreamout_file.hpp +++ b/src/LASzip/bytestreamout_file.hpp @@ -2,9 +2,9 @@ =============================================================================== FILE: bytestreamout_file.hpp - + CONTENTS: - + Class for FILE*-based output streams with endian handling. PROGRAMMERS: @@ -21,13 +21,13 @@ This software is distributed WITHOUT ANY WARRANTY and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - + CHANGE HISTORY: - + 1 October 2011 -- added 64 bit file support in MSVC 6.0 at McCafe at Hbf Linz 10 January 2011 -- licensing change for LGPL release and liblas integration 12 December 2010 -- created from ByteStreamOutFile after Howard got pushy (-; - + =============================================================================== */ #ifndef BYTE_STREAM_OUT_FILE_H @@ -130,7 +130,7 @@ inline BOOL ByteStreamOutFile::putBytes(const U8* bytes, U32 num_bytes) inline BOOL ByteStreamOutFile::isSeekable() const { - return (file != stdout); + return (true); } inline I64 ByteStreamOutFile::tell() const From c16439ed4cd10a9d8001bd60d1b0be3074779b61 Mon Sep 17 00:00:00 2001 From: Jean-Romain Date: Tue, 2 Mar 2021 15:35:58 -0500 Subject: [PATCH 09/20] srand -> R::runif --- src/LASlib/lasfilter.cpp | 59 ++++--- src/LASlib/lastransform.cpp | 339 ++++++++++++++++++------------------ 2 files changed, 200 insertions(+), 198 deletions(-) diff --git a/src/LASlib/lasfilter.cpp b/src/LASlib/lasfilter.cpp index 08797bc..9462545 100644 --- a/src/LASlib/lasfilter.cpp +++ b/src/LASlib/lasfilter.cpp @@ -2,11 +2,11 @@ =============================================================================== FILE: lasfilter.cpp - + CONTENTS: - + see corresponding header file - + PROGRAMMERS: martin.isenburg@rapidlasso.com - http://rapidlasso.com @@ -21,11 +21,11 @@ This software is distributed WITHOUT ANY WARRANTY and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - + CHANGE HISTORY: - + see corresponding header file - + =============================================================================== */ #include "lasfilter.hpp" @@ -521,7 +521,7 @@ class LAScriterionKeepReturns : public LAScriterion { public: inline const CHAR* name() const { return "keep_return_mask"; }; - inline I32 get_command(CHAR* string) const { + inline I32 get_command(CHAR* string) const { U32 i; U32 n = sprintf(string, "-keep_return "); U16 keep_return_mask = ~drop_return_mask; @@ -539,7 +539,7 @@ class LAScriterionDropReturns : public LAScriterion { public: inline const CHAR* name() const { return "drop_return_mask"; }; - inline I32 get_command(CHAR* string) const { + inline I32 get_command(CHAR* string) const { U32 i; U32 n = sprintf(string, "-drop_return "); for (i = 0; i < 16; i++) if ((1 << i) & drop_return_mask) n += sprintf(string + n, "%u ", i); @@ -673,7 +673,7 @@ class LAScriterionKeepNDVI : public LAScriterion inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s%s %g %g ", name(), (NIR == 3 ? "" : (NIR == 1 ? "_green_is_NIR" : "_blue_is_NIR")), below_NDVI, above_NDVI); }; inline U32 get_decompress_selective() const { if (NIR == 3) return LASZIP_DECOMPRESS_SELECTIVE_RGB | LASZIP_DECOMPRESS_SELECTIVE_NIR; else return LASZIP_DECOMPRESS_SELECTIVE_RGB; }; inline BOOL filter(const LASpoint* point) - { + { F32 NDVI = ((F32)(point->rgb[NIR] - point->get_R())) / ((F32)(point->rgb[NIR] + point->get_R())); return (NDVI < below_NDVI) || (above_NDVI < NDVI); }; @@ -690,7 +690,7 @@ class LAScriterionKeepNDVIfromCIR : public LAScriterion inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %g %g ", name(), below_NDVI, above_NDVI); }; inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_RGB; }; inline BOOL filter(const LASpoint* point) - { + { F32 NDVI = ((F32)(point->get_R() - point->get_G())) / ((F32)(point->get_R() + point->get_G())); return (NDVI < below_NDVI) || (above_NDVI < NDVI); }; @@ -706,7 +706,7 @@ class LAScriterionKeepNDVIintensityIsNIR : public LAScriterion inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %g %g ", name(), below_NDVI, above_NDVI); }; inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_RGB | LASZIP_DECOMPRESS_SELECTIVE_INTENSITY; }; inline BOOL filter(const LASpoint* point) - { + { F32 NDVI = ((F32)(point->get_intensity() - point->get_R())) / ((F32)(point->get_intensity() + point->get_R())); return (NDVI < below_NDVI) || (above_NDVI < NDVI); }; @@ -839,7 +839,7 @@ class LAScriterionKeepClassifications : public LAScriterion { public: inline const CHAR* name() const { return "keep_classification_mask"; }; - inline I32 get_command(CHAR* string) const { + inline I32 get_command(CHAR* string) const { U32 i; U32 n = sprintf(string, "-keep_class "); U32 keep_classification_mask = ~drop_classification_mask; @@ -858,7 +858,7 @@ class LAScriterionDropClassifications : public LAScriterion { public: inline const CHAR* name() const { return "drop_classification_mask"; }; - inline I32 get_command(CHAR* string) const { + inline I32 get_command(CHAR* string) const { U32 i; U32 n = sprintf(string, "-drop_class "); for (i = 0; i < 32; i++) if ((1 << i) & drop_classification_mask) n += sprintf(string + n, "%u ", i); @@ -1307,8 +1307,9 @@ class LAScriterionKeepRandomFraction : public LAScriterion inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %g ", name(), fraction); }; inline BOOL filter(const LASpoint* point) { - srand(seed); - seed = rand(); + //srand(seed); + //seed = rand(); + seed = R::runif(0, RAND_MAX); return ((F32)seed/(F32)RAND_MAX) > fraction; }; void reset() { seed = requested_seed; }; @@ -1326,7 +1327,7 @@ class LAScriterionThinWithGrid : public LAScriterion inline const CHAR* name() const { return "thin_with_grid"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %g ", name(), (grid_spacing > 0 ? grid_spacing : -grid_spacing)); }; inline BOOL filter(const LASpoint* point) - { + { if (grid_spacing < 0) { grid_spacing = -grid_spacing; @@ -1538,7 +1539,7 @@ class LAScriterionThinPulsesWithTime : public LAScriterion inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %lf ", name(), (time_spacing > 0 ? time_spacing : -time_spacing)); }; inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_GPS_TIME; }; inline BOOL filter(const LASpoint* point) - { + { I64 pos_t = I64_FLOOR(point->get_gps_time() / time_spacing); my_I64_F64_map::iterator map_element = times.find(pos_t); if (map_element == times.end()) @@ -1576,7 +1577,7 @@ class LAScriterionThinPointsWithTime : public LAScriterion inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %lf ", name(), (time_spacing > 0 ? time_spacing : -time_spacing)); }; inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_GPS_TIME; }; inline BOOL filter(const LASpoint* point) - { + { I64 pos_t = I64_FLOOR(point->get_gps_time() / time_spacing); my_I64_set::iterator map_element = times.find(pos_t); if (map_element == times.end()) @@ -1906,7 +1907,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) return FALSE; } add_criterion(new LAScriterionKeepxy(min_x, min_y, max_x, max_y)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; i+=4; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; i+=4; } else if (strcmp(argv[i],"-keep_xyz") == 0) { @@ -1952,7 +1953,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) return FALSE; } add_criterion(new LAScriterionKeepxyz(min_x, min_y, min_z, max_x, max_y, max_z)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; *argv[i+5]='\0'; *argv[i+6]='\0'; i+=6; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; *argv[i+5]='\0'; *argv[i+6]='\0'; i+=6; } else if (strcmp(argv[i],"-keep_x") == 0) { @@ -2090,7 +2091,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) return FALSE; } add_criterion(new LAScriterionKeepXY(min_X, min_Y, max_X, max_Y)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; i+=4; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; i+=4; } else if (strcmp(argv[i],"-keep_X") == 0) { @@ -2112,7 +2113,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) return FALSE; } add_criterion(new LAScriterionKeepX(min_X, max_X)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } } else if (strcmp(argv[i],"-keep_Y") == 0) @@ -2135,7 +2136,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) return FALSE; } add_criterion(new LAScriterionKeepY(min_Y, max_Y)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strncmp(argv[i],"-keep_Z", 7) == 0) { @@ -2159,7 +2160,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) return FALSE; } add_criterion(new LAScriterionKeepZ(min_Z, max_Z)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-keep_Z_above") == 0) { @@ -2220,7 +2221,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) return FALSE; } add_criterion(new LAScriterionKeepTile(llx, lly, size)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } else if (strcmp(argv[i],"-keep_circle") == 0) { @@ -2692,7 +2693,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) criteria[num_criteria] = 0; add_criterion(filter_criterion); i+=1; - } + } *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-keep_point_source_between") == 0) @@ -3160,7 +3161,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) return FALSE; } add_criterion(new LAScriterionDropxy(min_x, min_y, max_x, max_y)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; i+=4; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; i+=4; } else if (strcmp(argv[i],"-drop_xyz") == 0) { @@ -3206,7 +3207,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) return FALSE; } add_criterion(new LAScriterionDropxyz(min_x, min_y, min_z, max_x, max_y, max_z)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; *argv[i+5]='\0'; *argv[i+6]='\0'; i+=6; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; *argv[i+5]='\0'; *argv[i+6]='\0'; i+=6; } else if (strcmp(argv[i],"-drop_x") == 0) { @@ -3842,7 +3843,7 @@ BOOL LASfilter::parse(int argc, char* argv[]) } add_criterion(new LAScriterionDropScanAngleBelow(min)); *argv[i]='\0'; *argv[i+1]='\0'; i+=1; - } + } else if (strcmp(argv[i],"-drop_scan_angle_between") == 0) { if ((i+2) >= argc) diff --git a/src/LASlib/lastransform.cpp b/src/LASlib/lastransform.cpp index 73adcea..0f5ac92 100644 --- a/src/LASlib/lastransform.cpp +++ b/src/LASlib/lastransform.cpp @@ -2,11 +2,11 @@ =============================================================================== FILE: lastransform.cpp - + CONTENTS: - + see corresponding header file - + PROGRAMMERS: martin.isenburg@rapidlasso.com - http://rapidlasso.com @@ -21,11 +21,11 @@ This software is distributed WITHOUT ANY WARRANTY and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - + CHANGE HISTORY: - + see corresponding header file - + =============================================================================== */ #include "lastransform.hpp" @@ -579,8 +579,9 @@ class LASoperationTranslateRawXYatRandom : public LASoperation inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %d %d ", name(), max_raw_offset[0], max_raw_offset[1]); }; inline void transform(LASpoint* point) { I32 r; - srand(seed); - seed = rand(); + //srand(seed); + //seed = rand(); + seed = R::runif(0, RAND_MAX); r = ((seed >> 3) % ((2 * max_raw_offset[0]) + 1)) - max_raw_offset[0]; point->set_X(point->get_X() + r); r = ((seed >> 6) % ((2 * max_raw_offset[1]) + 1)) - max_raw_offset[1]; @@ -805,7 +806,7 @@ class LASoperationAddRegisters : public LASoperation inline const CHAR* name() const { return "add_registers"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u %u %u ", name(), input1, input2, output); }; inline void transform(LASpoint* point) { - F64 result = registers[input1] + registers[input2]; + F64 result = registers[input1] + registers[input2]; registers[output] = result; }; LASoperationAddRegisters(F64* registers, U32 input1, U32 input2, U32 output) { this->registers = registers; this->input1 = input1; this->input2 = input2; this->output = output; }; @@ -822,7 +823,7 @@ class LASoperationSubtractRegisters : public LASoperation inline const CHAR* name() const { return "subtract_registers"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u %u %u ", name(), input1, input2, output); }; inline void transform(LASpoint* point) { - F64 result = registers[input1] - registers[input2]; + F64 result = registers[input1] - registers[input2]; registers[output] = result; }; LASoperationSubtractRegisters(F64* registers, U32 input1, U32 input2, U32 output) { this->registers = registers; this->input1 = input1; this->input2 = input2; this->output = output; }; @@ -839,7 +840,7 @@ class LASoperationMultiplyRegisters : public LASoperation inline const CHAR* name() const { return "multiply_registers"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u %u %u ", name(), input1, input2, output); }; inline void transform(LASpoint* point) { - F64 result = registers[input1] * registers[input2]; + F64 result = registers[input1] * registers[input2]; registers[output] = result; }; LASoperationMultiplyRegisters(F64* registers, U32 input1, U32 input2, U32 output) { this->registers = registers; this->input1 = input1; this->input2 = input2; this->output = output; }; @@ -856,7 +857,7 @@ class LASoperationDivideRegisters : public LASoperation inline const CHAR* name() const { return "divide_registers"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s %u %u %u ", name(), input1, input2, output); }; inline void transform(LASpoint* point) { - F64 result = registers[input1] / registers[input2]; + F64 result = registers[input1] / registers[input2]; registers[output] = result; }; LASoperationDivideRegisters(F64* registers, U32 input1, U32 input2, U32 output) { this->registers = registers; this->input1 = input1; this->input2 = input2; this->output = output; }; @@ -2099,7 +2100,7 @@ class LASoperationMapAttributeIntoRGB : public LASoperation LASoperationMapAttributeIntoRGB(const U32 index, const CHAR* file_name) { F64 value; - U32 R, G, B; + U32 R, G, B; CHAR line[256]; FILE* file = fopen(file_name, "r"); size = 0; @@ -2119,7 +2120,7 @@ class LASoperationMapAttributeIntoRGB : public LASoperation } if (size) { - U32 count = 0; + U32 count = 0; values = new F64[size]; Rs = new U8[size]; Gs = new U8[size]; @@ -2216,7 +2217,7 @@ class LASoperationCopyRBGNIRintoRegister : public LASoperation inline const CHAR* name() const { return (band == 0 ? "copy_R_into_register" : (band == 1 ? "copy_G_into_register" : (band == 2 ? "copy_B_into_register" : "copy_NIR_into_register"))); }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s ", name()); }; inline U32 get_decompress_selective() const { return (band < 3 ? LASZIP_DECOMPRESS_SELECTIVE_RGB : LASZIP_DECOMPRESS_SELECTIVE_NIR); }; - inline void transform(LASpoint* point) { + inline void transform(LASpoint* point) { registers[index] = point->get_RGBI(band); }; LASoperationCopyRBGNIRintoRegister(const U32 band, F64* registers, const U32 index) { this->band = band; this->registers = registers; this->index = index; }; @@ -2295,7 +2296,7 @@ class LASoperationSwitchRGBItoCIR : public LASoperation inline const CHAR* name() const { return "switch_RGBI_into_CIR"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s ", name()); }; inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_RGB | LASZIP_DECOMPRESS_SELECTIVE_NIR; }; - inline void transform(LASpoint* point) { + inline void transform(LASpoint* point) { U16 R = point->get_R(); U16 G = point->get_G(); U16 I = point->get_NIR(); @@ -2311,7 +2312,7 @@ class LASoperationSwitchRGBIntensitytoCIR : public LASoperation inline const CHAR* name() const { return "switch_RGB_intensity_into_CIR"; }; inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s ", name()); }; inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_RGB | LASZIP_DECOMPRESS_SELECTIVE_INTENSITY; }; - inline void transform(LASpoint* point) { + inline void transform(LASpoint* point) { U16 R = point->get_R(); U16 G = point->get_G(); U16 intensity = point->get_intensity(); @@ -2723,7 +2724,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) } transformed_fields |= LASTRANSFORM_X_COORDINATE; add_operation(new LASoperationTranslateX(offset)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-translate_y") == 0) { @@ -2740,7 +2741,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) } transformed_fields |= LASTRANSFORM_Y_COORDINATE; add_operation(new LASoperationTranslateY(offset)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-translate_z") == 0) { @@ -2757,7 +2758,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) } transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationTranslateZ(offset)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-translate_xyz") == 0) { @@ -2788,7 +2789,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) if (offset_y) transformed_fields |= LASTRANSFORM_Y_COORDINATE; if (offset_z) transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationTranslateXYZ(offset_x, offset_y, offset_z)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } else if (strcmp(argv[i],"-translate_then_scale_x") == 0) { @@ -2811,7 +2812,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) } transformed_fields |= LASTRANSFORM_X_COORDINATE; add_operation(new LASoperationTranslateThenScaleX(offset, scale)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-translate_then_scale_y") == 0) { @@ -2834,7 +2835,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) } transformed_fields |= LASTRANSFORM_Y_COORDINATE; add_operation(new LASoperationTranslateThenScaleY(offset, scale)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-translate_then_scale_z") == 0) { @@ -2857,7 +2858,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) } transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationTranslateThenScaleZ(offset, scale)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strncmp(argv[i],"-translate_raw_", 14) == 0) { @@ -2876,7 +2877,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) } transformed_fields |= LASTRANSFORM_X_COORDINATE; add_operation(new LASoperationTranslateRawX(raw_offset)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-translate_raw_y") == 0) { @@ -2893,7 +2894,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) } transformed_fields |= LASTRANSFORM_Y_COORDINATE; add_operation(new LASoperationTranslateRawY(raw_offset)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-translate_raw_z") == 0) { @@ -2910,7 +2911,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) } transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationTranslateRawZ(raw_offset)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-translate_raw_xyz") == 0) { @@ -2941,7 +2942,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) if (raw_offset_y) transformed_fields |= LASTRANSFORM_Y_COORDINATE; if (raw_offset_z) transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationTranslateRawXYZ(raw_offset_x, raw_offset_y, raw_offset_z)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } else if (strcmp(argv[i],"-translate_raw_xy_at_random") == 0) { @@ -2965,7 +2966,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) if (max_raw_offset_x) transformed_fields |= LASTRANSFORM_X_COORDINATE; if (max_raw_offset_y) transformed_fields |= LASTRANSFORM_Y_COORDINATE; add_operation(new LASoperationTranslateRawXYatRandom(max_raw_offset_x, max_raw_offset_y)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } } else if (strcmp(argv[i],"-translate_intensity") == 0) @@ -2982,7 +2983,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationTranslateIntensity(offset)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-translate_then_scale_intensity") == 0) { @@ -3004,7 +3005,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationTranslateThenScaleIntensity(offset, scale)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-translate_scan_angle") == 0) { @@ -3020,7 +3021,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationTranslateScanAngle(offset)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-translate_then_scale_scan_angle") == 0) { @@ -3042,7 +3043,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationTranslateThenScaleScanAngle(offset, scale)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-translate_gps_time") == 0) { @@ -3058,7 +3059,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationTranslateGpsTime(offset)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-translate_attribute") == 0) { @@ -3080,7 +3081,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationTranslateAttribute(index, offset)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-translate_register") == 0) { @@ -3102,7 +3103,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationTranslateRegister(registers, index, offset)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } } else if (strncmp(argv[i],"-rotate_", 8) == 0) @@ -3140,7 +3141,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) transformed_fields |= LASTRANSFORM_X_COORDINATE; transformed_fields |= LASTRANSFORM_Y_COORDINATE; add_operation(new LASoperationRotateXY(angle, rot_center_x, rot_center_y)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } else if (strcmp(argv[i],"-rotate_xz") == 0) { @@ -3175,7 +3176,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) transformed_fields |= LASTRANSFORM_X_COORDINATE; transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationRotateXZ(angle, rot_center_x, rot_center_z)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } else if (strcmp(argv[i],"-rotate_yz") == 0) { @@ -3210,7 +3211,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) transformed_fields |= LASTRANSFORM_Y_COORDINATE; transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationRotateYZ(angle, rot_center_y, rot_center_z)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } } else if (strncmp(argv[i],"-clamp_", 7) == 0) @@ -3236,7 +3237,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) } transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationClampZ(below, above)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-clamp_z_below") == 0) { @@ -3253,7 +3254,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) } transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationClampZbelow(below)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-clamp_z_above") == 0) { @@ -3270,7 +3271,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) } transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationClampZabove(above)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-clamp_intensity") == 0) { @@ -3302,7 +3303,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationClampIntensity((U16)below, (U16)above)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-clamp_intensity_below") == 0) { @@ -3323,7 +3324,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationClampIntensityBelow((U16)below)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-clamp_intensity_above") == 0) { @@ -3344,7 +3345,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationClampIntensityAbove((U16)above)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-clamp_raw_z") == 0) { @@ -3367,7 +3368,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) } transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationClampRawZ(below, above)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } } else if (strncmp(argv[i],"-copy_", 6) == 0) @@ -3389,7 +3390,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) } transformed_fields |= LASTRANSFORM_X_COORDINATE; add_operation(new LASoperationCopyAttributeIntoX(index)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-copy_attribute_into_y") == 0) { @@ -3406,7 +3407,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) } transformed_fields |= LASTRANSFORM_Y_COORDINATE; add_operation(new LASoperationCopyAttributeIntoY(index)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-copy_attribute_into_z") == 0) { @@ -3423,7 +3424,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) } transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationCopyAttributeIntoZ(index)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-copy_attribute_into_user_data") == 0) { @@ -3439,7 +3440,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationCopyAttributeIntoUserData(index)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-copy_attribute_into_intensity") == 0) { @@ -3455,7 +3456,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationCopyAttributeIntoIntensity(index)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-copy_attribute_into_point_source") == 0) { @@ -3471,7 +3472,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationCopyAttributeIntoPointSource(index)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-copy_attribute_into_R") == 0) { @@ -3487,7 +3488,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationCopyAttributeIntoRGBNIR(index, 0)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-copy_attribute_into_G") == 0) { @@ -3503,7 +3504,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationCopyAttributeIntoRGBNIR(index, 1)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-copy_attribute_into_B") == 0) { @@ -3519,7 +3520,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationCopyAttributeIntoRGBNIR(index, 2)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if ((strcmp(argv[i],"-copy_attribute_into_NIR") == 0) || (strcmp(argv[i],"-copy_attribute_into_I") == 0)) { @@ -3535,7 +3536,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationCopyAttributeIntoRGBNIR(index, 3)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-copy_attribute_into_register") == 0) { @@ -3587,7 +3588,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) } transformed_fields |= LASTRANSFORM_X_COORDINATE; add_operation(new LASoperationCopyRegisterIntoX(registers, index)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-copy_register_into_y") == 0) { @@ -3609,7 +3610,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) } transformed_fields |= LASTRANSFORM_Y_COORDINATE; add_operation(new LASoperationCopyRegisterIntoY(registers, index)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-copy_register_into_z") == 0) { @@ -3631,7 +3632,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) } transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationCopyRegisterIntoZ(registers, index)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-copy_register_into_user_data") == 0) { @@ -3652,7 +3653,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationCopyRegisterIntoUserData(registers, index)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-copy_register_into_intensity") == 0) { @@ -3673,7 +3674,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationCopyRegisterIntoIntensity(registers, index)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-copy_register_into_point_source") == 0) { @@ -3694,7 +3695,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationCopyRegisterIntoPointSource(registers, index)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-copy_register_into_R") == 0) { @@ -3715,7 +3716,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationCopyRegisterIntoRGBNIR(registers, index, 0)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-copy_register_into_G") == 0) { @@ -3736,7 +3737,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationCopyRegisterIntoRGBNIR(registers, index, 1)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-copy_register_into_B") == 0) { @@ -3757,7 +3758,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationCopyRegisterIntoRGBNIR(registers, index, 2)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if ((strcmp(argv[i],"-copy_register_into_NIR") == 0) || (strcmp(argv[i],"-copy_register_into_I") == 0)) { @@ -3778,7 +3779,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationCopyRegisterIntoRGBNIR(registers, index, 3)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-copy_register_into_attribute") == 0) { @@ -3813,22 +3814,22 @@ BOOL LAStransform::parse(int argc, char* argv[]) if (strcmp(argv[i],"-copy_user_data_into_point_source") == 0) { add_operation(new LASoperationCopyUserDataIntoPointSource()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-copy_user_data_into_scanner_channel") == 0) { add_operation(new LASoperationCopyUserDataIntoScannerChannel()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-copy_user_data_into_classification") == 0) { add_operation(new LASoperationCopyUserDataIntoClassification()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-copy_user_data_into_z") == 0) { add_operation(new LASoperationCopyUserDataIntoZ()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-copy_user_data_into_attribute") == 0) { @@ -3844,7 +3845,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationCopyUserDataIntoAttribute(index)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-copy_user_data_into_register") == 0) { @@ -3865,7 +3866,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationCopyUserDataIntoRegister(registers, index)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } } else if (strncmp(argv[i],"-copy_point_source_", 19) == 0) @@ -3889,7 +3890,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationCopyPointSourceIntoRegister(registers, index)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } } else if (strncmp(argv[i],"-copy_scanner_channel_", 19) == 0) @@ -3897,12 +3898,12 @@ BOOL LAStransform::parse(int argc, char* argv[]) if (strcmp(argv[i],"-copy_scanner_channel_into_point_source") == 0) { add_operation(new LASoperationCopyScannerChannelIntoPointSource()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-copy_scanner_channel_into_user_data") == 0) { add_operation(new LASoperationCopyScannerChannelIntoUserData()); - *argv[i]='\0'; + *argv[i]='\0'; } } else if (strncmp(argv[i],"-copy_R", 7) == 0) @@ -3926,7 +3927,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationCopyRBGNIRintoRegister(0, registers, index)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-copy_RGB_into_intensity") == 0) { @@ -3936,7 +3937,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) else if (strcmp(argv[i],"-copy_R_into_intensity") == 0) { add_operation(new LASoperationCopyRintoIntensity()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-copy_R_into_NIR") == 0) { @@ -3965,17 +3966,17 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationCopyRBGNIRintoRegister(1, registers, index)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-copy_G_into_intensity") == 0) { add_operation(new LASoperationCopyGintoIntensity()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-copy_G_into_NIR") == 0) { add_operation(new LASoperationCopyGintoNIR()); - *argv[i]='\0'; + *argv[i]='\0'; } } else if (strncmp(argv[i],"-copy_B_", 8) == 0) @@ -3999,17 +4000,17 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationCopyRBGNIRintoRegister(2, registers, index)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-copy_B_into_intensity") == 0) { add_operation(new LASoperationCopyBintoIntensity()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-copy_B_into_NIR") == 0) { add_operation(new LASoperationCopyBintoNIR()); - *argv[i]='\0'; + *argv[i]='\0'; } } else if (strncmp(argv[i],"-copy_NIR_", 10) == 0) @@ -4033,12 +4034,12 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationCopyRBGNIRintoRegister(3, registers, index)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-copy_NIR_into_intensity") == 0) { add_operation(new LASoperationCopyNIRintoIntensity()); - *argv[i]='\0'; + *argv[i]='\0'; } } else if (strncmp(argv[i],"-copy_intensity_", 16) == 0) @@ -4047,17 +4048,17 @@ BOOL LAStransform::parse(int argc, char* argv[]) { transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationCopyIntensityIntoZ()); - *argv[i]='\0'; - } + *argv[i]='\0'; + } else if (strcmp(argv[i],"-copy_intensity_into_NIR") == 0) { add_operation(new LASoperationCopyIntensityIntoNIR()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-copy_intensity_into_classification") == 0) { add_operation(new LASoperationCopyIntensityIntoClassification()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-copy_intensity_into_attribute") == 0) { @@ -4073,7 +4074,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationCopyIntensityIntoAttribute(index)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-copy_intensity_into_register") == 0) { @@ -4094,7 +4095,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationCopyIntensityIntoRegister(registers, index)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } } else if (strncmp(argv[i],"-copy_classification_", 21) == 0) @@ -4102,12 +4103,12 @@ BOOL LAStransform::parse(int argc, char* argv[]) if (strcmp(argv[i],"-copy_classification_into_user_data") == 0) { add_operation(new LASoperationCopyClassificationIntoUserData()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-copy_classification_into_point_source") == 0) { add_operation(new LASoperationCopyClassificationIntoPointSource()); - *argv[i]='\0'; + *argv[i]='\0'; } } else if (strncmp(argv[i],"-copy_z_", 8) == 0) @@ -4126,7 +4127,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationCopyZIntoAttribute(index)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } } } @@ -4151,7 +4152,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationSetClassification((U8)classification)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-set_intensity") == 0) { @@ -4172,7 +4173,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationSetIntensity(U16_CLAMP(value))); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-set_withheld_flag") == 0) { @@ -4193,7 +4194,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationSetWithheldFlag((U8)value)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-set_synthetic_flag") == 0) { @@ -4214,7 +4215,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationSetSyntheticFlag((U8)value)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-set_keypoint_flag") == 0) { @@ -4235,7 +4236,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationSetKeypointFlag((U8)value)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if ((strcmp(argv[i],"-set_extended_overlap_flag") == 0) || (strcmp(argv[i],"-set_overlap_flag") == 0)) { @@ -4256,7 +4257,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationSetExtendedOverlapFlag((U8)value)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if ((strcmp(argv[i],"-set_extended_scanner_channel") == 0) || (strcmp(argv[i],"-set_scanner_channel") == 0)) { @@ -4277,7 +4278,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationSetExtendedScannerChannel((U8)value)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-set_user_data") == 0) { @@ -4298,7 +4299,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationSetUserData((U8)value)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-set_scan_angle") == 0) { @@ -4325,7 +4326,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) } add_operation(new LASoperationSetScanAngle(value)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strncmp(argv[i],"-set_point_source", 17) == 0) { @@ -4346,7 +4347,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationSetPointSource((U16)value)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-set_return_number") == 0) { @@ -4367,7 +4368,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationSetReturnNumber((U8)return_number)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-set_extended_return_number") == 0) { @@ -4388,7 +4389,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationSetExtendedReturnNumber((U8)extended_return_number)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-set_number_of_returns") == 0) { @@ -4409,7 +4410,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationSetNumberOfReturns((U8)number_of_returns)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-set_extended_number_of_returns") == 0) { @@ -4430,7 +4431,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationSetExtendedNumberOfReturns((U8)extended_number_of_returns)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-set_gps_time") == 0) { @@ -4446,7 +4447,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationSetGpsTime(gps_time)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if ((strcmp(argv[i],"-set_attribute") == 0)) { @@ -4535,7 +4536,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationSetRGB((U16)R, (U16)G, (U16)B)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } else if (strcmp(argv[i],"-set_RGB_of_class") == 0) { @@ -4674,7 +4675,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationChangeClassificationFromTo((U8)from_value, (U8)to_value)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-change_user_data_from_to") == 0) { @@ -4706,7 +4707,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationChangeUserDataFromTo(from_value, to_value)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-change_point_source_from_to") == 0) { @@ -4738,7 +4739,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationChangePointSourceFromTo((U16)from_value, (U16)to_value)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-change_return_number_from_to") == 0) { @@ -4770,7 +4771,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationChangeReturnNumberFromTo((U8)from_value, (U8)to_value)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-change_number_of_returns_from_to") == 0) { @@ -4802,7 +4803,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationChangeNumberOfReturnsFromTo((U8)from_value, (U8)to_value)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-change_extended_return_number_from_to") == 0) { @@ -4834,7 +4835,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationChangeExtendedReturnNumberFromTo((U8)from_value, (U8)to_value)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-change_extended_number_of_returns_from_to") == 0) { @@ -4866,7 +4867,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationChangeExtendedNumberOfReturnsFromTo((U8)from_value, (U8)to_value)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } } else if (strncmp(argv[i],"-classify_", 10) == 0) @@ -4898,7 +4899,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationClassifyZbelowAs(z_value, U8_CLAMP(classification))); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-classify_z_above_as") == 0) { @@ -4925,7 +4926,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationClassifyZaboveAs(z_value, U8_CLAMP(classification))); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-classify_z_between_as") == 0) { @@ -4958,7 +4959,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationClassifyZbetweenAs(z_min, z_max, U8_CLAMP(classification))); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } } else if (strncmp(argv[i],"-classify_intensity_", 20) == 0) @@ -4993,7 +4994,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationClassifyIntensityBelowAs(value, classification)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-classify_intensity_above_as") == 0) { @@ -5025,7 +5026,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationClassifyIntensityAboveAs(value, classification)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-classify_intensity_between_as") == 0) { @@ -5068,7 +5069,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationClassifyIntensityBetweenAs(min_value, max_value, classification)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } } else if (strncmp(argv[i],"-classify_attribute_", 12) == 0) @@ -5104,7 +5105,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationClassifyAttributeBelowAs(index, value, U8_CLAMP(classification))); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } else if (strcmp(argv[i],"-classify_attribute_above_as") == 0) { @@ -5137,7 +5138,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationClassifyAttributeAboveAs(index, value, U8_CLAMP(classification))); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } else if (strcmp(argv[i],"-classify_attribute_between_as") == 0) { @@ -5176,7 +5177,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationClassifyAttributeBetweenAs(index, min, max, U8_CLAMP(classification))); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; i+=4; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; *argv[i+4]='\0'; i+=4; } } } @@ -5197,7 +5198,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) } if (scale_x != 1.0) transformed_fields |= LASTRANSFORM_X_COORDINATE; add_operation(new LASoperationScaleX(scale_x)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-scale_y") == 0) { @@ -5214,7 +5215,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) } if (scale_y != 1.0) transformed_fields |= LASTRANSFORM_Y_COORDINATE; add_operation(new LASoperationScaleY(scale_y)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-scale_z") == 0) { @@ -5231,7 +5232,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) } if (scale_z != 1.0) transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationScaleZ(scale_z)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-scale_xyz") == 0) { @@ -5262,7 +5263,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) if (scale_y != 1.0) transformed_fields |= LASTRANSFORM_Y_COORDINATE; if (scale_z != 1.0) transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationScaleXYZ(scale_x, scale_y, scale_z)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } else if (strcmp(argv[i],"-scale_intensity") == 0) { @@ -5278,7 +5279,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationScaleIntensity(scale)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-scale_scan_angle") == 0) { @@ -5294,7 +5295,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationScaleScanAngle(scale)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-scale_user_data") == 0) { @@ -5310,7 +5311,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationScaleUserData(scale)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strncmp(argv[i],"-scale_RGB", 10) == 0 || strncmp(argv[i],"-scale_rgb", 10) == 0) { @@ -5340,7 +5341,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationScaleRGB(scale_R, scale_G, scale_B)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } else if ((strcmp(argv[i],"-scale_RGB_down") == 0) || (strcmp(argv[i],"-scale_rgb_down") == 0)) { @@ -5379,7 +5380,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationScaleNIR(scale_NIR)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if ((strcmp(argv[i],"-scale_NIR_down") == 0) || (strcmp(argv[i],"-scale_nir_down") == 0)) { @@ -5422,7 +5423,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationScaleAttribute(index, scale)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-scale_register") == 0) { @@ -5444,7 +5445,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationScaleRegister(registers, index, scale)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } } else if (strncmp(argv[i],"-switch_", 8) == 0) @@ -5452,42 +5453,42 @@ BOOL LAStransform::parse(int argc, char* argv[]) if (strcmp(argv[i],"-switch_x_y") == 0) { add_operation(new LASoperationSwitchXY()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-switch_x_z") == 0) { add_operation(new LASoperationSwitchXZ()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-switch_y_z") == 0) { add_operation(new LASoperationSwitchYZ()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-switch_R_G") == 0) { add_operation(new LASoperationSwitchRG()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-switch_R_B") == 0) { add_operation(new LASoperationSwitchRB()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-switch_G_B") == 0) { add_operation(new LASoperationSwitchGB()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-switch_RGBI_into_CIR") == 0) { add_operation(new LASoperationSwitchRGBItoCIR()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-switch_RGB_intensity_into_CIR") == 0) { add_operation(new LASoperationSwitchRGBIntensitytoCIR()); - *argv[i]='\0'; + *argv[i]='\0'; } } else if (strncmp(argv[i],"-bin_", 5) == 0) @@ -5511,7 +5512,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationBinZintoPointSource(bin_size)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-bin_abs_scan_angle_into_point_source") == 0) { @@ -5532,7 +5533,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationBinAbsScanAngleIntoPointSource(bin_size)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-bin_gps_time_into_intensity") == 0) { @@ -5553,7 +5554,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationBinGpsTimeIntoIntensity(bin_size)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-bin_gps_time_into_point_source") == 0) { @@ -5574,7 +5575,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationBinGpsTimeIntoPointSource(bin_size)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } } else if (strncmp(argv[i],"-map_", 5) == 0) @@ -5597,7 +5598,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) fclose(file); } add_operation(new LASoperationMapUserData(argv[i+1])); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-map_point_source") == 0) { @@ -5617,7 +5618,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) fclose(file); } add_operation(new LASoperationMapPointSource(argv[i+1])); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-map_intensity") == 0) { @@ -5637,7 +5638,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) fclose(file); } add_operation(new LASoperationMapIntensity(argv[i+1])); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-map_attribute_into_RGB") == 0) { @@ -5663,7 +5664,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) fclose(file); } add_operation(new LASoperationMapAttributeIntoRGB(index, argv[i+2])); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } } else if (strncmp(argv[i],"-load_", 6) == 0) @@ -5692,7 +5693,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) fclose(file); } add_operation(new LASoperationLoadAttributeFromText(index, argv[i+2])); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } } else if (strncmp(argv[i], "-transform_", 11) == 0) @@ -5719,7 +5720,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) REprintf("ERROR: '%s' needs 3 or 7 comma separated parameters as argument\n", argv[i]); return FALSE; } - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i], "-transform_affine") == 0) { @@ -5739,7 +5740,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) REprintf("ERROR: '%s' needs 4 comma separated parameters as argument\n", argv[i]); return FALSE; } - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } } else if (strcmp(argv[i],"-merge_scanner_channel_into_point_source") == 0) @@ -5760,17 +5761,17 @@ BOOL LAStransform::parse(int argc, char* argv[]) else if (strcmp(argv[i],"-flip_waveform_direction") == 0) { add_operation(new LASoperationFlipWaveformDirection()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-repair_zero_returns") == 0) { add_operation(new LASoperationRepairZeroReturns()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-adjusted_to_week") == 0) { add_operation(new LASoperationConvertAdjustedGpsToWeek()); - *argv[i]='\0'; + *argv[i]='\0'; } else if (strcmp(argv[i],"-week_to_adjusted") == 0) { @@ -5786,12 +5787,12 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationConvertWeekToAdjustedGps(week)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } else if (strcmp(argv[i],"-filtered_transform") == 0) { is_filtered = TRUE; - *argv[i]='\0'; + *argv[i]='\0'; } else if (strncmp(argv[i],"-add_", 5) == 0) { @@ -5836,7 +5837,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationAddRegisters(registers, input1, input2, output)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } else if (strncmp(argv[i],"-add_scaled_", 12) == 0) { @@ -5866,7 +5867,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) } transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationAddScaledAttributeToZ(index, scale)); - *argv[i]='\0'; *argv[i+2]='\0'; *argv[i+1]='\0'; i+=2; + *argv[i]='\0'; *argv[i+2]='\0'; *argv[i+1]='\0'; i+=2; } else if (strcmp(argv[i], "-add_scaled_attribute_to_user_data") == 0) { @@ -5888,7 +5889,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationAddScaledAttributeToUserData(index, scale)); - *argv[i]='\0'; *argv[i+2]='\0'; *argv[i+1]='\0'; i+=2; + *argv[i]='\0'; *argv[i+2]='\0'; *argv[i+1]='\0'; i+=2; } } else if (strcmp(argv[i], "-add_attribute_to_z") == 0) @@ -5906,7 +5907,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) } transformed_fields |= LASTRANSFORM_Z_COORDINATE; add_operation(new LASoperationAddAttributeToZ(index)); - *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } } else if (strncmp(argv[i],"-multiply_", 10) == 0) @@ -5952,7 +5953,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationMultiplyRegisters(registers, input1, input2, output)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } else if (strncmp(argv[i]+10, "scaled_intensity_into_RGB", 25) == 0) { @@ -6015,7 +6016,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) REprintf("ERROR: '%s' needs 1 argument: scale but '%g' is no valid divisor\n", argv[i], divisor); return FALSE; } - F32 scale = 1.0f / divisor; + F32 scale = 1.0f / divisor; if (strcmp(argv[i]+37,"red") == 0) { transformed_fields |= LASTRANSFORM_RGB; @@ -6085,7 +6086,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationSubtractRegisters(registers, input1, input2, output)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } } else if (strncmp(argv[i],"-divide_", 8) == 0) @@ -6131,7 +6132,7 @@ BOOL LAStransform::parse(int argc, char* argv[]) return FALSE; } add_operation(new LASoperationDivideRegisters(registers, input1, input2, output)); - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } } } From 9673af5c98ac5bb83b9acddd4e84cd98919ac973 Mon Sep 17 00:00:00 2001 From: Jean-Romain Date: Tue, 2 Mar 2021 15:39:42 -0500 Subject: [PATCH 10/20] asan fix --- src/LASzip/lasinterval.cpp | 2 +- src/LASzip/lasquadtree.cpp | 53 ++++++++++++++++++++------------------ 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/src/LASzip/lasinterval.cpp b/src/LASzip/lasinterval.cpp index d89ed39..4945ecd 100644 --- a/src/LASzip/lasinterval.cpp +++ b/src/LASzip/lasinterval.cpp @@ -549,7 +549,7 @@ LASinterval::~LASinterval() previous_cell = cell; cell = cell->next; } - delete previous_cell; + delete ((LASintervalStartCell*)previous_cell); hash_element++; } delete ((my_cell_hash*)cells); diff --git a/src/LASzip/lasquadtree.cpp b/src/LASzip/lasquadtree.cpp index b768d6c..39408ee 100644 --- a/src/LASzip/lasquadtree.cpp +++ b/src/LASzip/lasquadtree.cpp @@ -2,11 +2,11 @@ =============================================================================== FILE: lasquadtree.cpp - + CONTENTS: - + see corresponding header file - + PROGRAMMERS: martin.isenburg@rapidlasso.com - http://rapidlasso.com @@ -21,11 +21,11 @@ This software is distributed WITHOUT ANY WARRANTY and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - + CHANGE HISTORY: - + see corresponding header file - + =============================================================================== */ #include "lasquadtree.hpp" @@ -108,7 +108,7 @@ void LASquadtree::get_cell_bounding_box(const F64 x, const F64 y, U32 level, F32 volatile float cell_mid_y; float cell_min_x, cell_max_x; float cell_min_y, cell_max_y; - + cell_min_x = min_x; cell_max_x = max_x; cell_min_y = min_y; @@ -161,7 +161,7 @@ void LASquadtree::get_cell_bounding_box(U32 level_index, U32 level, F32* min, F3 volatile F32 cell_mid_y; F32 cell_min_x, cell_max_x; F32 cell_min_y, cell_max_y; - + cell_min_x = min_x; cell_max_x = max_x; cell_min_y = min_y; @@ -210,7 +210,7 @@ void LASquadtree::get_cell_bounding_box(U32 level_index, U32 level, F64* min, F6 volatile F64 cell_mid_y; F64 cell_min_x, cell_max_x; F64 cell_min_y, cell_max_y; - + cell_min_x = min_x; cell_max_x = max_x; cell_min_y = min_y; @@ -279,7 +279,7 @@ U32 LASquadtree::get_level_index(const F64 x, const F64 y, U32 level) const volatile float cell_mid_y; float cell_min_x, cell_max_x; float cell_min_y, cell_max_y; - + cell_min_x = min_x; cell_max_x = max_x; cell_min_y = min_y; @@ -331,7 +331,7 @@ U32 LASquadtree::get_level_index(const F64 x, const F64 y, U32 level, F32* min, volatile float cell_mid_y; float cell_min_x, cell_max_x; float cell_min_y, cell_max_y; - + cell_min_x = min_x; cell_max_x = max_x; cell_min_y = min_y; @@ -577,13 +577,13 @@ U32* LASquadtree::raster_occupancy(BOOL(*does_cell_exist)(I32)) const BOOL LASquadtree::read(ByteStreamIn* stream) { // read data in the following order - // U32 levels 4 bytes + // U32 levels 4 bytes // U32 level_index 4 bytes (default 0) // U32 implicit_levels 4 bytes (only used when level_index != 0)) - // F32 min_x 4 bytes - // F32 max_x 4 bytes - // F32 min_y 4 bytes - // F32 max_y 4 bytes + // F32 min_x 4 bytes + // F32 max_x 4 bytes + // F32 min_y 4 bytes + // F32 max_y 4 bytes // which totals 28 bytes char signature[4]; @@ -671,13 +671,13 @@ BOOL LASquadtree::read(ByteStreamIn* stream) BOOL LASquadtree::write(ByteStreamOut* stream) const { // which totals 28 bytes - // U32 levels 4 bytes + // U32 levels 4 bytes // U32 level_index 4 bytes (default 0) // U32 implicit_levels 4 bytes (only used when level_index != 0)) - // F32 min_x 4 bytes - // F32 max_x 4 bytes - // F32 min_y 4 bytes - // F32 max_y 4 bytes + // F32 min_x 4 bytes + // F32 max_x 4 bytes + // F32 min_y 4 bytes + // F32 max_y 4 bytes // which totals 28 bytes if (!stream->putBytes((const U8*)"LASS", 4)) @@ -746,7 +746,7 @@ BOOL LASquadtree::write(ByteStreamOut* stream) const return TRUE; } -// create or finalize the cell (in the spatial hierarchy) +// create or finalize the cell (in the spatial hierarchy) BOOL LASquadtree::manage_cell(const U32 cell_index, const BOOL finalize) { U32 adaptive_pos = cell_index/32; @@ -869,8 +869,8 @@ U32 LASquadtree::intersect_circle(const F64 center_x, const F64 center_y, const ((my_cell_vector*)current_cells)->clear(); } - F64 r_min_x = center_x - radius; - F64 r_min_y = center_y - radius; + F64 r_min_x = center_x - radius; + F64 r_min_y = center_y - radius; F64 r_max_x = center_x + radius; F64 r_max_y = center_y + radius; @@ -1659,7 +1659,10 @@ LASquadtree::LASquadtree() level_offset[0] = 0; for (l = 0; l < 23; l++) { - level_offset[l+1] = level_offset[l] + ((1< Date: Tue, 2 Mar 2021 15:40:14 -0500 Subject: [PATCH 11/20] #50 --- src/LASzip/bytestreamout_file.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/LASzip/bytestreamout_file.hpp b/src/LASzip/bytestreamout_file.hpp index df45689..26c628b 100644 --- a/src/LASzip/bytestreamout_file.hpp +++ b/src/LASzip/bytestreamout_file.hpp @@ -149,7 +149,7 @@ inline BOOL ByteStreamOutFile::seek(I64 position) #if defined _WIN32 && ! defined (__MINGW32__) return !(_fseeki64(file, position, SEEK_SET)); #elif defined (__MINGW32__) - return !(fseeko64(file, (off_t)position, SEEK_SET)); + return !(fseeko64(file, (off64_t)position, SEEK_SET)); #else return !(fseeko(file, (off_t)position, SEEK_SET)); #endif @@ -160,7 +160,7 @@ inline BOOL ByteStreamOutFile::seekEnd() #if defined _WIN32 && ! defined (__MINGW32__) return !(_fseeki64(file, 0, SEEK_END)); #elif defined (__MINGW32__) - return !(fseeko64(file, (off_t)0, SEEK_END)); + return !(fseeko64(file, (off64_t)0, SEEK_END)); #else return !(fseeko(file, (off_t)0, SEEK_END)); #endif From fd8ff9f1ead2a1f990fa27693dbd96b4ee9232da Mon Sep 17 00:00:00 2001 From: Jean-Romain Date: Tue, 2 Mar 2021 15:44:51 -0500 Subject: [PATCH 12/20] thin_with_voxel --- src/LASlib/lasfilter.cpp | 62 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/src/LASlib/lasfilter.cpp b/src/LASlib/lasfilter.cpp index 9462545..0c691c6 100644 --- a/src/LASlib/lasfilter.cpp +++ b/src/LASlib/lasfilter.cpp @@ -36,6 +36,7 @@ #include #include +#include using namespace std; typedef multimap my_I64_F64_map; @@ -1532,6 +1533,56 @@ class LAScriterionThinWithGrid : public LAScriterion U16* plus_plus_sizes; }; +class LAScriterionThinWithVoxel : public LAScriterion +{ + typedef std::array Array; + +public: + inline const CHAR* name() const { return "thin_with_voxel"; }; + inline I32 get_command(CHAR* string) const { return sprintf(string, "-%s ", name()); }; + inline U32 get_decompress_selective() const { return LASZIP_DECOMPRESS_SELECTIVE_CHANNEL_RETURNS_XY | LASZIP_DECOMPRESS_SELECTIVE_Z; }; + inline BOOL filter(const LASpoint* point) + { + if(voxel_spacing < 0) + { + xoffset = point->get_x(); + yoffset = point->get_y(); + zoffset = point->get_z(); + voxel_spacing = -voxel_spacing; + } + + I32 nx = I32_FLOOR((point->get_x() - xoffset) / voxel_spacing); + I32 ny = I32_FLOOR((point->get_y() - yoffset) / voxel_spacing); + I32 nz = I32_FLOOR((point->get_z() - zoffset) / voxel_spacing); + Array key = {nx, ny, nz}; + + return !dynamic_registry.insert(key).second; + }; + void reset() + { + voxel_spacing = -voxel_spacing; + xoffset = 0; + yoffset = 0; + zoffset = 0; + dynamic_registry.clear(); + }; + LAScriterionThinWithVoxel(F32 voxel_spacing) + { + this->voxel_spacing = voxel_spacing < 0 ? voxel_spacing : -voxel_spacing; + xoffset = 0; + yoffset = 0; + zoffset = 0; + }; + ~LAScriterionThinWithVoxel(){ reset(); }; + +private: + double voxel_spacing; + double xoffset; + double yoffset; + double zoffset; + std::unordered_set > dynamic_registry; +}; + class LAScriterionThinPulsesWithTime : public LAScriterion { public: @@ -1722,6 +1773,7 @@ void LASfilter::usage() const REprintf(" -keep_random_fraction 0.1\n"); REprintf(" -keep_random_fraction 0.1 4711\n"); REprintf(" -thin_with_grid 1.0\n"); + REprintf(" -thin_with_voxel 0.1\n"); REprintf(" -thin_pulses_with_time 0.0001\n"); REprintf(" -thin_points_with_time 0.000001\n"); REprintf("Boolean combination of filters.\n"); @@ -4317,6 +4369,16 @@ BOOL LASfilter::parse(int argc, char* argv[]) add_criterion(new LAScriterionThinWithGrid(step)); *argv[i]='\0'; *argv[i+1]='\0'; i+=1; } + else if (strcmp(argv[i],"-thin_with_voxel") == 0) + { + if ((i+1) >= argc) + { + REprintf("ERROR: '%s' needs 1 argument: voxel_side_length\n", argv[i]); + return FALSE; + } + add_criterion(new LAScriterionThinWithVoxel((F32)atof(argv[i+1]))); + *argv[i]='\0'; *argv[i+1]='\0'; i+=1; + } else if (strcmp(argv[i],"-thin_pulses_with_time") == 0 || strcmp(argv[i],"-thin_with_time") == 0) { if ((i+1) >= argc) From 88ac6317963ea8e904010bf916d7a3b4e46e9e15 Mon Sep 17 00:00:00 2001 From: Jean-Romain Date: Tue, 2 Mar 2021 15:45:04 -0500 Subject: [PATCH 13/20] update --- laslib2R.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/laslib2R.sh b/laslib2R.sh index ec26bba..995a8b8 100755 --- a/laslib2R.sh +++ b/laslib2R.sh @@ -19,8 +19,8 @@ perl -pi -w -e 's/exit\(1\)/throw std::runtime_error\("Internal error"\)/g;' $fi # fopen_compressed.cpp #include and #define STRICT_R_HEADERS # mydefs.hpp #include and #define STRICT_R_HEADERS -# lasreaderpipeon.cpp l96-101 comment lines -# laswriter.cpp l135-199 comment lines +# lasreaderpipeon.cpp l96-101 comment lines because of stdout +# laswriter.cpp l139-204 comment lines because of stdout (I guess) # laswriter.cpp l1130,1135 for gcc 8+ replace strncpy by memcpy # lasattributer.hpp l79-80 for gcc 8+ replace strncpy by memcpy - requires to get the char* length: # int len = 0 ; while(*(description+len) != '\0' && len < 32) len++; @@ -28,17 +28,18 @@ perl -pi -w -e 's/exit\(1\)/throw std::runtime_error\("Internal error"\)/g;' $fi # lasdefinition.hpp l570 cast to void* : memset((void*)&(vlrs[i]), 0, sizeof(LASvlr)); # lasdefinition.hpp l572,697 for gcc 8+ replace strncpy by memcpy in the same way than lasattributer.hpp # laswriter_bin.cpp l173 for gcc 8+ replace strncpy by memcpy -# bytestreamount_file.hpp l134 return (true) -# lastransform.cpp l401 R::runif(0, RAND_MAX); -# lasfilter.cpp l1298 R::runif(0, RAND_MAX); +# bytestreamount_file.hpp l134 return (true) to get rid of stdout +# lastransform.cpp l584 R::runif(0, RAND_MAX); +# lasfilter.cpp l1310 R::runif(0, RAND_MAX); # lasutility.cpp #include -# lasinterval.cpp l545 delete ((LASintervalStartCell*)previous_cell); for gcc-asan fix in lax files +# lasinterval.cpp l552 delete ((LASintervalStartCell*)previous_cell); for gcc-asan fix in lax files # lasquadtree.cpp l1662 for interger overflow # if (l < 16) # level_offset[l+1] = level_offset[l] + ((1< off64_t (see #50) +# bytestreamout_file.hpp l152,163 off_t -> off64_t (see #50) # CRAN is happy now! # In addition: From 4531867f516573f095515d9ba4f66e850d4f2a1e Mon Sep 17 00:00:00 2001 From: Jean-Romain Date: Tue, 2 Mar 2021 18:31:30 -0500 Subject: [PATCH 14/20] stdexcept --- src/LASlib/lasutility.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/LASlib/lasutility.cpp b/src/LASlib/lasutility.cpp index a00876f..f56a6be 100644 --- a/src/LASlib/lasutility.cpp +++ b/src/LASlib/lasutility.cpp @@ -2,11 +2,11 @@ =============================================================================== FILE: lasutility.cpp - + CONTENTS: - + see corresponding header file - + PROGRAMMERS: martin.isenburg@rapidlasso.com - http://rapidlasso.com @@ -21,9 +21,9 @@ This software is distributed WITHOUT ANY WARRANTY and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - + CHANGE HISTORY: - + see corresponding header file =============================================================================== @@ -33,6 +33,7 @@ #include #include #include +#include LASinventory::LASinventory() { @@ -1003,7 +1004,7 @@ BOOL LAShistogram::parse(int argc, char* argv[]) return FALSE; } if (!histo(argv[i+1], step)) return FALSE; - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; i+=2; } else if (strcmp(argv[i],"-histo_avg") == 0) { @@ -1019,7 +1020,7 @@ BOOL LAShistogram::parse(int argc, char* argv[]) return FALSE; } if (!histo_avg(argv[i+1], step, argv[i+3])) return FALSE; - *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; + *argv[i]='\0'; *argv[i+1]='\0'; *argv[i+2]='\0'; *argv[i+3]='\0'; i+=3; } } return TRUE; @@ -1683,7 +1684,7 @@ LASoccupancyGrid::LASoccupancyGrid(F32 grid_spacing) this->grid_spacing = -grid_spacing; minus_ankers = 0; minus_minus_size = 0; - minus_minus = 0; + minus_minus = 0; minus_minus_sizes = 0; minus_plus_size = 0; minus_plus = 0; From 845364923a1ff556000576cfb41014cd3bf461e3 Mon Sep 17 00:00:00 2001 From: Jean-Romain Date: Tue, 2 Mar 2021 18:35:06 -0500 Subject: [PATCH 15/20] unordered_set --- src/LASlib/lasfilter.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/LASlib/lasfilter.cpp b/src/LASlib/lasfilter.cpp index 0c691c6..03eaba7 100644 --- a/src/LASlib/lasfilter.cpp +++ b/src/LASlib/lasfilter.cpp @@ -36,7 +36,9 @@ #include #include +#include #include + using namespace std; typedef multimap my_I64_F64_map; From 54a9a34eb2fac394afdea2732c4b3cc85a82993c Mon Sep 17 00:00:00 2001 From: Jean-Romain Date: Tue, 2 Mar 2021 18:47:49 -0500 Subject: [PATCH 16/20] Replace R.h by Rcpp.h Don't know why --- src/LASlib/fopen_compressed.cpp | 2 +- src/LASzip/mydefs.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/LASlib/fopen_compressed.cpp b/src/LASlib/fopen_compressed.cpp index 274aa7b..4285081 100644 --- a/src/LASlib/fopen_compressed.cpp +++ b/src/LASlib/fopen_compressed.cpp @@ -40,7 +40,7 @@ #endif #define STRICT_R_HEADERS -#include +#include enum PIPES { READ_HANDLE, WRITE_HANDLE }; /* Constants 0 and 1 for READ and WRITE */ diff --git a/src/LASzip/mydefs.hpp b/src/LASzip/mydefs.hpp index 8d6bf68..490b1da 100644 --- a/src/LASzip/mydefs.hpp +++ b/src/LASzip/mydefs.hpp @@ -34,7 +34,7 @@ #define MYDEFS_HPP #define STRICT_R_HEADERS -#include +#include #ifndef _WIN32 #define LASLIB_DLL From 787e650d44b93b99b3bc0aaa704661a41eec1848 Mon Sep 17 00:00:00 2001 From: Jean-Romain Date: Tue, 2 Mar 2021 18:49:47 -0500 Subject: [PATCH 17/20] news --- NEWS.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 1632c99..f1d3d09 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,12 +2,13 @@ - Fix: build failure with GCC 4.x - Fix: gcc-asan signed integer overflow. -- Fix: when reading an non supported extra bytes attribute rlas used to print a warning message. It now throws a real warning. +- Fix: when reading a non supported extra bytes attribute rlas used to print a warning message. It now throws a real warning. - Fix: querying ROI using LAX files in LAS file > 2GB on Windows (see [#50](https://github.com/Jean-Romain/rlas/issues/50)) -- Change: use `tinytest` instead of `testthat` - New: `read.lasheader()` now reads the extended variable length record (EVLR) - New: `write.las()` now writes all GeoKeyDirectoryTag + GeoAsciiParamsTag + GeoDoubleParamsTag - New: `write.las()` can now write WKT OGC CS in EVLR +- Enhance: full update of LASlib (fix [#43](https://github.com/Jean-Romain/rlas/issues/43)) +- Change: use `tinytest` instead of `testthat` ### rlas v1.3.9 (Release date: 2021-01-11) From 667f35e43027aa450286eaf54d24be6a2dbde81c Mon Sep 17 00:00:00 2001 From: Jean-Romain Date: Tue, 2 Mar 2021 21:03:56 -0500 Subject: [PATCH 18/20] get rid of unused variable warning --- src/LASlib/lasreader_asc.cpp | 16 +++++++------- src/LASlib/lasreader_ply.cpp | 42 ++++++++++++++++++------------------ src/LASlib/lasreader_txt.cpp | 10 ++++----- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/LASlib/lasreader_asc.cpp b/src/LASlib/lasreader_asc.cpp index 19403ab..8a24419 100644 --- a/src/LASlib/lasreader_asc.cpp +++ b/src/LASlib/lasreader_asc.cpp @@ -2,11 +2,11 @@ =============================================================================== FILE: lasreader_asc.cpp - + CONTENTS: - + see corresponding header file - + PROGRAMMERS: martin.isenburg@rapidlasso.com - http://rapidlasso.com @@ -21,11 +21,11 @@ This software is distributed WITHOUT ANY WARRANTY and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - + CHANGE HISTORY: - + see corresponding header file - + =============================================================================== */ #include "lasreader_asc.hpp" @@ -316,7 +316,7 @@ BOOL LASreaderASC::open(const CHAR* file_name, BOOL comma_not_point) header.max_z = 0; } - // add the VLR for Raster LAZ + // add the VLR for Raster LAZ LASvlrRasterLAZ vlrRasterLAZ; vlrRasterLAZ.nbands = 1; @@ -515,7 +515,7 @@ BOOL LASreaderASC::reopen(const CHAR* file_name) I32 i; for (i = 0; i < header_lines; i++) { - fgets(line, line_size, file); + if (fgets(line, line_size, file)); } // special handling for European numbers diff --git a/src/LASlib/lasreader_ply.cpp b/src/LASlib/lasreader_ply.cpp index 03d04da..252eee5 100644 --- a/src/LASlib/lasreader_ply.cpp +++ b/src/LASlib/lasreader_ply.cpp @@ -2,11 +2,11 @@ =============================================================================== FILE: lasreader_ply.cpp - + CONTENTS: - + see corresponding header file - + PROGRAMMERS: martin.isenburg@rapidlasso.com - http://rapidlasso.com @@ -21,11 +21,11 @@ This software is distributed WITHOUT ANY WARRANTY and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - + CHANGE HISTORY: - + see corresponding header file - + =============================================================================== */ #include "lasreader_ply.hpp" @@ -137,7 +137,7 @@ BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL p if (point_type) { - switch (point_type) + switch (point_type) { case 1: header.point_data_record_length = 28; @@ -232,7 +232,7 @@ BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL p for (i = 0; i < number_attributes; i++) { I32 type = (attributes_data_types[i]-1)%10; - try { + try { LASattribute attribute(type, attribute_names[i], attribute_descriptions[i]); if (attribute_scales[i] != 1.0 || attribute_offsets[i] != 0.0) { @@ -270,7 +270,7 @@ BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL p if (streamin) // binary { - // read the first point + // read the first point read_binary_point(); } else @@ -330,7 +330,7 @@ BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL p } } - // read the remaining points + // read the remaining points for (i = 1; i < npoints; i++) { @@ -402,9 +402,9 @@ BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL p } // close the input file - + fclose(file); - + // populate scale and offset populate_scale_and_offset(); @@ -445,7 +445,7 @@ BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL p if (streamin) // binary { - // read the first point + // read the first point read_binary_point(); } else @@ -480,7 +480,7 @@ BOOL LASreaderPLY::open(FILE* file, const CHAR* file_name, U8 point_type, BOOL p return FALSE; } } - + if (!populated_header) { // init the bounding box that we will incrementally compute @@ -676,7 +676,7 @@ BOOL LASreaderPLY::read_point_default() } } } - + // compute the quantized x, y, and z values point.set_X((I32)header.get_X(point.coordinates[0])); point.set_Y((I32)header.get_Y(point.coordinates[1])); @@ -1488,10 +1488,10 @@ BOOL LASreaderPLY::parse(const char* parse_string) if (l[0] == 0) return FALSE; hex_string[0] = l[0]; hex_string[1] = l[1]; sscanf(hex_string,"%x",&hex_value); - point.rgb[0] = hex_value; + point.rgb[0] = hex_value; hex_string[0] = l[2]; hex_string[1] = l[3]; sscanf(hex_string,"%x",&hex_value); - point.rgb[1] = hex_value; + point.rgb[1] = hex_value; hex_string[0] = l[4]; hex_string[1] = l[5]; sscanf(hex_string,"%x",&hex_value); point.rgb[2] = hex_value; @@ -1526,7 +1526,7 @@ BOOL LASreaderPLY::parse_header(BOOL quiet) // first header line containing "ply" - fgets(line, 512, file); + if (fgets(line, 512, file)); if (strncmp(line, "ply", 3) != 0) { return FALSE; @@ -1545,8 +1545,8 @@ BOOL LASreaderPLY::parse_header(BOOL quiet) while (true) { // next line - fgets(line, 512, file); - + if (fgets(line, 512, file)); + if (strncmp(line, "end_header", 10) == 0) { break; @@ -1816,7 +1816,7 @@ BOOL LASreaderPLY::parse_header(BOOL quiet) items++; } else - { + { REprintf( "unknown property type: %snot implemented. contact martin@rapidlasso.com\n", &line[9]); return FALSE; } diff --git a/src/LASlib/lasreader_txt.cpp b/src/LASlib/lasreader_txt.cpp index 15b2164..15bfe64 100644 --- a/src/LASlib/lasreader_txt.cpp +++ b/src/LASlib/lasreader_txt.cpp @@ -276,7 +276,7 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const // skip lines if we have to - for (i = 0; i < skip_lines; i++) fgets(line, 512, file); + for (i = 0; i < skip_lines; i++) if (fgets(line, 512, file)); if (ipts) { @@ -590,7 +590,7 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const header.extended_number_of_points_by_return[3] = 0; header.extended_number_of_points_by_return[4] = 0; } - + // free the parse less string free(parse_less); @@ -640,7 +640,7 @@ BOOL LASreaderTXT::open(FILE* file, const CHAR* file_name, U8 point_type, const this->skip_lines = skip_lines; if (skip_lines) { - for (i = 0; i < skip_lines; i++) fgets(line, 512, file); + for (i = 0; i < skip_lines; i++) if (fgets(line, 512, file)); } else if (ipts) { @@ -1095,7 +1095,7 @@ BOOL LASreaderTXT::seek(const I64 p_index) fseek(file, 0, SEEK_SET); // skip lines if we have to int i; - for (i = 0; i < skip_lines; i++) fgets(line, 512, file); + for (i = 0; i < skip_lines; i++) if (fgets(line, 512, file)); // read the first line with full parse_string i = 0; while (fgets(line, 512, file)) @@ -1264,7 +1264,7 @@ BOOL LASreaderTXT::reopen(const char* file_name) // skip lines if we have to - for (i = 0; i < skip_lines; i++) fgets(line, 512, file); + for (i = 0; i < skip_lines; i++) if (fgets(line, 512, file)); // read the first line with full parse_string From 2417e777a995dc8bf297d5fd4b355e262a4ebb93 Mon Sep 17 00:00:00 2001 From: Jean-Romain Date: Wed, 3 Mar 2021 09:08:46 -0500 Subject: [PATCH 19/20] allow -inside 0 0 0 0 --- laslib2R.sh | 1 + src/LASlib/lasreader.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/laslib2R.sh b/laslib2R.sh index 995a8b8..aa59d4e 100755 --- a/laslib2R.sh +++ b/laslib2R.sh @@ -40,6 +40,7 @@ perl -pi -w -e 's/exit\(1\)/throw std::runtime_error\("Internal error"\)/g;' $fi # level_offset[l+1] = level_offset[l]; # bytestreamin_file.hpp l153,166 off_t -> off64_t (see #50) # bytestreamout_file.hpp l152,163 off_t -> off64_t (see #50) +# lasreader.cpp l1875,1880 add (min_y != 0 || max_y != 0) to allow -inside 0 0 0 0 in lidR # CRAN is happy now! # In addition: diff --git a/src/LASlib/lasreader.cpp b/src/LASlib/lasreader.cpp index fb9a19d..16051c5 100644 --- a/src/LASlib/lasreader.cpp +++ b/src/LASlib/lasreader.cpp @@ -1872,12 +1872,12 @@ BOOL LASreadOpener::parse(int argc, char* argv[], BOOL parse_ignore) REprintf( "ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y, but '%s' is not a valid max_y.\n", argv[i], argv[i+4]); return FALSE; } - if (min_x >= max_x) + if ((min_x != 0 || max_x != 0) && min_x >= max_x) { REprintf( "ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y, but %lf / %lf are not a valid min_x / max_x pair.\n", argv[i], min_x, max_x); return FALSE; } - if (min_y >= max_y) + if ((min_y != 0 || max_y != 0) && min_y >= max_y) { REprintf( "ERROR: '%s' needs 4 arguments: min_x min_y max_x max_y, but %lf / %lf are not a valid min_y / max_y pair.\n", argv[i], min_y, max_y); return FALSE; From 61575e2b5903e7b0a8895bae543c178a5e90d751 Mon Sep 17 00:00:00 2001 From: Jean-Romain Date: Sun, 7 Mar 2021 08:26:04 -0500 Subject: [PATCH 20/20] R 3.4.0 because C++14 --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 15a5793..96b5109 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -14,7 +14,7 @@ Description: Read and write 'las' and 'laz' binary file formats. The LAS file fo URL: https://github.com/Jean-Romain/rlas BugReports: https://github.com/Jean-Romain/rlas/issues License: GPL-3 -Depends: R (>= 3.0.0) +Depends: R (>= 3.4.0) Imports: Rcpp, data.table LazyData: true RoxygenNote: 7.1.1