智慧水务管理系统 - 精河县供水工程综合管理平台

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import Cartesian3 from "../Core/Cartesian3.js";
  2. import defined from "../Core/defined.js";
  3. import DeveloperError from "../Core/DeveloperError.js";
  4. import Matrix3 from "../Core/Matrix3.js";
  5. import ReferenceFrame from "../Core/ReferenceFrame.js";
  6. import Transforms from "../Core/Transforms.js";
  7. /**
  8. * The interface for all {@link Property} objects that define a world
  9. * location as a {@link Cartesian3} with an associated {@link ReferenceFrame}.
  10. * This type defines an interface and cannot be instantiated directly.
  11. *
  12. * @alias PositionProperty
  13. * @constructor
  14. * @abstract
  15. *
  16. * @see CallbackPositionProperty
  17. * @see CompositePositionProperty
  18. * @see ConstantPositionProperty
  19. * @see SampledPositionProperty
  20. * @see TimeIntervalCollectionPositionProperty
  21. */
  22. function PositionProperty() {
  23. DeveloperError.throwInstantiationError();
  24. }
  25. Object.defineProperties(PositionProperty.prototype, {
  26. /**
  27. * Gets a value indicating if this property is constant. A property is considered
  28. * constant if getValue always returns the same result for the current definition.
  29. * @memberof PositionProperty.prototype
  30. *
  31. * @type {boolean}
  32. * @readonly
  33. */
  34. isConstant: {
  35. get: DeveloperError.throwInstantiationError,
  36. },
  37. /**
  38. * Gets the event that is raised whenever the definition of this property changes.
  39. * The definition is considered to have changed if a call to getValue would return
  40. * a different result for the same time.
  41. * @memberof PositionProperty.prototype
  42. *
  43. * @type {Event}
  44. * @readonly
  45. */
  46. definitionChanged: {
  47. get: DeveloperError.throwInstantiationError,
  48. },
  49. /**
  50. * Gets the reference frame that the position is defined in.
  51. * @memberof PositionProperty.prototype
  52. * @type {ReferenceFrame}
  53. */
  54. referenceFrame: {
  55. get: DeveloperError.throwInstantiationError,
  56. },
  57. });
  58. /**
  59. * Gets the value of the property at the provided time in the fixed frame.
  60. * @function
  61. *
  62. * @param {JulianDate} [time=JulianDate.now()] The time for which to retrieve the value. If omitted, the current system time is used.
  63. * @param {Cartesian3} [result] The object to store the value into, if omitted, a new instance is created and returned.
  64. * @returns {Cartesian3 | undefined} The modified result parameter or a new instance if the result parameter was not supplied.
  65. */
  66. PositionProperty.prototype.getValue = DeveloperError.throwInstantiationError;
  67. /**
  68. * Gets the value of the property at the provided time and in the provided reference frame.
  69. * @function
  70. *
  71. * @param {JulianDate} time The time for which to retrieve the value.
  72. * @param {ReferenceFrame} referenceFrame The desired referenceFrame of the result.
  73. * @param {Cartesian3} [result] The object to store the value into, if omitted, a new instance is created and returned.
  74. * @returns {Cartesian3 | undefined} The modified result parameter or a new instance if the result parameter was not supplied.
  75. */
  76. PositionProperty.prototype.getValueInReferenceFrame =
  77. DeveloperError.throwInstantiationError;
  78. /**
  79. * Compares this property to the provided property and returns
  80. * <code>true</code> if they are equal, <code>false</code> otherwise.
  81. * @function
  82. *
  83. * @param {Property} [other] The other property.
  84. * @returns {boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
  85. */
  86. PositionProperty.prototype.equals = DeveloperError.throwInstantiationError;
  87. const scratchMatrix3 = new Matrix3();
  88. /**
  89. * @private
  90. */
  91. PositionProperty.convertToReferenceFrame = function (
  92. time,
  93. value,
  94. inputFrame,
  95. outputFrame,
  96. result,
  97. ) {
  98. if (!defined(value)) {
  99. return value;
  100. }
  101. if (!defined(result)) {
  102. result = new Cartesian3();
  103. }
  104. if (inputFrame === outputFrame) {
  105. return Cartesian3.clone(value, result);
  106. }
  107. const icrfToFixed = Transforms.computeIcrfToCentralBodyFixedMatrix(
  108. time,
  109. scratchMatrix3,
  110. );
  111. if (inputFrame === ReferenceFrame.INERTIAL) {
  112. return Matrix3.multiplyByVector(icrfToFixed, value, result);
  113. }
  114. if (inputFrame === ReferenceFrame.FIXED) {
  115. return Matrix3.multiplyByVector(
  116. Matrix3.transpose(icrfToFixed, scratchMatrix3),
  117. value,
  118. result,
  119. );
  120. }
  121. };
  122. export default PositionProperty;