Cesium JS API
AppearanceArcGisMapServerImageryProviderArcGISTiledElevationTerrainProviderArcTypeAssociativeArrayAxisAxisAlignedBoundingBoxbarycentricCoordinatesBillboardBillboardCollectionBillboardGraphicsBillboardVisualizerbinarySearchbinarySearchComparatorBingMapsGeocoderServiceBingMapsImageryProviderBingMapsStyleBlendEquationBlendFunctionBlendingStateBlendOptionBoundingRectangleBoundingSphereBoxEmitterBoxGeometryBoxGeometryUpdaterBoxGraphicsBoxOutlineGeometrybuildModuleUrlCallbackPropertyCameraCameraEventAggregatorCameraEventTypeCartesian2Cartesian3Cartesian4CartographicCartographicGeocoderServiceCatmullRomSplineCesium3DTileCesium3DTileColorBlendModeCesium3DTileContentCesium3DTileFeatureCesium3DTilePointFeatureCesium3DTilesetCesium3DTilesetGraphicsCesium3DTilesetVisualizerCesium3DTileStyleCesium3DTilesVoxelProviderCesiumTerrainProviderCesiumWidgetCheckerboardMaterialPropertyCircleEmitterCircleGeometryCircleOutlineGeometryClassificationPrimitiveClassificationTypeClippingPlaneClippingPlaneCollectionClockClockRangeClockStepcloneCloudCollectionCloudTypeColorColorBlendModeColorGeometryInstanceAttributeColorMaterialPropertycombineComponentDatatypeCompositeEntityCollectionCompositeMaterialPropertyCompositePositionPropertyCompositePropertyCompressedTextureBufferConditionsExpressionConeEmitterConstantPositionPropertyConstantPropertyConstantSplineContextOptionsCoplanarPolygonGeometryCoplanarPolygonOutlineGeometryCornerTypeCorridorGeometryCorridorGeometryUpdaterCorridorGraphicsCorridorOutlineGeometrycreateElevationBandMaterialcreateElevationBandMaterialBandcreateElevationBandMaterialEntrycreateGuidcreateOsmBuildingscreateTangentSpaceDebugPrimitivecreateWorldImagerycreateWorldTerrainCreditCreditDisplayCubicRealPolynomialCullFaceCullingVolumeCumulusCloudCustomDataSourceCustomHeightmapTerrainProviderCustomShaderCustomShaderModeCustomShaderTranslucencyModeCylinderGeometryCylinderGeometryUpdaterCylinderGraphicsCylinderOutlineGeometryCzmlDataSourceDataSourceDataSourceClockDataSourceCollectionDataSourceDisplayDebugAppearanceDebugCameraPrimitiveDebugModelMatrixPrimitiveDefaultProxydefaultValuedefinedDepthFunctiondestroyObjectDeveloperErrorDirectionalLightDirectionUpDiscardEmptyTileImagePolicyDiscardMissingTileImagePolicyDistanceDisplayConditionDistanceDisplayConditionGeometryInstanceAttributeEasingFunctionEllipseGeometryEllipseGeometryUpdaterEllipseGraphicsEllipseOutlineGeometryEllipsoidEllipsoidGeodesicEllipsoidGeometryEllipsoidGeometryUpdaterEllipsoidGraphicsEllipsoidOutlineGeometryEllipsoidRhumbLineEllipsoidSurfaceAppearanceEllipsoidTangentPlaneEllipsoidTerrainProviderEntityEntityClusterEntityCollectionEntityViewEventEventHelperexcludesReverseAxisexportKmlexportKmlModelCallbackexportKmlResultKmlexportKmlResultKmzExpressionExtrapolationTypeFeatureDetectionFogformatErrorFrameRateMonitorFrustumGeometryFrustumOutlineGeometryFullscreenGeocoderServiceGeocodeTypeGeographicProjectionGeographicTilingSchemeGeoJsonDataSourceGeometryGeometryAttributeGeometryAttributesGeometryFactoryGeometryInstanceGeometryInstanceAttributeGeometryPipelineGeometryUpdaterGeometryVisualizergetAbsoluteUrigetBaseUrigetExtensionFromUriGetFeatureInfoFormatgetFilenameFromUrigetImagePixelsgetTimestampGlobeGlobeTranslucencyGoogleEarthEnterpriseImageryProviderGoogleEarthEnterpriseMapsProviderGoogleEarthEnterpriseMetadataGoogleEarthEnterpriseTerrainDataGoogleEarthEnterpriseTerrainProviderGpxDataSourceGregorianDateGridImageryProviderGridMaterialPropertyGroundGeometryUpdaterGroundPolylineGeometryGroundPolylinePrimitiveGroundPrimitiveHeadingPitchRangeHeadingPitchRollHeadingPitchRollValuesHeightmapEncodingHeightmapTerrainDataHeightReferenceHermitePolynomialApproximationHermiteSplineHilbertOrderHorizontalOriginI3SDataProviderI3SFeatureI3SFieldI3SGeometryI3SLayerI3SNodeImageBasedLightingImageMaterialPropertyImageryLayerImageryLayerCollectionImageryLayerFeatureInfoImageryProviderImageryTypesincludesReverseAxisIndexDatatypeIntersectIntersections2DIntersectionTestsIntervalIonIonGeocoderServiceIonImageryProviderIonResourceIonWorldImageryStyleisLeapYearIso8601JulianDateKeyboardEventModifierKmlCameraKmlDataSourceKmlFeatureDataKmlLookAtKmlTourKmlTourFlyToKmlTourWaitLabelLabelCollectionLabelGraphicsLabelStyleLabelVisualizerLagrangePolynomialApproximationLeapSecondLightLightingModelLinearApproximationLinearSplineMapboxImageryProviderMapboxStyleImageryProviderMapMode2DMapProjectionMaterialMaterialAppearanceMaterialSupportMaterialPropertyMathMatrix2Matrix3Matrix4mergeSortmergeSortComparatorMetadataClassMetadataClassPropertyMetadataComponentTypeMetadataEnumMetadataEnumValueMetadataSchemaMetadataTypeModelModelAnimationModelAnimationCollectionModelAnimationLoopModelFeatureModelGraphicsModelNodeModelVisualizerMoonMorphWeightSplineNearFarScalarNeverTileDiscardPolicyNodeTransformationPropertyobjectToQueryOccluderOpenCageGeocoderServiceOpenStreetMapImageryProviderOrientedBoundingBoxOrthographicFrustumOrthographicOffCenterFrustumPackableForInterpolationParticleParticleBurstParticleEmitterParticleSystemPathGraphicsPathVisualizerPeliasGeocoderServicePerInstanceColorAppearancePerspectiveFrustumPerspectiveOffCenterFrustumPinBuilderPixelDatatypePixelFormatPlanePlaneGeometryPlaneGeometryUpdaterPlaneGraphicsPlaneOutlineGeometryPointCloudShadingPointGraphicspointInsideTrianglePointPrimitivePointPrimitiveCollectionPointVisualizerPolygonGeometryPolygonGeometryUpdaterPolygonGraphicsPolygonHierarchyPolygonOutlineGeometryPolylinePolylineArrowMaterialPropertyPolylineCollectionPolylineColorAppearancePolylineDashMaterialPropertyPolylineGeometryPolylineGeometryUpdaterPolylineGlowMaterialPropertyPolylineGraphicsPolylineMaterialAppearancePolylineOutlineMaterialPropertyPolylineVisualizerPolylineVolumeGeometryPolylineVolumeGeometryUpdaterPolylineVolumeGraphicsPolylineVolumeOutlineGeometryPositionPropertyPositionPropertyArrayPostProcessStagePostProcessStageCollectionPostProcessStageCompositePostProcessStageLibraryPostProcessStageSampleModePrimitivePrimitiveCollectionPrimitiveTypePropertyPropertyArrayPropertyBagProxyQuadraticRealPolynomialQuantizedMeshTerrainDataQuarticRealPolynomialQuaternionQuaternionSplinequeryToObjectQueueRayreadyPromiseRectangleRectangleGeometryRectangleGeometryUpdaterRectangleGraphicsRectangleOutlineGeometryReferenceFrameReferencePropertyremoveExtensionRequestRequestErrorEventRequestSchedulerRequestStateRequestTypeResourceRuntimeErrorSampledPositionPropertySampledPropertysampleTerrainsampleTerrainMostDetailedSceneSceneModeSceneTransformsScreenSpaceCameraControllerScreenSpaceEventHandlerScreenSpaceEventTypeshaderDefinesshaderMaximumIntersectionsLengthshaderUniformsShadowMapShadowModeShowGeometryInstanceAttributeSimon1994PlanetaryPositionsSimplePolylineGeometrySingleTileImageryProviderSkyAtmosphereSkyBoxSphereEmitterSphereGeometrySphereOutlineGeometrySphericalSplineSplitDirectionStencilFunctionStencilOperationSteppedSplineStripeMaterialPropertyStripeOrientationStyleExpressionsubdivideArraySunSunLightTaskProcessorTerrainDataTerrainProviderTextureMagnificationFilterTextureMinificationFilterTextureUniformTileAvailabilityTileCoordinatesImageryProviderTileDiscardPolicyTileMapServiceImageryProviderTileProviderErrorTilingSchemeTimeDynamicImageryTimeDynamicPointCloudTimeIntervalTimeIntervalCollectionTimeIntervalCollectionPositionPropertyTimeIntervalCollectionPropertyTimeStandardTransformsTranslationRotationScaleTridiagonalSystemSolverTrustedServersUniformSpecifierUniformTypeUrlTemplateImageryProviderVaryingTypeVelocityOrientationPropertyVelocityVectorPropertyVertexFormatVerticalOriginVideoSynchronizerViewportQuadVisibilityVisualizerVoxelPrimitiveVoxelProviderVoxelShapeTypeVRTheWorldTerrainProviderWallGeometryWallGeometryUpdaterWallGraphicsWallOutlineGeometryWebGLConstantsWebGLOptionsWebMapServiceImageryProviderWebMapTileServiceImageryProviderWebMercatorProjectionWebMercatorTilingSchemeWindingOrderwriteTextToCanvasAnimationAnimationViewModelBaseLayerPickerBaseLayerPickerViewModelCesium3DTilesInspectorCesium3DTilesInspectorViewModelCesiumInspectorCesiumInspectorViewModelClockViewModelCommandcreateCommandFullscreenButtonFullscreenButtonViewModelGeocoderGeocoderViewModelHomeButtonHomeButtonViewModelInfoBoxInfoBoxViewModelNavigationHelpButtonNavigationHelpButtonViewModelPerformanceWatchdogPerformanceWatchdogViewModelProjectionPickerProjectionPickerViewModelProviderViewModelSceneModePickerSceneModePickerViewModelSelectionIndicatorSelectionIndicatorViewModelSvgPathBindingHandlerTimelineToggleButtonViewModelViewerviewerCesium3DTilesInspectorMixinviewerCesiumInspectorMixinviewerDragDropMixinviewerPerformanceWatchdogMixinviewerVoxelInspectorMixinVoxelInspectorVoxelInspectorViewModelVRButtonVRButtonViewModel

