asmaloney / libE57Format

Library for reading & writing the E57 file format
Boost Software License 1.0
137 stars 66 forks source link

Prototypes failing range check #246

Closed asmaloney closed 1 year ago

asmaloney commented 1 year ago

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.