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

I3SStatistics.js 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import defined from "../Core/defined.js";
  2. import I3SDataProvider from "./I3SDataProvider.js";
  3. import Resource from "../Core/Resource.js";
  4. /**
  5. * This class implements an I3S statistics for Building Scene Layer.
  6. * <p>
  7. * Do not construct this directly, instead access statistics through {@link I3SDataProvider}.
  8. * </p>
  9. * @alias I3SStatistics
  10. * @internalConstructor
  11. */
  12. function I3SStatistics(dataProvider, uri) {
  13. this._dataProvider = dataProvider;
  14. this._resource = new Resource({ url: uri });
  15. this._resource.setQueryParameters(dataProvider.resource.queryParameters);
  16. this._resource.appendForwardSlash();
  17. }
  18. Object.defineProperties(I3SStatistics.prototype, {
  19. /**
  20. * Gets the resource for the statistics
  21. * @memberof I3SStatistics.prototype
  22. * @type {Resource}
  23. * @readonly
  24. */
  25. resource: {
  26. get: function () {
  27. return this._resource;
  28. },
  29. },
  30. /**
  31. * Gets the I3S data for this object.
  32. * @memberof I3SStatistics.prototype
  33. * @type {object}
  34. * @readonly
  35. */
  36. data: {
  37. get: function () {
  38. return this._data;
  39. },
  40. },
  41. /**
  42. * Gets the collection of attribute names.
  43. * @memberof I3SStatistics.prototype
  44. * @type {string[]}
  45. * @readonly
  46. */
  47. names: {
  48. get: function () {
  49. const names = [];
  50. const summary = this._data.summary;
  51. if (defined(summary)) {
  52. for (let i = 0; i < summary.length; ++i) {
  53. names.push(summary[i].fieldName);
  54. }
  55. }
  56. return names;
  57. },
  58. },
  59. });
  60. /**
  61. * Loads the content.
  62. * @returns {Promise<object>} A promise that is resolved when the data of the I3S statistics is loaded
  63. * @private
  64. */
  65. I3SStatistics.prototype.load = async function () {
  66. this._data = await I3SDataProvider.loadJson(this._resource);
  67. return this._data;
  68. };
  69. /**
  70. * @private
  71. */
  72. I3SStatistics.prototype._getValues = function (attributeName) {
  73. const summary = this._data.summary;
  74. if (defined(summary)) {
  75. for (let i = 0; i < summary.length; ++i) {
  76. const attribute = summary[i];
  77. if (attribute.fieldName === attributeName) {
  78. if (defined(attribute.mostFrequentValues)) {
  79. return [...attribute.mostFrequentValues];
  80. }
  81. return [];
  82. }
  83. }
  84. }
  85. };
  86. export default I3SStatistics;