[Git][debian-gis-team/laszip][upstream] New upstream version 3.2.8

Bas Couwenberg gitlab at salsa.debian.org
Tue Nov 20 14:52:34 GMT 2018


Bas Couwenberg pushed to branch upstream at Debian GIS Project / laszip


Commits:
3c23172d by Bas Couwenberg at 2018-11-20T14:49:39Z
New upstream version 3.2.8
- - - - -


30 changed files:

- .travis.yml
- CHANGES.txt
- CMakeLists.txt
- NEWS
- docs/source/conf.py
- docs/source/index.rst
- example/laszipdllexample.cpp
- include/laszip/laszip_api.h
- + scripts/ci/add_deploy_key.sh
- scripts/ci/build_docs.sh
- scripts/ci/deploy_website.sh
- scripts/ci/docker.sh
- + scripts/ci/pdaldocs-private.key.enc
- src/bytestreamin_istream.hpp
- src/lasattributer.hpp
- src/lasindex.cpp
- src/lasindex.hpp
- src/lasinterval.cpp
- src/lasinterval.hpp
- src/laspoint.hpp
- src/lasreaditemcompressed_v3.cpp
- src/lasreaditemcompressed_v4.cpp
- src/lasreaditemraw.hpp
- src/laswriteitemcompressed_v3.cpp
- src/laswriteitemcompressed_v4.cpp
- src/laswriteitemraw.hpp
- src/laszip.hpp
- src/laszip_decompress_selective_v3.hpp
- src/laszip_dll.cpp
- src/mydefs.hpp


Changes:

=====================================
.travis.yml
=====================================
@@ -19,7 +19,7 @@ compiler:
 
 after_success:
   - echo "secure travis:" "$TRAVIS_SECURE_ENV_VARS"
-  - sh -c 'if test "$TRAVIS_SECURE_ENV_VARS" = "true" -a "$TRAVIS_BRANCH" = "master" -a "$CXX" = "g++"; then echo "publish website"; ./scripts/ci/build_docs.sh; ./scripts/ci/deploy_website.sh $TRAVIS_BUILD_DIR/doc/build; fi'
+  - sh -c 'if test "$TRAVIS_SECURE_ENV_VARS" = "true" -a "$TRAVIS_BRANCH" = "master" -a "$CXX" = "g++"; then echo "publish website"; ./scripts/ci/build_docs.sh; ./scripts/ci/add_deploy_key.sh; ./scripts/ci/deploy_website.sh $TRAVIS_BUILD_DIR/docs/build /tmp; fi'
 
 before_install: ./scripts/ci/docker.sh
 


=====================================
CHANGES.txt
=====================================
@@ -1,3 +1,18 @@
+7 November 2018 -- laszip DLL: upped to 3.2 r8 for identical legacy and extended flags check
+20 October 2018 -- fixed rare bug in LASinterval::merge_intervals()
+5 October 2018 -- laszip DLL: upped to 3.2 r6 for corrected 'is_empty' return value in laszip_inside_rectangle()
+28 September 2018 -- laszip DLL: tiny bug fix for writing extended classifications via DLL and updated examples
+17 September 2018 -- laszip DLL: no more support for deprecated LASattributes (aka "extra bytes") with dimensions 2 or 3 
+30 July 2018 -- bug fix in selective decompression of "extra_bytes" for point types 6 and higher
+29 March 2018 -- add LASlib only fields to some structs to avoid future mix-up for "native" LAS 1.4
+9 February 2018 -- minor version increment to 3.2 as POINT14_v4 fixes context inefficiency bug
+28 December 2017 -- prepare to correct 'context switch' bug reported by Wanwannodao on some future date
+15 September 2017 -- new C++ istream / ostream interface completed and released
+22 August 2017 -- new C++ istream / ostream interface 
+18 July 2017 -- bug fix for spatially-indexed reading from native compressed LAS 1.4 files
+28 May 2017 -- support for "selective decompression" of compressed LAS 1.4 points added into DLL API
+25 April 2017 -- enable "native LAS 1.4 extension" in LASzip DLL via 'request_native_extension'
+30 March 2017 -- alpha-release of "native LAS 1.4 extension" for LASzip compression
 11 January 2017 --  new DLL/API function 'laszip_set_chunk_size()' to change chunk size
 8 January 2017 -- changed file names from "laszip_dll.h" to "laszip_api.h" for hobu
 7 January 2017 -- set reserved field in LASzip VLR from 0xAABB to 0x0


=====================================
CMakeLists.txt
=====================================
@@ -7,7 +7,7 @@ set(ROOT_DIR "${PROJECT_SOURCE_DIR}")
 
 # the next line is the ONLY place in the entire laszip system where
 # the version info is hard-coded
-set(LASZIP_API_VERSION_STRING "3.2.2" CACHE STRING "LASzip version" FORCE)
+set(LASZIP_API_VERSION_STRING "3.2.8" CACHE STRING "LASzip version" FORCE)
 
 include (CheckIncludeFileCXX)
 include(${ROOT_DIR}/cmake/common.cmake NO_POLICY_SCOPE)
@@ -41,7 +41,7 @@ set(LASZIP_API_VERSION ${LASZIP_API_VERSION_MAJOR}.${LASZIP_API_VERSION_MINOR}.$
 # libtool SO version naming
 # 8.0.0 for 3.2.1
 # 9.0.0 for 4.0+
-set(LASZIP_SO_VERSION "8.0.0")
+set(LASZIP_SO_VERSION "8.0.1")
 set(LASZIP_COMPATIBILITY_VERSION 8)
 
 check_include_file_cxx ("unordered_map" HAVE_UNORDERED_MAP)


=====================================
NEWS
=====================================
@@ -2,6 +2,20 @@
 LASzip
 ================================================================================
 
+3.2.8 19-NOV-18
+--------------------------------------------------------------------------------
+
+** NOTE: The version number is 3.2.8 to be brought in line with the patch version
+number present in LAStools, which had been incremented without being kept in sync
+with the laszip.org version. We regret the error. The following bug fixes have been
+made since 3.2.2:
+
+*    7 November 2018 -- upped to 3.2 r8 for identical legacy and extended flags check
+*   20 October 2018 -- upped to 3.2 r7 for rare bug in LASinterval::merge_intervals()
+*    5 October 2018 -- upped to 3.2 r6 for corrected 'is_empty' return value
+*   28 September 2018 -- upped to 3.2 r5 for fix in extended classification writing
+
+
 3.2.2 27-MAR-18
 --------------------------------------------------------------------------------
 


=====================================
docs/source/conf.py
=====================================
@@ -48,9 +48,9 @@ copyright = u'2018, Martin Isenburg'
 # built documents.
 #
 # The short X.Y version.
-version = '3.2.2'
+version = '3.2.3'
 # The full version, including alpha/beta/rc tags.
-release = '3.2.2'
+release = '3.2.3'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.


=====================================
docs/source/index.rst
=====================================
@@ -9,15 +9,20 @@ LASzip - a free open source product of `rapidlasso GmbH <http://rapidlasso.com/>
 Source
 ..............................................................................
 
-* **2018-03-26**
+* **2018-11-19**
 
-  - `laszip-3.2.1.tar.gz <https://github.com/LASzip/LASzip/releases/download/3.2.1/laszip-src-3.2.1.tar.gz>`_
-    `(md5) <https://github.com/LASzip/LASzip/releases/download/3.2.1/laszip-src-3.2.1.tar.gz.md5>`__
+  - `laszip-3.2.8.tar.gz <https://github.com/LASzip/LASzip/releases/download/3.2.8/laszip-src-3.2.8.tar.gz>`_
+    `(md5) <https://github.com/LASzip/LASzip/releases/download/3.2.8/laszip-src-3.2.8.tar.gz.md5>`__
 
 
 Past Release(s)
 ~~~~~~~~~~~~~~~~~~~~~~~~~
 
+* **2018-03-27**
+
+  - `laszip-3.2.2.tar.gz <https://github.com/LASzip/LASzip/releases/download/3.2.2/laszip-src-3.2.2.tar.gz>`_
+    `(md5) <https://github.com/LASzip/LASzip/releases/download/3.2.2/laszip-src-3.2.2.tar.gz.md5>`__
+
 * **2017-10-10**
 
   - `laszip-3.1.1.tar.gz <https://github.com/LASzip/LASzip/releases/download/3.1.1/laszip-src-3.1.1.tar.gz>`_


=====================================
example/laszipdllexample.cpp
=====================================
@@ -2,9 +2,9 @@
 ===============================================================================
 
   FILE:  laszipdllexample.cpp
-  
+
   CONTENTS:
-  
+
     This source code implements several different  easy-to-follow examples on
     how to use the LASzip DLL. The first and the second examples implement a
     small compression and decompression utilitity. The third example shows
@@ -24,9 +24,12 @@
 
     This software is distributed WITHOUT ANY WARRANTY and without even the
     implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-  
+
   CHANGE HISTORY:
-  
+
+     7 September 2018 -- introduced the LASCopyString macro to replace _strdup
+    28 May 2017 -- 14th example reads compressed LAS 1.4 with "selective decompression"
+    25 April 2017 -- 13th example writes LAS 1.4 using new "native LAS 1.4 extension"
     11 January 2017 -- 12th example changes the default chunk size from 50000 to 5000
      8 January 2017 -- changed from "laszip_dll.h" to "laszip_api.h" because of hobu
     23 September 2015 -- 11th example writes without a-priori bounding box or counters
@@ -34,9 +37,9 @@
      5 September 2015 -- eighth and nineth example show pre-existing "extra bytes"
     19 July 2015 -- sixth and seventh example show LAS 1.4 compatibility mode
      2 April 2015 -- fourth and fifth example with integrated spatially indexing
-    11 August 2013 -- added third example for exporting geo-referenced points 
-    29 July 2013 -- created for the LASzip DLL after returning to Sommerhausen 
-  
+    11 August 2013 -- added third example for exporting geo-referenced points
+    29 July 2013 -- created for the LASzip DLL after returning to Sommerhausen
+
 ===============================================================================
 */
 
@@ -47,6 +50,13 @@
 
 #include <laszip/laszip_api.h>
 
+#if defined(_MSC_VER) && \
+    (_MSC_FULL_VER >= 150000000)
+#define LASCopyString _strdup
+#else
+#define LASCopyString strdup
+#endif
+
 void usage(bool wait=false)
 {
   fprintf(stderr,"usage:\n");
@@ -80,7 +90,7 @@ static void dll_error(laszip_POINTER laszip)
 static void byebye(bool error=false, bool wait=false, laszip_POINTER laszip=0)
 {
   if (error)
-  {  
+  {
     dll_error(laszip);
   }
   if (wait)
@@ -108,8 +118,12 @@ static double taketime()
 #define EXAMPLE_TEN 10
 #define EXAMPLE_ELEVEN 11
 #define EXAMPLE_TWELVE 12
+#define EXAMPLE_THIRTEEN 13
+#define EXAMPLE_FOURTEEN 14
+#define EXAMPLE_FIFTEEN 15
+#define EXAMPLE_SIXTEEN 16
 
-#define EXAMPLE EXAMPLE_EIGHT
+#define EXAMPLE EXAMPLE_SIXTEEN
 
 int main(int argc, char *argv[])
 {
@@ -147,15 +161,15 @@ int main(int argc, char *argv[])
     fprintf(stderr,"%s is better run in the command line\n", argv[0]);
     fprintf(stderr,"enter input file%s: ", ((EXAMPLE == EXAMPLE_THREE) ? " (not used)" : "")); fgets(file_name, 256, stdin);
     file_name[strlen(file_name)-1] = '\0';
-    file_name_in = strdup(file_name);
+    file_name_in = LASCopyString(file_name);
     fprintf(stderr,"enter output file: "); fgets(file_name, 256, stdin);
     file_name[strlen(file_name)-1] = '\0';
-    file_name_out = strdup(file_name);
+    file_name_out = LASCopyString(file_name);
   }
   else if (argc == 3)
   {
-    file_name_in = strdup(argv[1]);
-    file_name_out = strdup(argv[2]);
+    file_name_in = LASCopyString(argv[1]);
+    file_name_out = LASCopyString(argv[2]);
   }
   else
   {
@@ -189,7 +203,7 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: opening laszip reader for '%s'\n", file_name_in);
       byebye(true, argc==1, laszip_reader);
     }
-  
+
     fprintf(stderr,"file '%s' is %scompressed\n", file_name_in, (is_compressed ? "" : "un"));
 
     // get a pointer to the header of the reader that was just populated
@@ -229,7 +243,7 @@ int main(int argc, char *argv[])
       byebye(true, argc==1);
     }
 
-    // initialize the header for the writer using the header of the reader 
+    // initialize the header for the writer using the header of the reader
 
     if (laszip_set_header(laszip_writer, header))
     {
@@ -246,7 +260,7 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
       byebye(true, argc==1, laszip_writer);
     }
-  
+
     fprintf(stderr,"writing file '%s' %scompressed\n", file_name_out, (compress ? "" : "un"));
 
     // read the points
@@ -319,7 +333,7 @@ int main(int argc, char *argv[])
     fprintf(stderr,"total time: %g sec for reading %scompressed and writing %scompressed\n", taketime()-start_time, (is_compressed ? "" : "un"), (compress ? "" : "un"));
 
   } // end of EXAMPLE_ONE
-  
+
   if (EXAMPLE == EXAMPLE_TWO)
   {
     fprintf(stderr,"running EXAMPLE_TWO (another way of reading *without* and writing *without* compatibility mode)\n");
@@ -341,7 +355,7 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: opening laszip reader for '%s'\n", file_name_in);
       byebye(true, argc==1, laszip_reader);
     }
-  
+
     fprintf(stderr,"file '%s' is %scompressed\n", file_name_in, (is_compressed ? "" : "un"));
 
     // get a pointer to the header of the reader that was just populated
@@ -396,7 +410,7 @@ int main(int argc, char *argv[])
     header_write->file_creation_day = header_read->file_creation_day;
     header_write->file_creation_year = header_read->file_creation_year;
     header_write->header_size = header_read->header_size;
-    header_write->offset_to_point_data = header_read->header_size; /* note !!! */ 
+    header_write->offset_to_point_data = header_read->header_size; /* note !!! */
     header_write->number_of_variable_length_records = header_read->number_of_variable_length_records;
     header_write->point_data_format = header_read->point_data_format;
     header_write->point_data_record_length = header_read->point_data_record_length;
@@ -471,7 +485,7 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
       byebye(true, argc==1, laszip_writer);
     }
-  
+
     fprintf(stderr,"writing file '%s' %scompressed\n", file_name_out, (compress ? "" : "un"));
 
     // get a pointer to the point of the reader will be read
@@ -531,7 +545,6 @@ int main(int argc, char *argv[])
       memcpy(point_write->wave_packet, point_read->wave_packet, 29);
 
       // LAS 1.4 only
-      point_write->extended_point_type = point_read->extended_point_type;
       point_write->extended_scanner_channel = point_read->extended_scanner_channel;
       point_write->extended_classification_flags = point_read->extended_classification_flags;
       point_write->extended_classification = point_read->extended_classification;
@@ -588,7 +601,7 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: destroying laszip reader\n");
       byebye(true, argc==1);
     }
-  
+
     fprintf(stderr,"total time: %g sec for reading %scompressed and writing %scompressed\n", taketime()-start_time, (is_compressed ? "" : "un"), (compress ? "" : "un"));
 
   } // end of EXAMPLE_TWO
@@ -698,7 +711,7 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: adding funny VLR to the header\n");
       byebye(true, argc==1, laszip_writer);
     }
-    
+
     fprintf(stderr,"offset_to_point_data after adding two VLRs         : %d\n", (laszip_I32)header->offset_to_point_data);
 
     // open the writer
@@ -710,7 +723,7 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
       byebye(true, argc==1, laszip_writer);
     }
-  
+
     fprintf(stderr,"writing file '%s' %scompressed\n", file_name_out, (compress ? "" : "un"));
 
     // get a pointer to the point of the writer that we will populate and write
@@ -783,10 +796,10 @@ int main(int argc, char *argv[])
       byebye(true, argc==1, laszip_writer);
     }
     p_count++;
-    
+
     // populate the third point
 
-    coordinates[0] = 630499.54;  
+    coordinates[0] = 630499.54;
     coordinates[1] = 4834749.66;
     coordinates[2] = 62.66;
 
@@ -814,7 +827,7 @@ int main(int argc, char *argv[])
 
     // populate the fourth point
 
-    coordinates[0] = 630498.56;     
+    coordinates[0] = 630498.56;
     coordinates[1] = 4834749.41;
     coordinates[2] = 63.68;
 
@@ -842,7 +855,7 @@ int main(int argc, char *argv[])
 
     // populate the fifth point
 
-    coordinates[0] = 630498.80; 
+    coordinates[0] = 630498.80;
     coordinates[1] = 4834748.73;
     coordinates[2] = 62.16;
 
@@ -867,7 +880,7 @@ int main(int argc, char *argv[])
       byebye(true, argc==1, laszip_writer);
     }
     p_count++;
-    
+
     // get the number of points written so far
 
     if (laszip_get_point_count(laszip_writer, &p_count))
@@ -893,7 +906,7 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: destroying laszip writer\n");
       byebye(true, argc==1);
     }
-  
+
     fprintf(stderr,"total time: %g sec for writing %scompressed\n", taketime()-start_time, (compress ? "" : "un"));
 
   } // end of EXAMPLE_THREE
@@ -928,7 +941,7 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: opening laszip reader for '%s'\n", file_name_in);
       byebye(true, argc==1, laszip_reader);
     }
-  
+
     fprintf(stderr,"file '%s' is %scompressed\n", file_name_in, (is_compressed ? "" : "un"));
 
     // check whether spatial indexing information is available
@@ -1005,7 +1018,7 @@ int main(int argc, char *argv[])
       byebye(true, argc==1);
     }
 
-    // initialize the header for the writer using the header of the reader 
+    // initialize the header for the writer using the header of the reader
 
     if (laszip_set_header(laszip_writer, header))
     {
@@ -1022,7 +1035,7 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
       byebye(true, argc==1, laszip_writer);
     }
-  
+
     fprintf(stderr,"writing file '%s' %scompressed\n", file_name_out, (compress ? "" : "un"));
 
     // read the points
@@ -1115,7 +1128,7 @@ int main(int argc, char *argv[])
   if (EXAMPLE == EXAMPLE_FIVE)
   {
     fprintf(stderr,"running EXAMPLE_FIVE (reading from one file and writing to another file while simultaneously generating a spatial index)\n");
- 
+
     // create the reader
 
     laszip_POINTER laszip_reader;
@@ -1133,7 +1146,7 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: opening laszip reader for '%s'\n", file_name_in);
       byebye(true, argc==1, laszip_reader);
     }
-  
+
     fprintf(stderr,"file '%s' is %scompressed\n", file_name_in, (is_compressed ? "" : "un"));
 
     // get a pointer to the header of the reader that was just populated
@@ -1173,7 +1186,7 @@ int main(int argc, char *argv[])
       byebye(true, argc==1);
     }
 
-    // initialize the header for the writer using the header of the reader 
+    // initialize the header for the writer using the header of the reader
 
     if (laszip_set_header(laszip_writer, header))
     {
@@ -1201,7 +1214,7 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
       byebye(true, argc==1, laszip_writer);
     }
-  
+
     fprintf(stderr,"writing file '%s' spatially indexed and %scompressed\n", file_name_out, (compress ? "" : "un"));
 
     // read the points