TimeIntervalCollection

TimeIntervalCollection是CesiumJS中的一个类,用于管理一组时间间隔(TimeInterval),提供方便的时间范围查询和样式编辑功能。

用法

创建TimeIntervalCollection

var timeIntervalCollection = new Cesium.TimeIntervalCollection();

添加TimeInterval

// 创建TimeInterval对象
var start = Cesium.JulianDate.fromIso8601('2022-01-01T00:00:00.00+08:00');
var stop = Cesium.JulianDate.fromIso8601('2022-01-05T00:00:00.00+08:00');
var interval = new Cesium.TimeInterval({
    start: start,
    stop: stop,
    isStartIncluded: true,
    isStopIncluded: false
});

// 添加TimeInterval到TimeIntervalCollection中
timeIntervalCollection.addInterval(interval);

查询时间范围

var start = Cesium.JulianDate.fromIso8601('2022-01-02T00:00:00.00+08:00');
var stop = Cesium.JulianDate.fromIso8601('2022-01-03T00:00:00.00+08:00');
var interval = new Cesium.TimeInterval({
    start: start,
    stop: stop,
    isStartIncluded: true,
    isStopIncluded: false
});

// 查询TimeIntervalCollection中包含给定时间范围的TimeInterval
var result = timeIntervalCollection.findDataForInterval(interval);

