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

Prototypes failing range check #246

Closed
asmaloney opened this issue Apr 21, 2023 · 0 comments · Fixed by #250
Closed

Prototypes failing range check #246

asmaloney opened this issue Apr 21, 2023 · 0 comments · Fixed by #250
Labels
bug Something isn't working

Comments

@asmaloney
Copy link
Owner

A prototype like the following will throw an exception:

<prototype type="Structure">
   <cartesianX type="Float" minimum="-0.09468899667263031" maximum="0.061009000986814499" />
   <cartesianY type="Float" minimum="0.040010999888181686" maximum="0.1873210072517395" />
   <cartesianZ type="Float" minimum="-0.061873000115156174" maximum="0.058798998594284058" />
</prototype>

The XML parser will default to value of 0.0 (see E57XmlParser::endElement), so in the cartesianY case it is out of range.

This is correct for any other "Float" node (E57 Standard 8.3.4.2):

The value of a Float is represented as child text of the XML element. This child text shall be zero or one occurrence of the xsd:float representation (if precision is single) or xsd:double (if precision is double), with optional leading and trailing XML whitespace. If no value is specified, the default value of the Float is 0.

However for prototypes (E57 Standard 8.3.9.3 (1)):

(1) The prototype child element specifies the structure of the data that will be stored in the CompressedVector, as well as the possible range of values that the data may take. The prototype shall be any E57 element type (with potential sub-children) except Blob and CompressedVector. The values of the prototype elements and sub-elements are ignored, and need not be specified.

So this case should not throw an exception.

@asmaloney asmaloney added the bug Something isn't working label Apr 21, 2023
asmaloney added a commit that referenced this issue May 21, 2023
A prototype field like this would throw an exception because it was checking the default value (0.0) against the range:

<cartesianY type="Float" minimum="0.040010999888181686" maximum="0.1873210072517395" />

Instead, only perform the check if we have explicitly set the value.

This fix follows the standard (E57 Standard 8.3.9.3 (1)) which allows this form:

"The values of the prototype elements and sub-elements are ignored, and need not be specified."

Fixes #246
asmaloney added a commit that referenced this issue May 21, 2023
)

A prototype field like this would throw an exception because it was checking the default value (0.0) against the range:

<cartesianY type="Float" minimum="0.040010999888181686" maximum="0.1873210072517395" />

Instead, only perform the check if we have explicitly set the value.

This fix follows the standard (E57 Standard 8.3.9.3 (1)) which allows this form:

"The values of the prototype elements and sub-elements are ignored, and need not be specified."

Fixes #246
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

Successfully merging a pull request may close this issue.

1 participant