@@ -1355,7 +1368,7 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: adding funny VLR to the header\n");
       byebye(true, argc==1, laszip_writer);
     }
-    
+
     fprintf(stderr,"offset_to_point_data after adding VLRs                   : %d\n", (laszip_I32)header->offset_to_point_data);
 
     // open the writer
@@ -1369,7 +1382,7 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
       byebye(true, argc==1, laszip_writer);
     }
-  
+
     fprintf(stderr,"writing file '%s' %scompressed\n", file_name_out, (compress ? "" : "un"));
 
     // get a pointer to the point of the writer that we will populate and write
@@ -1382,10 +1395,6 @@ int main(int argc, char *argv[])
       byebye(true, argc==1, laszip_writer);
     }
 
-    // set points to "extended type"
-
-    point->extended_point_type = 1;
-
     // write five points
 
     laszip_I64 p_count = 0;
@@ -1452,10 +1461,10 @@ int main(int argc, char *argv[])
       byebye(true, argc==1, laszip_writer);
     }
     p_count++;
-    
+
     // populate the third point
 
-    coordinates[0] = 630499.54;  
+    coordinates[0] = 630499.54;
     coordinates[1] = 4834749.66;
     coordinates[2] = 62.66;
 
@@ -1486,7 +1495,7 @@ int main(int argc, char *argv[])
 
     // populate the fourth point
 
-    coordinates[0] = 630498.56;     
+    coordinates[0] = 630498.56;
     coordinates[1] = 4834749.41;
     coordinates[2] = 63.68;
 
@@ -1517,7 +1526,7 @@ int main(int argc, char *argv[])
 
     // populate the fifth point
 
-    coordinates[0] = 630498.80; 
+    coordinates[0] = 630498.80;
     coordinates[1] = 4834748.73;
     coordinates[2] = 62.16;
 
@@ -1545,7 +1554,7 @@ int main(int argc, char *argv[])
       byebye(true, argc==1, laszip_writer);
     }
     p_count++;
-    
+
     // get the number of points written so far
 
     if (laszip_get_point_count(laszip_writer, &p_count))
@@ -1571,12 +1580,12 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: destroying laszip writer\n");
       byebye(true, argc==1);
     }
-  
+
     fprintf(stderr,"total time: %g sec for writing %scompressed\n", taketime()-start_time, (compress ? "" : "un"));
 
   } // end of EXAMPLE_SIX
 
-  if (EXAMPLE == EXAMPLE_SEVEN)
+  if (EXAMPLE == EXAMPLE_SEVEN) // CHECK
   {
     fprintf(stderr,"running EXAMPLE_SEVEN (writing five points of type 6 to LAS 1.4 *with* compatibility to compressed LAZ *and* also uncompressed LAS)\n");
 
@@ -1656,7 +1665,7 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: adding funny VLR to the header\n");
       byebye(true, argc==1, laszip_writer);
     }
-    
+
     fprintf(stderr,"offset_to_point_data after adding VLRs                   : %d\n", (laszip_I32)header->offset_to_point_data);
 
     // enable the compatibility mode
@@ -1677,7 +1686,7 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
       byebye(true, argc==1, laszip_writer);
     }
-  
+
     fprintf(stderr,"writing file '%s' %scompressed\n", file_name_out, (compress ? "" : "un"));
 
     // get a pointer to the point of the writer that we will populate and write
@@ -1690,10 +1699,6 @@ int main(int argc, char *argv[])
       byebye(true, argc==1, laszip_writer);
     }
 
-    // set points to "extended type"
-
-    point->extended_point_type = 1;
-
     // write five points
 
     laszip_I64 p_count = 0;
@@ -1760,10 +1765,10 @@ int main(int argc, char *argv[])
       byebye(true, argc==1, laszip_writer);
     }
     p_count++;
-    
+
     // populate the third point
 
-    coordinates[0] = 630499.54;  
+    coordinates[0] = 630499.54;
     coordinates[1] = 4834749.66;
     coordinates[2] = 62.66;
 
@@ -1794,7 +1799,7 @@ int main(int argc, char *argv[])
 
     // populate the fourth point
 
-    coordinates[0] = 630498.56;     
+    coordinates[0] = 630498.56;
     coordinates[1] = 4834749.41;
     coordinates[2] = 63.68;
 
@@ -1825,7 +1830,7 @@ int main(int argc, char *argv[])
 
     // populate the fifth point
 
-    coordinates[0] = 630498.80; 
+    coordinates[0] = 630498.80;
     coordinates[1] = 4834748.73;
     coordinates[2] = 62.16;
 
@@ -1854,7 +1859,7 @@ int main(int argc, char *argv[])
     }
     p_count++;
 
-    
+
     // get the number of points written so far
 
     if (laszip_get_point_count(laszip_writer, &p_count))
@@ -1880,11 +1885,11 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: destroying laszip writer\n");
       byebye(true, argc==1);
     }
-  
+
     fprintf(stderr,"total time: %g sec for writing %scompressed\n", taketime()-start_time, (compress ? "" : "un"));
 
   } // end of EXAMPLE_SEVEN
-  
+
   if (EXAMPLE == EXAMPLE_EIGHT)
   {
     fprintf(stderr,"running EXAMPLE_EIGHT (always *with* compatibility mode when reading but when writing *only* for compressed output)\n");
@@ -1898,7 +1903,7 @@ int main(int argc, char *argv[])
       byebye(true, argc==1);
     }
 
-    // enable the compatibility mode for the reader
+    // request compatibility mode for the reader
 
     laszip_BOOL request_reader = 1;
     if (laszip_request_compatibility_mode(laszip_reader, request_reader))
@@ -1915,7 +1920,7 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: opening laszip reader for '%s'\n", file_name_in);
       byebye(true, argc==1, laszip_reader);
     }
-  
+
     fprintf(stderr,"file '%s' is %scompressed\n", file_name_in, (is_compressed ? "" : "un"));
 
     // get a pointer to the header of the reader that was just populated
@@ -1971,7 +1976,7 @@ int main(int argc, char *argv[])
       }
     }
 
-    // initialize the header for the writer using the header of the reader 
+    // initialize the header for the writer using the header of the reader
 
     if (laszip_set_header(laszip_writer, header))
     {
@@ -1986,7 +1991,7 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
       byebye(true, argc==1, laszip_writer);
     }
-  
+
     fprintf(stderr,"writing file '%s' %scompressed\n", file_name_out, (compress ? "" : "un"));
 
     // read the points
@@ -2158,7 +2163,7 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: adding funny VLR to the header\n");
       byebye(true, argc==1, laszip_writer);
     }
-    
+
     fprintf(stderr,"offset_to_point_data after adding VLRs                      : %d\n", (laszip_I32)header->offset_to_point_data);
 
     // enable the compatibility mode
@@ -2179,7 +2184,7 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
       byebye(true, argc==1, laszip_writer);
     }
-  
+
     fprintf(stderr,"writing file '%s' %scompressed\n", file_name_out, (compress ? "" : "un"));
 
     // get a pointer to the point of the writer that we will populate and write
@@ -2191,11 +2196,7 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: getting point pointer from laszip writer\n");
       byebye(true, argc==1, laszip_writer);
     }
-
-    // set points to "extended type"
-
-    point->extended_point_type = 1;
-
+    
     // write five points
 
     laszip_I64 p_count = 0;
@@ -2274,10 +2275,10 @@ int main(int argc, char *argv[])
       byebye(true, argc==1, laszip_writer);
     }
     p_count++;
-    
+
     // populate the third point
 
-    coordinates[0] = 630499.54;  
+    coordinates[0] = 630499.54;
     coordinates[1] = 4834749.66;
     coordinates[2] = 62.66;
 
@@ -2314,7 +2315,7 @@ int main(int argc, char *argv[])
 
     // populate the fourth point
 
-    coordinates[0] = 630498.56;     
+    coordinates[0] = 630498.56;
     coordinates[1] = 4834749.41;
     coordinates[2] = 63.68;
 
@@ -2351,7 +2352,7 @@ int main(int argc, char *argv[])
 
     // populate the fifth point
 
-    coordinates[0] = 630498.80; 
+    coordinates[0] = 630498.80;
     coordinates[1] = 4834748.73;
     coordinates[2] = 62.16;
 
@@ -2385,7 +2386,7 @@ int main(int argc, char *argv[])
       byebye(true, argc==1, laszip_writer);
     }
     p_count++;
-    
+
     // get the number of points written so far
 
     if (laszip_get_point_count(laszip_writer, &p_count))
@@ -2411,7 +2412,7 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: destroying laszip writer\n");
       byebye(true, argc==1);
     }
-  
+
     fprintf(stderr,"total time: %g sec for writing %scompressed\n", taketime()-start_time, (compress ? "" : "un"));
 
   } // end of EXAMPLE_NINE
@@ -2446,7 +2447,7 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: opening laszip reader for '%s'\n", file_name_in);
       byebye(true, argc==1, laszip_reader);
     }
-  
+
     fprintf(stderr,"file '%s' is %scompressed\n", file_name_in, (is_compressed ? "" : "un"));
 
     // get a pointer to the header of the reader that was just populated
@@ -2535,7 +2536,7 @@ int main(int argc, char *argv[])
     header_write->file_creation_day = header_read->file_creation_day;
     header_write->file_creation_year = header_read->file_creation_year;
     header_write->header_size = header_read->header_size;
-    header_write->offset_to_point_data = header_read->header_size; /* note !!! */ 
+    header_write->offset_to_point_data = header_read->header_size; /* note !!! */
     header_write->number_of_variable_length_records = header_read->number_of_variable_length_records;
     header_write->point_data_format = header_read->point_data_format;
     header_write->point_data_record_length = header_read->point_data_record_length;
@@ -2663,7 +2664,7 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
       byebye(true, argc==1, laszip_writer);
     }
-  
+
     fprintf(stderr,"writing file '%s' %scompressed\n", file_name_out, (compress ? "" : "un"));
 
     // get a pointer to the point of the writer that we will populate and write
@@ -2704,7 +2705,6 @@ int main(int argc, char *argv[])
       point_write->gps_time = point_read->gps_time;
       memcpy(point_write->rgb, point_read->rgb, 8);
 
-      point_write->extended_point_type = 1;
       point_write->extended_scanner_channel = 0;
       point_write->extended_classification_flags = (point_read->withheld_flag << 2) | (point_read->keypoint_flag << 1) | (point_read->synthetic_flag << 0);;
       point_write->extended_classification = point_read->classification;
@@ -2838,7 +2838,7 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: adding funny VLR to the header\n");
       byebye(true, argc==1, laszip_writer);
     }
-    
+
     fprintf(stderr,"offset_to_point_data after adding VLRs                   : %d\n", (laszip_I32)header->offset_to_point_data);
 
     // compressed output or not?
@@ -2864,7 +2864,7 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
       byebye(true, argc==1, laszip_writer);
     }
-  
+
     fprintf(stderr,"writing file '%s' %scompressed\n", file_name_out, (compress ? "" : "un"));
 
     // get a pointer to the point of the writer that we will populate and write
@@ -2877,10 +2877,6 @@ int main(int argc, char *argv[])
       byebye(true, argc==1, laszip_writer);
     }
 
-    // set points to "extended type"
-
-    point->extended_point_type = 1;
-
     // write five points
 
     laszip_I64 p_count = 0;
@@ -2965,10 +2961,10 @@ int main(int argc, char *argv[])
     }
 
     p_count++;
-    
+
     // populate the third point
 
-    coordinates[0] = 630499.54;  
+    coordinates[0] = 630499.54;
     coordinates[1] = 4834749.66;
     coordinates[2] = 62.66;
 
@@ -3008,7 +3004,7 @@ int main(int argc, char *argv[])
 
     // populate the fourth point
 
-    coordinates[0] = 630498.56;     
+    coordinates[0] = 630498.56;
     coordinates[1] = 4834749.41;
     coordinates[2] = 63.68;
 
@@ -3048,7 +3044,7 @@ int main(int argc, char *argv[])
 
     // populate the fifth point
 
-    coordinates[0] = 630498.80; 
+    coordinates[0] = 630498.80;
     coordinates[1] = 4834748.73;
     coordinates[2] = 62.16;
 
@@ -3085,7 +3081,7 @@ int main(int argc, char *argv[])
     }
 
     p_count++;
-    
+
     // get the number of points written so far
 
     if (laszip_get_point_count(laszip_writer, &p_count))
@@ -3111,7 +3107,7 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: destroying laszip writer\n");
       byebye(true, argc==1);
     }
-  
+
     fprintf(stderr,"total time: %g sec for writing %scompressed\n", taketime()-start_time, (compress ? "" : "un"));
 
   } // end of EXAMPLE_ELEVEN
@@ -3146,7 +3142,7 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: opening laszip reader for '%s'\n", file_name_in);
       byebye(true, argc==1, laszip_reader);
     }
-  
+
     fprintf(stderr,"file '%s' is %scompressed\n", file_name_in, (is_compressed ? "" : "un"));
 
     // get a pointer to the header of the reader that was just populated
@@ -3202,7 +3198,7 @@ int main(int argc, char *argv[])
       }
     }
 
-    // initialize the header for the writer using the header of the reader 
+    // initialize the header for the writer using the header of the reader
 
     if (laszip_set_header(laszip_writer, header))
     {
@@ -3210,7 +3206,7 @@ int main(int argc, char *argv[])
       byebye(true, argc==1, laszip_writer);
     }
 
-    // change the chunk size from the default value to 50000 
+    // change the chunk size from the default value to 50000
 
     if (laszip_set_chunk_size(laszip_writer, 5000))
     {
@@ -3225,7 +3221,7 @@ int main(int argc, char *argv[])
       fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
       byebye(true, argc==1, laszip_writer);
     }
-  
+
     fprintf(stderr,"writing file '%s' %scompressed\n", file_name_out, (compress ? "" : "un"));
 
     // read the points
@@ -3299,6 +3295,904 @@ int main(int argc, char *argv[])
 
   } // end of EXAMPLE_TWELVE
 