更新时间间隔的样式

// 遍历TimeIntervalCollection中的所有TimeInterval,并设置其颜色
for (var i = 0; i < timeIntervalCollection.length; i++) {
    var interval = timeIntervalCollection.get(i);
    var color = Cesium.Color.fromRandom({ alpha: 0.3 });
    var data = interval.data;
    if (data === undefined) {
        data = {};
        interval.data = data;
    }
    data.color = color;
}

属性

  • length:TimeIntervalCollection中TimeInterval的数量,只读属性。

方法

  • addInterval(interval):将TimeInterval添加到TimeIntervalCollection中。

  • removeInterval(interval, [destroy = true]):从TimeIntervalCollection中删除给定的TimeInterval。如果destroy为true,TimeInterval将被销毁。

  • removeAll() :从TimeIntervalCollection中删除所有TimeInterval。

  • get(index):获取指定索引处的TimeInterval。

  • findDataForInterval(interval):查找TimeIntervalCollection中包含给定时间范围的TimeInterval。返回结果是一个数组,其中每个元素是包含了匹配时间间隔的时间区间的对象。每个对象都有一个 data 属性,可以用来存储自定义数据。

  • findIntervalContainingDate(date):查找包含给定日期的TimeInterval。返回找到的第一个TimeInterval,如果没有TimeInterval包含该日期,则返回undefined。

  • fromIso8601(options):将符合ISO8601格式的时间范围字符串转换为TimeIntervalCollection。options参数可以包含以下属性:

    • iso8601:字符串,必填,表示ISO8601格式的时间范围字符串。

    • isStartIncluded:可选,boolean类型,表示返回的TimeInterval是否包含起始时间。

    • isStopIncluded:可选,boolean类型,表示返回的TimeInterval是否包含终止时间。

    • dataCallback:可选,一个函数,用于对每个TimeInterval应用数据回调。该函数应具有此签名:function(timeInterval, data)。对于每个TimeInterval,该函数将调用一次,并传递TimeInterval和新创建的data对象。应该在data对象上设置自定义属性。

    • intervalCallback:可选,一个函数,用于对每个新创建的TimeInterval应用间隔回调。该函数应该有如下签名:function(timeInterval)

  • toIso8601():将TimeIntervalCollection转换为符合ISO8601格式的时间范围字符串。如果TimeIntervalCollection没有TimeInterval,返回为空字符串。

