@cesium/engine 2.1.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (240) hide show
  1. package/Build/Workers/{AttributeCompression-8a5a065e.js → AttributeCompression-f9f6c717.js} +1 -1
  2. package/Build/Workers/{AxisAlignedBoundingBox-a6f9f0e5.js → AxisAlignedBoundingBox-31fadcf0.js} +1 -1
  3. package/Build/Workers/{BoundingRectangle-b0a68595.js → BoundingRectangle-995f0079.js} +1 -1
  4. package/Build/Workers/{BoxGeometry-baedd794.js → BoxGeometry-7eb1af60.js} +1 -1
  5. package/Build/Workers/{Color-f85df1be.js → Color-2dc49658.js} +1 -1
  6. package/Build/Workers/{CoplanarPolygonGeometryLibrary-30516950.js → CoplanarPolygonGeometryLibrary-d7d972d6.js} +1 -1
  7. package/Build/Workers/{CorridorGeometryLibrary-5d5d3b3a.js → CorridorGeometryLibrary-1f5ef7b3.js} +1 -1
  8. package/Build/Workers/{CylinderGeometry-d899ae26.js → CylinderGeometry-23c67a6c.js} +1 -1
  9. package/Build/Workers/{CylinderGeometryLibrary-135b0858.js → CylinderGeometryLibrary-7bf291b4.js} +1 -1
  10. package/Build/Workers/{EllipseGeometry-a49f8449.js → EllipseGeometry-37014da4.js} +1 -1
  11. package/Build/Workers/{EllipseGeometryLibrary-cba7edde.js → EllipseGeometryLibrary-92ab6b1e.js} +1 -1
  12. package/Build/Workers/{EllipseOutlineGeometry-8095c8cb.js → EllipseOutlineGeometry-12b6fef5.js} +1 -1
  13. package/Build/Workers/{EllipsoidGeodesic-dcff5cbd.js → EllipsoidGeodesic-5b3623dc.js} +1 -1
  14. package/Build/Workers/{EllipsoidGeometry-ed93f571.js → EllipsoidGeometry-508da15c.js} +1 -1
  15. package/Build/Workers/{EllipsoidOutlineGeometry-e4854854.js → EllipsoidOutlineGeometry-40d97455.js} +1 -1
  16. package/Build/Workers/{EllipsoidRhumbLine-b672d507.js → EllipsoidRhumbLine-ef872433.js} +1 -1
  17. package/Build/Workers/{EllipsoidTangentPlane-7ae1aa9a.js → EllipsoidTangentPlane-46d4d9c2.js} +1 -1
  18. package/Build/Workers/{EncodedCartesian3-e8bbca36.js → EncodedCartesian3-57415c8a.js} +1 -1
  19. package/Build/Workers/{FrustumGeometry-b62db3e3.js → FrustumGeometry-38605e69.js} +32 -4
  20. package/Build/Workers/{GeometryAttribute-780af4fa.js → GeometryAttribute-a466e9c7.js} +1 -1
  21. package/Build/Workers/{GeometryInstance-3fb607b7.js → GeometryInstance-34d9e21e.js} +1 -1
  22. package/Build/Workers/{GeometryPipeline-36b61c99.js → GeometryPipeline-dcf79306.js} +1 -1
  23. package/Build/Workers/{IndexDatatype-b8f3e09d.js → IndexDatatype-2643aa47.js} +1 -1
  24. package/Build/Workers/{IntersectionTests-e889fcf0.js → IntersectionTests-88c49b2e.js} +1 -1
  25. package/Build/Workers/{Math-dad82b4d.js → Math-0a2ac845.js} +12 -2
  26. package/Build/Workers/{Matrix2-1e403d0e.js → Matrix2-e1298525.js} +1 -1
  27. package/Build/Workers/{Matrix3-fa806b97.js → Matrix3-41c58dde.js} +1 -1
  28. package/Build/Workers/{OrientedBoundingBox-43478ac8.js → OrientedBoundingBox-2dd47921.js} +5 -3
  29. package/Build/Workers/{Plane-c27e1ac6.js → Plane-4c3d403b.js} +1 -1
  30. package/Build/Workers/{PolygonGeometryLibrary-38a98276.js → PolygonGeometryLibrary-59126025.js} +1 -1
  31. package/Build/Workers/PolygonPipeline-1fe328c0.js +1344 -0
  32. package/Build/Workers/{PolylinePipeline-30e4cec9.js → PolylinePipeline-896735cc.js} +1 -1
  33. package/Build/Workers/{PolylineVolumeGeometryLibrary-90551d26.js → PolylineVolumeGeometryLibrary-9c0639f7.js} +1 -1
  34. package/Build/Workers/{PrimitivePipeline-558d9cb0.js → PrimitivePipeline-fc1a47ff.js} +1 -1
  35. package/Build/Workers/{RectangleGeometryLibrary-815c68df.js → RectangleGeometryLibrary-a23c9ebe.js} +1 -1
  36. package/Build/Workers/{TerrainEncoding-341ead52.js → TerrainEncoding-51b8b33b.js} +1 -1
  37. package/Build/Workers/Transforms-bc45e707.js +14699 -0
  38. package/Build/Workers/{WallGeometryLibrary-ccf90976.js → WallGeometryLibrary-007e9883.js} +1 -1
  39. package/Build/Workers/{WebMercatorProjection-76a3fcc0.js → WebMercatorProjection-13ed1a6e.js} +1 -1
  40. package/Build/Workers/{arrayRemoveDuplicates-fac118a8.js → arrayRemoveDuplicates-d2061e85.js} +1 -1
  41. package/Build/Workers/cesiumWorkerBootstrapper.js +1 -1
  42. package/Build/Workers/combineGeometry.js +1 -1
  43. package/Build/Workers/createBoxGeometry.js +1 -1
  44. package/Build/Workers/createBoxOutlineGeometry.js +1 -1
  45. package/Build/Workers/createCircleGeometry.js +1 -1
  46. package/Build/Workers/createCircleOutlineGeometry.js +1 -1
  47. package/Build/Workers/createCoplanarPolygonGeometry.js +1 -1
  48. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +1 -1
  49. package/Build/Workers/createCorridorGeometry.js +1 -1
  50. package/Build/Workers/createCorridorOutlineGeometry.js +1 -1
  51. package/Build/Workers/createCylinderGeometry.js +1 -1
  52. package/Build/Workers/createCylinderOutlineGeometry.js +1 -1
  53. package/Build/Workers/createEllipseGeometry.js +1 -1
  54. package/Build/Workers/createEllipseOutlineGeometry.js +1 -1
  55. package/Build/Workers/createEllipsoidGeometry.js +1 -1
  56. package/Build/Workers/createEllipsoidOutlineGeometry.js +1 -1
  57. package/Build/Workers/createFrustumGeometry.js +1 -1
  58. package/Build/Workers/createFrustumOutlineGeometry.js +1 -1
  59. package/Build/Workers/createGeometry.js +1 -1
  60. package/Build/Workers/createGroundPolylineGeometry.js +1 -1
  61. package/Build/Workers/createPlaneGeometry.js +1 -1
  62. package/Build/Workers/createPlaneOutlineGeometry.js +1 -1
  63. package/Build/Workers/createPolygonGeometry.js +1 -1
  64. package/Build/Workers/createPolygonOutlineGeometry.js +1 -1
  65. package/Build/Workers/createPolylineGeometry.js +1 -1
  66. package/Build/Workers/createPolylineVolumeGeometry.js +1 -1
  67. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +1 -1
  68. package/Build/Workers/createRectangleGeometry.js +1 -1
  69. package/Build/Workers/createRectangleOutlineGeometry.js +1 -1
  70. package/Build/Workers/createSimplePolylineGeometry.js +1 -1
  71. package/Build/Workers/createSphereGeometry.js +1 -1
  72. package/Build/Workers/createSphereOutlineGeometry.js +1 -1
  73. package/Build/Workers/createVectorTileClampedPolylines.js +1 -1
  74. package/Build/Workers/createVectorTileGeometries.js +1 -1
  75. package/Build/Workers/createVectorTilePoints.js +1 -1
  76. package/Build/Workers/createVectorTilePolygons.js +1 -1
  77. package/Build/Workers/createVectorTilePolylines.js +1 -1
  78. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +1 -1
  79. package/Build/Workers/createVerticesFromHeightmap.js +5 -8
  80. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +10 -15
  81. package/Build/Workers/createWallGeometry.js +1 -1
  82. package/Build/Workers/createWallOutlineGeometry.js +1 -1
  83. package/Build/Workers/decodeDraco.js +1 -1
  84. package/Build/Workers/decodeI3S.js +1 -1
  85. package/Build/Workers/package.js +1 -1
  86. package/Build/Workers/transferTypedArrayTest.js +1 -1
  87. package/Build/Workers/upsampleQuantizedTerrainMesh.js +1 -1
  88. package/Source/Core/ArcGISTiledElevationTerrainProvider.js +291 -191
  89. package/Source/Core/BingMapsGeocoderService.js +19 -1
  90. package/Source/Core/CartographicGeocoderService.js +15 -0
  91. package/Source/Core/CesiumTerrainProvider.js +571 -434
  92. package/Source/Core/Credit.js +1 -1
  93. package/Source/Core/CustomHeightmapTerrainProvider.js +12 -0
  94. package/Source/Core/EllipsoidTerrainProvider.js +17 -10
  95. package/Source/Core/FrustumGeometry.js +4 -3
  96. package/Source/Core/GeocoderService.js +32 -1
  97. package/Source/Core/GoogleEarthEnterpriseMetadata.js +86 -34
  98. package/Source/Core/GoogleEarthEnterpriseTerrainProvider.js +119 -82
  99. package/Source/Core/Ion.js +1 -1
  100. package/Source/Core/IonGeocoderService.js +17 -2
  101. package/Source/Core/IonResource.js +14 -3
  102. package/Source/Core/OpenCageGeocoderService.js +18 -1
  103. package/Source/Core/OrientedBoundingBox.js +4 -2
  104. package/Source/Core/OrthographicFrustum.js +13 -0
  105. package/Source/Core/PeliasGeocoderService.js +14 -1
  106. package/Source/Core/PerspectiveFrustum.js +14 -0
  107. package/Source/Core/Request.js +3 -2
  108. package/Source/Core/RequestScheduler.js +10 -5
  109. package/Source/Core/Resource.js +230 -236
  110. package/Source/Core/TerrainProvider.js +9 -14
  111. package/Source/Core/TileProviderError.js +8 -8
  112. package/Source/Core/VRTheWorldTerrainProvider.js +193 -124
  113. package/Source/Core/buildModuleUrl.js +4 -3
  114. package/Source/Core/createWorldTerrain.js +20 -2
  115. package/Source/Core/createWorldTerrainAsync.js +48 -0
  116. package/Source/Core/sampleTerrain.js +9 -10
  117. package/Source/Core/sampleTerrainMostDetailed.js +66 -72
  118. package/Source/DataSources/Cesium3DTilesetVisualizer.js +37 -26
  119. package/Source/DataSources/DataSourceDisplay.js +2 -2
  120. package/Source/DataSources/Entity.js +6 -1
  121. package/Source/DataSources/EntityCluster.js +126 -128
  122. package/Source/DataSources/ModelVisualizer.js +104 -34
  123. package/Source/DataSources/PolygonGraphics.js +1 -1
  124. package/Source/Renderer/UniformState.js +3 -2
  125. package/Source/Renderer/demodernizeShader.js +5 -5
  126. package/Source/Scene/ArcGisBaseMapType.js +12 -0
  127. package/Source/Scene/ArcGisMapServerImageryProvider.js +694 -376
  128. package/Source/Scene/ArcGisMapService.js +83 -0
  129. package/Source/Scene/BingMapsImageryProvider.js +511 -305
  130. package/Source/Scene/BufferLoader.js +29 -34
  131. package/Source/Scene/Camera.js +8 -7
  132. package/Source/Scene/Cesium3DTile.js +392 -254
  133. package/Source/Scene/Cesium3DTileBatchTable.js +2 -2
  134. package/Source/Scene/Cesium3DTileContent.js +16 -0
  135. package/Source/Scene/Cesium3DTileContentFactory.js +4 -4
  136. package/Source/Scene/Cesium3DTilePass.js +8 -11
  137. package/Source/Scene/Cesium3DTileStyleEngine.js +1 -1
  138. package/Source/Scene/Cesium3DTilesVoxelProvider.js +225 -117
  139. package/Source/Scene/Cesium3DTileset.js +756 -482
  140. package/Source/Scene/Cesium3DTilesetBaseTraversal.js +301 -0
  141. package/Source/Scene/Cesium3DTilesetMostDetailedTraversal.js +33 -46
  142. package/Source/Scene/Cesium3DTilesetSkipTraversal.js +421 -0
  143. package/Source/Scene/Cesium3DTilesetTraversal.js +219 -671
  144. package/Source/Scene/ClassificationPrimitive.js +7 -0
  145. package/Source/Scene/Composite3DTileContent.js +69 -26
  146. package/Source/Scene/CreditDisplay.js +132 -20
  147. package/Source/Scene/DepthPlane.js +1 -1
  148. package/Source/Scene/Empty3DTileContent.js +31 -1
  149. package/Source/Scene/Geometry3DTileContent.js +47 -7
  150. package/Source/Scene/Globe.js +5 -1
  151. package/Source/Scene/GlobeSurfaceTile.js +2 -1
  152. package/Source/Scene/GlobeSurfaceTileProvider.js +53 -30
  153. package/Source/Scene/GltfBufferViewLoader.js +47 -91
  154. package/Source/Scene/GltfDracoLoader.js +110 -112
  155. package/Source/Scene/GltfImageLoader.js +71 -78
  156. package/Source/Scene/GltfIndexBufferLoader.js +108 -121
  157. package/Source/Scene/GltfJsonLoader.js +87 -74
  158. package/Source/Scene/GltfLoader.js +381 -300
  159. package/Source/Scene/GltfStructuralMetadataLoader.js +109 -110
  160. package/Source/Scene/GltfTextureLoader.js +97 -96
  161. package/Source/Scene/GltfVertexBufferLoader.js +128 -133
  162. package/Source/Scene/GoogleEarthEnterpriseImageryProvider.js +353 -225
  163. package/Source/Scene/GoogleEarthEnterpriseMapsProvider.js +491 -331
  164. package/Source/Scene/GridImageryProvider.js +267 -104
  165. package/Source/Scene/GroundPolylinePrimitive.js +12 -1
  166. package/Source/Scene/GroundPrimitive.js +8 -1
  167. package/Source/Scene/I3SDataProvider.js +214 -113
  168. package/Source/Scene/I3SFeature.js +7 -6
  169. package/Source/Scene/I3SLayer.js +26 -37
  170. package/Source/Scene/I3SNode.js +59 -66
  171. package/Source/Scene/Imagery.js +6 -1
  172. package/Source/Scene/ImageryLayer.js +299 -48
  173. package/Source/Scene/ImageryLayerCollection.js +26 -0
  174. package/Source/Scene/ImageryProvider.js +129 -111
  175. package/Source/Scene/Implicit3DTileContent.js +72 -23
  176. package/Source/Scene/ImplicitSubtree.js +66 -45
  177. package/Source/Scene/IonImageryProvider.js +482 -275
  178. package/Source/Scene/MapboxImageryProvider.js +272 -112
  179. package/Source/Scene/MapboxStyleImageryProvider.js +270 -111
  180. package/Source/Scene/MetadataSchemaLoader.js +26 -36
  181. package/Source/Scene/Model/B3dmLoader.js +42 -46
  182. package/Source/Scene/Model/GeoJsonLoader.js +8 -32
  183. package/Source/Scene/Model/I3dmLoader.js +48 -74
  184. package/Source/Scene/Model/MaterialPipelineStage.js +12 -12
  185. package/Source/Scene/Model/Model.js +514 -135
  186. package/Source/Scene/Model/Model3DTileContent.js +83 -31
  187. package/Source/Scene/Model/ModelAnimationCollection.js +3 -3
  188. package/Source/Scene/Model/ModelDrawCommand.js +15 -26
  189. package/Source/Scene/Model/ModelUtility.js +16 -16
  190. package/Source/Scene/Model/PntsLoader.js +27 -32
  191. package/Source/Scene/Model/UniformType.js +1 -1
  192. package/Source/Scene/Multiple3DTileContent.js +134 -115
  193. package/Source/Scene/Picking.js +3 -2
  194. package/Source/Scene/PointCloud.js +11 -19
  195. package/Source/Scene/Primitive.js +20 -0
  196. package/Source/Scene/QuadtreePrimitive.js +5 -2
  197. package/Source/Scene/QuadtreeTileProvider.js +4 -8
  198. package/Source/Scene/ResourceCache.js +47 -105
  199. package/Source/Scene/ResourceCacheStatistics.js +24 -58
  200. package/Source/Scene/ResourceLoader.js +5 -17
  201. package/Source/Scene/ResourceLoaderState.js +12 -4
  202. package/Source/Scene/Scene.js +65 -0
  203. package/Source/Scene/SceneTransforms.js +3 -2
  204. package/Source/Scene/ScreenSpaceCameraController.js +2 -2
  205. package/Source/Scene/SingleTileImageryProvider.js +382 -209
  206. package/Source/Scene/Terrain.js +196 -0
  207. package/Source/Scene/TileCoordinatesImageryProvider.js +267 -104
  208. package/Source/Scene/TileMapServiceImageryProvider.js +177 -85
  209. package/Source/Scene/Tileset3DTileContent.js +47 -5
  210. package/Source/Scene/TimeDynamicPointCloud.js +15 -2
  211. package/Source/Scene/UrlTemplateImageryProvider.js +343 -215
  212. package/Source/Scene/Vector3DTileClampedPolylines.js +96 -84
  213. package/Source/Scene/Vector3DTileContent.js +47 -22
  214. package/Source/Scene/Vector3DTileGeometry.js +57 -52
  215. package/Source/Scene/Vector3DTilePoints.js +97 -81
  216. package/Source/Scene/Vector3DTilePolygons.js +118 -117
  217. package/Source/Scene/Vector3DTilePolylines.js +86 -82
  218. package/Source/Scene/Vector3DTilePrimitive.js +0 -1
  219. package/Source/Scene/VoxelContent.js +61 -63
  220. package/Source/Scene/VoxelPrimitive.js +39 -91
  221. package/Source/Scene/VoxelProvider.js +2 -2
  222. package/Source/Scene/WebMapServiceImageryProvider.js +272 -111
  223. package/Source/Scene/WebMapTileServiceImageryProvider.js +270 -107
  224. package/Source/Scene/computeFlyToLocationForRectangle.js +33 -37
  225. package/Source/Scene/createOsmBuildings.js +6 -0
  226. package/Source/Scene/createOsmBuildingsAsync.js +82 -0
  227. package/Source/Scene/createWorldImagery.js +14 -5
  228. package/Source/Scene/createWorldImageryAsync.js +39 -0
  229. package/Source/Shaders/AtmosphereCommon.glsl +51 -8
  230. package/Source/Shaders/AtmosphereCommon.js +51 -8
  231. package/Source/Shaders/PostProcessStages/AmbientOcclusionGenerate.glsl +1 -1
  232. package/Source/Shaders/PostProcessStages/AmbientOcclusionGenerate.js +1 -1
  233. package/Source/Shaders/PostProcessStages/AmbientOcclusionModulate.glsl +3 -3
  234. package/Source/Shaders/PostProcessStages/AmbientOcclusionModulate.js +3 -3
  235. package/Source/Widget/CesiumWidget.js +67 -27
  236. package/index.d.ts +2429 -1475
  237. package/index.js +324 -315
  238. package/package.json +4 -4
  239. package/Build/Workers/PolygonPipeline-d31ff61c.js +0 -1345
  240. package/Build/Workers/Transforms-9e9df299.js +0 -14714