+  if (EXAMPLE == EXAMPLE_THIRTEEN)
+  {
+    fprintf(stderr,"running EXAMPLE_THIRTEEN (*with* compatibility mode when reading compressed LAS 1.4 and *with* native extension when writing compressed LAS 1.4)\n");
+
+    // create the reader
+
+    laszip_POINTER laszip_reader;
+    if (laszip_create(&laszip_reader))
+    {
+      fprintf(stderr,"DLL ERROR: creating laszip reader\n");
+      byebye(true, argc==1);
+    }
+
+    // request compatibility mode for the reader
+
+    laszip_BOOL request_compatibility = 1;
+    if (laszip_request_compatibility_mode(laszip_reader, request_compatibility))
+    {
+      fprintf(stderr,"DLL ERROR: requesting LAS 1.4 compatibility mode for the reader\n");
+      byebye(true, argc==1, laszip_reader);
+    }
+
+    // open the reader
+
+    laszip_BOOL is_compressed = 0;
+    if (laszip_open_reader(laszip_reader, file_name_in, &is_compressed))
+    {
+      fprintf(stderr,"DLL ERROR: opening laszip reader for '%s'\n", file_name_in);
+      byebye(true, argc==1, laszip_reader);
+    }
+
+    fprintf(stderr,"file '%s' is %scompressed\n", file_name_in, (is_compressed ? "" : "un"));
+
+    // get a pointer to the header of the reader that was just populated
+
+    laszip_header* header;
+
+    if (laszip_get_header_pointer(laszip_reader, &header))
+    {
+      fprintf(stderr,"DLL ERROR: getting header pointer from laszip reader\n");
+      byebye(true, argc==1, laszip_reader);
+    }
+
+    // how many points does the file have
+
+    laszip_I64 npoints = (header->number_of_point_records ? header->number_of_point_records : header->extended_number_of_point_records);
+
+    // report how many points the file has
+
+    fprintf(stderr,"file '%s' contains %I64d points\n", file_name_in, npoints);
+
+    // get a pointer to the points that will be read
+
+    laszip_point* point;
+
+    if (laszip_get_point_pointer(laszip_reader, &point))
+    {
+      fprintf(stderr,"DLL ERROR: getting point pointer from laszip reader\n");
+      byebye(true, argc==1, laszip_reader);
+    }
+
+    // create the writer
+
+    laszip_POINTER laszip_writer;
+    if (laszip_create(&laszip_writer))
+    {
+      fprintf(stderr,"DLL ERROR: creating laszip writer\n");
+      byebye(true, argc==1);
+    }
+
+    // request native extension for the writer
+
+    laszip_BOOL request_native = 1;
+    if (laszip_request_native_extension(laszip_writer, request_native))
+    {
+      fprintf(stderr,"DLL ERROR: requesting native LAS 1.4 extension for the writer\n");
+      byebye(true, argc==1, laszip_writer);
+    }
+
+    // initialize the header for the writer using the header of the reader
+
+    if (laszip_set_header(laszip_writer, header))
+    {
+      fprintf(stderr,"DLL ERROR: setting header for laszip writer\n");
+      byebye(true, argc==1, laszip_writer);
+    }
+
+    // check if the output is compressed
+
+    laszip_BOOL compress = (strstr(file_name_out, ".laz") != 0);
+
+    // open the writer
+
+    if (laszip_open_writer(laszip_writer, file_name_out, compress))
+    {
+      fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
+      byebye(true, argc==1, laszip_writer);
+    }
+
+    fprintf(stderr,"writing file '%s' %scompressed\n", file_name_out, (compress ? "" : "un"));
+
+    // read the points
+
+    laszip_I64 p_count = 0;
+
+    while (p_count < npoints)
+    {
+      // read a point
+
+      if (laszip_read_point(laszip_reader))
+      {
+        fprintf(stderr,"DLL ERROR: reading point %I64\n", p_count);
+        byebye(true, argc==1, laszip_reader);
+      }
+
+      // copy the point
+
+      if (laszip_set_point(laszip_writer, point))
+      {
+        fprintf(stderr,"DLL ERROR: setting point %I64\n", p_count);
+        byebye(true, argc==1, laszip_writer);
+      }
+
+      // write the point
+
+      if (laszip_write_point(laszip_writer))
+      {
+        fprintf(stderr,"DLL ERROR: writing point %I64\n", p_count);
+        byebye(true, argc==1, laszip_writer);
+      }
+
+      p_count++;
+    }
+
+    fprintf(stderr,"successfully read and written %I64d points\n", p_count);
+
+    // close the writer
+
+    if (laszip_close_writer(laszip_writer))
+    {
+      fprintf(stderr,"DLL ERROR: closing laszip writer\n");
+      byebye(true, argc==1, laszip_writer);
+    }
+
+    // destroy the writer
+
+    if (laszip_destroy(laszip_writer))
+    {
+      fprintf(stderr,"DLL ERROR: destroying laszip writer\n");
+      byebye(true, argc==1);
+    }
+
+    // close the reader
+
+    if (laszip_close_reader(laszip_reader))
+    {
+      fprintf(stderr,"DLL ERROR: closing laszip reader\n");
+      byebye(true, argc==1, laszip_reader);
+    }
+
+    // destroy the reader
+
+    if (laszip_destroy(laszip_reader))
+    {
+      fprintf(stderr,"DLL ERROR: destroying laszip reader\n");
+      byebye(true, argc==1);
+    }
+
+    fprintf(stderr,"total time: %g sec for reading %scompressed and writing %scompressed\n", taketime()-start_time, (is_compressed ? "" : "un"), (compress ? "" : "un"));
+
+  } // end of EXAMPLE_THIRTEEN
+
+  if (EXAMPLE == EXAMPLE_FOURTEEN)
+  {
+    fprintf(stderr,"running EXAMPLE_FOURTEEN (selective decompression of XYZ when reading native compressed LAS 1.4\n");
+
+    // create the reader
+
+    laszip_POINTER laszip_reader;
+    if (laszip_create(&laszip_reader))
+    {
+      fprintf(stderr,"DLL ERROR: creating laszip reader\n");
+      byebye(true, argc==1);
+    }
+
+    // request compatibility mode for the reader
+
+    laszip_BOOL request_compatibility = 1;
+    if (laszip_request_compatibility_mode(laszip_reader, request_compatibility))
+    {
+      fprintf(stderr,"DLL ERROR: requesting LAS 1.4 compatibility mode for the reader\n");
+      byebye(true, argc==1, laszip_reader);
+    }
+
+    // request compatibility mode for the reader
+
+    laszip_U32 decompress_selective = laszip_DECOMPRESS_SELECTIVE_CHANNEL_RETURNS_XY | laszip_DECOMPRESS_SELECTIVE_Z;
+    if (laszip_decompress_selective(laszip_reader, decompress_selective))
+    {
+      fprintf(stderr,"DLL ERROR: decompressing XYZ selectively for the reader\n");
+      byebye(true, argc==1, laszip_reader);
+    }
+
+    // open the reader
+
+    laszip_BOOL is_compressed = 0;
+    if (laszip_open_reader(laszip_reader, file_name_in, &is_compressed))
+    {
+      fprintf(stderr,"DLL ERROR: opening laszip reader for '%s'\n", file_name_in);
+      byebye(true, argc==1, laszip_reader);
+    }
+
+    fprintf(stderr,"file '%s' is %scompressed\n", file_name_in, (is_compressed ? "" : "un"));
+
+    // get a pointer to the header of the reader that was just populated
+
+    laszip_header* header;
+
+    if (laszip_get_header_pointer(laszip_reader, &header))
+    {
+      fprintf(stderr,"DLL ERROR: getting header pointer from laszip reader\n");
+      byebye(true, argc==1, laszip_reader);
+    }
+
+    // how many points does the file have
+
+    laszip_I64 npoints = (header->number_of_point_records ? header->number_of_point_records : header->extended_number_of_point_records);
+
+    // report how many points the file has
+
+    fprintf(stderr,"file '%s' contains %I64d points\n", file_name_in, npoints);
+
+    // get a pointer to the points that will be read
+
+    laszip_point* point;
+
+    if (laszip_get_point_pointer(laszip_reader, &point))
+    {
+      fprintf(stderr,"DLL ERROR: getting point pointer from laszip reader\n");
+      byebye(true, argc==1, laszip_reader);
+    }
+
+    // create the writer
+
+    laszip_POINTER laszip_writer;
+    if (laszip_create(&laszip_writer))
+    {
+      fprintf(stderr,"DLL ERROR: creating laszip writer\n");
+      byebye(true, argc==1);
+    }
+
+    // request native extension for the writer
+
+    laszip_BOOL request_native = 1;
+    if (laszip_request_native_extension(laszip_writer, request_native))
+    {
+      fprintf(stderr,"DLL ERROR: requesting native LAS 1.4 extension for the writer\n");
+      byebye(true, argc==1, laszip_writer);
+    }
+
+    // initialize the header for the writer using the header of the reader
+
+    if (laszip_set_header(laszip_writer, header))
+    {
+      fprintf(stderr,"DLL ERROR: setting header for laszip writer\n");
+      byebye(true, argc==1, laszip_writer);
+    }
+
+    // check if the output is compressed
+
+    laszip_BOOL compress = (strstr(file_name_out, ".laz") != 0);
+
+    // open the writer
+
+    if (laszip_open_writer(laszip_writer, file_name_out, compress))
+    {
+      fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
+      byebye(true, argc==1, laszip_writer);
+    }
+
+    fprintf(stderr,"writing file '%s' %scompressed\n", file_name_out, (compress ? "" : "un"));
+
+    // read the points
+
+    laszip_I64 p_count = 0;
+
+    while (p_count < npoints)
+    {
+      // read a point
+
+      if (laszip_read_point(laszip_reader))
+      {
+        fprintf(stderr,"DLL ERROR: reading point %I64\n", p_count);
+        byebye(true, argc==1, laszip_reader);
+      }
+
+      // copy the point
+
+      if (laszip_set_point(laszip_writer, point))
+      {
+        fprintf(stderr,"DLL ERROR: setting point %I64\n", p_count);
+        byebye(true, argc==1, laszip_writer);
+      }
+
+      // write the point
+
+      if (laszip_write_point(laszip_writer))
+      {
+        fprintf(stderr,"DLL ERROR: writing point %I64\n", p_count);
+        byebye(true, argc==1, laszip_writer);
+      }
+
+      p_count++;
+    }
+
+    fprintf(stderr,"successfully read and written %I64d points\n", p_count);
+
+    // close the writer
+
+    if (laszip_close_writer(laszip_writer))
+    {
+      fprintf(stderr,"DLL ERROR: closing laszip writer\n");
+      byebye(true, argc==1, laszip_writer);
+    }
+
+    // destroy the writer
+
+    if (laszip_destroy(laszip_writer))
+    {
+      fprintf(stderr,"DLL ERROR: destroying laszip writer\n");
+      byebye(true, argc==1);
+    }
+
+    // close the reader
+
+    if (laszip_close_reader(laszip_reader))
+    {
+      fprintf(stderr,"DLL ERROR: closing laszip reader\n");
+      byebye(true, argc==1, laszip_reader);
+    }
+
+    // destroy the reader
+
+    if (laszip_destroy(laszip_reader))
+    {
+      fprintf(stderr,"DLL ERROR: destroying laszip reader\n");
+      byebye(true, argc==1);
+    }
+
+    fprintf(stderr,"total time: %g sec for reading %scompressed and writing %scompressed\n", taketime()-start_time, (is_compressed ? "" : "un"), (compress ? "" : "un"));
+
+  } // end of EXAMPLE_FOURTEEN
+
+  if (EXAMPLE == EXAMPLE_FIFTEEN)
+  {
+    fprintf(stderr,"running EXAMPLE_FIFETEEN (reading and writing native compressed LAS 1.4 by copying the points)\n");
+
+    // create the reader
+
+    laszip_POINTER laszip_reader;
+    if (laszip_create(&laszip_reader))
+    {
+      fprintf(stderr,"DLL ERROR: creating laszip reader\n");
+      byebye(true, argc==1);
+    }
+
+    // request compatibility mode for the reader
+
+    laszip_BOOL request_compatibility = 1;
+    if (laszip_request_compatibility_mode(laszip_reader, request_compatibility))
+    {
+      fprintf(stderr,"DLL ERROR: requesting LAS 1.4 compatibility mode for the reader\n");
+      byebye(true, argc==1, laszip_reader);
+    }
+
+    // open the reader
+
+    laszip_BOOL is_compressed = 0;
+    if (laszip_open_reader(laszip_reader, file_name_in, &is_compressed))
+    {
+      fprintf(stderr,"DLL ERROR: opening laszip reader for '%s'\n", file_name_in);
+      byebye(true, argc==1, laszip_reader);
+    }
+
+    fprintf(stderr,"file '%s' is %scompressed\n", file_name_in, (is_compressed ? "" : "un"));
+
+    // get a pointer to the header of the reader that was just populated
+
+    laszip_header* header_read;
+
+    if (laszip_get_header_pointer(laszip_reader, &header_read))
+    {
+      fprintf(stderr,"DLL ERROR: getting header pointer from laszip reader\n");
+      byebye(true, argc==1, laszip_reader);
+    }
+
+    // how many points does the file have
+
+    laszip_I64 npoints = (header_read->number_of_point_records ? header_read->number_of_point_records : header_read->extended_number_of_point_records);
+
+    // report how many points the file has
+
+    fprintf(stderr,"file '%s' contains %I64d points\n", file_name_in, npoints);
+
+    // get a pointer to the points that will be read
+
+    laszip_point* point_read;
+
+    if (laszip_get_point_pointer(laszip_reader, &point_read))
+    {
+      fprintf(stderr,"DLL ERROR: getting point pointer from laszip reader\n");
+      byebye(true, argc==1, laszip_reader);
+    }
+
+    // create the writer
+
+    laszip_POINTER laszip_writer;
+    if (laszip_create(&laszip_writer))
+    {
+      fprintf(stderr,"DLL ERROR: creating laszip writer\n");
+      byebye(true, argc==1);
+    }
+
+    // get a pointer to the header of the writer so we can populate it
+
+    laszip_header* header_write;
+
+    if (laszip_get_header_pointer(laszip_writer, &header_write))
+    {
+      fprintf(stderr,"DLL ERROR: getting header pointer from laszip writer\n");
+      byebye(true, argc==1, laszip_writer);
+    }
+
+    // populate the header
+
+    header_write->file_source_ID = header_read->file_source_ID;
+    header_write->global_encoding = header_read->global_encoding;
+    header_write->version_major = header_read->version_major;
+    header_write->version_minor = header_read->version_minor;
+    strncpy(header_write->system_identifier, "LASzip DLL example 15", 32);
+    header_write->file_creation_day = header_read->file_creation_day;
+    header_write->file_creation_year = header_read->file_creation_year;
+    header_write->header_size = header_read->header_size;
+    header_write->offset_to_point_data = header_read->header_size; // real offset_to_point_data is calculated when adding VLRs
+    header_write->point_data_format = header_read->point_data_format;
+    header_write->point_data_record_length = header_read->point_data_record_length;
+    if ((header_read->point_data_format > 5) || (header_read->extended_number_of_point_records > (2<<32-1)))
+    {
+      // legacy 32-bit counters should be zero for new point types > 5 or if there are more than 2<<32-1 points
+      header_write->number_of_point_records = 0;
+      for (i = 0; i < 5; i++)
+      {
+        header_write->number_of_points_by_return[i] = 0;
+      }
+    }
+    else
+    {
+      // legacy 32-bit counters should be populated
+      header_write->number_of_point_records = (header_read->number_of_point_records ? header_read->number_of_point_records : (laszip_U32)(header_read->extended_number_of_point_records));
+      for (i = 0; i < 5; i++)
+      {
+        header_write->number_of_points_by_return[i] = (header_read->number_of_points_by_return[i] ? header_read->number_of_points_by_return[i] : (laszip_U32)(header_read->extended_number_of_points_by_return[i]));
+      }
+    }
+    header_write->extended_number_of_point_records = header_read->extended_number_of_point_records;
+    for (i = 0; i < 15; i++)
+    {
+      header_write->extended_number_of_points_by_return[i] = header_read->extended_number_of_points_by_return[i];
+    }
+    header_write->x_scale_factor = header_read->x_scale_factor;
+    header_write->y_scale_factor = header_read->y_scale_factor;
+    header_write->z_scale_factor = header_read->z_scale_factor;
+    header_write->x_offset = header_read->x_offset;
+    header_write->y_offset = header_read->y_offset;
+    header_write->z_offset = header_read->z_offset;
+    header_write->max_x = header_read->max_x;
+    header_write->min_x = header_read->min_x;
+    header_write->max_y = header_read->max_y;
+    header_write->min_y = header_read->min_y;
+    header_write->max_z = header_read->max_z;
+    header_write->min_z = header_read->min_z;
+
+    // extended VLRs or Waveforms are not supported yet
+
+    header_write->start_of_waveform_data_packet_record = 0;
+    header_write->number_of_extended_variable_length_records = 0;
+    header_write->start_of_first_extended_variable_length_record = 0;
+
+    // add VLRs
+
+    for (i = 0; i < header_read->number_of_variable_length_records; i++)
+    {
+      if (laszip_add_vlr(laszip_writer, header_read->vlrs[i].user_id, header_read->vlrs[i].record_id, header_read->vlrs[i].record_length_after_header, header_read->vlrs[i].description, header_read->vlrs[i].data))
+      {
+        fprintf(stderr,"DLL ERROR: adding VLR[%d] to the header\n", i);
+        byebye(true, argc==1, laszip_writer);
+      }
+      fprintf(stderr,"offset_to_point_data after adding VLR[%d]                   : %d\n", i, (laszip_I32)header_write->offset_to_point_data);
+    }
+
+    // open the writer
+
+    laszip_BOOL compress = (strstr(file_name_out, ".laz") != 0);
+
+    if (laszip_open_writer(laszip_writer, file_name_out, compress))
+    {
+      fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
+      byebye(true, argc==1, laszip_writer);
+    }
+
+    fprintf(stderr,"writing file '%s' %scompressed\n", file_name_out, (compress ? "" : "un"));
+
+    // get a pointer to the point of the writer that we will populate and write
+
+    laszip_point* point_write;
+
+    if (laszip_get_point_pointer(laszip_writer, &point_write))
+    {
+      fprintf(stderr,"DLL ERROR: getting point pointer from laszip writer\n");
+      byebye(true, argc==1, laszip_writer);
+    }
+
+    // read and write all the points
+
+    laszip_I64 p_count = 0;
+
+    while (p_count < npoints)
+    {
+      // read a point
+
+      if (laszip_read_point(laszip_reader))
+      {
+        fprintf(stderr,"DLL ERROR: reading point %I64\n", p_count);
+        byebye(true, argc==1, laszip_reader);
+      }
+
+      // copy the point
+
+      point_write->X = point_read->X;
+      point_write->Y = point_read->Y;
+      point_write->Z = point_read->Z;
+      point_write->intensity = point_read->intensity;
+      point_write->scan_direction_flag = point_read->scan_direction_flag;
+      point_write->edge_of_flight_line = point_read->edge_of_flight_line;
+      point_write->withheld_flag = point_read->withheld_flag;
+      point_write->keypoint_flag = point_read->keypoint_flag;
+      point_write->synthetic_flag = point_read->synthetic_flag;
+      point_write->classification = point_read->classification;
+      point_write->user_data = point_read->user_data;
+      point_write->point_source_ID = point_read->point_source_ID;
+
+      point_write->gps_time = point_read->gps_time;
+      memcpy(point_write->rgb, point_read->rgb, 8);
+
+      if (point_write->extended_point_type)
+      {
+        point_write->extended_scanner_channel = point_read->extended_scanner_channel;
+        point_write->extended_classification_flags = point_read->extended_classification_flags;
+        point_write->extended_classification = point_read->extended_classification;
+        point_write->extended_return_number = point_read->extended_return_number;
+        point_write->extended_number_of_returns = point_read->extended_number_of_returns;
+        point_write->extended_scan_angle = point_read->extended_scan_angle;
+      }
+      else
+      {
+        point_write->return_number = point_read->return_number;
+        point_write->number_of_returns = point_read->number_of_returns;
+        point_write->scan_angle_rank = point_read->scan_angle_rank;
+      }
+
+      if (point_read->num_extra_bytes)
+      {
+        memcpy(point_write->extra_bytes, point_read->extra_bytes, point_read->num_extra_bytes);
+      }
+
+      // write the point
+
+      if (laszip_write_point(laszip_writer))
+      {
+        fprintf(stderr,"DLL ERROR: writing point %I64\n", p_count);
+        byebye(true, argc==1, laszip_writer);
+      }
+
+      p_count++;
+    }
+
+    fprintf(stderr,"successfully read and written %I64d points\n", p_count);
+
+    // close the writer
+
+    if (laszip_close_writer(laszip_writer))
+    {
+      fprintf(stderr,"DLL ERROR: closing laszip writer\n");
+      byebye(true, argc==1, laszip_writer);
+    }
+
+    // destroy the writer
+
+    if (laszip_destroy(laszip_writer))
+    {
+      fprintf(stderr,"DLL ERROR: destroying laszip writer\n");
+      byebye(true, argc==1);
+    }
+
+    // close the reader
+
+    if (laszip_close_reader(laszip_reader))
+    {
+      fprintf(stderr,"DLL ERROR: closing laszip reader\n");
+      byebye(true, argc==1, laszip_reader);
+    }
+
+    // destroy the reader
+
+    if (laszip_destroy(laszip_reader))
+    {
+      fprintf(stderr,"DLL ERROR: destroying laszip reader\n");
+      byebye(true, argc==1);
+    }
+
+    fprintf(stderr,"total time: %g sec for reading %scompressed and writing %scompressed\n", taketime()-start_time, (is_compressed ? "" : "un"), (compress ? "" : "un"));
+
+  } // end of EXAMPLE_FIFTEEN
+
+  if (EXAMPLE == EXAMPLE_SIXTEEN)
+  {
+    fprintf(stderr,"running EXAMPLE_SIXTEEN (writing three points of type 6 to LAS 1.4 file)\n");
+
+    // create the writer
+
+    laszip_POINTER laszip_writer;
+    if (laszip_create(&laszip_writer))
+    {
+      fprintf(stderr,"DLL ERROR: creating laszip writer\n");
+      byebye(true, argc==1);
+    }
+
+    // get a pointer to the header of the writer so we can populate it
+
+    laszip_header* header;
+
+    if (laszip_get_header_pointer(laszip_writer, &header))
+    {
+      fprintf(stderr,"DLL ERROR: getting header pointer from laszip writer\n");
+      byebye(true, argc==1, laszip_writer);
+    }
+
+    // populate the header
+
+    header->file_source_ID = 4711;
+    header->global_encoding = 0x0001; // time stamps are in adjusted standard GPS time
+    header->version_major = 1;
+    header->version_minor = 4;
+    strncpy(header->system_identifier, "LASzip DLL example 16", 32);
+    header->file_creation_day = 120;
+    header->file_creation_year = 2018;
+    header->header_size = 375;                 // must be 375 for LAS 1.4
+    header->offset_to_point_data = 375;        // must be at least 375 for LAS 1.4
+    header->number_of_variable_length_records = 0;
+    header->point_data_format = 6;
+    header->point_data_record_length = 30;
+    header->number_of_point_records = 0;       // must be zero for point type 6 or higher
+    header->number_of_points_by_return[0] = 0; // must be zero for point type 6 or higher
+    header->number_of_points_by_return[1] = 0; // must be zero for point type 6 or higher
+    header->number_of_points_by_return[2] = 0; // must be zero for point type 6 or higher
+    header->number_of_points_by_return[3] = 0; // must be zero for point type 6 or higher
+    header->number_of_points_by_return[4] = 0; // must be zero for point type 6 or higher
+    header->max_x = 630499.95;
+    header->min_x = 630498.56;
+    header->max_y = 4834749.66;
+    header->min_y = 4834748.73;
+    header->max_z = 63.68;
+    header->min_z = 61.33;
+    header->extended_number_of_point_records = 3;
+    header->extended_number_of_points_by_return[0] = 2;
+    header->extended_number_of_points_by_return[1] = 1;
+    header->extended_number_of_points_by_return[2] = 0;
+    header->extended_number_of_points_by_return[3] = 0;
+    header->extended_number_of_points_by_return[4] = 0;
+    header->extended_number_of_points_by_return[5] = 0;
+    header->extended_number_of_points_by_return[6] = 0;
+    header->extended_number_of_points_by_return[7] = 0;
+    header->extended_number_of_points_by_return[8] = 0;
+    header->extended_number_of_points_by_return[9] = 0;
+    header->extended_number_of_points_by_return[10] = 0;
+    header->extended_number_of_points_by_return[11] = 0;
+    header->extended_number_of_points_by_return[12] = 0;
+    header->extended_number_of_points_by_return[13] = 0;
+    header->extended_number_of_points_by_return[14] = 0;
+
+    // optional: use the bounding box and the scale factor to create a "good" offset
+
+    if (laszip_auto_offset(laszip_writer))
+    {
+      fprintf(stderr,"DLL ERROR: during automatic offset creation\n");
+      byebye(true, argc==1, laszip_writer);
+    }
+
+    fprintf(stderr,"offset_to_point_data before adding funny VLR is    : %d\n", (laszip_I32)header->offset_to_point_data);
+
+    // add some funny VLR
+
+    if (laszip_add_vlr(laszip_writer, "funny", 12345, 0, "just a funny VLR", 0))
+    {
+      fprintf(stderr,"DLL ERROR: adding funny VLR to the header\n");
+      byebye(true, argc==1, laszip_writer);
+    }
+
+    // create the geokeys with the projection information
+
+    laszip_geokey_struct key_entries[5];
+
+    // projected coordinates
+    key_entries[0].key_id = 1024; // GTModelTypeGeoKey
+    key_entries[0].tiff_tag_location = 0;
+    key_entries[0].count = 1;
+    key_entries[0].value_offset = 1; // ModelTypeProjected
+
+    // projection
+    key_entries[1].key_id = 3072; // ProjectedCSTypeGeoKey
+    key_entries[1].tiff_tag_location = 0;
+    key_entries[1].count = 1;
+    key_entries[1].value_offset = 32613; // PCS_WGS84_UTM_zone_13N
+
+    // horizontal units
+    key_entries[2].key_id = 3076; // ProjLinearUnitsGeoKey
+    key_entries[2].tiff_tag_location = 0;
+    key_entries[2].count = 1;
+    key_entries[2].value_offset = 9001; // meters
+
+    // vertical units
+    key_entries[3].key_id = 4099; // VerticalUnitsGeoKey
+    key_entries[3].tiff_tag_location = 0;
+    key_entries[3].count = 1;
+    key_entries[3].value_offset = 9001; // meters
+
+    // vertical datum
+    key_entries[4].key_id = 4096; // VerticalCSTypeGeoKey
+    key_entries[4].tiff_tag_location = 0;
+    key_entries[4].count = 1;
+    key_entries[4].value_offset = 5030; // WGS84
+
+    // add the geokeys (create or replace the appropriate VLR)
+
+    fprintf(stderr,"offset_to_point_data before adding projection VLR  : %d\n", (laszip_I32)header->offset_to_point_data);
+
+    if (laszip_set_geokeys(laszip_writer, 5, key_entries))
+    {
+      fprintf(stderr,"DLL ERROR: adding funny VLR to the header\n");
+      byebye(true, argc==1, laszip_writer);
+    }
+
+    fprintf(stderr,"offset_to_point_data after adding two VLRs         : %d\n", (laszip_I32)header->offset_to_point_data);
+
+    // open the writer
+
+    laszip_BOOL compress = (strstr(file_name_out, ".laz") != 0);
+
+    if (laszip_open_writer(laszip_writer, file_name_out, compress))
+    {
+      fprintf(stderr,"DLL ERROR: opening laszip writer for '%s'\n", file_name_out);
+      byebye(true, argc==1, laszip_writer);
+    }
+
+    fprintf(stderr,"writing file '%s' %scompressed\n", file_name_out, (compress ? "" : "un"));
+
+    // get a pointer to the point of the writer that we will populate and write
+
+    laszip_point* point;
+
+    if (laszip_get_point_pointer(laszip_writer, &point))
+    {
+      fprintf(stderr,"DLL ERROR: getting point pointer from laszip writer\n");
+      byebye(true, argc==1, laszip_writer);
+    }
+
+    // write three points
+
+    laszip_I64 p_count = 0;
+    laszip_F64 coordinates[3];
+
+    // populate the first point
+
+    coordinates[0] = 630499.95;
+    coordinates[1] = 4834749.17;
+    coordinates[2] = 63.15;
+
+    if (laszip_set_coordinates(laszip_writer, coordinates))
+    {
+      fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+      byebye(true, argc==1, laszip_writer);
+    }
+
+    point->intensity = 60;
+    point->extended_return_number = 1;
+    point->extended_number_of_returns = 2;
+    point->extended_classification = 1;
+    point->extended_classification_flags = 0; // none
+    point->extended_scan_angle = (laszip_I16)((21.0/0.006) + 0.5);
+    point->gps_time = 1132762996.478024;
+
+    // write the first point
+
+    if (laszip_write_point(laszip_writer))
+    {
+      fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+      byebye(true, argc==1, laszip_writer);
+    }
+    p_count++;
+
+    // populate the second point
+
+    coordinates[0] = 630499.83;
+    coordinates[1] = 4834748.88;
+    coordinates[2] = 62.18;
+
+    if (laszip_set_coordinates(laszip_writer, coordinates))
+    {
+      fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+      byebye(true, argc==1, laszip_writer);
+    }
+
+    point->intensity = 90;
+    point->extended_return_number = 2;
+    point->extended_number_of_returns = 2;
+    point->extended_classification = 1;
+    point->extended_classification_flags = 0x4 | 0x2 | 0x1; // withheld, keypoint, synthetic flag
+    point->extended_scan_angle = (laszip_I16)((21.0/0.006) + 0.5);
+    point->gps_time = 1132762996.478024;
+
+    // write the second point
+
+    if (laszip_write_point(laszip_writer))
+    {
+      fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+      byebye(true, argc==1, laszip_writer);
+    }
+    p_count++;
+
+    // populate the third point
+
+    coordinates[0] = 630499.54;
+    coordinates[1] = 4834749.66;
+    coordinates[2] = 62.66;
+
+    if (laszip_set_coordinates(laszip_writer, coordinates))
+    {
+      fprintf(stderr,"DLL ERROR: setting coordinates for point %I64d\n", p_count);
+      byebye(true, argc==1, laszip_writer);
+    }
+
+    point->intensity = 70;
+    point->extended_return_number = 1;
+    point->extended_number_of_returns = 1;
+    point->extended_classification = 2;
+    point->extended_classification_flags = 0x8 | 0x4 | 0x2 | 0x1; // overlap, withheld, keypoint, synthetic flag
+    point->extended_scan_angle = (laszip_I16)((21.25/0.006) + 0.5);
+    point->gps_time = 1132762996.476224;
+
+    // write the third point
+
+    if (laszip_write_point(laszip_writer))
+    {
+      fprintf(stderr,"DLL ERROR: writing point %I64d\n", p_count);
+      byebye(true, argc==1, laszip_writer);
+    }
+    p_count++;
+ 
+    // get the number of points written so far
+
+    if (laszip_get_point_count(laszip_writer, &p_count))
+    {
+      fprintf(stderr,"DLL ERROR: getting point count\n");
+      byebye(true, argc==1, laszip_writer);
+    }
+
+    fprintf(stderr,"successfully written %I64d points\n", p_count);
+
+    // close the writer
+
+    if (laszip_close_writer(laszip_writer))
+    {
+      fprintf(stderr,"DLL ERROR: closing laszip writer\n");
+      byebye(true, argc==1, laszip_writer);
+    }
+
+    // destroy the writer
+
+    if (laszip_destroy(laszip_writer))
+    {
+      fprintf(stderr,"DLL ERROR: destroying laszip writer\n");
+      byebye(true, argc==1);
+    }
+
+    fprintf(stderr,"total time: %g sec for writing %scompressed\n", taketime()-start_time, (compress ? "" : "un"));
+
+  } // end of EXAMPLE_SIXTEEN
+
   // unload LASzip DLL
 
   if (laszip_unload_dll())


