Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flexibly Modify Point Contents #49

Merged
merged 20 commits into from
Feb 3, 2025
Merged

Flexibly Modify Point Contents #49

merged 20 commits into from
Feb 3, 2025

Conversation

BenCurran98
Copy link
Collaborator

@BenCurran98 BenCurran98 commented Jan 30, 2025

Ability to flexibly modify point data and header info in LAS Dataset

Description

Adding the functionality to let users modify the point data or header information relating to the point data in a LASDataset without invalidating the header of the LAS file.
The main use case here is if you have some LASDataset and you want to add extra LAS fields to it (that aren't already present, and maybe don't correspond to the point version currently stored in your header). For example, if you have a file with the LasPoint0 format, but want to add an overlap column, you can do

las = load_las(...)
add_column!(las, :overlap, falses(number_of_points(las)))`

This will update the header information appropriately as well as the actual point data.
Additionally, you can opt to change the point format or las version specifically (without changing the point data itself).
The benefit of these changes is that if you load in a LAS file, do some processing, and then need to output it in a different format, you can do it without having to create a whole new LASDataset.

On top of this, you can add extra points to your dataset too using the new add_points! function (where one caveat is if your new points are missing any fields that are in the LAS dataset, they'll be filled in with zeroes)

To make this work, I've redone the internals of how we store point data, changing to use a single FlexTable instead of a core TypedTable and an optional FlexTable just containing user data. This may be slightly less performant in some operations over the point data due to type inference overhead, however I think the flexibility in the UI justifies this

Types of Changes

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Refactor/improvements
  • Documentation / non-code

Tasks

  • Functions to modify header format properties
  • Plumb header functions through LASDataset objects
  • Modify add_column! to work for LAS fields as well as user fields
  • Ability to add points to LASDataset
  • Documentation of API changes

Review

  • Tests

src/dataset.jl Outdated Show resolved Hide resolved
src/header.jl Show resolved Hide resolved
@i-kieu i-kieu self-requested a review January 30, 2025 06:32
@BenCurran98
Copy link
Collaborator Author

While I'm at it, I've also corrected a couple of small bits and pieces in the logic here.
Firstly, I've modified how we set scaling in the spatial information of the header to allow users to set different scale factors for different axes.
Also, I've updated the extract_vlr_type function to only return one VLR (or nothing, if it can't find a match) to match the logic in the spec that there should only ever be at most 1 VLR per unique user ID/record ID combination

Signed-off-by: BenCurran98 <[email protected]>
@BenCurran98 BenCurran98 marked this pull request as ready for review January 30, 2025 23:51
else
return Table(las.pointcloud, las._user_data)
end
return las.pointcloud
Copy link
Collaborator

Choose a reason for hiding this comment

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

the type returned has changed from Table -> FlexTable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, so this might cause issues in downstream methods expecting this to be of type Table. Ideally, those methods should change to accept AbstractVector{<:NamedTuple} instead

docs/src/interface.md Outdated Show resolved Hide resolved
src/dataset.jl Outdated Show resolved Hide resolved
i-kieu
i-kieu previously approved these changes Feb 3, 2025
Signed-off-by: BenCurran98 <[email protected]>
i-kieu
i-kieu previously approved these changes Feb 3, 2025
@BenCurran98 BenCurran98 merged commit c187fd4 into main Feb 3, 2025
10 checks passed
@BenCurran98 BenCurran98 deleted the ModifyRecords branch February 3, 2025 01:06
@@ -183,4 +183,40 @@
remove_vlr!(las, superseded_comment)
@test number_of_evlrs(get_header(las)) == 1
@test get_evlrs(las) == [new_commment]

# test modifying point formats and versions
las = LASDataset(pc)
Copy link
Collaborator

Choose a reason for hiding this comment

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

las = LASDataset(this_pc)?

@@ -554,13 +585,18 @@ end
Set the number of points in a LAS file with a header `header`
"""
function set_point_record_count!(header::LasHeader, num_points::Integer)
if las_version(header) == v"1.4"
if (las_version(header) == v"1.4")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do you need the brackets?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants