@openglobus/og 0.11.1 → 0.11.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (255) hide show
  1. package/package.json +18 -20
  2. package/src/og/Clock.js +11 -11
  3. package/src/og/Deferred.js +1 -1
  4. package/src/og/Events.js +9 -7
  5. package/src/og/Extent.js +117 -72
  6. package/src/og/Globe.js +35 -22
  7. package/src/og/ImageCanvas.js +24 -18
  8. package/src/og/Lock.js +2 -2
  9. package/src/og/LonLat.js +40 -37
  10. package/src/og/Popup.js +21 -15
  11. package/src/og/QueueArray.js +7 -3
  12. package/src/og/Rectangle.js +11 -6
  13. package/src/og/Stack.js +8 -5
  14. package/src/og/ajax.js +21 -33
  15. package/src/og/astro/astro.js +5 -5
  16. package/src/og/astro/earth.js +23 -17
  17. package/src/og/astro/jd.js +44 -39
  18. package/src/og/astro/orbit.js +20 -18
  19. package/src/og/astro/rotation.js +17 -8
  20. package/src/og/bv/Box.js +7 -3
  21. package/src/og/bv/Sphere.js +17 -9
  22. package/src/og/camera/Camera.js +137 -86
  23. package/src/og/camera/Frustum.js +30 -19
  24. package/src/og/camera/PlanetCamera.js +30 -26
  25. package/src/og/control/CompassButton.js +8 -2
  26. package/src/og/control/Control.js +13 -11
  27. package/src/og/control/DebugInfo.js +4 -1
  28. package/src/og/control/EarthCoordinates.js +62 -41
  29. package/src/og/control/EarthNavigation.js +20 -22
  30. package/src/og/control/GeoImageDragControl.js +1 -1
  31. package/src/og/control/KeyboardNavigation.js +12 -12
  32. package/src/og/control/LayerSwitcher.js +24 -23
  33. package/src/og/control/Lighting.js +1 -1
  34. package/src/og/control/MouseNavigation.js +1 -1
  35. package/src/og/control/ScaleControl.js +1 -1
  36. package/src/og/control/SegmentBoundVisualization.js +8 -9
  37. package/src/og/control/ShowFps.js +15 -10
  38. package/src/og/control/SimpleNavigation.js +8 -10
  39. package/src/og/control/Sun.js +25 -15
  40. package/src/og/control/ToggleWireframe.js +5 -5
  41. package/src/og/control/TouchNavigation.js +58 -45
  42. package/src/og/control/ZoomControl.js +41 -25
  43. package/src/og/control/index.js +4 -0
  44. package/src/og/ellipsoid/Ellipsoid.js +181 -85
  45. package/src/og/ellipsoid/wgs84.js +4 -4
  46. package/src/og/entity/BaseBillboard.js +97 -44
  47. package/src/og/entity/Billboard.js +15 -11
  48. package/src/og/entity/BillboardHandler.js +314 -64
  49. package/src/og/entity/Entity.js +106 -74
  50. package/src/og/entity/EntityCollection.js +72 -49
  51. package/src/og/entity/GeoObject.js +228 -0
  52. package/src/og/entity/GeoObjectHandler.js +910 -0
  53. package/src/og/entity/Geometry.js +29 -26
  54. package/src/og/entity/GeometryHandler.js +598 -126
  55. package/src/og/entity/Label.js +74 -40
  56. package/src/og/entity/LabelHandler.js +47 -246
  57. package/src/og/entity/LabelWorker.js +213 -0
  58. package/src/og/entity/Object3d.js +504 -0
  59. package/src/og/entity/PointCloud.js +81 -33
  60. package/src/og/entity/PointCloudHandler.js +9 -9
  61. package/src/og/entity/Polyline.js +39 -39
  62. package/src/og/entity/Ray.js +61 -28
  63. package/src/og/entity/ShapeHandler.js +1 -1
  64. package/src/og/entity/Strip.js +77 -48
  65. package/src/og/entity/StripHandler.js +27 -27
  66. package/src/og/entity/index.js +8 -16
  67. package/src/og/input/KeyboardHandler.js +107 -104
  68. package/src/og/input/MouseHandler.js +81 -78
  69. package/src/og/input/TouchHandler.js +55 -51
  70. package/src/og/layer/BaseGeoImage.js +61 -30
  71. package/src/og/layer/CanvasTiles.js +26 -24
  72. package/src/og/layer/GeoImage.js +10 -10
  73. package/src/og/layer/GeoTexture2d.js +1 -1
  74. package/src/og/layer/GeoVideo.js +3 -3
  75. package/src/og/layer/KML.js +66 -40
  76. package/src/og/layer/Layer.js +27 -17
  77. package/src/og/layer/Material.js +93 -61
  78. package/src/og/layer/Vector.js +118 -72
  79. package/src/og/layer/WMS.js +36 -19
  80. package/src/og/layer/XYZ.js +55 -48
  81. package/src/og/light/LightSource.js +47 -40
  82. package/src/og/math/Line2.js +24 -24
  83. package/src/og/math/Line3.js +103 -102
  84. package/src/og/math/Mat3.js +134 -121
  85. package/src/og/math/Mat4.js +603 -459
  86. package/src/og/math/Plane.js +21 -20
  87. package/src/og/math/Quat.js +980 -927
  88. package/src/og/math/Ray.js +195 -187
  89. package/src/og/math/Vec2.js +127 -117
  90. package/src/og/math/Vec3.js +206 -176
  91. package/src/og/math/Vec4.js +49 -53
  92. package/src/og/math/coder.js +18 -18
  93. package/src/og/math.js +12 -12
  94. package/src/og/mercator.js +11 -11
  95. package/src/og/proj/EPSG3857.js +4 -4
  96. package/src/og/proj/EPSG4326.js +4 -4
  97. package/src/og/proj/Proj.js +31 -31
  98. package/src/og/quadTree/EntityCollectionNode.js +310 -300
  99. package/src/og/quadTree/Node.js +1008 -993
  100. package/src/og/renderer/Renderer.js +768 -747
  101. package/src/og/renderer/RendererEvents.js +9 -6
  102. package/src/og/scene/Axes.js +1 -1
  103. package/src/og/scene/BaseNode.js +8 -9
  104. package/src/og/scene/Planet.js +115 -87
  105. package/src/og/scene/RenderNode.js +29 -22
  106. package/src/og/scene/SkyBox.js +1 -1
  107. package/src/og/segment/Segment.js +1886 -1878
  108. package/src/og/segment/SegmentLonLat.js +298 -268
  109. package/src/og/segment/segmentHelper.js +11 -11
  110. package/src/og/shaders/bloom.js +1 -1
  111. package/src/og/shaders/blur.js +2 -2
  112. package/src/og/shaders/depth.js +1 -1
  113. package/src/og/shaders/geoObject.js +211 -0
  114. package/src/og/shaders/label.js +1 -1
  115. package/src/og/shaders/lumFilter.js +1 -1
  116. package/src/og/shaders/pointCloud.js +42 -42
  117. package/src/og/shaders/screenFrame.js +1 -1
  118. package/src/og/shaders/shape.js +15 -21
  119. package/src/og/shaders/skybox.js +37 -37
  120. package/src/og/shaders/toneMapping.js +1 -1
  121. package/src/og/shapes/BaseShape.js +129 -57
  122. package/src/og/shapes/Icosphere.js +30 -15
  123. package/src/og/shapes/Sphere.js +13 -16
  124. package/src/og/terrain/BilTerrain.js +2 -1
  125. package/src/og/terrain/EmptyTerrain.js +2 -2
  126. package/src/og/terrain/Geoid.js +2 -2
  127. package/src/og/terrain/GlobusTerrain.js +10 -10
  128. package/src/og/terrain/MapboxTerrain.js +1 -1
  129. package/src/og/utils/GeoImageCreator.js +9 -9
  130. package/src/og/utils/Loader.js +6 -6
  131. package/src/og/utils/NormalMapCreator.js +13 -13
  132. package/src/og/utils/TerrainWorker.js +1 -1
  133. package/src/og/utils/TextureAtlas.js +20 -22
  134. package/src/og/utils/VectorTileCreator.js +5 -5
  135. package/src/og/utils/earcut.js +1 -1
  136. package/src/og/utils/shared.js +15 -15
  137. package/src/og/webgl/Framebuffer.js +101 -53
  138. package/src/og/webgl/Handler.js +125 -85
  139. package/src/og/webgl/Multisample.js +55 -27
  140. package/src/og/webgl/Program.js +80 -35
  141. package/src/og/webgl/ProgramController.js +27 -23
  142. package/src/og/webgl/callbacks.js +8 -8
  143. package/types/Clock.d.ts +6 -2
  144. package/types/Deferred.d.ts +1 -1
  145. package/types/Events.d.ts +8 -4
  146. package/types/Extent.d.ts +37 -33
  147. package/types/Globe.d.ts +15 -13
  148. package/types/ImageCanvas.d.ts +5 -3
  149. package/types/LonLat.d.ts +24 -24
  150. package/types/Popup.d.ts +4 -0
  151. package/types/QueueArray.d.ts +6 -2
  152. package/types/Rectangle.d.ts +10 -4
  153. package/types/Stack.d.ts +4 -0
  154. package/types/ajax.d.ts +1 -1
  155. package/types/astro/earth.d.ts +3 -2
  156. package/types/bv/Box.d.ts +10 -5
  157. package/types/bv/Sphere.d.ts +13 -7
  158. package/types/camera/Camera.d.ts +90 -81
  159. package/types/camera/Frustum.d.ts +26 -22
  160. package/types/camera/PlanetCamera.d.ts +49 -53
  161. package/types/control/CompassButton.d.ts +4 -4
  162. package/types/control/Control.d.ts +7 -4
  163. package/types/control/DebugInfo.d.ts +3 -4
  164. package/types/control/EarthCoordinates.d.ts +6 -6
  165. package/types/control/EarthNavigation.d.ts +42 -0
  166. package/types/control/KeyboardNavigation.d.ts +3 -4
  167. package/types/control/LayerSwitcher.d.ts +3 -5
  168. package/types/control/Lighting.d.ts +3 -3
  169. package/types/control/MouseNavigation.d.ts +47 -0
  170. package/types/control/ScaleControl.d.ts +3 -3
  171. package/types/control/ShowFps.d.ts +3 -4
  172. package/types/control/SimpleNavigation.d.ts +3 -6
  173. package/types/control/Sun.d.ts +8 -10
  174. package/types/control/ToggleWireframe.d.ts +3 -3
  175. package/types/control/TouchNavigation.d.ts +48 -0
  176. package/types/control/ZoomControl.d.ts +3 -4
  177. package/types/control/index.d.ts +3 -1
  178. package/types/ellipsoid/Ellipsoid.d.ts +47 -43
  179. package/types/ellipsoid/wgs84.d.ts +3 -2
  180. package/types/entity/BaseBillboard.d.ts +41 -34
  181. package/types/entity/Billboard.d.ts +7 -7
  182. package/types/entity/BillboardHandler.d.ts +4 -0
  183. package/types/entity/Entity.d.ts +101 -83
  184. package/types/entity/EntityCollection.d.ts +57 -43
  185. package/types/entity/GeoObject.d.ts +111 -0
  186. package/types/entity/GeoObjectHandler.d.ts +77 -0
  187. package/types/entity/Geometry.d.ts +9 -7
  188. package/types/entity/GeometryHandler.d.ts +2 -2
  189. package/types/entity/Label.d.ts +24 -29
  190. package/types/entity/LabelHandler.d.ts +9 -2
  191. package/types/entity/LabelWorker.d.ts +9 -0
  192. package/types/entity/PointCloud.d.ts +8 -8
  193. package/types/entity/PointCloudHandler.d.ts +3 -3
  194. package/types/entity/Polyline.d.ts +58 -55
  195. package/types/entity/Ray.d.ts +19 -18
  196. package/types/entity/Strip.d.ts +8 -7
  197. package/types/entity/StripHandler.d.ts +3 -3
  198. package/types/entity/index.d.ts +7 -7
  199. package/types/input/KeyboardHandler.d.ts +10 -0
  200. package/types/input/MouseHandler.d.ts +5 -0
  201. package/types/input/TouchHandler.d.ts +5 -0
  202. package/types/layer/BaseGeoImage.d.ts +23 -35
  203. package/types/layer/CanvasTiles.d.ts +15 -22
  204. package/types/layer/GeoImage.d.ts +5 -18
  205. package/types/layer/GeoVideo.d.ts +5 -30
  206. package/types/layer/KML.d.ts +20 -15
  207. package/types/layer/Layer.d.ts +326 -0
  208. package/types/layer/Material.d.ts +45 -0
  209. package/types/layer/Vector.d.ts +208 -0
  210. package/types/layer/WMS.d.ts +4 -7
  211. package/types/layer/XYZ.d.ts +19 -25
  212. package/types/light/LightSource.d.ts +54 -53
  213. package/types/math/Line2.d.ts +11 -0
  214. package/types/math/Line3.d.ts +10 -0
  215. package/types/math/Mat3.d.ts +30 -18
  216. package/types/math/Mat4.d.ts +71 -52
  217. package/types/math/Plane.d.ts +5 -4
  218. package/types/math/Quat.d.ts +379 -0
  219. package/types/math/Ray.d.ts +82 -0
  220. package/types/math/Vec2.d.ts +102 -101
  221. package/types/math/Vec3.d.ts +143 -142
  222. package/types/math/Vec4.d.ts +40 -39
  223. package/types/math/coder.d.ts +12 -11
  224. package/types/math.d.ts +8 -8
  225. package/types/mercator.d.ts +3 -3
  226. package/types/proj/EPSG3857.d.ts +3 -2
  227. package/types/proj/EPSG4326.d.ts +3 -2
  228. package/types/proj/Proj.d.ts +42 -0
  229. package/types/quadTree/EntityCollectionNode.d.ts +34 -0
  230. package/types/quadTree/Node.d.ts +61 -0
  231. package/types/renderer/Renderer.d.ts +300 -0
  232. package/types/renderer/RendererEvents.d.ts +10 -7
  233. package/types/scene/BaseNode.d.ts +9 -9
  234. package/types/scene/Planet.d.ts +131 -126
  235. package/types/scene/RenderNode.d.ts +22 -23
  236. package/types/segment/Segment.d.ts +279 -0
  237. package/types/segment/SegmentLonLat.d.ts +16 -0
  238. package/types/shaders/geoObject.d.ts +3 -0
  239. package/types/shapes/BaseShape.d.ts +43 -40
  240. package/types/shapes/Sphere.d.ts +7 -7
  241. package/types/terrain/BilTerrain.d.ts +0 -1
  242. package/types/terrain/EmptyTerrain.d.ts +4 -4
  243. package/types/terrain/GlobusTerrain.d.ts +17 -54
  244. package/types/terrain/MapboxTerrain.d.ts +0 -1
  245. package/types/utils/GeoImageCreator.d.ts +3 -2
  246. package/types/utils/TextureAtlas.d.ts +8 -8
  247. package/types/utils/shared.d.ts +25 -24
  248. package/types/webgl/Framebuffer.d.ts +5 -5
  249. package/types/webgl/Handler.d.ts +68 -43
  250. package/types/webgl/Multisample.d.ts +5 -5
  251. package/types/webgl/Program.d.ts +8 -2
  252. package/types/webgl/ProgramController.d.ts +18 -13
  253. package/src/og/inherits.js +0 -8
  254. package/src/og/utils/polylabel.js +0 -176
  255. package/types/inherits.d.ts +0 -4
