From 73e0f85e8b29822d00d75863c191a6058e7691c6 Mon Sep 17 00:00:00 2001 From: Maarten Pronk Date: Tue, 2 Feb 2021 16:53:14 +0000 Subject: [PATCH] Offset bugfix that always resulted in an offset of 1 (#29) * Added Table write interface for XYZ fields, includes conversion. * Added conversion of other fields as well. * Fixed offset bug. * Also update test. * Up version. --- .gitignore | 1 + Project.toml | 2 +- src/table.jl | 1 + test/testio.jl | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index b823a7c..ff566ca 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ deps/deps.jl deps/usr *.DS_Store +*.laz diff --git a/Project.toml b/Project.toml index 4106268..d94b40b 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "LazIO" uuid = "c3605908-9f0f-11e8-0a72-0d361c15a277" authors = ["Maarten Pronk "] -version = "0.3.0" +version = "0.3.1" [deps] Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" diff --git a/src/table.jl b/src/table.jl index 3756fc4..c58f937 100644 --- a/src/table.jl +++ b/src/table.jl @@ -17,6 +17,7 @@ function determine_offset(min_value, max_value, scale; threshold=10^7) # Try to convert back and forth and check overflow (muladd(round(Int32, (min_value - s) / scale), scale, s) > 0) == (min_value > 0) || error("Can't fit offset in this scale, try to coarsen it.") (muladd(round(Int32, (max_value - s) / scale), scale, s) > 0) == (max_value > 0) || error("Can't fit offset in this scale, try to coarsen it.") + s end """Correctly set fields that require conversion or packing.""" diff --git a/test/testio.jl b/test/testio.jl index 9933f81..4a2257e 100644 --- a/test/testio.jl +++ b/test/testio.jl @@ -88,7 +88,7 @@ end ds = LazIO.open(manual_fn) @test length(ds) == 3 - @test first(ds).X == 1099901 + @test first(ds).X == 1100001 @test muladd(first(ds).X, ds.header.x_scale_factor, ds.header.x_offset) ≈ 11000.01 @test LasIO.classification(first(ds)) == LazIO.classes.ground end