=====================================
include/laszip/laszip_api.h
=====================================
@@ -251,7 +251,7 @@ typedef struct laszip_point
 #define laszip_DECOMPRESS_SELECTIVE_BYTE5              0x00200000
 #define laszip_DECOMPRESS_SELECTIVE_BYTE6              0x00400000
 #define laszip_DECOMPRESS_SELECTIVE_BYTE7              0x00800000
-#define laszip_DECOMPRESS_SELECTIVE_EXTRA_BYTES        0xFFF00000
+#define laszip_DECOMPRESS_SELECTIVE_EXTRA_BYTES        0xFFFF0000
 
 /*---------------------------------------------------------------------------*/
 /*---------------- DLL functions to manage the LASzip DLL -------------------*/


=====================================
scripts/ci/add_deploy_key.sh
=====================================
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+if [ -n "$encrypted_de53628fc98a_key" ]; then
+    echo "decrypting SSH for github login"
+    openssl aes-256-cbc -K $encrypted_de53628fc98a_key -iv $encrypted_de53628fc98a_iv -in scripts/ci/pdaldocs-private.key.enc -out scripts/ci/pdaldocs-private.key -d
+#    openssl aes-256-cbc -K $encrypted_de53628fc98a_key -iv $encrypted_de53628fc98a_iv -in scripts/ci/pdaldocs-private.key.enc -out ~\/.ssh/pdal-docs/id_rsa -d
+
+    cp scripts/ci/pdaldocs-private.key ~/.ssh/id_rsa
+    rm scripts/ci/pdaldocs-private.key
+    chmod 600 ~/.ssh/id_rsa
+    echo -e "Host *\n\tStrictHostKeyChecking no\n" > ~/.ssh/config
+fi;
+
+


=====================================
scripts/ci/build_docs.sh
=====================================
@@ -8,6 +8,6 @@ if [[ ! -z $TRAVIS_BUILD_DIR ]]; then
 buildpath="$TRAVIS_BUILD_DIR"
 fi
 
-docker run -v $buildpath:/data -w /data/docs laszip/docs make html
+docker run -v $buildpath:/data -w /data/docs pdal/docs make html
 
 


=====================================
scripts/ci/deploy_website.sh
=====================================
@@ -2,7 +2,30 @@
 
 echo "deploying docs for $TRAVIS_BUILD_DIR/docs"
 
-export AWS_ACCESS_KEY_ID="$AWS_KEY"
-export AWS_SECRET_ACCESS_KEY="$AWS_SECRET"
+builddir=$1
+destdir=$2
+
+echo "builddir: " $builddir
+echo "destdir: " $destdir
+
+DATE=$(date +'%y.%m.%d %H:%M:%S')
+
+git clone git at github.com:LASzip/laszip.github.io.git $destdir/laszipdocs
+cd $destdir/laszipdocs
+git checkout master
+
+
+cd $builddir/html
+cp -rf * $destdir/laszipdocs
+
+#cd $builddir/latex/
+#cp PDAL.pdf $destdir/laszipdocs
+
+cd $destdir/laszipdocs
+git config user.email "howard+pdal-docs at hobu.co"
+git config user.name "PDAL Travis docsbot"
+
+git add -A
+git commit -m "update with results of commit https://github.com/LASzip/LASzip/commit/$TRAVIS_COMMIT for ${DATE}"
+git push origin master
 
-docker run -e "AWS_SECRET_ACCESS_KEY=$AWS_SECRET" -e "AWS_ACCESS_KEY_ID=$AWS_KEY" -v $TRAVIS_BUILD_DIR:/data -w /data/docs laszip/docs aws s3 sync ./build/html/ s3://www.laszip.org --acl public-read


=====================================
scripts/ci/docker.sh
=====================================
@@ -1,7 +1,6 @@
 #!/bin/bash
 
-# laszip/docs image has all of the Sphinx
-# dependencies need to build LASzip's docs
-
-docker pull laszip/docs
+# proj.4 image has all of the Sphinx
+# dependencies need to build proj.4's docs
 
+docker pull  pdal/docs


=====================================
scripts/ci/pdaldocs-private.key.enc
=====================================
Binary files /dev/null and b/scripts/ci/pdaldocs-private.key.enc differ


=====================================
src/bytestreamin_istream.hpp
=====================================
@@ -1,10 +1,10 @@
-/*
-===============================================================================
-
-  FILE:  bytestreamin_istream.hpp
-  
-  CONTENTS:
-      
+/*
+===============================================================================
+
+  FILE:  bytestreamin_istream.hpp
+  
+  CONTENTS:
+      
     Class for istream-based input streams with endian handling.
 
   PROGRAMMERS:
@@ -13,7 +13,7 @@
 
   COPYRIGHT:
 
-    (c) 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality
+    (c) 2007-2018, 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,14 +24,15 @@
   
   CHANGE HISTORY:
   
+    10 July 2018 -- because it's hard to determine seek-ability, user must set it
      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_ISTREAM_H
-#define BYTE_STREAM_IN_ISTREAM_H
+  
+===============================================================================
+*/
+#ifndef BYTE_STREAM_IN_ISTREAM_H
+#define BYTE_STREAM_IN_ISTREAM_H
 
 #include "bytestreamin.hpp"
 
@@ -42,17 +43,17 @@
 #include <fstream>
 using namespace std;
 #endif
-
-class ByteStreamInIstream : public ByteStreamIn
-{
+
+class ByteStreamInIstream : public ByteStreamIn
+{
 public:
-  ByteStreamInIstream(istream& stream);
+  ByteStreamInIstream(istream& stream, BOOL seekable=TRUE);
 /* read a single byte                                        */
-  U32 getByte();
+  U32 getByte();
 /* read an array of bytes                                    */
   void getBytes(U8* bytes, const U32 num_bytes);
-/* is the stream seekable (e.g. standard in is not)          */
-  BOOL isSeekable() const;
+/* is the stream seekable (e.g. stdin is not)                */
+  BOOL isSeekable() const { return seekable; };
 /* get current position of stream                            */
   I64 tell() const;
 /* seek to this position in the stream                       */
@@ -63,12 +64,13 @@ public:
   ~ByteStreamInIstream(){};
 protected:
   istream& stream;
-};
+  BOOL seekable;
+};
 
 class ByteStreamInIstreamLE : public ByteStreamInIstream
 {
 public:
-  ByteStreamInIstreamLE(istream& stream);
+  ByteStreamInIstreamLE(istream& stream, BOOL seekable=TRUE);
 /* read 16 bit low-endian field                              */
   void get16bitsLE(U8* bytes);
 /* read 32 bit low-endian field                              */
@@ -88,7 +90,7 @@ private:
 class ByteStreamInIstreamBE : public ByteStreamInIstream
 {
 public:
-  ByteStreamInIstreamBE(istream& stream);
+  ByteStreamInIstreamBE(istream& stream, BOOL seekable=TRUE);
 /* read 16 bit low-endian field                              */
   void get16bitsLE(U8* bytes);
 /* read 32 bit low-endian field                              */
@@ -105,8 +107,7 @@ private:
   U8 swapped[8];
 };
 
-inline ByteStreamInIstream::ByteStreamInIstream(istream& stream_param) :
-  stream(stream_param)
+inline ByteStreamInIstream::ByteStreamInIstream(istream& stream_param, BOOL seekable_param) : stream(stream_param), seekable(seekable_param)
 {
 }
 
@@ -119,7 +120,7 @@ inline U32 ByteStreamInIstream::getByte()
   }
   return (U32)byte;
 }
-
+
 inline void ByteStreamInIstream::getBytes(U8* bytes, const U32 num_bytes)
 {
   stream.read((char*)bytes, num_bytes);
@@ -129,11 +130,6 @@ inline void ByteStreamInIstream::getBytes(U8* bytes, const U32 num_bytes)
   }
 }
 
-inline BOOL ByteStreamInIstream::isSeekable() const
-{
-  return !!(static_cast<ifstream&>(stream));
-}
-
 inline I64 ByteStreamInIstream::tell() const
 {
   return (I64)stream.tellg();
@@ -155,7 +151,7 @@ inline BOOL ByteStreamInIstream::seekEnd(const I64 distance)
   return stream.good();
 }
 
-inline ByteStreamInIstreamLE::ByteStreamInIstreamLE(istream& stream) : ByteStreamInIstream(stream)
+inline ByteStreamInIstreamLE::ByteStreamInIstreamLE(istream& stream, BOOL seekable) : ByteStreamInIstream(stream, seekable)
 {
 }
 
@@ -203,7 +199,7 @@ inline void ByteStreamInIstreamLE::get64bitsBE(U8* bytes)
   bytes[7] = swapped[0];
 }
 
-inline ByteStreamInIstreamBE::ByteStreamInIstreamBE(istream& stream) : ByteStreamInIstream(stream)
+inline ByteStreamInIstreamBE::ByteStreamInIstreamBE(istream& stream, BOOL seekable) : ByteStreamInIstream(stream, seekable)
 {
 }
 
@@ -251,4 +247,4 @@ inline void ByteStreamInIstreamBE::get64bitsBE(U8* bytes)
   getBytes(bytes, 8);
 }
 
-#endif
+#endif


=====================================
src/lasattributer.hpp
=====================================
@@ -25,6 +25,7 @@
   
   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
   
 ===============================================================================
@@ -68,79 +69,81 @@ public:
     this->options = size;
   };
 
-  LASattribute(U32 type, const CHAR* name, const CHAR* description=0, U32 dim=1)
+  LASattribute(U32 type, const CHAR* name, const CHAR* description=0)
   {
     if (type > LAS_ATTRIBUTE_F64) throw;
-    if ((dim < 1) || (dim > 3)) throw;
     if (name == 0) throw;
     memset(this, 0, sizeof(LASattribute));
     scale[0] = scale[1] = scale[2] = 1.0;
-    this->data_type = (dim-1)*10+type+1;
+    this->data_type = type+1;
     strncpy(this->name, name, 32);
     if (description) strncpy(this->description, description, 32);
   };
 
