@cesium/engine 24.0.0 → 26.0.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.
- package/Build/Workers/{chunk-6WLHJFD3.js → chunk-3VFEWOBI.js} +59 -32
- package/Build/Workers/{chunk-UQU4RXLT.js → chunk-424RNO3D.js} +50 -45
- package/Build/Workers/chunk-4MGMYHOO.js +147 -0
- package/Build/Workers/{chunk-AMIHNSST.js → chunk-4S7IE3LB.js} +2 -2
- package/Build/Workers/{chunk-J6AW5YHS.js → chunk-52JDLOEM.js} +14 -14
- package/Build/Workers/{chunk-6RMS4S72.js → chunk-54I6Y66F.js} +6 -6
- package/Build/Workers/{chunk-C6P4IG5P.js → chunk-6YEE6JDR.js} +6 -6
- package/Build/Workers/{chunk-72VYSVEW.js → chunk-7J2HKPRH.js} +11 -10
- package/Build/Workers/{chunk-7O5XJTVE.js → chunk-7WM2PX4V.js} +5 -5
- package/Build/Workers/{chunk-5A2SW66E.js → chunk-ACXQXN46.js} +16 -16
- package/Build/Workers/{chunk-VLDEUTOP.js → chunk-AYKR4VBR.js} +2 -2
- package/Build/Workers/{chunk-YQFTYQMZ.js → chunk-C6J67V5A.js} +3 -2
- package/Build/Workers/{chunk-D4EJ2NXG.js → chunk-C6KNZ7T4.js} +17 -17
- package/Build/Workers/{chunk-7MDYBRYJ.js → chunk-CFQP6LYM.js} +4 -4
- package/Build/Workers/{chunk-YAOZMOFL.js → chunk-CXOYE2WM.js} +5 -5
- package/Build/Workers/{chunk-B6SCUUFP.js → chunk-CZEYZU4N.js} +10 -10
- package/Build/Workers/{chunk-NPF7SSHZ.js → chunk-DBOEKL43.js} +7 -7
- package/Build/Workers/{chunk-44EMEGKW.js → chunk-DDWSZVMY.js} +5 -5
- package/Build/Workers/{chunk-7X322WP2.js → chunk-DOBXCNC3.js} +13 -13
- package/Build/Workers/{chunk-JCI63T3K.js → chunk-E7VQ76KE.js} +6 -6
- package/Build/Workers/{chunk-7TYLCBGK.js → chunk-EBSIOBXY.js} +12 -10
- package/Build/Workers/{chunk-GQUNK2XC.js → chunk-EF2QYXGA.js} +14 -14
- package/Build/Workers/{chunk-BJD6QGXZ.js → chunk-EPYXRCDB.js} +12 -12
- package/Build/Workers/{chunk-63SIWPLS.js → chunk-F6QDY6HU.js} +13 -13
- package/Build/Workers/{chunk-XY6HMDGI.js → chunk-FRQZECAO.js} +5 -5
- package/Build/Workers/{chunk-VMVOUQ5J.js → chunk-G7PXZRVF.js} +7 -7
- package/Build/Workers/{chunk-N65BAKSH.js → chunk-INUEEEQA.js} +8 -8
- package/Build/Workers/{chunk-7QRFIKWQ.js → chunk-IRBKFCEJ.js} +2 -2
- package/Build/Workers/{chunk-UIGVOKKI.js → chunk-IYOUHCZB.js} +3 -2
- package/Build/Workers/{chunk-5GXYJQ2K.js → chunk-J6BWOHUF.js} +3 -3
- package/Build/Workers/{chunk-A47HVBC5.js → chunk-KFSTQKNM.js} +7 -7
- package/Build/Workers/{chunk-EV3VGO6Y.js → chunk-KKOSKAZB.js} +17 -17
- package/Build/Workers/{chunk-6MPGQEHA.js → chunk-KSSWJIZW.js} +2 -2
- package/Build/Workers/{chunk-DHKPFLSJ.js → chunk-M3B5JKSM.js} +3 -2
- package/Build/Workers/chunk-MPZHGZU6.js +2342 -0
- package/Build/Workers/{chunk-YJZGW74L.js → chunk-MYP774IS.js} +2213 -1349
- package/Build/Workers/{chunk-LIB2H534.js → chunk-O3EA5HS7.js} +12 -11
- package/Build/Workers/{chunk-ILMFADZA.js → chunk-P3CK7MCY.js} +27 -5
- package/Build/Workers/chunk-Q3PY526V.js +3201 -0
- package/Build/Workers/chunk-QN67VG36.js +973 -0
- package/Build/Workers/{chunk-XJRBB253.js → chunk-QRWGUWI6.js} +11 -11
- package/Build/Workers/{chunk-AF3MU2RL.js → chunk-S4MCOY6I.js} +7 -6
- package/Build/Workers/{chunk-Y7HNNPNK.js → chunk-SMQZZOW6.js} +10 -10
- package/Build/Workers/{chunk-PVV64VFW.js → chunk-TKKIREQ6.js} +3 -2
- package/Build/Workers/{chunk-MKM27KGV.js → chunk-U3ZA64U7.js} +2 -2
- package/Build/Workers/{chunk-2N4KDHS3.js → chunk-UA25D5MX.js} +12 -11
- package/Build/Workers/{chunk-RQNJD3O4.js → chunk-UOOIQ3KX.js} +12 -12
- package/Build/Workers/{chunk-GOQBUCXH.js → chunk-V7VQKN6N.js} +709 -431
- package/Build/Workers/{chunk-LXMCPFFS.js → chunk-VQYETPWC.js} +4 -4
- package/Build/Workers/{chunk-NKT5K3K3.js → chunk-VWV2IJRB.js} +13 -12
- package/Build/Workers/chunk-XZMBNNDX.js +1287 -0
- package/Build/Workers/{chunk-ISY4EZCA.js → chunk-Y57HREW5.js} +4 -4
- package/Build/Workers/{chunk-EDXL4W76.js → chunk-Y5BF6AFU.js} +2 -2
- package/Build/Workers/{chunk-Q3C6VQH6.js → chunk-YLY7NKAB.js} +4 -4
- package/Build/Workers/{chunk-4TIG36AW.js → chunk-ZK3CF7ZD.js} +12 -12
- package/Build/Workers/{chunk-AJLTU6PF.js → chunk-ZP7JMQV4.js} +4 -1
- package/Build/Workers/{chunk-HXJMS2ZI.js → chunk-ZZ46LWL6.js} +1 -1
- package/Build/Workers/combineGeometry.js +24 -24
- package/Build/Workers/createBoxGeometry.js +18 -18
- package/Build/Workers/createBoxOutlineGeometry.js +16 -16
- package/Build/Workers/createCircleGeometry.js +26 -26
- package/Build/Workers/createCircleOutlineGeometry.js +19 -19
- package/Build/Workers/createCoplanarPolygonGeometry.js +33 -33
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -31
- package/Build/Workers/createCorridorGeometry.js +29 -29
- package/Build/Workers/createCorridorOutlineGeometry.js +28 -28
- package/Build/Workers/createCylinderGeometry.js +20 -20
- package/Build/Workers/createCylinderOutlineGeometry.js +18 -18
- package/Build/Workers/createEllipseGeometry.js +26 -26
- package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
- package/Build/Workers/createEllipsoidGeometry.js +19 -19
- package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
- package/Build/Workers/createFrustumGeometry.js +18 -18
- package/Build/Workers/createFrustumOutlineGeometry.js +18 -18
- package/Build/Workers/createGeometry.js +24 -24
- package/Build/Workers/createGroundPolylineGeometry.js +175 -118
- package/Build/Workers/createPlaneGeometry.js +16 -16
- package/Build/Workers/createPlaneOutlineGeometry.js +15 -15
- package/Build/Workers/createPolygonGeometry.js +32 -32
- package/Build/Workers/createPolygonOutlineGeometry.js +30 -30
- package/Build/Workers/createPolylineGeometry.js +25 -25
- package/Build/Workers/createPolylineVolumeGeometry.js +31 -31
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
- package/Build/Workers/createRectangleGeometry.js +27 -27
- package/Build/Workers/createRectangleOutlineGeometry.js +20 -20
- package/Build/Workers/createSimplePolylineGeometry.js +23 -23
- package/Build/Workers/createSphereGeometry.js +19 -19
- package/Build/Workers/createSphereOutlineGeometry.js +18 -18
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
- package/Build/Workers/createVectorTileGeometries.js +24 -24
- package/Build/Workers/createVectorTilePoints.js +13 -13
- package/Build/Workers/createVectorTilePolygons.js +22 -22
- package/Build/Workers/createVectorTilePolylines.js +14 -14
- package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -25
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
- package/Build/Workers/createVerticesFromHeightmap.js +24 -23
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +20 -20
- package/Build/Workers/createWallGeometry.js +24 -24
- package/Build/Workers/createWallOutlineGeometry.js +23 -23
- package/Build/Workers/decodeDraco.js +10 -10
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +10 -10
- package/Build/Workers/gaussianSplatSorter.js +4 -4
- package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
- package/Build/Workers/incrementallyBuildTerrainPicker.js +10 -10
- package/Build/Workers/transcodeKTX2.js +12 -9
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
- package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
- package/Source/Core/ArcType.js +6 -1
- package/Source/Core/ArticulationStageType.js +5 -1
- package/Source/Core/AssociativeArray.js +100 -94
- package/Source/Core/BoundingSphere.js +1296 -1300
- package/Source/Core/Cartesian2.js +1 -1
- package/Source/Core/Cartesian3.js +2 -3
- package/Source/Core/Cartesian4.js +1 -1
- package/Source/Core/Cartographic.js +257 -249
- package/Source/Core/ClockRange.js +6 -1
- package/Source/Core/ClockStep.js +6 -1
- package/Source/Core/Color.js +844 -835
- package/Source/Core/ComponentDatatype.js +39 -1
- package/Source/Core/CornerType.js +6 -1
- package/Source/Core/Credit.js +121 -124
- package/Source/Core/Ellipsoid.js +637 -660
- package/Source/Core/ExtrapolationType.js +6 -1
- package/Source/Core/GeocodeType.js +6 -1
- package/Source/Core/GeographicProjection.js +74 -74
- package/Source/Core/GeographicTilingScheme.js +179 -198
- package/Source/Core/GeometryOffsetAttribute.js +7 -1
- package/Source/Core/GeometryType.js +7 -1
- package/Source/Core/HeightmapEncoding.js +6 -1
- package/Source/Core/Iau2006XysData.js +24 -13
- package/Source/Core/IndexDatatype.js +3 -1
- package/Source/Core/InterpolationType.js +5 -1
- package/Source/Core/Intersect.js +6 -1
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/IonGeocodeProviderType.js +5 -1
- package/Source/Core/JulianDate.js +850 -848
- package/Source/Core/KeyboardEventModifier.js +6 -1
- package/Source/Core/MapProjection.js +40 -44
- package/Source/Core/Matrix2.js +906 -893
- package/Source/Core/Matrix3.js +1643 -1575
- package/Source/Core/Matrix4.js +2903 -2872
- package/Source/Core/PixelFormat.js +3 -1
- package/Source/Core/PrimitiveType.js +11 -1
- package/Source/Core/Ray.js +62 -60
- package/Source/Core/Rectangle.js +913 -904
- package/Source/Core/ReferenceFrame.js +6 -1
- package/Source/Core/RequestScheduler.js +8 -3
- package/Source/Core/RequestState.js +6 -1
- package/Source/Core/RequestType.js +6 -1
- package/Source/Core/Resource.js +1 -1
- package/Source/Core/ScreenSpaceEventHandler.js +51 -41
- package/Source/Core/ScreenSpaceEventType.js +6 -1
- package/Source/Core/TerrainQuantization.js +6 -1
- package/Source/Core/TilingScheme.js +100 -98
- package/Source/Core/TimeConstants.js +6 -1
- package/Source/Core/TimeStandard.js +6 -1
- package/Source/Core/TrackingReferenceFrame.js +6 -1
- package/Source/Core/Visibility.js +6 -1
- package/Source/Core/VulkanConstants.js +6 -1
- package/Source/Core/WebGLConstants.js +6 -1
- package/Source/Core/WebMercatorProjection.js +108 -109
- package/Source/Core/WebMercatorTilingScheme.js +246 -242
- package/Source/Core/WindingOrder.js +3 -1
- package/Source/Core/createColorRamp.js +37 -0
- package/Source/Core/globalTypes.js +25 -0
- package/Source/DataSources/StaticGroundGeometryPerMaterialBatch.js +1 -0
- package/Source/DataSources/StaticGroundPolylinePerMaterialBatch.js +1 -0
- package/Source/DataSources/StripeOrientation.js +6 -1
- package/Source/Renderer/BufferUsage.js +20 -9
- package/Source/Renderer/Context.js +2 -29
- package/Source/Renderer/DrawCommand.js +435 -403
- package/Source/Renderer/MipmapHint.js +5 -1
- package/Source/Renderer/Pass.js +10 -3
- package/Source/Renderer/PickId.js +44 -0
- package/Source/Renderer/PixelDatatype.js +3 -1
- package/Source/Renderer/RenderbufferFormat.js +5 -1
- package/Source/Renderer/ShaderDestination.js +4 -1
- package/Source/Renderer/TextureMagnificationFilter.js +3 -1
- package/Source/Renderer/TextureMinificationFilter.js +3 -1
- package/Source/Renderer/TextureWrap.js +5 -1
- package/Source/Renderer/createUniform.js +346 -239
- package/Source/Renderer/createUniformArray.js +494 -381
- package/Source/Scene/AlphaMode.js +5 -1
- package/Source/Scene/ArcGisBaseMapType.js +6 -1
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/AttributeType.js +3 -1
- package/Source/Scene/Axis.js +3 -1
- package/Source/Scene/BingMapsStyle.js +6 -1
- package/Source/Scene/BlendEquation.js +6 -1
- package/Source/Scene/BlendFunction.js +6 -1
- package/Source/Scene/BlendOption.js +6 -1
- package/Source/Scene/BlendingState.js +6 -1
- package/Source/Scene/BufferLoader.js +0 -2
- package/Source/Scene/BufferPoint.js +1 -0
- package/Source/Scene/BufferPointCollection.js +17 -1
- package/Source/Scene/BufferPolygon.js +3 -2
- package/Source/Scene/BufferPolygonCollection.js +13 -1
- package/Source/Scene/BufferPolyline.js +1 -0
- package/Source/Scene/BufferPolylineCollection.js +5 -1
- package/Source/Scene/BufferPrimitiveCollection.js +210 -43
- package/Source/Scene/CameraEventAggregator.js +30 -18
- package/Source/Scene/CameraEventType.js +6 -1
- package/Source/Scene/Cesium3DTile.js +54 -1
- package/Source/Scene/Cesium3DTileColorBlendMode.js +6 -1
- package/Source/Scene/Cesium3DTileContent.js +195 -254
- package/Source/Scene/Cesium3DTileContentFactory.js +10 -2
- package/Source/Scene/Cesium3DTileContentState.js +6 -1
- package/Source/Scene/Cesium3DTileContentType.js +3 -1
- package/Source/Scene/Cesium3DTileFeature.js +289 -306
- package/Source/Scene/Cesium3DTileOptimizationHint.js +6 -1
- package/Source/Scene/Cesium3DTilePass.js +5 -1
- package/Source/Scene/Cesium3DTilePointFeature.js +433 -511
- package/Source/Scene/Cesium3DTileRefine.js +6 -1
- package/Source/Scene/Cesium3DTileVectorFeature.js +586 -0
- package/Source/Scene/Cesium3DTileset.js +46 -6
- package/Source/Scene/ClassificationType.js +3 -1
- package/Source/Scene/CloudType.js +3 -1
- package/Source/Scene/ColorBlendMode.js +4 -1
- package/Source/Scene/Composite3DTileContent.js +254 -292
- package/Source/Scene/CullFace.js +6 -1
- package/Source/Scene/DepthFunction.js +6 -1
- package/Source/Scene/DynamicAtmosphereLightingType.js +3 -1
- package/Source/Scene/EdgeDisplayMode.js +50 -0
- package/Source/Scene/Empty3DTileContent.js +100 -132
- package/Source/Scene/EquirectangularPanorama.js +1 -0
- package/Source/Scene/ExpressionNodeType.js +6 -1
- package/Source/Scene/GaussianSplat3DTileContent.js +436 -478
- package/Source/Scene/GeoJsonPrimitive.js +874 -0
- package/Source/Scene/Geometry3DTileContent.js +151 -185
- package/Source/Scene/GltfBufferViewLoader.js +0 -2
- package/Source/Scene/GltfDracoLoader.js +0 -2
- package/Source/Scene/GltfImageLoader.js +0 -3
- package/Source/Scene/GltfIndexBufferLoader.js +0 -4
- package/Source/Scene/GltfJsonLoader.js +0 -2
- package/Source/Scene/GltfLoader.js +109 -5
- package/Source/Scene/GltfLoaderUtil.js +14 -0
- package/Source/Scene/GltfSpzLoader.js +0 -2
- package/Source/Scene/GltfStructuralMetadataLoader.js +0 -2
- package/Source/Scene/GltfTextureLoader.js +0 -2
- package/Source/Scene/GltfVertexBufferLoader.js +0 -4
- package/Source/Scene/HeightReference.js +5 -1
- package/Source/Scene/HorizontalOrigin.js +6 -1
- package/Source/Scene/ImageryProvider.js +1 -1
- package/Source/Scene/ImageryState.js +6 -1
- package/Source/Scene/Implicit3DTileContent.js +179 -214
- package/Source/Scene/ImplicitSubdivisionScheme.js +3 -1
- package/Source/Scene/InstanceAttributeSemantic.js +3 -1
- package/Source/Scene/IonWorldImageryStyle.js +6 -1
- package/Source/Scene/JobType.js +6 -1
- package/Source/Scene/LabelStyle.js +6 -1
- package/Source/Scene/MVTDataProvider.js +147 -0
- package/Source/Scene/MapMode2D.js +6 -1
- package/Source/Scene/MetadataComponentType.js +3 -1
- package/Source/Scene/MetadataSchemaLoader.js +0 -2
- package/Source/Scene/MetadataSemantic.js +6 -2
- package/Source/Scene/MetadataType.js +3 -1
- package/Source/Scene/Model/B3dmLoader.js +0 -3
- package/Source/Scene/Model/CustomShaderMode.js +3 -1
- package/Source/Scene/Model/CustomShaderTranslucencyMode.js +5 -1
- package/Source/Scene/Model/EdgeVisibilityPipelineStage.js +78 -337
- package/Source/Scene/Model/Extensions/Gpm/PpeSource.js +5 -1
- package/Source/Scene/Model/Extensions/Gpm/StorageType.js +5 -1
- package/Source/Scene/Model/GeoJsonLoader.js +0 -2
- package/Source/Scene/Model/I3dmLoader.js +0 -3
- package/Source/Scene/Model/InstancingPipelineStage.js +1 -1
- package/Source/Scene/Model/LightingModel.js +5 -1
- package/Source/Scene/Model/MaterialPipelineStage.js +184 -3
- package/Source/Scene/Model/Model.js +34 -0
- package/Source/Scene/Model/Model3DTileContent.js +424 -458
- package/Source/Scene/Model/ModelDrawCommand.js +31 -3
- package/Source/Scene/Model/ModelReader.js +474 -3
- package/Source/Scene/Model/ModelRuntimePrimitive.js +2 -1
- package/Source/Scene/Model/ModelType.js +3 -1
- package/Source/Scene/Model/ModelUtility.js +4 -0
- package/Source/Scene/Model/PntsLoader.js +4 -3
- package/Source/Scene/Model/StyleCommandsNeeded.js +3 -1
- package/Source/Scene/Model/UniformType.js +5 -1
- package/Source/Scene/Model/VaryingType.js +5 -1
- package/Source/Scene/Model/createVectorTileBuffersFromModelComponents.js +500 -139
- package/Source/Scene/Model/pickModel.js +94 -299
- package/Source/Scene/ModelAnimationLoop.js +6 -1
- package/Source/Scene/ModelAnimationState.js +6 -1
- package/Source/Scene/ModelComponents.js +47 -2
- package/Source/Scene/Multiple3DTileContent.js +291 -334
- package/Source/Scene/PrimitiveState.js +7 -1
- package/Source/Scene/QuadtreeOccluders.js +20 -15
- package/Source/Scene/QuadtreeTile.js +547 -541
- package/Source/Scene/QuadtreeTileLoadState.js +6 -1
- package/Source/Scene/QuadtreeTileProvider.js +159 -175
- package/Source/Scene/ResourceLoader.js +0 -1
- package/Source/Scene/ResourceLoaderState.js +7 -1
- package/Source/Scene/Scene.js +26 -0
- package/Source/Scene/SceneMode.js +4 -1
- package/Source/Scene/ShadowMode.js +3 -1
- package/Source/Scene/SkyBox.js +1 -1
- package/Source/Scene/SplitDirection.js +6 -1
- package/Source/Scene/StencilFunction.js +6 -1
- package/Source/Scene/StencilOperation.js +6 -1
- package/Source/Scene/TerrainState.js +7 -1
- package/Source/Scene/TileState.js +7 -1
- package/Source/Scene/Tileset3DTileContent.js +113 -146
- package/Source/Scene/Tonemapper.js +5 -1
- package/Source/Scene/UrlTemplate3DTilesDataProvider.js +499 -0
- package/Source/Scene/Vector3DTileContent.js +205 -234
- package/Source/Scene/VectorGltf3DTileContent.js +131 -61
- package/Source/Scene/VertexAttributeSemantic.js +3 -1
- package/Source/Scene/VerticalOrigin.js +6 -1
- package/Source/Scene/VoxelBoxShape.js +12 -6
- package/Source/Scene/VoxelContent.js +2 -0
- package/Source/Scene/VoxelCylinderShape.js +39 -38
- package/Source/Scene/VoxelEllipsoidShape.js +46 -96
- package/Source/Scene/VoxelMetadataOrder.js +6 -1
- package/Source/Scene/VoxelPrimitive.js +159 -175
- package/Source/Scene/VoxelProvider.js +64 -90
- package/Source/Scene/VoxelShapeType.js +3 -1
- package/Source/Scene/buildVectorGltfFromMVT.js +1059 -0
- package/Source/Scene/buildVoxelCustomShader.js +199 -0
- package/Source/Scene/decodeMVT.js +634 -0
- package/Source/Scene/renderBufferPointCollection.js +124 -127
- package/Source/Scene/renderBufferPolygonCollection.js +122 -122
- package/Source/Scene/renderBufferPolylineCollection.js +386 -238
- package/Source/Shaders/BufferPointMaterialFS.glsl +1 -0
- package/Source/Shaders/BufferPointMaterialFS.js +1 -0
- package/Source/Shaders/BufferPointMaterialVS.glsl +19 -9
- package/Source/Shaders/BufferPointMaterialVS.js +20 -10
- package/Source/Shaders/BufferPolygonMaterialVS.glsl +13 -4
- package/Source/Shaders/BufferPolygonMaterialVS.js +14 -5
- package/Source/Shaders/BufferPolylineMaterialVS.glsl +16 -2
- package/Source/Shaders/BufferPolylineMaterialVS.js +17 -3
- package/Source/Shaders/Builtin/Constants/passCesium3DTileEdgesDirect.glsl +9 -0
- package/Source/Shaders/Builtin/Constants/passCesium3DTileEdgesDirect.js +11 -0
- package/Source/Shaders/Builtin/Constants/passOverlay.glsl +1 -1
- package/Source/Shaders/Builtin/Constants/passOverlay.js +1 -1
- package/Source/Shaders/Builtin/CzmBuiltins.js +4 -0
- package/Source/Shaders/Builtin/Functions/computeTextureTransform.glsl +24 -0
- package/Source/Shaders/Builtin/Functions/computeTextureTransform.js +25 -0
- package/Source/Shaders/Model/ConstantLodStageFS.glsl +60 -0
- package/Source/Shaders/Model/ConstantLodStageFS.js +62 -0
- package/Source/Shaders/Model/ConstantLodStageVS.glsl +12 -0
- package/Source/Shaders/Model/ConstantLodStageVS.js +13 -0
- package/Source/Shaders/Model/EdgeVisibilityStageVS.glsl +0 -1
- package/Source/Shaders/Model/EdgeVisibilityStageVS.js +0 -1
- package/Source/Shaders/Model/MaterialStageFS.glsl +46 -20
- package/Source/Shaders/Model/MaterialStageFS.js +46 -20
- package/Source/Shaders/Voxels/convertLocalToBoxUv.glsl +0 -1
- package/Source/Shaders/Voxels/convertLocalToBoxUv.js +0 -1
- package/Source/Shaders/Voxels/convertLocalToCylinderUv.glsl +7 -9
- package/Source/Shaders/Voxels/convertLocalToCylinderUv.js +7 -9
- package/Source/Shaders/Voxels/convertLocalToEllipsoidUv.glsl +7 -17
- package/Source/Shaders/Voxels/convertLocalToEllipsoidUv.js +7 -17
- package/Source/Widget/CesiumWidget.js +11 -4
- package/index.d.ts +595 -343
- package/index.js +392 -378
- package/package.json +3 -3
- package/Build/Workers/chunk-DVB56LG7.js +0 -114
- package/Build/Workers/chunk-HKUES6UG.js +0 -2357
- package/Build/Workers/chunk-HRHRYFHS.js +0 -940
- package/Build/Workers/chunk-KLPGTXS3.js +0 -642
- package/Build/Workers/chunk-ZBZRTRJB.js +0 -1829
|
@@ -195,603 +195,627 @@ const iso8601ErrorMessage = "Invalid ISO 8601 date.";
|
|
|
195
195
|
* part of the date in separate components. In order to be safe for arithmetic and represent
|
|
196
196
|
* leap seconds, the date is always stored in the International Atomic Time standard
|
|
197
197
|
* {@link TimeStandard.TAI}.
|
|
198
|
-
* @alias JulianDate
|
|
199
|
-
* @constructor
|
|
200
|
-
*
|
|
201
|
-
* @param {number} [julianDayNumber=0.0] The Julian Day Number representing the number of whole days. Fractional days will also be handled correctly.
|
|
202
|
-
* @param {number} [secondsOfDay=0.0] The number of seconds into the current Julian Day Number. Fractional seconds, negative seconds and seconds greater than a day will be handled correctly.
|
|
203
|
-
* @param {TimeStandard} [timeStandard=TimeStandard.UTC] The time standard in which the first two parameters are defined.
|
|
204
198
|
*/
|
|
205
|
-
|
|
199
|
+
class JulianDate {
|
|
206
200
|
/**
|
|
207
|
-
*
|
|
208
|
-
* @
|
|
201
|
+
* @param {number} [julianDayNumber=0.0] The Julian Day Number representing the number of whole days. Fractional days will also be handled correctly.
|
|
202
|
+
* @param {number} [secondsOfDay=0.0] The number of seconds into the current Julian Day Number. Fractional seconds, negative seconds and seconds greater than a day will be handled correctly.
|
|
203
|
+
* @param {TimeStandard} [timeStandard=TimeStandard.UTC] The time standard in which the first two parameters are defined.
|
|
209
204
|
*/
|
|
210
|
-
|
|
205
|
+
constructor(julianDayNumber, secondsOfDay, timeStandard) {
|
|
206
|
+
/**
|
|
207
|
+
* Gets or sets the number of whole days.
|
|
208
|
+
* @type {number}
|
|
209
|
+
*/
|
|
210
|
+
this.dayNumber = undefined;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Gets or sets the number of seconds into the current day.
|
|
214
|
+
* @type {number}
|
|
215
|
+
*/
|
|
216
|
+
this.secondsOfDay = undefined;
|
|
217
|
+
|
|
218
|
+
julianDayNumber = julianDayNumber ?? 0.0;
|
|
219
|
+
secondsOfDay = secondsOfDay ?? 0.0;
|
|
220
|
+
timeStandard = timeStandard ?? TimeStandard.UTC;
|
|
221
|
+
|
|
222
|
+
//If julianDayNumber is fractional, make it an integer and add the number of seconds the fraction represented.
|
|
223
|
+
const wholeDays = julianDayNumber | 0;
|
|
224
|
+
secondsOfDay =
|
|
225
|
+
secondsOfDay +
|
|
226
|
+
(julianDayNumber - wholeDays) * TimeConstants.SECONDS_PER_DAY;
|
|
227
|
+
|
|
228
|
+
setComponents(wholeDays, secondsOfDay, this);
|
|
229
|
+
|
|
230
|
+
if (timeStandard === TimeStandard.UTC) {
|
|
231
|
+
convertUtcToTai(this);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
211
234
|
|
|
212
235
|
/**
|
|
213
|
-
*
|
|
214
|
-
*
|
|
236
|
+
* Creates a new instance from a GregorianDate.
|
|
237
|
+
*
|
|
238
|
+
* @param {GregorianDate} date A GregorianDate.
|
|
239
|
+
* @param {JulianDate} [result] An existing instance to use for the result.
|
|
240
|
+
* @returns {JulianDate} The modified result parameter or a new instance if none was provided.
|
|
241
|
+
*
|
|
242
|
+
* @exception {DeveloperError} date must be a valid GregorianDate.
|
|
215
243
|
*/
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
//If julianDayNumber is fractional, make it an integer and add the number of seconds the fraction represented.
|
|
223
|
-
const wholeDays = julianDayNumber | 0;
|
|
224
|
-
secondsOfDay =
|
|
225
|
-
secondsOfDay +
|
|
226
|
-
(julianDayNumber - wholeDays) * TimeConstants.SECONDS_PER_DAY;
|
|
227
|
-
|
|
228
|
-
setComponents(wholeDays, secondsOfDay, this);
|
|
229
|
-
|
|
230
|
-
if (timeStandard === TimeStandard.UTC) {
|
|
231
|
-
convertUtcToTai(this);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
244
|
+
static fromGregorianDate(date, result) {
|
|
245
|
+
//>>includeStart('debug', pragmas.debug);
|
|
246
|
+
if (!(date instanceof GregorianDate)) {
|
|
247
|
+
throw new DeveloperError("date must be a valid GregorianDate.");
|
|
248
|
+
}
|
|
249
|
+
//>>includeEnd('debug');
|
|
234
250
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
const components = computeJulianDateComponents(
|
|
252
|
-
date.year,
|
|
253
|
-
date.month,
|
|
254
|
-
date.day,
|
|
255
|
-
date.hour,
|
|
256
|
-
date.minute,
|
|
257
|
-
date.second,
|
|
258
|
-
date.millisecond,
|
|
259
|
-
);
|
|
260
|
-
if (!defined(result)) {
|
|
261
|
-
return new JulianDate(components[0], components[1], TimeStandard.UTC);
|
|
251
|
+
const components = computeJulianDateComponents(
|
|
252
|
+
date.year,
|
|
253
|
+
date.month,
|
|
254
|
+
date.day,
|
|
255
|
+
date.hour,
|
|
256
|
+
date.minute,
|
|
257
|
+
date.second,
|
|
258
|
+
date.millisecond,
|
|
259
|
+
);
|
|
260
|
+
if (!defined(result)) {
|
|
261
|
+
return new JulianDate(components[0], components[1], TimeStandard.UTC);
|
|
262
|
+
}
|
|
263
|
+
setComponents(components[0], components[1], result);
|
|
264
|
+
convertUtcToTai(result);
|
|
265
|
+
return result;
|
|
262
266
|
}
|
|
263
|
-
setComponents(components[0], components[1], result);
|
|
264
|
-
convertUtcToTai(result);
|
|
265
|
-
return result;
|
|
266
|
-
};
|
|
267
267
|
|
|
268
|
-
/**
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
const components = computeJulianDateComponents(
|
|
285
|
-
date.getUTCFullYear(),
|
|
286
|
-
date.getUTCMonth() + 1,
|
|
287
|
-
date.getUTCDate(),
|
|
288
|
-
date.getUTCHours(),
|
|
289
|
-
date.getUTCMinutes(),
|
|
290
|
-
date.getUTCSeconds(),
|
|
291
|
-
date.getUTCMilliseconds(),
|
|
292
|
-
);
|
|
293
|
-
if (!defined(result)) {
|
|
294
|
-
return new JulianDate(components[0], components[1], TimeStandard.UTC);
|
|
295
|
-
}
|
|
296
|
-
setComponents(components[0], components[1], result);
|
|
297
|
-
convertUtcToTai(result);
|
|
298
|
-
return result;
|
|
299
|
-
};
|
|
268
|
+
/**
|
|
269
|
+
* Creates a new instance from a JavaScript Date.
|
|
270
|
+
*
|
|
271
|
+
* @param {Date} date A JavaScript Date.
|
|
272
|
+
* @param {JulianDate} [result] An existing instance to use for the result.
|
|
273
|
+
* @returns {JulianDate} The modified result parameter or a new instance if none was provided.
|
|
274
|
+
*
|
|
275
|
+
* @exception {DeveloperError} date must be a valid JavaScript Date.
|
|
276
|
+
*/
|
|
277
|
+
static fromDate(date, result) {
|
|
278
|
+
//>>includeStart('debug', pragmas.debug);
|
|
279
|
+
if (!(date instanceof Date) || isNaN(date.getTime())) {
|
|
280
|
+
throw new DeveloperError("date must be a valid JavaScript Date.");
|
|
281
|
+
}
|
|
282
|
+
//>>includeEnd('debug');
|
|
300
283
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
}
|
|
317
|
-
//>>includeEnd('debug');
|
|
318
|
-
|
|
319
|
-
//Comma and decimal point both indicate a fractional number according to ISO 8601,
|
|
320
|
-
//start out by blanket replacing , with . which is the only valid such symbol in JS.
|
|
321
|
-
iso8601String = iso8601String.replace(",", ".");
|
|
322
|
-
|
|
323
|
-
//Split the string into its date and time components, denoted by a mandatory T
|
|
324
|
-
let tokens = iso8601String.split("T");
|
|
325
|
-
let year;
|
|
326
|
-
let month = 1;
|
|
327
|
-
let day = 1;
|
|
328
|
-
let hour = 0;
|
|
329
|
-
let minute = 0;
|
|
330
|
-
let second = 0;
|
|
331
|
-
let millisecond = 0;
|
|
332
|
-
|
|
333
|
-
//Lacking a time is okay, but a missing date is illegal.
|
|
334
|
-
const date = tokens[0];
|
|
335
|
-
const time = tokens[1];
|
|
336
|
-
let tmp;
|
|
337
|
-
let inLeapYear;
|
|
338
|
-
//>>includeStart('debug', pragmas.debug);
|
|
339
|
-
if (!defined(date)) {
|
|
340
|
-
throw new DeveloperError(iso8601ErrorMessage);
|
|
284
|
+
const components = computeJulianDateComponents(
|
|
285
|
+
date.getUTCFullYear(),
|
|
286
|
+
date.getUTCMonth() + 1,
|
|
287
|
+
date.getUTCDate(),
|
|
288
|
+
date.getUTCHours(),
|
|
289
|
+
date.getUTCMinutes(),
|
|
290
|
+
date.getUTCSeconds(),
|
|
291
|
+
date.getUTCMilliseconds(),
|
|
292
|
+
);
|
|
293
|
+
if (!defined(result)) {
|
|
294
|
+
return new JulianDate(components[0], components[1], TimeStandard.UTC);
|
|
295
|
+
}
|
|
296
|
+
setComponents(components[0], components[1], result);
|
|
297
|
+
convertUtcToTai(result);
|
|
298
|
+
return result;
|
|
341
299
|
}
|
|
342
300
|
|
|
343
|
-
|
|
344
|
-
|
|
301
|
+
/**
|
|
302
|
+
* Creates a new instance from a from an {@link http://en.wikipedia.org/wiki/ISO_8601|ISO 8601} date.
|
|
303
|
+
* This method is superior to <code>Date.parse</code> because it will handle all valid formats defined by the ISO 8601
|
|
304
|
+
* specification, including leap seconds and sub-millisecond times, which discarded by most JavaScript implementations.
|
|
305
|
+
*
|
|
306
|
+
* @param {string} iso8601String An ISO 8601 date.
|
|
307
|
+
* @param {JulianDate} [result] An existing instance to use for the result.
|
|
308
|
+
* @returns {JulianDate} The modified result parameter or a new instance if none was provided.
|
|
309
|
+
*
|
|
310
|
+
* @exception {DeveloperError} Invalid ISO 8601 date.
|
|
311
|
+
*/
|
|
312
|
+
static fromIso8601(iso8601String, result) {
|
|
313
|
+
//>>includeStart('debug', pragmas.debug);
|
|
314
|
+
if (typeof iso8601String !== "string") {
|
|
315
|
+
throw new DeveloperError(iso8601ErrorMessage);
|
|
316
|
+
}
|
|
317
|
+
//>>includeEnd('debug');
|
|
345
318
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
319
|
+
//Comma and decimal point both indicate a fractional number according to ISO 8601,
|
|
320
|
+
//start out by blanket replacing , with . which is the only valid such symbol in JS.
|
|
321
|
+
iso8601String = iso8601String.replace(",", ".");
|
|
322
|
+
|
|
323
|
+
//Split the string into its date and time components, denoted by a mandatory T
|
|
324
|
+
let tokens = iso8601String.split("T");
|
|
325
|
+
let year;
|
|
326
|
+
let month = 1;
|
|
327
|
+
let day = 1;
|
|
328
|
+
let hour = 0;
|
|
329
|
+
let minute = 0;
|
|
330
|
+
let second = 0;
|
|
331
|
+
let millisecond = 0;
|
|
332
|
+
|
|
333
|
+
//Lacking a time is okay, but a missing date is illegal.
|
|
334
|
+
const date = tokens[0];
|
|
335
|
+
const time = tokens[1];
|
|
336
|
+
let tmp;
|
|
337
|
+
let inLeapYear;
|
|
349
338
|
//>>includeStart('debug', pragmas.debug);
|
|
350
|
-
|
|
351
|
-
if (dashCount > 0 && dashCount !== 2) {
|
|
339
|
+
if (!defined(date)) {
|
|
352
340
|
throw new DeveloperError(iso8601ErrorMessage);
|
|
353
341
|
}
|
|
342
|
+
|
|
343
|
+
let dashCount;
|
|
354
344
|
//>>includeEnd('debug');
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
} else {
|
|
359
|
-
tokens = date.match(matchCalendarMonth);
|
|
345
|
+
|
|
346
|
+
//First match the date against possible regular expressions.
|
|
347
|
+
tokens = date.match(matchCalendarDate);
|
|
360
348
|
if (tokens !== null) {
|
|
349
|
+
//>>includeStart('debug', pragmas.debug);
|
|
350
|
+
dashCount = date.split("-").length - 1;
|
|
351
|
+
if (dashCount > 0 && dashCount !== 2) {
|
|
352
|
+
throw new DeveloperError(iso8601ErrorMessage);
|
|
353
|
+
}
|
|
354
|
+
//>>includeEnd('debug');
|
|
361
355
|
year = +tokens[1];
|
|
362
356
|
month = +tokens[2];
|
|
357
|
+
day = +tokens[3];
|
|
363
358
|
} else {
|
|
364
|
-
tokens = date.match(
|
|
359
|
+
tokens = date.match(matchCalendarMonth);
|
|
365
360
|
if (tokens !== null) {
|
|
366
361
|
year = +tokens[1];
|
|
362
|
+
month = +tokens[2];
|
|
367
363
|
} else {
|
|
368
|
-
|
|
369
|
-
let dayOfYear;
|
|
370
|
-
tokens = date.match(matchOrdinalDate);
|
|
364
|
+
tokens = date.match(matchCalendarYear);
|
|
371
365
|
if (tokens !== null) {
|
|
372
366
|
year = +tokens[1];
|
|
373
|
-
dayOfYear = +tokens[2];
|
|
374
|
-
inLeapYear = isLeapYear(year);
|
|
375
|
-
|
|
376
|
-
//This validation is only applicable for this format.
|
|
377
|
-
//>>includeStart('debug', pragmas.debug);
|
|
378
|
-
if (
|
|
379
|
-
dayOfYear < 1 ||
|
|
380
|
-
(inLeapYear && dayOfYear > 366) ||
|
|
381
|
-
(!inLeapYear && dayOfYear > 365)
|
|
382
|
-
) {
|
|
383
|
-
throw new DeveloperError(iso8601ErrorMessage);
|
|
384
|
-
}
|
|
385
|
-
//>>includeEnd('debug');
|
|
386
367
|
} else {
|
|
387
|
-
|
|
368
|
+
//Not a year/month/day so it must be an ordinal date.
|
|
369
|
+
let dayOfYear;
|
|
370
|
+
tokens = date.match(matchOrdinalDate);
|
|
388
371
|
if (tokens !== null) {
|
|
389
|
-
//ISO week date to ordinal date from
|
|
390
|
-
//http://en.wikipedia.org/w/index.php?title=ISO_week_date&oldid=474176775
|
|
391
372
|
year = +tokens[1];
|
|
392
|
-
|
|
393
|
-
|
|
373
|
+
dayOfYear = +tokens[2];
|
|
374
|
+
inLeapYear = isLeapYear(year);
|
|
394
375
|
|
|
376
|
+
//This validation is only applicable for this format.
|
|
395
377
|
//>>includeStart('debug', pragmas.debug);
|
|
396
|
-
dashCount = date.split("-").length - 1;
|
|
397
378
|
if (
|
|
398
|
-
|
|
399
|
-
(
|
|
400
|
-
|
|
379
|
+
dayOfYear < 1 ||
|
|
380
|
+
(inLeapYear && dayOfYear > 366) ||
|
|
381
|
+
(!inLeapYear && dayOfYear > 365)
|
|
401
382
|
) {
|
|
402
383
|
throw new DeveloperError(iso8601ErrorMessage);
|
|
403
384
|
}
|
|
404
385
|
//>>includeEnd('debug');
|
|
405
|
-
|
|
406
|
-
const january4 = new Date(Date.UTC(year, 0, 4));
|
|
407
|
-
dayOfYear = weekNumber * 7 + dayOfWeek - january4.getUTCDay() - 3;
|
|
408
386
|
} else {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
387
|
+
tokens = date.match(matchWeekDate);
|
|
388
|
+
if (tokens !== null) {
|
|
389
|
+
//ISO week date to ordinal date from
|
|
390
|
+
//http://en.wikipedia.org/w/index.php?title=ISO_week_date&oldid=474176775
|
|
391
|
+
year = +tokens[1];
|
|
392
|
+
const weekNumber = +tokens[2];
|
|
393
|
+
const dayOfWeek = +tokens[3] || 0;
|
|
394
|
+
|
|
395
|
+
//>>includeStart('debug', pragmas.debug);
|
|
396
|
+
dashCount = date.split("-").length - 1;
|
|
397
|
+
if (
|
|
398
|
+
dashCount > 0 &&
|
|
399
|
+
((!defined(tokens[3]) && dashCount !== 1) ||
|
|
400
|
+
(defined(tokens[3]) && dashCount !== 2))
|
|
401
|
+
) {
|
|
402
|
+
throw new DeveloperError(iso8601ErrorMessage);
|
|
403
|
+
}
|
|
404
|
+
//>>includeEnd('debug');
|
|
405
|
+
|
|
406
|
+
const january4 = new Date(Date.UTC(year, 0, 4));
|
|
407
|
+
dayOfYear = weekNumber * 7 + dayOfWeek - january4.getUTCDay() - 3;
|
|
408
|
+
} else {
|
|
409
|
+
//None of our regular expressions succeeded in parsing the date properly.
|
|
410
|
+
//>>includeStart('debug', pragmas.debug);
|
|
411
|
+
throw new DeveloperError(iso8601ErrorMessage);
|
|
412
|
+
//>>includeEnd('debug');
|
|
413
|
+
}
|
|
413
414
|
}
|
|
415
|
+
//Split an ordinal date into month/day.
|
|
416
|
+
tmp = new Date(Date.UTC(year, 0, 1));
|
|
417
|
+
tmp.setUTCDate(dayOfYear);
|
|
418
|
+
month = tmp.getUTCMonth() + 1;
|
|
419
|
+
day = tmp.getUTCDate();
|
|
414
420
|
}
|
|
415
|
-
//Split an ordinal date into month/day.
|
|
416
|
-
tmp = new Date(Date.UTC(year, 0, 1));
|
|
417
|
-
tmp.setUTCDate(dayOfYear);
|
|
418
|
-
month = tmp.getUTCMonth() + 1;
|
|
419
|
-
day = tmp.getUTCDate();
|
|
420
421
|
}
|
|
421
422
|
}
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
//Now that we have all of the date components, validate them to make sure nothing is out of range.
|
|
425
|
-
inLeapYear = isLeapYear(year);
|
|
426
|
-
//>>includeStart('debug', pragmas.debug);
|
|
427
|
-
if (
|
|
428
|
-
month < 1 ||
|
|
429
|
-
month > 12 ||
|
|
430
|
-
day < 1 ||
|
|
431
|
-
((month !== 2 || !inLeapYear) && day > daysInMonth[month - 1]) ||
|
|
432
|
-
(inLeapYear && month === 2 && day > daysInLeapFebruary)
|
|
433
|
-
) {
|
|
434
|
-
throw new DeveloperError(iso8601ErrorMessage);
|
|
435
|
-
}
|
|
436
|
-
//>>includeEnd('debug');
|
|
437
423
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
424
|
+
//Now that we have all of the date components, validate them to make sure nothing is out of range.
|
|
425
|
+
inLeapYear = isLeapYear(year);
|
|
426
|
+
//>>includeStart('debug', pragmas.debug);
|
|
427
|
+
if (
|
|
428
|
+
month < 1 ||
|
|
429
|
+
month > 12 ||
|
|
430
|
+
day < 1 ||
|
|
431
|
+
((month !== 2 || !inLeapYear) && day > daysInMonth[month - 1]) ||
|
|
432
|
+
(inLeapYear && month === 2 && day > daysInLeapFebruary)
|
|
433
|
+
) {
|
|
434
|
+
throw new DeveloperError(iso8601ErrorMessage);
|
|
435
|
+
}
|
|
436
|
+
//>>includeEnd('debug');
|
|
450
437
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
} else {
|
|
457
|
-
tokens = time.match(matchHoursMinutes);
|
|
438
|
+
//Now move onto the time string, which is much simpler.
|
|
439
|
+
//If no time is specified, it is considered the beginning of the day, UTC to match Javascript's implementation.
|
|
440
|
+
let offsetIndex;
|
|
441
|
+
if (defined(time)) {
|
|
442
|
+
tokens = time.match(matchHoursMinutesSeconds);
|
|
458
443
|
if (tokens !== null) {
|
|
459
444
|
//>>includeStart('debug', pragmas.debug);
|
|
460
445
|
dashCount = time.split(":").length - 1;
|
|
461
|
-
if (dashCount > 2) {
|
|
446
|
+
if (dashCount > 0 && dashCount !== 2 && dashCount !== 3) {
|
|
462
447
|
throw new DeveloperError(iso8601ErrorMessage);
|
|
463
448
|
}
|
|
464
449
|
//>>includeEnd('debug');
|
|
465
450
|
|
|
466
451
|
hour = +tokens[1];
|
|
467
452
|
minute = +tokens[2];
|
|
468
|
-
second = +
|
|
469
|
-
|
|
453
|
+
second = +tokens[3];
|
|
454
|
+
millisecond = +(tokens[4] || 0) * 1000.0;
|
|
455
|
+
offsetIndex = 5;
|
|
470
456
|
} else {
|
|
471
|
-
tokens = time.match(
|
|
457
|
+
tokens = time.match(matchHoursMinutes);
|
|
472
458
|
if (tokens !== null) {
|
|
473
|
-
hour = +tokens[1];
|
|
474
|
-
minute = +(tokens[2] || 0) * 60.0;
|
|
475
|
-
offsetIndex = 3;
|
|
476
|
-
} else {
|
|
477
459
|
//>>includeStart('debug', pragmas.debug);
|
|
478
|
-
|
|
460
|
+
dashCount = time.split(":").length - 1;
|
|
461
|
+
if (dashCount > 2) {
|
|
462
|
+
throw new DeveloperError(iso8601ErrorMessage);
|
|
463
|
+
}
|
|
479
464
|
//>>includeEnd('debug');
|
|
465
|
+
|
|
466
|
+
hour = +tokens[1];
|
|
467
|
+
minute = +tokens[2];
|
|
468
|
+
second = +(tokens[3] || 0) * 60.0;
|
|
469
|
+
offsetIndex = 4;
|
|
470
|
+
} else {
|
|
471
|
+
tokens = time.match(matchHours);
|
|
472
|
+
if (tokens !== null) {
|
|
473
|
+
hour = +tokens[1];
|
|
474
|
+
minute = +(tokens[2] || 0) * 60.0;
|
|
475
|
+
offsetIndex = 3;
|
|
476
|
+
} else {
|
|
477
|
+
//>>includeStart('debug', pragmas.debug);
|
|
478
|
+
throw new DeveloperError(iso8601ErrorMessage);
|
|
479
|
+
//>>includeEnd('debug');
|
|
480
|
+
}
|
|
480
481
|
}
|
|
481
482
|
}
|
|
482
|
-
}
|
|
483
483
|
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
484
|
+
//Validate that all values are in proper range. Minutes and hours have special cases at 60 and 24.
|
|
485
|
+
//>>includeStart('debug', pragmas.debug);
|
|
486
|
+
if (
|
|
487
|
+
minute >= 60 ||
|
|
488
|
+
second >= 61 ||
|
|
489
|
+
hour > 24 ||
|
|
490
|
+
(hour === 24 && (minute > 0 || second > 0 || millisecond > 0))
|
|
491
|
+
) {
|
|
492
|
+
throw new DeveloperError(iso8601ErrorMessage);
|
|
493
|
+
}
|
|
494
|
+
//>>includeEnd('debug');
|
|
495
|
+
|
|
496
|
+
//Check the UTC offset value, if no value exists, use local time
|
|
497
|
+
//a Z indicates UTC, + or - are offsets.
|
|
498
|
+
const offset = tokens[offsetIndex];
|
|
499
|
+
const offsetHours = +tokens[offsetIndex + 1];
|
|
500
|
+
const offsetMinutes = +(tokens[offsetIndex + 2] || 0);
|
|
501
|
+
switch (offset) {
|
|
502
|
+
case "+":
|
|
503
|
+
hour = hour - offsetHours;
|
|
504
|
+
minute = minute - offsetMinutes;
|
|
505
|
+
break;
|
|
506
|
+
case "-":
|
|
507
|
+
hour = hour + offsetHours;
|
|
508
|
+
minute = minute + offsetMinutes;
|
|
509
|
+
break;
|
|
510
|
+
case "Z":
|
|
511
|
+
break;
|
|
512
|
+
default:
|
|
513
|
+
minute =
|
|
514
|
+
minute +
|
|
515
|
+
new Date(
|
|
516
|
+
Date.UTC(year, month - 1, day, hour, minute),
|
|
517
|
+
).getTimezoneOffset();
|
|
518
|
+
break;
|
|
519
|
+
}
|
|
493
520
|
}
|
|
494
|
-
//>>includeEnd('debug');
|
|
495
521
|
|
|
496
|
-
//
|
|
497
|
-
//
|
|
498
|
-
|
|
499
|
-
const
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
case "+":
|
|
503
|
-
hour = hour - offsetHours;
|
|
504
|
-
minute = minute - offsetMinutes;
|
|
505
|
-
break;
|
|
506
|
-
case "-":
|
|
507
|
-
hour = hour + offsetHours;
|
|
508
|
-
minute = minute + offsetMinutes;
|
|
509
|
-
break;
|
|
510
|
-
case "Z":
|
|
511
|
-
break;
|
|
512
|
-
default:
|
|
513
|
-
minute =
|
|
514
|
-
minute +
|
|
515
|
-
new Date(
|
|
516
|
-
Date.UTC(year, month - 1, day, hour, minute),
|
|
517
|
-
).getTimezoneOffset();
|
|
518
|
-
break;
|
|
522
|
+
//ISO8601 denotes a leap second by any time having a seconds component of 60 seconds.
|
|
523
|
+
//If that's the case, we need to temporarily subtract a second in order to build a UTC date.
|
|
524
|
+
//Then we add it back in after converting to TAI.
|
|
525
|
+
const isLeapSecond = second === 60;
|
|
526
|
+
if (isLeapSecond) {
|
|
527
|
+
second--;
|
|
519
528
|
}
|
|
520
|
-
}
|
|
521
529
|
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
//Then we add it back in after converting to TAI.
|
|
525
|
-
const isLeapSecond = second === 60;
|
|
526
|
-
if (isLeapSecond) {
|
|
527
|
-
second--;
|
|
528
|
-
}
|
|
530
|
+
//Even if we successfully parsed the string into its components, after applying UTC offset or
|
|
531
|
+
//special cases like 24:00:00 denoting midnight, we need to normalize the data appropriately.
|
|
529
532
|
|
|
530
|
-
|
|
531
|
-
|
|
533
|
+
//milliseconds can never be greater than 1000, and seconds can't be above 60, so we start with minutes
|
|
534
|
+
while (minute >= 60) {
|
|
535
|
+
minute -= 60;
|
|
536
|
+
hour++;
|
|
537
|
+
}
|
|
532
538
|
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
}
|
|
539
|
+
while (hour >= 24) {
|
|
540
|
+
hour -= 24;
|
|
541
|
+
day++;
|
|
542
|
+
}
|
|
538
543
|
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
day
|
|
542
|
-
|
|
544
|
+
tmp =
|
|
545
|
+
inLeapYear && month === 2 ? daysInLeapFebruary : daysInMonth[month - 1];
|
|
546
|
+
while (day > tmp) {
|
|
547
|
+
day -= tmp;
|
|
548
|
+
month++;
|
|
543
549
|
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
550
|
+
if (month > 12) {
|
|
551
|
+
month -= 12;
|
|
552
|
+
year++;
|
|
553
|
+
}
|
|
548
554
|
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
year++;
|
|
555
|
+
tmp =
|
|
556
|
+
inLeapYear && month === 2 ? daysInLeapFebruary : daysInMonth[month - 1];
|
|
552
557
|
}
|
|
553
558
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
559
|
+
//If UTC offset is at the beginning/end of the day, minutes can be negative.
|
|
560
|
+
while (minute < 0) {
|
|
561
|
+
minute += 60;
|
|
562
|
+
hour--;
|
|
563
|
+
}
|
|
557
564
|
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
}
|
|
565
|
+
while (hour < 0) {
|
|
566
|
+
hour += 24;
|
|
567
|
+
day--;
|
|
568
|
+
}
|
|
563
569
|
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
570
|
+
while (day < 1) {
|
|
571
|
+
month--;
|
|
572
|
+
if (month < 1) {
|
|
573
|
+
month += 12;
|
|
574
|
+
year--;
|
|
575
|
+
}
|
|
568
576
|
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
month += 12;
|
|
573
|
-
year--;
|
|
577
|
+
tmp =
|
|
578
|
+
inLeapYear && month === 2 ? daysInLeapFebruary : daysInMonth[month - 1];
|
|
579
|
+
day += tmp;
|
|
574
580
|
}
|
|
575
581
|
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
582
|
+
//Now create the JulianDate components from the Gregorian date and actually create our instance.
|
|
583
|
+
const components = computeJulianDateComponents(
|
|
584
|
+
year,
|
|
585
|
+
month,
|
|
586
|
+
day,
|
|
587
|
+
hour,
|
|
588
|
+
minute,
|
|
589
|
+
second,
|
|
590
|
+
millisecond,
|
|
591
|
+
);
|
|
580
592
|
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
minute,
|
|
588
|
-
second,
|
|
589
|
-
millisecond,
|
|
590
|
-
);
|
|
593
|
+
if (!defined(result)) {
|
|
594
|
+
result = new JulianDate(components[0], components[1], TimeStandard.UTC);
|
|
595
|
+
} else {
|
|
596
|
+
setComponents(components[0], components[1], result);
|
|
597
|
+
convertUtcToTai(result);
|
|
598
|
+
}
|
|
591
599
|
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
600
|
+
//If we were on a leap second, add it back.
|
|
601
|
+
if (isLeapSecond) {
|
|
602
|
+
JulianDate.addSeconds(result, 1, result);
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
return result;
|
|
597
606
|
}
|
|
598
607
|
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
608
|
+
/**
|
|
609
|
+
* Creates a new instance that represents the current system time.
|
|
610
|
+
* This is equivalent to calling <code>JulianDate.fromDate(new Date());</code>.
|
|
611
|
+
*
|
|
612
|
+
* @param {JulianDate} [result] An existing instance to use for the result.
|
|
613
|
+
* @returns {JulianDate} The modified result parameter or a new instance if none was provided.
|
|
614
|
+
*/
|
|
615
|
+
static now(result) {
|
|
616
|
+
return JulianDate.fromDate(new Date(), result);
|
|
602
617
|
}
|
|
603
618
|
|
|
604
|
-
|
|
605
|
-
}
|
|
619
|
+
/**
|
|
620
|
+
* Creates a {@link GregorianDate} from the provided instance.
|
|
621
|
+
*
|
|
622
|
+
* @param {JulianDate} julianDate The date to be converted.
|
|
623
|
+
* @param {GregorianDate} [result] An existing instance to use for the result.
|
|
624
|
+
* @returns {GregorianDate} The modified result parameter or a new instance if none was provided.
|
|
625
|
+
*/
|
|
626
|
+
static toGregorianDate(julianDate, result) {
|
|
627
|
+
//>>includeStart('debug', pragmas.debug);
|
|
628
|
+
if (!defined(julianDate)) {
|
|
629
|
+
throw new DeveloperError("julianDate is required.");
|
|
630
|
+
}
|
|
631
|
+
//>>includeEnd('debug');
|
|
606
632
|
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
}
|
|
633
|
+
let isLeapSecond = false;
|
|
634
|
+
let thisUtc = convertTaiToUtc(julianDate, toGregorianDateScratch);
|
|
635
|
+
if (!defined(thisUtc)) {
|
|
636
|
+
//Conversion to UTC will fail if we are during a leap second.
|
|
637
|
+
//If that's the case, subtract a second and convert again.
|
|
638
|
+
//JavaScript doesn't support leap seconds, so this results in second 59 being repeated twice.
|
|
639
|
+
JulianDate.addSeconds(julianDate, -1, toGregorianDateScratch);
|
|
640
|
+
thisUtc = convertTaiToUtc(toGregorianDateScratch, toGregorianDateScratch);
|
|
641
|
+
isLeapSecond = true;
|
|
642
|
+
}
|
|
617
643
|
|
|
618
|
-
|
|
644
|
+
let julianDayNumber = thisUtc.dayNumber;
|
|
645
|
+
const secondsOfDay = thisUtc.secondsOfDay;
|
|
619
646
|
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
* @param {JulianDate} julianDate The date to be converted.
|
|
624
|
-
* @param {GregorianDate} [result] An existing instance to use for the result.
|
|
625
|
-
* @returns {GregorianDate} The modified result parameter or a new instance if none was provided.
|
|
626
|
-
*/
|
|
627
|
-
JulianDate.toGregorianDate = function (julianDate, result) {
|
|
628
|
-
//>>includeStart('debug', pragmas.debug);
|
|
629
|
-
if (!defined(julianDate)) {
|
|
630
|
-
throw new DeveloperError("julianDate is required.");
|
|
631
|
-
}
|
|
632
|
-
//>>includeEnd('debug');
|
|
633
|
-
|
|
634
|
-
let isLeapSecond = false;
|
|
635
|
-
let thisUtc = convertTaiToUtc(julianDate, toGregorianDateScratch);
|
|
636
|
-
if (!defined(thisUtc)) {
|
|
637
|
-
//Conversion to UTC will fail if we are during a leap second.
|
|
638
|
-
//If that's the case, subtract a second and convert again.
|
|
639
|
-
//JavaScript doesn't support leap seconds, so this results in second 59 being repeated twice.
|
|
640
|
-
JulianDate.addSeconds(julianDate, -1, toGregorianDateScratch);
|
|
641
|
-
thisUtc = convertTaiToUtc(toGregorianDateScratch, toGregorianDateScratch);
|
|
642
|
-
isLeapSecond = true;
|
|
643
|
-
}
|
|
647
|
+
if (secondsOfDay >= 43200.0) {
|
|
648
|
+
julianDayNumber += 1;
|
|
649
|
+
}
|
|
644
650
|
|
|
645
|
-
|
|
646
|
-
|
|
651
|
+
// Algorithm from page 604 of the Explanatory Supplement to the
|
|
652
|
+
// Astronomical Almanac (Seidelmann 1992).
|
|
653
|
+
let L = (julianDayNumber + 68569) | 0;
|
|
654
|
+
const N = ((4 * L) / 146097) | 0;
|
|
655
|
+
L = (L - (((146097 * N + 3) / 4) | 0)) | 0;
|
|
656
|
+
const I = ((4000 * (L + 1)) / 1461001) | 0;
|
|
657
|
+
L = (L - (((1461 * I) / 4) | 0) + 31) | 0;
|
|
658
|
+
const J = ((80 * L) / 2447) | 0;
|
|
659
|
+
const day = (L - (((2447 * J) / 80) | 0)) | 0;
|
|
660
|
+
L = (J / 11) | 0;
|
|
661
|
+
const month = (J + 2 - 12 * L) | 0;
|
|
662
|
+
const year = (100 * (N - 49) + I + L) | 0;
|
|
663
|
+
|
|
664
|
+
let hour = (secondsOfDay / TimeConstants.SECONDS_PER_HOUR) | 0;
|
|
665
|
+
let remainingSeconds = secondsOfDay - hour * TimeConstants.SECONDS_PER_HOUR;
|
|
666
|
+
const minute = (remainingSeconds / TimeConstants.SECONDS_PER_MINUTE) | 0;
|
|
667
|
+
remainingSeconds =
|
|
668
|
+
remainingSeconds - minute * TimeConstants.SECONDS_PER_MINUTE;
|
|
669
|
+
let second = remainingSeconds | 0;
|
|
670
|
+
const millisecond =
|
|
671
|
+
(remainingSeconds - second) / TimeConstants.SECONDS_PER_MILLISECOND;
|
|
672
|
+
|
|
673
|
+
// JulianDates are noon-based
|
|
674
|
+
hour += 12;
|
|
675
|
+
if (hour > 23) {
|
|
676
|
+
hour -= 24;
|
|
677
|
+
}
|
|
647
678
|
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
679
|
+
//If we were on a leap second, add it back.
|
|
680
|
+
if (isLeapSecond) {
|
|
681
|
+
second += 1;
|
|
682
|
+
}
|
|
651
683
|
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
let hour = (secondsOfDay / TimeConstants.SECONDS_PER_HOUR) | 0;
|
|
666
|
-
let remainingSeconds = secondsOfDay - hour * TimeConstants.SECONDS_PER_HOUR;
|
|
667
|
-
const minute = (remainingSeconds / TimeConstants.SECONDS_PER_MINUTE) | 0;
|
|
668
|
-
remainingSeconds =
|
|
669
|
-
remainingSeconds - minute * TimeConstants.SECONDS_PER_MINUTE;
|
|
670
|
-
let second = remainingSeconds | 0;
|
|
671
|
-
const millisecond =
|
|
672
|
-
(remainingSeconds - second) / TimeConstants.SECONDS_PER_MILLISECOND;
|
|
684
|
+
if (!defined(result)) {
|
|
685
|
+
return new GregorianDate(
|
|
686
|
+
year,
|
|
687
|
+
month,
|
|
688
|
+
day,
|
|
689
|
+
hour,
|
|
690
|
+
minute,
|
|
691
|
+
second,
|
|
692
|
+
millisecond,
|
|
693
|
+
isLeapSecond,
|
|
694
|
+
);
|
|
695
|
+
}
|
|
673
696
|
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
hour
|
|
697
|
+
result.year = year;
|
|
698
|
+
result.month = month;
|
|
699
|
+
result.day = day;
|
|
700
|
+
result.hour = hour;
|
|
701
|
+
result.minute = minute;
|
|
702
|
+
result.second = second;
|
|
703
|
+
result.millisecond = millisecond;
|
|
704
|
+
result.isLeapSecond = isLeapSecond;
|
|
705
|
+
return result;
|
|
678
706
|
}
|
|
679
707
|
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
708
|
+
/**
|
|
709
|
+
* Creates a JavaScript Date from the provided instance.
|
|
710
|
+
* Since JavaScript dates are only accurate to the nearest millisecond and
|
|
711
|
+
* cannot represent a leap second, consider using {@link JulianDate.toGregorianDate} instead.
|
|
712
|
+
* If the provided JulianDate is during a leap second, the previous second is used.
|
|
713
|
+
*
|
|
714
|
+
* @param {JulianDate} julianDate The date to be converted.
|
|
715
|
+
* @returns {Date} A new instance representing the provided date.
|
|
716
|
+
*/
|
|
717
|
+
static toDate(julianDate) {
|
|
718
|
+
//>>includeStart('debug', pragmas.debug);
|
|
719
|
+
if (!defined(julianDate)) {
|
|
720
|
+
throw new DeveloperError("julianDate is required.");
|
|
721
|
+
}
|
|
722
|
+
//>>includeEnd('debug');
|
|
684
723
|
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
724
|
+
const gDate = JulianDate.toGregorianDate(julianDate, gregorianDateScratch);
|
|
725
|
+
let second = gDate.second;
|
|
726
|
+
if (gDate.isLeapSecond) {
|
|
727
|
+
second -= 1;
|
|
728
|
+
}
|
|
729
|
+
return new Date(
|
|
730
|
+
Date.UTC(
|
|
731
|
+
gDate.year,
|
|
732
|
+
gDate.month - 1,
|
|
733
|
+
gDate.day,
|
|
734
|
+
gDate.hour,
|
|
735
|
+
gDate.minute,
|
|
736
|
+
second,
|
|
737
|
+
gDate.millisecond,
|
|
738
|
+
),
|
|
695
739
|
);
|
|
696
740
|
}
|
|
697
741
|
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
742
|
+
/**
|
|
743
|
+
* Creates an ISO8601 representation of the provided date.
|
|
744
|
+
*
|
|
745
|
+
* @param {JulianDate} julianDate The date to be converted.
|
|
746
|
+
* @param {number} [precision] The number of fractional digits used to represent the seconds component. By default, the most precise representation is used.
|
|
747
|
+
* @returns {string} The ISO8601 representation of the provided date.
|
|
748
|
+
*/
|
|
749
|
+
static toIso8601(julianDate, precision) {
|
|
750
|
+
//>>includeStart('debug', pragmas.debug);
|
|
751
|
+
if (!defined(julianDate)) {
|
|
752
|
+
throw new DeveloperError("julianDate is required.");
|
|
753
|
+
}
|
|
754
|
+
//>>includeEnd('debug');
|
|
708
755
|
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
756
|
+
const gDate = JulianDate.toGregorianDate(julianDate, gregorianDateScratch);
|
|
757
|
+
let year = gDate.year;
|
|
758
|
+
let month = gDate.month;
|
|
759
|
+
let day = gDate.day;
|
|
760
|
+
let hour = gDate.hour;
|
|
761
|
+
const minute = gDate.minute;
|
|
762
|
+
const second = gDate.second;
|
|
763
|
+
const millisecond = gDate.millisecond;
|
|
764
|
+
|
|
765
|
+
// special case - Iso8601.MAXIMUM_VALUE produces a string which we can't parse unless we adjust.
|
|
766
|
+
// 10000-01-01T00:00:00 is the same instant as 9999-12-31T24:00:00
|
|
767
|
+
if (
|
|
768
|
+
year === 10000 &&
|
|
769
|
+
month === 1 &&
|
|
770
|
+
day === 1 &&
|
|
771
|
+
hour === 0 &&
|
|
772
|
+
minute === 0 &&
|
|
773
|
+
second === 0 &&
|
|
774
|
+
millisecond === 0
|
|
775
|
+
) {
|
|
776
|
+
year = 9999;
|
|
777
|
+
month = 12;
|
|
778
|
+
day = 31;
|
|
779
|
+
hour = 24;
|
|
780
|
+
}
|
|
724
781
|
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
}
|
|
782
|
+
let millisecondStr;
|
|
783
|
+
|
|
784
|
+
if (!defined(precision) && millisecond !== 0) {
|
|
785
|
+
// Forces milliseconds into a number with at least 3 digits.
|
|
786
|
+
const millisecondHundreds = millisecond * 0.01;
|
|
787
|
+
// Below 1e-6, toString returns scientific notation, so it should be replaced by toFixed with appropriate number of digits.
|
|
788
|
+
// 20 digits is a trade-off choice guided by JavaScript's Number representation accuracy (15-17 decimal digits for most numbers).
|
|
789
|
+
// Using toFixed(20) ensures capturing enough precision while avoiding inaccuracies due to floating-point limitations.
|
|
790
|
+
millisecondStr =
|
|
791
|
+
millisecondHundreds < 1e-6
|
|
792
|
+
? millisecondHundreds.toFixed(20).replace(".", "").replace(/0+$/, "")
|
|
793
|
+
: millisecondHundreds.toString().replace(".", "");
|
|
794
|
+
return `${year.toString().padStart(4, "0")}-${month
|
|
795
|
+
.toString()
|
|
796
|
+
.padStart(2, "0")}-${day.toString().padStart(2, "0")}T${hour
|
|
797
|
+
.toString()
|
|
798
|
+
.padStart(2, "0")}:${minute.toString().padStart(2, "0")}:${second
|
|
799
|
+
.toString()
|
|
800
|
+
.padStart(2, "0")}.${millisecondStr}Z`;
|
|
801
|
+
}
|
|
742
802
|
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
throw new DeveloperError("julianDate is required.");
|
|
754
|
-
}
|
|
755
|
-
//>>includeEnd('debug');
|
|
756
|
-
|
|
757
|
-
const gDate = JulianDate.toGregorianDate(julianDate, gregorianDateScratch);
|
|
758
|
-
let year = gDate.year;
|
|
759
|
-
let month = gDate.month;
|
|
760
|
-
let day = gDate.day;
|
|
761
|
-
let hour = gDate.hour;
|
|
762
|
-
const minute = gDate.minute;
|
|
763
|
-
const second = gDate.second;
|
|
764
|
-
const millisecond = gDate.millisecond;
|
|
765
|
-
|
|
766
|
-
// special case - Iso8601.MAXIMUM_VALUE produces a string which we can't parse unless we adjust.
|
|
767
|
-
// 10000-01-01T00:00:00 is the same instant as 9999-12-31T24:00:00
|
|
768
|
-
if (
|
|
769
|
-
year === 10000 &&
|
|
770
|
-
month === 1 &&
|
|
771
|
-
day === 1 &&
|
|
772
|
-
hour === 0 &&
|
|
773
|
-
minute === 0 &&
|
|
774
|
-
second === 0 &&
|
|
775
|
-
millisecond === 0
|
|
776
|
-
) {
|
|
777
|
-
year = 9999;
|
|
778
|
-
month = 12;
|
|
779
|
-
day = 31;
|
|
780
|
-
hour = 24;
|
|
781
|
-
}
|
|
803
|
+
//Precision is either 0 or milliseconds is 0 with undefined precision, in either case, leave off milliseconds entirely
|
|
804
|
+
if (!defined(precision) || precision === 0) {
|
|
805
|
+
return `${year.toString().padStart(4, "0")}-${month
|
|
806
|
+
.toString()
|
|
807
|
+
.padStart(2, "0")}-${day.toString().padStart(2, "0")}T${hour
|
|
808
|
+
.toString()
|
|
809
|
+
.padStart(2, "0")}:${minute
|
|
810
|
+
.toString()
|
|
811
|
+
.padStart(2, "0")}:${second.toString().padStart(2, "0")}Z`;
|
|
812
|
+
}
|
|
782
813
|
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
// Below 1e-6, toString returns scientific notation, so it should be replaced by toFixed with appropriate number of digits.
|
|
789
|
-
// 20 digits is a trade-off choice guided by JavaScript's Number representation accuracy (15-17 decimal digits for most numbers).
|
|
790
|
-
// Using toFixed(20) ensures capturing enough precision while avoiding inaccuracies due to floating-point limitations.
|
|
791
|
-
millisecondStr =
|
|
792
|
-
millisecondHundreds < 1e-6
|
|
793
|
-
? millisecondHundreds.toFixed(20).replace(".", "").replace(/0+$/, "")
|
|
794
|
-
: millisecondHundreds.toString().replace(".", "");
|
|
814
|
+
//Forces milliseconds into a number with at least 3 digits to whatever the specified precision is.
|
|
815
|
+
millisecondStr = (millisecond * 0.01)
|
|
816
|
+
.toFixed(precision)
|
|
817
|
+
.replace(".", "")
|
|
818
|
+
.slice(0, precision);
|
|
795
819
|
return `${year.toString().padStart(4, "0")}-${month
|
|
796
820
|
.toString()
|
|
797
821
|
.padStart(2, "0")}-${day.toString().padStart(2, "0")}T${hour
|
|
@@ -801,395 +825,373 @@ JulianDate.toIso8601 = function (julianDate, precision) {
|
|
|
801
825
|
.padStart(2, "0")}.${millisecondStr}Z`;
|
|
802
826
|
}
|
|
803
827
|
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
828
|
+
/**
|
|
829
|
+
* Duplicates a JulianDate instance.
|
|
830
|
+
*
|
|
831
|
+
* @param {JulianDate} julianDate The date to duplicate.
|
|
832
|
+
* @param {JulianDate} [result] An existing instance to use for the result.
|
|
833
|
+
* @returns {JulianDate} The modified result parameter or a new instance if none was provided. Returns undefined if julianDate is undefined.
|
|
834
|
+
*/
|
|
835
|
+
static clone(julianDate, result) {
|
|
836
|
+
if (!defined(julianDate)) {
|
|
837
|
+
return undefined;
|
|
838
|
+
}
|
|
839
|
+
if (!defined(result)) {
|
|
840
|
+
return new JulianDate(
|
|
841
|
+
julianDate.dayNumber,
|
|
842
|
+
julianDate.secondsOfDay,
|
|
843
|
+
TimeStandard.TAI,
|
|
844
|
+
);
|
|
845
|
+
}
|
|
846
|
+
result.dayNumber = julianDate.dayNumber;
|
|
847
|
+
result.secondsOfDay = julianDate.secondsOfDay;
|
|
848
|
+
return result;
|
|
813
849
|
}
|
|
814
850
|
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
.
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
851
|
+
/**
|
|
852
|
+
* Compares two instances.
|
|
853
|
+
*
|
|
854
|
+
* @param {JulianDate} left The first instance.
|
|
855
|
+
* @param {JulianDate} right The second instance.
|
|
856
|
+
* @returns {number} A negative value if left is less than right, a positive value if left is greater than right, or zero if left and right are equal.
|
|
857
|
+
*/
|
|
858
|
+
static compare(left, right) {
|
|
859
|
+
//>>includeStart('debug', pragmas.debug);
|
|
860
|
+
if (!defined(left)) {
|
|
861
|
+
throw new DeveloperError("left is required.");
|
|
862
|
+
}
|
|
863
|
+
if (!defined(right)) {
|
|
864
|
+
throw new DeveloperError("right is required.");
|
|
865
|
+
}
|
|
866
|
+
//>>includeEnd('debug');
|
|
828
867
|
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
* @returns {JulianDate} The modified result parameter or a new instance if none was provided. Returns undefined if julianDate is undefined.
|
|
835
|
-
*/
|
|
836
|
-
JulianDate.clone = function (julianDate, result) {
|
|
837
|
-
if (!defined(julianDate)) {
|
|
838
|
-
return undefined;
|
|
868
|
+
const julianDayNumberDifference = left.dayNumber - right.dayNumber;
|
|
869
|
+
if (julianDayNumberDifference !== 0) {
|
|
870
|
+
return julianDayNumberDifference;
|
|
871
|
+
}
|
|
872
|
+
return left.secondsOfDay - right.secondsOfDay;
|
|
839
873
|
}
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
874
|
+
|
|
875
|
+
/**
|
|
876
|
+
* Compares two instances and returns <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
877
|
+
*
|
|
878
|
+
* @param {JulianDate} [left] The first instance.
|
|
879
|
+
* @param {JulianDate} [right] The second instance.
|
|
880
|
+
* @returns {boolean} <code>true</code> if the dates are equal; otherwise, <code>false</code>.
|
|
881
|
+
*/
|
|
882
|
+
static equals(left, right) {
|
|
883
|
+
return (
|
|
884
|
+
left === right ||
|
|
885
|
+
(defined(left) &&
|
|
886
|
+
defined(right) &&
|
|
887
|
+
left.dayNumber === right.dayNumber &&
|
|
888
|
+
left.secondsOfDay === right.secondsOfDay)
|
|
845
889
|
);
|
|
846
890
|
}
|
|
847
|
-
result.dayNumber = julianDate.dayNumber;
|
|
848
|
-
result.secondsOfDay = julianDate.secondsOfDay;
|
|
849
|
-
return result;
|
|
850
|
-
};
|
|
851
891
|
|
|
852
|
-
/**
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
JulianDate
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
892
|
+
/**
|
|
893
|
+
* Compares two instances and returns <code>true</code> if they are within <code>epsilon</code> seconds of
|
|
894
|
+
* each other. That is, in order for the dates to be considered equal (and for
|
|
895
|
+
* this function to return <code>true</code>), the absolute value of the difference between them, in
|
|
896
|
+
* seconds, must be less than <code>epsilon</code>.
|
|
897
|
+
*
|
|
898
|
+
* @param {JulianDate} [left] The first instance.
|
|
899
|
+
* @param {JulianDate} [right] The second instance.
|
|
900
|
+
* @param {number} [epsilon=0] The maximum number of seconds that should separate the two instances.
|
|
901
|
+
* @returns {boolean} <code>true</code> if the two dates are within <code>epsilon</code> seconds of each other; otherwise <code>false</code>.
|
|
902
|
+
*/
|
|
903
|
+
static equalsEpsilon(left, right, epsilon) {
|
|
904
|
+
epsilon = epsilon ?? 0;
|
|
905
|
+
|
|
906
|
+
return (
|
|
907
|
+
left === right ||
|
|
908
|
+
(defined(left) &&
|
|
909
|
+
defined(right) &&
|
|
910
|
+
Math.abs(JulianDate.secondsDifference(left, right)) <= epsilon)
|
|
911
|
+
);
|
|
866
912
|
}
|
|
867
|
-
//>>includeEnd('debug');
|
|
868
913
|
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
914
|
+
/**
|
|
915
|
+
* Computes the total number of whole and fractional days represented by the provided instance.
|
|
916
|
+
*
|
|
917
|
+
* @param {JulianDate} julianDate The date.
|
|
918
|
+
* @returns {number} The Julian date as single floating point number.
|
|
919
|
+
*/
|
|
920
|
+
static totalDays(julianDate) {
|
|
921
|
+
//>>includeStart('debug', pragmas.debug);
|
|
922
|
+
if (!defined(julianDate)) {
|
|
923
|
+
throw new DeveloperError("julianDate is required.");
|
|
924
|
+
}
|
|
925
|
+
//>>includeEnd('debug');
|
|
926
|
+
return (
|
|
927
|
+
julianDate.dayNumber +
|
|
928
|
+
julianDate.secondsOfDay / TimeConstants.SECONDS_PER_DAY
|
|
929
|
+
);
|
|
872
930
|
}
|
|
873
|
-
return left.secondsOfDay - right.secondsOfDay;
|
|
874
|
-
};
|
|
875
|
-
|
|
876
|
-
/**
|
|
877
|
-
* Compares two instances and returns <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
878
|
-
*
|
|
879
|
-
* @param {JulianDate} [left] The first instance.
|
|
880
|
-
* @param {JulianDate} [right] The second instance.
|
|
881
|
-
* @returns {boolean} <code>true</code> if the dates are equal; otherwise, <code>false</code>.
|
|
882
|
-
*/
|
|
883
|
-
JulianDate.equals = function (left, right) {
|
|
884
|
-
return (
|
|
885
|
-
left === right ||
|
|
886
|
-
(defined(left) &&
|
|
887
|
-
defined(right) &&
|
|
888
|
-
left.dayNumber === right.dayNumber &&
|
|
889
|
-
left.secondsOfDay === right.secondsOfDay)
|
|
890
|
-
);
|
|
891
|
-
};
|
|
892
|
-
|
|
893
|
-
/**
|
|
894
|
-
* Compares two instances and returns <code>true</code> if they are within <code>epsilon</code> seconds of
|
|
895
|
-
* each other. That is, in order for the dates to be considered equal (and for
|
|
896
|
-
* this function to return <code>true</code>), the absolute value of the difference between them, in
|
|
897
|
-
* seconds, must be less than <code>epsilon</code>.
|
|
898
|
-
*
|
|
899
|
-
* @param {JulianDate} [left] The first instance.
|
|
900
|
-
* @param {JulianDate} [right] The second instance.
|
|
901
|
-
* @param {number} [epsilon=0] The maximum number of seconds that should separate the two instances.
|
|
902
|
-
* @returns {boolean} <code>true</code> if the two dates are within <code>epsilon</code> seconds of each other; otherwise <code>false</code>.
|
|
903
|
-
*/
|
|
904
|
-
JulianDate.equalsEpsilon = function (left, right, epsilon) {
|
|
905
|
-
epsilon = epsilon ?? 0;
|
|
906
|
-
|
|
907
|
-
return (
|
|
908
|
-
left === right ||
|
|
909
|
-
(defined(left) &&
|
|
910
|
-
defined(right) &&
|
|
911
|
-
Math.abs(JulianDate.secondsDifference(left, right)) <= epsilon)
|
|
912
|
-
);
|
|
913
|
-
};
|
|
914
931
|
|
|
915
|
-
/**
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
};
|
|
932
|
+
/**
|
|
933
|
+
* Computes the difference in seconds between the provided instance.
|
|
934
|
+
*
|
|
935
|
+
* @param {JulianDate} left The first instance.
|
|
936
|
+
* @param {JulianDate} right The second instance.
|
|
937
|
+
* @returns {number} The difference, in seconds, when subtracting <code>right</code> from <code>left</code>.
|
|
938
|
+
*/
|
|
939
|
+
static secondsDifference(left, right) {
|
|
940
|
+
//>>includeStart('debug', pragmas.debug);
|
|
941
|
+
if (!defined(left)) {
|
|
942
|
+
throw new DeveloperError("left is required.");
|
|
943
|
+
}
|
|
944
|
+
if (!defined(right)) {
|
|
945
|
+
throw new DeveloperError("right is required.");
|
|
946
|
+
}
|
|
947
|
+
//>>includeEnd('debug');
|
|
932
948
|
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
* @param {JulianDate} left The first instance.
|
|
937
|
-
* @param {JulianDate} right The second instance.
|
|
938
|
-
* @returns {number} The difference, in seconds, when subtracting <code>right</code> from <code>left</code>.
|
|
939
|
-
*/
|
|
940
|
-
JulianDate.secondsDifference = function (left, right) {
|
|
941
|
-
//>>includeStart('debug', pragmas.debug);
|
|
942
|
-
if (!defined(left)) {
|
|
943
|
-
throw new DeveloperError("left is required.");
|
|
944
|
-
}
|
|
945
|
-
if (!defined(right)) {
|
|
946
|
-
throw new DeveloperError("right is required.");
|
|
949
|
+
const dayDifference =
|
|
950
|
+
(left.dayNumber - right.dayNumber) * TimeConstants.SECONDS_PER_DAY;
|
|
951
|
+
return dayDifference + (left.secondsOfDay - right.secondsOfDay);
|
|
947
952
|
}
|
|
948
|
-
//>>includeEnd('debug');
|
|
949
953
|
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
}
|
|
954
|
+
/**
|
|
955
|
+
* Computes the difference in days between the provided instance.
|
|
956
|
+
*
|
|
957
|
+
* @param {JulianDate} left The first instance.
|
|
958
|
+
* @param {JulianDate} right The second instance.
|
|
959
|
+
* @returns {number} The difference, in days, when subtracting <code>right</code> from <code>left</code>.
|
|
960
|
+
*/
|
|
961
|
+
static daysDifference(left, right) {
|
|
962
|
+
//>>includeStart('debug', pragmas.debug);
|
|
963
|
+
if (!defined(left)) {
|
|
964
|
+
throw new DeveloperError("left is required.");
|
|
965
|
+
}
|
|
966
|
+
if (!defined(right)) {
|
|
967
|
+
throw new DeveloperError("right is required.");
|
|
968
|
+
}
|
|
969
|
+
//>>includeEnd('debug');
|
|
954
970
|
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
* @param {JulianDate} right The second instance.
|
|
960
|
-
* @returns {number} The difference, in days, when subtracting <code>right</code> from <code>left</code>.
|
|
961
|
-
*/
|
|
962
|
-
JulianDate.daysDifference = function (left, right) {
|
|
963
|
-
//>>includeStart('debug', pragmas.debug);
|
|
964
|
-
if (!defined(left)) {
|
|
965
|
-
throw new DeveloperError("left is required.");
|
|
966
|
-
}
|
|
967
|
-
if (!defined(right)) {
|
|
968
|
-
throw new DeveloperError("right is required.");
|
|
971
|
+
const dayDifference = left.dayNumber - right.dayNumber;
|
|
972
|
+
const secondDifference =
|
|
973
|
+
(left.secondsOfDay - right.secondsOfDay) / TimeConstants.SECONDS_PER_DAY;
|
|
974
|
+
return dayDifference + secondDifference;
|
|
969
975
|
}
|
|
970
|
-
//>>includeEnd('debug');
|
|
971
976
|
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
const leapSeconds = JulianDate.leapSeconds;
|
|
987
|
-
let index = binarySearch(
|
|
988
|
-
leapSeconds,
|
|
989
|
-
binarySearchScratchLeapSecond,
|
|
990
|
-
compareLeapSecondDates,
|
|
991
|
-
);
|
|
992
|
-
if (index < 0) {
|
|
993
|
-
index = ~index;
|
|
994
|
-
--index;
|
|
977
|
+
/**
|
|
978
|
+
* Computes the number of seconds the provided instance is ahead of UTC.
|
|
979
|
+
*
|
|
980
|
+
* @param {JulianDate} julianDate The date.
|
|
981
|
+
* @returns {number} The number of seconds the provided instance is ahead of UTC
|
|
982
|
+
*/
|
|
983
|
+
static computeTaiMinusUtc(julianDate) {
|
|
984
|
+
binarySearchScratchLeapSecond.julianDate = julianDate;
|
|
985
|
+
const leapSeconds = JulianDate.leapSeconds;
|
|
986
|
+
let index = binarySearch(
|
|
987
|
+
leapSeconds,
|
|
988
|
+
binarySearchScratchLeapSecond,
|
|
989
|
+
compareLeapSecondDates,
|
|
990
|
+
);
|
|
995
991
|
if (index < 0) {
|
|
996
|
-
index =
|
|
992
|
+
index = ~index;
|
|
993
|
+
--index;
|
|
994
|
+
if (index < 0) {
|
|
995
|
+
index = 0;
|
|
996
|
+
}
|
|
997
997
|
}
|
|
998
|
+
return leapSeconds[index].offset;
|
|
998
999
|
}
|
|
999
|
-
return leapSeconds[index].offset;
|
|
1000
|
-
};
|
|
1001
1000
|
|
|
1002
|
-
/**
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1001
|
+
/**
|
|
1002
|
+
* Adds the provided number of seconds to the provided date instance.
|
|
1003
|
+
*
|
|
1004
|
+
* @param {JulianDate} julianDate The date.
|
|
1005
|
+
* @param {number} seconds The number of seconds to add or subtract.
|
|
1006
|
+
* @param {JulianDate} result An existing instance to use for the result.
|
|
1007
|
+
* @returns {JulianDate} The modified result parameter.
|
|
1008
|
+
*/
|
|
1009
|
+
static addSeconds(julianDate, seconds, result) {
|
|
1010
|
+
//>>includeStart('debug', pragmas.debug);
|
|
1011
|
+
if (!defined(julianDate)) {
|
|
1012
|
+
throw new DeveloperError("julianDate is required.");
|
|
1013
|
+
}
|
|
1014
|
+
if (!defined(seconds)) {
|
|
1015
|
+
throw new DeveloperError("seconds is required.");
|
|
1016
|
+
}
|
|
1017
|
+
if (!defined(result)) {
|
|
1018
|
+
throw new DeveloperError("result is required.");
|
|
1019
|
+
}
|
|
1020
|
+
//>>includeEnd('debug');
|
|
1021
|
+
|
|
1022
|
+
return setComponents(
|
|
1023
|
+
julianDate.dayNumber,
|
|
1024
|
+
julianDate.secondsOfDay + seconds,
|
|
1025
|
+
result,
|
|
1026
|
+
);
|
|
1020
1027
|
}
|
|
1021
|
-
//>>includeEnd('debug');
|
|
1022
1028
|
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
}
|
|
1029
|
+
/**
|
|
1030
|
+
* Adds the provided number of minutes to the provided date instance.
|
|
1031
|
+
*
|
|
1032
|
+
* @param {JulianDate} julianDate The date.
|
|
1033
|
+
* @param {number} minutes The number of minutes to add or subtract.
|
|
1034
|
+
* @param {JulianDate} result An existing instance to use for the result.
|
|
1035
|
+
* @returns {JulianDate} The modified result parameter.
|
|
1036
|
+
*/
|
|
1037
|
+
static addMinutes(julianDate, minutes, result) {
|
|
1038
|
+
//>>includeStart('debug', pragmas.debug);
|
|
1039
|
+
if (!defined(julianDate)) {
|
|
1040
|
+
throw new DeveloperError("julianDate is required.");
|
|
1041
|
+
}
|
|
1042
|
+
if (!defined(minutes)) {
|
|
1043
|
+
throw new DeveloperError("minutes is required.");
|
|
1044
|
+
}
|
|
1045
|
+
if (!defined(result)) {
|
|
1046
|
+
throw new DeveloperError("result is required.");
|
|
1047
|
+
}
|
|
1048
|
+
//>>includeEnd('debug');
|
|
1029
1049
|
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
* @param {JulianDate} julianDate The date.
|
|
1034
|
-
* @param {number} minutes The number of minutes to add or subtract.
|
|
1035
|
-
* @param {JulianDate} result An existing instance to use for the result.
|
|
1036
|
-
* @returns {JulianDate} The modified result parameter.
|
|
1037
|
-
*/
|
|
1038
|
-
JulianDate.addMinutes = function (julianDate, minutes, result) {
|
|
1039
|
-
//>>includeStart('debug', pragmas.debug);
|
|
1040
|
-
if (!defined(julianDate)) {
|
|
1041
|
-
throw new DeveloperError("julianDate is required.");
|
|
1042
|
-
}
|
|
1043
|
-
if (!defined(minutes)) {
|
|
1044
|
-
throw new DeveloperError("minutes is required.");
|
|
1050
|
+
const newSecondsOfDay =
|
|
1051
|
+
julianDate.secondsOfDay + minutes * TimeConstants.SECONDS_PER_MINUTE;
|
|
1052
|
+
return setComponents(julianDate.dayNumber, newSecondsOfDay, result);
|
|
1045
1053
|
}
|
|
1046
|
-
if (!defined(result)) {
|
|
1047
|
-
throw new DeveloperError("result is required.");
|
|
1048
|
-
}
|
|
1049
|
-
//>>includeEnd('debug');
|
|
1050
1054
|
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
}
|
|
1055
|
+
/**
|
|
1056
|
+
* Adds the provided number of hours to the provided date instance.
|
|
1057
|
+
*
|
|
1058
|
+
* @param {JulianDate} julianDate The date.
|
|
1059
|
+
* @param {number} hours The number of hours to add or subtract.
|
|
1060
|
+
* @param {JulianDate} result An existing instance to use for the result.
|
|
1061
|
+
* @returns {JulianDate} The modified result parameter.
|
|
1062
|
+
*/
|
|
1063
|
+
static addHours(julianDate, hours, result) {
|
|
1064
|
+
//>>includeStart('debug', pragmas.debug);
|
|
1065
|
+
if (!defined(julianDate)) {
|
|
1066
|
+
throw new DeveloperError("julianDate is required.");
|
|
1067
|
+
}
|
|
1068
|
+
if (!defined(hours)) {
|
|
1069
|
+
throw new DeveloperError("hours is required.");
|
|
1070
|
+
}
|
|
1071
|
+
if (!defined(result)) {
|
|
1072
|
+
throw new DeveloperError("result is required.");
|
|
1073
|
+
}
|
|
1074
|
+
//>>includeEnd('debug');
|
|
1055
1075
|
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
* @param {JulianDate} julianDate The date.
|
|
1060
|
-
* @param {number} hours The number of hours to add or subtract.
|
|
1061
|
-
* @param {JulianDate} result An existing instance to use for the result.
|
|
1062
|
-
* @returns {JulianDate} The modified result parameter.
|
|
1063
|
-
*/
|
|
1064
|
-
JulianDate.addHours = function (julianDate, hours, result) {
|
|
1065
|
-
//>>includeStart('debug', pragmas.debug);
|
|
1066
|
-
if (!defined(julianDate)) {
|
|
1067
|
-
throw new DeveloperError("julianDate is required.");
|
|
1068
|
-
}
|
|
1069
|
-
if (!defined(hours)) {
|
|
1070
|
-
throw new DeveloperError("hours is required.");
|
|
1071
|
-
}
|
|
1072
|
-
if (!defined(result)) {
|
|
1073
|
-
throw new DeveloperError("result is required.");
|
|
1076
|
+
const newSecondsOfDay =
|
|
1077
|
+
julianDate.secondsOfDay + hours * TimeConstants.SECONDS_PER_HOUR;
|
|
1078
|
+
return setComponents(julianDate.dayNumber, newSecondsOfDay, result);
|
|
1074
1079
|
}
|
|
1075
|
-
//>>includeEnd('debug');
|
|
1076
1080
|
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
}
|
|
1081
|
+
/**
|
|
1082
|
+
* Adds the provided number of days to the provided date instance.
|
|
1083
|
+
*
|
|
1084
|
+
* @param {JulianDate} julianDate The date.
|
|
1085
|
+
* @param {number} days The number of days to add or subtract.
|
|
1086
|
+
* @param {JulianDate} result An existing instance to use for the result.
|
|
1087
|
+
* @returns {JulianDate} The modified result parameter.
|
|
1088
|
+
*/
|
|
1089
|
+
static addDays(julianDate, days, result) {
|
|
1090
|
+
//>>includeStart('debug', pragmas.debug);
|
|
1091
|
+
if (!defined(julianDate)) {
|
|
1092
|
+
throw new DeveloperError("julianDate is required.");
|
|
1093
|
+
}
|
|
1094
|
+
if (!defined(days)) {
|
|
1095
|
+
throw new DeveloperError("days is required.");
|
|
1096
|
+
}
|
|
1097
|
+
if (!defined(result)) {
|
|
1098
|
+
throw new DeveloperError("result is required.");
|
|
1099
|
+
}
|
|
1100
|
+
//>>includeEnd('debug');
|
|
1081
1101
|
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
*
|
|
1085
|
-
* @param {JulianDate} julianDate The date.
|
|
1086
|
-
* @param {number} days The number of days to add or subtract.
|
|
1087
|
-
* @param {JulianDate} result An existing instance to use for the result.
|
|
1088
|
-
* @returns {JulianDate} The modified result parameter.
|
|
1089
|
-
*/
|
|
1090
|
-
JulianDate.addDays = function (julianDate, days, result) {
|
|
1091
|
-
//>>includeStart('debug', pragmas.debug);
|
|
1092
|
-
if (!defined(julianDate)) {
|
|
1093
|
-
throw new DeveloperError("julianDate is required.");
|
|
1094
|
-
}
|
|
1095
|
-
if (!defined(days)) {
|
|
1096
|
-
throw new DeveloperError("days is required.");
|
|
1097
|
-
}
|
|
1098
|
-
if (!defined(result)) {
|
|
1099
|
-
throw new DeveloperError("result is required.");
|
|
1102
|
+
const newJulianDayNumber = julianDate.dayNumber + days;
|
|
1103
|
+
return setComponents(newJulianDayNumber, julianDate.secondsOfDay, result);
|
|
1100
1104
|
}
|
|
1101
|
-
//>>includeEnd('debug');
|
|
1102
1105
|
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
+
/**
|
|
1107
|
+
* Compares the provided instances and returns <code>true</code> if <code>left</code> is earlier than <code>right</code>, <code>false</code> otherwise.
|
|
1108
|
+
*
|
|
1109
|
+
* @param {JulianDate} left The first instance.
|
|
1110
|
+
* @param {JulianDate} right The second instance.
|
|
1111
|
+
* @returns {boolean} <code>true</code> if <code>left</code> is earlier than <code>right</code>, <code>false</code> otherwise.
|
|
1112
|
+
*/
|
|
1113
|
+
static lessThan(left, right) {
|
|
1114
|
+
return JulianDate.compare(left, right) < 0;
|
|
1115
|
+
}
|
|
1106
1116
|
|
|
1107
|
-
/**
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
}
|
|
1117
|
+
/**
|
|
1118
|
+
* Compares the provided instances and returns <code>true</code> if <code>left</code> is earlier than or equal to <code>right</code>, <code>false</code> otherwise.
|
|
1119
|
+
*
|
|
1120
|
+
* @param {JulianDate} left The first instance.
|
|
1121
|
+
* @param {JulianDate} right The second instance.
|
|
1122
|
+
* @returns {boolean} <code>true</code> if <code>left</code> is earlier than or equal to <code>right</code>, <code>false</code> otherwise.
|
|
1123
|
+
*/
|
|
1124
|
+
static lessThanOrEquals(left, right) {
|
|
1125
|
+
return JulianDate.compare(left, right) <= 0;
|
|
1126
|
+
}
|
|
1117
1127
|
|
|
1118
|
-
/**
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
}
|
|
1128
|
+
/**
|
|
1129
|
+
* Compares the provided instances and returns <code>true</code> if <code>left</code> is later than <code>right</code>, <code>false</code> otherwise.
|
|
1130
|
+
*
|
|
1131
|
+
* @param {JulianDate} left The first instance.
|
|
1132
|
+
* @param {JulianDate} right The second instance.
|
|
1133
|
+
* @returns {boolean} <code>true</code> if <code>left</code> is later than <code>right</code>, <code>false</code> otherwise.
|
|
1134
|
+
*/
|
|
1135
|
+
static greaterThan(left, right) {
|
|
1136
|
+
return JulianDate.compare(left, right) > 0;
|
|
1137
|
+
}
|
|
1128
1138
|
|
|
1129
|
-
/**
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
}
|
|
1139
|
+
/**
|
|
1140
|
+
* Compares the provided instances and returns <code>true</code> if <code>left</code> is later than or equal to <code>right</code>, <code>false</code> otherwise.
|
|
1141
|
+
*
|
|
1142
|
+
* @param {JulianDate} left The first instance.
|
|
1143
|
+
* @param {JulianDate} right The second instance.
|
|
1144
|
+
* @returns {boolean} <code>true</code> if <code>left</code> is later than or equal to <code>right</code>, <code>false</code> otherwise.
|
|
1145
|
+
*/
|
|
1146
|
+
static greaterThanOrEquals(left, right) {
|
|
1147
|
+
return JulianDate.compare(left, right) >= 0;
|
|
1148
|
+
}
|
|
1139
1149
|
|
|
1140
|
-
/**
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
JulianDate.
|
|
1148
|
-
|
|
1149
|
-
};
|
|
1150
|
+
/**
|
|
1151
|
+
* Duplicates this instance.
|
|
1152
|
+
*
|
|
1153
|
+
* @param {JulianDate} [result] An existing instance to use for the result.
|
|
1154
|
+
* @returns {JulianDate} The modified result parameter or a new instance if none was provided.
|
|
1155
|
+
*/
|
|
1156
|
+
clone(result) {
|
|
1157
|
+
return JulianDate.clone(this, result);
|
|
1158
|
+
}
|
|
1150
1159
|
|
|
1151
|
-
/**
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
}
|
|
1160
|
+
/**
|
|
1161
|
+
* Compares this and the provided instance and returns <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
1162
|
+
*
|
|
1163
|
+
* @param {JulianDate} [right] The second instance.
|
|
1164
|
+
* @returns {boolean} <code>true</code> if the dates are equal; otherwise, <code>false</code>.
|
|
1165
|
+
*/
|
|
1166
|
+
equals(right) {
|
|
1167
|
+
return JulianDate.equals(this, right);
|
|
1168
|
+
}
|
|
1160
1169
|
|
|
1161
|
-
/**
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
};
|
|
1170
|
+
/**
|
|
1171
|
+
* Compares this and the provided instance and returns <code>true</code> if they are within <code>epsilon</code> seconds of
|
|
1172
|
+
* each other. That is, in order for the dates to be considered equal (and for
|
|
1173
|
+
* this function to return <code>true</code>), the absolute value of the difference between them, in
|
|
1174
|
+
* seconds, must be less than <code>epsilon</code>.
|
|
1175
|
+
*
|
|
1176
|
+
* @param {JulianDate} [right] The second instance.
|
|
1177
|
+
* @param {number} [epsilon=0] The maximum number of seconds that should separate the two instances.
|
|
1178
|
+
* @returns {boolean} <code>true</code> if the two dates are within <code>epsilon</code> seconds of each other; otherwise <code>false</code>.
|
|
1179
|
+
*/
|
|
1180
|
+
equalsEpsilon(right, epsilon) {
|
|
1181
|
+
return JulianDate.equalsEpsilon(this, right, epsilon);
|
|
1182
|
+
}
|
|
1170
1183
|
|
|
1171
|
-
/**
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
*/
|
|
1181
|
-
JulianDate.prototype.equalsEpsilon = function (right, epsilon) {
|
|
1182
|
-
return JulianDate.equalsEpsilon(this, right, epsilon);
|
|
1183
|
-
};
|
|
1184
|
+
/**
|
|
1185
|
+
* Creates a string representing this date in ISO8601 format.
|
|
1186
|
+
*
|
|
1187
|
+
* @returns {string} A string representing this date in ISO8601 format.
|
|
1188
|
+
*/
|
|
1189
|
+
toString() {
|
|
1190
|
+
return JulianDate.toIso8601(this);
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1184
1193
|
|
|
1185
|
-
|
|
1186
|
-
* Creates a string representing this date in ISO8601 format.
|
|
1187
|
-
*
|
|
1188
|
-
* @returns {string} A string representing this date in ISO8601 format.
|
|
1189
|
-
*/
|
|
1190
|
-
JulianDate.prototype.toString = function () {
|
|
1191
|
-
return JulianDate.toIso8601(this);
|
|
1192
|
-
};
|
|
1194
|
+
const toGregorianDateScratch = new JulianDate(0, 0, TimeStandard.TAI);
|
|
1193
1195
|
|
|
1194
1196
|
/**
|
|
1195
1197
|
* Gets or sets the list of leap seconds used throughout Cesium.
|