From e08d53b3dd83f7c20dbc8186733a9b3aed06ad92 Mon Sep 17 00:00:00 2001 From: Andrew Bell Date: Wed, 11 May 2022 15:28:23 -0400 Subject: [PATCH] Fix windows warnings. --- .gitattributes | 1 + lazperf/detail/field_nir14.cpp | 2 +- lazperf/detail/field_point14.cpp | 8 ++++---- lazperf/lazperf.cpp | 2 +- lazperf/lazperf_base.hpp | 4 +++- lazperf/readers.cpp | 4 ++-- lazperf/vlr.cpp | 9 +++++++-- lazperf/writers.cpp | 14 +++++++++++--- 8 files changed, 30 insertions(+), 14 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..176a458 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto diff --git a/lazperf/detail/field_nir14.cpp b/lazperf/detail/field_nir14.cpp index d37ee3c..4fede0e 100644 --- a/lazperf/detail/field_nir14.cpp +++ b/lazperf/detail/field_nir14.cpp @@ -82,7 +82,7 @@ const char *Nir14Compressor::compress(const char *buf, int& sc) bool lowChange = (lastNir.val & 0xFF) != (nir.val & 0xFF); bool highChange = (lastNir.val & 0xFF00) != (nir.val & 0xFF00); - int32_t sym = lowChange | (highChange << 1); + int32_t sym = (int)lowChange | ((int)highChange << 1); if (sym) nir_enc_.makeValid(); nir_enc_.encodeSymbol(c.used_model_, sym); diff --git a/lazperf/detail/field_point14.cpp b/lazperf/detail/field_point14.cpp index 1bd3936..1a0126c 100644 --- a/lazperf/detail/field_point14.cpp +++ b/lazperf/detail/field_point14.cpp @@ -276,7 +276,7 @@ const char *Point14Compressor::compress(const char *buf, int& scArg) // X and Y { - uint32_t ctx = (number_return_map_6ctx[n][r] << 1) | gps_time_change; + uint32_t ctx = (number_return_map_6ctx[n][r] << 1) | (int)gps_time_change; int32_t median = c.last_x_diff_median5_[ctx].get(); int32_t diff = point.x() - c.last_.x(); c.dx_compr_.compress(xy_enc_, median, diff, point.numReturns() == 1); @@ -333,7 +333,7 @@ const char *Point14Compressor::compress(const char *buf, int& scArg) // Intensity { int32_t ctx = - gps_time_change | + (int)gps_time_change | ((r >= n) << 1) | ((r == 1) << 2); @@ -693,7 +693,7 @@ char *Point14Decompressor::decompress(char *buf, int& scArg) LAZDEBUG(sumReturn.add(n)); LAZDEBUG(sumReturn.add(r)); - uint32_t ctx = (number_return_map_6ctx[n][r] << 1) | gps_time_changed; + uint32_t ctx = (number_return_map_6ctx[n][r] << 1) | (int)gps_time_changed; // X { int32_t median = c.last_x_diff_median5_[ctx].get(); @@ -754,7 +754,7 @@ char *Point14Decompressor::decompress(char *buf, int& scArg) // Intensity if (intensity_dec_.valid()) { - int32_t ctx = gps_time_changed | ((r >= n) << 1) | ((r == 1) << 2); + int32_t ctx = (int)gps_time_changed | ((r >= n) << 1) | ((r == 1) << 2); uint16_t intensity = c.intensity_decomp_.decompress(intensity_dec_, c.last_intensity_[ctx], ctx >> 1); diff --git a/lazperf/lazperf.cpp b/lazperf/lazperf.cpp index 8c2137f..d2c8b8c 100644 --- a/lazperf/lazperf.cpp +++ b/lazperf/lazperf.cpp @@ -678,7 +678,7 @@ std::vector decompress_chunk_table(InputCb cb, size_t numChunks) std::vector sizes; for (chunk& c : chunks) - sizes.push_back(c.offset); + sizes.push_back((uint32_t)c.offset); return sizes; } diff --git a/lazperf/lazperf_base.hpp b/lazperf/lazperf_base.hpp index 864ca2c..21b85b6 100644 --- a/lazperf/lazperf_base.hpp +++ b/lazperf/lazperf_base.hpp @@ -6,10 +6,12 @@ #define LAZPERF_REVISION 0 #define LAZPERF_VERSION 3.0.0 +/** #ifdef _WIN32 #define LAZPERF_EXPORT __declspec(dllexport) #else -// This may not be necessary. The GCC doc says it take __declspec((dllexport)) #define LAZPERF_EXPORT __attribute__((visibility ("default"))) #endif +**/ +#define LAZPERF_EXPORT diff --git a/lazperf/readers.cpp b/lazperf/readers.cpp index 5688b13..568cf3a 100644 --- a/lazperf/readers.cpp +++ b/lazperf/readers.cpp @@ -247,7 +247,7 @@ bool basic_file::Private::extractVlr(const std::string& user_id, uint16_t record // Extract EB VLR else if (user_id == "LASF_Spec" && record_id == 4) { - eb.read(*f, data_length); + eb.read(*f, (int)data_length); return true; } return false; @@ -338,7 +338,7 @@ void basic_file::Private::parseChunkTable() { if (total_points < laz.chunk_size) { - count = total_points; + count = (uint32_t)total_points; assert(i == chunk_table_header.chunk_count - 1); } else diff --git a/lazperf/vlr.cpp b/lazperf/vlr.cpp index 3dab921..da3dd2a 100644 --- a/lazperf/vlr.cpp +++ b/lazperf/vlr.cpp @@ -325,8 +325,13 @@ eb_vlr::eb_vlr() eb_vlr::eb_vlr(int ebCount) { - while (ebCount--) - addField(); + for (int i = 0; i < ebCount; ++i) + { + eb_vlr::ebfield field; + + field.name = "FIELD_" + std::to_string(i); + addField(field); + } } eb_vlr::~eb_vlr() diff --git a/lazperf/writers.cpp b/lazperf/writers.cpp index 27d94c0..4faf4ce 100644 --- a/lazperf/writers.cpp +++ b/lazperf/writers.cpp @@ -196,7 +196,15 @@ void basic_file::Private::close() void basic_file::Private::writeHeader() { laz_vlr lazVlr(head14.pointFormat(), head14.ebCount(), chunk_size); - eb_vlr ebVlr(head14.ebCount()); + eb_vlr ebVlr; + + for (int i = 0; i < head14.ebCount(); ++i) + { + eb_vlr::ebfield field; + + field.name = "FIELD_" + std::to_string(i); + ebVlr.addField(field); + } // Set the version number to 2 in order to write something reasonable. if (head14.version.minor < 2 || head14.version.minor > 4) @@ -210,11 +218,11 @@ void basic_file::Private::writeHeader() { head14.vlr_count++; head14.point_format_id |= (1 << 7); - head14.point_offset += lazVlr.size() + lazVlr.header().Size; + head14.point_offset += (uint32_t)(lazVlr.size() + lazVlr.header().Size); } if (head14.ebCount()) { - head14.point_offset += ebVlr.size() + ebVlr.header().Size; + head14.point_offset += uint32_t(ebVlr.size() + ebVlr.header().Size); head14.vlr_count++; }