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

LayerDescriptors should have dimensions, and Layer::read() should use them. #109

Open
brian-r-calder opened this issue Jun 12, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@brian-r-calder
Copy link
Collaborator

The current v2.0 API uses the XML metadata read from the BAG file to set the shape (dimensions) in BAG::Descriptor as returned by getDims(). This should, in theory, be the shape of the Elevation and Uncertainty mandatory layers (as long as the metadata is valid).

However, it is possible for optional layers to be of different shapes. The variable resolution refinement and node layers are a particular example of this: although the VR metadata has the same shape as the mandatory layers, the refinements and nodes are stored as a one-dimensional array (with indices in the metadata element for each fixed-resolution node).

The code in BAG::Layer::read() (advisedly) checks the size of the read request against the shape to avoid out-of-bounds requests, but although it has a BAG::LayerDescriptor for the layer, it uses the BAG::Descriptor for dimensions (because the BAG::LayerDescriptor doesn't have dimensions for the individual layer). This means that if the optional layer doesn't have the same shape as the metadata describes, then the code may fail with a BAG::InvalidReadSize exception for valid reads.

To fix this:

  1. The BAG::LayerDescriptor object needs to have row/col parameters for the shape of the layer, as read from the HDF5 file.
  2. The BAG::LayerDescriptor object must have a getDims() method to return this information.
  3. The layer constructor must populate the shape parameters in BAG::LayerDescriptor at construction.
  4. The BAG::Layer::read() helper must validate the read shape against the BAG::LayerDescriptor rather than the BAG::Descriptor.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant