MetadataEnumValue.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import Check from "../Core/Check.js";
  2. import clone from "../Core/clone.js";
  3. import defaultValue from "../Core/defaultValue.js";
  4. /**
  5. * A metadata enum value.
  6. * <p>
  7. * See the {@link https://github.com/CesiumGS/3d-tiles/tree/main/specification/Metadata|3D Metadata Specification} for 3D Tiles
  8. * </p>
  9. *
  10. * @param {object} options Object with the following properties:
  11. * @param {number} options.value The integer value.
  12. * @param {string} options.name The name of the enum value.
  13. * @param {string} [options.description] The description of the enum value.
  14. * @param {*} [options.extras] Extra user-defined properties.
  15. * @param {object} [options.extensions] An object containing extensions.
  16. *
  17. * @alias MetadataEnumValue
  18. * @constructor
  19. * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
  20. */
  21. function MetadataEnumValue(options) {
  22. options = defaultValue(options, defaultValue.EMPTY_OBJECT);
  23. const value = options.value;
  24. const name = options.name;
  25. //>>includeStart('debug', pragmas.debug);
  26. Check.typeOf.number("options.value", value);
  27. Check.typeOf.string("options.name", name);
  28. //>>includeEnd('debug');
  29. this._value = value;
  30. this._name = name;
  31. this._description = options.description;
  32. this._extras = clone(options.extras, true);
  33. this._extensions = clone(options.extensions, true);
  34. }
  35. /**
  36. * Creates a {@link MetadataEnumValue} from either 3D Tiles 1.1, 3DTILES_metadata, EXT_structural_metadata, or EXT_feature_metadata.
  37. *
  38. * @param {object} value The enum value JSON object.
  39. *
  40. * @returns {MetadataEnumValue} The newly created metadata enum value.
  41. *
  42. * @private
  43. * @experimental This feature is using part of the 3D Tiles spec that is not final and is subject to change without Cesium's standard deprecation policy.
  44. */
  45. MetadataEnumValue.fromJson = function (value) {
  46. //>>includeStart('debug', pragmas.debug);
  47. Check.typeOf.object("value", value);
  48. //>>includeEnd('debug');
  49. return new MetadataEnumValue({
  50. value: value.value,
  51. name: value.name,
  52. description: value.description,
  53. extras: value.extras,
  54. extensions: value.extensions,
  55. });
  56. };
  57. Object.defineProperties(MetadataEnumValue.prototype, {
  58. /**
  59. * The integer value.
  60. *
  61. * @memberof MetadataEnumValue.prototype
  62. * @type {number}
  63. * @readonly
  64. */
  65. value: {
  66. get: function () {
  67. return this._value;
  68. },
  69. },
  70. /**
  71. * The name of the enum value.
  72. *
  73. * @memberof MetadataEnumValue.prototype
  74. * @type {string}
  75. * @readonly
  76. */
  77. name: {
  78. get: function () {
  79. return this._name;
  80. },
  81. },
  82. /**
  83. * The description of the enum value.
  84. *
  85. * @memberof MetadataEnumValue.prototype
  86. * @type {string}
  87. * @readonly
  88. */
  89. description: {
  90. get: function () {
  91. return this._description;
  92. },
  93. },
  94. /**
  95. * Extra user-defined properties.
  96. *
  97. * @memberof MetadataEnumValue.prototype
  98. * @type {*}
  99. * @readonly
  100. */
  101. extras: {
  102. get: function () {
  103. return this._extras;
  104. },
  105. },
  106. /**
  107. * An object containing extensions.
  108. *
  109. * @memberof MetadataEnumValue.prototype
  110. * @type {object}
  111. * @readonly
  112. */
  113. extensions: {
  114. get: function () {
  115. return this._extensions;
  116. },
  117. },
  118. });
  119. export default MetadataEnumValue;