-
Notifications
You must be signed in to change notification settings - Fork 156
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
Validation of UINT64
values that are out of the range of number
#251
Comments
As an addendum, related to #260 : (EDIT: What originally was written here did not make sense, because it referred to a case that was disallowed by the specification. But the core of the question remains, and has been updated accordingly) When metadata values have the type
Comparing |
Metadata values may have the type
UINT64
(orINT64
). JavaScript numbers internally usedouble
. This means that integer values larger than ~253 lose precision.An example of this (intentionally!) appears in the
TilesetWithFullMetadata
sample :This is the maximum value that a
UINT64
may have. When this value is parsed (using standardJSON.parse
), it is converted to anumber
value. Due to the rounding and precision loss, this value is larger than the actual maximum. So this currently causes a validation error:It is theoretically possible to avoid this, but only within the validator: The validator could use https://www.npmjs.com/package/json-bigint for parsing, and obtain the exact values. But this will break as soon as there will be an option to validate an (already parsed) object that represents the tileset: We cannot force clients to use
json-bigint
. They should be able to still useJSON.parse
, even if this may then only contain the rounded values.The severity level of this particular check should probably be reduced from
ERROR
toWARNING
, and adjusted to have an appropriate message (Roughly: "Yes, this is probably valid, but not very portable"). This is not entirely straightforward, though: One could argue that the handling should be different depending on whether the values have been obtained from a metadata entity in JSON, or whether they have been read from binary metadata. The latter can represent these values, and clients can fetch the value asnumber
orbigint
, depending on the implementation.The text was updated successfully, but these errors were encountered: