I3SFeature.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import defined from "../Core/defined.js";
  2. import I3SDataProvider from "./I3SDataProvider.js";
  3. /**
  4. * This class implements an I3S Feature.
  5. * <p>
  6. * Do not construct this directly, instead access tiles through {@link I3SNode}.
  7. * </p>
  8. * @alias I3SFeature
  9. * @internalConstructor
  10. */
  11. function I3SFeature(parent, uri) {
  12. this._parent = parent;
  13. this._dataProvider = parent._dataProvider;
  14. this._layer = parent._layer;
  15. if (defined(this._parent._nodeIndex)) {
  16. this._resource = this._parent._layer.resource.getDerivedResource({
  17. url: `nodes/${this._parent._data.mesh.attribute.resource}/${uri}`,
  18. });
  19. } else {
  20. this._resource = this._parent.resource.getDerivedResource({ url: uri });
  21. }
  22. }
  23. Object.defineProperties(I3SFeature.prototype, {
  24. /**
  25. * Gets the resource for the feature
  26. * @memberof I3SFeature.prototype
  27. * @type {Resource}
  28. * @readonly
  29. */
  30. resource: {
  31. get: function () {
  32. return this._resource;
  33. },
  34. },
  35. /**
  36. * Gets the I3S data for this object.
  37. * @memberof I3SFeature.prototype
  38. * @type {object}
  39. * @readonly
  40. */
  41. data: {
  42. get: function () {
  43. return this._data;
  44. },
  45. },
  46. });
  47. /**
  48. * Loads the content.
  49. * @returns {Promise} A promise that is resolved when the data of the I3S feature is loaded
  50. * @private
  51. */
  52. I3SFeature.prototype.load = async function () {
  53. this._data = await I3SDataProvider.loadJson(
  54. this._resource,
  55. this._dataProvider._traceFetches
  56. );
  57. return this._data;
  58. };
  59. export default I3SFeature;