cesium 0.13.0

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 (491) hide show
  1. data/LICENSE.md +259 -0
  2. data/README.rdoc +90 -0
  3. data/Rakefile +40 -0
  4. data/app/assets/javascripts/Assets/Assets.profile.js +8 -0
  5. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_0.json +1 -0
  6. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_1.json +1 -0
  7. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_10.json +1 -0
  8. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_11.json +1 -0
  9. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_12.json +1 -0
  10. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_13.json +1 -0
  11. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_14.json +1 -0
  12. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_15.json +1 -0
  13. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_16.json +1 -0
  14. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_17.json +1 -0
  15. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_18.json +1 -0
  16. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_19.json +1 -0
  17. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_2.json +1 -0
  18. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_20.json +1 -0
  19. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_21.json +1 -0
  20. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_22.json +1 -0
  21. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_23.json +1 -0
  22. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_24.json +1 -0
  23. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_25.json +1 -0
  24. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_26.json +1 -0
  25. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_27.json +1 -0
  26. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_3.json +1 -0
  27. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_4.json +1 -0
  28. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_5.json +1 -0
  29. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_6.json +1 -0
  30. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_7.json +1 -0
  31. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_8.json +1 -0
  32. data/app/assets/javascripts/Assets/IAU2006_XYS/IAU2006_XYS_9.json +1 -0
  33. data/app/assets/javascripts/Assets/Textures/NE2_LR_LC_SR_W_DR_2048.jpg +0 -0
  34. data/app/assets/javascripts/Assets/Textures/SkyBox/tycho2t3_80_mx.jpg +0 -0
  35. data/app/assets/javascripts/Assets/Textures/SkyBox/tycho2t3_80_my.jpg +0 -0
  36. data/app/assets/javascripts/Assets/Textures/SkyBox/tycho2t3_80_mz.jpg +0 -0
  37. data/app/assets/javascripts/Assets/Textures/SkyBox/tycho2t3_80_px.jpg +0 -0
  38. data/app/assets/javascripts/Assets/Textures/SkyBox/tycho2t3_80_py.jpg +0 -0
  39. data/app/assets/javascripts/Assets/Textures/SkyBox/tycho2t3_80_pz.jpg +0 -0
  40. data/app/assets/javascripts/Assets/Textures/waterNormals.jpg +0 -0
  41. data/app/assets/javascripts/Assets/package.json +6 -0
  42. data/app/assets/javascripts/Cesium.js +320 -0
  43. data/app/assets/javascripts/Core/AnimationController.js +148 -0
  44. data/app/assets/javascripts/Core/AxisAlignedBoundingBox.js +243 -0
  45. data/app/assets/javascripts/Core/BoundingRectangle.js +364 -0
  46. data/app/assets/javascripts/Core/BoundingSphere.js +819 -0
  47. data/app/assets/javascripts/Core/BoxTessellator.js +93 -0
  48. data/app/assets/javascripts/Core/Cartesian2.js +762 -0
  49. data/app/assets/javascripts/Core/Cartesian3.js +861 -0
  50. data/app/assets/javascripts/Core/Cartesian4.js +762 -0
  51. data/app/assets/javascripts/Core/Cartographic.js +211 -0
  52. data/app/assets/javascripts/Core/CatmullRomSpline.js +232 -0
  53. data/app/assets/javascripts/Core/Clock.js +195 -0
  54. data/app/assets/javascripts/Core/ClockRange.js +37 -0
  55. data/app/assets/javascripts/Core/ClockStep.js +32 -0
  56. data/app/assets/javascripts/Core/Color.js +1629 -0
  57. data/app/assets/javascripts/Core/ComponentDatatype.js +119 -0
  58. data/app/assets/javascripts/Core/Core.profile.js +8 -0
  59. data/app/assets/javascripts/Core/CubeMapEllipsoidTessellator.js +198 -0
  60. data/app/assets/javascripts/Core/CubicRealPolynomial.js +251 -0
  61. data/app/assets/javascripts/Core/DefaultProxy.js +30 -0
  62. data/app/assets/javascripts/Core/DeveloperError.js +60 -0
  63. data/app/assets/javascripts/Core/EarthOrientationParameters.js +383 -0
  64. data/app/assets/javascripts/Core/EarthOrientationParametersSample.js +50 -0
  65. data/app/assets/javascripts/Core/Ellipsoid.js +539 -0
  66. data/app/assets/javascripts/Core/EllipsoidTangentPlane.js +207 -0
  67. data/app/assets/javascripts/Core/EllipsoidalOccluder.js +151 -0
  68. data/app/assets/javascripts/Core/EncodedCartesian3.js +197 -0
  69. data/app/assets/javascripts/Core/Enumeration.js +67 -0
  70. data/app/assets/javascripts/Core/Event.js +122 -0
  71. data/app/assets/javascripts/Core/Extent.js +383 -0
  72. data/app/assets/javascripts/Core/ExtentTessellator.js +384 -0
  73. data/app/assets/javascripts/Core/FAR.js +13 -0
  74. data/app/assets/javascripts/Core/FeatureDetection.js +126 -0
  75. data/app/assets/javascripts/Core/Fullscreen.js +235 -0
  76. data/app/assets/javascripts/Core/GeographicProjection.js +107 -0
  77. data/app/assets/javascripts/Core/HermitePolynomialApproximation.js +176 -0
  78. data/app/assets/javascripts/Core/HermiteSpline.js +234 -0
  79. data/app/assets/javascripts/Core/Iau2006XysData.js +259 -0
  80. data/app/assets/javascripts/Core/Iau2006XysSample.js +36 -0
  81. data/app/assets/javascripts/Core/IndexDatatype.js +28 -0
  82. data/app/assets/javascripts/Core/Intersect.js +40 -0
  83. data/app/assets/javascripts/Core/IntersectionTests.js +359 -0
  84. data/app/assets/javascripts/Core/Interval.js +27 -0
  85. data/app/assets/javascripts/Core/Iso8601.js +46 -0
  86. data/app/assets/javascripts/Core/JulianDate.js +1228 -0
  87. data/app/assets/javascripts/Core/KeyboardEventModifier.js +38 -0
  88. data/app/assets/javascripts/Core/LagrangePolynomialApproximation.js +96 -0
  89. data/app/assets/javascripts/Core/LeapSecond.js +158 -0
  90. data/app/assets/javascripts/Core/LinearApproximation.js +98 -0
  91. data/app/assets/javascripts/Core/Math.js +532 -0
  92. data/app/assets/javascripts/Core/Matrix2.js +833 -0
  93. data/app/assets/javascripts/Core/Matrix3.js +1099 -0
  94. data/app/assets/javascripts/Core/Matrix4.js +2164 -0
  95. data/app/assets/javascripts/Core/MeshFilters.js +568 -0
  96. data/app/assets/javascripts/Core/Occluder.js +474 -0
  97. data/app/assets/javascripts/Core/OrientationInterpolator.js +109 -0
  98. data/app/assets/javascripts/Core/PlaneTessellator.js +74 -0
  99. data/app/assets/javascripts/Core/PolygonPipeline.js +792 -0
  100. data/app/assets/javascripts/Core/PolylinePipeline.js +90 -0
  101. data/app/assets/javascripts/Core/PrimitiveType.js +80 -0
  102. data/app/assets/javascripts/Core/QuadraticRealPolynomial.js +146 -0
  103. data/app/assets/javascripts/Core/QuarticRealPolynomial.js +339 -0
  104. data/app/assets/javascripts/Core/Quaternion.js +947 -0
  105. data/app/assets/javascripts/Core/Queue.js +95 -0
  106. data/app/assets/javascripts/Core/Ray.js +64 -0
  107. data/app/assets/javascripts/Core/ReferenceFrame.js +25 -0
  108. data/app/assets/javascripts/Core/RequestErrorEvent.js +35 -0
  109. data/app/assets/javascripts/Core/RuntimeError.js +59 -0
  110. data/app/assets/javascripts/Core/ScreenSpaceEventHandler.js +658 -0
  111. data/app/assets/javascripts/Core/ScreenSpaceEventType.js +149 -0
  112. data/app/assets/javascripts/Core/Shapes.js +230 -0
  113. data/app/assets/javascripts/Core/Spherical.js +192 -0
  114. data/app/assets/javascripts/Core/TaskProcessor.js +131 -0
  115. data/app/assets/javascripts/Core/TimeConstants.js +85 -0
  116. data/app/assets/javascripts/Core/TimeInterval.js +305 -0
  117. data/app/assets/javascripts/Core/TimeIntervalCollection.js +543 -0
  118. data/app/assets/javascripts/Core/TimeStandard.js +31 -0
  119. data/app/assets/javascripts/Core/Tipsify.js +285 -0
  120. data/app/assets/javascripts/Core/Transforms.js +614 -0
  121. data/app/assets/javascripts/Core/TridiagonalSystemSolver.js +102 -0
  122. data/app/assets/javascripts/Core/Visibility.js +38 -0
  123. data/app/assets/javascripts/Core/WebMercatorProjection.js +154 -0
  124. data/app/assets/javascripts/Core/WindingOrder.js +40 -0
  125. data/app/assets/javascripts/Core/binarySearch.js +69 -0
  126. data/app/assets/javascripts/Core/buildModuleUrl.js +77 -0
  127. data/app/assets/javascripts/Core/clone.js +21 -0
  128. data/app/assets/javascripts/Core/combine.js +81 -0
  129. data/app/assets/javascripts/Core/computeSunPosition.js +116 -0
  130. data/app/assets/javascripts/Core/createGuid.js +25 -0
  131. data/app/assets/javascripts/Core/defaultValue.js +22 -0
  132. data/app/assets/javascripts/Core/destroyObject.js +61 -0
  133. data/app/assets/javascripts/Core/freezeObject.js +20 -0
  134. data/app/assets/javascripts/Core/getImagePixels.js +46 -0
  135. data/app/assets/javascripts/Core/isLeapYear.js +30 -0
  136. data/app/assets/javascripts/Core/jsonp.js +116 -0
  137. data/app/assets/javascripts/Core/loadArrayBuffer.js +76 -0
  138. data/app/assets/javascripts/Core/loadImage.js +85 -0
  139. data/app/assets/javascripts/Core/loadJson.js +54 -0
  140. data/app/assets/javascripts/Core/loadText.js +78 -0
  141. data/app/assets/javascripts/Core/loadXML.js +76 -0
  142. data/app/assets/javascripts/Core/package.json +6 -0
  143. data/app/assets/javascripts/Core/pointInsideTriangle2D.js +41 -0
  144. data/app/assets/javascripts/Core/requestAnimationFrame.js +61 -0
  145. data/app/assets/javascripts/Core/throttleRequestByServer.js +74 -0
  146. data/app/assets/javascripts/Core/writeTextToCanvas.js +92 -0
  147. data/app/assets/javascripts/DynamicScene/CompositeDynamicObjectCollection.js +254 -0
  148. data/app/assets/javascripts/DynamicScene/CzmlBoolean.js +57 -0
  149. data/app/assets/javascripts/DynamicScene/CzmlCartesian2.js +96 -0
  150. data/app/assets/javascripts/DynamicScene/CzmlCartesian3.js +99 -0
  151. data/app/assets/javascripts/DynamicScene/CzmlCartographic.js +125 -0
  152. data/app/assets/javascripts/DynamicScene/CzmlColor.js +127 -0
  153. data/app/assets/javascripts/DynamicScene/CzmlDefaults.js +135 -0
  154. data/app/assets/javascripts/DynamicScene/CzmlHorizontalOrigin.js +59 -0
  155. data/app/assets/javascripts/DynamicScene/CzmlImage.js +61 -0
  156. data/app/assets/javascripts/DynamicScene/CzmlLabelStyle.js +59 -0
  157. data/app/assets/javascripts/DynamicScene/CzmlNumber.js +82 -0
  158. data/app/assets/javascripts/DynamicScene/CzmlString.js +56 -0
  159. data/app/assets/javascripts/DynamicScene/CzmlUnitCartesian3.js +99 -0
  160. data/app/assets/javascripts/DynamicScene/CzmlUnitQuaternion.js +172 -0
  161. data/app/assets/javascripts/DynamicScene/CzmlUnitSpherical.js +98 -0
  162. data/app/assets/javascripts/DynamicScene/CzmlVerticalOrigin.js +59 -0
  163. data/app/assets/javascripts/DynamicScene/DynamicBillboard.js +245 -0
  164. data/app/assets/javascripts/DynamicScene/DynamicBillboardVisualizer.js +347 -0
  165. data/app/assets/javascripts/DynamicScene/DynamicColorMaterial.js +78 -0
  166. data/app/assets/javascripts/DynamicScene/DynamicCone.js +291 -0
  167. data/app/assets/javascripts/DynamicScene/DynamicConeVisualizer.js +350 -0
  168. data/app/assets/javascripts/DynamicScene/DynamicConeVisualizerUsingCustomSensor.js +389 -0
  169. data/app/assets/javascripts/DynamicScene/DynamicDirectionsProperty.js +163 -0
  170. data/app/assets/javascripts/DynamicScene/DynamicEllipsoid.js +158 -0
  171. data/app/assets/javascripts/DynamicScene/DynamicEllipsoidVisualizer.js +277 -0
  172. data/app/assets/javascripts/DynamicScene/DynamicImageMaterial.js +136 -0
  173. data/app/assets/javascripts/DynamicScene/DynamicLabel.js +286 -0
  174. data/app/assets/javascripts/DynamicScene/DynamicLabelVisualizer.js +341 -0
  175. data/app/assets/javascripts/DynamicScene/DynamicMaterialProperty.js +125 -0
  176. data/app/assets/javascripts/DynamicScene/DynamicObject.js +364 -0
  177. data/app/assets/javascripts/DynamicScene/DynamicObjectCollection.js +137 -0
  178. data/app/assets/javascripts/DynamicScene/DynamicObjectView.js +299 -0
  179. data/app/assets/javascripts/DynamicScene/DynamicPath.js +214 -0
  180. data/app/assets/javascripts/DynamicScene/DynamicPathVisualizer.js +402 -0
  181. data/app/assets/javascripts/DynamicScene/DynamicPoint.js +184 -0
  182. data/app/assets/javascripts/DynamicScene/DynamicPointVisualizer.js +323 -0
  183. data/app/assets/javascripts/DynamicScene/DynamicPolygon.js +138 -0
  184. data/app/assets/javascripts/DynamicScene/DynamicPolygonVisualizer.js +251 -0
  185. data/app/assets/javascripts/DynamicScene/DynamicPolyline.js +183 -0
  186. data/app/assets/javascripts/DynamicScene/DynamicPolylineVisualizer.js +268 -0
  187. data/app/assets/javascripts/DynamicScene/DynamicPositionProperty.js +525 -0
  188. data/app/assets/javascripts/DynamicScene/DynamicProperty.js +352 -0
  189. data/app/assets/javascripts/DynamicScene/DynamicPyramid.js +204 -0
  190. data/app/assets/javascripts/DynamicScene/DynamicPyramidVisualizer.js +302 -0
  191. data/app/assets/javascripts/DynamicScene/DynamicScene.profile.js +8 -0
  192. data/app/assets/javascripts/DynamicScene/DynamicVertexPositionsProperty.js +199 -0
  193. data/app/assets/javascripts/DynamicScene/ReferenceProperty.js +155 -0
  194. data/app/assets/javascripts/DynamicScene/VisualizerCollection.js +181 -0
  195. data/app/assets/javascripts/DynamicScene/package.json +6 -0
  196. data/app/assets/javascripts/DynamicScene/processCzml.js +77 -0
  197. data/app/assets/javascripts/Renderer/BlendEquation.js +52 -0
  198. data/app/assets/javascripts/Renderer/BlendFunction.js +158 -0
  199. data/app/assets/javascripts/Renderer/BlendingState.js +64 -0
  200. data/app/assets/javascripts/Renderer/Buffer.js +141 -0
  201. data/app/assets/javascripts/Renderer/BufferUsage.js +48 -0
  202. data/app/assets/javascripts/Renderer/ClearCommand.js +40 -0
  203. data/app/assets/javascripts/Renderer/CommandLists.js +42 -0
  204. data/app/assets/javascripts/Renderer/Context.js +2805 -0
  205. data/app/assets/javascripts/Renderer/CubeMap.js +358 -0
  206. data/app/assets/javascripts/Renderer/CubeMapFace.js +202 -0
  207. data/app/assets/javascripts/Renderer/CullFace.js +50 -0
  208. data/app/assets/javascripts/Renderer/DepthFunction.js +95 -0
  209. data/app/assets/javascripts/Renderer/DrawCommand.js +96 -0
  210. data/app/assets/javascripts/Renderer/Framebuffer.js +435 -0
  211. data/app/assets/javascripts/Renderer/MipmapHint.js +50 -0
  212. data/app/assets/javascripts/Renderer/PickFramebuffer.js +178 -0
  213. data/app/assets/javascripts/Renderer/PixelDatatype.js +86 -0
  214. data/app/assets/javascripts/Renderer/PixelFormat.js +113 -0
  215. data/app/assets/javascripts/Renderer/Renderbuffer.js +102 -0
  216. data/app/assets/javascripts/Renderer/RenderbufferFormat.js +77 -0
  217. data/app/assets/javascripts/Renderer/Renderer.profile.js +8 -0
  218. data/app/assets/javascripts/Renderer/ShaderCache.js +121 -0
  219. data/app/assets/javascripts/Renderer/ShaderProgram.js +2402 -0
  220. data/app/assets/javascripts/Renderer/StencilFunction.js +95 -0
  221. data/app/assets/javascripts/Renderer/StencilOperation.js +95 -0
  222. data/app/assets/javascripts/Renderer/Texture.js +395 -0
  223. data/app/assets/javascripts/Renderer/TextureAtlas.js +472 -0
  224. data/app/assets/javascripts/Renderer/TextureAtlasBuilder.js +133 -0
  225. data/app/assets/javascripts/Renderer/TextureMagnificationFilter.js +41 -0
  226. data/app/assets/javascripts/Renderer/TextureMinificationFilter.js +77 -0
  227. data/app/assets/javascripts/Renderer/TextureWrap.js +50 -0
  228. data/app/assets/javascripts/Renderer/UniformDatatype.js +218 -0
  229. data/app/assets/javascripts/Renderer/UniformState.js +799 -0
  230. data/app/assets/javascripts/Renderer/VertexArray.js +365 -0
  231. data/app/assets/javascripts/Renderer/VertexArrayFacade.js +574 -0
  232. data/app/assets/javascripts/Renderer/VertexLayout.js +49 -0
  233. data/app/assets/javascripts/Renderer/loadCubeMap.js +92 -0
  234. data/app/assets/javascripts/Renderer/package.json +6 -0
  235. data/app/assets/javascripts/Scene/AnimationCollection.js +249 -0
  236. data/app/assets/javascripts/Scene/ArcGisMapServerImageryProvider.js +384 -0
  237. data/app/assets/javascripts/Scene/Billboard.js +680 -0
  238. data/app/assets/javascripts/Scene/BillboardCollection.js +1209 -0
  239. data/app/assets/javascripts/Scene/BingMapsImageryProvider.js +460 -0
  240. data/app/assets/javascripts/Scene/BingMapsStyle.js +55 -0
  241. data/app/assets/javascripts/Scene/Camera.js +358 -0
  242. data/app/assets/javascripts/Scene/CameraColumbusViewMode.js +30 -0
  243. data/app/assets/javascripts/Scene/CameraController.js +1258 -0
  244. data/app/assets/javascripts/Scene/CameraEventAggregator.js +270 -0
  245. data/app/assets/javascripts/Scene/CameraEventType.js +53 -0
  246. data/app/assets/javascripts/Scene/CameraFlightPath.js +495 -0
  247. data/app/assets/javascripts/Scene/CentralBody.js +817 -0
  248. data/app/assets/javascripts/Scene/CentralBodySurface.js +1120 -0
  249. data/app/assets/javascripts/Scene/CentralBodySurfaceShaderSet.js +107 -0
  250. data/app/assets/javascripts/Scene/ComplexConicSensorVolume.js +511 -0
  251. data/app/assets/javascripts/Scene/CompositePrimitive.js +454 -0
  252. data/app/assets/javascripts/Scene/CullingVolume.js +59 -0
  253. data/app/assets/javascripts/Scene/CustomSensorVolume.js +440 -0
  254. data/app/assets/javascripts/Scene/DiscardMissingTileImagePolicy.js +134 -0
  255. data/app/assets/javascripts/Scene/EllipsoidPrimitive.js +412 -0
  256. data/app/assets/javascripts/Scene/EllipsoidTerrainProvider.js +182 -0
  257. data/app/assets/javascripts/Scene/FrameState.js +86 -0
  258. data/app/assets/javascripts/Scene/FrustumCommands.js +32 -0
  259. data/app/assets/javascripts/Scene/GeographicTilingScheme.js +265 -0
  260. data/app/assets/javascripts/Scene/HorizontalOrigin.js +39 -0
  261. data/app/assets/javascripts/Scene/Imagery.js +85 -0
  262. data/app/assets/javascripts/Scene/ImageryLayer.js +876 -0
  263. data/app/assets/javascripts/Scene/ImageryLayerCollection.js +403 -0
  264. data/app/assets/javascripts/Scene/ImageryProvider.js +185 -0
  265. data/app/assets/javascripts/Scene/ImageryProviderError.js +149 -0
  266. data/app/assets/javascripts/Scene/ImageryState.js +20 -0
  267. data/app/assets/javascripts/Scene/Label.js +706 -0
  268. data/app/assets/javascripts/Scene/LabelCollection.js +697 -0
  269. data/app/assets/javascripts/Scene/LabelStyle.js +39 -0
  270. data/app/assets/javascripts/Scene/Material.js +1177 -0
  271. data/app/assets/javascripts/Scene/NeverTileDiscardPolicy.js +38 -0
  272. data/app/assets/javascripts/Scene/OpenStreetMapImageryProvider.js +282 -0
  273. data/app/assets/javascripts/Scene/OrthographicFrustum.js +345 -0
  274. data/app/assets/javascripts/Scene/PerformanceDisplay.js +183 -0
  275. data/app/assets/javascripts/Scene/PerspectiveFrustum.js +239 -0
  276. data/app/assets/javascripts/Scene/PerspectiveOffCenterFrustum.js +394 -0
  277. data/app/assets/javascripts/Scene/Polygon.js +886 -0
  278. data/app/assets/javascripts/Scene/Polyline.js +441 -0
  279. data/app/assets/javascripts/Scene/PolylineCollection.js +1532 -0
  280. data/app/assets/javascripts/Scene/Projections.js +93 -0
  281. data/app/assets/javascripts/Scene/RectangularPyramidSensorVolume.js +224 -0
  282. data/app/assets/javascripts/Scene/Scene.js +632 -0
  283. data/app/assets/javascripts/Scene/Scene.profile.js +8 -0
  284. data/app/assets/javascripts/Scene/SceneMode.js +51 -0
  285. data/app/assets/javascripts/Scene/SceneTransitioner.js +776 -0
  286. data/app/assets/javascripts/Scene/ScreenSpaceCameraController.js +1063 -0
  287. data/app/assets/javascripts/Scene/SensorVolumeCollection.js +192 -0
  288. data/app/assets/javascripts/Scene/SingleTileImageryProvider.js +295 -0
  289. data/app/assets/javascripts/Scene/SkyAtmosphere.js +239 -0
  290. data/app/assets/javascripts/Scene/SkyBox.js +231 -0
  291. data/app/assets/javascripts/Scene/TerrainProvider.js +229 -0
  292. data/app/assets/javascripts/Scene/TexturePool.js +154 -0
  293. data/app/assets/javascripts/Scene/Tile.js +322 -0
  294. data/app/assets/javascripts/Scene/TileDiscardPolicy.js +42 -0
  295. data/app/assets/javascripts/Scene/TileImagery.js +36 -0
  296. data/app/assets/javascripts/Scene/TileLoadQueue.js +123 -0
  297. data/app/assets/javascripts/Scene/TileMapServiceImageryProvider.js +337 -0
  298. data/app/assets/javascripts/Scene/TileReplacementQueue.js +139 -0
  299. data/app/assets/javascripts/Scene/TileState.js +19 -0
  300. data/app/assets/javascripts/Scene/TilingScheme.js +213 -0
  301. data/app/assets/javascripts/Scene/VerticalOrigin.js +39 -0
  302. data/app/assets/javascripts/Scene/ViewportQuad.js +256 -0
  303. data/app/assets/javascripts/Scene/WebMapServiceImageryProvider.js +374 -0
  304. data/app/assets/javascripts/Scene/WebMercatorTilingScheme.js +291 -0
  305. data/app/assets/javascripts/Scene/package.json +6 -0
  306. data/app/assets/javascripts/Shaders/BillboardCollectionFS.glsl +30 -0
  307. data/app/assets/javascripts/Shaders/BillboardCollectionFS.js +31 -0
  308. data/app/assets/javascripts/Shaders/BillboardCollectionVS.glsl +68 -0
  309. data/app/assets/javascripts/Shaders/BillboardCollectionVS.js +54 -0
  310. data/app/assets/javascripts/Shaders/BuiltinFunctions.glsl +927 -0
  311. data/app/assets/javascripts/Shaders/BuiltinFunctions.js +322 -0
  312. data/app/assets/javascripts/Shaders/CentralBodyFS.glsl +106 -0
  313. data/app/assets/javascripts/Shaders/CentralBodyFS.js +82 -0
  314. data/app/assets/javascripts/Shaders/CentralBodyFSDepth.glsl +20 -0
  315. data/app/assets/javascripts/Shaders/CentralBodyFSDepth.js +22 -0
  316. data/app/assets/javascripts/Shaders/CentralBodyFSPole.glsl +29 -0
  317. data/app/assets/javascripts/Shaders/CentralBodyFSPole.js +28 -0
  318. data/app/assets/javascripts/Shaders/CentralBodyVS.glsl +88 -0
  319. data/app/assets/javascripts/Shaders/CentralBodyVS.js +69 -0
  320. data/app/assets/javascripts/Shaders/CentralBodyVSDepth.glsl +9 -0
  321. data/app/assets/javascripts/Shaders/CentralBodyVSDepth.js +13 -0
  322. data/app/assets/javascripts/Shaders/CentralBodyVSPole.glsl +12 -0
  323. data/app/assets/javascripts/Shaders/CentralBodyVSPole.js +15 -0
  324. data/app/assets/javascripts/Shaders/ComplexConicSensorVolumeFS.glsl +448 -0
  325. data/app/assets/javascripts/Shaders/ComplexConicSensorVolumeFS.js +361 -0
  326. data/app/assets/javascripts/Shaders/ComplexConicSensorVolumeVS.glsl +19 -0
  327. data/app/assets/javascripts/Shaders/ComplexConicSensorVolumeVS.js +20 -0
  328. data/app/assets/javascripts/Shaders/ConstructiveSolidGeometry.glsl +886 -0
  329. data/app/assets/javascripts/Shaders/ConstructiveSolidGeometry.js +586 -0
  330. data/app/assets/javascripts/Shaders/CustomSensorVolumeFS.glsl +126 -0
  331. data/app/assets/javascripts/Shaders/CustomSensorVolumeFS.js +95 -0
  332. data/app/assets/javascripts/Shaders/CustomSensorVolumeVS.glsl +14 -0
  333. data/app/assets/javascripts/Shaders/CustomSensorVolumeVS.js +18 -0
  334. data/app/assets/javascripts/Shaders/EllipsoidFS.glsl +40 -0
  335. data/app/assets/javascripts/Shaders/EllipsoidFS.js +38 -0
  336. data/app/assets/javascripts/Shaders/EllipsoidVS.glsl +26 -0
  337. data/app/assets/javascripts/Shaders/EllipsoidVS.js +16 -0
  338. data/app/assets/javascripts/Shaders/Materials/AsphaltMaterial.glsl +25 -0
  339. data/app/assets/javascripts/Shaders/Materials/AsphaltMaterial.js +23 -0
  340. data/app/assets/javascripts/Shaders/Materials/BlobMaterial.glsl +18 -0
  341. data/app/assets/javascripts/Shaders/Materials/BlobMaterial.js +19 -0
  342. data/app/assets/javascripts/Shaders/Materials/BrickMaterial.glsl +42 -0
  343. data/app/assets/javascripts/Shaders/Materials/BrickMaterial.js +36 -0
  344. data/app/assets/javascripts/Shaders/Materials/BumpMapMaterial.glsl +29 -0
  345. data/app/assets/javascripts/Shaders/Materials/BumpMapMaterial.js +27 -0
  346. data/app/assets/javascripts/Shaders/Materials/CementMaterial.glsl +19 -0
  347. data/app/assets/javascripts/Shaders/Materials/CementMaterial.js +20 -0
  348. data/app/assets/javascripts/Shaders/Materials/CheckerboardMaterial.glsl +38 -0
  349. data/app/assets/javascripts/Shaders/Materials/CheckerboardMaterial.js +32 -0
  350. data/app/assets/javascripts/Shaders/Materials/DotMaterial.glsl +17 -0
  351. data/app/assets/javascripts/Shaders/Materials/DotMaterial.js +18 -0
  352. data/app/assets/javascripts/Shaders/Materials/ErosionMaterial.glsl +23 -0
  353. data/app/assets/javascripts/Shaders/Materials/ErosionMaterial.js +24 -0
  354. data/app/assets/javascripts/Shaders/Materials/FacetMaterial.glsl +18 -0
  355. data/app/assets/javascripts/Shaders/Materials/FacetMaterial.js +19 -0
  356. data/app/assets/javascripts/Shaders/Materials/FresnelMaterial.glsl +12 -0
  357. data/app/assets/javascripts/Shaders/Materials/FresnelMaterial.js +15 -0
  358. data/app/assets/javascripts/Shaders/Materials/GrassMaterial.glsl +28 -0
  359. data/app/assets/javascripts/Shaders/Materials/GrassMaterial.js +26 -0
  360. data/app/assets/javascripts/Shaders/Materials/NormalMapMaterial.glsl +19 -0
  361. data/app/assets/javascripts/Shaders/Materials/NormalMapMaterial.js +21 -0
  362. data/app/assets/javascripts/Shaders/Materials/ReflectionMaterial.glsl +13 -0
  363. data/app/assets/javascripts/Shaders/Materials/ReflectionMaterial.js +16 -0
  364. data/app/assets/javascripts/Shaders/Materials/RefractionMaterial.glsl +14 -0
  365. data/app/assets/javascripts/Shaders/Materials/RefractionMaterial.js +17 -0
  366. data/app/assets/javascripts/Shaders/Materials/RimLightingMaterial.glsl +18 -0
  367. data/app/assets/javascripts/Shaders/Materials/RimLightingMaterial.js +19 -0
  368. data/app/assets/javascripts/Shaders/Materials/StripeMaterial.glsl +29 -0
  369. data/app/assets/javascripts/Shaders/Materials/StripeMaterial.js +26 -0
  370. data/app/assets/javascripts/Shaders/Materials/TieDyeMaterial.glsl +17 -0
  371. data/app/assets/javascripts/Shaders/Materials/TieDyeMaterial.js +19 -0
  372. data/app/assets/javascripts/Shaders/Materials/Water.glsl +91 -0
  373. data/app/assets/javascripts/Shaders/Materials/Water.js +60 -0
  374. data/app/assets/javascripts/Shaders/Materials/WoodMaterial.glsl +36 -0
  375. data/app/assets/javascripts/Shaders/Materials/WoodMaterial.js +31 -0
  376. data/app/assets/javascripts/Shaders/Noise.glsl +453 -0
  377. data/app/assets/javascripts/Shaders/Noise.js +242 -0
  378. data/app/assets/javascripts/Shaders/PolygonFS.glsl +27 -0
  379. data/app/assets/javascripts/Shaders/PolygonFS.js +23 -0
  380. data/app/assets/javascripts/Shaders/PolygonFSPick.glsl +6 -0
  381. data/app/assets/javascripts/Shaders/PolygonFSPick.js +11 -0
  382. data/app/assets/javascripts/Shaders/PolygonVS.glsl +38 -0
  383. data/app/assets/javascripts/Shaders/PolygonVS.js +39 -0
  384. data/app/assets/javascripts/Shaders/PolygonVSPick.glsl +30 -0
  385. data/app/assets/javascripts/Shaders/PolygonVSPick.js +32 -0
  386. data/app/assets/javascripts/Shaders/PolylineFS.glsl +6 -0
  387. data/app/assets/javascripts/Shaders/PolylineFS.js +11 -0
  388. data/app/assets/javascripts/Shaders/PolylineVS.glsl +34 -0
  389. data/app/assets/javascripts/Shaders/PolylineVS.js +35 -0
  390. data/app/assets/javascripts/Shaders/Ray.glsl +532 -0
  391. data/app/assets/javascripts/Shaders/Ray.js +357 -0
  392. data/app/assets/javascripts/Shaders/ReprojectWebMercatorFS.glsl +26 -0
  393. data/app/assets/javascripts/Shaders/ReprojectWebMercatorFS.js +22 -0
  394. data/app/assets/javascripts/Shaders/ReprojectWebMercatorVS.glsl +11 -0
  395. data/app/assets/javascripts/Shaders/ReprojectWebMercatorVS.js +14 -0
  396. data/app/assets/javascripts/Shaders/SensorVolume.glsl +43 -0
  397. data/app/assets/javascripts/Shaders/SensorVolume.js +31 -0
  398. data/app/assets/javascripts/Shaders/Shaders.profile.js +8 -0
  399. data/app/assets/javascripts/Shaders/SkyAtmosphereFS.glsl +70 -0
  400. data/app/assets/javascripts/Shaders/SkyAtmosphereFS.js +62 -0
  401. data/app/assets/javascripts/Shaders/SkyAtmosphereVS.glsl +131 -0
  402. data/app/assets/javascripts/Shaders/SkyAtmosphereVS.js +115 -0
  403. data/app/assets/javascripts/Shaders/SkyBoxFS.glsl +10 -0
  404. data/app/assets/javascripts/Shaders/SkyBoxFS.js +14 -0
  405. data/app/assets/javascripts/Shaders/SkyBoxVS.glsl +10 -0
  406. data/app/assets/javascripts/Shaders/SkyBoxVS.js +14 -0
  407. data/app/assets/javascripts/Shaders/ViewportQuadFS.glsl +16 -0
  408. data/app/assets/javascripts/Shaders/ViewportQuadFS.js +17 -0
  409. data/app/assets/javascripts/Shaders/ViewportQuadVS.glsl +10 -0
  410. data/app/assets/javascripts/Shaders/ViewportQuadVS.js +14 -0
  411. data/app/assets/javascripts/Shaders/package.json +6 -0
  412. data/app/assets/javascripts/ThirdParty/ThirdParty.profile.js +8 -0
  413. data/app/assets/javascripts/ThirdParty/Tween.js +678 -0
  414. data/app/assets/javascripts/ThirdParty/Uri.js +277 -0
  415. data/app/assets/javascripts/ThirdParty/measureText.js +197 -0
  416. data/app/assets/javascripts/ThirdParty/package.json +6 -0
  417. data/app/assets/javascripts/ThirdParty/sprintf.js +319 -0
  418. data/app/assets/javascripts/ThirdParty/when.js +748 -0
  419. data/app/assets/javascripts/Widgets/Dojo/CesiumViewerWidget.css +175 -0
  420. data/app/assets/javascripts/Widgets/Dojo/CesiumViewerWidget.html +52 -0
  421. data/app/assets/javascripts/Widgets/Dojo/CesiumViewerWidget.js +1237 -0
  422. data/app/assets/javascripts/Widgets/Dojo/CesiumWidget.html +4 -0
  423. data/app/assets/javascripts/Widgets/Dojo/CesiumWidget.js +349 -0
  424. data/app/assets/javascripts/Widgets/Dojo/TimelineWidget.css +1 -0
  425. data/app/assets/javascripts/Widgets/Dojo/TimelineWidget.js +47 -0
  426. data/app/assets/javascripts/Widgets/Dojo/checkForChromeFrame.js +71 -0
  427. data/app/assets/javascripts/Widgets/Images/Bing_Logo_51x19_White.png +0 -0
  428. data/app/assets/javascripts/Widgets/Images/Cesium_Logo_overlay.png +0 -0
  429. data/app/assets/javascripts/Widgets/Images/TimelineIcons.png +0 -0
  430. data/app/assets/javascripts/Widgets/Images/ajax-loader.gif +0 -0
  431. data/app/assets/javascripts/Widgets/Images/animationBar.png +0 -0
  432. data/app/assets/javascripts/Widgets/Images/viewControlBar.png +0 -0
  433. data/app/assets/javascripts/Widgets/Timeline.css +113 -0
  434. data/app/assets/javascripts/Widgets/Timeline.js +629 -0
  435. data/app/assets/javascripts/Widgets/TimelineHighlightRange.js +51 -0
  436. data/app/assets/javascripts/Widgets/TimelineTrack.js +54 -0
  437. data/app/assets/javascripts/Widgets/Widgets.profile.js +8 -0
  438. data/app/assets/javascripts/Widgets/package.json +6 -0
  439. data/app/assets/javascripts/Workers/Workers.profile.js +8 -0
  440. data/app/assets/javascripts/Workers/cesiumWorkerBootstrapper.js +2015 -0
  441. data/app/assets/javascripts/Workers/createTaskProcessorWorker.js +55 -0
  442. data/app/assets/javascripts/Workers/createVerticesFromExtent.js +24 -0
  443. data/app/assets/javascripts/Workers/package.json +6 -0
  444. data/app/assets/javascripts/copyrightHeader.js +22 -0
  445. data/app/assets/javascripts/main.js +10 -0
  446. data/app/assets/stylesheets/cesium.css +4 -0
  447. data/app/controllers/cesium_controller.rb +4 -0
  448. data/app/helpers/cesium_helper.rb +2 -0
  449. data/app/views/cesium/index.html.erb +3 -0
  450. data/config/routes.rb +3 -0
  451. data/lib/cesium.rb +4 -0
  452. data/lib/cesium/engine.rb +4 -0
  453. data/lib/cesium/version.rb +3 -0
  454. data/lib/tasks/cesium_tasks.rake +4 -0
  455. data/test/cesium_test.rb +7 -0
  456. data/test/dummy/README.rdoc +261 -0
  457. data/test/dummy/Rakefile +7 -0
  458. data/test/dummy/app/assets/javascripts/adapters/jquery-adapter.js.coffee +4 -0
  459. data/test/dummy/app/assets/javascripts/app.js.coffee +11 -0
  460. data/test/dummy/app/assets/javascripts/application.js.coffee +73 -0
  461. data/test/dummy/app/assets/stylesheets/application.css +12 -0
  462. data/test/dummy/app/controllers/application_controller.rb +4 -0
  463. data/test/dummy/app/helpers/application_helper.rb +2 -0
  464. data/test/dummy/app/views/layouts/application.html.erb +21 -0
  465. data/test/dummy/config.ru +4 -0
  466. data/test/dummy/config/application.rb +59 -0
  467. data/test/dummy/config/boot.rb +10 -0
  468. data/test/dummy/config/database.yml +25 -0
  469. data/test/dummy/config/environment.rb +5 -0
  470. data/test/dummy/config/environments/development.rb +37 -0
  471. data/test/dummy/config/environments/production.rb +67 -0
  472. data/test/dummy/config/environments/test.rb +37 -0
  473. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  474. data/test/dummy/config/initializers/inflections.rb +15 -0
  475. data/test/dummy/config/initializers/mime_types.rb +5 -0
  476. data/test/dummy/config/initializers/secret_token.rb +7 -0
  477. data/test/dummy/config/initializers/session_store.rb +8 -0
  478. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  479. data/test/dummy/config/locales/en.yml +5 -0
  480. data/test/dummy/config/requirejs.yml +10 -0
  481. data/test/dummy/config/routes.rb +3 -0
  482. data/test/dummy/public/404.html +26 -0
  483. data/test/dummy/public/422.html +26 -0
  484. data/test/dummy/public/500.html +25 -0
  485. data/test/dummy/public/favicon.ico +0 -0
  486. data/test/dummy/script/rails +6 -0
  487. data/test/functional/cesium_controller_test.rb +9 -0
  488. data/test/integration/navigation_test.rb +10 -0
  489. data/test/test_helper.rb +15 -0
  490. data/test/unit/helpers/cesium_helper_test.rb +4 -0
  491. metadata +641 -0
