Skip to content

fix(SurfaceAttributes): parse multi-channel attribute layer ranges - #2

Open
haraldsteinlechner wants to merge 1 commit into
masterfrom
fix/multichannel-attribute-layer-ranges
Open

fix(SurfaceAttributes): parse multi-channel attribute layer ranges#2
haraldsteinlechner wants to merge 1 commit into
masterfrom
fix/multichannel-attribute-layer-ranges

Conversation

@haraldsteinlechner

Copy link
Copy Markdown
Member

Fixes #1.

SurfaceAttributes.parseMap read a Map attribute layer's range with Range1d.Parse, which only understands a single [min, max]. Multi-channel layers declare one range per channel:

<ChannelsDefinedRange>[[-0.000039896, 0.000040985], [-0.000046144, 0.000046183], [-0.000050788, 0.000050736]]</ChannelsDefinedRange>

so parsing threw and the whole *.opcx failed to load. Both forms are accepted now.

Which range is kept

ScalarLayer has room for exactly one Range1d, and its consumers refer to the layer's first channel — the false-colour legend, and mapping sampled texture values back to physical ones (attribute textures are read through ChannelReference.ChannelWithIndex 0). So the first channel's range is kept. Unioning the channels would widen it — by ~25% for the Gravity layer above — and skew everything derived from it.

parseChannelRanges is public, so callers that need all channels can get them.

An unparsable range now fails with the layer name and the offending text rather than Range1d.Parse's opaque error.

Verification

OPCViewer.Base builds. The equivalent change was verified in PRo3D, which carries a copy of this module: fed the unpatched *.opcx of a HERA/Dimorphos DTM export, the parser now yields ranges identical to the hand-patched file, layer for layer —

LonLatRad    [0.185185194, 399.814819336]
Normal       [-0.999235153, 0.999621212]
Gravity      [-3.9896E-05, 4.0985E-05]
Magnitude    [3.7598E-05, 5.0796E-05]
Potential    [-0.005895375, -0.001222028]
Elevation    [0.004859322, 124.307319641]
Slope        [0.360530615, 47.203220367]

There is no test project in this repo; the covering tests live in PRo3D (OpcSidecarTests.opcx attribute layers) and include the single-channel form, the multi-channel form, and an unparsable range.

ChannelsDefinedRange / ChannelsActualRange of a Map attribute layer were read with
Range1d.Parse, which only understands a single "[min, max]". Multi-channel layers
(normals, gravity vectors, lon/lat/radius) declare one range per channel:

  [[-0.000039896, 0.000040985], [-0.000046144, 0.000046183], [-0.000050788, 0.000050736]]

so parsing threw and the whole *.opcx failed to load.

Both forms are accepted now. ScalarLayer has room for exactly one Range1d and its
consumers refer to the layer's first channel - the false colour legend, and mapping
sampled texture values back to physical ones, since attribute textures are read
through ChannelReference.ChannelWithIndex 0 - so the first channel's range is kept.
Unioning the channels would widen it (by ~25% for the Gravity layer above) and skew
everything derived from it.

An unparsable range now fails with the layer name and the offending text instead of
Range1d.Parse's opaque error.
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.

SurfaceAttributes: multi-channel ChannelsDefinedRange/ChannelsActualRange fails to parse

1 participant