@@ -36,184 +36,6 @@ const xhrBlobSupported = (function () {
36
36
  }
37
37
  })();
38
38
 
39
- /**
40
- * Parses a query string and returns the object equivalent.
41
- *
42
- * @param {Uri} uri The Uri with a query object.
43
- * @param {Resource} resource The Resource that will be assigned queryParameters.
44
- * @param {boolean} merge If true, we'll merge with the resource's existing queryParameters. Otherwise they will be replaced.
45
- * @param {boolean} preserveQueryParameters If true duplicate parameters will be concatenated into an array. If false, keys in uri will take precedence.
46
- *
47
- * @private
48
- */
49
- function parseQuery(uri, resource, merge, preserveQueryParameters) {
50
- const queryString = uri.query();
51
- if (queryString.length === 0) {
52
- return {};
53
- }
54
-
55
- let query;
56
- // Special case we run into where the querystring is just a string, not key/value pairs
57
- if (queryString.indexOf("=") === -1) {
58
- const result = {};
59
- result[queryString] = undefined;
60
- query = result;
61
- } else {
62
- query = queryToObject(queryString);
63
- }
64
-
65
- if (merge) {
66
- resource._queryParameters = combineQueryParameters(
67
- query,
68
- resource._queryParameters,
69
- preserveQueryParameters
70
- );
71
- } else {
72
- resource._queryParameters = query;
73
- }
74
- uri.search("");
75
- }
76
-
77
- /**
78
- * Converts a query object into a string.
79
- *
80
- * @param {Uri} uri The Uri object that will have the query object set.
81
- * @param {Resource} resource The resource that has queryParameters
82
- *
83
- * @private
84
- */
85
- function stringifyQuery(uri, resource) {
86
- const queryObject = resource._queryParameters;
87
-
88
- const keys = Object.keys(queryObject);
89
-
90
- // We have 1 key with an undefined value, so this is just a string, not key/value pairs
91
- if (keys.length === 1 && !defined(queryObject[keys[0]])) {
92
- uri.search(keys[0]);
93
- } else {
94
- uri.search(objectToQuery(queryObject));
95
- }
96
- }
97
-
98
- /**
99
- * Clones a value if it is defined, otherwise returns the default value
100
- *
101
- * @param {*} [val] The value to clone.
102
- * @param {*} [defaultVal] The default value.
103
- *
104
- * @returns {*} A clone of val or the defaultVal.
105
- *
106
- * @private
107
- */
108
- function defaultClone(val, defaultVal) {
109
- if (!defined(val)) {
110
- return defaultVal;
111
- }
112
-
113
- return defined(val.clone) ? val.clone() : clone(val);
114
- }
115
-
116
- /**
117
- * Checks to make sure the Resource isn't already being requested.
118
- *
119
- * @param {Request} request The request to check.
120
- *
121
- * @private
122
- */
123
- function checkAndResetRequest(request) {
124
- if (
125
- request.state === RequestState.ISSUED ||
126
- request.state === RequestState.ACTIVE
127
- ) {
128
- throw new RuntimeError("The Resource is already being fetched.");
129
- }
130
-
131
- request.state = RequestState.UNISSUED;
132
- request.deferred = undefined;
133
- }
134
-
135
- /**
136
- * This combines a map of query parameters.
137
- *
138
- * @param {object} q1 The first map of query parameters. Values in this map will take precedence if preserveQueryParameters is false.
139
- * @param {object} q2 The second map of query parameters.
140
- * @param {boolean} preserveQueryParameters If true duplicate parameters will be concatenated into an array. If false, keys in q1 will take precedence.
141
- *
142
- * @returns {object} The combined map of query parameters.
143
- *
144
- * @example
145
- * const q1 = {
146
- * a: 1,
147
- * b: 2
148
- * };
149
- * const q2 = {
150
- * a: 3,
151
- * c: 4
152
- * };
153
- * const q3 = {
154
- * b: [5, 6],
155
- * d: 7
156
- * }
157
- *
158
- * // Returns
159
- * // {
160
- * // a: [1, 3],
161
- * // b: 2,
162
- * // c: 4
163
- * // };
164
- * combineQueryParameters(q1, q2, true);
165
- *
166
- * // Returns
167
- * // {
168
- * // a: 1,
169
- * // b: 2,
170
- * // c: 4
171
- * // };
172
- * combineQueryParameters(q1, q2, false);
173
- *
174
- * // Returns
175
- * // {
176
- * // a: 1,
177
- * // b: [2, 5, 6],
178
- * // d: 7
179
- * // };
180
- * combineQueryParameters(q1, q3, true);
181
- *
182
- * // Returns
183
- * // {
184
- * // a: 1,
185
- * // b: 2,
186
- * // d: 7
187
- * // };
188
- * combineQueryParameters(q1, q3, false);
189
- *
190
- * @private
191
- */
192
- function combineQueryParameters(q1, q2, preserveQueryParameters) {
193
- if (!preserveQueryParameters) {
194
- return combine(q1, q2);
195
- }
196
-
197
- const result = clone(q1, true);
198
- for (const param in q2) {
199
- if (q2.hasOwnProperty(param)) {
200
- let value = result[param];
201
- const q2Value = q2[param];
202
- if (defined(value)) {
203
- if (!Array.isArray(value)) {
204
- value = result[param] = [value];
205
- }
206
-
207
- result[param] = value.concat(q2Value);
208
- } else {
209
- result[param] = Array.isArray(q2Value) ? q2Value.slice() : q2Value;
210
- }
211
- }
212
- }
213
-
214
- return result;
215
- }
216
-
217
39
  /**
218
40
  * @typedef {object} Resource.ConstructorOptions
219
41
  *
@@ -227,6 +49,7 @@ function combineQueryParameters(q1, q2, preserveQueryParameters) {
227
49
  * @property {Resource.RetryCallback} [retryCallback] The Function to call when a request for this resource fails. If it returns true, the request will be retried.
228
50
  * @property {number} [retryAttempts=0] The number of times the retryCallback should be called before giving up.
229
51
  * @property {Request} [request] A Request object that will be used. Intended for internal use only.
52
+ * @property {boolean} [parseUrl=true] If true, parse the url for query parameters; otherwise store the url without change
230
53
  */
