Skip to content

Commit

Permalink
Fix windows warnings. (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub authored May 11, 2022
1 parent e62298a commit e61f125
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
2 changes: 1 addition & 1 deletion lazperf/detail/field_nir14.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions lazperf/detail/field_point14.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lazperf/lazperf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ std::vector<uint32_t> decompress_chunk_table(InputCb cb, size_t numChunks)

std::vector<uint32_t> sizes;
for (chunk& c : chunks)
sizes.push_back(c.offset);
sizes.push_back((uint32_t)c.offset);
return sizes;
}

Expand Down
4 changes: 3 additions & 1 deletion lazperf/lazperf_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

4 changes: 2 additions & 2 deletions lazperf/readers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions lazperf/vlr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
14 changes: 11 additions & 3 deletions lazperf/writers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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++;
}

Expand Down

0 comments on commit e61f125

Please sign in to comment.