Skip to content

Commit

Permalink
Offset bugfix that always resulted in an offset of 1 (#29)
Browse files Browse the repository at this point in the history
* Added Table write interface for XYZ fields, includes conversion.

* Added conversion of other fields as well.

* Fixed offset bug.

* Also update test.

* Up version.
  • Loading branch information
evetion authored Feb 2, 2021
1 parent 11d8297 commit 73e0f85
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
deps/deps.jl
deps/usr
*.DS_Store
*.laz
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "LazIO"
uuid = "c3605908-9f0f-11e8-0a72-0d361c15a277"
authors = ["Maarten Pronk <[email protected]>"]
version = "0.3.0"
version = "0.3.1"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
1 change: 1 addition & 0 deletions src/table.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
2 changes: 1 addition & 1 deletion test/testio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

2 comments on commit 73e0f85

@evetion
Copy link
Owner Author

@evetion evetion commented on 73e0f85 Feb 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/29205

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.1 -m "<description of version>" 73e0f85e8b29822d00d75863c191a6058e7691c6
git push origin v0.3.1

Please sign in to comment.