Source: layer/WmsTimeDimensionedLayer.js

  1. /*
  2. * Copyright 2003-2006, 2009, 2017, 2020 United States Government, as represented
  3. * by the Administrator of the National Aeronautics and Space Administration.
  4. * All rights reserved.
  5. *
  6. * The NASAWorldWind/WebWorldWind platform is licensed under the Apache License,
  7. * Version 2.0 (the "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License
  9. * at http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software distributed
  12. * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  13. * CONDITIONS OF ANY KIND, either express or implied. See the License for the
  14. * specific language governing permissions and limitations under the License.
  15. *
  16. * NASAWorldWind/WebWorldWind also contains the following 3rd party Open Source
  17. * software:
  18. *
  19. * ES6-Promise – under MIT License
  20. * libtess.js – SGI Free Software License B
  21. * Proj4 – under MIT License
  22. * JSZip – under MIT License
  23. *
  24. * A complete listing of 3rd Party software notices and licenses included in
  25. * WebWorldWind can be found in the WebWorldWind 3rd-party notices and licenses
  26. * PDF found in code directory.
  27. */
  28. /**
  29. * @exports WmsTimeDimensionedLayer
  30. */
  31. define([
  32. '../error/ArgumentError',
  33. '../layer/Layer',
  34. '../util/Logger',
  35. '../layer/WmsLayer'
  36. ],
  37. function (ArgumentError,
  38. Layer,
  39. Logger,
  40. WmsLayer) {
  41. "use strict";
  42. /**
  43. * Constructs a WMS time-dimensioned image layer.
  44. * @alias WmsTimeDimensionedLayer
  45. * @constructor
  46. * @augments Layer
  47. * @classdesc Displays a time-series WMS image layer. This layer contains a collection of {@link WmsLayer}s,
  48. * each representing a different time in a time sequence. Only the layer indicated by this layer's
  49. * [time]{@link WmsTimeDimensionedLayer#time} property is displayed during any frame.
  50. * @param {{}} config Specifies configuration information for the layer.
  51. * See the constructor description for {@link WmsLayer} for a description of the required properties.
  52. * @throws {ArgumentError} If the specified configuration is null or undefined.
  53. */
  54. var WmsTimeDimensionedLayer = function (config) {
  55. if (!config) {
  56. throw new ArgumentError(
  57. Logger.logMessage(Logger.LEVEL_SEVERE, "WmsTimeDimensionedLayer", "constructor",
  58. "No configuration specified."));
  59. }
  60. Layer.call(this, "WMS Time Dimensioned Layer");
  61. /**
  62. * The configuration object specified at construction.
  63. * @type {{}}
  64. * @readonly
  65. */
  66. this.config = config;
  67. // Intentionally not documented.
  68. this.displayName = config.title;
  69. this.pickEnabled = false;
  70. // Intentionally not documented. Contains the lazily loaded list of sub-layers.
  71. this.layers = {};
  72. };
  73. WmsTimeDimensionedLayer.prototype = Object.create(Layer.prototype);
  74. WmsTimeDimensionedLayer.prototype.doRender = function (dc) {
  75. if (this.time) {
  76. var currentTimeString = this.time.toISOString(),
  77. layer = this.layers[currentTimeString];
  78. if (!layer) {
  79. layer = new WmsLayer(this.config, currentTimeString);
  80. this.layers[currentTimeString] = layer;
  81. }
  82. layer.opacity = this.opacity;
  83. layer.doRender(dc);
  84. this.inCurrentFrame = layer.inCurrentFrame;
  85. }
  86. };
  87. return WmsTimeDimensionedLayer;
  88. });