@@ -0,0 +1,27 @@
1
+ /*global define*/
2
+ define(['./defaultValue'], function(defaultValue) {
3
+ "use strict";
4
+
5
+ /**
6
+ * Represents the closed interval [start, stop].
7
+ * @alias Interval
8
+ * @constructor
9
+ *
10
+ * @param {Number} [start=0.0] The beginning of the interval.
11
+ * @param {Number} [stop=0.0] The end of the interval.
12
+ */
13
+ var Interval = function(start, stop) {
14
+ /**
15
+ * The beginning of the interval.
16
+ * @type {Number}
17
+ */
18
+ this.start = defaultValue(start, 0.0);
19
+ /**
20
+ * The end of the interval.
21
+ * @type {Number}
22
+ */
23
+ this.stop = defaultValue(stop, 0.0);
24
+ };
25
+
26
+ return Interval;
27
+ });
@@ -0,0 +1,46 @@
1
+ /*global define*/
2
+ define([
3
+ './freezeObject',
4
+ './JulianDate',
5
+ './TimeInterval'
6
+ ], function(
7
+ freezeObject,
8
+ JulianDate,
9
+ TimeInterval) {
10
+ "use strict";
11
+
12
+ var MINIMUM_VALUE = freezeObject(JulianDate.fromIso8601('0000-01-01T00:00:00Z'));
13
+ var MAXIMUM_VALUE = freezeObject(JulianDate.fromIso8601('9999-12-31T24:00:00Z'));
14
+ var MAXIMUM_INTERVAL = freezeObject(new TimeInterval(MINIMUM_VALUE, MAXIMUM_VALUE, true, true));
15
+
16
+ /**
17
+ * Constants related to ISO8601 support.
18
+ *
19
+ * @exports Iso8601
20
+ *
21
+ * @see <a href='http://en.wikipedia.org/wiki/ISO_8601'>ISO 8601 on Wikipedia</a>.
22
+ * @see JulianDate
23
+ * @see TimeInterval
24
+ */
25
+ var Iso8601 = {
26
+ /**
27
+ * A {@link JulianDate} representing the earliest time representable by an ISO8601 date.
28
+ * This is equivalent to the date string '0000-01-01T00:00:00Z'
29
+ */
30
+ MINIMUM_VALUE : MINIMUM_VALUE,
31
+
32
+ /**
33
+ * A {@link JulianDate} representing the latest time representable by an ISO8601 date.
34
+ * This is equivalent to the date string '9999-12-31T24:00:00Z'
35
+ */
36
+ MAXIMUM_VALUE : MAXIMUM_VALUE,
37
+
38
+ /**
39
+ * A {@link TimeInterval} representing the largest interval representable by an ISO8601 interval.
40
+ * This is equivalent to the interval string '0000-01-01T00:00:00Z/9999-12-31T24:00:00Z'
41
+ */
42
+ MAXIMUM_INTERVAL : MAXIMUM_INTERVAL
43
+ };
44
+
45
+ return Iso8601;
46
+ });
@@ -0,0 +1,1228 @@
1
+ /*global define*/
2
+ define([
3
+ './DeveloperError',
4
+ './binarySearch',
5
+ './TimeConstants',
6
+ './LeapSecond',
7
+ './TimeStandard',
8
+ './isLeapYear',
9
+ '../ThirdParty/sprintf'
10
+ ], function(
11
+ DeveloperError,
12
+ binarySearch,
13
+ TimeConstants,
14
+ LeapSecond,
15
+ TimeStandard,
16
+ isLeapYear,
17
+ sprintf) {
18
+ "use strict";
19
+
20
+ /**
21
+ * The object returned by {@link JulianDate#toGregorianDate}.
22
+ *
23
+ * @alias GregorianDate
24
+ * @see JulianDate#toGregorianDate
25
+ * @constructor
26
+ */
27
+ var GregorianDate = function(year, month, day, hour, minute, second, millisecond, isLeapSecond) {
28
+ /**
29
+ * The year, a whole number.
30
+ * @type Number
31
+ */
32
+ this.year = year;
33
+ /**
34
+ * The month, a whole number with range [1, 12].
35
+ * @type Number
36
+ */
37
+ this.month = month;
38
+ /**
39
+ * The day, a whole number with range 1.
40
+ * @type Number
41
+ */
42
+ this.day = day;
43
+ /**
44
+ * The hour, a whole number with range [0, 23].
45
+ * @type Number
46
+ */
47
+ this.hour = hour;
48
+ /**
49
+ * The minute, a whole number with range [0, 59].
50
+ * @type Number
51
+ */
52
+ this.minute = minute;
53
+ /**
54
+ * The second, a whole number with range [0, 60], with 60 representing a leap second.
55
+ * @type Number
56
+ */
57
+ this.second = second;
58
+ /**
59
+ * The millisecond, a floating point number with range [0.0, 1000.0).
60
+ * @type Number
61
+ */
62
+ this.millisecond = millisecond;
63
+ /**
64
+ * True if this date is during a leap second.
65
+ * @type Boolean
66
+ */
67
+ this.isLeapSecond = isLeapSecond;
68
+ };
69
+
70
+ var daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
71
+ var daysInLeapFeburary = 29;
72
+
73
+ function convertUtcToTai(julianDate) {
74
+ //Even though julianDate is in UTC, we'll treat it as TAI and
75
+ //search the leap second table for it.
76
+ var toFind = new LeapSecond(julianDate, 0.0);
77
+ var leapSeconds = LeapSecond.getLeapSeconds();
78
+ var index = binarySearch(leapSeconds, toFind, LeapSecond.compareLeapSecondDate);
79
+
80
+ if (index < 0) {
81
+ index = ~index;
82
+ }
83
+
84
+ if (index >= leapSeconds.length) {
85
+ index = leapSeconds.length - 1;
86
+ }
87
+
88
+ var offset = leapSeconds[index].offset;
89
+ if (index > 0) {
90
+ //Now we have the index of the closest leap second that comes on or after our UTC time.
91
+ //However, if the difference between the UTC date being converted and the TAI
92
+ //defined leap second is greater than the offset, we are off by one and need to use
93
+ //the previous leap second.
94
+ var difference = julianDate.getSecondsDifference(leapSeconds[index].julianDate);
95
+ if (difference > offset) {
96
+ index--;
97
+ offset = leapSeconds[index].offset;
98
+ }
99
+ }
100
+
101
+ julianDate.addSeconds(offset, julianDate);
102
+ }
103
+
104
+ function convertTaiToUtc(julianDate, result) {
105
+ var toFind = new LeapSecond(julianDate, 0.0);
106
+ var leapSeconds = LeapSecond.getLeapSeconds();
107
+ var index = binarySearch(leapSeconds, toFind, LeapSecond.compareLeapSecondDate);
108
+ if (index < 0) {
109
+ index = ~index;
110
+ }
111
+
112
+ //All times before our first leap second get the first offset.
113
+ if (index === 0) {
114
+ return julianDate.addSeconds(-leapSeconds[0].offset, result);
115
+ }
116
+
117
+ //All times after our leap second get the last offset.
118
+ if (index >= leapSeconds.length) {
119
+ return julianDate.addSeconds(-leapSeconds[index - 1].offset, result);
120
+ }
121
+
122
+ //Compute the difference between the found leap second and the time we are converting.
123
+ var difference = julianDate.getSecondsDifference(leapSeconds[index].julianDate);
124
+
125
+ if (difference === 0) {
126
+ //The date is in our leap second table.
127
+ return julianDate.addSeconds(-leapSeconds[index].offset, result);
128
+ }
129
+
130
+ if (difference <= 1.0) {
131
+ //The requested date is during the moment of a leap second, then we cannot convert to UTC
132
+ return undefined;
133
+ }
134
+
135
+ //The time is in between two leap seconds, index is the leap second after the date
136
+ //we're converting, so we subtract one to get the correct LeapSecond instance.
137
+ return julianDate.addSeconds(-leapSeconds[--index].offset, result);
138
+ }
139
+
140
+ function setComponents(wholeDays, secondsOfDay, julianDate) {
141
+ var extraDays = (secondsOfDay / TimeConstants.SECONDS_PER_DAY) | 0;
142
+ wholeDays += extraDays;
143
+ secondsOfDay -= TimeConstants.SECONDS_PER_DAY * extraDays;
144
+
145
+ if (secondsOfDay < 0) {
146
+ wholeDays--;
147
+ secondsOfDay += TimeConstants.SECONDS_PER_DAY;
148
+ }
149
+
150
+ if (typeof julianDate === 'undefined') {
151
+ return new JulianDate(wholeDays, secondsOfDay, TimeStandard.TAI);
152
+ }
153
+
154
+ julianDate._julianDayNumber = wholeDays;
155
+ julianDate._secondsOfDay = secondsOfDay;
156
+ return julianDate;
157
+ }
158
+
159
+ function computeJulianDateComponents(year, month, day, hour, minute, second, millisecond) {
160
+ // Algorithm from page 604 of the Explanatory Supplement to the
161
+ // Astronomical Almanac (Seidelmann 1992).
162
+
163
+ var a = ((month - 14) / 12) | 0;
164
+ var b = year + 4800 + a;
165
+ var dayNumber = (((1461 * b) / 4) | 0) + (((367 * (month - 2 - 12 * a)) / 12) | 0) - (((3 * ((b + 100) / 100)) / 4) | 0) + day - 32075;
166
+
167
+ // JulianDates are noon-based
168
+ hour = hour - 12;
169
+ if (hour < 0) {
170
+ hour += 24;
171
+ }
172
+
173
+ var secondsOfDay = second + ((hour * TimeConstants.SECONDS_PER_HOUR) + (minute * TimeConstants.SECONDS_PER_MINUTE) + (millisecond * TimeConstants.SECONDS_PER_MILLISECOND));
174
+
175
+ if (secondsOfDay >= 43200.0) {
176
+ dayNumber -= 1;
177
+ }
178
+
179
+ return [dayNumber, secondsOfDay];
180
+ }
181
+
182
+ function computeJulianDateComponentsFromDate(date) {
183
+ return computeJulianDateComponents(date.getUTCFullYear(), date.getUTCMonth() + 1, date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds(), date
184
+ .getUTCMilliseconds());
185
+ }
186
+
187
+ //Regular expressions used for ISO8601 date parsing.
188
+ //YYYY
189
+ var matchCalendarYear = /^(\d{4})$/;
190
+ //YYYY-MM (YYYYMM is invalid)
191
+ var matchCalendarMonth = /^(\d{4})-(\d{2})$/;
192
+ //YYYY-DDD or YYYYDDD
193
+ var matchOrdinalDate = /^(\d{4})-?(\d{3})$/;
194
+ //YYYY-Www or YYYYWww or YYYY-Www-D or YYYYWwwD
195
+ var matchWeekDate = /^(\d{4})-?W(\d{2})-?(\d{1})?$/;
196
+ //YYYY-MM-DD or YYYYMMDD
197
+ var matchCalendarDate = /^(\d{4})-?(\d{2})-?(\d{2})$/;
198
+ // Match utc offset
199
+ var utcOffset = /([Z+\-])?(\d{2})?:?(\d{2})?$/;
200
+ // Match hours HH or HH.xxxxx
201
+ var matchHours = /^(\d{2})(\.\d+)?/.source + utcOffset.source;
202
+ // Match hours/minutes HH:MM HHMM.xxxxx
203
+ var matchHoursMinutes = /^(\d{2}):?(\d{2})(\.\d+)?/.source + utcOffset.source;
204
+ // Match hours/minutes HH:MM:SS HHMMSS.xxxxx
205
+ var matchHoursMinutesSeconds = /^(\d{2}):?(\d{2}):?(\d{2})(\.\d+)?/.source + utcOffset.source;
206
+
207
+ var iso8601ErrorMessage = 'Valid ISO 8601 date string required.';
208
+
209
+ /**
210
+ * Constructs a JulianDate instance from a Julian day number, the number of seconds elapsed
211
+ * into that day, and the time standard which the parameters are in. Passing no parameters will
212
+ * construct a JulianDate that represents the current system time.
213
+ *
214
+ * An astronomical Julian Date is the number of days since noon on January 1, -4712 (4713 BC).
215
+ * For increased precision, this class stores the whole number part of the date and the seconds
216
+ * part of the date in separate components. In order to be safe for arithmetic and represent
217
+ * leap seconds, the date is always stored in the International Atomic Time standard
218
+ * {@link TimeStandard.TAI}.
219
+ *
220
+ * @alias JulianDate
221
+ * @constructor
222
+ * @immutable
223
+ *
224
+ * @param {Number} julianDayNumber The Julian Day Number representing the number of whole days. Fractional days will also be handled correctly.
225
+ * @param {Number} julianSecondsOfDay The number of seconds into the current Julian Day Number. Fractional seconds, negative seconds and seconds greater than a day will be handled correctly.
226
+ * @param {TimeStandard} [timeStandard = TimeStandard.UTC] The time standard in which the first two parameters are defined.
227
+ *
228
+ * @exception {DeveloperError} timeStandard is not a known TimeStandard.
229
+ * @exception {DeveloperError} julianDayNumber is required.
230
+ * @exception {DeveloperError} julianSecondsOfDay is required.
231
+ *
232
+ * @see JulianDate.fromDate
233
+ * @see JulianDate.fromTotalDays
234
+ * @see JulianDate.fromIso8601
235
+ * @see TimeStandard
236
+ * @see LeapSecond
237
+ *
238
+ * @example
239
+ * // Example 1. Construct a Julian date representing the current system time.
240
+ * var julianDate = new JulianDate();
241
+ *
242
+ * // Example 2. Construct a Julian date from a Julian day number and seconds of the day.
243
+ * var julianDayNumber = 2448257; // January 1, 1991
244
+ * var secondsOfDay = 21600; // 06:00:00
245
+ * var julianDate = new JulianDate(julianDayNumber, secondsOfDay, TimeStandard.UTC);
246
+ */
247
+ var JulianDate = function(julianDayNumber, julianSecondsOfDay, timeStandard) {
248
+ this._julianDayNumber = undefined;
249
+ this._secondsOfDay = undefined;
250
+
251
+ var wholeDays;
252
+ var secondsOfDay;
253
+ //If any of the properties are defined, then we are constructing from components.
254
+ if (typeof julianDayNumber !== 'undefined' || typeof julianSecondsOfDay !== 'undefined' || typeof timeStandard !== 'undefined') {
255
+ if (typeof timeStandard === 'undefined') {
256
+ timeStandard = TimeStandard.UTC;
257
+ } else if ((timeStandard !== TimeStandard.UTC) && (timeStandard !== TimeStandard.TAI)) {
258
+ throw new DeveloperError('timeStandard is not a known TimeStandard.');
259
+ }
260
+
261
+ if (julianDayNumber === null || isNaN(julianDayNumber)) {
262
+ throw new DeveloperError('julianDayNumber is required.');
263
+ }
264
+
265
+ if (julianSecondsOfDay === null || isNaN(julianSecondsOfDay)) {
266
+ throw new DeveloperError('julianSecondsOfDay is required.');
267
+ }
268
+
269
+ //coerce to integer
270
+ wholeDays = julianDayNumber | 0;
271
+ //If julianDayNumber was fractional, add the number of seconds the fraction represented
272
+ secondsOfDay = julianSecondsOfDay + (julianDayNumber - wholeDays) * TimeConstants.SECONDS_PER_DAY;
273
+ } else {
274
+ //Create a new date from the current time.
275
+ var date = new Date();
276
+ var components = computeJulianDateComponentsFromDate(date);
277
+ wholeDays = components[0];
278
+ secondsOfDay = components[1];
279
+ timeStandard = TimeStandard.UTC;
280
+ }
281
+
282
+ setComponents(wholeDays, secondsOfDay, this);
283
+
284
+ if (timeStandard === TimeStandard.UTC) {
285
+ convertUtcToTai(this);
286
+ }
287
+ };
288
+
289
+ /**
290
+ * Duplicates a JulianDate instance.
291
+ * @memberof JulianDate
292
+ *
293
+ * @param {Cartesian3} date The JulianDate to duplicate.
294
+ * @param {Cartesian3} [result] The object onto which to store the JulianDate.
295
+ * @return {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided.
296
+ *
297
+ * @exception {DeveloperError} date is required.
298
+ */
299
+ JulianDate.clone = function(date, result) {
300
+ if (typeof date === 'undefined') {
301
+ throw new DeveloperError('date is required.');
302
+ }
303
+ if (typeof result === 'undefined') {
304
+ return new JulianDate(date._julianDayNumber, date._secondsOfDay, TimeStandard.TAI);
305
+ }
306
+ result._julianDayNumber = date._julianDayNumber;
307
+ result._secondsOfDay = date._secondsOfDay;
308
+ return result;
309
+ };
310
+
311
+ /**
312
+ * Creates a JulianDate instance from a JavaScript Date object.
313
+ * While the JavaScript Date object defaults to the system's local time zone,
314
+ * the Julian date is computed using the UTC values.
315
+ *
316
+ * @memberof JulianDate
317
+ *
318
+ * @param {Date} date The JavaScript Date object representing the time to be converted to a Julian date.
319
+ * @param {TimeStandard} [timeStandard = TimeStandard.UTC] Indicates the time standard in which this Julian date is represented.
320
+ *
321
+ * @return {JulianDate} The new {@Link JulianDate} instance.
322
+ *
323
+ * @exception {DeveloperError} date must be a valid JavaScript Date.
324
+ *
325
+ * @see JulianDate
326
+ * @see JulianDate.fromTotalDays
327
+ * @see JulianDate.fromIso8601
328
+ * @see TimeStandard
329
+ * @see LeapSecond
330
+ * @see <a href='http://www.w3schools.com/js/js_obj_date.asp'>JavaScript Date Object on w3schools</a>.
331
+ * @see <a href='http://www.w3schools.com/jsref/jsref_obj_date.asp'>JavaScript Date Object Reference on w3schools</a>.
332
+ *
333
+ * @example
334
+ * // Construct a Julian date specifying the UTC time standard
335
+ * var date = new Date('January 1, 2011 12:00:00 EST');
336
+ * var julianDate = JulianDate.fromDate(date, TimeStandard.UTC);
337
+ */
338
+ JulianDate.fromDate = function(date, timeStandard) {
339
+ if (typeof date === 'undefined' || date === null || isNaN(date.getTime())) {
340
+ throw new DeveloperError('date must be a valid JavaScript Date.');
341
+ }
342
+
343
+ var components = computeJulianDateComponentsFromDate(date);
344
+ return new JulianDate(components[0], components[1], timeStandard);
345
+ };
346
+
347
+ /**
348
+ * Creates a JulianDate instance from an ISO 8601 date string. Unlike Date.parse,
349
+ * this method properly accounts for all valid formats defined by the ISO 8601
350
+ * specification. It also properly handles leap seconds and sub-millisecond times.
351
+ *
352
+ * @memberof JulianDate
353
+ *
354
+ * @param {String} iso8601String The ISO 8601 date string representing the time to be converted to a Julian date.
355
+ *
356
+ * @return {JulianDate} The new {@Link JulianDate} instance.
357
+ *
358
+ * @exception {DeveloperError} Valid ISO 8601 date string required.
359
+ *
360
+ * @see JulianDate
361
+ * @see JulianDate.fromTotalDays
362
+ * @see JulianDate.fromDate
363
+ * @see LeapSecond
364
+ * @see <a href='http://en.wikipedia.org/wiki/ISO_8601'>ISO 8601 on Wikipedia</a>.
365
+ *
366
+ * @example
367
+ * // Example 1. Construct a Julian date in UTC at April 24th, 2012 6:08PM UTC
368
+ * var julianDate = JulianDate.fromIso8601('2012-04-24T18:08Z');
369
+ * // Example 2. Construct a Julian date in local time April 24th, 2012 12:00 AM
370
+ * var localDay = JulianDate.fromIso8601('2012-04-24');
371
+ * // Example 3. Construct a Julian date 5 hours behind UTC April 24th, 2012 5:00 pm UTC
372
+ * var localDay = JulianDate.fromIso8601('2012-04-24T12:00-05:00');
373
+ */
374
+ JulianDate.fromIso8601 = function(iso8601String) {
375
+ if (typeof iso8601String !== 'string') {
376
+ throw new DeveloperError(iso8601ErrorMessage);
377
+ }
378
+
379
+ //Comma and decimal point both indicate a fractional number according to ISO 8601,
380
+ //start out by blanket replacing , with . which is the only valid such symbol in JS.
381
+ iso8601String = iso8601String.replace(',', '.');
382
+
383
+ //Split the string into its date and time components, denoted by a mandatory T
384
+ var tokens = iso8601String.split('T');
385
+ var year;
386
+ var month = 1;
387
+ var day = 1;
388
+ var hour = 0;
389
+ var minute = 0;
390
+ var second = 0;
391
+ var millisecond = 0;
392
+
393
+ //Lacking a time is okay, but a missing date is illegal.
394
+ var date = tokens[0];
395
+ var time = tokens[1];
396
+ var tmp;
397
+ var inLeapYear;
398
+ if (typeof date === 'undefined') {
399
+ throw new DeveloperError(iso8601ErrorMessage);
400
+ }
401
+
402
+ var dashCount;
403
+
404
+ //First match the date against possible regular expressions.
405
+ tokens = date.match(matchCalendarDate);
406
+ if (tokens !== null) {
407
+ dashCount = date.split('-').length - 1;
408
+ if (dashCount > 0 && dashCount !== 2) {
409
+ throw new DeveloperError(iso8601ErrorMessage);
410
+ }
411
+ year = +tokens[1];
412
+ month = +tokens[2];
413
+ day = +tokens[3];
414
+ } else {
415
+ tokens = date.match(matchCalendarMonth);
416
+ if (tokens !== null) {
417
+ year = +tokens[1];
418
+ month = +tokens[2];
419
+ } else {
420
+ tokens = date.match(matchCalendarYear);
421
+ if (tokens !== null) {
422
+ year = +tokens[1];
423
+ } else {
424
+ //Not a year/month/day so it must be an ordinal date.
425
+ var dayOfYear;
426
+ tokens = date.match(matchOrdinalDate);
427
+ if (tokens !== null) {
428
+
429
+ year = +tokens[1];
430
+ dayOfYear = +tokens[2];
431
+ inLeapYear = isLeapYear(year);
432
+
433
+ //This validation is only applicable for this format.
434
+ if (dayOfYear < 1 || (inLeapYear && dayOfYear > 366) || (!inLeapYear && dayOfYear > 365)) {
435
+ throw new DeveloperError(iso8601ErrorMessage);
436
+ }
437
+ } else {
438
+ tokens = date.match(matchWeekDate);
439
+ if (tokens !== null) {
440
+ //ISO week date to ordinal date from
441
+ //http://en.wikipedia.org/w/index.php?title=ISO_week_date&oldid=474176775
442
+ year = +tokens[1];
443
+ var weekNumber = +tokens[2];
444
+ var dayOfWeek = +tokens[3] || 0;
445
+
446
+ dashCount = date.split('-').length - 1;
447
+ if (dashCount > 0 &&
448
+ ((typeof tokens[3] === 'undefined' && dashCount !== 1) ||
449
+ (typeof tokens[3] !== 'undefined' && dashCount !== 2))) {
450
+ throw new DeveloperError(iso8601ErrorMessage);
451
+ }
452
+
453
+ var january4 = new Date(Date.UTC(year, 0, 4));
454
+ dayOfYear = (weekNumber * 7) + dayOfWeek - january4.getUTCDay() - 3;
455
+ } else {
456
+ //None of our regular expressions succeeded in parsing the date properly.
457
+ throw new DeveloperError(iso8601ErrorMessage);
458
+ }
459
+ }
460
+ //Split an ordinal date into month/day.
461
+ tmp = new Date(Date.UTC(year, 0, 1));
462
+ tmp.setUTCDate(dayOfYear);
463
+ month = tmp.getUTCMonth() + 1;
464
+ day = tmp.getUTCDate();
465
+ }
466
+ }
467
+ }
468
+
469
+ //Now that we have all of the date components, validate them to make sure nothing is out of range.
470
+ inLeapYear = isLeapYear(year);
471
+ if (month < 1 || month > 12 || day < 1 || ((month !== 2 || !inLeapYear) && day > daysInMonth[month - 1]) || (inLeapYear && month === 2 && day > daysInLeapFeburary)) {
472
+ throw new DeveloperError(iso8601ErrorMessage);
473
+ }
474
+
475
+ //Not move onto the time string, which is much simpler.
476
+ var offsetIndex;
477
+ if (typeof time !== 'undefined') {
478
+ tokens = time.match(matchHoursMinutesSeconds);
479
+ if (tokens !== null) {
480
+ dashCount = time.split(':').length - 1;
481
+ if (dashCount > 0 && dashCount !== 2) {
482
+ throw new DeveloperError(iso8601ErrorMessage);
483
+ }
484
+
485
+ hour = +tokens[1];
486
+ minute = +tokens[2];
487
+ second = +tokens[3];
488
+ millisecond = +(tokens[4] || 0) * 1000.0;
489
+ offsetIndex = 5;
490
+ } else {
491
+ tokens = time.match(matchHoursMinutes);
492
+ if (tokens !== null) {
493
+ dashCount = time.split(':').length - 1;
494
+ if (dashCount > 0 && dashCount !== 1) {
495
+ throw new DeveloperError(iso8601ErrorMessage);
496
+ }
497
+
498
+ hour = +tokens[1];
499
+ minute = +tokens[2];
500
+ second = +(tokens[3] || 0) * 60.0;
501
+ offsetIndex = 4;
502
+ } else {
503
+ tokens = time.match(matchHours);
504
+ if (tokens !== null) {
505
+ hour = +tokens[1];
506
+ minute = +(tokens[2] || 0) * 60.0;
507
+ offsetIndex = 3;
508
+ } else {
509
+ throw new DeveloperError(iso8601ErrorMessage);
510
+ }
511
+ }
512
+ }
513
+
514
+ //Validate that all values are in proper range. Minutes and hours have special cases at 60 and 24.
515
+ if (minute >= 60 || second >= 61 || hour > 24 || (hour === 24 && (minute > 0 || second > 0 || millisecond > 0))) {
516
+ throw new DeveloperError(iso8601ErrorMessage);
517
+ }
518
+
519
+ //Check the UTC offset value, if no value exists, use local time
520
+ //a Z indicates UTC, + or - are offsets.
521
+ var offset = tokens[offsetIndex];
522
+ var offsetHours = +(tokens[offsetIndex + 1]);
523
+ var offsetMinutes = +(tokens[offsetIndex + 2] || 0);
524
+ switch (offset) {
525
+ case '+':
526
+ hour = hour - offsetHours;
527
+ minute = minute - offsetMinutes;
528
+ break;
529
+ case '-':
530
+ hour = hour + offsetHours;
531
+ minute = minute + offsetMinutes;
532
+ break;
533
+ case 'Z':
534
+ break;
535
+ default:
536
+ minute = minute + new Date(Date.UTC(year, month - 1, day, hour, minute)).getTimezoneOffset();
537
+ break;
538
+ }
539
+ } else {
540
+ //If no time is specified, it is considered the beginning of the day, local time.
541
+ minute = minute + new Date(Date.UTC(year, month - 1, day)).getTimezoneOffset();
542
+ }
543
+
544
+ //ISO8601 denotes a leap second by any time having a seconds component of 60 seconds.
545
+ //If that's the case, we need to temporarily subtract a second in order to build a UTC date.
546
+ //Then we add it back in after converting to TAI.
547
+ var isLeapSecond = second === 60;
548
+ if (isLeapSecond) {
549
+ second--;
550
+ }
551
+
552
+ //Even if we successfully parsed the string into its components, after applying UTC offset or
553
+ //special cases like 24:00:00 denoting midnight, we need to normalize the data appropriately.
554
+
555
+ //milliseconds can never be greater than 1000, and seconds can't be above 60, so we start with minutes
556
+ while (minute >= 60) {
557
+ minute -= 60;
558
+ hour++;
559
+ }
560
+
561
+ while (hour >= 24) {
562
+ hour -= 24;
563
+ day++;
564
+ }
565
+
566
+ tmp = (inLeapYear && month === 2) ? daysInLeapFeburary : daysInMonth[month - 1];
567
+ while (day > tmp) {
568
+ day -= tmp;
569
+ month++;
570
+
571
+ if (month > 12) {
572
+ month -= 12;
573
+ year++;
574
+ }
575
+
576
+ tmp = (inLeapYear && month === 2) ? daysInLeapFeburary : daysInMonth[month - 1];
577
+ }
578
+
579
+ //If UTC offset is at the beginning/end of the day, minutes can be negative.
580
+ while (minute < 0) {
581
+ minute += 60;
582
+ hour--;
583
+ }
584
+
585
+ while (hour < 0) {
586
+ hour += 24;
587
+ day--;
588
+ }
589
+
590
+ while (day < 1) {
591
+ month--;
592
+ if (month < 1) {
593
+ month += 12;
594
+ year--;
595
+ }
596
+
597
+ tmp = (inLeapYear && month === 2) ? daysInLeapFeburary : daysInMonth[month - 1];
598
+ day += tmp;
599
+ }
600
+
601
+ //Now create the JulianDate components from the Gregorian date and actually create our instance.
602
+ var components = computeJulianDateComponents(year, month, day, hour, minute, second, millisecond);
603
+ var result = new JulianDate(components[0], components[1], TimeStandard.UTC);
604
+
605
+ //If we were on a leap second, add it back.
606
+ if (isLeapSecond) {
607
+ result.addSeconds(1, result);
608
+ }
609
+
610
+ return result;
611
+ };
612
+
613
+ /**
614
+ * Creates a JulianDate instance from a single number representing the Julian day and fractional day.
615
+ *
616
+ * @memberof JulianDate
617
+ *
618
+ * @param {Number} totalDays The combined Julian Day Number and fractional day.
619
+ * @param {TimeStandard} [timeStandard = TimeStandard.UTC] Indicates the time standard in which the first parameter is defined.
620
+ *
621
+ * @return {JulianDate} The new {@Link JulianDate} instance.
622
+ *
623
+ * @exception {DeveloperError} totalDays is required.
624
+ *
625
+ * @see JulianDate
626
+ * @see JulianDate.fromDate
627
+ * @see JulianDate.fromIso8601
628
+ * @see TimeStandard
629
+ * @see LeapSecond
630
+ *
631
+ * @example
632
+ * // Construct a date which corresponds to January 1, 1991 06:00:00 UTC.
633
+ * var julianDate = JulianDate.fromTotalDays(2448257.75, TimeStandard.UTC);
634
+ */
635
+ JulianDate.fromTotalDays = function(totalDays, timeStandard) {
636
+ if (totalDays === null || isNaN(totalDays)) {
637
+ throw new DeveloperError('totalDays is required.');
638
+ }
639
+ return new JulianDate(totalDays, 0, timeStandard);
640
+ };
641
+
642
+ /**
643
+ * Compares two {JulianDate} instances.
644
+ *
645
+ * @memberof JulianDate
646
+ *
647
+ * @param {JulianDate} a The first instance.
648
+ * @param {JulianDate} b The second instance.
649
+ * @return {Number} A negative value if a is less than b, a positive value if
650
+ * a is greater than b, and zero if a and b are equal.
651
+ */
652
+ JulianDate.compare = function(a, b) {
653
+ var dayDifference = (a._julianDayNumber - b._julianDayNumber);
654
+ if (dayDifference !== 0) {
655
+ return dayDifference;
656
+ }
657
+ return a._secondsOfDay - b._secondsOfDay;
658
+ };
659
+
660
+ /**
661
+ * Duplicates this JulianDate.
662
+ * @memberof JulianDate
663
+ *
664
+ * @param {Cartesian3} [result] The object onto which to store the JulianDate.
665
+ * @return {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided.
666
+ */
667
+ JulianDate.prototype.clone = function(result) {
668
+ return JulianDate.clone(this, result);
669
+ };
670
+
671
+ /**
672
+ * Returns the total number of whole and fractional days represented by this astronomical Julian date.
673
+ *
674
+ * @memberof JulianDate
675
+ *
676
+ * @return {Number} The Julian date as single floating point number.
677
+ *
678
+ * @see JulianDate#getJulianDayNumber
679
+ * @see JulianDate#getJulianTimeFraction
680
+ */
681
+ JulianDate.prototype.getTotalDays = function() {
682
+ return this._julianDayNumber + (this._secondsOfDay / TimeConstants.SECONDS_PER_DAY);
683
+ };
684
+
685
+ /**
686
+ * Returns the whole number component of the Julian date.
687
+ *
688
+ * @memberof JulianDate
689
+ *
690
+ * @return {Number} A whole number representing the Julian day number.
691
+ *
692
+ * @see JulianDate#getTotalDays
693
+ * @see JulianDate#getJulianTimeFraction
694
+ */
695
+ JulianDate.prototype.getJulianDayNumber = function() {
696
+ return this._julianDayNumber;
697
+ };
698
+
699
+ /**
700
+ * Returns the floating point component of the Julian date representing the time of day.
701
+ *
702
+ * @memberof JulianDate
703
+ *
704
+ * @return {Number} The floating point component of the Julian date representing the time of day.
705
+ *
706
+ * @see JulianDate#getTotalDays
707
+ * @see JulianDate#getJulianDayNumber
708
+ */
709
+ JulianDate.prototype.getJulianTimeFraction = function() {
710
+ return this._secondsOfDay / TimeConstants.SECONDS_PER_DAY;
711
+ };
712
+
713
+ /**
714
+ * Return the number of seconds elapsed into the current Julian day (starting at noon).
715
+ *
716
+ * @memberof JulianDate
717
+ *
718
+ * @return {Number} The number of seconds elapsed into the current day.
719
+ *
720
+ * @see JulianDate#getJulianDayNumber
721
+ */
722
+ JulianDate.prototype.getSecondsOfDay = function() {
723
+ return this._secondsOfDay;
724
+ };
725
+
726
+ var toGregorianDateScratch = new JulianDate(0, 0, TimeStandard.TAI);
727
+
728
+ /**
729
+ * Creates a GregorianDate representation of this date in UTC.
730
+ * @memberof JulianDate
731
+ *
732
+ * @return {GregorianDate} A gregorian date.
733
+ */
734
+ JulianDate.prototype.toGregorianDate = function() {
735
+ var isLeapSecond = false;
736
+ var thisUtc = convertTaiToUtc(this, toGregorianDateScratch);
737
+ if (typeof thisUtc === 'undefined') {
738
+ //Conversion to UTC will fail if we are during a leap second.
739
+ //If that's the case, subtract a second and convert again.
740
+ //JavaScript doesn't support leap seconds, so this results in second 59 being repeated twice.
741
+ this.addSeconds(-1, toGregorianDateScratch);
742
+ thisUtc = convertTaiToUtc(toGregorianDateScratch, toGregorianDateScratch);
743
+ isLeapSecond = true;
744
+ }
745
+
746
+ var julianDayNumber = thisUtc._julianDayNumber;
747
+ var secondsOfDay = thisUtc._secondsOfDay;
748
+
749
+ if (secondsOfDay >= 43200.0) {
750
+ julianDayNumber += 1;
751
+ }
752
+
753
+ // Algorithm from page 604 of the Explanatory Supplement to the
754
+ // Astronomical Almanac (Seidelmann 1992).
755
+ var L = (julianDayNumber + 68569) | 0;
756
+ var N = (4 * L / 146097) | 0;
757
+ L = (L - (((146097 * N + 3) / 4) | 0)) | 0;
758
+ var I = ((4000 * (L + 1)) / 1461001) | 0;
759
+ L = (L - (((1461 * I) / 4) | 0) + 31) | 0;
760
+ var J = ((80 * L) / 2447) | 0;
761
+ var day = (L - (((2447 * J) / 80) | 0)) | 0;
762
+ L = (J / 11) | 0;
763
+ var month = (J + 2 - 12 * L) | 0;
764
+ var year = (100 * (N - 49) + I + L) | 0;
765
+
766
+ var hour = (secondsOfDay / TimeConstants.SECONDS_PER_HOUR) | 0;
767
+ var remainingSeconds = secondsOfDay - (hour * TimeConstants.SECONDS_PER_HOUR);
768
+ var minute = (remainingSeconds / TimeConstants.SECONDS_PER_MINUTE) | 0;
769
+ remainingSeconds = remainingSeconds - (minute * TimeConstants.SECONDS_PER_MINUTE);
770
+ var second = remainingSeconds | 0;
771
+ var millisecond = ((remainingSeconds - second) / TimeConstants.SECONDS_PER_MILLISECOND);
772
+
773
+ // JulianDates are noon-based
774
+ hour += 12;
775
+ if (hour > 23) {
776
+ hour -= 24;
777
+ }
778
+
779
+ //If we were on a leap second, add it back.
780
+ if (isLeapSecond) {
781
+ second += 1;
782
+ }
783
+
784
+ return new GregorianDate(year, month, day, hour, minute, second, millisecond, isLeapSecond);
785
+ };
786
+
787
+ /**
788
+ * Creates a JavaScript Date representation of this date in UTC.
789
+ * Javascript dates are only accurate to the nearest millisecond.
790
+ * @memberof JulianDate
791
+ *
792
+ * @return {Date} A new JavaScript Date equivalent to this Julian date.
793
+ */
794
+ JulianDate.prototype.toDate = function() {
795
+ var gDate = this.toGregorianDate();
796
+ var second = gDate.second;
797
+ if (gDate.isLeapSecond) {
798
+ second -= 1;
799
+ }
800
+ return new Date(Date.UTC(gDate.year, gDate.month - 1, gDate.day, gDate.hour, gDate.minute, second, gDate.millisecond));
801
+ };
802
+
803
+ /**
804
+ * Creates an ISO8601 string represenation of this Julian date in UTC.
805
+ * @memberof JulianDate
806
+ *
807
+ * @param {Number} [precision] The number of fractional digits used to represent the seconds component. By default, the most precise representation is used.
808
+ * @return {String} An ISO8601 string represenation of this Julian date.
809
+ */
810
+ JulianDate.prototype.toIso8601 = function(precision) {
811
+ var gDate = this.toGregorianDate();
812
+ var millisecondStr;
813
+
814
+ if (typeof precision === 'undefined' && gDate.millisecond !== 0) {
815
+ //Forces milliseconds into a number with at least 3 digits to whatever the default toString() precision is.
816
+ millisecondStr = (gDate.millisecond * 0.01).toString().replace('.', '');
817
+ return sprintf("%04d-%02d-%02dT%02d:%02d:%02d.%sZ", gDate.year, gDate.month, gDate.day, gDate.hour, gDate.minute, gDate.second, millisecondStr);
818
+ }
819
+
820
+ //Precision is either 0 or milliseconds is 0 with undefined precision, in either case, leave off milliseconds entirely
821
+ if (typeof precision === 'undefined' || precision === 0) {
822
+ return sprintf("%04d-%02d-%02dT%02d:%02d:%02dZ", gDate.year, gDate.month, gDate.day, gDate.hour, gDate.minute, gDate.second);
823
+ }
824
+
825
+ //Forces milliseconds into a number with at least 3 digits to whatever the specified precision is.
826
+ millisecondStr = (gDate.millisecond * 0.01).toFixed(precision).replace('.', '').slice(0, precision);
827
+ return sprintf("%04d-%02d-%02dT%02d:%02d:%02d.%sZ", gDate.year, gDate.month, gDate.day, gDate.hour, gDate.minute, gDate.second, millisecondStr);
828
+ };
829
+
830
+ /**
831
+ * Computes the number of seconds that have elapsed from this Julian date to the <code>other</code>
832
+ * Julian date.
833
+ *
834
+ * @memberof JulianDate
835
+ *
836
+ * @param {JulianDate} other The other Julian date, which is the end of the interval.
837
+ *
838
+ * @return {Number} The number of seconds that have elpased from this Julian date to the other Julian date.
839
+ *
840
+ * @see JulianDate#getMinutesDifference
841
+ * @see JulianDate#getDaysDifference
842
+ *
843
+ * @example
844
+ * var start = JulianDate.fromDate(new Date('July 4, 2011 12:00:00'));
845
+ * var end = JulianDate.fromDate(new Date('July 5, 2011 12:01:00'));
846
+ * var difference = start.getSecondsDifference(end); // 86460.0 seconds
847
+ */
848
+ JulianDate.prototype.getSecondsDifference = function(other) {
849
+ var julianDate1 = this;
850
+ var julianDate2 = other;
851
+ var dayDifference = (julianDate2._julianDayNumber - julianDate1._julianDayNumber) * TimeConstants.SECONDS_PER_DAY;
852
+ return (dayDifference + (julianDate2._secondsOfDay - julianDate1._secondsOfDay));
853
+ };
854
+
855
+ /**
856
+ * Computes the number of minutes that have elapsed from this Julian date to the <code>other</code>
857
+ * Julian date.
858
+ *
859
+ * @memberof JulianDate
860
+ *
861
+ * @param {JulianDate} other The other Julian date, which is the end of the interval.
862
+ *
863
+ * @return {Number} The number of seconds that have elpased from this Julian date to the other Julian date.
864
+ *
865
+ * @see JulianDate#getSecondsDifference
866
+ * @see JulianDate#getDaysDifference
867
+ *
868
+ * @example
869
+ * var start = JulianDate.fromDate(new Date('July 4, 2011 12:00:00'));
870
+ * var end = JulianDate.fromDate(new Date('July 5, 2011 12:01:00'));
871
+ * var difference = start.getMinutesDifference(end); // 1441.0 minutes
872
+ */
873
+ JulianDate.prototype.getMinutesDifference = function(other) {
874
+ return this.getSecondsDifference(other) / TimeConstants.SECONDS_PER_MINUTE;
875
+ };
876
+
877
+ /**
878
+ * Computes the number of days that have elapsed from this Julian date to the <code>other</code>
879
+ * Julian date. A day is always exactly 86400.0 seconds.
880
+ *
881
+ * @memberof JulianDate
882
+ *
883
+ * @param {JulianDate} other The other Julian date, which is the end of the interval.
884
+ *
885
+ * @return {Number} The number of days that have elpased from this Julian date to the other Julian date.
886
+ *
887
+ * @see JulianDate#getSecondsDifference
888
+ * @see JulianDate#getMinutesDifference
889
+ *
890
+ * @example
891
+ * var start = JulianDate.fromDate(new Date('July 4, 2011 12:00:00'));
892
+ * var end = JulianDate.fromDate(new Date('July 5, 2011 14:24:00'));
893
+ * var difference = start.getDaysDifference(end); // 1.1 days
894
+ */
895
+ JulianDate.prototype.getDaysDifference = function(other) {
896
+ var julianDate1 = this;
897
+ var julianDate2 = other;
898
+ var dayDifference = (julianDate2._julianDayNumber - julianDate1._julianDayNumber);
899
+ var secondDifference = (julianDate2._secondsOfDay - julianDate1._secondsOfDay) / TimeConstants.SECONDS_PER_DAY;
900
+ return dayDifference + secondDifference;
901
+ };
902
+
903
+ /**
904
+ * Returns the number of seconds this TAI date is ahead of UTC.
905
+ *
906
+ * @memberof JulianDate
907
+ *
908
+ * @return {Number} The number of seconds this TAI date is ahead of UTC
909
+ *
910
+ * @see LeapSecond
911
+ * @see TimeStandard
912
+ *
913
+ * @example
914
+ * var date = new Date('August 1, 2012 12:00:00 UTC');
915
+ * var julianDate = JulianDate.fromDate(date);
916
+ * var difference = julianDate.getTaiMinusUtc(); //35
917
+ */
918
+ JulianDate.prototype.getTaiMinusUtc = function() {
919
+ var toFind = new LeapSecond(this, 0.0);
920
+ var leapSeconds = LeapSecond.getLeapSeconds();
921
+ var index = binarySearch(leapSeconds, toFind, LeapSecond.compareLeapSecondDate);
922
+ if (index < 0) {
923
+ index = ~index;
924
+ --index;
925
+ if (index < 0) {
926
+ index = 0;
927
+ }
928
+ }
929
+ return leapSeconds[index].offset;
930
+ };
931
+
932
+ /**
933
+ * Returns a new Julian date representing a time <code>duration</code> seconds later
934
+ * (or earlier in the case of a negative amount).
935
+ *
936
+ * @memberof JulianDate
937
+ *
938
+ * @param {Number} seconds The number of seconds to add or subtract.
939
+ * @param {JulianDate} [result] The JulianDate to store the result into.
940
+ *
941
+ * @return {JulianDate} The modified result parameter or a new JulianDate instance if it was not provided.
942
+ *
943
+ * @exception {DeveloperError} seconds is required and must be a number.
944
+ *
945
+ * @see JulianDate#addMinutes
946
+ * @see JulianDate#addHours
947
+ * @see JulianDate#addDays
948
+ *
949
+ * @example
950
+ * var date = new Date();
951
+ * date.setUTCFullYear(2011, 6, 4); // July 4, 2011 @ 12:00:00 UTC
952
+ * date.setUTCHours(12, 0, 00, 0);
953
+ * var start = JulianDate.fromDate(date);
954
+ * var end = start.addSeconds(95); // July 4, 2011 @ 12:01:35 UTC
955
+ */
956
+ JulianDate.prototype.addSeconds = function(seconds, result) {
957
+ if (seconds === null || isNaN(seconds)) {
958
+ throw new DeveloperError('seconds is required and must be a number.');
959
+ }
960
+ return setComponents(this._julianDayNumber, this._secondsOfDay + seconds, result);
961
+ };
962
+
963
+ /**
964
+ * Returns a new Julian date representing a time <code>duration</code> minutes later
965
+ * (or earlier in the case of a negative amount).
966
+ *
967
+ * @memberof JulianDate
968
+ *
969
+ * @param {Number} duration An integer number of minutes to add or subtract.
970
+ *
971
+ * @return {JulianDate} A new Julian date object
972
+ *
973
+ * @exception {DeveloperError} duration is required and must be a number.
974
+ *
975
+ * @see JulianDate#addSeconds
976
+ * @see JulianDate#addHours
977
+ * @see JulianDate#addDays
978
+ *
979
+ * @example
980
+ * var date = new Date();
981
+ * date.setUTCFullYear(2011, 6, 4); // July 4, 2011 @ 12:00 UTC
982
+ * date.setUTCHours(12, 0, 0, 0);
983
+ * var start = JulianDate.fromDate(date);
984
+ * var end = start.addMinutes(65); // July 4, 2011 @ 13:05 UTC
985
+ */
986
+ JulianDate.prototype.addMinutes = function(duration) {
987
+ if (duration === null || isNaN(duration)) {
988
+ throw new DeveloperError('duration is required and must be a number.');
989
+ }
990
+ var newSecondsOfDay = this._secondsOfDay + (duration * TimeConstants.SECONDS_PER_MINUTE);
991
+ return new JulianDate(this._julianDayNumber, newSecondsOfDay, TimeStandard.TAI);
992
+ };
993
+
994
+ /**
995
+ * Returns a new Julian date representing a time <code>duration</code> hours later
996
+ * (or earlier in the case of a negative amount).
997
+ *
998
+ * @memberof JulianDate
999
+ *
1000
+ * @param {Number} duration An integer number of hours to add or subtract.
1001
+ *
1002
+ * @return {JulianDate} A new Julian date object
1003
+ *
1004
+ * @exception {DeveloperError} duration is required and must be a number.
1005
+ *
1006
+ * @see JulianDate#addSeconds
1007
+ * @see JulianDate#addMinutes
1008
+ * @see JulianDate#addDays
1009
+ *
1010
+ * @example
1011
+ * var date = new Date();
1012
+ * date.setUTCFullYear(2011, 6, 4); // July 4, 2011 @ 12:00 UTC
1013
+ * date.setUTCHours(12, 0, 0, 0);
1014
+ * var start = JulianDate.fromDate(date);
1015
+ * var end = start.addHours(6); // July 4, 2011 @ 18:00 UTC
1016
+ */
1017
+ JulianDate.prototype.addHours = function(duration) {
1018
+ if (duration === null || isNaN(duration)) {
1019
+ throw new DeveloperError('duration is required and must be a number.');
1020
+ }
1021
+ var newSecondsOfDay = this._secondsOfDay + (duration * TimeConstants.SECONDS_PER_HOUR);
1022
+ return new JulianDate(this._julianDayNumber, newSecondsOfDay, TimeStandard.TAI);
1023
+ };
1024
+
1025
+ /**
1026
+ * Returns a new Julian date representing a time <code>duration</code> days later
1027
+ * (or earlier in the case of a negative amount).
1028
+ *
1029
+ * @memberof JulianDate
1030
+ *
1031
+ * @param {Number} duration An integer number of days to add or subtract.
1032
+ *
1033
+ * @return {JulianDate} A new Julian date object
1034
+ *
1035
+ * @exception {DeveloperError} duration is required and must be a number.
1036
+ *
1037
+ * @see JulianDate#addSeconds
1038
+ * @see JulianDate#addMinutes
1039
+ * @see JulianDate#addHours
1040
+ *
1041
+ * @example
1042
+ * var date = new Date();
1043
+ * date.setUTCFullYear(2011, 6, 4); // July 4, 2011 @ 12:00 UTC
1044
+ * date.setUTCHours(12, 0, 0, 0);
1045
+ * var start = JulianDate.fromDate(date);
1046
+ * var end = start.addDays(5); // July 9, 2011 @ 12:00 UTC
1047
+ */
1048
+ JulianDate.prototype.addDays = function(duration) {
1049
+ if (duration === null || isNaN(duration)) {
1050
+ throw new DeveloperError('duration is required and must be a number.');
1051
+ }
1052
+ var newJulianDayNumber = this._julianDayNumber + duration;
1053
+ return new JulianDate(newJulianDayNumber, this._secondsOfDay, TimeStandard.TAI);
1054
+ };
1055
+
1056
+ /**
1057
+ * Returns true if <code>other</code> occurs after this Julian date.
1058
+ *
1059
+ * @memberof JulianDate
1060
+ *
1061
+ * @param {JulianDate} other The Julian date to be compared.
1062
+ *
1063
+ * @return {Boolean} <code>true</code> if this JulianDate is chronologically earlier than <code>other</code>; otherwise, <code>false</code>.
1064
+ *
1065
+ * @see JulianDate#lessThanOrEquals
1066
+ * @see JulianDate#greaterThan
1067
+ * @see JulianDate#greaterThanOrEquals
1068
+ *
1069
+ * @example
1070
+ * var start = JulianDate.fromDate(new Date('July 6, 1991 12:00:00'));
1071
+ * var end = JulianDate.fromDate(new Date('July 6, 2011 12:01:00'));
1072
+ * start.lessThan(end); // true
1073
+ */
1074
+ JulianDate.prototype.lessThan = function(other) {
1075
+ return JulianDate.compare(this, other) < 0;
1076
+ };
1077
+
1078
+ /**
1079
+ * Returns true if <code>other</code> occurs at or after this Julian date.
1080
+ *
1081
+ * @memberof JulianDate
1082
+ *
1083
+ * @param {JulianDate} other The Julian date to be compared.
1084
+ *
1085
+ * @return {Boolean} <code>true</code> if this JulianDate is chronologically less than or equal to<code>other</code>; otherwise, <code>false</code>.
1086
+ *
1087
+ * @see JulianDate#lessThan
1088
+ * @see JulianDate#greaterThan
1089
+ * @see JulianDate#greaterThanOrEquals
1090
+ *
1091
+ * @example
1092
+ * var start = JulianDate.fromDate(new Date('July 6, 1991 12:00:00'));
1093
+ * var end = JulianDate.fromDate(new Date('July 6, 2011 12:00:00'));
1094
+ * start.lessThanOrEquals(end); // true
1095
+ */
1096
+ JulianDate.prototype.lessThanOrEquals = function(other) {
1097
+ return JulianDate.compare(this, other) <= 0;
1098
+ };
1099
+
1100
+ /**
1101
+ * Returns true if <code>other</code> occurs before this Julian date.
1102
+ *
1103
+ * @memberof JulianDate
1104
+ *
1105
+ * @param {JulianDate} other The Julian date to be compared.
1106
+ *
1107
+ * @return {Boolean} <code>true</code> if this JulianDate is chronologically later than <code>other</code>; otherwise, <code>false</code>.
1108
+ *
1109
+ * @see JulianDate#lessThan
1110
+ * @see JulianDate#lessThanOrEquals
1111
+ * @see JulianDate#greaterThanOrEquals
1112
+ *
1113
+ * @example
1114
+ * var start = JulianDate.fromDate(new Date('July 6, 1991 12:00:00'));
1115
+ * var end = JulianDate.fromDate(new Date('July 6, 2011 12:01:00'));
1116
+ * end.greaterThan(start); // true
1117
+ */
1118
+ JulianDate.prototype.greaterThan = function(other) {
1119
+ return JulianDate.compare(this, other) > 0;
1120
+ };
1121
+
1122
+ /**
1123
+ * Returns true if <code>other</code> occurs at or before this Julian date.
1124
+ *
1125
+ * @memberof JulianDate
1126
+ *
1127
+ * @param {JulianDate} other The Julian date to be compared.
1128
+ *
1129
+ * @return {Boolean} <code>true</code> if this JulianDate is chronologically later than or equal to <code>other</code>; otherwise, <code>false</code>.
1130
+ *
1131
+ * @see JulianDate#lessThan
1132
+ * @see JulianDate#lessThanOrEquals
1133
+ * @see JulianDate#greaterThan
1134
+ *
1135
+ * @example
1136
+ * var start = JulianDate.fromDate(new Date('July 6, 1991 12:00:00'));
1137
+ * var end = JulianDate.fromDate(new Date('July 6, 2011 12:00:00'));
1138
+ * end.greaterThanOrEquals(start); // true
1139
+ */
1140
+ JulianDate.prototype.greaterThanOrEquals = function(other) {
1141
+ return JulianDate.compare(this, other) >= 0;
1142
+ };
1143
+
1144
+ /**
1145
+ * Returns <code>true</code> if this date is equivalent to the specified date.
1146
+ *
1147
+ * @memberof JulianDate
1148
+ *
1149
+ * @param {JulianDate} other The JulianDate to be compared.
1150
+ * @param {Number} epsilon The number of seconds that should separate the two JulianDates
1151
+ *
1152
+ * @return {Boolean} <code>true</code> if the two JulianDates are equal; otherwise <code>false</code>.
1153
+ *
1154
+ * @see JulianDate#equalsEpsilon
1155
+ *
1156
+ * @example
1157
+ * var original = JulianDate.fromDate(new Date('July 4, 2011 12:00:00'));
1158
+ * var clone = JulianDate.fromDate(new Date('July 4, 2011 12:00:00'));
1159
+ * original.equals(clone); // true
1160
+ */
1161
+ JulianDate.prototype.equals = function(other) {
1162
+ return JulianDate.compare(this, other) === 0;
1163
+ };
1164
+
1165
+ /**
1166
+ * Returns <code>true</code> if this date is within <code>epsilon</code> seconds of the
1167
+ * specified date. That is, in order for the dates to be considered equal (and for
1168
+ * this function to return <code>true</code>), the absolute value of the difference between them, in
1169
+ * seconds, must be less than <code>epsilon</code>.
1170
+ *
1171
+ * @memberof JulianDate
1172
+ *
1173
+ * @param {JulianDate} other The JulianDate to be compared.
1174
+ * @param {Number} epsilon The number of seconds that should separate the two JulianDates
1175
+ *
1176
+ * @return {Boolean} <code>true</code> if the two JulianDates are within <code>epsilon</code> seconds of each other; otherwise <code>false</code>.
1177
+ *
1178
+ * @exception {DeveloperError} epsilon is required and must be number.
1179
+ *
1180
+ * @see JulianDate#equals
1181
+ *
1182
+ * @example
1183
+ * var original = JulianDate.fromDate(new Date('July 4, 2011 12:00:00'));
1184
+ * var clone = JulianDate.fromDate(new Date('July 4, 2011 12:00:01'));
1185
+ * original.equalsEpsilon(clone, 2); // true
1186
+ */
1187
+ JulianDate.prototype.equalsEpsilon = function(other, epsilon) {
1188
+ if (epsilon === null || isNaN(epsilon)) {
1189
+ throw new DeveloperError('epsilon is required and must be number.');
1190
+ }
1191
+ return Math.abs(this.getSecondsDifference(other)) <= epsilon;
1192
+ };
1193
+
1194
+ //To avoid circular dependencies, we load the default list of leap seconds
1195
+ //here, rather than in the LeapSecond class itself.
1196
+ if (LeapSecond._leapSeconds.length === 0) {
1197
+ LeapSecond._leapSeconds = [
1198
+ new LeapSecond(new JulianDate(2441317, 43210.0, TimeStandard.TAI), 10), // January 1, 1972 00:00:00 UTC
1199
+ new LeapSecond(new JulianDate(2441499, 43211.0, TimeStandard.TAI), 11), // July 1, 1972 00:00:00 UTC
1200
+ new LeapSecond(new JulianDate(2441683, 43212.0, TimeStandard.TAI), 12), // January 1, 1973 00:00:00 UTC
1201
+ new LeapSecond(new JulianDate(2442048, 43213.0, TimeStandard.TAI), 13), // January 1, 1974 00:00:00 UTC
1202
+ new LeapSecond(new JulianDate(2442413, 43214.0, TimeStandard.TAI), 14), // January 1, 1975 00:00:00 UTC
1203
+ new LeapSecond(new JulianDate(2442778, 43215.0, TimeStandard.TAI), 15), // January 1, 1976 00:00:00 UTC
1204
+ new LeapSecond(new JulianDate(2443144, 43216.0, TimeStandard.TAI), 16), // January 1, 1977 00:00:00 UTC
1205
+ new LeapSecond(new JulianDate(2443509, 43217.0, TimeStandard.TAI), 17), // January 1, 1978 00:00:00 UTC
1206
+ new LeapSecond(new JulianDate(2443874, 43218.0, TimeStandard.TAI), 18), // January 1, 1979 00:00:00 UTC
1207
+ new LeapSecond(new JulianDate(2444239, 43219.0, TimeStandard.TAI), 19), // January 1, 1980 00:00:00 UTC
1208
+ new LeapSecond(new JulianDate(2444786, 43220.0, TimeStandard.TAI), 20), // July 1, 1981 00:00:00 UTC
1209
+ new LeapSecond(new JulianDate(2445151, 43221.0, TimeStandard.TAI), 21), // July 1, 1982 00:00:00 UTC
1210
+ new LeapSecond(new JulianDate(2445516, 43222.0, TimeStandard.TAI), 22), // July 1, 1983 00:00:00 UTC
1211
+ new LeapSecond(new JulianDate(2446247, 43223.0, TimeStandard.TAI), 23), // July 1, 1985 00:00:00 UTC
1212
+ new LeapSecond(new JulianDate(2447161, 43224.0, TimeStandard.TAI), 24), // January 1, 1988 00:00:00 UTC
1213
+ new LeapSecond(new JulianDate(2447892, 43225.0, TimeStandard.TAI), 25), // January 1, 1990 00:00:00 UTC
1214
+ new LeapSecond(new JulianDate(2448257, 43226.0, TimeStandard.TAI), 26), // January 1, 1991 00:00:00 UTC
1215
+ new LeapSecond(new JulianDate(2448804, 43227.0, TimeStandard.TAI), 27), // July 1, 1992 00:00:00 UTC
1216
+ new LeapSecond(new JulianDate(2449169, 43228.0, TimeStandard.TAI), 28), // July 1, 1993 00:00:00 UTC
1217
+ new LeapSecond(new JulianDate(2449534, 43229.0, TimeStandard.TAI), 29), // July 1, 1994 00:00:00 UTC
1218
+ new LeapSecond(new JulianDate(2450083, 43230.0, TimeStandard.TAI), 30), // January 1, 1996 00:00:00 UTC
1219
+ new LeapSecond(new JulianDate(2450630, 43231.0, TimeStandard.TAI), 31), // July 1, 1997 00:00:00 UTC
1220
+ new LeapSecond(new JulianDate(2451179, 43232.0, TimeStandard.TAI), 32), // January 1, 1999 00:00:00 UTC
1221
+ new LeapSecond(new JulianDate(2453736, 43233.0, TimeStandard.TAI), 33), // January 1, 2006 00:00:00 UTC
1222
+ new LeapSecond(new JulianDate(2454832, 43234.0, TimeStandard.TAI), 34), // January 1, 2009 00:00:00 UTC
1223
+ new LeapSecond(new JulianDate(2456109, 43235.0, TimeStandard.TAI), 35) // July 1, 2012 00:00:00 UTC
1224
+ ];
1225
+ }
1226
+
1227
+ return JulianDate;
1228
+ });