@cesium/engine 24.0.0 → 25.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-NKT5K3K3.js → chunk-35H3UBIO.js} +13 -12
- package/Build/Workers/{chunk-5A2SW66E.js → chunk-3LSD7OOA.js} +16 -16
- package/Build/Workers/{chunk-HXJMS2ZI.js → chunk-3RFFPH4M.js} +1 -1
- package/Build/Workers/{chunk-EDXL4W76.js → chunk-3TKLDHV3.js} +2 -2
- package/Build/Workers/{chunk-GQUNK2XC.js → chunk-3VDDRF2E.js} +14 -14
- package/Build/Workers/{chunk-Q3C6VQH6.js → chunk-3XY3MVPG.js} +4 -4
- package/Build/Workers/{chunk-A47HVBC5.js → chunk-4GF4MVPY.js} +7 -7
- package/Build/Workers/{chunk-YQFTYQMZ.js → chunk-4MTRQFJP.js} +3 -2
- package/Build/Workers/{chunk-N65BAKSH.js → chunk-4QQXGTCE.js} +8 -8
- package/Build/Workers/{chunk-EV3VGO6Y.js → chunk-4XXHJI6Y.js} +17 -17
- package/Build/Workers/{chunk-DHKPFLSJ.js → chunk-5T6QQAJW.js} +3 -2
- package/Build/Workers/{chunk-UIGVOKKI.js → chunk-6SDGQI27.js} +3 -2
- package/Build/Workers/{chunk-ILMFADZA.js → chunk-77RL3MBD.js} +6 -5
- package/Build/Workers/{chunk-2N4KDHS3.js → chunk-7LSFAEWF.js} +12 -11
- package/Build/Workers/{chunk-44EMEGKW.js → chunk-A7A433MD.js} +5 -5
- package/Build/Workers/{chunk-J6AW5YHS.js → chunk-A7ZBMVFS.js} +14 -14
- package/Build/Workers/{chunk-XJRBB253.js → chunk-ACFFCHHZ.js} +11 -11
- package/Build/Workers/{chunk-MKM27KGV.js → chunk-AEAVLYPS.js} +2 -2
- package/Build/Workers/{chunk-7MDYBRYJ.js → chunk-AWFZHD2B.js} +4 -4
- package/Build/Workers/{chunk-UQU4RXLT.js → chunk-BTX2NL3P.js} +50 -45
- package/Build/Workers/{chunk-4TIG36AW.js → chunk-BVAIWR7O.js} +12 -12
- package/Build/Workers/chunk-CKQP3DSS.js +973 -0
- package/Build/Workers/{chunk-VLDEUTOP.js → chunk-CZ23Y3RM.js} +2 -2
- package/Build/Workers/{chunk-NPF7SSHZ.js → chunk-DFEI5MAV.js} +7 -7
- package/Build/Workers/{chunk-AJLTU6PF.js → chunk-DH26SNAB.js} +4 -1
- package/Build/Workers/{chunk-5GXYJQ2K.js → chunk-DYT5NR6P.js} +3 -3
- package/Build/Workers/{chunk-63SIWPLS.js → chunk-EZARA5FJ.js} +13 -13
- package/Build/Workers/{chunk-AMIHNSST.js → chunk-FIBS5S7R.js} +2 -2
- package/Build/Workers/{chunk-Y7HNNPNK.js → chunk-FVLVVOBQ.js} +10 -10
- package/Build/Workers/{chunk-XY6HMDGI.js → chunk-GL7DNVUS.js} +5 -5
- package/Build/Workers/{chunk-6WLHJFD3.js → chunk-GPIGURCG.js} +59 -32
- package/Build/Workers/{chunk-B6SCUUFP.js → chunk-H2A4USJR.js} +10 -10
- package/Build/Workers/chunk-HSVQATK2.js +147 -0
- package/Build/Workers/{chunk-72VYSVEW.js → chunk-HVMG6AG4.js} +11 -10
- package/Build/Workers/{chunk-LXMCPFFS.js → chunk-I3A6DXYZ.js} +4 -4
- package/Build/Workers/{chunk-7QRFIKWQ.js → chunk-ITD2IN7N.js} +2 -2
- package/Build/Workers/{chunk-RQNJD3O4.js → chunk-J3OFS2RD.js} +12 -12
- package/Build/Workers/{chunk-C6P4IG5P.js → chunk-J647NNZW.js} +6 -6
- package/Build/Workers/{chunk-7X322WP2.js → chunk-J7KQEKPK.js} +13 -13
- package/Build/Workers/{chunk-7O5XJTVE.js → chunk-K6NFIRFB.js} +5 -5
- package/Build/Workers/{chunk-AF3MU2RL.js → chunk-LH5SF3XV.js} +7 -6
- package/Build/Workers/{chunk-GOQBUCXH.js → chunk-ND3NTTOF.js} +708 -430
- package/Build/Workers/chunk-QO2CGXMP.js +2342 -0
- package/Build/Workers/chunk-QSDY4NS7.js +1287 -0
- package/Build/Workers/chunk-QXNQQYPV.js +3201 -0
- package/Build/Workers/{chunk-YAOZMOFL.js → chunk-ST2UWDUU.js} +5 -5
- package/Build/Workers/{chunk-PVV64VFW.js → chunk-TA777BGS.js} +3 -2
- package/Build/Workers/{chunk-ISY4EZCA.js → chunk-TAI4HLII.js} +4 -4
- package/Build/Workers/{chunk-JCI63T3K.js → chunk-URUCCIPS.js} +6 -6
- package/Build/Workers/{chunk-VMVOUQ5J.js → chunk-VQKLRBIK.js} +7 -7
- package/Build/Workers/{chunk-6MPGQEHA.js → chunk-WC57YYBN.js} +2 -2
- package/Build/Workers/{chunk-BJD6QGXZ.js → chunk-WN6P5UDH.js} +12 -12
- package/Build/Workers/{chunk-LIB2H534.js → chunk-WNN5D4W3.js} +12 -11
- package/Build/Workers/{chunk-D4EJ2NXG.js → chunk-WTQGE7Q6.js} +17 -17
- package/Build/Workers/{chunk-YJZGW74L.js → chunk-WUBKZFF6.js} +2213 -1349
- package/Build/Workers/{chunk-7TYLCBGK.js → chunk-ZAPOS52G.js} +12 -10
- package/Build/Workers/{chunk-6RMS4S72.js → chunk-ZCCIIBZT.js} +6 -6
- 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/Cartesian3.js +1 -2
- 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 +4 -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 +39 -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/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/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 +7 -1
- 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/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/BufferPointCollection.js +4 -1
- package/Source/Scene/BufferPolygonCollection.js +3 -1
- package/Source/Scene/BufferPolylineCollection.js +3 -1
- package/Source/Scene/BufferPrimitiveCollection.js +140 -24
- package/Source/Scene/CameraEventType.js +6 -1
- package/Source/Scene/Cesium3DTileColorBlendMode.js +6 -1
- 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 +1 -1
- package/Source/Scene/ClassificationType.js +3 -1
- package/Source/Scene/CloudType.js +3 -1
- package/Source/Scene/ColorBlendMode.js +4 -1
- package/Source/Scene/CullFace.js +6 -1
- package/Source/Scene/DepthFunction.js +6 -1
- package/Source/Scene/DynamicAtmosphereLightingType.js +3 -1
- package/Source/Scene/EquirectangularPanorama.js +1 -0
- package/Source/Scene/ExpressionNodeType.js +6 -1
- 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 +0 -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/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/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 +44 -71
- 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/ModelReader.js +474 -3
- package/Source/Scene/Model/ModelRuntimePrimitive.js +2 -1
- package/Source/Scene/Model/ModelType.js +3 -1
- 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 +73 -28
- 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 +8 -1
- 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/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/Tonemapper.js +5 -1
- package/Source/Scene/VectorGltf3DTileContent.js +72 -51
- 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/VoxelProvider.js +1 -0
- package/Source/Scene/VoxelShapeType.js +3 -1
- package/Source/Scene/renderBufferPointCollection.js +17 -66
- package/Source/Scene/renderBufferPolygonCollection.js +21 -68
- package/Source/Scene/renderBufferPolylineCollection.js +22 -73
- package/Source/Shaders/Builtin/CzmBuiltins.js +2 -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/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 +343 -309
- package/index.js +443 -438
- package/package.json +2 -2
- 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
package/Source/Core/Rectangle.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
1
3
|
import Cartesian3 from "./Cartesian3.js";
|
|
2
4
|
import Cartographic from "./Cartographic.js";
|
|
3
5
|
import Check from "./Check.js";
|
|
@@ -7,1052 +9,1059 @@ import CesiumMath from "./Math.js";
|
|
|
7
9
|
import Transforms from "./Transforms.js";
|
|
8
10
|
import Matrix4 from "./Matrix4.js";
|
|
9
11
|
|
|
12
|
+
/** @import BoundingSphere from "./BoundingSphere.js"; */
|
|
13
|
+
|
|
10
14
|
/**
|
|
11
15
|
* A two dimensional region specified as longitude and latitude coordinates.
|
|
12
|
-
*
|
|
13
|
-
* @alias Rectangle
|
|
14
|
-
* @constructor
|
|
15
|
-
*
|
|
16
|
-
* @param {number} [west=0.0] The westernmost longitude, in radians, in the range [-Pi, Pi].
|
|
17
|
-
* @param {number} [south=0.0] The southernmost latitude, in radians, in the range [-Pi/2, Pi/2].
|
|
18
|
-
* @param {number} [east=0.0] The easternmost longitude, in radians, in the range [-Pi, Pi].
|
|
19
|
-
* @param {number} [north=0.0] The northernmost latitude, in radians, in the range [-Pi/2, Pi/2].
|
|
20
|
-
*
|
|
21
16
|
* @see Packable
|
|
22
17
|
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* The westernmost longitude in radians in the range [-Pi, Pi].
|
|
26
|
-
*
|
|
27
|
-
* @type {number}
|
|
28
|
-
* @default 0.0
|
|
29
|
-
*/
|
|
30
|
-
this.west = west ?? 0.0;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* The southernmost latitude in radians in the range [-Pi/2, Pi/2].
|
|
34
|
-
*
|
|
35
|
-
* @type {number}
|
|
36
|
-
* @default 0.0
|
|
37
|
-
*/
|
|
38
|
-
this.south = south ?? 0.0;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* The easternmost longitude in radians in the range [-Pi, Pi].
|
|
42
|
-
*
|
|
43
|
-
* @type {number}
|
|
44
|
-
* @default 0.0
|
|
45
|
-
*/
|
|
46
|
-
this.east = east ?? 0.0;
|
|
47
|
-
|
|
18
|
+
class Rectangle {
|
|
48
19
|
/**
|
|
49
|
-
* The
|
|
50
|
-
*
|
|
51
|
-
* @
|
|
52
|
-
* @
|
|
20
|
+
* @param {number} [west=0.0] The westernmost longitude, in radians, in the range [-Pi, Pi].
|
|
21
|
+
* @param {number} [south=0.0] The southernmost latitude, in radians, in the range [-Pi/2, Pi/2].
|
|
22
|
+
* @param {number} [east=0.0] The easternmost longitude, in radians, in the range [-Pi, Pi].
|
|
23
|
+
* @param {number} [north=0.0] The northernmost latitude, in radians, in the range [-Pi/2, Pi/2].
|
|
53
24
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
25
|
+
constructor(west, south, east, north) {
|
|
26
|
+
/**
|
|
27
|
+
* The westernmost longitude in radians in the range [-Pi, Pi].
|
|
28
|
+
*
|
|
29
|
+
* @type {number}
|
|
30
|
+
* @default 0.0
|
|
31
|
+
*/
|
|
32
|
+
this.west = west ?? 0.0;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The southernmost latitude in radians in the range [-Pi/2, Pi/2].
|
|
36
|
+
*
|
|
37
|
+
* @type {number}
|
|
38
|
+
* @default 0.0
|
|
39
|
+
*/
|
|
40
|
+
this.south = south ?? 0.0;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The easternmost longitude in radians in the range [-Pi, Pi].
|
|
44
|
+
*
|
|
45
|
+
* @type {number}
|
|
46
|
+
* @default 0.0
|
|
47
|
+
*/
|
|
48
|
+
this.east = east ?? 0.0;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The northernmost latitude in radians in the range [-Pi/2, Pi/2].
|
|
52
|
+
*
|
|
53
|
+
* @type {number}
|
|
54
|
+
* @default 0.0
|
|
55
|
+
*/
|
|
56
|
+
this.north = north ?? 0.0;
|
|
57
|
+
}
|
|
56
58
|
|
|
57
|
-
Object.defineProperties(Rectangle.prototype, {
|
|
58
59
|
/**
|
|
59
60
|
* Gets the width of the rectangle in radians.
|
|
60
|
-
* @memberof Rectangle.prototype
|
|
61
61
|
* @type {number}
|
|
62
62
|
* @readonly
|
|
63
63
|
*/
|
|
64
|
-
width
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
},
|
|
68
|
-
},
|
|
64
|
+
get width() {
|
|
65
|
+
return Rectangle.computeWidth(this);
|
|
66
|
+
}
|
|
69
67
|
|
|
70
68
|
/**
|
|
71
69
|
* Gets the height of the rectangle in radians.
|
|
72
|
-
* @memberof Rectangle.prototype
|
|
73
70
|
* @type {number}
|
|
74
71
|
* @readonly
|
|
75
72
|
*/
|
|
76
|
-
height
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
});
|
|
73
|
+
get height() {
|
|
74
|
+
return Rectangle.computeHeight(this);
|
|
75
|
+
}
|
|
82
76
|
|
|
83
|
-
/**
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Stores the provided instance into the provided array.
|
|
79
|
+
*
|
|
80
|
+
* @param {Rectangle} value The value to pack.
|
|
81
|
+
* @param {number[]} array The array to pack into.
|
|
82
|
+
* @param {number} [startingIndex=0] The index into the array at which to start packing the elements.
|
|
83
|
+
*
|
|
84
|
+
* @returns {number[]} The array that was packed into
|
|
85
|
+
*/
|
|
86
|
+
static pack(value, array, startingIndex) {
|
|
87
|
+
//>>includeStart('debug', pragmas.debug);
|
|
88
|
+
Check.typeOf.object("value", value);
|
|
89
|
+
Check.defined("array", array);
|
|
90
|
+
//>>includeEnd('debug');
|
|
88
91
|
|
|
89
|
-
|
|
90
|
-
* Stores the provided instance into the provided array.
|
|
91
|
-
*
|
|
92
|
-
* @param {Rectangle} value The value to pack.
|
|
93
|
-
* @param {number[]} array The array to pack into.
|
|
94
|
-
* @param {number} [startingIndex=0] The index into the array at which to start packing the elements.
|
|
95
|
-
*
|
|
96
|
-
* @returns {number[]} The array that was packed into
|
|
97
|
-
*/
|
|
98
|
-
Rectangle.pack = function (value, array, startingIndex) {
|
|
99
|
-
//>>includeStart('debug', pragmas.debug);
|
|
100
|
-
Check.typeOf.object("value", value);
|
|
101
|
-
Check.defined("array", array);
|
|
102
|
-
//>>includeEnd('debug');
|
|
92
|
+
startingIndex = startingIndex ?? 0;
|
|
103
93
|
|
|
104
|
-
|
|
94
|
+
array[startingIndex++] = value.west;
|
|
95
|
+
array[startingIndex++] = value.south;
|
|
96
|
+
array[startingIndex++] = value.east;
|
|
97
|
+
array[startingIndex] = value.north;
|
|
105
98
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
array[startingIndex++] = value.east;
|
|
109
|
-
array[startingIndex] = value.north;
|
|
99
|
+
return array;
|
|
100
|
+
}
|
|
110
101
|
|
|
111
|
-
|
|
112
|
-
|
|
102
|
+
/**
|
|
103
|
+
* Retrieves an instance from a packed array.
|
|
104
|
+
*
|
|
105
|
+
* @param {number[]} array The packed array.
|
|
106
|
+
* @param {number} [startingIndex=0] The starting index of the element to be unpacked.
|
|
107
|
+
* @param {Rectangle} [result] The object into which to store the result.
|
|
108
|
+
* @returns {Rectangle} The modified result parameter or a new Rectangle instance if one was not provided.
|
|
109
|
+
*/
|
|
110
|
+
static unpack(array, startingIndex, result) {
|
|
111
|
+
//>>includeStart('debug', pragmas.debug);
|
|
112
|
+
Check.defined("array", array);
|
|
113
|
+
//>>includeEnd('debug');
|
|
113
114
|
|
|
114
|
-
|
|
115
|
-
* Retrieves an instance from a packed array.
|
|
116
|
-
*
|
|
117
|
-
* @param {number[]} array The packed array.
|
|
118
|
-
* @param {number} [startingIndex=0] The starting index of the element to be unpacked.
|
|
119
|
-
* @param {Rectangle} [result] The object into which to store the result.
|
|
120
|
-
* @returns {Rectangle} The modified result parameter or a new Rectangle instance if one was not provided.
|
|
121
|
-
*/
|
|
122
|
-
Rectangle.unpack = function (array, startingIndex, result) {
|
|
123
|
-
//>>includeStart('debug', pragmas.debug);
|
|
124
|
-
Check.defined("array", array);
|
|
125
|
-
//>>includeEnd('debug');
|
|
115
|
+
startingIndex = startingIndex ?? 0;
|
|
126
116
|
|
|
127
|
-
|
|
117
|
+
if (!defined(result)) {
|
|
118
|
+
result = new Rectangle();
|
|
119
|
+
}
|
|
128
120
|
|
|
129
|
-
|
|
130
|
-
result =
|
|
121
|
+
result.west = array[startingIndex++];
|
|
122
|
+
result.south = array[startingIndex++];
|
|
123
|
+
result.east = array[startingIndex++];
|
|
124
|
+
result.north = array[startingIndex];
|
|
125
|
+
return result;
|
|
131
126
|
}
|
|
132
127
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
128
|
+
/**
|
|
129
|
+
* Computes the width of a rectangle in radians.
|
|
130
|
+
* @param {Rectangle} rectangle The rectangle to compute the width of.
|
|
131
|
+
* @returns {number} The width.
|
|
132
|
+
*/
|
|
133
|
+
static computeWidth(rectangle) {
|
|
134
|
+
//>>includeStart('debug', pragmas.debug);
|
|
135
|
+
Check.typeOf.object("rectangle", rectangle);
|
|
136
|
+
//>>includeEnd('debug');
|
|
137
|
+
let east = rectangle.east;
|
|
138
|
+
const west = rectangle.west;
|
|
139
|
+
if (east < west) {
|
|
140
|
+
east += CesiumMath.TWO_PI;
|
|
141
|
+
}
|
|
142
|
+
return east - west;
|
|
143
|
+
}
|
|
139
144
|
|
|
140
|
-
/**
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
const west = rectangle.west;
|
|
151
|
-
if (east < west) {
|
|
152
|
-
east += CesiumMath.TWO_PI;
|
|
145
|
+
/**
|
|
146
|
+
* Computes the height of a rectangle in radians.
|
|
147
|
+
* @param {Rectangle} rectangle The rectangle to compute the height of.
|
|
148
|
+
* @returns {number} The height.
|
|
149
|
+
*/
|
|
150
|
+
static computeHeight(rectangle) {
|
|
151
|
+
//>>includeStart('debug', pragmas.debug);
|
|
152
|
+
Check.typeOf.object("rectangle", rectangle);
|
|
153
|
+
//>>includeEnd('debug');
|
|
154
|
+
return rectangle.north - rectangle.south;
|
|
153
155
|
}
|
|
154
|
-
return east - west;
|
|
155
|
-
};
|
|
156
156
|
|
|
157
|
-
/**
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
157
|
+
/**
|
|
158
|
+
* Creates a rectangle given the boundary longitude and latitude in degrees.
|
|
159
|
+
*
|
|
160
|
+
* @param {number} [west=0.0] The westernmost longitude in degrees in the range [-180.0, 180.0].
|
|
161
|
+
* @param {number} [south=0.0] The southernmost latitude in degrees in the range [-90.0, 90.0].
|
|
162
|
+
* @param {number} [east=0.0] The easternmost longitude in degrees in the range [-180.0, 180.0].
|
|
163
|
+
* @param {number} [north=0.0] The northernmost latitude in degrees in the range [-90.0, 90.0].
|
|
164
|
+
* @param {Rectangle} [result] The object onto which to store the result, or undefined if a new instance should be created.
|
|
165
|
+
* @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided.
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* const rectangle = Cesium.Rectangle.fromDegrees(0.0, 20.0, 10.0, 30.0);
|
|
169
|
+
*/
|
|
170
|
+
static fromDegrees(west, south, east, north, result) {
|
|
171
|
+
west = CesiumMath.toRadians(west ?? 0.0);
|
|
172
|
+
south = CesiumMath.toRadians(south ?? 0.0);
|
|
173
|
+
east = CesiumMath.toRadians(east ?? 0.0);
|
|
174
|
+
north = CesiumMath.toRadians(north ?? 0.0);
|
|
175
|
+
|
|
176
|
+
if (!defined(result)) {
|
|
177
|
+
return new Rectangle(west, south, east, north);
|
|
178
|
+
}
|
|
168
179
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
* @param {number} [north=0.0] The northernmost latitude in degrees in the range [-90.0, 90.0].
|
|
176
|
-
* @param {Rectangle} [result] The object onto which to store the result, or undefined if a new instance should be created.
|
|
177
|
-
* @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided.
|
|
178
|
-
*
|
|
179
|
-
* @example
|
|
180
|
-
* const rectangle = Cesium.Rectangle.fromDegrees(0.0, 20.0, 10.0, 30.0);
|
|
181
|
-
*/
|
|
182
|
-
Rectangle.fromDegrees = function (west, south, east, north, result) {
|
|
183
|
-
west = CesiumMath.toRadians(west ?? 0.0);
|
|
184
|
-
south = CesiumMath.toRadians(south ?? 0.0);
|
|
185
|
-
east = CesiumMath.toRadians(east ?? 0.0);
|
|
186
|
-
north = CesiumMath.toRadians(north ?? 0.0);
|
|
187
|
-
|
|
188
|
-
if (!defined(result)) {
|
|
189
|
-
return new Rectangle(west, south, east, north);
|
|
180
|
+
result.west = west;
|
|
181
|
+
result.south = south;
|
|
182
|
+
result.east = east;
|
|
183
|
+
result.north = north;
|
|
184
|
+
|
|
185
|
+
return result;
|
|
190
186
|
}
|
|
191
187
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
188
|
+
/**
|
|
189
|
+
* Creates a rectangle given the boundary longitude and latitude in radians.
|
|
190
|
+
*
|
|
191
|
+
* @param {number} [west=0.0] The westernmost longitude in radians in the range [-Math.PI, Math.PI].
|
|
192
|
+
* @param {number} [south=0.0] The southernmost latitude in radians in the range [-Math.PI/2, Math.PI/2].
|
|
193
|
+
* @param {number} [east=0.0] The easternmost longitude in radians in the range [-Math.PI, Math.PI].
|
|
194
|
+
* @param {number} [north=0.0] The northernmost latitude in radians in the range [-Math.PI/2, Math.PI/2].
|
|
195
|
+
* @param {Rectangle} [result] The object onto which to store the result, or undefined if a new instance should be created.
|
|
196
|
+
* @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* const rectangle = Cesium.Rectangle.fromRadians(0.0, Math.PI/4, Math.PI/8, 3*Math.PI/4);
|
|
200
|
+
*/
|
|
201
|
+
static fromRadians(west, south, east, north, result) {
|
|
202
|
+
if (!defined(result)) {
|
|
203
|
+
return new Rectangle(west, south, east, north);
|
|
204
|
+
}
|
|
196
205
|
|
|
197
|
-
|
|
198
|
-
|
|
206
|
+
result.west = west ?? 0.0;
|
|
207
|
+
result.south = south ?? 0.0;
|
|
208
|
+
result.east = east ?? 0.0;
|
|
209
|
+
result.north = north ?? 0.0;
|
|
199
210
|
|
|
200
|
-
|
|
201
|
-
* Creates a rectangle given the boundary longitude and latitude in radians.
|
|
202
|
-
*
|
|
203
|
-
* @param {number} [west=0.0] The westernmost longitude in radians in the range [-Math.PI, Math.PI].
|
|
204
|
-
* @param {number} [south=0.0] The southernmost latitude in radians in the range [-Math.PI/2, Math.PI/2].
|
|
205
|
-
* @param {number} [east=0.0] The easternmost longitude in radians in the range [-Math.PI, Math.PI].
|
|
206
|
-
* @param {number} [north=0.0] The northernmost latitude in radians in the range [-Math.PI/2, Math.PI/2].
|
|
207
|
-
* @param {Rectangle} [result] The object onto which to store the result, or undefined if a new instance should be created.
|
|
208
|
-
* @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided.
|
|
209
|
-
*
|
|
210
|
-
* @example
|
|
211
|
-
* const rectangle = Cesium.Rectangle.fromRadians(0.0, Math.PI/4, Math.PI/8, 3*Math.PI/4);
|
|
212
|
-
*/
|
|
213
|
-
Rectangle.fromRadians = function (west, south, east, north, result) {
|
|
214
|
-
if (!defined(result)) {
|
|
215
|
-
return new Rectangle(west, south, east, north);
|
|
211
|
+
return result;
|
|
216
212
|
}
|
|
217
213
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
214
|
+
/**
|
|
215
|
+
* Creates the smallest possible Rectangle that encloses all positions in the provided array.
|
|
216
|
+
*
|
|
217
|
+
* @param {Cartographic[]} cartographics The list of Cartographic instances.
|
|
218
|
+
* @param {Rectangle} [result] The object onto which to store the result, or undefined if a new instance should be created.
|
|
219
|
+
* @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided.
|
|
220
|
+
*/
|
|
221
|
+
static fromCartographicArray(cartographics, result) {
|
|
222
|
+
//>>includeStart('debug', pragmas.debug);
|
|
223
|
+
Check.defined("cartographics", cartographics);
|
|
224
|
+
//>>includeEnd('debug');
|
|
225
|
+
|
|
226
|
+
let west = Number.MAX_VALUE;
|
|
227
|
+
let east = -Number.MAX_VALUE;
|
|
228
|
+
let westOverIDL = Number.MAX_VALUE;
|
|
229
|
+
let eastOverIDL = -Number.MAX_VALUE;
|
|
230
|
+
let south = Number.MAX_VALUE;
|
|
231
|
+
let north = -Number.MAX_VALUE;
|
|
232
|
+
|
|
233
|
+
for (let i = 0, len = cartographics.length; i < len; i++) {
|
|
234
|
+
const position = cartographics[i];
|
|
235
|
+
west = Math.min(west, position.longitude);
|
|
236
|
+
east = Math.max(east, position.longitude);
|
|
237
|
+
south = Math.min(south, position.latitude);
|
|
238
|
+
north = Math.max(north, position.latitude);
|
|
239
|
+
|
|
240
|
+
const lonAdjusted =
|
|
241
|
+
position.longitude >= 0
|
|
242
|
+
? position.longitude
|
|
243
|
+
: position.longitude + CesiumMath.TWO_PI;
|
|
244
|
+
westOverIDL = Math.min(westOverIDL, lonAdjusted);
|
|
245
|
+
eastOverIDL = Math.max(eastOverIDL, lonAdjusted);
|
|
246
|
+
}
|
|
222
247
|
|
|
223
|
-
|
|
224
|
-
|
|
248
|
+
if (east - west > eastOverIDL - westOverIDL) {
|
|
249
|
+
west = westOverIDL;
|
|
250
|
+
east = eastOverIDL;
|
|
225
251
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
let north = -Number.MAX_VALUE;
|
|
244
|
-
|
|
245
|
-
for (let i = 0, len = cartographics.length; i < len; i++) {
|
|
246
|
-
const position = cartographics[i];
|
|
247
|
-
west = Math.min(west, position.longitude);
|
|
248
|
-
east = Math.max(east, position.longitude);
|
|
249
|
-
south = Math.min(south, position.latitude);
|
|
250
|
-
north = Math.max(north, position.latitude);
|
|
251
|
-
|
|
252
|
-
const lonAdjusted =
|
|
253
|
-
position.longitude >= 0
|
|
254
|
-
? position.longitude
|
|
255
|
-
: position.longitude + CesiumMath.TWO_PI;
|
|
256
|
-
westOverIDL = Math.min(westOverIDL, lonAdjusted);
|
|
257
|
-
eastOverIDL = Math.max(eastOverIDL, lonAdjusted);
|
|
252
|
+
if (east > CesiumMath.PI) {
|
|
253
|
+
east = east - CesiumMath.TWO_PI;
|
|
254
|
+
}
|
|
255
|
+
if (west > CesiumMath.PI) {
|
|
256
|
+
west = west - CesiumMath.TWO_PI;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (!defined(result)) {
|
|
261
|
+
return new Rectangle(west, south, east, north);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
result.west = west;
|
|
265
|
+
result.south = south;
|
|
266
|
+
result.east = east;
|
|
267
|
+
result.north = north;
|
|
268
|
+
return result;
|
|
258
269
|
}
|
|
259
270
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
271
|
+
/**
|
|
272
|
+
* Creates the smallest possible Rectangle that encloses all positions in the provided array.
|
|
273
|
+
*
|
|
274
|
+
* @param {Cartesian3[]} cartesians The list of Cartesian instances.
|
|
275
|
+
* @param {Ellipsoid} [ellipsoid=Ellipsoid.default] The ellipsoid the cartesians are on.
|
|
276
|
+
* @param {Rectangle} [result] The object onto which to store the result, or undefined if a new instance should be created.
|
|
277
|
+
* @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided.
|
|
278
|
+
*/
|
|
279
|
+
static fromCartesianArray(cartesians, ellipsoid, result) {
|
|
280
|
+
//>>includeStart('debug', pragmas.debug);
|
|
281
|
+
Check.defined("cartesians", cartesians);
|
|
282
|
+
//>>includeEnd('debug');
|
|
283
|
+
ellipsoid = ellipsoid ?? Ellipsoid.default;
|
|
284
|
+
|
|
285
|
+
let west = Number.MAX_VALUE;
|
|
286
|
+
let east = -Number.MAX_VALUE;
|
|
287
|
+
let westOverIDL = Number.MAX_VALUE;
|
|
288
|
+
let eastOverIDL = -Number.MAX_VALUE;
|
|
289
|
+
let south = Number.MAX_VALUE;
|
|
290
|
+
let north = -Number.MAX_VALUE;
|
|
291
|
+
|
|
292
|
+
for (let i = 0, len = cartesians.length; i < len; i++) {
|
|
293
|
+
const position = ellipsoid.cartesianToCartographic(cartesians[i]);
|
|
294
|
+
west = Math.min(west, position.longitude);
|
|
295
|
+
east = Math.max(east, position.longitude);
|
|
296
|
+
south = Math.min(south, position.latitude);
|
|
297
|
+
north = Math.max(north, position.latitude);
|
|
298
|
+
|
|
299
|
+
const lonAdjusted =
|
|
300
|
+
position.longitude >= 0
|
|
301
|
+
? position.longitude
|
|
302
|
+
: position.longitude + CesiumMath.TWO_PI;
|
|
303
|
+
westOverIDL = Math.min(westOverIDL, lonAdjusted);
|
|
304
|
+
eastOverIDL = Math.max(eastOverIDL, lonAdjusted);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (east - west > eastOverIDL - westOverIDL) {
|
|
308
|
+
west = westOverIDL;
|
|
309
|
+
east = eastOverIDL;
|
|
263
310
|
|
|
264
|
-
|
|
265
|
-
|
|
311
|
+
if (east > CesiumMath.PI) {
|
|
312
|
+
east = east - CesiumMath.TWO_PI;
|
|
313
|
+
}
|
|
314
|
+
if (west > CesiumMath.PI) {
|
|
315
|
+
west = west - CesiumMath.TWO_PI;
|
|
316
|
+
}
|
|
266
317
|
}
|
|
267
|
-
|
|
268
|
-
|
|
318
|
+
|
|
319
|
+
if (!defined(result)) {
|
|
320
|
+
return new Rectangle(west, south, east, north);
|
|
269
321
|
}
|
|
270
|
-
}
|
|
271
322
|
|
|
272
|
-
|
|
273
|
-
|
|
323
|
+
result.west = west;
|
|
324
|
+
result.south = south;
|
|
325
|
+
result.east = east;
|
|
326
|
+
result.north = north;
|
|
327
|
+
return result;
|
|
274
328
|
}
|
|
275
329
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
}
|
|
330
|
+
/**
|
|
331
|
+
* Create a rectangle from a bounding sphere, ignoring height.
|
|
332
|
+
*
|
|
333
|
+
*
|
|
334
|
+
* @param {BoundingSphere} boundingSphere The bounding sphere.
|
|
335
|
+
* @param {Ellipsoid} [ellipsoid=Ellipsoid.default] The ellipsoid.
|
|
336
|
+
* @param {Rectangle} [result] The object onto which to store the result, or undefined if a new instance should be created.
|
|
337
|
+
* @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided.
|
|
338
|
+
*/
|
|
339
|
+
static fromBoundingSphere(boundingSphere, ellipsoid, result) {
|
|
340
|
+
//>>includeStart('debug', pragmas.debug);
|
|
341
|
+
Check.typeOf.object("boundingSphere", boundingSphere);
|
|
342
|
+
//>>includeEnd('debug');
|
|
282
343
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
*
|
|
286
|
-
* @param {Cartesian3[]} cartesians The list of Cartesian instances.
|
|
287
|
-
* @param {Ellipsoid} [ellipsoid=Ellipsoid.default] The ellipsoid the cartesians are on.
|
|
288
|
-
* @param {Rectangle} [result] The object onto which to store the result, or undefined if a new instance should be created.
|
|
289
|
-
* @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided.
|
|
290
|
-
*/
|
|
291
|
-
Rectangle.fromCartesianArray = function (cartesians, ellipsoid, result) {
|
|
292
|
-
//>>includeStart('debug', pragmas.debug);
|
|
293
|
-
Check.defined("cartesians", cartesians);
|
|
294
|
-
//>>includeEnd('debug');
|
|
295
|
-
ellipsoid = ellipsoid ?? Ellipsoid.default;
|
|
296
|
-
|
|
297
|
-
let west = Number.MAX_VALUE;
|
|
298
|
-
let east = -Number.MAX_VALUE;
|
|
299
|
-
let westOverIDL = Number.MAX_VALUE;
|
|
300
|
-
let eastOverIDL = -Number.MAX_VALUE;
|
|
301
|
-
let south = Number.MAX_VALUE;
|
|
302
|
-
let north = -Number.MAX_VALUE;
|
|
303
|
-
|
|
304
|
-
for (let i = 0, len = cartesians.length; i < len; i++) {
|
|
305
|
-
const position = ellipsoid.cartesianToCartographic(cartesians[i]);
|
|
306
|
-
west = Math.min(west, position.longitude);
|
|
307
|
-
east = Math.max(east, position.longitude);
|
|
308
|
-
south = Math.min(south, position.latitude);
|
|
309
|
-
north = Math.max(north, position.latitude);
|
|
310
|
-
|
|
311
|
-
const lonAdjusted =
|
|
312
|
-
position.longitude >= 0
|
|
313
|
-
? position.longitude
|
|
314
|
-
: position.longitude + CesiumMath.TWO_PI;
|
|
315
|
-
westOverIDL = Math.min(westOverIDL, lonAdjusted);
|
|
316
|
-
eastOverIDL = Math.max(eastOverIDL, lonAdjusted);
|
|
317
|
-
}
|
|
344
|
+
const center = boundingSphere.center;
|
|
345
|
+
const radius = boundingSphere.radius;
|
|
318
346
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
347
|
+
if (!defined(ellipsoid)) {
|
|
348
|
+
ellipsoid = Ellipsoid.default;
|
|
349
|
+
}
|
|
322
350
|
|
|
323
|
-
if (
|
|
324
|
-
|
|
351
|
+
if (!defined(result)) {
|
|
352
|
+
result = new Rectangle();
|
|
325
353
|
}
|
|
326
|
-
|
|
327
|
-
|
|
354
|
+
|
|
355
|
+
if (Cartesian3.equals(center, Cartesian3.ZERO)) {
|
|
356
|
+
Rectangle.clone(Rectangle.MAX_VALUE, result);
|
|
357
|
+
return result;
|
|
328
358
|
}
|
|
329
|
-
}
|
|
330
359
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
360
|
+
const fromENU = Transforms.eastNorthUpToFixedFrame(
|
|
361
|
+
center,
|
|
362
|
+
ellipsoid,
|
|
363
|
+
fromBoundingSphereMatrixScratch,
|
|
364
|
+
);
|
|
365
|
+
const east = Matrix4.multiplyByPointAsVector(
|
|
366
|
+
fromENU,
|
|
367
|
+
Cartesian3.UNIT_X,
|
|
368
|
+
fromBoundingSphereEastScratch,
|
|
369
|
+
);
|
|
370
|
+
Cartesian3.normalize(east, east);
|
|
371
|
+
const north = Matrix4.multiplyByPointAsVector(
|
|
372
|
+
fromENU,
|
|
373
|
+
Cartesian3.UNIT_Y,
|
|
374
|
+
fromBoundingSphereNorthScratch,
|
|
375
|
+
);
|
|
376
|
+
Cartesian3.normalize(north, north);
|
|
334
377
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
result.east = east;
|
|
338
|
-
result.north = north;
|
|
339
|
-
return result;
|
|
340
|
-
};
|
|
378
|
+
Cartesian3.multiplyByScalar(north, radius, north);
|
|
379
|
+
Cartesian3.multiplyByScalar(east, radius, east);
|
|
341
380
|
|
|
342
|
-
const
|
|
343
|
-
const
|
|
344
|
-
const fromBoundingSphereNorthScratch = new Cartesian3();
|
|
345
|
-
const fromBoundingSphereWestScratch = new Cartesian3();
|
|
346
|
-
const fromBoundingSphereSouthScratch = new Cartesian3();
|
|
347
|
-
const fromBoundingSpherePositionsScratch = new Array(5);
|
|
348
|
-
for (let n = 0; n < fromBoundingSpherePositionsScratch.length; ++n) {
|
|
349
|
-
fromBoundingSpherePositionsScratch[n] = new Cartesian3();
|
|
350
|
-
}
|
|
351
|
-
/**
|
|
352
|
-
* Create a rectangle from a bounding sphere, ignoring height.
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
* @param {BoundingSphere} boundingSphere The bounding sphere.
|
|
356
|
-
* @param {Ellipsoid} [ellipsoid=Ellipsoid.default] The ellipsoid.
|
|
357
|
-
* @param {Rectangle} [result] The object onto which to store the result, or undefined if a new instance should be created.
|
|
358
|
-
* @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided.
|
|
359
|
-
*/
|
|
360
|
-
Rectangle.fromBoundingSphere = function (boundingSphere, ellipsoid, result) {
|
|
361
|
-
//>>includeStart('debug', pragmas.debug);
|
|
362
|
-
Check.typeOf.object("boundingSphere", boundingSphere);
|
|
363
|
-
//>>includeEnd('debug');
|
|
381
|
+
const south = Cartesian3.negate(north, fromBoundingSphereSouthScratch);
|
|
382
|
+
const west = Cartesian3.negate(east, fromBoundingSphereWestScratch);
|
|
364
383
|
|
|
365
|
-
|
|
366
|
-
const radius = boundingSphere.radius;
|
|
384
|
+
const positions = fromBoundingSpherePositionsScratch;
|
|
367
385
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
386
|
+
// North
|
|
387
|
+
let corner = positions[0];
|
|
388
|
+
Cartesian3.add(center, north, corner);
|
|
371
389
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
390
|
+
// West
|
|
391
|
+
corner = positions[1];
|
|
392
|
+
Cartesian3.add(center, west, corner);
|
|
375
393
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
}
|
|
394
|
+
// South
|
|
395
|
+
corner = positions[2];
|
|
396
|
+
Cartesian3.add(center, south, corner);
|
|
380
397
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
fromBoundingSphereMatrixScratch,
|
|
385
|
-
);
|
|
386
|
-
const east = Matrix4.multiplyByPointAsVector(
|
|
387
|
-
fromENU,
|
|
388
|
-
Cartesian3.UNIT_X,
|
|
389
|
-
fromBoundingSphereEastScratch,
|
|
390
|
-
);
|
|
391
|
-
Cartesian3.normalize(east, east);
|
|
392
|
-
const north = Matrix4.multiplyByPointAsVector(
|
|
393
|
-
fromENU,
|
|
394
|
-
Cartesian3.UNIT_Y,
|
|
395
|
-
fromBoundingSphereNorthScratch,
|
|
396
|
-
);
|
|
397
|
-
Cartesian3.normalize(north, north);
|
|
398
|
-
|
|
399
|
-
Cartesian3.multiplyByScalar(north, radius, north);
|
|
400
|
-
Cartesian3.multiplyByScalar(east, radius, east);
|
|
401
|
-
|
|
402
|
-
const south = Cartesian3.negate(north, fromBoundingSphereSouthScratch);
|
|
403
|
-
const west = Cartesian3.negate(east, fromBoundingSphereWestScratch);
|
|
404
|
-
|
|
405
|
-
const positions = fromBoundingSpherePositionsScratch;
|
|
406
|
-
|
|
407
|
-
// North
|
|
408
|
-
let corner = positions[0];
|
|
409
|
-
Cartesian3.add(center, north, corner);
|
|
410
|
-
|
|
411
|
-
// West
|
|
412
|
-
corner = positions[1];
|
|
413
|
-
Cartesian3.add(center, west, corner);
|
|
414
|
-
|
|
415
|
-
// South
|
|
416
|
-
corner = positions[2];
|
|
417
|
-
Cartesian3.add(center, south, corner);
|
|
418
|
-
|
|
419
|
-
// East
|
|
420
|
-
corner = positions[3];
|
|
421
|
-
Cartesian3.add(center, east, corner);
|
|
422
|
-
|
|
423
|
-
positions[4] = center;
|
|
424
|
-
|
|
425
|
-
return Rectangle.fromCartesianArray(positions, ellipsoid, result);
|
|
426
|
-
};
|
|
398
|
+
// East
|
|
399
|
+
corner = positions[3];
|
|
400
|
+
Cartesian3.add(center, east, corner);
|
|
427
401
|
|
|
428
|
-
|
|
429
|
-
* Duplicates a Rectangle.
|
|
430
|
-
*
|
|
431
|
-
* @param {Rectangle} rectangle The rectangle to clone.
|
|
432
|
-
* @param {Rectangle} [result] The object onto which to store the result, or undefined if a new instance should be created.
|
|
433
|
-
* @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided. (Returns undefined if rectangle is undefined)
|
|
434
|
-
*/
|
|
435
|
-
Rectangle.clone = function (rectangle, result) {
|
|
436
|
-
if (!defined(rectangle)) {
|
|
437
|
-
return undefined;
|
|
438
|
-
}
|
|
402
|
+
positions[4] = center;
|
|
439
403
|
|
|
440
|
-
|
|
441
|
-
return new Rectangle(
|
|
442
|
-
rectangle.west,
|
|
443
|
-
rectangle.south,
|
|
444
|
-
rectangle.east,
|
|
445
|
-
rectangle.north,
|
|
446
|
-
);
|
|
404
|
+
return Rectangle.fromCartesianArray(positions, ellipsoid, result);
|
|
447
405
|
}
|
|
448
406
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
}
|
|
407
|
+
/**
|
|
408
|
+
* Duplicates a Rectangle.
|
|
409
|
+
*
|
|
410
|
+
* @param {Rectangle} rectangle The rectangle to clone.
|
|
411
|
+
* @param {Rectangle} [result] The object onto which to store the result, or undefined if a new instance should be created.
|
|
412
|
+
* @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided. (Returns undefined if rectangle is undefined)
|
|
413
|
+
*/
|
|
414
|
+
static clone(rectangle, result) {
|
|
415
|
+
if (!defined(rectangle)) {
|
|
416
|
+
return undefined;
|
|
417
|
+
}
|
|
455
418
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
* @returns {boolean} <code>true</code> if left and right are within the provided epsilon, <code>false</code> otherwise.
|
|
465
|
-
*/
|
|
466
|
-
Rectangle.equalsEpsilon = function (left, right, absoluteEpsilon) {
|
|
467
|
-
absoluteEpsilon = absoluteEpsilon ?? 0;
|
|
468
|
-
|
|
469
|
-
return (
|
|
470
|
-
left === right ||
|
|
471
|
-
(defined(left) &&
|
|
472
|
-
defined(right) &&
|
|
473
|
-
Math.abs(left.west - right.west) <= absoluteEpsilon &&
|
|
474
|
-
Math.abs(left.south - right.south) <= absoluteEpsilon &&
|
|
475
|
-
Math.abs(left.east - right.east) <= absoluteEpsilon &&
|
|
476
|
-
Math.abs(left.north - right.north) <= absoluteEpsilon)
|
|
477
|
-
);
|
|
478
|
-
};
|
|
419
|
+
if (!defined(result)) {
|
|
420
|
+
return new Rectangle(
|
|
421
|
+
rectangle.west,
|
|
422
|
+
rectangle.south,
|
|
423
|
+
rectangle.east,
|
|
424
|
+
rectangle.north,
|
|
425
|
+
);
|
|
426
|
+
}
|
|
479
427
|
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
Rectangle.prototype.clone = function (result) {
|
|
487
|
-
return Rectangle.clone(this, result);
|
|
488
|
-
};
|
|
428
|
+
result.west = rectangle.west;
|
|
429
|
+
result.south = rectangle.south;
|
|
430
|
+
result.east = rectangle.east;
|
|
431
|
+
result.north = rectangle.north;
|
|
432
|
+
return result;
|
|
433
|
+
}
|
|
489
434
|
|
|
490
|
-
/**
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
435
|
+
/**
|
|
436
|
+
* Compares the provided Rectangles componentwise and returns
|
|
437
|
+
* <code>true</code> if they pass an absolute or relative tolerance test,
|
|
438
|
+
* <code>false</code> otherwise.
|
|
439
|
+
*
|
|
440
|
+
* @param {Rectangle} [left] The first Rectangle.
|
|
441
|
+
* @param {Rectangle} [right] The second Rectangle.
|
|
442
|
+
* @param {number} [absoluteEpsilon=0] The absolute epsilon tolerance to use for equality testing.
|
|
443
|
+
* @returns {boolean} <code>true</code> if left and right are within the provided epsilon, <code>false</code> otherwise.
|
|
444
|
+
*/
|
|
445
|
+
static equalsEpsilon(left, right, absoluteEpsilon) {
|
|
446
|
+
absoluteEpsilon = absoluteEpsilon ?? 0;
|
|
447
|
+
|
|
448
|
+
return (
|
|
449
|
+
left === right ||
|
|
450
|
+
(defined(left) &&
|
|
451
|
+
defined(right) &&
|
|
452
|
+
Math.abs(left.west - right.west) <= absoluteEpsilon &&
|
|
453
|
+
Math.abs(left.south - right.south) <= absoluteEpsilon &&
|
|
454
|
+
Math.abs(left.east - right.east) <= absoluteEpsilon &&
|
|
455
|
+
Math.abs(left.north - right.north) <= absoluteEpsilon)
|
|
456
|
+
);
|
|
457
|
+
}
|
|
500
458
|
|
|
501
|
-
/**
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
return (
|
|
511
|
-
left === right ||
|
|
512
|
-
(defined(left) &&
|
|
513
|
-
defined(right) &&
|
|
514
|
-
left.west === right.west &&
|
|
515
|
-
left.south === right.south &&
|
|
516
|
-
left.east === right.east &&
|
|
517
|
-
left.north === right.north)
|
|
518
|
-
);
|
|
519
|
-
};
|
|
459
|
+
/**
|
|
460
|
+
* Duplicates this Rectangle.
|
|
461
|
+
*
|
|
462
|
+
* @param {Rectangle} [result] The object onto which to store the result.
|
|
463
|
+
* @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided.
|
|
464
|
+
*/
|
|
465
|
+
clone(result) {
|
|
466
|
+
return Rectangle.clone(this, result);
|
|
467
|
+
}
|
|
520
468
|
|
|
521
|
-
/**
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
return Rectangle.equalsEpsilon(this, other, epsilon);
|
|
532
|
-
};
|
|
469
|
+
/**
|
|
470
|
+
* Compares the provided Rectangle with this Rectangle componentwise and returns
|
|
471
|
+
* <code>true</code> if they are equal, <code>false</code> otherwise.
|
|
472
|
+
*
|
|
473
|
+
* @param {Rectangle} [other] The Rectangle to compare.
|
|
474
|
+
* @returns {boolean} <code>true</code> if the Rectangles are equal, <code>false</code> otherwise.
|
|
475
|
+
*/
|
|
476
|
+
equals(other) {
|
|
477
|
+
return Rectangle.equals(this, other);
|
|
478
|
+
}
|
|
533
479
|
|
|
534
|
-
/**
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
-CesiumMath.PI_OVER_TWO,
|
|
554
|
-
);
|
|
555
|
-
Check.typeOf.number.lessThanOrEquals("north", north, CesiumMath.PI_OVER_TWO);
|
|
480
|
+
/**
|
|
481
|
+
* Compares the provided rectangles and returns <code>true</code> if they are equal,
|
|
482
|
+
* <code>false</code> otherwise.
|
|
483
|
+
*
|
|
484
|
+
* @param {Rectangle} [left] The first Rectangle.
|
|
485
|
+
* @param {Rectangle} [right] The second Rectangle.
|
|
486
|
+
* @returns {boolean} <code>true</code> if left and right are equal; otherwise <code>false</code>.
|
|
487
|
+
*/
|
|
488
|
+
static equals(left, right) {
|
|
489
|
+
return (
|
|
490
|
+
left === right ||
|
|
491
|
+
(defined(left) &&
|
|
492
|
+
defined(right) &&
|
|
493
|
+
left.west === right.west &&
|
|
494
|
+
left.south === right.south &&
|
|
495
|
+
left.east === right.east &&
|
|
496
|
+
left.north === right.north)
|
|
497
|
+
);
|
|
498
|
+
}
|
|
556
499
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
500
|
+
/**
|
|
501
|
+
* Compares the provided Rectangle with this Rectangle componentwise and returns
|
|
502
|
+
* <code>true</code> if they are within the provided epsilon,
|
|
503
|
+
* <code>false</code> otherwise.
|
|
504
|
+
*
|
|
505
|
+
* @param {Rectangle} [other] The Rectangle to compare.
|
|
506
|
+
* @param {number} [epsilon=0] The epsilon to use for equality testing.
|
|
507
|
+
* @returns {boolean} <code>true</code> if the Rectangles are within the provided epsilon, <code>false</code> otherwise.
|
|
508
|
+
*/
|
|
509
|
+
equalsEpsilon(other, epsilon) {
|
|
510
|
+
return Rectangle.equalsEpsilon(this, other, epsilon);
|
|
511
|
+
}
|
|
564
512
|
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
513
|
+
/**
|
|
514
|
+
* Checks a Rectangle's properties and throws if they are not in valid ranges.
|
|
515
|
+
*
|
|
516
|
+
* @param {Rectangle} rectangle The rectangle to validate
|
|
517
|
+
*
|
|
518
|
+
* @exception {DeveloperError} <code>north</code> must be in the interval [<code>-Pi/2</code>, <code>Pi/2</code>].
|
|
519
|
+
* @exception {DeveloperError} <code>south</code> must be in the interval [<code>-Pi/2</code>, <code>Pi/2</code>].
|
|
520
|
+
* @exception {DeveloperError} <code>east</code> must be in the interval [<code>-Pi</code>, <code>Pi</code>].
|
|
521
|
+
* @exception {DeveloperError} <code>west</code> must be in the interval [<code>-Pi</code>, <code>Pi</code>].
|
|
522
|
+
* @private
|
|
523
|
+
*/
|
|
524
|
+
static _validate(rectangle) {
|
|
525
|
+
//>>includeStart('debug', pragmas.debug);
|
|
526
|
+
Check.typeOf.object("rectangle", rectangle);
|
|
527
|
+
|
|
528
|
+
const north = rectangle.north;
|
|
529
|
+
Check.typeOf.number.greaterThanOrEquals(
|
|
530
|
+
"north",
|
|
531
|
+
north,
|
|
532
|
+
-CesiumMath.PI_OVER_TWO,
|
|
533
|
+
);
|
|
534
|
+
Check.typeOf.number.lessThanOrEquals(
|
|
535
|
+
"north",
|
|
536
|
+
north,
|
|
537
|
+
CesiumMath.PI_OVER_TWO,
|
|
538
|
+
);
|
|
568
539
|
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
540
|
+
const south = rectangle.south;
|
|
541
|
+
Check.typeOf.number.greaterThanOrEquals(
|
|
542
|
+
"south",
|
|
543
|
+
south,
|
|
544
|
+
-CesiumMath.PI_OVER_TWO,
|
|
545
|
+
);
|
|
546
|
+
Check.typeOf.number.lessThanOrEquals(
|
|
547
|
+
"south",
|
|
548
|
+
south,
|
|
549
|
+
CesiumMath.PI_OVER_TWO,
|
|
550
|
+
);
|
|
574
551
|
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
* @param {Rectangle} rectangle The rectangle for which to find the corner
|
|
579
|
-
* @param {Cartographic} [result] The object onto which to store the result.
|
|
580
|
-
* @returns {Cartographic} The modified result parameter or a new Cartographic instance if none was provided.
|
|
581
|
-
*/
|
|
582
|
-
Rectangle.southwest = function (rectangle, result) {
|
|
583
|
-
//>>includeStart('debug', pragmas.debug);
|
|
584
|
-
Check.typeOf.object("rectangle", rectangle);
|
|
585
|
-
//>>includeEnd('debug');
|
|
552
|
+
const west = rectangle.west;
|
|
553
|
+
Check.typeOf.number.greaterThanOrEquals("west", west, -Math.PI);
|
|
554
|
+
Check.typeOf.number.lessThanOrEquals("west", west, Math.PI);
|
|
586
555
|
|
|
587
|
-
|
|
588
|
-
|
|
556
|
+
const east = rectangle.east;
|
|
557
|
+
Check.typeOf.number.greaterThanOrEquals("east", east, -Math.PI);
|
|
558
|
+
Check.typeOf.number.lessThanOrEquals("east", east, Math.PI);
|
|
559
|
+
//>>includeEnd('debug');
|
|
589
560
|
}
|
|
590
|
-
result.longitude = rectangle.west;
|
|
591
|
-
result.latitude = rectangle.south;
|
|
592
|
-
result.height = 0.0;
|
|
593
|
-
return result;
|
|
594
|
-
};
|
|
595
561
|
|
|
596
|
-
/**
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
562
|
+
/**
|
|
563
|
+
* Computes the southwest corner of a rectangle.
|
|
564
|
+
*
|
|
565
|
+
* @param {Rectangle} rectangle The rectangle for which to find the corner
|
|
566
|
+
* @param {Cartographic} [result] The object onto which to store the result.
|
|
567
|
+
* @returns {Cartographic} The modified result parameter or a new Cartographic instance if none was provided.
|
|
568
|
+
*/
|
|
569
|
+
static southwest(rectangle, result) {
|
|
570
|
+
//>>includeStart('debug', pragmas.debug);
|
|
571
|
+
Check.typeOf.object("rectangle", rectangle);
|
|
572
|
+
//>>includeEnd('debug');
|
|
607
573
|
|
|
608
|
-
|
|
609
|
-
|
|
574
|
+
if (!defined(result)) {
|
|
575
|
+
return new Cartographic(rectangle.west, rectangle.south);
|
|
576
|
+
}
|
|
577
|
+
result.longitude = rectangle.west;
|
|
578
|
+
result.latitude = rectangle.south;
|
|
579
|
+
result.height = 0.0;
|
|
580
|
+
return result;
|
|
610
581
|
}
|
|
611
|
-
result.longitude = rectangle.west;
|
|
612
|
-
result.latitude = rectangle.north;
|
|
613
|
-
result.height = 0.0;
|
|
614
|
-
return result;
|
|
615
|
-
};
|
|
616
582
|
|
|
617
|
-
/**
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
583
|
+
/**
|
|
584
|
+
* Computes the northwest corner of a rectangle.
|
|
585
|
+
*
|
|
586
|
+
* @param {Rectangle} rectangle The rectangle for which to find the corner
|
|
587
|
+
* @param {Cartographic} [result] The object onto which to store the result.
|
|
588
|
+
* @returns {Cartographic} The modified result parameter or a new Cartographic instance if none was provided.
|
|
589
|
+
*/
|
|
590
|
+
static northwest(rectangle, result) {
|
|
591
|
+
//>>includeStart('debug', pragmas.debug);
|
|
592
|
+
Check.typeOf.object("rectangle", rectangle);
|
|
593
|
+
//>>includeEnd('debug');
|
|
628
594
|
|
|
629
|
-
|
|
630
|
-
|
|
595
|
+
if (!defined(result)) {
|
|
596
|
+
return new Cartographic(rectangle.west, rectangle.north);
|
|
597
|
+
}
|
|
598
|
+
result.longitude = rectangle.west;
|
|
599
|
+
result.latitude = rectangle.north;
|
|
600
|
+
result.height = 0.0;
|
|
601
|
+
return result;
|
|
631
602
|
}
|
|
632
|
-
result.longitude = rectangle.east;
|
|
633
|
-
result.latitude = rectangle.north;
|
|
634
|
-
result.height = 0.0;
|
|
635
|
-
return result;
|
|
636
|
-
};
|
|
637
603
|
|
|
638
|
-
/**
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
604
|
+
/**
|
|
605
|
+
* Computes the northeast corner of a rectangle.
|
|
606
|
+
*
|
|
607
|
+
* @param {Rectangle} rectangle The rectangle for which to find the corner
|
|
608
|
+
* @param {Cartographic} [result] The object onto which to store the result.
|
|
609
|
+
* @returns {Cartographic} The modified result parameter or a new Cartographic instance if none was provided.
|
|
610
|
+
*/
|
|
611
|
+
static northeast(rectangle, result) {
|
|
612
|
+
//>>includeStart('debug', pragmas.debug);
|
|
613
|
+
Check.typeOf.object("rectangle", rectangle);
|
|
614
|
+
//>>includeEnd('debug');
|
|
649
615
|
|
|
650
|
-
|
|
651
|
-
|
|
616
|
+
if (!defined(result)) {
|
|
617
|
+
return new Cartographic(rectangle.east, rectangle.north);
|
|
618
|
+
}
|
|
619
|
+
result.longitude = rectangle.east;
|
|
620
|
+
result.latitude = rectangle.north;
|
|
621
|
+
result.height = 0.0;
|
|
622
|
+
return result;
|
|
652
623
|
}
|
|
653
|
-
result.longitude = rectangle.east;
|
|
654
|
-
result.latitude = rectangle.south;
|
|
655
|
-
result.height = 0.0;
|
|
656
|
-
return result;
|
|
657
|
-
};
|
|
658
624
|
|
|
659
|
-
/**
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
let east = rectangle.east;
|
|
672
|
-
const west = rectangle.west;
|
|
625
|
+
/**
|
|
626
|
+
* Computes the southeast corner of a rectangle.
|
|
627
|
+
*
|
|
628
|
+
* @param {Rectangle} rectangle The rectangle for which to find the corner
|
|
629
|
+
* @param {Cartographic} [result] The object onto which to store the result.
|
|
630
|
+
* @returns {Cartographic} The modified result parameter or a new Cartographic instance if none was provided.
|
|
631
|
+
*/
|
|
632
|
+
static southeast(rectangle, result) {
|
|
633
|
+
//>>includeStart('debug', pragmas.debug);
|
|
634
|
+
Check.typeOf.object("rectangle", rectangle);
|
|
635
|
+
//>>includeEnd('debug');
|
|
673
636
|
|
|
674
|
-
|
|
675
|
-
|
|
637
|
+
if (!defined(result)) {
|
|
638
|
+
return new Cartographic(rectangle.east, rectangle.south);
|
|
639
|
+
}
|
|
640
|
+
result.longitude = rectangle.east;
|
|
641
|
+
result.latitude = rectangle.south;
|
|
642
|
+
result.height = 0.0;
|
|
643
|
+
return result;
|
|
676
644
|
}
|
|
677
645
|
|
|
678
|
-
|
|
679
|
-
|
|
646
|
+
/**
|
|
647
|
+
* Computes the center of a rectangle.
|
|
648
|
+
*
|
|
649
|
+
* @param {Rectangle} rectangle The rectangle for which to find the center
|
|
650
|
+
* @param {Cartographic} [result] The object onto which to store the result.
|
|
651
|
+
* @returns {Cartographic} The modified result parameter or a new Cartographic instance if none was provided.
|
|
652
|
+
*/
|
|
653
|
+
static center(rectangle, result) {
|
|
654
|
+
//>>includeStart('debug', pragmas.debug);
|
|
655
|
+
Check.typeOf.object("rectangle", rectangle);
|
|
656
|
+
//>>includeEnd('debug');
|
|
680
657
|
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
}
|
|
658
|
+
let east = rectangle.east;
|
|
659
|
+
const west = rectangle.west;
|
|
684
660
|
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
return result;
|
|
689
|
-
};
|
|
661
|
+
if (east < west) {
|
|
662
|
+
east += CesiumMath.TWO_PI;
|
|
663
|
+
}
|
|
690
664
|
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
* latitude and longitude in radians and produces a correct intersection, taking into account the fact that
|
|
694
|
-
* the same angle can be represented with multiple values as well as the wrapping of longitude at the
|
|
695
|
-
* anti-meridian. For a simple intersection that ignores these factors and can be used with projected
|
|
696
|
-
* coordinates, see {@link Rectangle.simpleIntersection}.
|
|
697
|
-
*
|
|
698
|
-
* @param {Rectangle} rectangle On rectangle to find an intersection
|
|
699
|
-
* @param {Rectangle} otherRectangle Another rectangle to find an intersection
|
|
700
|
-
* @param {Rectangle} [result] The object onto which to store the result.
|
|
701
|
-
* @returns {Rectangle|undefined} The modified result parameter, a new Rectangle instance if none was provided or undefined if there is no intersection.
|
|
702
|
-
*/
|
|
703
|
-
Rectangle.intersection = function (rectangle, otherRectangle, result) {
|
|
704
|
-
//>>includeStart('debug', pragmas.debug);
|
|
705
|
-
Check.typeOf.object("rectangle", rectangle);
|
|
706
|
-
Check.typeOf.object("otherRectangle", otherRectangle);
|
|
707
|
-
//>>includeEnd('debug');
|
|
708
|
-
|
|
709
|
-
let rectangleEast = rectangle.east;
|
|
710
|
-
let rectangleWest = rectangle.west;
|
|
711
|
-
|
|
712
|
-
let otherRectangleEast = otherRectangle.east;
|
|
713
|
-
let otherRectangleWest = otherRectangle.west;
|
|
714
|
-
|
|
715
|
-
if (rectangleEast < rectangleWest && otherRectangleEast > 0.0) {
|
|
716
|
-
rectangleEast += CesiumMath.TWO_PI;
|
|
717
|
-
} else if (otherRectangleEast < otherRectangleWest && rectangleEast > 0.0) {
|
|
718
|
-
otherRectangleEast += CesiumMath.TWO_PI;
|
|
719
|
-
}
|
|
665
|
+
const longitude = CesiumMath.negativePiToPi((west + east) * 0.5);
|
|
666
|
+
const latitude = (rectangle.south + rectangle.north) * 0.5;
|
|
720
667
|
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
rectangleWest += CesiumMath.TWO_PI;
|
|
725
|
-
}
|
|
668
|
+
if (!defined(result)) {
|
|
669
|
+
return new Cartographic(longitude, latitude);
|
|
670
|
+
}
|
|
726
671
|
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
Math.min(rectangleEast, otherRectangleEast),
|
|
732
|
-
);
|
|
733
|
-
|
|
734
|
-
if (
|
|
735
|
-
(rectangle.west < rectangle.east ||
|
|
736
|
-
otherRectangle.west < otherRectangle.east) &&
|
|
737
|
-
east <= west
|
|
738
|
-
) {
|
|
739
|
-
return undefined;
|
|
672
|
+
result.longitude = longitude;
|
|
673
|
+
result.latitude = latitude;
|
|
674
|
+
result.height = 0.0;
|
|
675
|
+
return result;
|
|
740
676
|
}
|
|
741
677
|
|
|
742
|
-
|
|
743
|
-
|
|
678
|
+
/**
|
|
679
|
+
* Computes the intersection of two rectangles. This function assumes that the rectangle's coordinates are
|
|
680
|
+
* latitude and longitude in radians and produces a correct intersection, taking into account the fact that
|
|
681
|
+
* the same angle can be represented with multiple values as well as the wrapping of longitude at the
|
|
682
|
+
* anti-meridian. For a simple intersection that ignores these factors and can be used with projected
|
|
683
|
+
* coordinates, see {@link Rectangle.simpleIntersection}.
|
|
684
|
+
*
|
|
685
|
+
* @param {Rectangle} rectangle On rectangle to find an intersection
|
|
686
|
+
* @param {Rectangle} otherRectangle Another rectangle to find an intersection
|
|
687
|
+
* @param {Rectangle} [result] The object onto which to store the result.
|
|
688
|
+
* @returns {Rectangle|undefined} The modified result parameter, a new Rectangle instance if none was provided or undefined if there is no intersection.
|
|
689
|
+
*/
|
|
690
|
+
static intersection(rectangle, otherRectangle, result) {
|
|
691
|
+
//>>includeStart('debug', pragmas.debug);
|
|
692
|
+
Check.typeOf.object("rectangle", rectangle);
|
|
693
|
+
Check.typeOf.object("otherRectangle", otherRectangle);
|
|
694
|
+
//>>includeEnd('debug');
|
|
695
|
+
|
|
696
|
+
let rectangleEast = rectangle.east;
|
|
697
|
+
let rectangleWest = rectangle.west;
|
|
698
|
+
|
|
699
|
+
let otherRectangleEast = otherRectangle.east;
|
|
700
|
+
let otherRectangleWest = otherRectangle.west;
|
|
701
|
+
|
|
702
|
+
if (rectangleEast < rectangleWest && otherRectangleEast > 0.0) {
|
|
703
|
+
rectangleEast += CesiumMath.TWO_PI;
|
|
704
|
+
} else if (otherRectangleEast < otherRectangleWest && rectangleEast > 0.0) {
|
|
705
|
+
otherRectangleEast += CesiumMath.TWO_PI;
|
|
706
|
+
}
|
|
744
707
|
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
708
|
+
if (rectangleEast < rectangleWest && otherRectangleWest < 0.0) {
|
|
709
|
+
otherRectangleWest += CesiumMath.TWO_PI;
|
|
710
|
+
} else if (otherRectangleEast < otherRectangleWest && rectangleWest < 0.0) {
|
|
711
|
+
rectangleWest += CesiumMath.TWO_PI;
|
|
712
|
+
}
|
|
748
713
|
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
result.north = north;
|
|
756
|
-
return result;
|
|
757
|
-
};
|
|
714
|
+
const west = CesiumMath.negativePiToPi(
|
|
715
|
+
Math.max(rectangleWest, otherRectangleWest),
|
|
716
|
+
);
|
|
717
|
+
const east = CesiumMath.negativePiToPi(
|
|
718
|
+
Math.min(rectangleEast, otherRectangleEast),
|
|
719
|
+
);
|
|
758
720
|
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
* @param {Rectangle} otherRectangle Another rectangle to find an intersection
|
|
767
|
-
* @param {Rectangle} [result] The object onto which to store the result.
|
|
768
|
-
* @returns {Rectangle|undefined} The modified result parameter, a new Rectangle instance if none was provided or undefined if there is no intersection.
|
|
769
|
-
*/
|
|
770
|
-
Rectangle.simpleIntersection = function (rectangle, otherRectangle, result) {
|
|
771
|
-
//>>includeStart('debug', pragmas.debug);
|
|
772
|
-
Check.typeOf.object("rectangle", rectangle);
|
|
773
|
-
Check.typeOf.object("otherRectangle", otherRectangle);
|
|
774
|
-
//>>includeEnd('debug');
|
|
775
|
-
|
|
776
|
-
const west = Math.max(rectangle.west, otherRectangle.west);
|
|
777
|
-
const south = Math.max(rectangle.south, otherRectangle.south);
|
|
778
|
-
const east = Math.min(rectangle.east, otherRectangle.east);
|
|
779
|
-
const north = Math.min(rectangle.north, otherRectangle.north);
|
|
780
|
-
|
|
781
|
-
if (south >= north || west >= east) {
|
|
782
|
-
return undefined;
|
|
783
|
-
}
|
|
721
|
+
if (
|
|
722
|
+
(rectangle.west < rectangle.east ||
|
|
723
|
+
otherRectangle.west < otherRectangle.east) &&
|
|
724
|
+
east <= west
|
|
725
|
+
) {
|
|
726
|
+
return undefined;
|
|
727
|
+
}
|
|
784
728
|
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
}
|
|
729
|
+
const south = Math.max(rectangle.south, otherRectangle.south);
|
|
730
|
+
const north = Math.min(rectangle.north, otherRectangle.north);
|
|
788
731
|
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
result.north = north;
|
|
793
|
-
return result;
|
|
794
|
-
};
|
|
732
|
+
if (south >= north) {
|
|
733
|
+
return undefined;
|
|
734
|
+
}
|
|
795
735
|
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
Rectangle.union = function (rectangle, otherRectangle, result) {
|
|
805
|
-
//>>includeStart('debug', pragmas.debug);
|
|
806
|
-
Check.typeOf.object("rectangle", rectangle);
|
|
807
|
-
Check.typeOf.object("otherRectangle", otherRectangle);
|
|
808
|
-
//>>includeEnd('debug');
|
|
809
|
-
|
|
810
|
-
if (!defined(result)) {
|
|
811
|
-
result = new Rectangle();
|
|
736
|
+
if (!defined(result)) {
|
|
737
|
+
return new Rectangle(west, south, east, north);
|
|
738
|
+
}
|
|
739
|
+
result.west = west;
|
|
740
|
+
result.south = south;
|
|
741
|
+
result.east = east;
|
|
742
|
+
result.north = north;
|
|
743
|
+
return result;
|
|
812
744
|
}
|
|
813
745
|
|
|
814
|
-
|
|
815
|
-
|
|
746
|
+
/**
|
|
747
|
+
* Computes a simple intersection of two rectangles. Unlike {@link Rectangle.intersection}, this function
|
|
748
|
+
* does not attempt to put the angular coordinates into a consistent range or to account for crossing the
|
|
749
|
+
* anti-meridian. As such, it can be used for rectangles where the coordinates are not simply latitude
|
|
750
|
+
* and longitude (i.e. projected coordinates).
|
|
751
|
+
*
|
|
752
|
+
* @param {Rectangle} rectangle On rectangle to find an intersection
|
|
753
|
+
* @param {Rectangle} otherRectangle Another rectangle to find an intersection
|
|
754
|
+
* @param {Rectangle} [result] The object onto which to store the result.
|
|
755
|
+
* @returns {Rectangle|undefined} The modified result parameter, a new Rectangle instance if none was provided or undefined if there is no intersection.
|
|
756
|
+
*/
|
|
757
|
+
static simpleIntersection(rectangle, otherRectangle, result) {
|
|
758
|
+
//>>includeStart('debug', pragmas.debug);
|
|
759
|
+
Check.typeOf.object("rectangle", rectangle);
|
|
760
|
+
Check.typeOf.object("otherRectangle", otherRectangle);
|
|
761
|
+
//>>includeEnd('debug');
|
|
762
|
+
|
|
763
|
+
const west = Math.max(rectangle.west, otherRectangle.west);
|
|
764
|
+
const south = Math.max(rectangle.south, otherRectangle.south);
|
|
765
|
+
const east = Math.min(rectangle.east, otherRectangle.east);
|
|
766
|
+
const north = Math.min(rectangle.north, otherRectangle.north);
|
|
767
|
+
|
|
768
|
+
if (south >= north || west >= east) {
|
|
769
|
+
return undefined;
|
|
770
|
+
}
|
|
816
771
|
|
|
817
|
-
|
|
818
|
-
|
|
772
|
+
if (!defined(result)) {
|
|
773
|
+
return new Rectangle(west, south, east, north);
|
|
774
|
+
}
|
|
819
775
|
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
776
|
+
result.west = west;
|
|
777
|
+
result.south = south;
|
|
778
|
+
result.east = east;
|
|
779
|
+
result.north = north;
|
|
780
|
+
return result;
|
|
824
781
|
}
|
|
825
782
|
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
783
|
+
/**
|
|
784
|
+
* Computes a rectangle that is the union of two rectangles.
|
|
785
|
+
*
|
|
786
|
+
* @param {Rectangle} rectangle A rectangle to enclose in rectangle.
|
|
787
|
+
* @param {Rectangle} otherRectangle A rectangle to enclose in a rectangle.
|
|
788
|
+
* @param {Rectangle} [result] The object onto which to store the result.
|
|
789
|
+
* @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided.
|
|
790
|
+
*/
|
|
791
|
+
static union(rectangle, otherRectangle, result) {
|
|
792
|
+
//>>includeStart('debug', pragmas.debug);
|
|
793
|
+
Check.typeOf.object("rectangle", rectangle);
|
|
794
|
+
Check.typeOf.object("otherRectangle", otherRectangle);
|
|
795
|
+
//>>includeEnd('debug');
|
|
796
|
+
|
|
797
|
+
if (!defined(result)) {
|
|
798
|
+
result = new Rectangle();
|
|
799
|
+
}
|
|
831
800
|
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
);
|
|
835
|
-
const east = CesiumMath.negativePiToPi(
|
|
836
|
-
Math.max(rectangleEast, otherRectangleEast),
|
|
837
|
-
);
|
|
801
|
+
let rectangleEast = rectangle.east;
|
|
802
|
+
let rectangleWest = rectangle.west;
|
|
838
803
|
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
result.east = east;
|
|
842
|
-
result.north = Math.max(rectangle.north, otherRectangle.north);
|
|
804
|
+
let otherRectangleEast = otherRectangle.east;
|
|
805
|
+
let otherRectangleWest = otherRectangle.west;
|
|
843
806
|
|
|
844
|
-
|
|
845
|
-
|
|
807
|
+
if (rectangleEast < rectangleWest && otherRectangleEast > 0.0) {
|
|
808
|
+
rectangleEast += CesiumMath.TWO_PI;
|
|
809
|
+
} else if (otherRectangleEast < otherRectangleWest && rectangleEast > 0.0) {
|
|
810
|
+
otherRectangleEast += CesiumMath.TWO_PI;
|
|
811
|
+
}
|
|
846
812
|
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
* @param {Rectangle} [result] The object onto which to store the result.
|
|
853
|
-
* @returns {Rectangle} The modified result parameter or a new Rectangle instance if one was not provided.
|
|
854
|
-
*/
|
|
855
|
-
Rectangle.expand = function (rectangle, cartographic, result) {
|
|
856
|
-
//>>includeStart('debug', pragmas.debug);
|
|
857
|
-
Check.typeOf.object("rectangle", rectangle);
|
|
858
|
-
Check.typeOf.object("cartographic", cartographic);
|
|
859
|
-
//>>includeEnd('debug');
|
|
860
|
-
|
|
861
|
-
if (!defined(result)) {
|
|
862
|
-
result = new Rectangle();
|
|
863
|
-
}
|
|
813
|
+
if (rectangleEast < rectangleWest && otherRectangleWest < 0.0) {
|
|
814
|
+
otherRectangleWest += CesiumMath.TWO_PI;
|
|
815
|
+
} else if (otherRectangleEast < otherRectangleWest && rectangleWest < 0.0) {
|
|
816
|
+
rectangleWest += CesiumMath.TWO_PI;
|
|
817
|
+
}
|
|
864
818
|
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
819
|
+
const west = CesiumMath.negativePiToPi(
|
|
820
|
+
Math.min(rectangleWest, otherRectangleWest),
|
|
821
|
+
);
|
|
822
|
+
const east = CesiumMath.negativePiToPi(
|
|
823
|
+
Math.max(rectangleEast, otherRectangleEast),
|
|
824
|
+
);
|
|
869
825
|
|
|
870
|
-
|
|
871
|
-
|
|
826
|
+
result.west = west;
|
|
827
|
+
result.south = Math.min(rectangle.south, otherRectangle.south);
|
|
828
|
+
result.east = east;
|
|
829
|
+
result.north = Math.max(rectangle.north, otherRectangle.north);
|
|
872
830
|
|
|
873
|
-
|
|
874
|
-
* Returns true if the cartographic is on or inside the rectangle, false otherwise.
|
|
875
|
-
*
|
|
876
|
-
* @param {Rectangle} rectangle The rectangle
|
|
877
|
-
* @param {Cartographic} cartographic The cartographic to test.
|
|
878
|
-
* @returns {boolean} true if the provided cartographic is inside the rectangle, false otherwise.
|
|
879
|
-
*/
|
|
880
|
-
Rectangle.contains = function (rectangle, cartographic) {
|
|
881
|
-
//>>includeStart('debug', pragmas.debug);
|
|
882
|
-
Check.typeOf.object("rectangle", rectangle);
|
|
883
|
-
Check.typeOf.object("cartographic", cartographic);
|
|
884
|
-
//>>includeEnd('debug');
|
|
885
|
-
|
|
886
|
-
let longitude = cartographic.longitude;
|
|
887
|
-
const latitude = cartographic.latitude;
|
|
888
|
-
|
|
889
|
-
const west = rectangle.west;
|
|
890
|
-
let east = rectangle.east;
|
|
891
|
-
|
|
892
|
-
if (east < west) {
|
|
893
|
-
east += CesiumMath.TWO_PI;
|
|
894
|
-
if (longitude < 0.0) {
|
|
895
|
-
longitude += CesiumMath.TWO_PI;
|
|
896
|
-
}
|
|
831
|
+
return result;
|
|
897
832
|
}
|
|
898
|
-
return (
|
|
899
|
-
(longitude > west ||
|
|
900
|
-
CesiumMath.equalsEpsilon(longitude, west, CesiumMath.EPSILON14)) &&
|
|
901
|
-
(longitude < east ||
|
|
902
|
-
CesiumMath.equalsEpsilon(longitude, east, CesiumMath.EPSILON14)) &&
|
|
903
|
-
latitude >= rectangle.south &&
|
|
904
|
-
latitude <= rectangle.north
|
|
905
|
-
);
|
|
906
|
-
};
|
|
907
833
|
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
834
|
+
/**
|
|
835
|
+
* Computes a rectangle by enlarging the provided rectangle until it contains the provided cartographic.
|
|
836
|
+
*
|
|
837
|
+
* @param {Rectangle} rectangle A rectangle to expand.
|
|
838
|
+
* @param {Cartographic} cartographic A cartographic to enclose in a rectangle.
|
|
839
|
+
* @param {Rectangle} [result] The object onto which to store the result.
|
|
840
|
+
* @returns {Rectangle} The modified result parameter or a new Rectangle instance if one was not provided.
|
|
841
|
+
*/
|
|
842
|
+
static expand(rectangle, cartographic, result) {
|
|
843
|
+
//>>includeStart('debug', pragmas.debug);
|
|
844
|
+
Check.typeOf.object("rectangle", rectangle);
|
|
845
|
+
Check.typeOf.object("cartographic", cartographic);
|
|
846
|
+
//>>includeEnd('debug');
|
|
847
|
+
|
|
848
|
+
if (!defined(result)) {
|
|
849
|
+
result = new Rectangle();
|
|
850
|
+
}
|
|
924
851
|
|
|
925
|
-
|
|
926
|
-
|
|
852
|
+
result.west = Math.min(rectangle.west, cartographic.longitude);
|
|
853
|
+
result.south = Math.min(rectangle.south, cartographic.latitude);
|
|
854
|
+
result.east = Math.max(rectangle.east, cartographic.longitude);
|
|
855
|
+
result.north = Math.max(rectangle.north, cartographic.latitude);
|
|
927
856
|
|
|
928
|
-
|
|
929
|
-
result = [];
|
|
857
|
+
return result;
|
|
930
858
|
}
|
|
931
|
-
let length = 0;
|
|
932
859
|
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
860
|
+
/**
|
|
861
|
+
* Returns true if the cartographic is on or inside the rectangle, false otherwise.
|
|
862
|
+
*
|
|
863
|
+
* @param {Rectangle} rectangle The rectangle
|
|
864
|
+
* @param {Cartographic} cartographic The cartographic to test.
|
|
865
|
+
* @returns {boolean} true if the provided cartographic is inside the rectangle, false otherwise.
|
|
866
|
+
*/
|
|
867
|
+
static contains(rectangle, cartographic) {
|
|
868
|
+
//>>includeStart('debug', pragmas.debug);
|
|
869
|
+
Check.typeOf.object("rectangle", rectangle);
|
|
870
|
+
Check.typeOf.object("cartographic", cartographic);
|
|
871
|
+
//>>includeEnd('debug');
|
|
872
|
+
|
|
873
|
+
let longitude = cartographic.longitude;
|
|
874
|
+
const latitude = cartographic.latitude;
|
|
875
|
+
|
|
876
|
+
const west = rectangle.west;
|
|
877
|
+
let east = rectangle.east;
|
|
878
|
+
|
|
879
|
+
if (east < west) {
|
|
880
|
+
east += CesiumMath.TWO_PI;
|
|
881
|
+
if (longitude < 0.0) {
|
|
882
|
+
longitude += CesiumMath.TWO_PI;
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
return (
|
|
886
|
+
(longitude > west ||
|
|
887
|
+
CesiumMath.equalsEpsilon(longitude, west, CesiumMath.EPSILON14)) &&
|
|
888
|
+
(longitude < east ||
|
|
889
|
+
CesiumMath.equalsEpsilon(longitude, east, CesiumMath.EPSILON14)) &&
|
|
890
|
+
latitude >= rectangle.south &&
|
|
891
|
+
latitude <= rectangle.north
|
|
892
|
+
);
|
|
893
|
+
}
|
|
937
894
|
|
|
938
|
-
|
|
939
|
-
|
|
895
|
+
/**
|
|
896
|
+
* Samples a rectangle so that it includes a list of Cartesian points suitable for passing to
|
|
897
|
+
* {@link BoundingSphere#fromPoints}. Sampling is necessary to account
|
|
898
|
+
* for rectangles that cover the poles or cross the equator.
|
|
899
|
+
*
|
|
900
|
+
* @param {Rectangle} rectangle The rectangle to subsample.
|
|
901
|
+
* @param {Ellipsoid} [ellipsoid=Ellipsoid.default] The ellipsoid to use.
|
|
902
|
+
* @param {number} [surfaceHeight=0.0] The height of the rectangle above the ellipsoid.
|
|
903
|
+
* @param {Cartesian3[]} [result] The array of Cartesians onto which to store the result.
|
|
904
|
+
* @returns {Cartesian3[]} The modified result parameter or a new Array of Cartesians instances if none was provided.
|
|
905
|
+
*/
|
|
906
|
+
static subsample(rectangle, ellipsoid, surfaceHeight, result) {
|
|
907
|
+
//>>includeStart('debug', pragmas.debug);
|
|
908
|
+
Check.typeOf.object("rectangle", rectangle);
|
|
909
|
+
//>>includeEnd('debug');
|
|
940
910
|
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
result[length] = ellipsoid.cartographicToCartesian(lla, result[length]);
|
|
944
|
-
length++;
|
|
911
|
+
ellipsoid = ellipsoid ?? Ellipsoid.default;
|
|
912
|
+
surfaceHeight = surfaceHeight ?? 0.0;
|
|
945
913
|
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
914
|
+
if (!defined(result)) {
|
|
915
|
+
result = [];
|
|
916
|
+
}
|
|
917
|
+
let length = 0;
|
|
949
918
|
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
919
|
+
const north = rectangle.north;
|
|
920
|
+
const south = rectangle.south;
|
|
921
|
+
const east = rectangle.east;
|
|
922
|
+
const west = rectangle.west;
|
|
953
923
|
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
length++;
|
|
924
|
+
const lla = subsampleLlaScratch;
|
|
925
|
+
lla.height = surfaceHeight;
|
|
957
926
|
|
|
958
|
-
|
|
927
|
+
lla.longitude = west;
|
|
959
928
|
lla.latitude = north;
|
|
960
|
-
|
|
929
|
+
result[length] = ellipsoid.cartographicToCartesian(lla, result[length]);
|
|
930
|
+
length++;
|
|
931
|
+
|
|
932
|
+
lla.longitude = east;
|
|
933
|
+
result[length] = ellipsoid.cartographicToCartesian(lla, result[length]);
|
|
934
|
+
length++;
|
|
935
|
+
|
|
961
936
|
lla.latitude = south;
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
937
|
+
result[length] = ellipsoid.cartographicToCartesian(lla, result[length]);
|
|
938
|
+
length++;
|
|
939
|
+
|
|
940
|
+
lla.longitude = west;
|
|
941
|
+
result[length] = ellipsoid.cartographicToCartesian(lla, result[length]);
|
|
942
|
+
length++;
|
|
943
|
+
|
|
944
|
+
if (north < 0.0) {
|
|
945
|
+
lla.latitude = north;
|
|
946
|
+
} else if (south > 0.0) {
|
|
947
|
+
lla.latitude = south;
|
|
948
|
+
} else {
|
|
949
|
+
lla.latitude = 0.0;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
for (let i = 1; i < 8; ++i) {
|
|
953
|
+
lla.longitude = -Math.PI + i * CesiumMath.PI_OVER_TWO;
|
|
954
|
+
if (Rectangle.contains(rectangle, lla)) {
|
|
955
|
+
result[length] = ellipsoid.cartographicToCartesian(lla, result[length]);
|
|
956
|
+
length++;
|
|
957
|
+
}
|
|
958
|
+
}
|
|
965
959
|
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
960
|
+
if (lla.latitude === 0.0) {
|
|
961
|
+
lla.longitude = west;
|
|
962
|
+
result[length] = ellipsoid.cartographicToCartesian(lla, result[length]);
|
|
963
|
+
length++;
|
|
964
|
+
lla.longitude = east;
|
|
969
965
|
result[length] = ellipsoid.cartographicToCartesian(lla, result[length]);
|
|
970
966
|
length++;
|
|
971
967
|
}
|
|
968
|
+
result.length = length;
|
|
969
|
+
return result;
|
|
972
970
|
}
|
|
973
971
|
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
972
|
+
/**
|
|
973
|
+
* Computes a subsection of a rectangle from normalized coordinates in the range [0.0, 1.0].
|
|
974
|
+
*
|
|
975
|
+
* @param {Rectangle} rectangle The rectangle to subsection.
|
|
976
|
+
* @param {number} westLerp The west interpolation factor in the range [0.0, 1.0]. Must be less than or equal to eastLerp.
|
|
977
|
+
* @param {number} southLerp The south interpolation factor in the range [0.0, 1.0]. Must be less than or equal to northLerp.
|
|
978
|
+
* @param {number} eastLerp The east interpolation factor in the range [0.0, 1.0]. Must be greater than or equal to westLerp.
|
|
979
|
+
* @param {number} northLerp The north interpolation factor in the range [0.0, 1.0]. Must be greater than or equal to southLerp.
|
|
980
|
+
* @param {Rectangle} [result] The object onto which to store the result.
|
|
981
|
+
* @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided.
|
|
982
|
+
*/
|
|
983
|
+
static subsection(
|
|
984
|
+
rectangle,
|
|
985
|
+
westLerp,
|
|
986
|
+
southLerp,
|
|
987
|
+
eastLerp,
|
|
988
|
+
northLerp,
|
|
989
|
+
result,
|
|
990
|
+
) {
|
|
991
|
+
//>>includeStart('debug', pragmas.debug);
|
|
992
|
+
Check.typeOf.object("rectangle", rectangle);
|
|
993
|
+
Check.typeOf.number.greaterThanOrEquals("westLerp", westLerp, 0.0);
|
|
994
|
+
Check.typeOf.number.lessThanOrEquals("westLerp", westLerp, 1.0);
|
|
995
|
+
Check.typeOf.number.greaterThanOrEquals("southLerp", southLerp, 0.0);
|
|
996
|
+
Check.typeOf.number.lessThanOrEquals("southLerp", southLerp, 1.0);
|
|
997
|
+
Check.typeOf.number.greaterThanOrEquals("eastLerp", eastLerp, 0.0);
|
|
998
|
+
Check.typeOf.number.lessThanOrEquals("eastLerp", eastLerp, 1.0);
|
|
999
|
+
Check.typeOf.number.greaterThanOrEquals("northLerp", northLerp, 0.0);
|
|
1000
|
+
Check.typeOf.number.lessThanOrEquals("northLerp", northLerp, 1.0);
|
|
1001
|
+
|
|
1002
|
+
Check.typeOf.number.lessThanOrEquals("westLerp", westLerp, eastLerp);
|
|
1003
|
+
Check.typeOf.number.lessThanOrEquals("southLerp", southLerp, northLerp);
|
|
1004
|
+
//>>includeEnd('debug');
|
|
1005
|
+
|
|
1006
|
+
if (!defined(result)) {
|
|
1007
|
+
result = new Rectangle();
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
// This function doesn't use CesiumMath.lerp because it has floating point precision problems
|
|
1011
|
+
// when the start and end values are the same but the t changes.
|
|
1012
|
+
|
|
1013
|
+
if (rectangle.west <= rectangle.east) {
|
|
1014
|
+
const width = rectangle.east - rectangle.west;
|
|
1015
|
+
result.west = rectangle.west + westLerp * width;
|
|
1016
|
+
result.east = rectangle.west + eastLerp * width;
|
|
1017
|
+
} else {
|
|
1018
|
+
const width = CesiumMath.TWO_PI + rectangle.east - rectangle.west;
|
|
1019
|
+
result.west = CesiumMath.negativePiToPi(
|
|
1020
|
+
rectangle.west + westLerp * width,
|
|
1021
|
+
);
|
|
1022
|
+
result.east = CesiumMath.negativePiToPi(
|
|
1023
|
+
rectangle.west + eastLerp * width,
|
|
1024
|
+
);
|
|
1025
|
+
}
|
|
1026
|
+
const height = rectangle.north - rectangle.south;
|
|
1027
|
+
result.south = rectangle.south + southLerp * height;
|
|
1028
|
+
result.north = rectangle.south + northLerp * height;
|
|
1029
|
+
|
|
1030
|
+
// Fix floating point precision problems when t = 1
|
|
1031
|
+
if (westLerp === 1.0) {
|
|
1032
|
+
result.west = rectangle.east;
|
|
1033
|
+
}
|
|
1034
|
+
if (eastLerp === 1.0) {
|
|
1035
|
+
result.east = rectangle.east;
|
|
1036
|
+
}
|
|
1037
|
+
if (southLerp === 1.0) {
|
|
1038
|
+
result.south = rectangle.north;
|
|
1039
|
+
}
|
|
1040
|
+
if (northLerp === 1.0) {
|
|
1041
|
+
result.north = rectangle.north;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
return result;
|
|
981
1045
|
}
|
|
982
|
-
|
|
983
|
-
return result;
|
|
984
|
-
};
|
|
1046
|
+
}
|
|
985
1047
|
|
|
986
1048
|
/**
|
|
987
|
-
*
|
|
988
|
-
*
|
|
989
|
-
* @param {Rectangle} rectangle The rectangle to subsection.
|
|
990
|
-
* @param {number} westLerp The west interpolation factor in the range [0.0, 1.0]. Must be less than or equal to eastLerp.
|
|
991
|
-
* @param {number} southLerp The south interpolation factor in the range [0.0, 1.0]. Must be less than or equal to northLerp.
|
|
992
|
-
* @param {number} eastLerp The east interpolation factor in the range [0.0, 1.0]. Must be greater than or equal to westLerp.
|
|
993
|
-
* @param {number} northLerp The north interpolation factor in the range [0.0, 1.0]. Must be greater than or equal to southLerp.
|
|
994
|
-
* @param {Rectangle} [result] The object onto which to store the result.
|
|
995
|
-
* @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided.
|
|
1049
|
+
* The number of elements used to pack the object into an array.
|
|
1050
|
+
* @type {number}
|
|
996
1051
|
*/
|
|
997
|
-
Rectangle.
|
|
998
|
-
rectangle,
|
|
999
|
-
westLerp,
|
|
1000
|
-
southLerp,
|
|
1001
|
-
eastLerp,
|
|
1002
|
-
northLerp,
|
|
1003
|
-
result,
|
|
1004
|
-
) {
|
|
1005
|
-
//>>includeStart('debug', pragmas.debug);
|
|
1006
|
-
Check.typeOf.object("rectangle", rectangle);
|
|
1007
|
-
Check.typeOf.number.greaterThanOrEquals("westLerp", westLerp, 0.0);
|
|
1008
|
-
Check.typeOf.number.lessThanOrEquals("westLerp", westLerp, 1.0);
|
|
1009
|
-
Check.typeOf.number.greaterThanOrEquals("southLerp", southLerp, 0.0);
|
|
1010
|
-
Check.typeOf.number.lessThanOrEquals("southLerp", southLerp, 1.0);
|
|
1011
|
-
Check.typeOf.number.greaterThanOrEquals("eastLerp", eastLerp, 0.0);
|
|
1012
|
-
Check.typeOf.number.lessThanOrEquals("eastLerp", eastLerp, 1.0);
|
|
1013
|
-
Check.typeOf.number.greaterThanOrEquals("northLerp", northLerp, 0.0);
|
|
1014
|
-
Check.typeOf.number.lessThanOrEquals("northLerp", northLerp, 1.0);
|
|
1015
|
-
|
|
1016
|
-
Check.typeOf.number.lessThanOrEquals("westLerp", westLerp, eastLerp);
|
|
1017
|
-
Check.typeOf.number.lessThanOrEquals("southLerp", southLerp, northLerp);
|
|
1018
|
-
//>>includeEnd('debug');
|
|
1019
|
-
|
|
1020
|
-
if (!defined(result)) {
|
|
1021
|
-
result = new Rectangle();
|
|
1022
|
-
}
|
|
1023
|
-
|
|
1024
|
-
// This function doesn't use CesiumMath.lerp because it has floating point precision problems
|
|
1025
|
-
// when the start and end values are the same but the t changes.
|
|
1026
|
-
|
|
1027
|
-
if (rectangle.west <= rectangle.east) {
|
|
1028
|
-
const width = rectangle.east - rectangle.west;
|
|
1029
|
-
result.west = rectangle.west + westLerp * width;
|
|
1030
|
-
result.east = rectangle.west + eastLerp * width;
|
|
1031
|
-
} else {
|
|
1032
|
-
const width = CesiumMath.TWO_PI + rectangle.east - rectangle.west;
|
|
1033
|
-
result.west = CesiumMath.negativePiToPi(rectangle.west + westLerp * width);
|
|
1034
|
-
result.east = CesiumMath.negativePiToPi(rectangle.west + eastLerp * width);
|
|
1035
|
-
}
|
|
1036
|
-
const height = rectangle.north - rectangle.south;
|
|
1037
|
-
result.south = rectangle.south + southLerp * height;
|
|
1038
|
-
result.north = rectangle.south + northLerp * height;
|
|
1052
|
+
Rectangle.packedLength = 4;
|
|
1039
1053
|
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
}
|
|
1050
|
-
if (northLerp === 1.0) {
|
|
1051
|
-
result.north = rectangle.north;
|
|
1052
|
-
}
|
|
1054
|
+
const fromBoundingSphereMatrixScratch = new Matrix4();
|
|
1055
|
+
const fromBoundingSphereEastScratch = new Cartesian3();
|
|
1056
|
+
const fromBoundingSphereNorthScratch = new Cartesian3();
|
|
1057
|
+
const fromBoundingSphereWestScratch = new Cartesian3();
|
|
1058
|
+
const fromBoundingSphereSouthScratch = new Cartesian3();
|
|
1059
|
+
const fromBoundingSpherePositionsScratch = new Array(5);
|
|
1060
|
+
for (let n = 0; n < fromBoundingSpherePositionsScratch.length; ++n) {
|
|
1061
|
+
fromBoundingSpherePositionsScratch[n] = new Cartesian3();
|
|
1062
|
+
}
|
|
1053
1063
|
|
|
1054
|
-
|
|
1055
|
-
};
|
|
1064
|
+
const subsampleLlaScratch = new Cartographic();
|
|
1056
1065
|
|
|
1057
1066
|
/**
|
|
1058
1067
|
* The largest possible rectangle.
|