@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
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
1
3
|
import defined from "../Core/defined.js";
|
|
2
4
|
import DeveloperError from "../Core/DeveloperError.js";
|
|
3
5
|
import Rectangle from "../Core/Rectangle.js";
|
|
@@ -5,15 +7,24 @@ import Cartographic from "../Core/Cartographic.js";
|
|
|
5
7
|
import QuadtreeTileLoadState from "./QuadtreeTileLoadState.js";
|
|
6
8
|
import TileSelectionResult from "./TileSelectionResult.js";
|
|
7
9
|
|
|
10
|
+
/** @import TilingScheme from "../Core/TilingScheme.js"; */
|
|
11
|
+
|
|
8
12
|
/**
|
|
9
13
|
* A simple Least Recently Used (LRU) cache implementation.
|
|
14
|
+
*
|
|
15
|
+
* @private
|
|
10
16
|
*/
|
|
11
17
|
class LRUCache {
|
|
18
|
+
/** @param {number} maxSize */
|
|
12
19
|
constructor(maxSize) {
|
|
13
20
|
this.maxSize = maxSize;
|
|
14
21
|
this.cache = new Map();
|
|
15
22
|
}
|
|
16
23
|
|
|
24
|
+
/**
|
|
25
|
+
* @param {unknown} key
|
|
26
|
+
* @returns {unknown}
|
|
27
|
+
*/
|
|
17
28
|
get(key) {
|
|
18
29
|
if (!this.cache.has(key)) {
|
|
19
30
|
return undefined;
|
|
@@ -25,6 +36,10 @@ class LRUCache {
|
|
|
25
36
|
return value;
|
|
26
37
|
}
|
|
27
38
|
|
|
39
|
+
/**
|
|
40
|
+
* @param {unknown} key
|
|
41
|
+
* @param {unknown} value
|
|
42
|
+
*/
|
|
28
43
|
set(key, value) {
|
|
29
44
|
if (this.cache.has(key)) {
|
|
30
45
|
this.cache.delete(key);
|
|
@@ -36,6 +51,14 @@ class LRUCache {
|
|
|
36
51
|
this.cache.set(key, value);
|
|
37
52
|
}
|
|
38
53
|
|
|
54
|
+
/**
|
|
55
|
+
* @type {number}
|
|
56
|
+
* @readonly
|
|
57
|
+
*/
|
|
58
|
+
get size() {
|
|
59
|
+
return this.cache.size;
|
|
60
|
+
}
|
|
61
|
+
|
|
39
62
|
clear() {
|
|
40
63
|
this.cache.clear();
|
|
41
64
|
}
|
|
@@ -47,523 +70,391 @@ const MAX_CACHE_ENTRIES = 1000;
|
|
|
47
70
|
/**
|
|
48
71
|
* A single tile in a {@link QuadtreePrimitive}.
|
|
49
72
|
*
|
|
50
|
-
* @alias QuadtreeTile
|
|
51
|
-
* @constructor
|
|
52
73
|
* @private
|
|
53
|
-
*
|
|
54
|
-
* @param {number} options.level The level of the tile in the quadtree.
|
|
55
|
-
* @param {number} options.x The X coordinate of the tile in the quadtree. 0 is the westernmost tile.
|
|
56
|
-
* @param {number} options.y The Y coordinate of the tile in the quadtree. 0 is the northernmost tile.
|
|
57
|
-
* @param {TilingScheme} options.tilingScheme The tiling scheme in which this tile exists.
|
|
58
|
-
* @param {QuadtreeTile} [options.parent] This tile's parent, or undefined if this is a root tile.
|
|
59
74
|
*/
|
|
60
|
-
|
|
61
|
-
//>>includeStart('debug', pragmas.debug);
|
|
62
|
-
if (!defined(options)) {
|
|
63
|
-
throw new DeveloperError("options is required.");
|
|
64
|
-
}
|
|
65
|
-
if (!defined(options.x)) {
|
|
66
|
-
throw new DeveloperError("options.x is required.");
|
|
67
|
-
} else if (!defined(options.y)) {
|
|
68
|
-
throw new DeveloperError("options.y is required.");
|
|
69
|
-
} else if (options.x < 0 || options.y < 0) {
|
|
70
|
-
throw new DeveloperError(
|
|
71
|
-
"options.x and options.y must be greater than or equal to zero.",
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
if (!defined(options.level)) {
|
|
75
|
-
throw new DeveloperError(
|
|
76
|
-
"options.level is required and must be greater than or equal to zero.",
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
if (!defined(options.tilingScheme)) {
|
|
80
|
-
throw new DeveloperError("options.tilingScheme is required.");
|
|
81
|
-
}
|
|
82
|
-
//>>includeEnd('debug');
|
|
83
|
-
|
|
84
|
-
this._tilingScheme = options.tilingScheme;
|
|
85
|
-
this._x = options.x;
|
|
86
|
-
this._y = options.y;
|
|
87
|
-
this._level = options.level;
|
|
88
|
-
this._parent = options.parent;
|
|
89
|
-
this._rectangle = this._tilingScheme.tileXYToRectangle(
|
|
90
|
-
this._x,
|
|
91
|
-
this._y,
|
|
92
|
-
this._level,
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
this._southwestChild = undefined;
|
|
96
|
-
this._southeastChild = undefined;
|
|
97
|
-
this._northwestChild = undefined;
|
|
98
|
-
this._northeastChild = undefined;
|
|
99
|
-
|
|
100
|
-
// TileReplacementQueue gets/sets these private properties.
|
|
101
|
-
this.replacementPrevious = undefined;
|
|
102
|
-
this.replacementNext = undefined;
|
|
103
|
-
|
|
104
|
-
// The distance from the camera to this tile, updated when the tile is selected
|
|
105
|
-
// for rendering. We can get rid of this if we have a better way to sort by
|
|
106
|
-
// distance - for example, by using the natural ordering of a quadtree.
|
|
107
|
-
// QuadtreePrimitive gets/sets this private property.
|
|
108
|
-
this._distance = 0.0;
|
|
109
|
-
this._loadPriority = 0.0;
|
|
110
|
-
|
|
111
|
-
this._customData = new Set();
|
|
112
|
-
this._customDataIterator = undefined;
|
|
113
|
-
this._addedCustomData = [];
|
|
114
|
-
this._removedCustomData = [];
|
|
115
|
-
this._lastSelectionResult = TileSelectionResult.NONE;
|
|
116
|
-
this._lastSelectionResultFrame = undefined;
|
|
117
|
-
this._loadedCallbacks = {};
|
|
118
|
-
|
|
119
|
-
// Cache for storing computed position values per tile to avoid redundant calculations
|
|
120
|
-
this._positionCache = new LRUCache(MAX_CACHE_ENTRIES);
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Gets or sets the current state of the tile in the tile load pipeline.
|
|
124
|
-
* @type {QuadtreeTileLoadState}
|
|
125
|
-
* @default {@link QuadtreeTileLoadState.START}
|
|
126
|
-
*/
|
|
127
|
-
this.state = QuadtreeTileLoadState.START;
|
|
128
|
-
|
|
75
|
+
class QuadtreeTile {
|
|
129
76
|
/**
|
|
130
|
-
*
|
|
131
|
-
* @
|
|
132
|
-
* @
|
|
77
|
+
* @param {object} options
|
|
78
|
+
* @param {number} options.level The level of the tile in the quadtree.
|
|
79
|
+
* @param {number} options.x The X coordinate of the tile in the quadtree. 0 is the westernmost tile.
|
|
80
|
+
* @param {number} options.y The Y coordinate of the tile in the quadtree. 0 is the northernmost tile.
|
|
81
|
+
* @param {TilingScheme} options.tilingScheme The tiling scheme in which this tile exists.
|
|
82
|
+
* @param {QuadtreeTile} [options.parent] This tile's parent, or undefined if this is a root tile.
|
|
133
83
|
*/
|
|
134
|
-
|
|
84
|
+
constructor(options) {
|
|
85
|
+
//>>includeStart('debug', pragmas.debug);
|
|
86
|
+
if (!defined(options)) {
|
|
87
|
+
throw new DeveloperError("options is required.");
|
|
88
|
+
}
|
|
89
|
+
if (!defined(options.x)) {
|
|
90
|
+
throw new DeveloperError("options.x is required.");
|
|
91
|
+
} else if (!defined(options.y)) {
|
|
92
|
+
throw new DeveloperError("options.y is required.");
|
|
93
|
+
} else if (options.x < 0 || options.y < 0) {
|
|
94
|
+
throw new DeveloperError(
|
|
95
|
+
"options.x and options.y must be greater than or equal to zero.",
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
if (!defined(options.level)) {
|
|
99
|
+
throw new DeveloperError(
|
|
100
|
+
"options.level is required and must be greater than or equal to zero.",
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
if (!defined(options.tilingScheme)) {
|
|
104
|
+
throw new DeveloperError("options.tilingScheme is required.");
|
|
105
|
+
}
|
|
106
|
+
//>>includeEnd('debug');
|
|
107
|
+
|
|
108
|
+
this._tilingScheme = options.tilingScheme;
|
|
109
|
+
this._x = options.x;
|
|
110
|
+
this._y = options.y;
|
|
111
|
+
this._level = options.level;
|
|
112
|
+
this._parent = options.parent;
|
|
113
|
+
|
|
114
|
+
/** @type {Rectangle} */
|
|
115
|
+
this._rectangle = this._tilingScheme.tileXYToRectangle(
|
|
116
|
+
this._x,
|
|
117
|
+
this._y,
|
|
118
|
+
this._level,
|
|
119
|
+
);
|
|
135
120
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
121
|
+
this._southwestChild = undefined;
|
|
122
|
+
this._southeastChild = undefined;
|
|
123
|
+
this._northwestChild = undefined;
|
|
124
|
+
this._northeastChild = undefined;
|
|
125
|
+
|
|
126
|
+
// TileReplacementQueue gets/sets these private properties.
|
|
127
|
+
this.replacementPrevious = undefined;
|
|
128
|
+
this.replacementNext = undefined;
|
|
129
|
+
|
|
130
|
+
// The distance from the camera to this tile, updated when the tile is selected
|
|
131
|
+
// for rendering. We can get rid of this if we have a better way to sort by
|
|
132
|
+
// distance - for example, by using the natural ordering of a quadtree.
|
|
133
|
+
// QuadtreePrimitive gets/sets this private property.
|
|
134
|
+
this._distance = 0.0;
|
|
135
|
+
this._loadPriority = 0.0;
|
|
136
|
+
|
|
137
|
+
this._customData = new Set();
|
|
138
|
+
this._customDataIterator = undefined;
|
|
139
|
+
/** @type {unknown[]} */
|
|
140
|
+
this._addedCustomData = [];
|
|
141
|
+
/** @type {unknown[]} */
|
|
142
|
+
this._removedCustomData = [];
|
|
143
|
+
this._lastSelectionResult = TileSelectionResult.NONE;
|
|
144
|
+
this._lastSelectionResultFrame = undefined;
|
|
145
|
+
this._loadedCallbacks = {};
|
|
146
|
+
|
|
147
|
+
// Cache for storing computed position values per tile to avoid redundant calculations
|
|
148
|
+
this._positionCache = new LRUCache(MAX_CACHE_ENTRIES);
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Gets or sets the current state of the tile in the tile load pipeline.
|
|
152
|
+
* @type {QuadtreeTileLoadState}
|
|
153
|
+
* @default {@link QuadtreeTileLoadState.START}
|
|
154
|
+
*/
|
|
155
|
+
this.state = QuadtreeTileLoadState.START;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Gets or sets a value indicating whether or not the tile is currently renderable.
|
|
159
|
+
* @type {boolean}
|
|
160
|
+
* @default false
|
|
161
|
+
*/
|
|
162
|
+
this.renderable = false;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Gets or set a value indicating whether or not the tile was entirely upsampled from its
|
|
166
|
+
* parent tile. If all four children of a parent tile were upsampled from the parent,
|
|
167
|
+
* we will render the parent instead of the children even if the LOD indicates that
|
|
168
|
+
* the children would be preferable.
|
|
169
|
+
* @type {boolean}
|
|
170
|
+
* @default false
|
|
171
|
+
*/
|
|
172
|
+
this.upsampledFromParent = false;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Gets or sets the additional data associated with this tile. The exact content is specific to the
|
|
176
|
+
* {@link QuadtreeTileProvider}.
|
|
177
|
+
* @type {object}
|
|
178
|
+
* @default undefined
|
|
179
|
+
*/
|
|
180
|
+
this.data = undefined;
|
|
181
|
+
}
|
|
145
182
|
|
|
146
183
|
/**
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
* @
|
|
184
|
+
* Creates a rectangular set of tiles for level of detail zero, the coarsest, least detailed level.
|
|
185
|
+
*
|
|
186
|
+
*
|
|
187
|
+
* @param {TilingScheme} tilingScheme The tiling scheme for which the tiles are to be created.
|
|
188
|
+
* @returns {QuadtreeTile[]} An array containing the tiles at level of detail zero, starting with the
|
|
189
|
+
* tile in the northwest corner and followed by the tile (if any) to its east.
|
|
151
190
|
*/
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
* Creates a rectangular set of tiles for level of detail zero, the coarsest, least detailed level.
|
|
157
|
-
*
|
|
158
|
-
* @memberof QuadtreeTile
|
|
159
|
-
*
|
|
160
|
-
* @param {TilingScheme} tilingScheme The tiling scheme for which the tiles are to be created.
|
|
161
|
-
* @returns {QuadtreeTile[]} An array containing the tiles at level of detail zero, starting with the
|
|
162
|
-
* tile in the northwest corner and followed by the tile (if any) to its east.
|
|
163
|
-
*/
|
|
164
|
-
QuadtreeTile.createLevelZeroTiles = function (tilingScheme) {
|
|
165
|
-
//>>includeStart('debug', pragmas.debug);
|
|
166
|
-
if (!defined(tilingScheme)) {
|
|
167
|
-
throw new DeveloperError("tilingScheme is required.");
|
|
168
|
-
}
|
|
169
|
-
//>>includeEnd('debug');
|
|
170
|
-
|
|
171
|
-
const numberOfLevelZeroTilesX = tilingScheme.getNumberOfXTilesAtLevel(0);
|
|
172
|
-
const numberOfLevelZeroTilesY = tilingScheme.getNumberOfYTilesAtLevel(0);
|
|
173
|
-
|
|
174
|
-
const result = new Array(numberOfLevelZeroTilesX * numberOfLevelZeroTilesY);
|
|
175
|
-
|
|
176
|
-
let index = 0;
|
|
177
|
-
for (let y = 0; y < numberOfLevelZeroTilesY; ++y) {
|
|
178
|
-
for (let x = 0; x < numberOfLevelZeroTilesX; ++x) {
|
|
179
|
-
result[index++] = new QuadtreeTile({
|
|
180
|
-
tilingScheme: tilingScheme,
|
|
181
|
-
x: x,
|
|
182
|
-
y: y,
|
|
183
|
-
level: 0,
|
|
184
|
-
});
|
|
191
|
+
static createLevelZeroTiles(tilingScheme) {
|
|
192
|
+
//>>includeStart('debug', pragmas.debug);
|
|
193
|
+
if (!defined(tilingScheme)) {
|
|
194
|
+
throw new DeveloperError("tilingScheme is required.");
|
|
185
195
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
return result;
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Creates a spatial hash key for the given longitude, latitude, and tile level.
|
|
193
|
-
* The precision is adjusted based on the tile level and extent to achieve finer precision at higher levels.
|
|
194
|
-
*
|
|
195
|
-
* This function calculates the spatial hash key by first determining the precision at the given tile for the current maximum screenspace error (MAX_ERROR_PX),
|
|
196
|
-
* and then rounding the longitude and latitude to that precision for consistency.
|
|
197
|
-
*
|
|
198
|
-
* The steps for computing the level precision are as follows:
|
|
199
|
-
*
|
|
200
|
-
* 1. Compute the resolution (meters per pixel) at the given level:
|
|
201
|
-
* level_resolution_m = (2 * PI * RADIUS) / (2^level * TILE_SIZE)
|
|
202
|
-
*
|
|
203
|
-
* 2. Compute the target precision in meters:
|
|
204
|
-
* level_precision_m = level_resolution_m * MAX_ERROR_PX
|
|
205
|
-
*
|
|
206
|
-
* 3. Compute the target precision to radians:
|
|
207
|
-
* level_precision_rad = level_precision_m / BODY_RADIUS
|
|
208
|
-
*
|
|
209
|
-
* This simplifies to:
|
|
210
|
-
* level_precision_rad = (2 * PI * MAX_ERROR_PX) / (2^level * TILE_SIZE)
|
|
211
|
-
* which can also be written as:
|
|
212
|
-
* level_precision_rad = (PI * MAX_ERROR_PX) / (2^(level-1) * TILE_SIZE)
|
|
213
|
-
*
|
|
214
|
-
* The computed level_precision_rad is then used to round the input longitude and latitude,
|
|
215
|
-
* ensuring that positions that fall within the same spatial bin produce the same hash key.
|
|
216
|
-
*
|
|
217
|
-
* The constants below are computed once since they are fixed for the given configuration.
|
|
218
|
-
*
|
|
219
|
-
* @param {number} longitude - The longitude in radians.
|
|
220
|
-
* @param {number} latitude - The latitude in radians.
|
|
221
|
-
* @param {Rectangle} rectangle - The quadtree tile extents.
|
|
222
|
-
* @returns {string} A string representing the spatial hash key.
|
|
223
|
-
*/
|
|
224
|
-
const TILE_SIZE = 256;
|
|
225
|
-
|
|
226
|
-
function createSpatialHashKey(
|
|
227
|
-
longitude,
|
|
228
|
-
latitude,
|
|
229
|
-
rectangle,
|
|
230
|
-
maximumScreenSpaceError,
|
|
231
|
-
) {
|
|
232
|
-
// Adjust precision based on quadtree level - higher levels get finer precision
|
|
233
|
-
const maxError = (rectangle.width / TILE_SIZE) * maximumScreenSpaceError;
|
|
234
|
-
// Round to the grid precision
|
|
235
|
-
const lonGrid = Math.floor(longitude / maxError) * maxError;
|
|
236
|
-
const latGrid = Math.floor(latitude / maxError) * maxError;
|
|
237
|
-
return `${lonGrid.toFixed(10)},${latGrid.toFixed(10)}`;
|
|
238
|
-
}
|
|
196
|
+
//>>includeEnd('debug');
|
|
239
197
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
* @memberof QuadtreeTile
|
|
243
|
-
*
|
|
244
|
-
* @param {Cartographic} cartographic The cartographic coordinates.
|
|
245
|
-
* @param {number} maximumScreenSpaceError The maximum screen-space error, in pixels, that is allowed.
|
|
246
|
-
* A higher maximum error will render fewer tiles and improve performance, while a lower
|
|
247
|
-
* value will improve visual quality.
|
|
248
|
-
* @returns {string} A string representing the spatial hash key.
|
|
249
|
-
*/
|
|
250
|
-
QuadtreeTile.prototype._getCacheKey = function (
|
|
251
|
-
cartographic,
|
|
252
|
-
maximumScreenSpaceError,
|
|
253
|
-
) {
|
|
254
|
-
return createSpatialHashKey(
|
|
255
|
-
cartographic.longitude,
|
|
256
|
-
cartographic.latitude,
|
|
257
|
-
this._rectangle,
|
|
258
|
-
maximumScreenSpaceError,
|
|
259
|
-
);
|
|
260
|
-
};
|
|
198
|
+
const numberOfLevelZeroTilesX = tilingScheme.getNumberOfXTilesAtLevel(0);
|
|
199
|
+
const numberOfLevelZeroTilesY = tilingScheme.getNumberOfYTilesAtLevel(0);
|
|
261
200
|
|
|
262
|
-
|
|
263
|
-
* Retrieves a cached position for the specified cartographic position.
|
|
264
|
-
*
|
|
265
|
-
* @memberof QuadtreeTile
|
|
266
|
-
*
|
|
267
|
-
* @param {Cartographic} cartographic - The cartographic coordinates.
|
|
268
|
-
* @param {number} maximumScreenSpaceError The maximum screen-space error, in pixels, that is allowed.
|
|
269
|
-
* A higher maximum error will render fewer tiles and improve performance, while a lower
|
|
270
|
-
* value will improve visual quality.
|
|
271
|
-
* @returns {object|undefined} The cached position data or undefined if not found.
|
|
272
|
-
*/
|
|
273
|
-
QuadtreeTile.prototype.getPositionCacheEntry = function (
|
|
274
|
-
cartographic,
|
|
275
|
-
maximumScreenSpaceError,
|
|
276
|
-
) {
|
|
277
|
-
return this._positionCache.get(
|
|
278
|
-
this._getCacheKey(cartographic, maximumScreenSpaceError),
|
|
279
|
-
);
|
|
280
|
-
};
|
|
201
|
+
const result = new Array(numberOfLevelZeroTilesX * numberOfLevelZeroTilesY);
|
|
281
202
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
QuadtreeTile.prototype.setPositionCacheEntry = function (
|
|
294
|
-
cartographic,
|
|
295
|
-
maximumScreenSpaceError,
|
|
296
|
-
value,
|
|
297
|
-
) {
|
|
298
|
-
this._positionCache.set(
|
|
299
|
-
this._getCacheKey(cartographic, maximumScreenSpaceError),
|
|
300
|
-
value,
|
|
301
|
-
);
|
|
302
|
-
};
|
|
203
|
+
let index = 0;
|
|
204
|
+
for (let y = 0; y < numberOfLevelZeroTilesY; ++y) {
|
|
205
|
+
for (let x = 0; x < numberOfLevelZeroTilesX; ++x) {
|
|
206
|
+
result[index++] = new QuadtreeTile({
|
|
207
|
+
tilingScheme: tilingScheme,
|
|
208
|
+
x: x,
|
|
209
|
+
y: y,
|
|
210
|
+
level: 0,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
303
214
|
|
|
304
|
-
|
|
305
|
-
* Clears the position cache for this tile.
|
|
306
|
-
* This function removes all cached positions that were previously stored
|
|
307
|
-
* to optimize height computations.
|
|
308
|
-
*
|
|
309
|
-
* @memberof QuadtreeTile
|
|
310
|
-
*/
|
|
311
|
-
QuadtreeTile.prototype.clearPositionCache = function () {
|
|
312
|
-
if (this._positionCache.size > 0) {
|
|
313
|
-
this._positionCache.clear();
|
|
215
|
+
return result;
|
|
314
216
|
}
|
|
315
|
-
};
|
|
316
217
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
218
|
+
/**
|
|
219
|
+
* Generates a unique cache key for a given cartographic position.
|
|
220
|
+
*
|
|
221
|
+
* @param {Cartographic} cartographic The cartographic coordinates.
|
|
222
|
+
* @param {number} maximumScreenSpaceError The maximum screen-space error, in pixels, that is allowed.
|
|
223
|
+
* A higher maximum error will render fewer tiles and improve performance, while a lower
|
|
224
|
+
* value will improve visual quality.
|
|
225
|
+
* @returns {string} A string representing the spatial hash key.
|
|
226
|
+
*/
|
|
227
|
+
_getCacheKey(cartographic, maximumScreenSpaceError) {
|
|
228
|
+
return createSpatialHashKey(
|
|
229
|
+
cartographic.longitude,
|
|
230
|
+
cartographic.latitude,
|
|
231
|
+
this._rectangle,
|
|
232
|
+
maximumScreenSpaceError,
|
|
233
|
+
);
|
|
322
234
|
}
|
|
323
235
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
236
|
+
/**
|
|
237
|
+
* Retrieves a cached position for the specified cartographic position.
|
|
238
|
+
*
|
|
239
|
+
*
|
|
240
|
+
* @param {Cartographic} cartographic - The cartographic coordinates.
|
|
241
|
+
* @param {number} maximumScreenSpaceError The maximum screen-space error, in pixels, that is allowed.
|
|
242
|
+
* A higher maximum error will render fewer tiles and improve performance, while a lower
|
|
243
|
+
* value will improve visual quality.
|
|
244
|
+
* @returns {object|undefined} The cached position data or undefined if not found.
|
|
245
|
+
*/
|
|
246
|
+
getPositionCacheEntry(cartographic, maximumScreenSpaceError) {
|
|
247
|
+
const result = this._positionCache.get(
|
|
248
|
+
this._getCacheKey(cartographic, maximumScreenSpaceError),
|
|
249
|
+
);
|
|
250
|
+
return /** @type {object|undefined} */ (result);
|
|
251
|
+
}
|
|
328
252
|
|
|
329
|
-
|
|
330
|
-
|
|
253
|
+
/**
|
|
254
|
+
* Sets a position on the cache for this tile.
|
|
255
|
+
*
|
|
256
|
+
*
|
|
257
|
+
* @param {Cartographic} cartographic - The cartographic coordinates.
|
|
258
|
+
* @param {number} maximumScreenSpaceError The maximum screen-space error, in pixels, that is allowed.
|
|
259
|
+
* A higher maximum error will render fewer tiles and improve performance, while a lower
|
|
260
|
+
* value will improve visual quality.
|
|
261
|
+
* @param {object} value - The object to be cached.
|
|
262
|
+
*/
|
|
263
|
+
setPositionCacheEntry(cartographic, maximumScreenSpaceError, value) {
|
|
264
|
+
this._positionCache.set(
|
|
265
|
+
this._getCacheKey(cartographic, maximumScreenSpaceError),
|
|
266
|
+
value,
|
|
267
|
+
);
|
|
331
268
|
}
|
|
332
|
-
this._addedCustomData.length = 0;
|
|
333
269
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
270
|
+
/**
|
|
271
|
+
* Clears the position cache for this tile.
|
|
272
|
+
* This function removes all cached positions that were previously stored
|
|
273
|
+
* to optimize height computations.
|
|
274
|
+
*
|
|
275
|
+
*/
|
|
276
|
+
clearPositionCache() {
|
|
277
|
+
if (this._positionCache.size > 0) {
|
|
278
|
+
this._positionCache.clear();
|
|
338
279
|
}
|
|
339
|
-
|
|
340
|
-
const child = childTileAtPosition(this, data.positionCartographic);
|
|
341
|
-
child._removedCustomData.push(data);
|
|
342
280
|
}
|
|
343
|
-
this._removedCustomData.length = 0;
|
|
344
|
-
};
|
|
345
281
|
|
|
346
|
-
|
|
282
|
+
updateCustomData() {
|
|
283
|
+
const added = this._addedCustomData;
|
|
284
|
+
const removed = this._removedCustomData;
|
|
285
|
+
if (added.length === 0 && removed.length === 0) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
347
288
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
* @param {QuadtreeTile} tile - The parent tile.
|
|
353
|
-
* @param {Cartographic} positionCartographic - The cartographic position.
|
|
354
|
-
* @returns {QuadtreeTile} The child tile that contains the position.
|
|
355
|
-
*/
|
|
356
|
-
function childTileAtPosition(tile, positionCartographic) {
|
|
357
|
-
// Can't assume that a given tiling scheme divides a parent into four tiles at its rectangle's center.
|
|
358
|
-
// But we can safely take any child tile's rectangle and take its center-facing corner as the parent's split point.
|
|
359
|
-
const nwChildRectangle = tile.northwestChild.rectangle;
|
|
360
|
-
const tileSplitPoint = Rectangle.southeast(
|
|
361
|
-
nwChildRectangle,
|
|
362
|
-
splitPointScratch,
|
|
363
|
-
);
|
|
289
|
+
const customData = this.customData;
|
|
290
|
+
for (let i = 0; i < added.length; ++i) {
|
|
291
|
+
const data = /** @type {*} */ (added[i]);
|
|
292
|
+
customData.add(data);
|
|
364
293
|
|
|
365
|
-
|
|
366
|
-
|
|
294
|
+
const child = childTileAtPosition(this, data.positionCartographic);
|
|
295
|
+
child._addedCustomData.push(data);
|
|
296
|
+
}
|
|
297
|
+
this._addedCustomData.length = 0;
|
|
367
298
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
299
|
+
for (let i = 0; i < removed.length; ++i) {
|
|
300
|
+
const data = /** @type {*} */ (removed[i]);
|
|
301
|
+
if (customData.has(data)) {
|
|
302
|
+
customData.delete(data);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const child = childTileAtPosition(this, data.positionCartographic);
|
|
306
|
+
child._removedCustomData.push(data);
|
|
307
|
+
}
|
|
308
|
+
this._removedCustomData.length = 0;
|
|
377
309
|
}
|
|
378
|
-
}
|
|
379
310
|
|
|
380
|
-
Object.defineProperties(QuadtreeTile.prototype, {
|
|
381
311
|
/**
|
|
382
312
|
* Gets the tiling scheme used to tile the surface.
|
|
383
|
-
* @memberof QuadtreeTile.prototype
|
|
384
313
|
* @type {TilingScheme}
|
|
385
314
|
*/
|
|
386
|
-
tilingScheme
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
},
|
|
390
|
-
},
|
|
315
|
+
get tilingScheme() {
|
|
316
|
+
return this._tilingScheme;
|
|
317
|
+
}
|
|
391
318
|
|
|
392
319
|
/**
|
|
393
320
|
* Gets the tile X coordinate.
|
|
394
|
-
* @memberof QuadtreeTile.prototype
|
|
395
321
|
* @type {number}
|
|
396
322
|
*/
|
|
397
|
-
x
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
},
|
|
401
|
-
},
|
|
323
|
+
get x() {
|
|
324
|
+
return this._x;
|
|
325
|
+
}
|
|
402
326
|
|
|
403
327
|
/**
|
|
404
328
|
* Gets the tile Y coordinate.
|
|
405
|
-
* @memberof QuadtreeTile.prototype
|
|
406
329
|
* @type {number}
|
|
407
330
|
*/
|
|
408
|
-
y
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
},
|
|
412
|
-
},
|
|
331
|
+
get y() {
|
|
332
|
+
return this._y;
|
|
333
|
+
}
|
|
413
334
|
|
|
414
335
|
/**
|
|
415
336
|
* Gets the level-of-detail, where zero is the coarsest, least-detailed.
|
|
416
|
-
* @memberof QuadtreeTile.prototype
|
|
417
337
|
* @type {number}
|
|
418
338
|
*/
|
|
419
|
-
level
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
},
|
|
423
|
-
},
|
|
339
|
+
get level() {
|
|
340
|
+
return this._level;
|
|
341
|
+
}
|
|
424
342
|
|
|
425
343
|
/**
|
|
426
344
|
* Gets the parent tile of this tile.
|
|
427
|
-
* @memberof QuadtreeTile.prototype
|
|
428
345
|
* @type {QuadtreeTile}
|
|
429
346
|
*/
|
|
430
|
-
parent
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
},
|
|
434
|
-
},
|
|
347
|
+
get parent() {
|
|
348
|
+
return this._parent;
|
|
349
|
+
}
|
|
435
350
|
|
|
436
351
|
/**
|
|
437
352
|
* Gets the cartographic rectangle of the tile, with north, south, east and
|
|
438
353
|
* west properties in radians.
|
|
439
|
-
* @memberof QuadtreeTile.prototype
|
|
440
354
|
* @type {Rectangle}
|
|
441
355
|
*/
|
|
442
|
-
rectangle
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
},
|
|
446
|
-
},
|
|
356
|
+
get rectangle() {
|
|
357
|
+
return this._rectangle;
|
|
358
|
+
}
|
|
447
359
|
|
|
448
360
|
/**
|
|
449
361
|
* An array of tiles that is at the next level of the tile tree.
|
|
450
|
-
* @memberof QuadtreeTile.prototype
|
|
451
362
|
* @type {QuadtreeTile[]}
|
|
452
363
|
*/
|
|
453
|
-
children
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
},
|
|
462
|
-
},
|
|
364
|
+
get children() {
|
|
365
|
+
return [
|
|
366
|
+
this.northwestChild,
|
|
367
|
+
this.northeastChild,
|
|
368
|
+
this.southwestChild,
|
|
369
|
+
this.southeastChild,
|
|
370
|
+
];
|
|
371
|
+
}
|
|
463
372
|
|
|
464
373
|
/**
|
|
465
374
|
* Gets the southwest child tile.
|
|
466
|
-
* @memberof QuadtreeTile.prototype
|
|
467
375
|
* @type {QuadtreeTile}
|
|
468
376
|
*/
|
|
469
|
-
southwestChild
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
this.
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
},
|
|
482
|
-
},
|
|
377
|
+
get southwestChild() {
|
|
378
|
+
if (!defined(this._southwestChild)) {
|
|
379
|
+
this._southwestChild = new QuadtreeTile({
|
|
380
|
+
tilingScheme: this.tilingScheme,
|
|
381
|
+
x: this.x * 2,
|
|
382
|
+
y: this.y * 2 + 1,
|
|
383
|
+
level: this.level + 1,
|
|
384
|
+
parent: this,
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
return this._southwestChild;
|
|
388
|
+
}
|
|
483
389
|
|
|
484
390
|
/**
|
|
485
391
|
* Gets the southeast child tile.
|
|
486
|
-
* @memberof QuadtreeTile.prototype
|
|
487
392
|
* @type {QuadtreeTile}
|
|
488
393
|
*/
|
|
489
|
-
southeastChild
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
this.
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
},
|
|
502
|
-
},
|
|
394
|
+
get southeastChild() {
|
|
395
|
+
if (!defined(this._southeastChild)) {
|
|
396
|
+
this._southeastChild = new QuadtreeTile({
|
|
397
|
+
tilingScheme: this.tilingScheme,
|
|
398
|
+
x: this.x * 2 + 1,
|
|
399
|
+
y: this.y * 2 + 1,
|
|
400
|
+
level: this.level + 1,
|
|
401
|
+
parent: this,
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
return this._southeastChild;
|
|
405
|
+
}
|
|
503
406
|
|
|
504
407
|
/**
|
|
505
408
|
* Gets the northwest child tile.
|
|
506
|
-
* @memberof QuadtreeTile.prototype
|
|
507
409
|
* @type {QuadtreeTile}
|
|
508
410
|
*/
|
|
509
|
-
northwestChild
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
this.
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
},
|
|
522
|
-
},
|
|
411
|
+
get northwestChild() {
|
|
412
|
+
if (!defined(this._northwestChild)) {
|
|
413
|
+
this._northwestChild = new QuadtreeTile({
|
|
414
|
+
tilingScheme: this.tilingScheme,
|
|
415
|
+
x: this.x * 2,
|
|
416
|
+
y: this.y * 2,
|
|
417
|
+
level: this.level + 1,
|
|
418
|
+
parent: this,
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
return this._northwestChild;
|
|
422
|
+
}
|
|
523
423
|
|
|
524
424
|
/**
|
|
525
425
|
* Gets the northeast child tile.
|
|
526
|
-
* @memberof QuadtreeTile.prototype
|
|
527
426
|
* @type {QuadtreeTile}
|
|
528
427
|
*/
|
|
529
|
-
northeastChild
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
this.
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
},
|
|
542
|
-
},
|
|
428
|
+
get northeastChild() {
|
|
429
|
+
if (!defined(this._northeastChild)) {
|
|
430
|
+
this._northeastChild = new QuadtreeTile({
|
|
431
|
+
tilingScheme: this.tilingScheme,
|
|
432
|
+
x: this.x * 2 + 1,
|
|
433
|
+
y: this.y * 2,
|
|
434
|
+
level: this.level + 1,
|
|
435
|
+
parent: this,
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
return this._northeastChild;
|
|
439
|
+
}
|
|
543
440
|
|
|
544
441
|
/**
|
|
545
442
|
* A set of objects associated with this tile.
|
|
546
|
-
* @
|
|
547
|
-
* @type {Set}
|
|
443
|
+
* @type {Set<*>}
|
|
548
444
|
*/
|
|
549
|
-
customData
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
},
|
|
553
|
-
},
|
|
445
|
+
get customData() {
|
|
446
|
+
return this._customData;
|
|
447
|
+
}
|
|
554
448
|
|
|
555
449
|
/**
|
|
556
450
|
* Gets a value indicating whether or not this tile needs further loading.
|
|
557
451
|
* This property will return true if the {@link QuadtreeTile#state} is
|
|
558
452
|
* <code>START</code> or <code>LOADING</code>.
|
|
559
|
-
* @memberof QuadtreeTile.prototype
|
|
560
453
|
* @type {boolean}
|
|
561
454
|
*/
|
|
562
|
-
needsLoading
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
},
|
|
566
|
-
},
|
|
455
|
+
get needsLoading() {
|
|
456
|
+
return this.state < QuadtreeTileLoadState.DONE;
|
|
457
|
+
}
|
|
567
458
|
|
|
568
459
|
/**
|
|
569
460
|
* Gets a value indicating whether or not this tile is eligible to be unloaded.
|
|
@@ -573,157 +464,272 @@ Object.defineProperties(QuadtreeTile.prototype, {
|
|
|
573
464
|
* property. If {@link QuadtreeTile#data} is defined and has an
|
|
574
465
|
* <code>eligibleForUnloading</code> property, the value of that property is returned.
|
|
575
466
|
* Otherwise, this property returns true.
|
|
576
|
-
* @memberof QuadtreeTile.prototype
|
|
577
467
|
* @type {boolean}
|
|
578
468
|
*/
|
|
579
|
-
eligibleForUnloading
|
|
580
|
-
|
|
581
|
-
let result = true;
|
|
582
|
-
|
|
583
|
-
if (defined(this.data)) {
|
|
584
|
-
result = this.data.eligibleForUnloading;
|
|
585
|
-
if (!defined(result)) {
|
|
586
|
-
result = true;
|
|
587
|
-
}
|
|
588
|
-
}
|
|
469
|
+
get eligibleForUnloading() {
|
|
470
|
+
let result = true;
|
|
589
471
|
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
472
|
+
if (defined(this.data)) {
|
|
473
|
+
result = /** @type {*} */ (this.data).eligibleForUnloading;
|
|
474
|
+
if (!defined(result)) {
|
|
475
|
+
result = true;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
594
478
|
|
|
595
|
-
|
|
596
|
-
const xTiles = this.tilingScheme.getNumberOfXTilesAtLevel(0);
|
|
597
|
-
if (x < 0) {
|
|
598
|
-
x += xTiles;
|
|
599
|
-
} else if (x >= xTiles) {
|
|
600
|
-
x -= xTiles;
|
|
479
|
+
return result;
|
|
601
480
|
}
|
|
602
481
|
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
482
|
+
/**
|
|
483
|
+
* @param {QuadtreeTile[]} levelZeroTiles
|
|
484
|
+
* @param {number} x
|
|
485
|
+
* @param {number} y
|
|
486
|
+
* @returns {QuadtreeTile}
|
|
487
|
+
*/
|
|
488
|
+
findLevelZeroTile(levelZeroTiles, x, y) {
|
|
489
|
+
const xTiles = this.tilingScheme.getNumberOfXTilesAtLevel(0);
|
|
490
|
+
if (x < 0) {
|
|
491
|
+
x += xTiles;
|
|
492
|
+
} else if (x >= xTiles) {
|
|
493
|
+
x -= xTiles;
|
|
494
|
+
}
|
|
606
495
|
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
};
|
|
496
|
+
if (y < 0 || y >= this.tilingScheme.getNumberOfYTilesAtLevel(0)) {
|
|
497
|
+
return undefined;
|
|
498
|
+
}
|
|
611
499
|
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
return this.findLevelZeroTile(levelZeroTiles, this.x - 1, this.y);
|
|
500
|
+
return levelZeroTiles.filter(function (tile) {
|
|
501
|
+
return tile.x === x && tile.y === y;
|
|
502
|
+
})[0];
|
|
616
503
|
}
|
|
617
504
|
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
505
|
+
/**
|
|
506
|
+
* @param {QuadtreeTile[]} levelZeroTiles
|
|
507
|
+
* @returns {QuadtreeTile|undefined}
|
|
508
|
+
*/
|
|
509
|
+
findTileToWest(levelZeroTiles) {
|
|
510
|
+
const parent = this.parent;
|
|
511
|
+
if (parent === undefined) {
|
|
512
|
+
return this.findLevelZeroTile(levelZeroTiles, this.x - 1, this.y);
|
|
513
|
+
}
|
|
623
514
|
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
}
|
|
630
|
-
return westOfParent.northeastChild;
|
|
631
|
-
};
|
|
515
|
+
if (parent.southeastChild === this) {
|
|
516
|
+
return parent.southwestChild;
|
|
517
|
+
} else if (parent.northeastChild === this) {
|
|
518
|
+
return parent.northwestChild;
|
|
519
|
+
}
|
|
632
520
|
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
521
|
+
const westOfParent = parent.findTileToWest(levelZeroTiles);
|
|
522
|
+
if (westOfParent === undefined) {
|
|
523
|
+
return undefined;
|
|
524
|
+
} else if (parent.southwestChild === this) {
|
|
525
|
+
return westOfParent.southeastChild;
|
|
526
|
+
}
|
|
527
|
+
return westOfParent.northeastChild;
|
|
637
528
|
}
|
|
638
529
|
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
530
|
+
/**
|
|
531
|
+
* @param {QuadtreeTile[]} levelZeroTiles
|
|
532
|
+
* @returns {QuadtreeTile|undefined}
|
|
533
|
+
*/
|
|
534
|
+
findTileToEast(levelZeroTiles) {
|
|
535
|
+
const parent = this.parent;
|
|
536
|
+
if (parent === undefined) {
|
|
537
|
+
return this.findLevelZeroTile(levelZeroTiles, this.x + 1, this.y);
|
|
538
|
+
}
|
|
644
539
|
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
}
|
|
651
|
-
return eastOfParent.northwestChild;
|
|
652
|
-
};
|
|
540
|
+
if (parent.southwestChild === this) {
|
|
541
|
+
return parent.southeastChild;
|
|
542
|
+
} else if (parent.northwestChild === this) {
|
|
543
|
+
return parent.northeastChild;
|
|
544
|
+
}
|
|
653
545
|
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
546
|
+
const eastOfParent = parent.findTileToEast(levelZeroTiles);
|
|
547
|
+
if (eastOfParent === undefined) {
|
|
548
|
+
return undefined;
|
|
549
|
+
} else if (parent.southeastChild === this) {
|
|
550
|
+
return eastOfParent.southwestChild;
|
|
551
|
+
}
|
|
552
|
+
return eastOfParent.northwestChild;
|
|
658
553
|
}
|
|
659
554
|
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
555
|
+
/**
|
|
556
|
+
* @param {QuadtreeTile[]} levelZeroTiles
|
|
557
|
+
* @returns {QuadtreeTile|undefined}
|
|
558
|
+
*/
|
|
559
|
+
findTileToSouth(levelZeroTiles) {
|
|
560
|
+
const parent = this.parent;
|
|
561
|
+
if (parent === undefined) {
|
|
562
|
+
return this.findLevelZeroTile(levelZeroTiles, this.x, this.y + 1);
|
|
563
|
+
}
|
|
665
564
|
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
}
|
|
672
|
-
return southOfParent.northeastChild;
|
|
673
|
-
};
|
|
565
|
+
if (parent.northwestChild === this) {
|
|
566
|
+
return parent.southwestChild;
|
|
567
|
+
} else if (parent.northeastChild === this) {
|
|
568
|
+
return parent.southeastChild;
|
|
569
|
+
}
|
|
674
570
|
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
571
|
+
const southOfParent = parent.findTileToSouth(levelZeroTiles);
|
|
572
|
+
if (southOfParent === undefined) {
|
|
573
|
+
return undefined;
|
|
574
|
+
} else if (parent.southwestChild === this) {
|
|
575
|
+
return southOfParent.northwestChild;
|
|
576
|
+
}
|
|
577
|
+
return southOfParent.northeastChild;
|
|
679
578
|
}
|
|
680
579
|
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
580
|
+
/**
|
|
581
|
+
* @param {QuadtreeTile[]} levelZeroTiles
|
|
582
|
+
* @returns {QuadtreeTile|undefined}
|
|
583
|
+
*/
|
|
584
|
+
findTileToNorth(levelZeroTiles) {
|
|
585
|
+
const parent = this.parent;
|
|
586
|
+
if (parent === undefined) {
|
|
587
|
+
return this.findLevelZeroTile(levelZeroTiles, this.x, this.y - 1);
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
if (parent.southwestChild === this) {
|
|
591
|
+
return parent.northwestChild;
|
|
592
|
+
} else if (parent.southeastChild === this) {
|
|
593
|
+
return parent.northeastChild;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
const northOfParent = parent.findTileToNorth(levelZeroTiles);
|
|
597
|
+
if (northOfParent === undefined) {
|
|
598
|
+
return undefined;
|
|
599
|
+
} else if (parent.northwestChild === this) {
|
|
600
|
+
return northOfParent.southwestChild;
|
|
601
|
+
}
|
|
602
|
+
return northOfParent.southeastChild;
|
|
685
603
|
}
|
|
686
604
|
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
605
|
+
/**
|
|
606
|
+
* Frees the resources associated with this tile and returns it to the <code>START</code>
|
|
607
|
+
* {@link QuadtreeTileLoadState}. If the {@link QuadtreeTile#data} property is defined and it
|
|
608
|
+
* has a <code>freeResources</code> method, the method will be invoked.
|
|
609
|
+
*
|
|
610
|
+
*/
|
|
611
|
+
freeResources() {
|
|
612
|
+
// Clears cached heights when the tile is freed
|
|
613
|
+
this.clearPositionCache();
|
|
614
|
+
this.state = QuadtreeTileLoadState.START;
|
|
615
|
+
this.renderable = false;
|
|
616
|
+
this.upsampledFromParent = false;
|
|
617
|
+
|
|
618
|
+
const data = /** @type {*} */ (this.data);
|
|
619
|
+
if (defined(data) && defined(data.freeResources)) {
|
|
620
|
+
data.freeResources();
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
freeTile(this._southwestChild);
|
|
624
|
+
this._southwestChild = undefined;
|
|
625
|
+
freeTile(this._southeastChild);
|
|
626
|
+
this._southeastChild = undefined;
|
|
627
|
+
freeTile(this._northwestChild);
|
|
628
|
+
this._northwestChild = undefined;
|
|
629
|
+
freeTile(this._northeastChild);
|
|
630
|
+
this._northeastChild = undefined;
|
|
692
631
|
}
|
|
693
|
-
|
|
694
|
-
};
|
|
632
|
+
}
|
|
695
633
|
|
|
696
634
|
/**
|
|
697
|
-
*
|
|
698
|
-
*
|
|
699
|
-
* has a <code>freeResources</code> method, the method will be invoked.
|
|
635
|
+
* Creates a spatial hash key for the given longitude, latitude, and tile level.
|
|
636
|
+
* The precision is adjusted based on the tile level and extent to achieve finer precision at higher levels.
|
|
700
637
|
*
|
|
701
|
-
*
|
|
638
|
+
* This function calculates the spatial hash key by first determining the precision at the given tile for the current maximum screenspace error (MAX_ERROR_PX),
|
|
639
|
+
* and then rounding the longitude and latitude to that precision for consistency.
|
|
640
|
+
*
|
|
641
|
+
* The steps for computing the level precision are as follows:
|
|
642
|
+
*
|
|
643
|
+
* 1. Compute the resolution (meters per pixel) at the given level:
|
|
644
|
+
* level_resolution_m = (2 * PI * RADIUS) / (2^level * TILE_SIZE)
|
|
645
|
+
*
|
|
646
|
+
* 2. Compute the target precision in meters:
|
|
647
|
+
* level_precision_m = level_resolution_m * MAX_ERROR_PX
|
|
648
|
+
*
|
|
649
|
+
* 3. Compute the target precision to radians:
|
|
650
|
+
* level_precision_rad = level_precision_m / BODY_RADIUS
|
|
651
|
+
*
|
|
652
|
+
* This simplifies to:
|
|
653
|
+
* level_precision_rad = (2 * PI * MAX_ERROR_PX) / (2^level * TILE_SIZE)
|
|
654
|
+
* which can also be written as:
|
|
655
|
+
* level_precision_rad = (PI * MAX_ERROR_PX) / (2^(level-1) * TILE_SIZE)
|
|
656
|
+
*
|
|
657
|
+
* The computed level_precision_rad is then used to round the input longitude and latitude,
|
|
658
|
+
* ensuring that positions that fall within the same spatial bin produce the same hash key.
|
|
659
|
+
*
|
|
660
|
+
* The constants below are computed once since they are fixed for the given configuration.
|
|
661
|
+
*
|
|
662
|
+
* @param {number} longitude - The longitude in radians.
|
|
663
|
+
* @param {number} latitude - The latitude in radians.
|
|
664
|
+
* @param {Rectangle} rectangle - The quadtree tile extents.
|
|
665
|
+
* @returns {string} A string representing the spatial hash key.
|
|
702
666
|
*/
|
|
703
|
-
|
|
704
|
-
// Clears cached heights when the tile is freed
|
|
705
|
-
this.clearPositionCache();
|
|
706
|
-
this.state = QuadtreeTileLoadState.START;
|
|
707
|
-
this.renderable = false;
|
|
708
|
-
this.upsampledFromParent = false;
|
|
709
|
-
|
|
710
|
-
if (defined(this.data) && defined(this.data.freeResources)) {
|
|
711
|
-
this.data.freeResources();
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
freeTile(this._southwestChild);
|
|
715
|
-
this._southwestChild = undefined;
|
|
716
|
-
freeTile(this._southeastChild);
|
|
717
|
-
this._southeastChild = undefined;
|
|
718
|
-
freeTile(this._northwestChild);
|
|
719
|
-
this._northwestChild = undefined;
|
|
720
|
-
freeTile(this._northeastChild);
|
|
721
|
-
this._northeastChild = undefined;
|
|
722
|
-
};
|
|
667
|
+
const TILE_SIZE = 256;
|
|
723
668
|
|
|
669
|
+
/**
|
|
670
|
+
* @param {number} longitude
|
|
671
|
+
* @param {number} latitude
|
|
672
|
+
* @param {Rectangle} rectangle
|
|
673
|
+
* @param {number} maximumScreenSpaceError
|
|
674
|
+
* @returns {string}
|
|
675
|
+
* @ignore
|
|
676
|
+
*/
|
|
677
|
+
function createSpatialHashKey(
|
|
678
|
+
longitude,
|
|
679
|
+
latitude,
|
|
680
|
+
rectangle,
|
|
681
|
+
maximumScreenSpaceError,
|
|
682
|
+
) {
|
|
683
|
+
// Adjust precision based on quadtree level - higher levels get finer precision
|
|
684
|
+
const maxError = (rectangle.width / TILE_SIZE) * maximumScreenSpaceError;
|
|
685
|
+
// Round to the grid precision
|
|
686
|
+
const lonGrid = Math.floor(longitude / maxError) * maxError;
|
|
687
|
+
const latGrid = Math.floor(latitude / maxError) * maxError;
|
|
688
|
+
return `${lonGrid.toFixed(10)},${latGrid.toFixed(10)}`;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
const splitPointScratch = new Cartographic();
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* Determines which child tile that contains the specified position. Assumes the position is within
|
|
695
|
+
* the bounds of the parent tile.
|
|
696
|
+
* @private
|
|
697
|
+
* @param {QuadtreeTile} tile - The parent tile.
|
|
698
|
+
* @param {Cartographic} positionCartographic - The cartographic position.
|
|
699
|
+
* @returns {QuadtreeTile} The child tile that contains the position.
|
|
700
|
+
*/
|
|
701
|
+
function childTileAtPosition(tile, positionCartographic) {
|
|
702
|
+
// Can't assume that a given tiling scheme divides a parent into four tiles at its rectangle's center.
|
|
703
|
+
// But we can safely take any child tile's rectangle and take its center-facing corner as the parent's split point.
|
|
704
|
+
const nwChildRectangle = tile.northwestChild.rectangle;
|
|
705
|
+
const tileSplitPoint = Rectangle.southeast(
|
|
706
|
+
nwChildRectangle,
|
|
707
|
+
splitPointScratch,
|
|
708
|
+
);
|
|
709
|
+
|
|
710
|
+
const x = positionCartographic.longitude >= tileSplitPoint.longitude ? 1 : 0;
|
|
711
|
+
const y = positionCartographic.latitude < tileSplitPoint.latitude ? 1 : 0;
|
|
712
|
+
|
|
713
|
+
switch (y * 2 + x) {
|
|
714
|
+
case 0:
|
|
715
|
+
return tile.northwestChild;
|
|
716
|
+
case 1:
|
|
717
|
+
return tile.northeastChild;
|
|
718
|
+
case 2:
|
|
719
|
+
return tile.southwestChild;
|
|
720
|
+
default:
|
|
721
|
+
return tile.southeastChild;
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
/**
|
|
726
|
+
* @param {QuadtreeTile} tile
|
|
727
|
+
* @ignore
|
|
728
|
+
*/
|
|
724
729
|
function freeTile(tile) {
|
|
725
730
|
if (defined(tile)) {
|
|
726
731
|
tile.freeResources();
|
|
727
732
|
}
|
|
728
733
|
}
|
|
734
|
+
|
|
729
735
|
export default QuadtreeTile;
|