231
54
 
232
55
  /**
@@ -319,13 +142,26 @@ function Resource(options) {
319
142
  this.retryAttempts = defaultValue(options.retryAttempts, 0);
320
143
  this._retryCount = 0;
321
144
 
322
- const uri = new Uri(options.url);
323
- parseQuery(uri, this, true, true);
324
-
325
- // Remove the fragment as it's not sent with a request
326
- uri.fragment("");
145
+ const parseUrl = defaultValue(options.parseUrl, true);
146
+ if (parseUrl) {
147
+ this.parseUrl(options.url, true, true);
148
+ } else {
149
+ this._url = options.url;
150
+ }
151
+ }
327
152
 
328
- this._url = uri.toString();
153
+ /**
154
+ * Clones a value if it is defined, otherwise returns the default value
155
+ *
156
+ * @param {object} [value] The value to clone.
157
+ * @param {object} [defaultValue] The default value.
158
+ *
159
+ * @returns {object} A clone of value or the defaultValue.
160
+ *
161
+ * @private
162
+ */
163
+ function defaultClone(value, defaultValue) {
164
+ return defined(value) ? clone(value) : defaultValue;
329
165
  }
330
166
 
331
167
  /**
@@ -471,14 +307,7 @@ Object.defineProperties(Resource.prototype, {
471
307
  return this.getUrlComponent(true, true);
472
308
  },
473
309
  set: function (value) {
474
- const uri = new Uri(value);
475
-
476
- parseQuery(uri, this, false);
477
-
478
- // Remove the fragment as it's not sent with a request
479
- uri.fragment("");
480
-
481
- this._url = uri.toString();
310
+ this.parseUrl(value, false, false);
482
311
  },
483
312
  },
484
313
 
@@ -555,6 +384,138 @@ Resource.prototype.toString = function () {
555
384
  return this.getUrlComponent(true, true);
556
385
  };
557
386
 
387
+ /**
388
+ * Parse a url string, and store its info
389
+ *
390
+ * @param {string} url The input url string.
391
+ * @param {boolean} merge If true, we'll merge with the resource's existing queryParameters. Otherwise they will be replaced.
392
+ * @param {boolean} preserveQuery If true duplicate parameters will be concatenated into an array. If false, keys in url will take precedence.
393
+ * @param {string} [baseUrl] If supplied, and input url is a relative url, it will be made absolute relative to baseUrl
394
+ *
395
+ * @private
396
+ */
397
+ Resource.prototype.parseUrl = function (url, merge, preserveQuery, baseUrl) {
398
+ let uri = new Uri(url);
399
+ const query = parseQueryString(uri.query());
400
+
401
+ this._queryParameters = merge
402
+ ? combineQueryParameters(query, this.queryParameters, preserveQuery)
403
+ : query;
404
+
405
+ // Remove unneeded info from the Uri
406
+ uri.search("");
407
+ uri.fragment("");
408
+
409
+ if (defined(baseUrl) && uri.scheme() === "") {
410
+ uri = uri.absoluteTo(getAbsoluteUri(baseUrl));
411
+ }
412
+
413
+ this._url = uri.toString();
414
+ };
415
+
416
+ /**
417
+ * Parses a query string and returns the object equivalent.
418
+ *
419
+ * @param {string} queryString The query string
420
+ * @returns {object}
421
+ *
422
+ * @private
423
+ */
424
+ function parseQueryString(queryString) {
425
+ if (queryString.length === 0) {
426
+ return {};
427
+ }
428
+
429
+ // Special case where the querystring is just a string, not key/value pairs
430
+ if (queryString.indexOf("=") === -1) {
431
+ return { [queryString]: undefined };
432
+ }
433
+
434
+ return queryToObject(queryString);
435
+ }
436
+
437
+ /**
438
+ * This combines a map of query parameters.
439
+ *
440
+ * @param {object} q1 The first map of query parameters. Values in this map will take precedence if preserveQueryParameters is false.
441
+ * @param {object} q2 The second map of query parameters.
442
+ * @param {boolean} preserveQueryParameters If true duplicate parameters will be concatenated into an array. If false, keys in q1 will take precedence.
443
+ *
444
+ * @returns {object} The combined map of query parameters.
445
+ *
446
+ * @example
447
+ * const q1 = {
448
+ * a: 1,
449
+ * b: 2
450
+ * };
451
+ * const q2 = {
452
+ * a: 3,
453
+ * c: 4
454
+ * };
455
+ * const q3 = {
456
+ * b: [5, 6],
457
+ * d: 7
458
+ * }
459
+ *
460
+ * // Returns
461
+ * // {
462
+ * // a: [1, 3],
463
+ * // b: 2,
464
+ * // c: 4
465
+ * // };
466
+ * combineQueryParameters(q1, q2, true);
467
+ *
468
+ * // Returns
469
+ * // {
470
+ * // a: 1,
471
+ * // b: 2,
472
+ * // c: 4
473
+ * // };
474
+ * combineQueryParameters(q1, q2, false);
475
+ *
476
+ * // Returns
477
+ * // {
478
+ * // a: 1,
479
+ * // b: [2, 5, 6],
480
+ * // d: 7
481
+ * // };
482
+ * combineQueryParameters(q1, q3, true);
483
+ *
484
+ * // Returns
485
+ * // {
486
+ * // a: 1,
487
+ * // b: 2,
488
+ * // d: 7
489
+ * // };
490
+ * combineQueryParameters(q1, q3, false);
491
+ *
492
+ * @private
493
+ */
494
+ function combineQueryParameters(q1, q2, preserveQueryParameters) {
495
+ if (!preserveQueryParameters) {
496
+ return combine(q1, q2);
497
+ }
498
+
499
+ const result = clone(q1, true);
500
+ for (const param in q2) {
501
+ if (q2.hasOwnProperty(param)) {
502
+ let value = result[param];
503
+ const q2Value = q2[param];
504
+ if (defined(value)) {
505
+ if (!Array.isArray(value)) {
506
+ value = result[param] = [value];
507
+ }
508
+
509
+ result[param] = value.concat(q2Value);
510
+ } else {
511
+ result[param] = Array.isArray(q2Value) ? q2Value.slice() : q2Value;
512
+ }
513
+ }
514
+ }
515
+
516
+ return result;
517
+ }
518
+
558
519
  /**
559
520
  * Returns the url, optional with the query string and processed by a proxy.
560
521
  *
@@ -568,32 +529,56 @@ Resource.prototype.getUrlComponent = function (query, proxy) {
568
529
  return this._url;
569
530
  }
570
531
 
571
- const uri = new Uri(this._url);
572
-
532
+ let url = this._url;
573
533
  if (query) {
574
- stringifyQuery(uri, this);
534
+ url = `${url}${stringifyQuery(this.queryParameters)}`;
575
535
  }
576
536
 
577
- // objectToQuery escapes the placeholders. Undo that.
578
- let url = uri.toString().replace(/%7B/g, "{").replace(/%7D/g, "}");
537
+ // Restore the placeholders, which may have been escaped in objectToQuery or elsewhere
538
+ url = url.replace(/%7B/g, "{").replace(/%7D/g, "}");
579
539
 
580
540
  const templateValues = this._templateValues;
581
- url = url.replace(/{(.*?)}/g, function (match, key) {
582
- const replacement = templateValues[key];
583
- if (defined(replacement)) {
584
- // use the replacement value from templateValues if there is one...
585
- return encodeURIComponent(replacement);
586
- }
587
- // otherwise leave it unchanged
588
- return match;
589
- });
541
+ if (Object.keys(templateValues).length > 0) {
542
+ url = url.replace(/{(.*?)}/g, function (match, key) {
543
+ const replacement = templateValues[key];
544
+ if (defined(replacement)) {
545
+ // use the replacement value from templateValues if there is one...
546
+ return encodeURIComponent(replacement);
547
+ }
548
+ // otherwise leave it unchanged
549
+ return match;
550
+ });
551
+ }
590
552
 
591
553
  if (proxy && defined(this.proxy)) {
592
554
  url = this.proxy.getURL(url);
593
555
  }
556
+
594
557
  return url;
595
558
  };
596
559
 
560
+ /**
561
+ * Converts a query object into a string.
562
+ *
563
+ * @param {object} queryObject The object with query parameters
564
+ * @returns {string}
565
+ *
566
+ * @private
567
+ */
568
+ function stringifyQuery(queryObject) {
569
+ const keys = Object.keys(queryObject);
570
+
571
+ if (keys.length === 0) {
572
+ return "";
573
+ }
574
+ if (keys.length === 1 && !defined(queryObject[keys[0]])) {
575
+ // We have 1 key with an undefined value, so this is just a string, not key/value pairs
576
+ return `?${keys[0]}`;
577
+ }
578
+
579
+ return `?${objectToQuery(queryObject)}`;
580
+ }
581
+
597
582
  /**
598
583
  * Combines the specified object and the existing query parameters. This allows you to add many parameters at once,
599
584
  * as opposed to adding them one at a time to the queryParameters property. If a value is already set, it will be replaced with the new value.
@@ -667,30 +652,14 @@ Resource.prototype.getDerivedResource = function (options) {
667
652
  resource._retryCount = 0;
668
653
 
669
654
  if (defined(options.url)) {
670
- const uri = new Uri(options.url);
671
-
672
- const preserveQueryParameters = defaultValue(
673
- options.preserveQueryParameters,
674
- false
675
- );
676
- parseQuery(uri, resource, true, preserveQueryParameters);
677
-
678
- // Remove the fragment as it's not sent with a request
679
- uri.fragment("");
680
-
681
- if (uri.scheme() !== "") {
682
- resource._url = uri.toString();
683
- } else {
684
- resource._url = uri
685
- .absoluteTo(new Uri(getAbsoluteUri(this._url)))
686
- .toString();
687
- }
655
+ const preserveQuery = defaultValue(options.preserveQueryParameters, false);
656
+ resource.parseUrl(options.url, true, preserveQuery, this._url);
688
657
  }
689
658
 
690
659
  if (defined(options.queryParameters)) {
691
660
  resource._queryParameters = combine(
692
661
  options.queryParameters,
693
- resource._queryParameters
662
+ resource.queryParameters
694
663
  );
695
664
  }
696
665
  if (defined(options.templateValues)) {
@@ -721,7 +690,7 @@ Resource.prototype.getDerivedResource = function (options) {
721
690
  /**
722
691
  * Called when a resource fails to load. This will call the retryCallback function if defined until retryAttempts is reached.
723
692
  *
724
- * @param {Error} [error] The error that was encountered.
693
+ * @param {RequestErrorEvent} [error] The error that was encountered.
725
694
  *
726
695
  * @returns {Promise<boolean>} A promise to a boolean, that if true will cause the resource request to be retried.
727
696
  *
@@ -753,8 +722,16 @@ Resource.prototype.retryOnError = function (error) {
753
722
  */
