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

Adding support for writing BlobNode (imagery) #59

Merged
merged 2 commits into from
May 3, 2024

Conversation

joaori
Copy link
Contributor

@joaori joaori commented Apr 28, 2024

When trying to clone an E57 file with images, I've realized a missing binding to support adding a BlobNode field to a StructureNode.

I've introduced a unit test file with an example of the clone process, in case you find it useful.

Also including unit test validating support to fully copy an E57
structure
@dancergraham
Copy link
Collaborator

dancergraham commented May 2, 2024

I had a look at the test file - it seems to be an unmodified copy of the standard e57 test file. After the xz hack attempt I was a bit nervous about accepting a pull request containing anonymous blob data 😁

Copy link
Collaborator

@dancergraham dancergraham left a comment

Choose a reason for hiding this comment

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

Looks good, thank you very much - I have made a few comments and a small fix is needed on the imports

@pytest.fixture
def temp_e57_write(request):
path = sample_data("test_write.e57")
request.addfinalizer(lambda: delete_retry(path))
Copy link
Collaborator

Choose a reason for hiding this comment

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

issue: this function has not been imported

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My bad, last minute change before I pushed the code. 😅

in_image = libe57.ImageFile(e57_path, "r")
out_image = libe57.ImageFile(temp_e57_write, "w")

for i in range(0, in_image.extensionsCount()):
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: should be for i in range(in_image.extensionsCount()):

Copy link
Collaborator

Choose a reason for hiding this comment

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

question: could this sensibly be integrated with test_main.py? Some of the existing tests relate specifically to aspects of libe57 so it is confusing to split them in this way.

compressed_node_pairs.extend(out_child_compressed_node_pairs)
blob_node_pairs.extend(out_child_blob_node_pairs)

if (isinstance(node, libe57.BlobNode)):
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion: change to elif

Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion: move above the container types with the other terminal nodes


current_index += current_chunk

def copy_node(node, dest_image):
Copy link
Collaborator

Choose a reason for hiding this comment

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

question: would it make sense to add this function to the main pye57 library? For instance in the utils namespace ?


@pytest.fixture
def e57_path():
# From http://www.libe57.org/data.html
Copy link
Collaborator

Choose a reason for hiding this comment

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

praise: nice to have the source mentioned here

Copy link
Contributor Author

@joaori joaori left a comment

Choose a reason for hiding this comment

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

All comments addressed. Let me know if you'd like me to squash all commits before merge (not sure if there's any preference there).
Thanks

@pytest.fixture
def temp_e57_write(request):
path = sample_data("test_write.e57")
request.addfinalizer(lambda: delete_retry(path))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

My bad, last minute change before I pushed the code. 😅

Copy link
Collaborator

@dancergraham dancergraham left a comment

Choose a reason for hiding this comment

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

Looks great - thanks again.
It would be very cool to add a tutorial or sample or just a reference to the clone e57 test case as an example of how to use the library to copy an e57 file. I also wonder whether the buffer functions would be good as part of utils but I will merge it for now as it stands !

@dancergraham dancergraham merged commit 75b9c7c into davidcaron:master May 3, 2024
13 checks passed
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.

2 participants