Source: formats/kml/KmlCamera.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. define([
  29. './KmlElements',
  30. './KmlAbstractView',
  31. './util/KmlNodeTransformers'
  32. ], function (KmlElements,
  33. KmlAbstractView,
  34. NodeTransformers) {
  35. "use strict";
  36. /**
  37. * Constructs an KmlCamera. Applications usually don't call this constructor. It is called by {@link KmlFile} as
  38. * objects from Kml file are read. This object is already concrete implementation.
  39. * @alias KmlCamera
  40. * @classdesc Contains the data associated with Camera node.
  41. * @param options {Object}
  42. * @param options.objectNode {Node} Node representing camera in the document.
  43. * @constructor
  44. * @throws {ArgumentError} If the node is null or undefined.
  45. * @see https://developers.google.com/kml/documentation/kmlreference#camera
  46. * @augments KmlAbstractView
  47. */
  48. var KmlCamera = function (options) {
  49. KmlAbstractView.call(this, options);
  50. };
  51. KmlCamera.prototype = Object.create(KmlAbstractView.prototype);
  52. Object.defineProperties(KmlCamera.prototype, {
  53. /**
  54. * Longitude of the virtual camera (eye point). Angular distance in degrees, relative to the Prime Meridian.
  55. * Values west of the Meridian range from +-180 to 0 degrees. Values east of the Meridian range from 0
  56. * to 180 degrees.
  57. * @memberof KmlCamera.prototype
  58. * @readonly
  59. * @type {String}
  60. */
  61. kmlLongitude: {
  62. get: function () {
  63. return this._factory.specific(this, {name: 'longitude', transformer: NodeTransformers.string});
  64. }
  65. },
  66. /**
  67. * Latitude of the virtual camera. Degrees north or south of the Equator (0 degrees). Values range from -90
  68. * degrees to 90 degrees.
  69. * @memberof KmlCamera.prototype
  70. * @readonly
  71. * @type {String}
  72. */
  73. kmlLatitude: {
  74. get: function () {
  75. return this._factory.specific(this, {name: 'latitude', transformer: NodeTransformers.string});
  76. }
  77. },
  78. /**
  79. * Distance of the camera from the earth's surface, in meters. Interpreted according to the Camera's
  80. * <altitudeMode> or <gx:altitudeMode>.
  81. * @memberof KmlCamera.prototype
  82. * @readonly
  83. * @type {String}
  84. */
  85. kmlAltitude: {
  86. get: function () {
  87. return this._factory.specific(this, {name: 'altitude', transformer: NodeTransformers.string});
  88. }
  89. },
  90. /**
  91. * Direction (azimuth) of the camera, in degrees. Default=0 (true North). (See diagram.) Values range from
  92. * 0 to 360 degrees.
  93. * @memberof KmlCamera.prototype
  94. * @readonly
  95. * @type {String}
  96. */
  97. kmlHeading: {
  98. get: function () {
  99. return this._factory.specific(this, {name: 'heading', transformer: NodeTransformers.string});
  100. }
  101. },
  102. /**
  103. * Rotation, in degrees, of the camera around the X axis. A value of 0 indicates that the view is aimed
  104. * straight down toward the earth (the most common case). A value for 90 for <tilt> indicates that the
  105. * view
  106. * is aimed toward the horizon. Values greater than 90 indicate that the view is pointed up into the sky.
  107. * Values for <tilt> are clamped at +180 degrees.
  108. * @memberof KmlCamera.prototype
  109. * @readonly
  110. * @type {String}
  111. */
  112. kmlTilt: {
  113. get: function () {
  114. return this._factory.specific(this, {name: 'tilt', transformer: NodeTransformers.string});
  115. }
  116. },
  117. /**
  118. * Rotation, in degrees, of the camera around the Z axis. Values range from -180 to +180 degrees.
  119. * @memberof KmlCamera.prototype
  120. * @readonly
  121. * @type {String}
  122. */
  123. kmlRoll: {
  124. get: function () {
  125. return this._factory.specific(this, {name: 'roll', transformer: NodeTransformers.string});
  126. }
  127. },
  128. /**
  129. * Specifies how the <altitude> specified for the Camera is interpreted. Possible values are as
  130. * follows:
  131. * relativeToGround - (default) Interprets the <altitude> as a value in meters above the ground. If the
  132. * point is over water, the <altitude> will be interpreted as a value in meters above sea level. See
  133. * <gx:altitudeMode> below to specify points relative to the sea floor. clampToGround - For a camera, this
  134. * setting also places the camera relativeToGround, since putting the camera exactly at terrain height
  135. * would
  136. * mean that the eye would intersect the terrain (and the view would be blocked). absolute - Interprets the
  137. * <altitude> as a value in meters above sea level.
  138. * @memberof KmlCamera.prototype
  139. * @readonly
  140. * @type {String}
  141. */
  142. kmlAltitudeMode: {
  143. get: function () {
  144. return this._factory.specific(this, {name: 'altitudeMode', transformer: NodeTransformers.string});
  145. }
  146. }
  147. });
  148. /**
  149. * @inheritDoc
  150. */
  151. KmlCamera.prototype.getTagNames = function () {
  152. return ['Camera'];
  153. };
  154. KmlElements.addKey(KmlCamera.prototype.getTagNames()[0], KmlCamera);
  155. return KmlCamera;
  156. });