754
723
  Resource.prototype.clone = function (result) {
755
724
  if (!defined(result)) {
756
- result = new Resource({
725
+ return new Resource({
757
726
  url: this._url,
727
+ queryParameters: this.queryParameters,
728
+ templateValues: this.templateValues,
729
+ headers: this.headers,
730
+ proxy: this.proxy,
731
+ retryCallback: this.retryCallback,
732
+ retryAttempts: this.retryAttempts,
733
+ request: this.request.clone(),
734
+ parseUrl: false,
758
735
  });
759
736
  }
760
737
 
@@ -1301,7 +1278,8 @@ function fetchJsonp(resource, callbackParameterName, functionName) {
1301
1278
  resource.setQueryParameters(callbackQuery);
1302
1279
 
1303
1280
  const request = resource.request;
1304
- request.url = resource.url;
1281
+ const url = resource.url;
1282
+ request.url = url;
1305
1283
  request.requestFunction = function () {
1306
1284
  const deferred = defer();
1307
1285
 
@@ -1316,11 +1294,7 @@ function fetchJsonp(resource, callbackParameterName, functionName) {
1316
1294
  }
1317
1295
  };
1318
1296
 
1319
- Resource._Implementations.loadAndExecuteScript(
1320
- resource.url,
1321
- functionName,
1322
- deferred
1323
- );
1297
+ Resource._Implementations.loadAndExecuteScript(url, functionName, deferred);
1324
1298
  return deferred.promise;
1325
1299
  };
1326
1300
 
@@ -1376,7 +1350,8 @@ Resource.prototype._makeRequest = function (options) {
1376
1350
  checkAndResetRequest(resource.request);
1377
1351
 
1378
1352
  const request = resource.request;
1379
- request.url = resource.url;
1353
+ const url = resource.url;
1354
+ request.url = url;
1380
1355
 
1381
1356
  request.requestFunction = function () {
1382
1357
  const responseType = options.responseType;
@@ -1386,7 +1361,7 @@ Resource.prototype._makeRequest = function (options) {
1386
1361
  const data = options.data;
1387
1362
  const deferred = defer();
1388
1363
  const xhr = Resource._Implementations.loadWithXhr(
1389
- resource.url,
1364
+ url,
1390
1365
  responseType,
1391
1366
  method,
1392
1367
  data,
@@ -1433,6 +1408,25 @@ Resource.prototype._makeRequest = function (options) {
1433
1408
  });
1434
1409
  };
1435
1410
 
1411
+ /**
1412
+ * Checks to make sure the Resource isn't already being requested.
1413
+ *
1414
+ * @param {Request} request The request to check.
1415
+ *
1416
+ * @private
1417
+ */
1418
+ function checkAndResetRequest(request) {
1419
+ if (
1420
+ request.state === RequestState.ISSUED ||
1421
+ request.state === RequestState.ACTIVE
1422
+ ) {
1423
+ throw new RuntimeError("The Resource is already being fetched.");
1424
+ }
1425
+
1426
+ request.state = RequestState.UNISSUED;
1427
+ request.deferred = undefined;
1428
+ }
1429
+
1436
1430
  const dataUriRegex = /^data:(.*?)(;base64)?,(.*)$/;
1437
1431
 
1438
1432
  function decodeDataUriText(isBase64, data) {
@@ -2301,7 +2295,7 @@ Resource.DEFAULT = Object.freeze(
2301
2295
  * @callback Resource.RetryCallback
2302
2296
  *
2303
2297
  * @param {Resource} [resource] The resource that failed to load.
2304
- * @param {Error} [error] The error that occurred during the loading of the resource.
2298
+ * @param {RequestErrorEvent} [error] The error that occurred during the loading of the resource.
2305
2299
  * @returns {boolean|Promise<boolean>} If true or a promise that resolved to true, the resource will be retried. Otherwise the failure will be returned.
2306
2300
  */
2307
2301
  export default Resource;
@@ -22,7 +22,7 @@ function TerrainProvider() {
22
22
 
23
23
  Object.defineProperties(TerrainProvider.prototype, {
24
24
  /**
25
- * Gets an event that is raised when the terrain provider encounters an asynchronous error.. By subscribing
25
+ * Gets an event that is raised when the terrain provider encounters an asynchronous error. By subscribing
26
26
  * to the event, you will be notified of the error and can potentially recover from it. Event listeners
27
27
  * are passed an instance of {@link TileProviderError}.
28
28
  * @memberof TerrainProvider.prototype
@@ -35,8 +35,7 @@ Object.defineProperties(TerrainProvider.prototype, {
35
35
 
36
36
  /**
37
37
  * Gets the credit to display when this terrain provider is active. Typically this is used to credit
38
- * the source of the terrain. This function should
39
- * not be called before {@link TerrainProvider#ready} returns true.
38
+ * the source of the terrain.
40
39
  * @memberof TerrainProvider.prototype
41
40
  * @type {Credit}
42
41
  * @readonly
@@ -46,8 +45,7 @@ Object.defineProperties(TerrainProvider.prototype, {
46
45
  },
47
46
 
48
47
  /**
49
- * Gets the tiling scheme used by the provider. This function should
50
- * not be called before {@link TerrainProvider#ready} returns true.
48
+ * Gets the tiling scheme used by the provider.
51
49
  * @memberof TerrainProvider.prototype
52
50
  * @type {TilingScheme}
53
51
  * @readonly
@@ -61,6 +59,7 @@ Object.defineProperties(TerrainProvider.prototype, {
61
59
  * @memberof TerrainProvider.prototype
62
60
  * @type {boolean}
63
61
  * @readonly
62
+ * @deprecated
64
63
  */
65
64
  ready: {
66
65
  get: DeveloperError.throwInstantiationError,
@@ -71,6 +70,7 @@ Object.defineProperties(TerrainProvider.prototype, {
71
70
  * @memberof TerrainProvider.prototype
72
71
  * @type {Promise<boolean>}
73
72
  * @readonly
73
+ * @deprecated
74
74
  */
75
75
  readyPromise: {
76
76
  get: DeveloperError.throwInstantiationError,
@@ -79,8 +79,7 @@ Object.defineProperties(TerrainProvider.prototype, {
79
79
  /**
80
80
  * Gets a value indicating whether or not the provider includes a water mask. The water mask
81
81
  * indicates which areas of the globe are water rather than land, so they can be rendered
82
- * as a reflective surface with animated waves. This function should not be
83
- * called before {@link TerrainProvider#ready} returns true.
82
+ * as a reflective surface with animated waves.
84
83
  * @memberof TerrainProvider.prototype
85
84
  * @type {boolean}
86
85
  * @readonly
@@ -91,7 +90,6 @@ Object.defineProperties(TerrainProvider.prototype, {
91
90
 
92
91
  /**
93
92
  * Gets a value indicating whether or not the requested tiles include vertex normals.
94
- * This function should not be called before {@link TerrainProvider#ready} returns true.
95
93
  * @memberof TerrainProvider.prototype
96
94
  * @type {boolean}
97
95
  * @readonly
@@ -102,8 +100,7 @@ Object.defineProperties(TerrainProvider.prototype, {
102
100
 
103
101
  /**
104
102
  * Gets an object that can be used to determine availability of terrain from this provider, such as
105
- * at points and in rectangles. This function should not be called before
106
- * {@link TerrainProvider#ready} returns true. This property may be undefined if availability
103
+ * at points and in rectangles. This property may be undefined if availability
107
104
  * information is not available.
108
105
  * @memberof TerrainProvider.prototype
109
106
  * @type {TileAvailability}
@@ -399,8 +396,7 @@ TerrainProvider.getEstimatedLevelZeroGeometricErrorForAHeightmap = function (
399
396
  };
400
397
 
401
398
  /**
402
- * Requests the geometry for a given tile. This function should not be called before
403
- * {@link TerrainProvider#ready} returns true. The result must include terrain data and
399
+ * Requests the geometry for a given tile. The result must include terrain data and
404
400
  * may optionally include a water mask and an indication of which child tiles are available.
405
401
  * @function
406
402
  *
@@ -417,8 +413,7 @@ TerrainProvider.prototype.requestTileGeometry =
417
413
  DeveloperError.throwInstantiationError;
418
414
 
419
415
  /**
420
- * Gets the maximum geometric error allowed in a tile at a given level. This function should not be
421
- * called before {@link TerrainProvider#ready} returns true.
416
+ * Gets the maximum geometric error allowed in a tile at a given level.
422
417
  * @function
423
418
  *
424
419
  * @param {number} level The tile level for which to get the maximum geometric error.
@@ -92,14 +92,14 @@ function TileProviderError(
92
92
  * @param {TileProviderError} previousError The error instance returned by this function the last
93
93
  * time it was called for this error, or undefined if this is the first time this error has
94
94
  * occurred.
95
- * @param {ImageryProvider|TerrainProvider} provider The imagery or terrain provider that encountered the error.
96
- * @param {Event} event The event to raise to inform listeners of the error.
97
- * @param {string} message The message describing the error.
98
- * @param {number} x The X coordinate of the tile that experienced the error, or undefined if the
95
+ * @param {ImageryProvider|TerrainProvider} [provider] The imagery or terrain provider that encountered the error.
96
+ * @param {Event} [event] The event to raise to inform listeners of the error.
97
+ * @param {string} [message] The message describing the error.
98
+ * @param {number} [x] The X coordinate of the tile that experienced the error, or undefined if the
99
99
  * error is not specific to a particular tile.
100
- * @param {number} y The Y coordinate of the tile that experienced the error, or undefined if the
100
+ * @param {number} [y] The Y coordinate of the tile that experienced the error, or undefined if the
101
101
  * error is not specific to a particular tile.
102
- * @param {number} level The level-of-detail of the tile that experienced the error, or undefined if the
102
+ * @param {number} [level] The level-of-detail of the tile that experienced the error, or undefined if the
103
103
  * error is not specific to a particular tile.
104
104
  * @param {Error} [errorDetails] The error or exception that occurred, if any.
105
105
  * @returns {TileProviderError} The error instance that was passed to the event listeners and that
@@ -138,9 +138,9 @@ TileProviderError.reportError = function (
138
138
  ++error.timesRetried;
139
139
  }
140
140
 
141
- if (event.numberOfListeners > 0) {
141
+ if (defined(event) && event.numberOfListeners > 0) {
142
142
  event.raiseEvent(error);
143
- } else {
143
+ } else if (defined(provider)) {
144
144
  console.log(
145
145
  `An error occurred in "${provider.constructor.name}": ${formatError(
146
146
  message