-  inline BOOL set_no_data(U8 no_data, I32 dim=0) { if ((0 == get_type()) && (dim < get_dim())) { this->no_data[dim].u64 = no_data; options |= 0x01; return TRUE; } return FALSE; };
-  inline BOOL set_no_data(I8 no_data, I32 dim=0) { if ((1 == get_type()) && (dim < get_dim())) { this->no_data[dim].i64 = no_data; options |= 0x01; return TRUE; } return FALSE; };
-  inline BOOL set_no_data(U16 no_data, I32 dim=0) { if ((2 == get_type()) && (dim < get_dim())) { this->no_data[dim].u64 = no_data; options |= 0x01; return TRUE; } return FALSE; };
-  inline BOOL set_no_data(I16 no_data, I32 dim=0) { if ((3 == get_type()) && (dim < get_dim())) { this->no_data[dim].i64 = no_data; options |= 0x01; return TRUE; } return FALSE; };
-  inline BOOL set_no_data(U32 no_data, I32 dim=0) { if ((4 == get_type()) && (dim < get_dim())) { this->no_data[dim].u64 = no_data; options |= 0x01; return TRUE; } return FALSE; };
-  inline BOOL set_no_data(I32 no_data, I32 dim=0) { if ((5 == get_type()) && (dim < get_dim())) { this->no_data[dim].i64 = no_data; options |= 0x01; return TRUE; } return FALSE; };
-  inline BOOL set_no_data(U64 no_data, I32 dim=0) { if ((6 == get_type()) && (dim < get_dim())) { this->no_data[dim].u64 = no_data; options |= 0x01; return TRUE; } return FALSE; };
-  inline BOOL set_no_data(I64 no_data, I32 dim=0) { if ((7 == get_type()) && (dim < get_dim())) { this->no_data[dim].i64 = no_data; options |= 0x01; return TRUE; } return FALSE; };
-  inline BOOL set_no_data(F32 no_data, I32 dim=0) { if ((8 == get_type()) && (dim < get_dim())) { this->no_data[dim].f64 = no_data; options |= 0x01; return TRUE; } return FALSE; };
-  inline BOOL set_no_data(F64 no_data, I32 dim=0)
+  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; };
+  inline BOOL set_no_data(I8  no_data) { if (1 == get_type()) { this->no_data[0].i64 = no_data; options |= 0x01; return TRUE; } return FALSE; };
+  inline BOOL set_no_data(U16 no_data) { if (2 == get_type()) { this->no_data[0].u64 = no_data; options |= 0x01; return TRUE; } return FALSE; };
+  inline BOOL set_no_data(I16 no_data) { if (3 == get_type()) { this->no_data[0].i64 = no_data; options |= 0x01; return TRUE; } return FALSE; };
+  inline BOOL set_no_data(U32 no_data) { if (4 == get_type()) { this->no_data[0].u64 = no_data; options |= 0x01; return TRUE; } return FALSE; };
+  inline BOOL set_no_data(I32 no_data) { if (5 == get_type()) { this->no_data[0].i64 = no_data; options |= 0x01; return TRUE; } return FALSE; };
+  inline BOOL set_no_data(U64 no_data) { if (6 == get_type()) { this->no_data[0].u64 = no_data; options |= 0x01; return TRUE; } return FALSE; };
+  inline BOOL set_no_data(I64 no_data) { if (7 == get_type()) { this->no_data[0].i64 = no_data; options |= 0x01; return TRUE; } return FALSE; };
+  inline BOOL set_no_data(F32 no_data) { if (8 == get_type()) { this->no_data[0].f64 = no_data; options |= 0x01; return TRUE; } return FALSE; };
+  inline BOOL set_no_data(F64 no_data)
   {
-    if (dim < get_dim())
+    switch (get_type())
     {
-      switch (get_type())
-      {
-      case 0:
-      case 2:
-      case 4:
-      case 6:
-        this->no_data[dim].u64 = (U64)no_data; options |= 0x01; return TRUE;
-      case 1:
-      case 3:
-      case 5:
-      case 7:
-        this->no_data[dim].i64 = (I64)no_data; options |= 0x01; return TRUE;
-      case 8:
-      case 9:
-        this->no_data[dim].f64 = no_data; options |= 0x01; return TRUE;
-      }
+    case 0:
+    case 2:
+    case 4:
+    case 6:
+      this->no_data[0].u64 = (U64)no_data;
+      options |= 0x01;
+      return TRUE;
+    case 1:
+    case 3:
+    case 5:
+    case 7:
+      this->no_data[0].i64 = (I64)no_data;
+      options |= 0x01;
+      return TRUE;
+    case 8:
+    case 9:
+      this->no_data[0].f64 = no_data;
+      options |= 0x01;
+      return TRUE;
     }
     return FALSE;
   };
 
-  inline void set_min(U8* min, I32 dim=0) { this->min[dim] = cast(min); options |= 0x02; };
-  inline void update_min(U8* min, I32 dim=0) { this->min[dim] = smallest(cast(min), this->min[dim]); };
-  inline BOOL set_min(U8 min, I32 dim=0) { if ((0 == get_type()) && (dim < get_dim())) { this->min[dim].u64 = min; options |= 0x02; return TRUE; } return FALSE; };
-  inline BOOL set_min(I8 min, I32 dim=0) { if ((1 == get_type()) && (dim < get_dim())) { this->min[dim].i64 = min; options |= 0x02; return TRUE; } return FALSE; };
-  inline BOOL set_min(U16 min, I32 dim=0) { if ((2 == get_type()) && (dim < get_dim())) { this->min[dim].u64 = min; options |= 0x02; return TRUE; } return FALSE; };
-  inline BOOL set_min(I16 min, I32 dim=0) { if ((3 == get_type()) && (dim < get_dim())) { this->min[dim].i64 = min; options |= 0x02; return TRUE; } return FALSE; };
-  inline BOOL set_min(U32 min, I32 dim=0) { if ((4 == get_type()) && (dim < get_dim())) { this->min[dim].u64 = min; options |= 0x02; return TRUE; } return FALSE; };
-  inline BOOL set_min(I32 min, I32 dim=0) { if ((5 == get_type()) && (dim < get_dim())) { this->min[dim].i64 = min; options |= 0x02; return TRUE; } return FALSE; };
-  inline BOOL set_min(U64 min, I32 dim=0) { if ((6 == get_type()) && (dim < get_dim())) { this->min[dim].u64 = min; options |= 0x02; return TRUE; } return FALSE; };
-  inline BOOL set_min(I64 min, I32 dim=0) { if ((7 == get_type()) && (dim < get_dim())) { this->min[dim].i64 = min; options |= 0x02; return TRUE; } return FALSE; };
-  inline BOOL set_min(F32 min, I32 dim=0) { if ((8 == get_type()) && (dim < get_dim())) { this->min[dim].f64 = min; options |= 0x02; return TRUE; } return FALSE; };
-  inline BOOL set_min(F64 min, I32 dim=0) { if ((9 == get_type()) && (dim < get_dim())) { this->min[dim].f64 = min; options |= 0x02; return TRUE; } return FALSE; };
-
-  inline void set_max(U8* max, I32 dim=0) { this->max[dim] = cast(max); options |= 0x04; };
-  inline void update_max(U8* max, I32 dim=0) { this->max[dim] = biggest(cast(max), this->max[dim]); };
-  inline BOOL set_max(U8 max, I32 dim=0) { if ((0 == get_type()) && (dim < get_dim())) { this->max[dim].u64 = max; options |= 0x04; return TRUE; } return FALSE; };
-  inline BOOL set_max(I8 max, I32 dim=0) { if ((1 == get_type()) && (dim < get_dim())) { this->max[dim].i64 = max; options |= 0x04; return TRUE; } return FALSE; };
-  inline BOOL set_max(U16 max, I32 dim=0) { if ((2 == get_type()) && (dim < get_dim())) { this->max[dim].u64 = max; options |= 0x04; return TRUE; } return FALSE; };
-  inline BOOL set_max(I16 max, I32 dim=0) { if ((3 == get_type()) && (dim < get_dim())) { this->max[dim].i64 = max; options |= 0x04; return TRUE; } return FALSE; };
-  inline BOOL set_max(U32 max, I32 dim=0) { if ((4 == get_type()) && (dim < get_dim())) { this->max[dim].u64 = max; options |= 0x04; return TRUE; } return FALSE; };
-  inline BOOL set_max(I32 max, I32 dim=0) { if ((5 == get_type()) && (dim < get_dim())) { this->max[dim].i64 = max; options |= 0x04; return TRUE; } return FALSE; };
-  inline BOOL set_max(U64 max, I32 dim=0) { if ((6 == get_type()) && (dim < get_dim())) { this->max[dim].u64 = max; options |= 0x04; return TRUE; } return FALSE; };
-  inline BOOL set_max(I64 max, I32 dim=0) { if ((7 == get_type()) && (dim < get_dim())) { this->max[dim].i64 = max; options |= 0x04; return TRUE; } return FALSE; };
-  inline BOOL set_max(F32 max, I32 dim=0) { if ((8 == get_type()) && (dim < get_dim())) { this->max[dim].f64 = max; options |= 0x04; return TRUE; } return FALSE; };
-  inline BOOL set_max(F64 max, I32 dim=0) { if ((9 == get_type()) && (dim < get_dim())) { this->max[dim].f64 = max; options |= 0x04; return TRUE; } return FALSE; };
-
-  inline BOOL set_scale(F64 scale, I32 dim=0) { if (data_type) { this->scale[dim] = scale; options |= 0x08; return TRUE; } return FALSE; };
-  inline BOOL set_offset(F64 offset, I32 dim=0) { if (data_type) { this->offset[dim] = offset; options |= 0x10; return TRUE; } return FALSE; };
+  inline void set_min(U8* min) { this->min[0] = cast(min); options |= 0x02; };
+  inline void update_min(U8* min) { this->min[0] = smallest(cast(min), this->min[0]); };
+  inline BOOL set_min(U8  min) { if (0 == get_type()) { this->min[0].u64 = min; options |= 0x02; return TRUE; } return FALSE; };
+  inline BOOL set_min(I8  min) { if (1 == get_type()) { this->min[0].i64 = min; options |= 0x02; return TRUE; } return FALSE; };
+  inline BOOL set_min(U16 min) { if (2 == get_type()) { this->min[0].u64 = min; options |= 0x02; return TRUE; } return FALSE; };
+  inline BOOL set_min(I16 min) { if (3 == get_type()) { this->min[0].i64 = min; options |= 0x02; return TRUE; } return FALSE; };
+  inline BOOL set_min(U32 min) { if (4 == get_type()) { this->min[0].u64 = min; options |= 0x02; return TRUE; } return FALSE; };
+  inline BOOL set_min(I32 min) { if (5 == get_type()) { this->min[0].i64 = min; options |= 0x02; return TRUE; } return FALSE; };
+  inline BOOL set_min(U64 min) { if (6 == get_type()) { this->min[0].u64 = min; options |= 0x02; return TRUE; } return FALSE; };
+  inline BOOL set_min(I64 min) { if (7 == get_type()) { this->min[0].i64 = min; options |= 0x02; return TRUE; } return FALSE; };
+  inline BOOL set_min(F32 min) { if (8 == get_type()) { this->min[0].f64 = min; options |= 0x02; return TRUE; } return FALSE; };
+  inline BOOL set_min(F64 min) { if (9 == get_type()) { this->min[0].f64 = min; options |= 0x02; return TRUE; } return FALSE; };
+
+  inline void set_max(U8* max) { this->max[0] = cast(max); options |= 0x04; };
+  inline void update_max(U8* max) { this->max[0] = biggest(cast(max), this->max[0]); };
+  inline BOOL set_max(U8  max) { if (0 == get_type()) { this->max[0].u64 = max; options |= 0x04; return TRUE; } return FALSE; };
+  inline BOOL set_max(I8  max) { if (1 == get_type()) { this->max[0].i64 = max; options |= 0x04; return TRUE; } return FALSE; };
+  inline BOOL set_max(U16 max) { if (2 == get_type()) { this->max[0].u64 = max; options |= 0x04; return TRUE; } return FALSE; };
+  inline BOOL set_max(I16 max) { if (3 == get_type()) { this->max[0].i64 = max; options |= 0x04; return TRUE; } return FALSE; };
+  inline BOOL set_max(U32 max) { if (4 == get_type()) { this->max[0].u64 = max; options |= 0x04; return TRUE; } return FALSE; };
+  inline BOOL set_max(I32 max) { if (5 == get_type()) { this->max[0].i64 = max; options |= 0x04; return TRUE; } return FALSE; };
+  inline BOOL set_max(U64 max) { if (6 == get_type()) { this->max[0].u64 = max; options |= 0x04; return TRUE; } return FALSE; };
+  inline BOOL set_max(I64 max) { if (7 == get_type()) { this->max[0].i64 = max; options |= 0x04; return TRUE; } return FALSE; };
+  inline BOOL set_max(F32 max) { if (8 == get_type()) { this->max[0].f64 = max; options |= 0x04; return TRUE; } return FALSE; };
+  inline BOOL set_max(F64 max) { if (9 == get_type()) { this->max[0].f64 = max; options |= 0x04; return TRUE; } return FALSE; };
+
+  inline BOOL set_scale(F64 scale) { if (data_type) { this->scale[0] = scale; options |= 0x08; return TRUE; } return FALSE; };
+  inline BOOL set_offset(F64 offset) { if (data_type) { this->offset[0] = offset; options |= 0x10; return TRUE; } return FALSE; };
 
   inline BOOL has_no_data() const { return options & 0x01; };
   inline BOOL has_min() const { return options & 0x02; };