@@ -2,11 +2,11 @@
2
2
  * @module og/ellipsoid/Ellipsoid
3
3
  */
4
4
 
5
- 'use strict';
5
+ "use strict";
6
6
 
7
- import * as math from '../math.js';
8
- import { Vec3 } from '../math/Vec3.js';
9
- import { LonLat } from '../LonLat.js';
7
+ import * as math from "../math.js";
8
+ import { Vec3 } from "../math/Vec3.js";
9
+ import { LonLat } from "../LonLat.js";
10
10
 
11
11
  /**
12
12
  * Class represents a plant ellipsoid.
@@ -15,6 +15,10 @@ import { LonLat } from '../LonLat.js';
15
15
  * @param {number} polarSize - Polar ellipsoid size.
16
16
  */
17
17
  class Ellipsoid {
18
+ /**
19
+ * @param {number} equatorialSize - Equatorial ellipsoid size.
20
+ * @param {number} polarSize - Polar ellipsoid size.
21
+ */
18
22
  constructor(equatorialSize, polarSize) {
19
23
  this._a = equatorialSize;
20
24
  this._b = polarSize;
@@ -40,8 +44,10 @@ class Ellipsoid {
40
44
  }
41
45
 
42
46
  static getRelativeBearing(a, b) {
43
- let a_y = Math.cos(a), a_x = Math.sin(a),
44
- b_y = Math.cos(b), b_x = Math.sin(b);
47
+ let a_y = Math.cos(a),
48
+ a_x = Math.sin(a),
49
+ b_y = Math.cos(b),
50
+ b_x = Math.sin(b);
45
51
  let c = a_y * b_x - b_y * a_x,
46
52
  d = a_x * b_x + a_y * b_y;
47
53
  if (c > 0.0) {
@@ -52,9 +58,9 @@ class Ellipsoid {
52
58
 
53
59
  /**
54
60
  * Returns the midpoint between two points on the great circle.
55
- * @param {og.LonLat} lonLat1 - Longitude/latitude of first point.
56
- * @param {og.LonLat} lonLat2 - Longitude/latitude of second point.
57
- * @return {og.LonLat} Midpoint between points.
61
+ * @param {LonLat} lonLat1 - Longitude/latitude of first point.
62
+ * @param {LonLat} lonLat2 - Longitude/latitude of second point.
63
+ * @return {LonLat} Midpoint between points.
58
64
  */
59
65
  static getMiddlePointOnGreatCircle(lonLat1, lonLat2) {
60
66
  var f1 = lonLat1.lat * math.RADIANS,
@@ -71,26 +77,36 @@ class Ellipsoid {
71
77
 
72
78
  var l3 = l1 + Math.atan2(By, Math.cos(f1) + Bx);
73
79
 
74
- return new LonLat((l3 * math.DEGREES + 540) % 360 - 180, f3 * math.DEGREES);
80
+ return new LonLat(((l3 * math.DEGREES + 540) % 360) - 180, f3 * math.DEGREES);
75
81
  }
76
82
 
77
83
  /**
78
84
  * Returns the point at given fraction between two points on the great circle.
79
- * @param {og.LonLat} lonLat1 - Longitude/Latitude of source point.
80
- * @param {og.LonLat} lonLat2 - Longitude/Latitude of destination point.
85
+ * @param {LonLat} lonLat1 - Longitude/Latitude of source point.
86
+ * @param {LonLat} lonLat2 - Longitude/Latitude of destination point.
81
87
  * @param {number} fraction - Fraction between the two points (0 = source point, 1 = destination point).
82
- * @returns {og.LonLat} Intermediate point between points.
88
+ * @returns {LonLat} Intermediate point between points.
83
89
  */
84
90
  static getIntermediatePointOnGreatCircle(lonLat1, lonLat2, fraction) {
85
- var f1 = lonLat1.lat * math.RADIANS, l1 = lonLat1.lon * math.RADIANS;
86
- var f2 = lonLat2.lat * math.RADIANS, l2 = lonLat2.lon * math.RADIANS;
87
-
88
- var sinf1 = Math.sin(f1), cosf1 = Math.cos(f1), sinl1 = Math.sin(l1), cosl1 = Math.cos(l1);
89
- var sinf2 = Math.sin(f2), cosf2 = Math.cos(f2), sinl2 = Math.sin(l2), cosl2 = Math.cos(l2);
91
+ var f1 = lonLat1.lat * math.RADIANS,
92
+ l1 = lonLat1.lon * math.RADIANS;
93
+ var f2 = lonLat2.lat * math.RADIANS,
94
+ l2 = lonLat2.lon * math.RADIANS;
95
+
96
+ var sinf1 = Math.sin(f1),
97
+ cosf1 = Math.cos(f1),
98
+ sinl1 = Math.sin(l1),
99
+ cosl1 = Math.cos(l1);
100
+ var sinf2 = Math.sin(f2),
101
+ cosf2 = Math.cos(f2),
102
+ sinl2 = Math.sin(l2),
103
+ cosl2 = Math.cos(l2);
90
104
 
91
105
  var df = f2 - f1,
92
106
  dl = l2 - l1;
93
- var a = Math.sin(df / 2) * Math.sin(df / 2) + Math.cos(f1) * Math.cos(f2) * Math.sin(dl / 2) * Math.sin(dl / 2);
107
+ var a =
108
+ Math.sin(df / 2) * Math.sin(df / 2) +
109
+ Math.cos(f1) * Math.cos(f2) * Math.sin(dl / 2) * Math.sin(dl / 2);
94
110
  var d = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
95
111
 
96
112
  var A = Math.sin((1 - fraction) * d) / Math.sin(d);
@@ -103,12 +119,15 @@ class Ellipsoid {
103
119
  var f3 = Math.atan2(z, Math.sqrt(x * x + y * y));
104
120
  var l3 = Math.atan2(y, x);
105
121
 
106
- return new LonLat((l3 * math.DEGREES + 540) % 360 - 180, f3 * math.DEGREES);
122
+ return new LonLat(((l3 * math.DEGREES + 540) % 360) - 180, f3 * math.DEGREES);
107
123
  }
108
124
 
109
125
  static getRhumbBearing(lonLat1, lonLat2) {
110
126
  var dLon = (lonLat2.lon - lonLat1.lon) * math.RADIANS;
111
- var dPhi = Math.log(Math.tan(lonLat2.lat * math.RADIANS / 2 + Math.PI / 4) / Math.tan(lonLat1.lat * math.RADIANS / 2 + Math.PI / 4));
127
+ var dPhi = Math.log(
128
+ Math.tan((lonLat2.lat * math.RADIANS) / 2 + Math.PI / 4) /
129
+ Math.tan((lonLat1.lat * math.RADIANS) / 2 + Math.PI / 4)
130
+ );
112
131
  if (Math.abs(dLon) > Math.PI) {
113
132
  if (dLon > 0) {
114
133
  dLon = (2 * Math.PI - dLon) * -1;
@@ -120,8 +139,10 @@ class Ellipsoid {
120
139
  }
121
140
 
122
141
  static getBearing(lonLat1, lonLat2) {
123
- var f1 = lonLat1.lat * math.RADIANS, l1 = lonLat1.lon * math.RADIANS;
124
- var f2 = lonLat2.lat * math.RADIANS, l2 = lonLat2.lon * math.RADIANS;
142
+ var f1 = lonLat1.lat * math.RADIANS,
143
+ l1 = lonLat1.lon * math.RADIANS;
144
+ var f2 = lonLat2.lat * math.RADIANS,
145
+ l2 = lonLat2.lon * math.RADIANS;
125
146
  var y = Math.sin(l2 - l1) * Math.cos(f2);
126
147
  var x = Math.cos(f1) * Math.sin(f2) - Math.sin(f1) * Math.cos(f2) * Math.cos(l2 - l1);
127
148
  return Math.atan2(y, x) * math.DEGREES;
@@ -129,8 +150,8 @@ class Ellipsoid {
129
150
 
130
151
  /**
131
152
  * Returns the (initial) bearing from source to destination point on the great circle.
132
- * @param {og.LonLat} lonLat1 - Longitude/latitude of source point.
133
- * @param {og.LonLat} lonLat2 - Longitude/latitude of destination point.
153
+ * @param {LonLat} lonLat1 - Longitude/latitude of source point.
154
+ * @param {LonLat} lonLat2 - Longitude/latitude of destination point.
134
155
  * @return {number} Initial bearing in degrees from north.
135
156
  */
136
157
  static getInitialBearing(lonLat1, lonLat2) {
@@ -138,19 +159,18 @@ class Ellipsoid {
138
159
  f2 = lonLat2.lat * math.RADIANS;
139
160
  var dl = (lonLat2.lon - lonLat1.lon) * math.RADIANS;
140
161
  var y = Math.sin(dl) * Math.cos(f2);
141
- var x = Math.cos(f1) * Math.sin(f2) -
142
- Math.sin(f1) * Math.cos(f2) * Math.cos(dl);
162
+ var x = Math.cos(f1) * Math.sin(f2) - Math.sin(f1) * Math.cos(f2) * Math.cos(dl);
143
163
  var D = Math.atan2(y, x);
144
164
  return (D * math.DEGREES + 360) % 360;
145
165
  }
146
166
 
147
167
  /**
148
168
  * Returns the point of intersection of two paths defined by point and bearing.
149
- * @param {og.LonLat} p1 - First point.
169
+ * @param {LonLat} p1 - First point.
150
170
  * @param {number} brng1 - Initial bearing from first point.
151
- * @param {og.LonLat} p2 - Second point.
171
+ * @param {LonLat} p2 - Second point.
152
172
  * @param {number} brng2 - Initial bearing from second point.
153
- * @return {og.LonLat|null} Destination point (null if no unique intersection defined).
173
+ * @return {LonLat|null} Destination point (null if no unique intersection defined).
154
174
  */
155
175
  static intersection(p1, brng1, p2, brng2) {
156
176
  var f1 = p1.lat * math.RADIANS,
@@ -162,19 +182,30 @@ class Ellipsoid {
162
182
  var df = f2 - f1,
163
183
  dl = l2 - l1;
164
184
 
165
- var d12 = 2 * Math.asin(Math.sqrt(Math.sin(df / 2) * Math.sin(df / 2) + Math.cos(f1) * Math.cos(f2) * Math.sin(dl / 2) * Math.sin(dl / 2)));
185
+ var d12 =
186
+ 2 *
187
+ Math.asin(
188
+ Math.sqrt(
189
+ Math.sin(df / 2) * Math.sin(df / 2) +
190
+ Math.cos(f1) * Math.cos(f2) * Math.sin(dl / 2) * Math.sin(dl / 2)
191
+ )
192
+ );
166
193
  if (d12 == 0) return null;
167
194
 
168
195
  // initial/final bearings between points
169
- var Da = Math.acos((Math.sin(f2) - Math.sin(f1) * Math.cos(d12)) / (Math.sin(d12) * Math.cos(f1)));
196
+ var Da = Math.acos(
197
+ (Math.sin(f2) - Math.sin(f1) * Math.cos(d12)) / (Math.sin(d12) * Math.cos(f1))
198
+ );
170
199
  if (isNaN(Da)) Da = 0; // protect against rounding
171
- var Db = Math.acos((Math.sin(f1) - Math.sin(f2) * Math.cos(d12)) / (Math.sin(d12) * Math.cos(f2)));
200
+ var Db = Math.acos(
201
+ (Math.sin(f1) - Math.sin(f2) * Math.cos(d12)) / (Math.sin(d12) * Math.cos(f2))
202
+ );
172
203
 
173
204
  var D12 = Math.sin(l2 - l1) > 0 ? Da : 2 * Math.PI - Da;
174
205
  var D21 = Math.sin(l2 - l1) > 0 ? 2 * Math.PI - Db : Db;
175
206
 
176
- var a1 = (D13 - D12 + Math.PI) % (2 * Math.PI) - Math.PI;
177
- var a2 = (D21 - D23 + Math.PI) % (2 * Math.PI) - Math.PI;
207
+ var a1 = ((D13 - D12 + Math.PI) % (2 * Math.PI)) - Math.PI;
208
+ var a2 = ((D21 - D23 + Math.PI) % (2 * Math.PI)) - Math.PI;
178
209
 
179
210
  if (Math.sin(a1) == 0 && Math.sin(a2) == 0) return null; // infinite intersections
180
211
  if (Math.sin(a1) * Math.sin(a2) < 0) return null; // ambiguous intersection
@@ -183,20 +214,30 @@ class Ellipsoid {
183
214
  // a2 = Math.abs(a2);
184
215
  // ... Ed Williams takes abs of a1/a2, but seems to break calculation?
185
216
 
186
- var a3 = Math.acos(-Math.cos(a1) * Math.cos(a2) + Math.sin(a1) * Math.sin(a2) * Math.cos(d12));
187
- var d13 = Math.atan2(Math.sin(d12) * Math.sin(a1) * Math.sin(a2), Math.cos(a2) + Math.cos(a1) * Math.cos(a3));
188
- var f3 = Math.asin(Math.sin(f1) * Math.cos(d13) + Math.cos(f1) * Math.sin(d13) * Math.cos(D13));
189
- var dl13 = Math.atan2(Math.sin(D13) * Math.sin(d13) * Math.cos(f1), Math.cos(d13) - Math.sin(f1) * Math.sin(f3));
217
+ var a3 = Math.acos(
218
+ -Math.cos(a1) * Math.cos(a2) + Math.sin(a1) * Math.sin(a2) * Math.cos(d12)
219
+ );
220
+ var d13 = Math.atan2(
221
+ Math.sin(d12) * Math.sin(a1) * Math.sin(a2),
222
+ Math.cos(a2) + Math.cos(a1) * Math.cos(a3)
223
+ );
224
+ var f3 = Math.asin(
225
+ Math.sin(f1) * Math.cos(d13) + Math.cos(f1) * Math.sin(d13) * Math.cos(D13)
226
+ );
227
+ var dl13 = Math.atan2(
228
+ Math.sin(D13) * Math.sin(d13) * Math.cos(f1),
229
+ Math.cos(d13) - Math.sin(f1) * Math.sin(f3)
230
+ );
190
231
  var l3 = l1 + dl13;
191
232
 
192
- return new LonLat((l3 * math.DEGREES + 540) % 360 - 180, f3 * math.DEGREES);
233
+ return new LonLat(((l3 * math.DEGREES + 540) % 360) - 180, f3 * math.DEGREES);
193
234
  }
194
235
 
195
236
  /**
196
237
  * Returns final bearing arriving at destination destination point from lonLat1 point; the final bearing
197
238
  * will differ from the initial bearing by varying degrees according to distance and latitude.
198
- * @param {og.LonLat} lonLat1 - Longitude/latitude of source point.
199
- * @param {og.LonLat} lonLat2 - Longitude/latitude of destination point.
239
+ * @param {LonLat} lonLat1 - Longitude/latitude of source point.
240
+ * @param {LonLat} lonLat2 - Longitude/latitude of destination point.
200
241
  * @return {number} Final bearing in degrees from north.
201
242
  */
202
243
  static getFinalBearing(lonLat1, lonLat2) {
@@ -225,8 +266,8 @@ class Ellipsoid {
225
266
  /**
226
267
  * Gets cartesian ECEF from Wgs84 geodetic coordiantes.
227
268
  * @public
228
- * @param {og.LonLat} lonlat - Degrees geodetic coordiantes.
229
- * @returns {og.Vec3} -
269
+ * @param {LonLat} lonlat - Degrees geodetic coordiantes.
270
+ * @returns {Vec3} -
230
271
  */
231
272
  lonLatToCartesian(lonlat) {
232
273
  var latrad = math.RADIANS * lonlat.lat,
@@ -240,15 +281,16 @@ class Ellipsoid {
240
281
  return new Vec3(
241
282
  nc * Math.sin(lonrad),
242
283
  (N * (1.0 - this._e2) + lonlat.height) * slt,
243
- nc * Math.cos(lonrad));
284
+ nc * Math.cos(lonrad)
285
+ );
244
286
  }
245
287
 
246
288
  /**
247
289
  * Gets cartesian ECEF from Wgs84 geodetic coordiantes.
248
290
  * @public
249
- * @param {og.LonLat} lonlat - Degrees geodetic coordiantes.
250
- * @param {og.Vec3} res - Output result.
251
- * @returns {og.Vec3} -
291
+ * @param {LonLat} lonlat - Degrees geodetic coordiantes.
292
+ * @param {Vec3} res - Output result.
293
+ * @returns {Vec3} -
252
294
  */
253
295
  lonLatToCartesianRes(lonlat, res) {
254
296
  var latrad = math.RADIANS * lonlat.lat,
@@ -272,7 +314,7 @@ class Ellipsoid {
272
314
  * @param {Number} lon - Longitude.
273
315
  * @param {Number} lat - Latitude.
274
316
  * @param {Number} height - Height.
275
- * @returns {og.Vec3} -
317
+ * @returns {Vec3} -
276
318
  */
277
319
  geodeticToCartesian(lon, lat, height = 0) {
278
320
  var latrad = math.RADIANS * lat,
@@ -286,17 +328,20 @@ class Ellipsoid {
286
328
  return new Vec3(
287
329
  nc * Math.sin(lonrad),
288
330
  (N * (1 - this._e2) + height) * slt,
289
- nc * Math.cos(lonrad));
331
+ nc * Math.cos(lonrad)
332
+ );
290
333
  }
291
334
 
292
335
  /**
293
336
  * Gets Wgs84 geodetic coordiantes from cartesian ECEF.
294
337
  * @public
295
- * @param {og.Vec3} cartesian - Cartesian coordinates.
296
- * @returns {og.LonLat} -
338
+ * @param {Vec3} cartesian - Cartesian coordinates.
339
+ * @returns {LonLat} -
297
340
  */
298
341
  cartesianToLonLat(cartesian) {
299
- var x = cartesian.z, y = cartesian.x, z = cartesian.y;
342
+ var x = cartesian.z,
343
+ y = cartesian.x,
344
+ z = cartesian.y;
300
345
  var ecc2 = this._e2;
301
346
  var ecc22 = this._e22;
302
347
  var r2 = x * x + y * y;
@@ -305,24 +350,37 @@ class Ellipsoid {
305
350
  var f = 54.0 * this._b2 * z2;
306
351
  var g = r2 + (1.0 - ecc2) * z2 + ecc2 * (this._a2 - this._b2);
307
352
  var g2 = g * g;
308
- var c = ecc22 * f * r2 / (g2 * g);
309
- var s = Math.pow((1.0 + c + Math.sqrt(c * (c + 2.0))), 0.33333333333333333);
310
- var p = f / (3.0 * Math.pow((1.0 + s + 1.0 / s), 2.0) * g2);
353
+ var c = (ecc22 * f * r2) / (g2 * g);
354
+ var s = Math.pow(1.0 + c + Math.sqrt(c * (c + 2.0)), 0.33333333333333333);
355
+ var p = f / (3.0 * Math.pow(1.0 + s + 1.0 / s, 2.0) * g2);
311
356
  var q = Math.sqrt(1.0 + 2.0 * ecc22 * p);
312
- var recc2r0 = r - ecc2 * (-(p * ecc2 * r) / 1 + q + Math.sqrt(0.5 * this._a2 * (1.0 + 1.0 / q) - p * (1.0 - ecc2) * z2 / (q * (1.0 + q)) - 0.5 * p * r2));
357
+ var recc2r0 =
358
+ r -
359
+ ecc2 *
360
+ (-(p * ecc2 * r) / 1 +
361
+ q +
362
+ Math.sqrt(
363
+ 0.5 * this._a2 * (1.0 + 1.0 / q) -
364
+ (p * (1.0 - ecc2) * z2) / (q * (1.0 + q)) -
365
+ 0.5 * p * r2
366
+ ));
313
367
  var recc2r02 = recc2r0 * recc2r0;
314
368
  var v = Math.sqrt(recc2r02 + (1.0 - ecc2) * z2);
315
- var z0 = this._b2 * z / (this._a * v);
369
+ var z0 = (this._b2 * z) / (this._a * v);
316
370
  var lat = Math.atan((z + this._k2 * z0) / r) * math.DEGREES;
317
371
  var lon = Math.atan2(y, x) * math.DEGREES;
318
- return new LonLat(lon, lat, cartesian.length() - this.geodeticToCartesian(lon, lat).length());
372
+ return new LonLat(
373
+ lon,
374
+ lat,
375
+ cartesian.length() - this.geodeticToCartesian(lon, lat).length()
376
+ );
319
377
  }
320
378
 
321
379
  /**
322
380
  * Gets ellipsoid surface normal.
323
381
  * @public
324
- * @param {og.Vec3} coord - Spatial coordiantes.
325
- * @returns {og.Vec3} -
382
+ * @param {Vec3} coord - Spatial coordiantes.
383
+ * @returns {Vec3} -
326
384
  */
327
385
  getSurfaceNormal3v(coord) {
328
386
  var r2 = this._invRadii2;
@@ -335,24 +393,39 @@ class Ellipsoid {
335
393
 
336
394
  getBearingDestination(lonLat1, bearing, distance) {
337
395
  bearing = bearing * math.RADIANS;
338
- var nlon = (lonLat1.lon + 540) % 360 - 180;
339
- var f1 = lonLat1.lat * math.RADIANS, l1 = nlon * math.RADIANS;
396
+ var nlon = ((lonLat1.lon + 540) % 360) - 180;
397
+ var f1 = lonLat1.lat * math.RADIANS,
398
+ l1 = nlon * math.RADIANS;
340
399
  var dR = distance / this._a;
341
- var f2 = Math.asin(Math.sin(f1) * Math.cos(dR) + Math.cos(f1) * Math.sin(dR) * Math.cos(bearing));
342
- return new LonLat((l1 + Math.atan2(Math.sin(bearing) * Math.sin(dR) * Math.cos(f1), Math.cos(dR) - Math.sin(f1) * Math.sin(f2))) * math.DEGREES, f2 * math.DEGREES);
400
+ var f2 = Math.asin(
401
+ Math.sin(f1) * Math.cos(dR) + Math.cos(f1) * Math.sin(dR) * Math.cos(bearing)
402
+ );
403
+ return new LonLat(
404
+ (l1 +
405
+ Math.atan2(
406
+ Math.sin(bearing) * Math.sin(dR) * Math.cos(f1),
407
+ Math.cos(dR) - Math.sin(f1) * Math.sin(f2)
408
+ )) *
409
+ math.DEGREES,
410
+ f2 * math.DEGREES
411
+ );
343
412
  }
344
413
 
345
414
  /**
346
415
  * Returns the distance from one point to another(using haversine formula) on the great circle.
347
- * @param {og.LonLat} lonLat1 - Longitude/latitude of source point.
348
- * @param {og.LonLat} lonLat2 - Longitude/latitude of destination point.
416
+ * @param {LonLat} lonLat1 - Longitude/latitude of source point.
417
+ * @param {LonLat} lonLat2 - Longitude/latitude of destination point.
349
418
  * @return {number} Distance between points.
350
419
  */
351
420
  getGreatCircleDistance(lonLat1, lonLat2) {
352
421
  var dLat = (lonLat2.lat - lonLat1.lat) * math.RADIANS;
353
422
  var dLon = (lonLat2.lon - lonLat1.lon) * math.RADIANS;
354
- var a = Math.sin(dLat / 2.0) * Math.sin(dLat / 2.0) +
355
- Math.sin(dLon / 2.0) * Math.sin(dLon / 2) * Math.cos(lonLat1.lat * math.RADIANS) * Math.cos(lonLat2.lat * math.RADIANS);
423
+ var a =
424
+ Math.sin(dLat / 2.0) * Math.sin(dLat / 2.0) +
425
+ Math.sin(dLon / 2.0) *
426
+ Math.sin(dLon / 2) *
427
+ Math.cos(lonLat1.lat * math.RADIANS) *
428
+ Math.cos(lonLat2.lat * math.RADIANS);
356
429
  return this._a * 2.0 * Math.atan2(Math.sqrt(a), Math.sqrt(1.0 - a));
357
430
  }
358
431
 
@@ -373,28 +446,52 @@ class Ellipsoid {
373
446
  sinAlpha1 = Math.sin(alpha1),
374
447
  cosAlpha1 = Math.cos(alpha1),
375
448
  tanU1 = (1 - f) * Math.tan(lat1 * math.RADIANS),
376
- cosU1 = 1 / Math.sqrt((1 + tanU1 * tanU1)), sinU1 = tanU1 * cosU1,
449
+ cosU1 = 1 / Math.sqrt(1 + tanU1 * tanU1),
450
+ sinU1 = tanU1 * cosU1,
377
451
  sigma1 = Math.atan2(tanU1, cosAlpha1),
378
452
  sinAlpha = cosU1 * sinAlpha1,
379
453
  cosSqAlpha = 1 - sinAlpha * sinAlpha,
380
- uSq = cosSqAlpha * (a * a - b * b) / (b * b),
381
- A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq))),
382
- B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq))),
454
+ uSq = (cosSqAlpha * (a * a - b * b)) / (b * b),
455
+ A = 1 + (uSq / 16384) * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq))),
456
+ B = (uSq / 1024) * (256 + uSq * (-128 + uSq * (74 - 47 * uSq))),
383
457
  sigma = s / (b * A),
384
458
  sigmaP = 2 * Math.PI;
385
459
  while (Math.abs(sigma - sigmaP) > 1e-12) {
386
460
  var cos2SigmaM = Math.cos(2 * sigma1 + sigma),
387
461
  sinSigma = Math.sin(sigma),
388
462
  cosSigma = Math.cos(sigma),
389
- deltaSigma = B * sinSigma * (cos2SigmaM + B / 4 * (cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM) - B / 6 * cos2SigmaM * (-3 + 4 * sinSigma * sinSigma) * (-3 + 4 * cos2SigmaM * cos2SigmaM)));
463
+ deltaSigma =
464
+ B *
465
+ sinSigma *
466
+ (cos2SigmaM +
467
+ (B / 4) *
468
+ (cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM) -
469
+ (B / 6) *
470
+ cos2SigmaM *
471
+ (-3 + 4 * sinSigma * sinSigma) *
472
+ (-3 + 4 * cos2SigmaM * cos2SigmaM)));
390
473
  sigmaP = sigma;
391
474
  sigma = s / (b * A) + deltaSigma;
392
- };
475
+ }
393
476
  var tmp = sinU1 * sinSigma - cosU1 * cosSigma * cosAlpha1,
394
- lat2 = Math.atan2(sinU1 * cosSigma + cosU1 * sinSigma * cosAlpha1, (1 - f) * Math.sqrt(sinAlpha * sinAlpha + tmp * tmp)),
395
- lambda = Math.atan2(sinSigma * sinAlpha1, cosU1 * cosSigma - sinU1 * sinSigma * cosAlpha1),
396
- C = f / 16 * cosSqAlpha * (4 + f * (4 - 3 * cosSqAlpha)),
397
- L = lambda - (1 - C) * f * sinAlpha * (sigma + C * sinSigma * (cos2SigmaM + C * cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM))),
477
+ lat2 = Math.atan2(
478
+ sinU1 * cosSigma + cosU1 * sinSigma * cosAlpha1,
479
+ (1 - f) * Math.sqrt(sinAlpha * sinAlpha + tmp * tmp)
480
+ ),
481
+ lambda = Math.atan2(
482
+ sinSigma * sinAlpha1,
483
+ cosU1 * cosSigma - sinU1 * sinSigma * cosAlpha1
484
+ ),
485
+ C = (f / 16) * cosSqAlpha * (4 + f * (4 - 3 * cosSqAlpha)),
486
+ L =
487
+ lambda -
488
+ (1 - C) *
489
+ f *
490
+ sinAlpha *
491
+ (sigma +
492
+ C *
493
+ sinSigma *
494
+ (cos2SigmaM + C * cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM))),
398
495
  revAz = Math.atan2(sinAlpha, -tmp); // final bearing
399
496
  return new LonLat(lon1 + L * math.DEGREES, lat2 * math.DEGREES);
400
497
  }
@@ -403,12 +500,11 @@ class Ellipsoid {
403
500
  * Returns ray vector hit ellipsoid coordinates.
404
501
  * If the ray doesn't hit ellipsoid returns null.
405
502
  * @public
406
- * @param {og.Vec3} origin - Ray origin point.
407
- * @param {og.Vec3} direction - Ray direction.
408
- * @returns {og.Vec3} -
503
+ * @param {Vec3} origin - Ray origin point.
504
+ * @param {Vec3} direction - Ray direction.
505
+ * @returns {Vec3} -
409
506
  */
410
507
  hitRay(origin, direction) {
411
-
412
508
  var q = this._invRadii.mul(origin);
413
509
  var w = this._invRadii.mul(direction);
414
510
 
@@ -467,6 +563,6 @@ class Ellipsoid {
467
563
  return null;
468
564
  }
469
565
  }
470
- };
566
+ }
471
567
 
472
- export { Ellipsoid };
568
+ export { Ellipsoid };
@@ -2,12 +2,12 @@
2
2
  * @module og/ellipsoid/wgs84
3
3
  */
4
4
 
5
- 'use strict';
5
+ "use strict";
6
6
 
7
- import { Ellipsoid } from './Ellipsoid.js';
7
+ import { Ellipsoid } from "./Ellipsoid.js";
8
8
 
9
9
  /**
10
10
  * WGS84 ellipsoid object.
11
- * @type {og.Ellipsoid}
11
+ * @type {Ellipsoid}
12
12
  */
13
- export const wgs84 = new Ellipsoid(6378137.000, 6356752.3142);
13
+ export const wgs84 = new Ellipsoid(6378137.0, 6356752.3142);