Skip to content

Commit

Permalink
Support scaling per dimension via Tables.
Browse files Browse the repository at this point in the history
  • Loading branch information
evetion committed Apr 1, 2021
1 parent 35579ac commit c05c8b1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions src/table.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function Base.setproperty!(p::LazPoint, name, value, header)
end
end

function write(fn::AbstractString, table, bbox; scale=0.01, kwargs...)
function write(fn::AbstractString, table, bbox; scalex=0.01, scaley=0.01, scalez=0.01, kwargs...)

schema = Tables.schema(table)
isnothing(schema) && error("A Schema is required")
Expand All @@ -50,12 +50,12 @@ function write(fn::AbstractString, table, bbox; scale=0.01, kwargs...)
rows = Tables.rows(table)

header = LazHeader(;kwargs...)
header.x_offset = determine_offset(bbox.min_x, bbox.max_x, scale)
header.y_offset = determine_offset(bbox.min_y, bbox.max_y, scale)
header.z_offset = determine_offset(bbox.min_z, bbox.max_z, scale)
header.x_scale_factor = scale
header.y_scale_factor = scale
header.z_scale_factor = scale
header.x_offset = determine_offset(bbox.min_x, bbox.max_x, scalex)
header.y_offset = determine_offset(bbox.min_y, bbox.max_y, scaley)
header.z_offset = determine_offset(bbox.min_z, bbox.max_z, scalez)
header.x_scale_factor = scalex
header.y_scale_factor = scaley
header.z_scale_factor = scalez

p = LazPoint()

Expand Down
4 changes: 2 additions & 2 deletions test/testio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ end
@test first(ds) isa LazIO.LazPoint
@inferred first(Tables.rows(ds))

LazIO.write("test_table.laz", ds, LazIO.bounds(ds), scale=0.1)
LazIO.write("test_table.laz", ds, LazIO.bounds(ds), scalex=0.1)
close(ds)

manual_fn = "test_table_manual.laz"
Expand All @@ -83,7 +83,7 @@ end
return_number = [1,2,1],
number_of_returns = [1,2,3])
bounds = (min_x = 11000.01, max_x = 32000., min_y = 11000., max_y = 32000., min_z = 11000., max_z = 32000.01)
LazIO.write(manual_fn, table, bounds, scale=0.01, system_identifier=LazIO.writestring("Laser shooter, pew pew!", 32))
LazIO.write(manual_fn, table, bounds, scalex=0.01, system_identifier=LazIO.writestring("Laser shooter, pew pew!", 32))

ds = LazIO.open(manual_fn)

Expand Down

0 comments on commit c05c8b1

Please sign in to comment.