@@ -154,8 +157,7 @@ public:
     {
       const U32 size_table[10] = { 1, 1, 2, 2, 4, 4, 8, 8, 4, 8 };
       U32 type = get_type();
-      U32 dim = get_dim();
-      return size_table[type]*dim;
+      return size_table[type];
     }
     else
     {
@@ -197,7 +199,7 @@ private:
   };
   inline I32 get_dim() const
   {
-    return 1 + ((I32)data_type - 1)/10;
+    return 1;
   };
   inline U64I64F64 cast(U8* value) const
   {
@@ -262,6 +264,7 @@ private:
 class LASattributer
 {
 public:
+  BOOL attributes_linked;
   I32 number_attributes;
   LASattribute* attributes;
   I32* attribute_starts;
@@ -269,6 +272,7 @@ public:
 
   LASattributer()
   {
+    attributes_linked = TRUE;
     number_attributes = 0;
     attributes = 0;
     attribute_starts = 0;
@@ -282,12 +286,15 @@ public:
 
   void clean_attributes()
   {
-    if (number_attributes)
+    if (attributes_linked)
     {
-      number_attributes = 0;
-      free(attributes); attributes = 0;
-      free(attribute_starts); attribute_starts = 0;
-      free(attribute_sizes); attribute_sizes = 0;
+      if (attributes)
+      {
+        number_attributes = 0;
+        free(attributes); attributes = 0;
+        free(attribute_starts); attribute_starts = 0;
+        free(attribute_sizes); attribute_sizes = 0;
+      }
     }
   };
 


=====================================
src/lasindex.cpp
=====================================
@@ -327,7 +327,7 @@ BOOL LASindex::write(FILE* file) const
 BOOL LASindex::read(const char* file_name)
 {
   if (file_name == 0) return FALSE;
-  char* name = strdup(file_name);
+  char* name = LASCopyString(file_name);
   if (strstr(file_name, ".las") || strstr(file_name, ".laz"))
   {
     name[strlen(name)-1] = 'x';
@@ -502,7 +502,7 @@ BOOL LASindex::append(const char* file_name) const
 BOOL LASindex::write(const char* file_name) const
 {
   if (file_name == 0) return FALSE;
-  char* name = strdup(file_name);
+  char* name = LASCopyString(file_name);
   if (strstr(file_name, ".las") || strstr(file_name, ".laz"))
   {
     name[strlen(name)-1] = 'x';


=====================================
src/lasindex.hpp
=====================================
@@ -27,10 +27,11 @@
 
   CHANGE HISTORY:
 
+     7 September 2018 -- replaced calls to _strdup with calls to the LASCopyString macro
      7 January 2017 -- add read(FILE* file) for Trimble LASzip DLL improvement
      2 April 2015 -- add seek_next(LASreadPoint* reader, I64 &p_count) for DLL
      2 April 2015 -- delete read_next(LASreader* lasreader) that was not used
-    31 March 2015 -- remove unused LASquadtree inheritance of abstract LASspatial 
+    31 March 2015 -- remove unused LASquadtree inheritance of abstract LASspatial
     29 April 2011 -- created after cable outage during the royal wedding (-:
 
 ===============================================================================


=====================================
src/lasinterval.cpp
=====================================
@@ -44,7 +44,7 @@
 using namespace std;
 
 #ifdef UNORDERED
-   // Figure out whether <unordered_map> is in tr1
+// Figure out whether <unordered_map> is in tr1
 #  ifdef __has_include
 #    if __has_include(<unordered_map>)
 #     include <unordered_map>
@@ -168,7 +168,7 @@ BOOL LASinterval::add(const U32 p_index, const I32 c_index)
 // get total number of cells
 U32 LASinterval::get_number_cells() const
 {
-  return ((my_cell_hash*)cells)->size();
+  return (U32)((my_cell_hash*)cells)->size();
 }
 
 // get total number of intervals
@@ -239,9 +239,6 @@ void LASinterval::merge_intervals(U32 maximum_intervals, const BOOL verbose)
     hash_element++;
   }
 
-  my_cell_map::iterator map_element = map.begin();
-  diff = (*map_element).first;
-
   // maybe nothing to do
   if (map.size() <= maximum_intervals)
   {
@@ -253,13 +250,16 @@ void LASinterval::merge_intervals(U32 maximum_intervals, const BOOL verbose)
       }
       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);
       }
     }
     return;
   }
 
-  U32 size = map.size();
+  my_cell_map::iterator map_element;
+  U32 size = (U32)map.size();
+
   while (size > maximum_intervals)
   {
     map_element = map.begin();
@@ -671,7 +671,7 @@ BOOL LASinterval::write(ByteStreamOut* stream) const
     return FALSE;
   }
   // write number of cells
-  U32 number_cells = ((my_cell_hash*)cells)->size();
+  U32 number_cells = (U32)((my_cell_hash*)cells)->size();
   if (!stream->put32bitsLE((U8*)&number_cells))
   {
     fprintf(stderr,"ERROR (LASinterval): writing number of cells %d\n", number_cells);


=====================================
src/lasinterval.hpp
=====================================
@@ -25,6 +25,7 @@
   
   CHANGE HISTORY:
   
+    20 October 2018 -- fixed rare bug in merge_intervals() when verbose is TRUE
     29 April 2011 -- created after cable outage during the royal wedding (-:
   
 ===============================================================================


=====================================
src/laspoint.hpp
=====================================
@@ -25,6 +25,7 @@
   
   CHANGE HISTORY:
   
+    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
     19 July 2015 -- created after FOSS4GE in the train back from Lake Como
@@ -92,11 +93,14 @@ public:
   U8 extended_return_number : 4;
   U8 extended_number_of_returns : 4;
 
+  // LASlib internal use only
+  U8 deleted_flag;
+
   // for 8 byte alignment of the GPS time
-  U8 dummy[3];
+  U8 dummy[2];
 
-  // LASlib only
-  U32 deleted_flag;
+  // compressed LASzip 1.4 points only
+  BOOL gps_time_change;
 
   F64 gps_time;
   U16 rgb[4];
@@ -190,8 +194,8 @@ public:
     }
     else if (extended_point_type)
     {
-      extended_classification = other.classification & 31;
-      extended_classification_flags = other.classification >> 5;
+      extended_classification = other.classification;
+      extended_classification_flags = ((other.withheld_flag) << 2) | ((other.keypoint_flag) << 1) | (other.synthetic_flag);
       extended_number_of_returns = other.number_of_returns;
       extended_return_number = other.return_number;
       extended_scan_angle = I16_QUANTIZE(((F32)other.scan_angle_rank)/0.006);
@@ -554,7 +558,7 @@ public:
   inline I8 get_scan_angle_rank() const { return scan_angle_rank; };
   inline U8 get_user_data() const { return user_data; };
   inline U16 get_point_source_ID() const { return point_source_ID; };
-  inline U32 get_deleted_flag() const { return deleted_flag; };
+  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 U16 get_R() const { return rgb[0]; };
@@ -578,7 +582,7 @@ public:
   inline void set_scan_angle_rank(I8 scan_angle_rank) { this->scan_angle_rank = scan_angle_rank; };
   inline void set_user_data(U8 user_data) { this->user_data = user_data; };
   inline void set_point_source_ID(U16 point_source_ID) { this->point_source_ID = point_source_ID; };
-  inline void set_deleted_flag(U8 deleted_flag) { this->deleted_flag = (U32)deleted_flag; };
+  inline void set_deleted_flag(U8 deleted_flag) { this->deleted_flag = deleted_flag; };
   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); };
@@ -596,6 +600,8 @@ public:
   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 is_extended_point_type() const { return extended_point_type; };
+
   inline U8 get_extended_classification() const { return extended_classification; };
   inline U8 get_extended_return_number() const { return extended_return_number; };
   inline U8 get_extended_number_of_returns() const { return extended_number_of_returns; };
@@ -613,6 +619,8 @@ public:
   inline F32 get_scan_angle() const { if (extended_point_type) return 0.006f*extended_scan_angle; else return (F32)scan_angle_rank; };
   inline F32 get_abs_scan_angle() const { if (extended_point_type) return (extended_scan_angle < 0 ? -0.006f*extended_scan_angle : 0.006f*extended_scan_angle) ; else return (scan_angle_rank < 0 ? (F32)-scan_angle_rank : (F32)scan_angle_rank); };
 
+  inline void set_scan_angle(F32 scan_angle) { if (extended_point_type) set_extended_scan_angle(I16_QUANTIZE(scan_angle/0.006f)); else set_scan_angle_rank(I8_QUANTIZE(scan_angle)); };
+
   inline void compute_coordinates()
   {
     coordinates[0] = get_x();
@@ -636,11 +644,11 @@ public:
 
   // generic functions for attributes in extra bytes
 
-  inline BOOL has_attribute(I32 index) const
+  inline BOOL has_attribute(U32 index) const
   {
     if (attributer)
     {
-      if (index < attributer->number_attributes)
+      if (((I32)index) < attributer->number_attributes)
       {
         return TRUE;
       }
@@ -648,7 +656,7 @@ public:
     return FALSE;
   };
 
-  inline BOOL get_attribute(I32 index, U8* data) const
+  inline BOOL get_attribute(U32 index, U8* data) const
   {
     if (has_attribute(index))
     {
@@ -658,7 +666,7 @@ public:
     return FALSE;
   };
 
-  inline BOOL set_attribute(I32 index, const U8* data) 
+  inline BOOL set_attribute(U32 index, const U8* data) 
   {
     if (has_attribute(index))
     {
@@ -668,7 +676,7 @@ public:
     return FALSE;
   };
 
-  inline const CHAR* get_attribute_name(I32 index) const
+  inline const CHAR* get_attribute_name(U32 index) const
   {
     if (has_attribute(index))
     {
@@ -677,7 +685,7 @@ public:
     return 0;
   };
 
-  inline F64 get_attribute_as_float(I32 index) const
+  inline F64 get_attribute_as_float(U32 index) const
   {
     if (has_attribute(index))
     {


=====================================
src/lasreaditemcompressed_v3.cpp
=====================================
@@ -59,7 +59,13 @@ typedef struct LASpoint14
   U8 return_number : 4;
   U8 number_of_returns : 4;
 
-  U8 dummy[3]; // for 8 byte alignment of the GPS time
+  // LASlib internal use only
+  U8 deleted_flag;
+
+  // for 8 byte alignment of the GPS time
+  U8 dummy[2];
+
+  // compressed LASzip 1.4 points only
   BOOL gps_time_change;
 
   F64 gps_time;


=====================================
src/lasreaditemcompressed_v4.cpp
=====================================
@@ -59,7 +59,13 @@ typedef struct LASpoint14
   U8 return_number : 4;
   U8 number_of_returns : 4;
 
-  U8 dummy[3]; // for 8 byte alignment of the GPS time
+  // LASlib internal use only
+  U8 deleted_flag;
+
+  // for 8 byte alignment of the GPS time
+  U8 dummy[2];
+
+  // compressed LASzip 1.4 points only
   BOOL gps_time_change;
 
   F64 gps_time;


=====================================
src/lasreaditemraw.hpp
=====================================
@@ -1,12 +1,12 @@
-/*
-===============================================================================
-
-  FILE:  lasitemreadraw.hpp
-  
-  CONTENTS:
-  
-    Implementation of LASitemReadRaw for *all* items that compose a point.
-
+/*
+===============================================================================
+
+  FILE:  lasitemreadraw.hpp
+  
+  CONTENTS:
+  
+    Implementation of LASitemReadRaw for *all* items that compose a point.
+
   PROGRAMMERS:
 
     martin.isenburg at rapidlasso.com  -  http://rapidlasso.com
@@ -27,16 +27,16 @@
     28 August 2017 -- moving 'context' from global development hack to interface  
     10 January 2011 -- licensing change for LGPL release and liblas integration
     7 December 2010 -- refactored after getting invited to KAUST in Saudi Arabia
-  
-===============================================================================
-*/
-#ifndef LAS_READ_ITEM_RAW_HPP
-#define LAS_READ_ITEM_RAW_HPP
-
-#include "lasreaditem.hpp"
+  
+===============================================================================
+*/
+#ifndef LAS_READ_ITEM_RAW_HPP
+#define LAS_READ_ITEM_RAW_HPP
+
+#include "lasreaditem.hpp"
 
 #include <assert.h>
-
+
 class LASreadItemRaw_POINT10_LE : public LASreadItemRaw
 {
 public:
@@ -47,8 +47,8 @@ public:
   }
 };
 
-class LASreadItemRaw_POINT10_BE : public LASreadItemRaw
-{
+class LASreadItemRaw_POINT10_BE : public LASreadItemRaw
+{
 public:
   LASreadItemRaw_POINT10_BE(){};
   inline void read(U8* item, U32& context)
@@ -63,7 +63,7 @@ public:
   };
 private:
   U8 swapped[20];
-};
+};
 
 class LASreadItemRaw_GPSTIME11_LE : public LASreadItemRaw
 {
@@ -243,7 +243,7 @@ public:
     }
     ((LAStempReadPoint10*)item)->scan_direction_flag = ((LAStempReadPoint14*)buffer)->scan_direction_flag;
     ((LAStempReadPoint10*)item)->edge_of_flight_line = ((LAStempReadPoint14*)buffer)->edge_of_flight_line;
-    ((LAStempReadPoint10*)item)->classification = (((LAStempReadPoint14*)buffer)->classification_flags << 5);
+    ((LAStempReadPoint10*)item)->classification = (U8)(((((LAStempReadPoint14*)buffer)->classification_flags) << 5) & 0xE0);
     if (((LAStempReadPoint14*)buffer)->classification < 32) ((LAStempReadPoint10*)item)->classification |= ((LAStempReadPoint14*)buffer)->classification;
     ((LAStempReadPoint10*)item)->scan_angle_rank = I8_CLAMP(I16_QUANTIZE(0.006f*((LAStempReadPoint14*)buffer)->scan_angle));
     ((LAStempReadPoint10*)item)->user_data = ((LAStempReadPoint14*)buffer)->user_data;
@@ -340,4 +340,4 @@ private:
   U8 swapped[8];
 };
 
-#endif
+#endif


=====================================
src/laswriteitemcompressed_v3.cpp
=====================================
@@ -68,7 +68,13 @@ typedef struct LASpoint14
   U8 return_number : 4;
   U8 number_of_returns : 4;
 
-  U8 dummy[3]; // for 8 byte alignment of the GPS time
+  // LASlib internal use only
+  U8 deleted_flag;
+
+  // for 8 byte alignment of the GPS time
+  U8 dummy[2];
+
+  // compressed LASzip 1.4 points only
   BOOL gps_time_change;
 
   F64 gps_time;


=====================================
src/laswriteitemcompressed_v4.cpp
=====================================
@@ -68,7 +68,13 @@ typedef struct LASpoint14
   U8 return_number : 4;
   U8 number_of_returns : 4;
 
-  U8 dummy[3]; // for 8 byte alignment of the GPS time
+  // LASlib internal use only
+  U8 deleted_flag;
+
+  // for 8 byte alignment of the GPS time
+  U8 dummy[2];
+
+  // compressed LASzip 1.4 points only
   BOOL gps_time_change;
 
   F64 gps_time;


=====================================
src/laswriteitemraw.hpp
=====================================
@@ -1,19 +1,19 @@
-/*
-===============================================================================
-
-  FILE:  laswriteitemraw.hpp
-  
-  CONTENTS:
-  
-    Implementation of LASwriteItemRaw for *all* items that compose a point.
-
+/*
+===============================================================================
+
+  FILE:  laswriteitemraw.hpp
+  
+  CONTENTS:
+  
+    Implementation of LASwriteItemRaw for *all* items that compose a point.
+
   PROGRAMMERS:
 
     martin.isenburg at rapidlasso.com  -  http://rapidlasso.com
 
   COPYRIGHT:
 
-    (c) 2007-2017, martin isenburg, rapidlasso - fast tools to catch reality
+    (c) 2007-2018, 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,17 +24,18 @@
   
   CHANGE HISTORY:
   
+    29 September 2018 -- fix: extended_classification when classification not set 
     28 August 2017 -- moving 'context' from global development hack to interface  
     10 January 2011 -- licensing change for LGPL release and liblas integration
     7 January 2011 -- introduced swap buffers to reduce number of fwrite calls
     12 December 2010 -- refactored after watching two movies with silke
-  
-===============================================================================
-*/
-#ifndef LAS_WRITE_ITEM_RAW_HPP
-#define LAS_WRITE_ITEM_RAW_HPP
-
-#include "laswriteitem.hpp"
+  
+===============================================================================
+*/
+#ifndef LAS_WRITE_ITEM_RAW_HPP
+#define LAS_WRITE_ITEM_RAW_HPP
+
+#include "laswriteitem.hpp"
 
 #include <assert.h>
 
@@ -65,7 +66,7 @@ public:
 private:
   U8 swapped[20];
 };
-
+
 class LASwriteItemRaw_GPSTIME11_LE : public LASwriteItemRaw
 {
 public:
@@ -230,7 +231,7 @@ public:
     if (((LAStempWritePoint10*)item)->extended_point_type)
     {
       ((LAStempWritePoint14*)buffer)->classification_flags = (((LAStempWritePoint10*)item)->extended_classification_flags & 8) | (((LAStempWritePoint10*)item)->classification >> 5);
-      if (((LAStempWritePoint10*)item)->extended_classification > 31) ((LAStempWritePoint14*)buffer)->classification = ((LAStempWritePoint10*)item)->extended_classification;
+      if (((LAStempWritePoint14*)buffer)->classification == 0) ((LAStempWritePoint14*)buffer)->classification = ((LAStempWritePoint10*)item)->extended_classification;
       ((LAStempWritePoint14*)buffer)->scanner_channel = ((LAStempWritePoint10*)item)->extended_scanner_channel;
       ((LAStempWritePoint14*)buffer)->return_number = ((LAStempWritePoint10*)item)->extended_return_number;
       ((LAStempWritePoint14*)buffer)->number_of_returns = ((LAStempWritePoint10*)item)->extended_number_of_returns;
@@ -271,7 +272,7 @@ public:
     if (((LAStempWritePoint10*)item)->extended_point_type)
     {
       ((LAStempWritePoint14*)swapped)->classification_flags = (((LAStempWritePoint10*)item)->extended_classification_flags & 8) | (((LAStempWritePoint10*)item)->classification >> 5);
-      if (((LAStempWritePoint10*)item)->extended_classification > 31) ((LAStempWritePoint14*)swapped)->classification = ((LAStempWritePoint10*)item)->extended_classification;
+      if (((LAStempWritePoint14*)swapped)->classification == 0) ((LAStempWritePoint14*)swapped)->classification = ((LAStempWritePoint10*)item)->extended_classification;
       ((LAStempWritePoint14*)swapped)->scanner_channel = ((LAStempWritePoint10*)item)->extended_scanner_channel;
       ((LAStempWritePoint14*)swapped)->return_number = ((LAStempWritePoint10*)item)->extended_return_number;
       ((LAStempWritePoint14*)swapped)->number_of_returns = ((LAStempWritePoint10*)item)->extended_number_of_returns;
@@ -319,4 +320,4 @@ private:
   U8 swapped[8];
 };
 
-#endif
+#endif


=====================================
src/laszip.hpp
=====================================
@@ -25,21 +25,25 @@
 
   CHANGE HISTORY:
 
-    9 February 2018 -- minor version increment as it can read v4 compressed items
+     7 November 2018 -- upped to 3.2 r8 for identical legacy and extended flags check
+    20 October 2018 -- upped to 3.2 r7 for rare bug in LASinterval::merge_intervals()
+     5 October 2018 -- upped to 3.2 r6 for corrected 'is_empty' return value
+    28 September 2018 -- upped to 3.2 r5 for fix in extended classification writing 
+     9 February 2018 -- minor version increment as it can read v4 compressed items
     28 December 2017 -- fix incorrect 'context switch' reported by Wanwannodao
     23 August 2017 -- minor version increment for C++ stream-based read/write API
     28 May 2017 -- support for "LAS 1.4 selective decompression" added into DLL API
-    8 April 2017 -- new check for whether point size and total size of items match
+     8 April 2017 -- new check for whether point size and total size of items match
     30 March 2017 -- support for "native LAS 1.4 extension" added into main branch
-    7 January 2017 -- set reserved VLR field from 0xAABB to 0x0 in DLL
-    7 January 2017 -- consistent compatibility mode scan angle quantization in DLL
-    7 January 2017 -- compatibility mode *decompression* fix for waveforms in DLL
+     7 January 2017 -- set reserved VLR field from 0xAABB to 0x0 in DLL
+     7 January 2017 -- consistent compatibility mode scan angle quantization in DLL
+     7 January 2017 -- compatibility mode *decompression* fix for waveforms in DLL
     25 February 2016 -- depreciating old libLAS laszipper/lasunzipper binding
     29 July 2013 -- reorganized to create an easy-to-use LASzip DLL
-    5 December 2011 -- learns the chunk table if it is missing (e.g. truncated LAZ)
-    6 October 2011 -- large file support, ability to read with missing chunk table
+     5 December 2011 -- learns the chunk table if it is missing (e.g. truncated LAZ)
+     6 October 2011 -- large file support, ability to read with missing chunk table
     23 June 2011 -- turned on LASzip version 2.0 compressor with chunking
-    8 May 2011 -- added an option for variable chunking via chunk()
+     8 May 2011 -- added an option for variable chunking via chunk()
     23 April 2011 -- changed interface for simplicity and chunking support
     20 March 2011 -- incrementing LASZIP_VERSION to 1.2 for improved compression
     10 January 2011 -- licensing change for LGPL release and liblas integration
@@ -66,8 +70,8 @@ typedef long long SIGNED_INT64;
 
 #define LASZIP_VERSION_MAJOR                3
 #define LASZIP_VERSION_MINOR                2
-#define LASZIP_VERSION_REVISION             2
-#define LASZIP_VERSION_BUILD_DATE      180327
+#define LASZIP_VERSION_REVISION             8
+#define LASZIP_VERSION_BUILD_DATE      181107
 
 #define LASZIP_COMPRESSOR_NONE              0
 #define LASZIP_COMPRESSOR_POINTWISE         1


=====================================
src/laszip_decompress_selective_v3.hpp
=====================================
@@ -53,6 +53,6 @@
 #define LASZIP_DECOMPRESS_SELECTIVE_BYTE5              0x00200000
 #define LASZIP_DECOMPRESS_SELECTIVE_BYTE6              0x00400000
 #define LASZIP_DECOMPRESS_SELECTIVE_BYTE7              0x00800000
-#define LASZIP_DECOMPRESS_SELECTIVE_EXTRA_BYTES        0xFFF00000
+#define LASZIP_DECOMPRESS_SELECTIVE_EXTRA_BYTES        0xFFFF0000
 
 #endif // LASZIP_DECOMPRESS_SELECTIVE_V3_HPP


=====================================
src/laszip_dll.cpp
=====================================
@@ -24,14 +24,21 @@
 
   CHANGE HISTORY:
 
-   30 August 2017 -- completing stream-based writing (with writing LAS header)
-   23 August 2017 -- turn on "native" by default
-    3 August 2017 -- new 'laszip_create_laszip_vlr()' gets VLR as C++ std::vector
-   29 July 2017 -- integrating minimal stream-based reading/writing into branch
-   20 July 2017 -- Andrew Bell adds support for stream-based reading/writing
-   28 May 2017 -- support for "LAS 1.4 selective decompression" added into DLL API
-   25 April 2017 -- adding initial support for new "native LAS 1.4 extension"
-    8 January 2017 -- changed from "laszip_dll.h" to "laszip_api.h" for hobu
+     7 November 2018 -- assure identical legacy and extended flags in laszip_write_point()
+    20 October 2018 -- changed (U8*) to (const U8*) for all out->put___() calls
+     5 October 2018 -- corrected 'is_empty' return value in laszip_inside_rectangle()
+    29 September 2018 -- laszip_prepare_point_for_write() sets extended_point_type 
+    19 September 2018 -- removed tuples and triple support from attributes
+     7 September 2018 -- replaced calls to _strdup with calls to the LASCopyString macro
+     6 April 2018 -- added zero() function to laszip_dll struct to fix memory leak
+    30 August 2017 -- completing stream-based writing (with writing LAS header)
+    23 August 2017 -- turn on "native" by default
+     3 August 2017 -- new 'laszip_create_laszip_vlr()' gets VLR as C++ std::vector
+    29 July 2017 -- integrating minimal stream-based reading/writing into branch
+    20 July 2017 -- Andrew Bell adds support for stream-based reading/writing
+    28 May 2017 -- support for "LAS 1.4 selective decompression" added into DLL API
+    25 April 2017 -- adding initial support for new "native LAS 1.4 extension"
+     8 January 2017 -- changed from "laszip_dll.h" to "laszip_api.h" for hobu
 
 ===============================================================================
 */
@@ -148,6 +155,44 @@ typedef struct laszip_dll {
   I32 start_NIR_band;
   laszip_dll_inventory* inventory;
   std::vector<void *> buffers;
+
+  void zero()
+  {
+    memset(&header, 0, sizeof(laszip_header_struct));
+    p_count = 0;
+    npoints = 0;
+    memset(&point, 0, sizeof(laszip_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;
+  };
 } laszip_dll_struct;
 
 /*---------------------------------------------------------------------------*/
@@ -236,9 +281,9 @@ laszip_create(
       return 1;
     }
 
-    // zero everything
+    // zero every field of the laszip_dll struct
 
-    memset(laszip_dll, 0, sizeof(laszip_dll_struct));
+    laszip_dll->zero();
 
     // create the default
 
@@ -313,6 +358,38 @@ laszip_clean(
       laszip_dll->point.extra_bytes = 0;
     }
 
+    // dealloc point items although close_reader() / close_writer() call should have done this already
+
+    if (laszip_dll->point_items)
+    {
+      delete [] laszip_dll->point_items;
+      laszip_dll->point_items = 0;
+    }
+
+    // close file although close_reader() / close_writer() call should have done this already
+
+    if (laszip_dll->file)
+    {
+      fclose(laszip_dll->file);
+      laszip_dll->file = 0;
+    }
+
+    // dealloc streamin although close_reader() call should have done this already
+
+    if (laszip_dll->streamin)
+    {
+      delete laszip_dll->streamin;
+      laszip_dll->streamin = 0;
+    }
+
+    // dealloc streamout although close_writer() call should have done this already
+
+    if (laszip_dll->streamout)
+    {
+      delete laszip_dll->streamout;
+      laszip_dll->streamout = 0;
+    }
+
     // dealloc the attributer
 
     if (laszip_dll->attributer)
@@ -321,14 +398,44 @@ laszip_clean(
       laszip_dll->attributer = 0;
     }
 
-    for (size_t i = 0; i < laszip_dll->buffers.size(); ++i)
-        free(laszip_dll->buffers[i]);
-    laszip_dll->buffers.clear();
+    // dealloc lax_index although close_reader() / close_writer() call should have done this already
+
+    if (laszip_dll->lax_index)
+    {
+      delete laszip_dll->lax_index;
+      laszip_dll->lax_index = 0;
+    }
+
+    // dealloc lax_file_name although close_writer() call should have done this already
+
+    if (laszip_dll->lax_file_name)
+    {
+      free(laszip_dll->lax_file_name);
+      laszip_dll->lax_file_name = 0;
+    }
+
+    // dealloc the inventory although close_writer() call should have done this already
+
+    if (laszip_dll->inventory == 0)
+    {
+      delete laszip_dll->inventory;
+      laszip_dll->inventory = 0;
+    }
+
+    // dealloc any data fields that were kept around in memory for others
 
+    if (laszip_dll->buffers.size())
+    {
+      for (size_t i = 0; i < laszip_dll->buffers.size(); i++)
+      {
+        free(laszip_dll->buffers[i]);
+      }
+      laszip_dll->buffers.clear();
+    }
 
-    // zero everything
+    // zero every field of the laszip_dll struct
 
-    memset(laszip_dll, 0, sizeof(laszip_dll_struct));
+    laszip_dll->zero();
 
     // create default header
 
@@ -505,7 +612,7 @@ laszip_set_header(
       return 1;
     }
 
-    // clean the attributer if needed
+    // dealloc the attributer (if needed)
 
     if (laszip_dll->attributer)
     {
@@ -1259,8 +1366,8 @@ laszip_add_attribute(
     }
 
     LASattribute lasattribute(type, name, description);
-    lasattribute.set_scale(scale, 0);
-    lasattribute.set_offset(offset, 0);
+    lasattribute.set_scale(scale);
+    lasattribute.set_offset(offset);
 
     if (laszip_dll->attributer == 0)
     {
@@ -1568,6 +1675,11 @@ laszip_request_native_extension(
     }
 
     laszip_dll->request_native_extension = request;
+
+    if (request) // only one should be on
+    {
+      laszip_dll->request_compatibility_mode = FALSE;
+    }
   }
   catch (...)
   {
@@ -1604,6 +1716,11 @@ laszip_request_compatibility_mode(
     }
 
     laszip_dll->request_compatibility_mode = request;
+
+    if (request) // only one should be on
+    {
+      laszip_dll->request_native_extension = FALSE;
+    }
   }
   catch (...)
   {
@@ -1775,13 +1892,22 @@ laszip_prepare_point_for_write(
 
   if (laszip_dll->header.point_data_format > 5)
   {
+    // must be set for the new point types 6 or higher ...
+
+    laszip_dll->point.extended_point_type = 1;
+
     if (laszip_dll->request_native_extension)
     {
       // we are *not* operating in compatibility mode
+
       laszip_dll->compatibility_mode = FALSE;
     }
     else if (laszip_dll->request_compatibility_mode)
     {
+      // we are *not* using the native extension
+
+      laszip_dll->request_native_extension = FALSE;
+
       // make sure there are no more than U32_MAX points
 
       if (laszip_dll->header.extended_number_of_point_records > U32_MAX)
@@ -1982,7 +2108,7 @@ laszip_prepare_point_for_write(
 
       // 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, 0);
+      lasattribute_scan_angle.set_scale(0.006);
       I32 index_scan_angle = laszip_dll->attributer->add_attribute(lasattribute_scan_angle);
       laszip_dll->start_scan_angle = laszip_dll->attributer->get_attribute_start(index_scan_angle);
       // extended returns stored as a U8
@@ -2044,7 +2170,12 @@ laszip_prepare_point_for_write(
   }
   else
   {
+    // must *not* be set for the old point type 5 or lower
+
+    laszip_dll->point.extended_point_type = 0;
+    
     // we are *not* operating in compatibility mode
+
     laszip_dll->compatibility_mode = FALSE;
   }
 
@@ -2171,52 +2302,52 @@ write_laszip_vlr_payload(
   //        U16 version             2 bytes * num_items
   // which totals 34+6*num_items
 
-  try { out->put16bitsLE((U8*)&(laszip->compressor)); } catch(...)
+  try { out->put16bitsLE((const U8*)&(laszip->compressor)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing compressor %d", (I32)laszip->compressor);
     return 1;
   }
-  try { out->put16bitsLE((U8*)&(laszip->coder)); } catch(...)
+  try { out->put16bitsLE((const U8*)&(laszip->coder)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing coder %d", (I32)laszip->coder);
     return 1;
   }
-  try { out->putBytes((U8*)&(laszip->version_major), 1); } catch(...)
+  try { out->putBytes((const U8*)&(laszip->version_major), 1); } catch(...)
   {
     sprintf(laszip_dll->error, "writing version_major %d", (I32)laszip->version_major);
     return 1;
   }
-  try { out->putBytes((U8*)&(laszip->version_minor), 1); } catch(...)
+  try { out->putBytes((const U8*)&(laszip->version_minor), 1); } catch(...)
   {
     sprintf(laszip_dll->error, "writing version_minor %d", (I32)laszip->version_minor);
     return 1;
   }
-  try { out->put16bitsLE((U8*)&(laszip->version_revision)); } catch(...)
+  try { out->put16bitsLE((const U8*)&(laszip->version_revision)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing version_revision %d", (I32)laszip->version_revision);
     return 1;
   }
-  try { out->put32bitsLE((U8*)&(laszip->options)); } catch(...)
+  try { out->put32bitsLE((const U8*)&(laszip->options)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing options %u", laszip->options);
     return 1;
   }
-  try { out->put32bitsLE((U8*)&(laszip->chunk_size)); } catch(...)
+  try { out->put32bitsLE((const U8*)&(laszip->chunk_size)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing chunk_size %u", laszip->chunk_size);
     return 1;
   }
-  try { out->put64bitsLE((U8*)&(laszip->number_of_special_evlrs)); } catch(...)
+  try { out->put64bitsLE((const U8*)&(laszip->number_of_special_evlrs)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing number_of_special_evlrs %d", (I32)laszip->number_of_special_evlrs);
     return 1;
   }
-  try { out->put64bitsLE((U8*)&(laszip->offset_to_special_evlrs)); } catch(...)
+  try { out->put64bitsLE((const U8*)&(laszip->offset_to_special_evlrs)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing offset_to_special_evlrs %d", (I32)laszip->offset_to_special_evlrs);
     return 1;
   }
-  try { out->put16bitsLE((U8*)&(laszip->num_items)); } catch(...)
+  try { out->put16bitsLE((const U8*)&(laszip->num_items)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing num_items %d", (I32)laszip->num_items);
     return 1;
@@ -2226,17 +2357,17 @@ write_laszip_vlr_payload(
   for (j = 0; j < laszip->num_items; j++)
   {
     U16 type = (U16)(laszip->items[j].type);
-    try { out->put16bitsLE((U8*)&type); } catch(...)
+    try { out->put16bitsLE((const U8*)&type); } catch(...)
     {
       sprintf(laszip_dll->error, "writing type %d of item %d", (I32)laszip->items[j].type, j);
       return 1;
     }
-    try { out->put16bitsLE((U8*)&(laszip->items[j].size)); } catch(...)
+    try { out->put16bitsLE((const U8*)&(laszip->items[j].size)); } catch(...)
     {
       sprintf(laszip_dll->error, "writing size %d of item %d", (I32)laszip->items[j].size, j);
       return 1;
     }
-    try { out->put16bitsLE((U8*)&(laszip->items[j].version)); } catch(...)
+    try { out->put16bitsLE((const U8*)&(laszip->items[j].version)); } catch(...)
     {
       sprintf(laszip_dll->error, "writing version %d of item %d", (I32)laszip->items[j].version, j);
       return 1;
@@ -2255,52 +2386,52 @@ laszip_write_header(
 {
   U32 i;
 
-  try { laszip_dll->streamout->putBytes((U8*)"LASF", 4); } catch(...)
+  try { laszip_dll->streamout->putBytes((const U8*)"LASF", 4); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.file_signature");
     return 1;
   }
-  try { laszip_dll->streamout->put16bitsLE((U8*)&(laszip_dll->header.file_source_ID)); } catch(...)
+  try { laszip_dll->streamout->put16bitsLE((const U8*)&(laszip_dll->header.file_source_ID)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.file_source_ID");
     return 1;
   }
-  try { laszip_dll->streamout->put16bitsLE((U8*)&(laszip_dll->header.global_encoding)); } catch(...)
+  try { laszip_dll->streamout->put16bitsLE((const U8*)&(laszip_dll->header.global_encoding)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.global_encoding");
     return 1;
   }
-  try { laszip_dll->streamout->put32bitsLE((U8*)&(laszip_dll->header.project_ID_GUID_data_1)); } catch(...)
+  try { laszip_dll->streamout->put32bitsLE((const U8*)&(laszip_dll->header.project_ID_GUID_data_1)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.project_ID_GUID_data_1");
     return 1;
   }
-  try { laszip_dll->streamout->put16bitsLE((U8*)&(laszip_dll->header.project_ID_GUID_data_2)); } catch(...)
+  try { laszip_dll->streamout->put16bitsLE((const U8*)&(laszip_dll->header.project_ID_GUID_data_2)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.project_ID_GUID_data_2");
     return 1;
   }
-  try { laszip_dll->streamout->put16bitsLE((U8*)&(laszip_dll->header.project_ID_GUID_data_3)); } catch(...)
+  try { laszip_dll->streamout->put16bitsLE((const U8*)&(laszip_dll->header.project_ID_GUID_data_3)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.project_ID_GUID_data_3");
     return 1;
   }
-  try { laszip_dll->streamout->putBytes((U8*)laszip_dll->header.project_ID_GUID_data_4, 8); } catch(...)
+  try { laszip_dll->streamout->putBytes((const U8*)laszip_dll->header.project_ID_GUID_data_4, 8); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.project_ID_GUID_data_4");
     return 1;
   }
-  try { laszip_dll->streamout->putBytes((U8*)&(laszip_dll->header.version_major), 1); } catch(...)
+  try { laszip_dll->streamout->putBytes((const U8*)&(laszip_dll->header.version_major), 1); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.version_major");
     return 1;
   }
-  try { laszip_dll->streamout->putBytes((U8*)&(laszip_dll->header.version_minor), 1); } catch(...)
+  try { laszip_dll->streamout->putBytes((const U8*)&(laszip_dll->header.version_minor), 1); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.version_minor");
     return 1;
   }
-  try { laszip_dll->streamout->putBytes((U8*)laszip_dll->header.system_identifier, 32); } catch(...)
+  try { laszip_dll->streamout->putBytes((const U8*)laszip_dll->header.system_identifier, 32); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.system_identifier");
     return 1;
@@ -2310,22 +2441,22 @@ laszip_write_header(
     memset(laszip_dll->header.generating_software, 0, 32);
     sprintf(laszip_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 { laszip_dll->streamout->putBytes((U8*)laszip_dll->header.generating_software, 32); } catch(...)
+  try { laszip_dll->streamout->putBytes((const U8*)laszip_dll->header.generating_software, 32); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.generating_software");
     return 1;
   }
-  try { laszip_dll->streamout->put16bitsLE((U8*)&(laszip_dll->header.file_creation_day)); } catch(...)
+  try { laszip_dll->streamout->put16bitsLE((const U8*)&(laszip_dll->header.file_creation_day)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.file_creation_day");
     return 1;
   }
-  try { laszip_dll->streamout->put16bitsLE((U8*)&(laszip_dll->header.file_creation_year)); } catch(...)
+  try { laszip_dll->streamout->put16bitsLE((const U8*)&(laszip_dll->header.file_creation_year)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.file_creation_year");
     return 1;
   }
-  try { laszip_dll->streamout->put16bitsLE((U8*)&(laszip_dll->header.header_size)); } catch(...)
+  try { laszip_dll->streamout->put16bitsLE((const U8*)&(laszip_dll->header.header_size)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.header_size");
     return 1;
@@ -2334,7 +2465,7 @@ laszip_write_header(
   {
     laszip_dll->header.offset_to_point_data += (54 + laszip_vrl_payload_size(laszip));
   }
-  try { laszip_dll->streamout->put32bitsLE((U8*)&(laszip_dll->header.offset_to_point_data)); } catch(...)
+  try { laszip_dll->streamout->put32bitsLE((const U8*)&(laszip_dll->header.offset_to_point_data)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.offset_to_point_data");
     return 1;
@@ -2344,7 +2475,7 @@ laszip_write_header(
     laszip_dll->header.offset_to_point_data -= (54 + laszip_vrl_payload_size(laszip));
     laszip_dll->header.number_of_variable_length_records += 1;
   }
-  try { laszip_dll->streamout->put32bitsLE((U8*)&(laszip_dll->header.number_of_variable_length_records)); } catch(...)
+  try { laszip_dll->streamout->put32bitsLE((const U8*)&(laszip_dll->header.number_of_variable_length_records)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.number_of_variable_length_records");
     return 1;
@@ -2354,7 +2485,7 @@ laszip_write_header(
     laszip_dll->header.number_of_variable_length_records -= 1;
     laszip_dll->header.point_data_format |= 128;
   }
-  try { laszip_dll->streamout->putBytes((U8*)&(laszip_dll->header.point_data_format), 1); } catch(...)
+  try { laszip_dll->streamout->putBytes((const U8*)&(laszip_dll->header.point_data_format), 1); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.point_data_format");
     return 1;
@@ -2363,80 +2494,80 @@ laszip_write_header(
   {
     laszip_dll->header.point_data_format &= 127;
   }
-  try { laszip_dll->streamout->put16bitsLE((U8*)&(laszip_dll->header.point_data_record_length)); } catch(...)
+  try { laszip_dll->streamout->put16bitsLE((const U8*)&(laszip_dll->header.point_data_record_length)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.point_data_record_length");
     return 1;
   }
-  try { laszip_dll->streamout->put32bitsLE((U8*)&(laszip_dll->header.number_of_point_records)); } catch(...)
+  try { laszip_dll->streamout->put32bitsLE((const U8*)&(laszip_dll->header.number_of_point_records)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.number_of_point_records");
     return 1;
   }
   for (i = 0; i < 5; i++)
   {
-    try { laszip_dll->streamout->put32bitsLE((U8*)&(laszip_dll->header.number_of_points_by_return[i])); } catch(...)
+    try { laszip_dll->streamout->put32bitsLE((const U8*)&(laszip_dll->header.number_of_points_by_return[i])); } catch(...)
     {
       sprintf(laszip_dll->error, "writing header.number_of_points_by_return %d", i);
       return 1;
     }
   }
-  try { laszip_dll->streamout->put64bitsLE((U8*)&(laszip_dll->header.x_scale_factor)); } catch(...)
+  try { laszip_dll->streamout->put64bitsLE((const U8*)&(laszip_dll->header.x_scale_factor)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.x_scale_factor");
     return 1;
   }
-  try { laszip_dll->streamout->put64bitsLE((U8*)&(laszip_dll->header.y_scale_factor)); } catch(...)
+  try { laszip_dll->streamout->put64bitsLE((const U8*)&(laszip_dll->header.y_scale_factor)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.y_scale_factor");
     return 1;
   }
-  try { laszip_dll->streamout->put64bitsLE((U8*)&(laszip_dll->header.z_scale_factor)); } catch(...)
+  try { laszip_dll->streamout->put64bitsLE((const U8*)&(laszip_dll->header.z_scale_factor)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.z_scale_factor");
     return 1;
   }
-  try { laszip_dll->streamout->put64bitsLE((U8*)&(laszip_dll->header.x_offset)); } catch(...)
+  try { laszip_dll->streamout->put64bitsLE((const U8*)&(laszip_dll->header.x_offset)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.x_offset");
     return 1;
   }
-  try { laszip_dll->streamout->put64bitsLE((U8*)&(laszip_dll->header.y_offset)); } catch(...)
+  try { laszip_dll->streamout->put64bitsLE((const U8*)&(laszip_dll->header.y_offset)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.y_offset");
     return 1;
   }
-  try { laszip_dll->streamout->put64bitsLE((U8*)&(laszip_dll->header.z_offset)); } catch(...)
+  try { laszip_dll->streamout->put64bitsLE((const U8*)&(laszip_dll->header.z_offset)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.z_offset");
     return 1;
   }
-  try { laszip_dll->streamout->put64bitsLE((U8*)&(laszip_dll->header.max_x)); } catch(...)
+  try { laszip_dll->streamout->put64bitsLE((const U8*)&(laszip_dll->header.max_x)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.max_x");
     return 1;
   }
-  try { laszip_dll->streamout->put64bitsLE((U8*)&(laszip_dll->header.min_x)); } catch(...)
+  try { laszip_dll->streamout->put64bitsLE((const U8*)&(laszip_dll->header.min_x)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.min_x");
     return 1;
   }
-  try { laszip_dll->streamout->put64bitsLE((U8*)&(laszip_dll->header.max_y)); } catch(...)
+  try { laszip_dll->streamout->put64bitsLE((const U8*)&(laszip_dll->header.max_y)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.max_y");
     return 1;
   }
-  try { laszip_dll->streamout->put64bitsLE((U8*)&(laszip_dll->header.min_y)); } catch(...)
+  try { laszip_dll->streamout->put64bitsLE((const U8*)&(laszip_dll->header.min_y)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.min_y");
     return 1;
   }
-  try { laszip_dll->streamout->put64bitsLE((U8*)&(laszip_dll->header.max_z)); } catch(...)
+  try { laszip_dll->streamout->put64bitsLE((const U8*)&(laszip_dll->header.max_z)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.max_z");
     return 1;
   }
-  try { laszip_dll->streamout->put64bitsLE((U8*)&(laszip_dll->header.min_z)); } catch(...)
+  try { laszip_dll->streamout->put64bitsLE((const U8*)&(laszip_dll->header.min_z)); } catch(...)
   {
     sprintf(laszip_dll->error, "writing header.min_z");
     return 1;
@@ -2461,7 +2592,7 @@ laszip_write_header(
 #endif
         laszip_dll->header.start_of_waveform_data_packet_record = 0;
       }
-      try { laszip_dll->streamout->put64bitsLE((U8*)&(laszip_dll->header.start_of_waveform_data_packet_record)); } catch(...)
+      try { laszip_dll->streamout->put64bitsLE((const U8*)&(laszip_dll->header.start_of_waveform_data_packet_record)); } catch(...)
       {
         sprintf(laszip_dll->error, "writing header.start_of_waveform_data_packet_record");
         return 1;
@@ -2484,24 +2615,24 @@ laszip_write_header(
     }
     else
     {
-      try { laszip_dll->streamout->put64bitsLE((U8*)&(laszip_dll->header.start_of_first_extended_variable_length_record)); } catch(...)
+      try { laszip_dll->streamout->put64bitsLE((const U8*)&(laszip_dll->header.start_of_first_extended_variable_length_record)); } catch(...)
       {
         sprintf(laszip_dll->error, "writing header.start_of_first_extended_variable_length_record");
         return 1;
       }
-      try { laszip_dll->streamout->put32bitsLE((U8*)&(laszip_dll->header.number_of_extended_variable_length_records)); } catch(...)
+      try { laszip_dll->streamout->put32bitsLE((const U8*)&(laszip_dll->header.number_of_extended_variable_length_records)); } catch(...)
       {
         sprintf(laszip_dll->error, "writing header.number_of_extended_variable_length_records");
         return 1;
       }
-      try { laszip_dll->streamout->put64bitsLE((U8*)&(laszip_dll->header.extended_number_of_point_records)); } catch(...)
+      try { laszip_dll->streamout->put64bitsLE((const U8*)&(laszip_dll->header.extended_number_of_point_records)); } catch(...)
       {
         sprintf(laszip_dll->error, "writing header.extended_number_of_point_records");
         return 1;
       }
       for (i = 0; i < 15; i++)
       {
-        try { laszip_dll->streamout->put64bitsLE((U8*)&(laszip_dll->header.extended_number_of_points_by_return[i])); } catch(...)
+        try { laszip_dll->streamout->put64bitsLE((const U8*)&(laszip_dll->header.extended_number_of_points_by_return[i])); } catch(...)
         {
           sprintf(laszip_dll->error, "writing header.extended_number_of_points_by_return[%d]", i);
           return 1;
@@ -2514,7 +2645,7 @@ laszip_write_header(
   // write any number of user-defined bytes that might have been added to the header
   if (laszip_dll->header.user_data_in_header_size)
   {
-    try { laszip_dll->streamout->putBytes((U8*)laszip_dll->header.user_data_in_header, laszip_dll->header.user_data_in_header_size); } catch(...)
+    try { laszip_dll->streamout->putBytes((const U8*)laszip_dll->header.user_data_in_header, laszip_dll->header.user_data_in_header_size); } catch(...)
     {
       sprintf(laszip_dll->error, "writing %d bytes of data into header.user_data_in_header", laszip_dll->header.user_data_in_header_size);
       return 1;
@@ -2531,28 +2662,28 @@ laszip_write_header(
     {
       // write variable length records variable after variable (to avoid alignment issues)
 
-      try { laszip_dll->streamout->put16bitsLE((U8*)&(laszip_dll->header.vlrs[i].reserved)); } catch(...)
+      try { laszip_dll->streamout->put16bitsLE((const U8*)&(laszip_dll->header.vlrs[i].reserved)); } catch(...)
       {
         sprintf(laszip_dll->error, "writing header.vlrs[%d].reserved", i);
         return 1;
       }
 
-      try { laszip_dll->streamout->putBytes((U8*)laszip_dll->header.vlrs[i].user_id, 16); } catch(...)
+      try { laszip_dll->streamout->putBytes((const U8*)laszip_dll->header.vlrs[i].user_id, 16); } catch(...)
       {
         sprintf(laszip_dll->error, "writing header.vlrs[%d].user_id", i);
         return 1;
       }
-      try { laszip_dll->streamout->put16bitsLE((U8*)&(laszip_dll->header.vlrs[i].record_id)); } catch(...)
+      try { laszip_dll->streamout->put16bitsLE((const U8*)&(laszip_dll->header.vlrs[i].record_id)); } catch(...)
       {
         sprintf(laszip_dll->error, "writing header.vlrs[%d].record_id", i);
         return 1;
       }
-      try { laszip_dll->streamout->put16bitsLE((U8*)&(laszip_dll->header.vlrs[i].record_length_after_header)); } catch(...)
+      try { laszip_dll->streamout->put16bitsLE((const U8*)&(laszip_dll->header.vlrs[i].record_length_after_header)); } catch(...)
       {
         sprintf(laszip_dll->error, "writing header.vlrs[%d].record_length_after_header", i);
         return 1;
       }
-      try { laszip_dll->streamout->putBytes((U8*)laszip_dll->header.vlrs[i].description, 32); } catch(...)
+      try { laszip_dll->streamout->putBytes((const U8*)laszip_dll->header.vlrs[i].description, 32); } catch(...)
       {
         sprintf(laszip_dll->error, "writing header.vlrs[%d].description", i);
         return 1;
@@ -2592,7 +2723,7 @@ laszip_write_header(
 
   if (laszip_dll->header.user_data_after_header_size)
   {
-    try { laszip_dll->streamout->putBytes((U8*)laszip_dll->header.user_data_after_header, laszip_dll->header.user_data_after_header_size); } catch(...)
+    try { laszip_dll->streamout->putBytes((const U8*)laszip_dll->header.user_data_after_header, laszip_dll->header.user_data_after_header_size); } catch(...)
     {
       sprintf(laszip_dll->error, "writing %u bytes of data into header.user_data_after_header", laszip_dll->header.user_data_after_header_size);
       return 1;
@@ -2857,7 +2988,7 @@ laszip_open_writer(
 
       // copy the file name for later
 
-      laszip_dll->lax_file_name = strdup(file_name);
+      laszip_dll->lax_file_name = LASCopyString(file_name);
     }
 
     // set the point number and point count
@@ -2886,6 +3017,18 @@ laszip_write_point(
 
   try
   {
+    // temporary fix to avoid corrupt LAZ files
+
+    if (laszip_dll->point.extended_point_type)
+    {
+      // make sure legacy flags and extended flags are identical
+      if ((laszip_dll->point.extended_classification_flags & 0x7) != ((((U8*)&(laszip_dll->point.intensity))[3]) >> 5))
+      {
+        sprintf(laszip_dll->error, "legacy flags and extended flags are not identical");
+        return 1;
+      }
+    }
+
     // special recoding of points (in compatibility mode only)
 
     if (laszip_dll->compatibility_mode)
@@ -3015,7 +3158,7 @@ laszip_write_indexed_point(
   }
   catch (...)
   {
-    sprintf(laszip_dll->error, "internal error in laszip_write_point");
+    sprintf(laszip_dll->error, "internal error in laszip_write_indexed_point");
     return 1;
   }
 
@@ -3087,14 +3230,14 @@ laszip_close_writer(
       if (laszip_dll->header.point_data_format <= 5) // only update legacy counters for old point types
       {
         laszip_dll->streamout->seek(107);
-        if (!laszip_dll->streamout->put32bitsLE((U8*)&(laszip_dll->inventory->number_of_point_records)))
+        if (!laszip_dll->streamout->put32bitsLE((const U8*)&(laszip_dll->inventory->number_of_point_records)))
         {
           sprintf(laszip_dll->error, "updating laszip_dll->inventory->number_of_point_records");
           return 1;
         }
         for (I32 i = 0; i < 5; i++)
         {
-          if (!laszip_dll->streamout->put32bitsLE((U8*)&(laszip_dll->inventory->number_of_points_by_return[i+1])))
+          if (!laszip_dll->streamout->put32bitsLE((const U8*)&(laszip_dll->inventory->number_of_points_by_return[i+1])))
           {
             sprintf(laszip_dll->error, "updating laszip_dll->inventory->number_of_points_by_return[%d]\n", i);
             return 1;
@@ -3104,37 +3247,37 @@ laszip_close_writer(
       laszip_dll->streamout->seek(179);
       F64 value;
       value = laszip_dll->header.x_scale_factor*laszip_dll->inventory->max_X+laszip_dll->header.x_offset;
-      if (!laszip_dll->streamout->put64bitsLE((U8*)&value))
+      if (!laszip_dll->streamout->put64bitsLE((const U8*)&value))
       {
         sprintf(laszip_dll->error, "updating laszip_dll->inventory->max_X");
         return 1;
       }
       value = laszip_dll->header.x_scale_factor*laszip_dll->inventory->min_X+laszip_dll->header.x_offset;
-      if (!laszip_dll->streamout->put64bitsLE((U8*)&value))
+      if (!laszip_dll->streamout->put64bitsLE((const U8*)&value))
       {
         sprintf(laszip_dll->error, "updating laszip_dll->inventory->min_X");
         return 1;
       }
       value = laszip_dll->header.y_scale_factor*laszip_dll->inventory->max_Y+laszip_dll->header.y_offset;
-      if (!laszip_dll->streamout->put64bitsLE((U8*)&value))
+      if (!laszip_dll->streamout->put64bitsLE((const U8*)&value))
       {
         sprintf(laszip_dll->error, "updating laszip_dll->inventory->max_Y");
         return 1;
       }
       value = laszip_dll->header.y_scale_factor*laszip_dll->inventory->min_Y+laszip_dll->header.y_offset;
-      if (!laszip_dll->streamout->put64bitsLE((U8*)&value))
+      if (!laszip_dll->streamout->put64bitsLE((const U8*)&value))
       {
         sprintf(laszip_dll->error, "updating laszip_dll->inventory->min_Y");
         return 1;
       }
       value = laszip_dll->header.z_scale_factor*laszip_dll->inventory->max_Z+laszip_dll->header.z_offset;
-      if (!laszip_dll->streamout->put64bitsLE((U8*)&value))
+      if (!laszip_dll->streamout->put64bitsLE((const U8*)&value))
       {
         sprintf(laszip_dll->error, "updating laszip_dll->inventory->max_Z");
         return 1;
       }
       value = laszip_dll->header.z_scale_factor*laszip_dll->inventory->min_Z+laszip_dll->header.z_offset;
-      if (!laszip_dll->streamout->put64bitsLE((U8*)&value))
+      if (!laszip_dll->streamout->put64bitsLE((const U8*)&value))
       {
         sprintf(laszip_dll->error, "updating laszip_dll->inventory->min_Z");
         return 1;
@@ -3143,7 +3286,7 @@ laszip_close_writer(
       {
         laszip_dll->streamout->seek(247);
         I64 number = laszip_dll->inventory->number_of_point_records;
-        if (!laszip_dll->streamout->put64bitsLE((U8*)&number))
+        if (!laszip_dll->streamout->put64bitsLE((const U8*)&number))
         {
           sprintf(laszip_dll->error, "updating laszip_dll->inventory->extended_number_of_point_records");
           return 1;
@@ -3151,7 +3294,7 @@ laszip_close_writer(
         for (I32 i = 0; i < 15; i++)
         {
           number = laszip_dll->inventory->number_of_points_by_return[i+1];
-          if (!laszip_dll->streamout->put64bitsLE((U8*)&number))
+          if (!laszip_dll->streamout->put64bitsLE((const U8*)&number))
           {
             sprintf(laszip_dll->error, "updating laszip_dll->inventory->extended_number_of_points_by_return[%d]\n", i);
             return 1;
@@ -3184,9 +3327,11 @@ laszip_close_writer(
     delete laszip_dll->streamout;
     laszip_dll->streamout = 0;
 
-	if (laszip_dll->file)
+	  if (laszip_dll->file)
+    {
       fclose(laszip_dll->file);
-    laszip_dll->file = 0;
+      laszip_dll->file = 0;
+    }
   }
   catch (...)
   {
@@ -4319,12 +4464,12 @@ laszip_inside_rectangle(
     {
       if (laszip_dll->lax_index->intersect_rectangle(r_min_x, r_min_y, r_max_x, r_max_y))
       {
-        // no overlap between spatial indexing cells and query reactangle
-        *is_empty = 1;
+        *is_empty = 0;
       }
       else
       {
-        *is_empty = 0;
+        // no overlap between spatial indexing cells and query reactangle
+        *is_empty = 1;
       }
     }
     else
@@ -4339,8 +4484,6 @@ laszip_inside_rectangle(
         *is_empty = 0;
       }
     }
-
-
   }
   catch (...)
   {
@@ -4446,7 +4589,7 @@ laszip_read_point(
       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->classification >> 5);
+      point->extended_classification_flags = (overlap_bit << 3) | ((point->withheld_flag) << 2) | ((point->keypoint_flag) << 1) | (point->synthetic_flag);
     }
 
     laszip_dll->p_count++;
@@ -4567,9 +4710,11 @@ laszip_close_reader(
       laszip_dll->lax_index = 0;
     }
 
-	if (laszip_dll->file)
+  	if (laszip_dll->file)
+    {
       fclose(laszip_dll->file);
-    laszip_dll->file = 0;
+      laszip_dll->file = 0;
+    }
   }
   catch (...)
   {


=====================================
src/mydefs.hpp
=====================================
@@ -30,9 +30,9 @@
   
 ===============================================================================
 */
-#ifndef MYDEFS_HPP
-#define MYDEFS_HPP
-
+#ifndef MYDEFS_HPP
+#define MYDEFS_HPP
+
 #ifndef _WIN32
 #define LASLIB_DLL
 #else  // _WIN32
@@ -47,67 +47,68 @@
 
 typedef char               CHAR;
 
-typedef int                I32;
-typedef short              I16;
-typedef char               I8;
-
-typedef unsigned int       U32;
-typedef unsigned short     U16;
-typedef unsigned char      U8;
-
+typedef int                I32;
+typedef short              I16;
+typedef char               I8;
+
+typedef unsigned int       U32;
+typedef unsigned short     U16;
+typedef unsigned char      U8;
+
 #if defined(_WIN32) && ! defined (__MINGW32__) // 64 byte integer under Windows 
-typedef unsigned __int64   U64;
-typedef __int64            I64;
-#else                                          // 64 byte integer elsewhere ... 
-typedef unsigned long long U64;
-typedef long long          I64;
-#endif
-
-typedef float              F32;
-typedef double             F64;
-
-#if defined(_MSC_VER) && (_MSC_VER < 1300) || defined (__MINGW32__)
+typedef unsigned __int64   U64;
+typedef __int64            I64;
+#else                                          // 64 byte integer elsewhere ... 
+typedef unsigned long long U64;
+typedef long long          I64;
+#endif
+
+typedef float              F32;
+typedef double             F64;
+
+#if defined(_MSC_VER) || defined (__MINGW32__)
 typedef int                BOOL;
 #else
 typedef bool               BOOL;
 #endif
-
-typedef union U32I32F32 { U32 u32; I32 i32; F32 f32; } U32I32F32;
-typedef union U64I64F64 { U64 u64; I64 i64; F64 f64; } U64I64F64;
-
-#define F32_MAX            +2.0e+37f
-#define F32_MIN            -2.0e+37f
-
+
+typedef union U32I32F32 { U32 u32; I32 i32; F32 f32; } U32I32F32;
+typedef union U64I64F64 { U64 u64; I64 i64; F64 f64; } U64I64F64;
+typedef union I64U32I32F32 { I64 i64; U32 u32[2]; I32 i32[2]; F32 f32[2]; } I64U32I32F32;
+
+#define F32_MAX            +2.0e+37f
+#define F32_MIN            -2.0e+37f
+
 #define F64_MAX            +2.0e+307
 #define F64_MIN            -2.0e+307
 
 #define U8_MIN             ((U8)0x0)  // 0
-#define U8_MAX             ((U8)0xFF) // 255
+#define U8_MAX             ((U8)0xFF) // 255
 #define U8_MAX_MINUS_ONE   ((U8)0xFE) // 254
-#define U8_MAX_PLUS_ONE    0x0100     // 256
-
+#define U8_MAX_PLUS_ONE    0x0100     // 256
+
 #define U16_MIN            ((U16)0x0)    // 0
-#define U16_MAX            ((U16)0xFFFF) // 65535
+#define U16_MAX            ((U16)0xFFFF) // 65535
 #define U16_MAX_MINUS_ONE  ((U16)0xFFFE) // 65534
-#define U16_MAX_PLUS_ONE   0x00010000    // 65536
-
+#define U16_MAX_PLUS_ONE   0x00010000    // 65536
+
 #define U32_MIN            ((U32)0x0)            // 0
-#define U32_MAX            ((U32)0xFFFFFFFF)     // 4294967295
+#define U32_MAX            ((U32)0xFFFFFFFF)     // 4294967295
 #define U32_MAX_MINUS_ONE  ((U32)0xFFFFFFFE)     // 4294967294
-#if defined(WIN32)            // 64 byte unsigned int constant under Windows 
-#define U32_MAX_PLUS_ONE   0x0000000100000000    // 4294967296
-#else                         // 64 byte unsigned int constant elsewhere ... 
-#define U32_MAX_PLUS_ONE   0x0000000100000000ull // 4294967296
-#endif
-
-#define I8_MIN             ((I8)0x80) // -128
-#define I8_MAX             ((I8)0x7F) // 127
-
-#define I16_MIN            ((I16)0x8000) // -32768
-#define I16_MAX            ((I16)0x7FFF) // 32767
-
-#define I32_MIN            ((I32)0x80000000) // -2147483648
-#define I32_MAX            ((I32)0x7FFFFFFF) //  2147483647
+#if defined(WIN32)            // 64 byte unsigned int constant under Windows 
+#define U32_MAX_PLUS_ONE   0x0000000100000000    // 4294967296
+#else                         // 64 byte unsigned int constant elsewhere ... 
+#define U32_MAX_PLUS_ONE   0x0000000100000000ull // 4294967296
+#endif
+
+#define I8_MIN             ((I8)0x80) // -128
+#define I8_MAX             ((I8)0x7F) // 127
+
+#define I16_MIN            ((I16)0x8000) // -32768
+#define I16_MAX            ((I16)0x7FFF) // 32767
+
+#define I32_MIN            ((I32)0x80000000) // -2147483648
+#define I32_MAX            ((I32)0x7FFFFFFF) //  2147483647
 
 #define I64_MIN            ((I64)0x8000000000000000)
 #define I64_MAX            ((I64)0x7FFFFFFFFFFFFFFF)
@@ -116,7 +117,7 @@ typedef union U64I64F64 { U64 u64; I64 i64; F64 f64; } U64I64F64;
 
 #define I8_CLAMP(n)     (((n) <= I8_MIN) ? I8_MIN : (((n) >= I8_MAX) ? I8_MAX : ((I8)(n))))
 #define U8_CLAMP(n)     (((n) <= U8_MIN) ? U8_MIN : (((n) >= U8_MAX) ? U8_MAX : ((U8)(n))))
-
+
 #define I16_CLAMP(n)    (((n) <= I16_MIN) ? I16_MIN : (((n) >= I16_MAX) ? I16_MAX : ((I16)(n))))
 #define U16_CLAMP(n)    (((n) <= U16_MIN) ? U16_MIN : (((n) >= U16_MAX) ? U16_MAX : ((U16)(n))))
 
@@ -156,17 +157,17 @@ typedef union U64I64F64 { U64 u64; I64 i64; F64 f64; } U64I64F64;
 #define U32_ZERO_BIT_0(n) (((n)&(U32)0xFFFFFFFE))
 #define U32_ZERO_BIT_0_1(n) (((n)&(U32)0xFFFFFFFC))
 
-#ifndef FALSE
-#define FALSE   0
-#endif
-
-#ifndef TRUE
-#define TRUE    1
-#endif
-
-#ifndef NULL
-#define NULL    0
-#endif
+#ifndef FALSE
+#define FALSE   0
+#endif
+
+#ifndef TRUE
+#define TRUE    1
+#endif
+
+#ifndef NULL
+#define NULL    0
+#endif
 
 inline BOOL IS_LITTLE_ENDIAN()
 {
@@ -183,7 +184,7 @@ inline BOOL IS_LITTLE_ENDIAN()
 	  ((((U32) n) <<  8) & 0x00FF0000) |	\
 	  ((((U32) n) >>  8) & 0x0000FF00) |	\
 	  ((((U32) n) >> 24) & 0x000000FF) )
-
+
 inline void ENDIAN_SWAP_16(U8* field)
 {
   U8 help = field[0];
@@ -245,4 +246,4 @@ inline void ENDIAN_SWAP_64(const U8* from, U8* to)
   to[7] = from[0];
 }
 
-#endif
+#endif



View it on GitLab: https://salsa.debian.org/debian-gis-team/laszip/commit/3c23172d15dfe084e0c398f2441a725b1c238808

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/laszip/commit/3c23172d15dfe084e0c398f2441a725b1c238808
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20181120/70e9fa1b/attachment-0001.html>


More information about the Pkg-grass-devel mailing list