Source: layer/RestTiledImageLayer.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 RestTiledImageLayer
  30. */
  31. define([
  32. '../error/ArgumentError',
  33. '../geom/Location',
  34. '../util/Logger',
  35. '../geom/Sector',
  36. '../layer/TiledImageLayer',
  37. '../util/LevelRowColumnUrlBuilder',
  38. '../util/WWUtil'
  39. ],
  40. function (ArgumentError,
  41. Location,
  42. Logger,
  43. Sector,
  44. TiledImageLayer,
  45. LevelRowColumnUrlBuilder,
  46. WWUtil) {
  47. "use strict";
  48. /**
  49. * Constructs a tiled image layer that uses a REST interface to retrieve its imagery.
  50. * @alias RestTiledImageLayer
  51. * @constructor
  52. * @augments TiledImageLayer
  53. * @classdesc Displays a layer whose imagery is retrieved using a REST interface.
  54. * See [LevelRowColumnUrlBuilder]{@link LevelRowColumnUrlBuilder} for a description of the REST interface.
  55. * @param {String} serverAddress The server address of the tile service. May be null, in which case the
  56. * current origin is used (see window.location).
  57. * @param {String} pathToData The path to the data directory relative to the specified server address.
  58. * May be null, in which case the server address is assumed to be the full path to the data directory.
  59. * @param {String} displayName The display name to associate with this layer.
  60. * @param {{}} configuration The tiled image layer configuration. May have the following properties:
  61. * <ul>
  62. * <li>sector {Sector}, default is full sphere</li>
  63. * <li>levelZerotTileDelta {Location}, default is 45, 45</li>
  64. * <li>numLevels {Number}, default is 5</li>
  65. * <li>imageFormat {String}, default is image/jpeg</li>
  66. * <li>tileWidth {Number}, default is 256</li>
  67. * <li>tileHeight {Number}, default is 256</li>
  68. * </ul>
  69. * The specified default is used for any property not specified.
  70. */
  71. var RestTiledImageLayer = function (serverAddress, pathToData, displayName, configuration) {
  72. var cachePath = WWUtil.urlPath(serverAddress + "/" + pathToData);
  73. TiledImageLayer.call(this,
  74. (configuration && configuration.sector) || Sector.FULL_SPHERE,
  75. (configuration && configuration.levelZeroTileDelta) || new Location(45, 45),
  76. (configuration && configuration.numLevels) || 5,
  77. (configuration && configuration.imageFormat) || "image/jpeg",
  78. cachePath,
  79. (configuration && configuration.tileWidth) || 256,
  80. (configuration && configuration.tileHeight) || 256);
  81. this.displayName = displayName;
  82. this.pickEnabled = false;
  83. this.urlBuilder = new LevelRowColumnUrlBuilder(serverAddress, pathToData);
  84. };
  85. RestTiledImageLayer.prototype = Object.create(TiledImageLayer.prototype);
  86. return RestTiledImageLayer;
  87. });