示例

  • 创造TimeIntervalCollection并添加TimeInterval
var start1 = Cesium.JulianDate.fromIso8601('2019-12-31T00:00:00.00+08:00');
var stop1 = Cesium.JulianDate.fromIso8601('2020-01-02T00:00:00.00+08:00');
var interval1 = new Cesium.TimeInterval({
    start: start1,
    stop: stop1,
    isStartIncluded: true,
    isStopIncluded: true,
    data: { name: 'New Year' }
});

var start2 = Cesium.JulianDate.fromIso8601('2020-10-01T00:00:00.00+08:00');
var stop2 = Cesium.JulianDate.fromIso8601('2020-10-08T00:00:00.00+08:00');
var interval2 = new Cesium.TimeInterval({
    start: start2,
    stop: stop2,
    isStartIncluded: true,
    isStopIncluded: true,
    data: { name: 'National Day' }
});

var timeIntervalCollection = new Cesium.TimeIntervalCollection();
timeIntervalCollection.addInterval(interval1);
timeIntervalCollection.addInterval(interval2);
  • 查询TimeIntervalCollection中包含给定时间范围的TimeInterval
var start = Cesium.JulianDate.fromIso8601('2020-01-01T00:00:00.00+08:00');
var stop = Cesium.JulianDate.fromIso8601('2020-01-15T00:00:00.00+08:00');
var interval = new Cesium.TimeInterval({
    start: start,
    stop: stop,
    isStartIncluded: true,
    isStopIncluded: true
});

var result = timeIntervalCollection.findDataForInterval(interval);
  • 更新TimeIntervalCollection中TimeInterval样式
timeIntervalCollection.forEach(function(interval) {
    var color = Cesium.Color.fromRandom({ alpha: 0.3 });
    var data = interval.data;
    if (data === undefined) {
        data = {};
        interval.data = data;
    }
    data.color = color;
});