leaflet-city-mapper 0.1.0 → 0.1.1

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 (515) hide show
  1. package/README.md +1 -1
  2. package/dist/leaflet-city-mapper-src.js.map +1 -1
  3. package/dist/leaflet-city-mapper-worker-src.js.map +1 -1
  4. package/dist/leaflet-city-mapper-worker.js.map +1 -1
  5. package/dist/leaflet-city-mapper.js.map +1 -1
  6. package/libs/leaflet-lens.js +151 -151
  7. package/libs/leaflet.js +3 -3
  8. package/libs/openlayers-bindings.js +1129 -1129
  9. package/libs/openlayers-bindings.min.js.map +1 -1
  10. package/package.json +2 -4
  11. package/src/animations/cancelCameraAnimation.js +19 -19
  12. package/src/animations/mapStopPitchBearingAnimation.js +10 -10
  13. package/src/animations/scheduleCameraAnimation.js +15 -15
  14. package/src/animations/scheduleMarkerPan.js +14 -14
  15. package/src/animations/updateZoomCamera.js +25 -25
  16. package/src/archives/findDirectoryEntry.js +17 -17
  17. package/src/archives/findTile.js +45 -45
  18. package/src/archives/getDirectoryEntries.js +30 -30
  19. package/src/archives/getTileData.js +26 -26
  20. package/src/archives/readArchiveRange.js +48 -48
  21. package/src/astronomy/solarTime.js +21 -21
  22. package/src/camera/cameraMapReady.js +9 -9
  23. package/src/camera/cleanupCameraMap.js +13 -13
  24. package/src/camera/constrainCameraToBounds.js +3 -3
  25. package/src/camera/createSceneCamera.js +25 -25
  26. package/src/camera/getBearing.js +10 -10
  27. package/src/camera/getPitch.js +10 -10
  28. package/src/camera/mapGetBoundsCenterZoom.js +14 -14
  29. package/src/camera/mapLimitOffset.js +17 -17
  30. package/src/camera/mapPanBy.js +14 -14
  31. package/src/camera/setBearing.js +13 -13
  32. package/src/camera/setPitch.js +13 -13
  33. package/src/cog/decodeCogTile.js +37 -37
  34. package/src/cog/finiteCogValues.js +12 -12
  35. package/src/cog/getCogAssetEntry.js +26 -26
  36. package/src/cog/getCogBase.js +22 -22
  37. package/src/cog/getCogHeader.js +10 -10
  38. package/src/cog/getCogProfile.js +25 -25
  39. package/src/cog/getCogTile.js +25 -25
  40. package/src/cog/getColorTile.js +38 -38
  41. package/src/cog/getElevationTile.js +29 -29
  42. package/src/cog/hasCogProjection.js +16 -16
  43. package/src/cog/initCog.js +13 -13
  44. package/src/cog/invalidCogFullResponse.js +10 -10
  45. package/src/cog/openCog.js +40 -40
  46. package/src/cog/openCogAsset.js +22 -22
  47. package/src/cog/readCog.js +39 -39
  48. package/src/cog/readCogBlock.js +19 -19
  49. package/src/cog/readCogBody.js +30 -30
  50. package/src/cog/readCogDirectories.js +32 -32
  51. package/src/cog/readCogDirectory.js +34 -34
  52. package/src/cog/readCogLevel.js +36 -36
  53. package/src/cog/readCogTag.js +28 -28
  54. package/src/cog/validCogDimensions.js +15 -15
  55. package/src/cog/validCogEncoding.js +18 -18
  56. package/src/cog/validCogGeoArrays.js +17 -17
  57. package/src/cog/validCogGrid.js +22 -22
  58. package/src/cog/validCogTileCoordinates.js +13 -13
  59. package/src/cog/validateCogContainer.js +17 -17
  60. package/src/cog/validateCogContentRange.js +18 -18
  61. package/src/cog/validateCogOffsets.js +19 -19
  62. package/src/cog/validateCogRange.js +16 -16
  63. package/src/cog/validateCogResponse.js +26 -26
  64. package/src/collision/collectIntersections.js +41 -41
  65. package/src/collision/hiddenLightHit.js +19 -19
  66. package/src/collision/indexTriangle.js +18 -18
  67. package/src/collision/insideMesh.js +47 -47
  68. package/src/collision/insideWalker.js +52 -52
  69. package/src/collision/intersectMeshes.js +40 -40
  70. package/src/collision/localRay.js +31 -31
  71. package/src/collision/mergeHits.js +19 -19
  72. package/src/collision/rayBounds.js +28 -28
  73. package/src/collision/readTriangle.js +32 -32
  74. package/src/collision/trafficCollision.js +23 -23
  75. package/src/collision/transformTriangle.js +18 -18
  76. package/src/collision/triangleDistance.js +34 -34
  77. package/src/collision/vertexCount.js +11 -11
  78. package/src/collision/worldHit.js +30 -30
  79. package/src/controls/acceptPitchDrag.js +10 -10
  80. package/src/controls/acceptRotateDrag.js +9 -9
  81. package/src/controls/addCameraHandler.js +18 -18
  82. package/src/controls/adjustCameraDrag.js +13 -13
  83. package/src/controls/cameraDragContextMenu.js +12 -12
  84. package/src/controls/cameraDragEnd.js +10 -10
  85. package/src/controls/cameraDragMove.js +31 -31
  86. package/src/controls/changeCameraTouch.js +17 -17
  87. package/src/controls/compassOrientation.js +12 -12
  88. package/src/controls/compassRemoveHooks.js +2 -2
  89. package/src/controls/containerResizeRemoveHooks.js +2 -2
  90. package/src/controls/endCameraTouch.js +18 -18
  91. package/src/controls/failCompassPermission.js +10 -10
  92. package/src/controls/finishCameraDrag.js +14 -14
  93. package/src/controls/finishCompassPermission.js +24 -24
  94. package/src/controls/isEditableTarget.js +9 -9
  95. package/src/controls/loadCameraControls.js +18 -18
  96. package/src/controls/moveCameraTouch.js +34 -34
  97. package/src/controls/refreshRotateFocus.js +5 -5
  98. package/src/controls/removeCameraDrag.js +28 -28
  99. package/src/controls/resizeMap.js +7 -7
  100. package/src/controls/rotateButtonClick.js +16 -16
  101. package/src/controls/rotateButtonKeydown.js +20 -20
  102. package/src/controls/rotateControl.js +12 -12
  103. package/src/controls/shiftRotateRemoveHooks.js +2 -2
  104. package/src/controls/shiftRotateWheel.js +15 -15
  105. package/src/core/cameraMarkerOnDrag.js +16 -16
  106. package/src/core/constructLayer.js +16 -16
  107. package/src/core/extendLeafletClass.js +12 -12
  108. package/src/core/extendTerrainPixelBounds.js +41 -41
  109. package/src/core/layerAddInitHook.js +12 -12
  110. package/src/core/layerMergeOptions.js +14 -14
  111. package/src/core/markerInitInteraction.js +10 -10
  112. package/src/core/markerSetIcon.js +14 -14
  113. package/src/core/markerSetRotation.js +19 -19
  114. package/src/core/projectNativePath.js +30 -30
  115. package/src/core/redrawPath.js +11 -11
  116. package/src/core/removeLayer.js +26 -26
  117. package/src/core/setRotation.js +12 -12
  118. package/src/core/whenReady.js +14 -14
  119. package/src/geometry/addBridges.js +36 -36
  120. package/src/geometry/addGeneratedTriangle.js +10 -10
  121. package/src/geometry/appendAreaTriangle.js +32 -32
  122. package/src/geometry/appendNativeTriangle.js +17 -17
  123. package/src/geometry/appendRouteDash.js +33 -33
  124. package/src/geometry/appendRouteSegment.js +28 -28
  125. package/src/geometry/assembleAreaGeometry.js +48 -48
  126. package/src/geometry/bridgeEdge.js +18 -18
  127. package/src/geometry/bridgeFaces.js +22 -22
  128. package/src/geometry/bridgePaths.js +19 -19
  129. package/src/geometry/bridgePolygon.js +37 -37
  130. package/src/geometry/bridgeSides.js +18 -18
  131. package/src/geometry/buildProjectedPoint.js +32 -32
  132. package/src/geometry/buildProjectedPolygon.js +34 -34
  133. package/src/geometry/circleAt.js +20 -20
  134. package/src/geometry/circleGeometry.js +41 -41
  135. package/src/geometry/createModelGeometry.js +44 -44
  136. package/src/geometry/crossVector.js +15 -15
  137. package/src/geometry/dashValues.js +23 -23
  138. package/src/geometry/dashedSegment.js +33 -33
  139. package/src/geometry/diskAt.js +18 -18
  140. package/src/geometry/emitter.js +18 -18
  141. package/src/geometry/fillNativePolygon.js +28 -28
  142. package/src/geometry/generateTreeGeometry.js +18 -18
  143. package/src/geometry/indexBridge.js +36 -36
  144. package/src/geometry/instanceAreaGeometry.js +37 -37
  145. package/src/geometry/line.js +28 -28
  146. package/src/geometry/lineJoin.js +35 -35
  147. package/src/geometry/markerImageBounds.js +20 -20
  148. package/src/geometry/meshShadowBounds.js +33 -33
  149. package/src/geometry/offsetBelowGround.js +10 -10
  150. package/src/geometry/quad.js +23 -23
  151. package/src/geometry/restoreGeometry.js +29 -29
  152. package/src/geometry/roofCoverage.js +33 -33
  153. package/src/geometry/roofFootprint.js +40 -40
  154. package/src/geometry/samePoint.js +11 -11
  155. package/src/geometry/segment.js +32 -32
  156. package/src/geometry/subtractRoofTile.js +28 -28
  157. package/src/geometry/terrainBuffers.js +36 -36
  158. package/src/geometry/terrainTileGeometry.js +28 -28
  159. package/src/geometry/validateTree.js +19 -19
  160. package/src/globals/L.js +6 -6
  161. package/src/globals/cameraFov.js +8 -8
  162. package/src/globals/cogTags.js +6 -6
  163. package/src/globals/colorTexture.js +11 -11
  164. package/src/globals/cosObliquity.js +8 -8
  165. package/src/globals/degrees.js +6 -6
  166. package/src/globals/earthCirc.js +6 -6
  167. package/src/globals/geometryWorkerUrl.js +8 -8
  168. package/src/globals/halfRadians.js +6 -6
  169. package/src/globals/lampDirections.js +13 -13
  170. package/src/globals/layerControlAddItem.js +8 -8
  171. package/src/globals/leafletLayer.js +8 -8
  172. package/src/globals/lightScale.js +6 -6
  173. package/src/globals/mvtTextDecoder.js +6 -6
  174. package/src/globals/nativeScalableStyleKeys.js +6 -6
  175. package/src/globals/sinObliquity.js +8 -8
  176. package/src/globals/tau.js +6 -6
  177. package/src/globals/vectorStyleNamedColors.js +13 -13
  178. package/src/globals/vectorTileEvents.js +6 -6
  179. package/src/globals/workerCogSource.js +6 -6
  180. package/src/gpu/initializeRendererResources.js +39 -39
  181. package/src/gpu/initializeSharedRenderer.js +59 -59
  182. package/src/gpu/mountRenderer.js +25 -25
  183. package/src/layer-controls/layerControlInputId.js +18 -18
  184. package/src/layer-controls/layerCountTitle.js +16 -16
  185. package/src/layer-controls/placeEntryElement.js +29 -29
  186. package/src/layer-controls/renderLayerCount.js +28 -28
  187. package/src/lighting/visitLightCells.js +26 -26
  188. package/src/lighting/writeLightCell.js +14 -14
  189. package/src/materials/createProgramLayout.js +44 -44
  190. package/src/materials/createProgramUniforms.js +25 -25
  191. package/src/materials/modelMaterialFor.js +29 -29
  192. package/src/materials/prepareMeshCutout.js +21 -21
  193. package/src/materials/terrainRasterProgram.js +65 -65
  194. package/src/materials/validateRoofMaterial.js +17 -17
  195. package/src/models/applyModelTransform.js +18 -18
  196. package/src/models/buildModelNodes.js +24 -24
  197. package/src/models/createModelContext.js +24 -24
  198. package/src/models/loadBuffer.js +16 -16
  199. package/src/models/loadModelResources.js +22 -22
  200. package/src/models/normalizeAccessor.js +21 -21
  201. package/src/models/prepareModel.js +29 -29
  202. package/src/models/prepareModelGeometry.js +35 -35
  203. package/src/models/prepareModelPrimitive.js +25 -25
  204. package/src/models/readAccessorValue.js +16 -16
  205. package/src/models/readModelAttributes.js +32 -32
  206. package/src/models/readModelIndices.js +28 -28
  207. package/src/models/readSparseAccessor.js +31 -31
  208. package/src/models/releaseModelResources.js +15 -15
  209. package/src/mvt/addMvtCrossings.js +23 -23
  210. package/src/mvt/appendMvtBandTriangles.js +42 -42
  211. package/src/mvt/appendMvtCoordinates.js +20 -20
  212. package/src/mvt/appendMvtPolygonTriangles.js +29 -29
  213. package/src/mvt/beginMvtPath.js +19 -19
  214. package/src/mvt/closeMvtPath.js +16 -16
  215. package/src/mvt/collectMvtEdges.js +29 -29
  216. package/src/mvt/createMvtReader.js +14 -14
  217. package/src/mvt/decodeVectorTile.js +39 -39
  218. package/src/mvt/expectMvtWire.js +11 -11
  219. package/src/mvt/finishMvtPath.js +14 -14
  220. package/src/mvt/finiteMvtCoordinate.js +14 -14
  221. package/src/mvt/groupMvtPolygons.js +35 -35
  222. package/src/mvt/isMvtFallbackError.js +13 -13
  223. package/src/mvt/mergeMvtActiveEdges.js +18 -18
  224. package/src/mvt/mvtEdgeX.js +12 -12
  225. package/src/mvt/mvtPathsVertices.js +15 -15
  226. package/src/mvt/mvtPolygonPaths.js +19 -19
  227. package/src/mvt/numericMvtValue.js +11 -11
  228. package/src/mvt/readMvtFeature.js +46 -46
  229. package/src/mvt/readMvtField.js +17 -17
  230. package/src/mvt/readMvtGeometry.js +42 -42
  231. package/src/mvt/readMvtInteger.js +22 -22
  232. package/src/mvt/readMvtKnownValue.js +30 -30
  233. package/src/mvt/readMvtLayer.js +40 -40
  234. package/src/mvt/readMvtMessage.js +18 -18
  235. package/src/mvt/readMvtNumber.js +18 -18
  236. package/src/mvt/readMvtNumbers.js +18 -18
  237. package/src/mvt/readMvtString.js +14 -14
  238. package/src/mvt/readMvtValue.js +29 -29
  239. package/src/mvt/skipMvtField.js +22 -22
  240. package/src/mvt/sortMvtActiveEdges.js +20 -20
  241. package/src/mvt/sortedMvtLevels.js +29 -29
  242. package/src/mvt/takeMvtBytes.js +18 -18
  243. package/src/mvt/tessellateVectorRings.js +26 -26
  244. package/src/mvt/triangulateVectorRings.js +23 -23
  245. package/src/native/beforeNativeRender.js +21 -21
  246. package/src/native/bypassNativeEvent.js +21 -21
  247. package/src/native/canScaleNativeStyle.js +26 -26
  248. package/src/native/compareNativeHits.js +10 -10
  249. package/src/native/createNativeMesh.js +46 -46
  250. package/src/native/forwardNativeError.js +8 -8
  251. package/src/native/getGridTerrainTile.js +47 -47
  252. package/src/native/gridTerrainElevation.js +34 -34
  253. package/src/native/isCurrentNativeLayer.js +11 -11
  254. package/src/native/loadGridTerrain.js +36 -36
  255. package/src/native/nativeEventSource.js +27 -27
  256. package/src/native/nativeProgram.js +28 -28
  257. package/src/native/nativeTerrainElevation.js +27 -27
  258. package/src/native/nativeVectorGeometry.js +30 -30
  259. package/src/native/orderNativeGridLayer.js +20 -20
  260. package/src/native/prepareGridTerrainRequests.js +23 -23
  261. package/src/native/pruneNativeResources.js +25 -25
  262. package/src/native/readyNativeGPU.js +13 -13
  263. package/src/native/rejectNativeReady.js +2 -2
  264. package/src/native/removeNativeEvents.js +20 -20
  265. package/src/native/resolveNativeReady.js +2 -2
  266. package/src/native/restoreNativeEvents.js +8 -8
  267. package/src/native/retainGridTerrain.js +15 -15
  268. package/src/native/styleNativeMesh.js +20 -20
  269. package/src/native/syncGridTile.js +28 -28
  270. package/src/native/syncImageOverlay.js +13 -13
  271. package/src/native/syncNativeStrokeAnchors.js +18 -18
  272. package/src/native/syncNativeStrokeZoom.js +34 -34
  273. package/src/native/syncTerrainGridTile.js +38 -38
  274. package/src/native/terrainGridMesh.js +47 -47
  275. package/src/native/updateNativeHover.js +15 -15
  276. package/src/native/updateNativeStrokeRadius.js +14 -14
  277. package/src/picking/hitColliderCell.js +29 -29
  278. package/src/picking/validateCameraInverse.js +15 -15
  279. package/src/projections/displayContainerPoint.js +32 -32
  280. package/src/projections/projectBridgePoint.js +17 -17
  281. package/src/projections/toPoint.js +13 -13
  282. package/src/projections/transformZoomAnimationPoint.js +8 -8
  283. package/src/projections/verticalGroundY.js +14 -14
  284. package/src/raster/rasterTileRange.js +32 -32
  285. package/src/raster/retainRasterTiles.js +21 -21
  286. package/src/rendering/collectVisibleMesh.js +48 -48
  287. package/src/rendering/compareMeshDepth.js +14 -14
  288. package/src/rendering/drawPipeline.js +44 -44
  289. package/src/rendering/nativeStrokeExpansion.js +11 -11
  290. package/src/rendering/prepareFrameBuffer.js +24 -24
  291. package/src/rendering/prepareMeshUniforms.js +36 -36
  292. package/src/rendering/revealRoofMesh.js +43 -43
  293. package/src/scene/addSceneLayer.js +24 -24
  294. package/src/scene/callLayer.js +34 -34
  295. package/src/scene/createLayer.js +13 -13
  296. package/src/scene/getLocation.js +12 -12
  297. package/src/scene/isNativeLayer.js +19 -19
  298. package/src/scene/removeSceneLayer.js +22 -22
  299. package/src/scene/reportLayerError.js +9 -9
  300. package/src/shaders/materialBaseShader.js +26 -26
  301. package/src/shaders/materialSurfaceShader.js +60 -60
  302. package/src/shaders/materialVertexShader.js +89 -89
  303. package/src/shaders/nativeStrokeShader.js +13 -13
  304. package/src/shaders/roofVertexShader.js +16 -16
  305. package/src/shadows/shadowMeshMatches.js +19 -19
  306. package/src/sources/buildAreaFeatures.js +23 -23
  307. package/src/sources/extrusionStyle.js +21 -21
  308. package/src/sources/featureAnchor.js +21 -21
  309. package/src/sources/groundOffset.js +9 -9
  310. package/src/sources/initVectorTiles.js +21 -21
  311. package/src/sources/isVectorTileSource.js +11 -11
  312. package/src/sources/matchesAreaTile.js +17 -17
  313. package/src/sources/pendingSourceAreas.js +28 -28
  314. package/src/sources/prepareAreaGeometryJob.js +34 -34
  315. package/src/sources/projectAreaPolygons.js +25 -25
  316. package/src/sources/readyVectorTiles.js +17 -17
  317. package/src/sunlight/addTimeControlToMap.js +18 -18
  318. package/src/sunlight/addTimeLayer.js +12 -12
  319. package/src/sunlight/initializeTimeControl.js +18 -18
  320. package/src/sunlight/onAddSun.js +37 -37
  321. package/src/sunlight/onAddTimeControl.js +12 -12
  322. package/src/sunlight/onRemoveSun.js +10 -10
  323. package/src/sunlight/removeSun.js +25 -25
  324. package/src/sunlight/removeTimeControl.js +14 -14
  325. package/src/sunlight/removeTimeLayer.js +11 -11
  326. package/src/sunlight/requestSunlightRender.js +12 -12
  327. package/src/sunlight/styleTimeControl.js +13 -13
  328. package/src/sunlight/tickSun.js +10 -10
  329. package/src/sunlight/updateCelestialDisc.js +23 -23
  330. package/src/sunlight/updateSun.js +44 -44
  331. package/src/sunlight/useLiveTime.js +11 -11
  332. package/src/sunlight/useSelectedTime.js +26 -26
  333. package/src/terrain/applyTerrain.js +30 -30
  334. package/src/terrain/copyTerrainTile.js +20 -20
  335. package/src/terrain/loadReadyTerrain.js +6 -6
  336. package/src/terrain/mapElevationOf.js +19 -19
  337. package/src/terrain/readBridges.js +13 -13
  338. package/src/terrain/readyTerrainOf.js +14 -14
  339. package/src/terrain/sampleTerrainTile.js +16 -16
  340. package/src/terrain/terrainTileQueue.js +34 -34
  341. package/src/textures/addImageState.js +13 -13
  342. package/src/textures/bindMeshTextures.js +57 -57
  343. package/src/textures/collectRoofTiles.js +23 -23
  344. package/src/textures/loadModelImage.js +29 -29
  345. package/src/textures/modelTextureFor.js +47 -47
  346. package/src/textures/prepareMeshTextures.js +31 -31
  347. package/src/textures/removeImageState.js +13 -13
  348. package/src/textures/resizeRoofTexture.js +32 -32
  349. package/src/textures/restoreMaterialTextures.js +22 -22
  350. package/src/textures/updateRoofAtlas.js +29 -29
  351. package/src/textures/uploadMeshTexture.js +32 -32
  352. package/src/textures/uploadNativeImage.js +26 -26
  353. package/src/textures/uploadRoofTile.js +29 -29
  354. package/src/traffic/createTrafficMesh.js +17 -17
  355. package/src/traffic/disposeTrafficObject.js +19 -19
  356. package/src/traffic/failTraffic.js +12 -12
  357. package/src/traffic/failedTrafficLoad.js +10 -10
  358. package/src/traffic/fetchTrafficLanes.js +21 -21
  359. package/src/traffic/loadedTrafficLanes.js +21 -21
  360. package/src/traffic/locateTraffic.js +20 -20
  361. package/src/traffic/moveTraffic.js +21 -21
  362. package/src/traffic/readyTraffic.js +10 -10
  363. package/src/traffic/refreshTrafficTrips.js +42 -42
  364. package/src/traffic/routeColor.js +13 -13
  365. package/src/traffic/startTraffic.js +12 -12
  366. package/src/traffic/trafficNow.js +15 -15
  367. package/src/traffic/trafficStatusText.js +13 -13
  368. package/src/traffic/trafficStorage.js +13 -13
  369. package/src/traffic/updateTraffic.js +13 -13
  370. package/src/traffic/updateTrafficLights.js +23 -23
  371. package/src/traffic/updateTrafficPose.js +15 -15
  372. package/src/traffic/updateTrafficTerrain.js +15 -15
  373. package/src/traffic/uploadTrafficLanes.js +27 -27
  374. package/src/transforms/composeLocalTransform.js +23 -23
  375. package/src/transforms/transformNativePoint.js +19 -19
  376. package/src/transforms/worldMatrixChanged.js +26 -26
  377. package/src/triangulation/clipEars.js +32 -32
  378. package/src/triangulation/connectHole.js +30 -30
  379. package/src/triangulation/cross.js +12 -12
  380. package/src/triangulation/equal.js +11 -11
  381. package/src/triangulation/intersects.js +21 -21
  382. package/src/triangulation/mergeHoles.js +19 -19
  383. package/src/triangulation/on.js +13 -13
  384. package/src/triangulation/polygonRings.js +22 -22
  385. package/src/triangulation/validateArea.js +19 -19
  386. package/src/utils/compareDistance.js +11 -11
  387. package/src/utils/yieldTask.js +12 -12
  388. package/src/vector-style/appendQuotedStyleCharacter.js +30 -30
  389. package/src/vector-style/arrayContainsRange.js +18 -18
  390. package/src/vector-style/evaluateBoolean.js +31 -31
  391. package/src/vector-style/evaluateCoalesceOrCase.js +34 -34
  392. package/src/vector-style/evaluateComparison.js +29 -29
  393. package/src/vector-style/evaluateIExpression.js +21 -21
  394. package/src/vector-style/evaluateInput.js +16 -16
  395. package/src/vector-style/evaluateInterpolate.js +36 -36
  396. package/src/vector-style/evaluateMatch.js +21 -21
  397. package/src/vector-style/evaluateMath.js +26 -26
  398. package/src/vector-style/evaluateMembership.js +29 -29
  399. package/src/vector-style/evaluateNegation.js +26 -26
  400. package/src/vector-style/evaluatePrimitive.js +21 -21
  401. package/src/vector-style/evaluateStep.js +20 -20
  402. package/src/vector-style/evaluateStyle.js +43 -43
  403. package/src/vector-style/evaluateToExpression.js +27 -27
  404. package/src/vector-style/fillVectorPaint.js +26 -26
  405. package/src/vector-style/lineVectorPaint.js +31 -31
  406. package/src/vector-style/parseFunctionalColor.js +23 -23
  407. package/src/vector-style/parseHexColor.js +20 -20
  408. package/src/vector-style/parseVectorStyle.js +20 -20
  409. package/src/vector-style/readPaintValue.js +17 -17
  410. package/src/vector-style/removeTrailingCommas.js +19 -19
  411. package/src/vector-style/scaleDashArray.js +25 -25
  412. package/src/vector-style/skipStyleComment.js +20 -20
  413. package/src/vector-style/stripStyleComments.js +28 -28
  414. package/src/vector-style/styleColor.js +18 -18
  415. package/src/vector-style/validateVectorLayers.js +18 -18
  416. package/src/vector-style/vectorPaint.js +17 -17
  417. package/src/vector-style/visibleStyle.js +16 -16
  418. package/src/vector-tiles/appendVectorBatch.js +34 -34
  419. package/src/vector-tiles/attachVectorTileBatch.js +25 -25
  420. package/src/vector-tiles/attachVectorTileBatches.js +26 -26
  421. package/src/vector-tiles/compareVectorLabelPriority.js +11 -11
  422. package/src/vector-tiles/compareVectorTileDistance.js +11 -11
  423. package/src/vector-tiles/createVectorLabel.js +37 -37
  424. package/src/vector-tiles/forwardVectorTileError.js +10 -10
  425. package/src/vector-tiles/loadVectorSprite.js +14 -14
  426. package/src/vector-tiles/loadVectorTile.js +45 -45
  427. package/src/vector-tiles/onVectorTileAdd.js +44 -44
  428. package/src/vector-tiles/onVectorTileMessage.js +15 -15
  429. package/src/vector-tiles/onVectorTileRemove.js +25 -25
  430. package/src/vector-tiles/onVectorTileWorkerError.js +16 -16
  431. package/src/vector-tiles/paintVectorTileBatch.js +18 -18
  432. package/src/vector-tiles/prepareVectorLabel.js +34 -34
  433. package/src/vector-tiles/prepareVectorStyleLayer.js +38 -38
  434. package/src/vector-tiles/prepareVectorTile.js +29 -29
  435. package/src/vector-tiles/projectVectorPaths.js +25 -25
  436. package/src/vector-tiles/projectVectorPoint.js +15 -15
  437. package/src/vector-tiles/projectVectorTriangles.js +28 -28
  438. package/src/vector-tiles/pruneVectorTiles.js +14 -14
  439. package/src/vector-tiles/pumpVectorTiles.js +21 -21
  440. package/src/vector-tiles/readTileJSON.js +27 -27
  441. package/src/vector-tiles/readVectorStyle.js +28 -28
  442. package/src/vector-tiles/refreshVectorTiles.js +8 -8
  443. package/src/vector-tiles/reserveVectorLabelCells.js +14 -14
  444. package/src/vector-tiles/retireVectorTileGroup.js +20 -20
  445. package/src/vector-tiles/revokeVectorWorkerUrl.js +14 -14
  446. package/src/vector-tiles/rotateVectorLabel.js +19 -19
  447. package/src/vector-tiles/rotateVectorLabels.js +9 -9
  448. package/src/vector-tiles/simplifyVectorPath.js +29 -29
  449. package/src/vector-tiles/updateVectorLabelMarker.js +36 -36
  450. package/src/vector-tiles/updateVectorLabelStyle.js +14 -14
  451. package/src/vector-tiles/updateVectorTileLabels.js +33 -33
  452. package/src/vector-tiles/updateVectorTilePaint.js +25 -25
  453. package/src/vector-tiles/updateVectorTiles.js +32 -32
  454. package/src/vector-tiles/validateVectorTileZooms.js +15 -15
  455. package/src/vector-tiles/vectorFeaturePaint.js +25 -25
  456. package/src/vector-tiles/vectorFeaturePaths.js +26 -26
  457. package/src/vector-tiles/vectorFeatureZoom.js +18 -18
  458. package/src/vector-tiles/vectorLabelAnchors.js +31 -31
  459. package/src/vector-tiles/vectorLabelCandidates.js +18 -18
  460. package/src/vector-tiles/vectorLabelCells.js +32 -32
  461. package/src/vector-tiles/vectorLabelIcon.js +38 -38
  462. package/src/vector-tiles/vectorLabelProperty.js +12 -12
  463. package/src/vector-tiles/vectorLabelText.js +19 -19
  464. package/src/vector-tiles/vectorSpriteIcon.js +19 -19
  465. package/src/vector-tiles/vectorStraightRun.js +23 -23
  466. package/src/vector-tiles/vectorStyleDependencies.js +22 -22
  467. package/src/vector-tiles/vectorStyleValue.js +16 -16
  468. package/src/vector-tiles/vectorStyleZoom.js +12 -12
  469. package/src/vector-tiles/vectorTileAwaited.js +17 -17
  470. package/src/vector-tiles/vectorTileOverlaps.js +12 -12
  471. package/src/vector-tiles/vectorTilePaint.js +18 -18
  472. package/src/vector-tiles/vectorTileSettings.js +27 -27
  473. package/src/vector-tiles/vectorTilesIdle.js +11 -11
  474. package/src/vector-tiles/vectorTolerance.js +11 -11
  475. package/src/vector-tiles/wrapVectorLabel.js +17 -17
  476. package/src/vehicles/boatModel.js +35 -35
  477. package/src/vehicles/busModel.js +13 -13
  478. package/src/vehicles/carModel.js +39 -39
  479. package/src/walk/initializeWalkControl.js +12 -12
  480. package/src/walk/isWalkBlocked.js +15 -15
  481. package/src/walk/landWalker.js +41 -41
  482. package/src/walk/moveWalker.js +37 -37
  483. package/src/walk/onAddWalkControl.js +40 -40
  484. package/src/walk/onRemoveWalkControl.js +17 -17
  485. package/src/walk/onWalkBlur.js +3 -3
  486. package/src/walk/onWalkTerrain.js +3 -3
  487. package/src/walk/resolveWalkerPosition.js +33 -33
  488. package/src/walk/stepWalkerHeight.js +18 -18
  489. package/src/walk/toggleWalking.js +4 -4
  490. package/src/walk/updateWalkerFrame.js +29 -29
  491. package/src/walk/updateWalkerView.js +31 -31
  492. package/src/weakmaps/cameraHandlersByMap.js +6 -6
  493. package/src/weakmaps/geometryWorkersByMap.js +6 -6
  494. package/src/weakmaps/nativeProgramsByRenderer.js +6 -6
  495. package/src/weakmaps/pathProjectionByMap.js +6 -6
  496. package/src/weakmaps/streamTerrainByLayer.js +6 -6
  497. package/src/weakmaps/streamTerrainByMap.js +6 -6
  498. package/src/weakmaps/sunByMap.js +6 -6
  499. package/src/weakmaps/vectorTileOptionsByLayer.js +6 -6
  500. package/src/weakmaps/vectorWorkerByLayer.js +6 -6
  501. package/src/weakmaps/walkByMap.js +6 -6
  502. package/src/weakmaps/workerMapByLayer.js +6 -6
  503. package/src/workers/acquireGeometryWorker.js +39 -39
  504. package/src/workers/buildAreaInWorker.js +24 -24
  505. package/src/workers/closeGeometryWorkers.js +16 -16
  506. package/src/workers/cogWorker.js +27 -27
  507. package/src/workers/createGeometryWorker.js +30 -30
  508. package/src/workers/geometryWorker.js +34 -34
  509. package/src/workers/getCogInWorker.js +18 -18
  510. package/src/workers/modelWorker.js +17 -17
  511. package/src/workers/openCogInWorker.js +22 -22
  512. package/src/workers/runSourceWorker.js +44 -44
  513. package/src/workers/settleGeometryWorker.js +16 -16
  514. package/src/workers/startGeometryWorker.js +23 -23
  515. package/src/workers/vectorTileWorker.js +15 -15
@@ -1,40 +1,40 @@
1
- import { readCog } from './readCog.js';
2
- import { readCogDirectories } from './readCogDirectories.js';
3
- import { getCogTile } from './getCogTile.js';
4
- import { getCogHeader } from './getCogHeader.js';
5
- import { openCogAsset } from './openCogAsset.js';
6
-
7
- /**
8
- * Open an EPSG:3857 COG, standalone or as a named asset in a PMTiles container.
9
- *
10
- * @param {string} url COG or container URL.
11
- * @param {string} [asset] Named COG asset in the container.
12
- *
13
- * @returns {Promise<Object>} Archive-compatible header and XYZ tile methods.
14
- *
15
- * @throws {Error} If TIFF byte order is invalid.
16
- * @throws {Error} If the file is not classic TIFF.
17
- */
18
- export async function openCog(url, asset) {
19
- const source = asset === undefined ? /* alloc */ { url } : await openCogAsset(url, asset);
20
- source.levels = /* alloc */ new Map();
21
- const header = /* alloc */ new DataView(await readCog(source, 0, 8));
22
- const order = header.getUint16(0);
23
- if (order !== 0x4949 && order !== 0x4d4d) throw /* alloc */ new Error('Invalid TIFF byte order');
24
- source.little = order === 0x4949;
25
- if (header.getUint16(2, source.little) !== 42) throw /* alloc */ new Error('Expected classic TIFF (BigTIFF is not supported)');
26
- const { base, minZoom, maxZoom } = await readCogDirectories(source, header.getUint32(4, source.little));
27
- const half = 20037508.342789244;
28
- const left = base.left + base.resolution / 2, right = base.left + (base.width - 0.5) * base.resolution;
29
- const top = base.top - base.resolution / 2, bottom = base.top - (base.height - 0.5) * base.resolution;
30
- source.header = /* alloc */ {
31
- minZoom, maxZoom, tileType: base.elevation ? 0 : 2,
32
- minLon: left / half * 180, maxLon: right / half * 180,
33
- minLat: Math.atan(Math.sinh(bottom / half * Math.PI)) * 180 / Math.PI,
34
- maxLat: Math.atan(Math.sinh(top / half * Math.PI)) * 180 / Math.PI,
35
- };
36
- return /* alloc */ {
37
- getHeader: getCogHeader.bind(null, source),
38
- getZxy: getCogTile.bind(null, source),
39
- };
40
- }
1
+ import { readCog } from './readCog.js';
2
+ import { readCogDirectories } from './readCogDirectories.js';
3
+ import { getCogTile } from './getCogTile.js';
4
+ import { getCogHeader } from './getCogHeader.js';
5
+ import { openCogAsset } from './openCogAsset.js';
6
+
7
+ /**
8
+ * Open an EPSG:3857 COG, standalone or as a named asset in a PMTiles container.
9
+ *
10
+ * @param {string} url COG or container URL.
11
+ * @param {string} [asset] Named COG asset in the container.
12
+ *
13
+ * @returns {Promise<Object>} Archive-compatible header and XYZ tile methods.
14
+ *
15
+ * @throws {Error} If TIFF byte order is invalid.
16
+ * @throws {Error} If the file is not classic TIFF.
17
+ */
18
+ export async function openCog(url, asset) {
19
+ const source = asset === undefined ? /* alloc */ { url } : await openCogAsset(url, asset);
20
+ source.levels = /* alloc */ new Map();
21
+ const header = /* alloc */ new DataView(await readCog(source, 0, 8));
22
+ const order = header.getUint16(0);
23
+ if (order !== 0x4949 && order !== 0x4d4d) throw /* alloc */ new Error('Invalid TIFF byte order');
24
+ source.little = order === 0x4949;
25
+ if (header.getUint16(2, source.little) !== 42) throw /* alloc */ new Error('Expected classic TIFF (BigTIFF is not supported)');
26
+ const { base, minZoom, maxZoom } = await readCogDirectories(source, header.getUint32(4, source.little));
27
+ const half = 20037508.342789244;
28
+ const left = base.left + base.resolution / 2, right = base.left + (base.width - 0.5) * base.resolution;
29
+ const top = base.top - base.resolution / 2, bottom = base.top - (base.height - 0.5) * base.resolution;
30
+ source.header = /* alloc */ {
31
+ minZoom, maxZoom, tileType: base.elevation ? 0 : 2,
32
+ minLon: left / half * 180, maxLon: right / half * 180,
33
+ minLat: Math.atan(Math.sinh(bottom / half * Math.PI)) * 180 / Math.PI,
34
+ maxLat: Math.atan(Math.sinh(top / half * Math.PI)) * 180 / Math.PI,
35
+ };
36
+ return /* alloc */ {
37
+ getHeader: getCogHeader.bind(null, source),
38
+ getZxy: getCogTile.bind(null, source),
39
+ };
40
+ }
@@ -1,22 +1,22 @@
1
- import { decodeHeader } from '../archives/decodeHeader.js';
2
- import { readCog } from './readCog.js';
3
- import { validateCogContainer } from './validateCogContainer.js';
4
- import { getCogAssetEntry } from './getCogAssetEntry.js';
5
-
6
- /**
7
- * Open a named COG asset within a PMTiles container as a bounded byte source.
8
- *
9
- * @param {string} url Container URL.
10
- * @param {string} asset Asset name.
11
- *
12
- * @returns {Promise<Object>} COG source with container offset and size.
13
- */
14
- export async function openCogAsset(url, asset) {
15
- const container = /* alloc */ { url };
16
- const header = decodeHeader(await readCog(container, 0, 127));
17
- validateCogContainer(container, header);
18
- const entry = await getCogAssetEntry(container, header, asset);
19
- const baseOffset = header.tileDataOffset + entry.offset;
20
- return /* alloc */ { url, baseOffset, size: entry.length, containerSize: container.size,
21
- etag: container.etag, full: container.full?.slice(baseOffset, baseOffset + entry.length) };
22
- }
1
+ import { decodeHeader } from '../archives/decodeHeader.js';
2
+ import { readCog } from './readCog.js';
3
+ import { validateCogContainer } from './validateCogContainer.js';
4
+ import { getCogAssetEntry } from './getCogAssetEntry.js';
5
+
6
+ /**
7
+ * Open a named COG asset within a PMTiles container as a bounded byte source.
8
+ *
9
+ * @param {string} url Container URL.
10
+ * @param {string} asset Asset name.
11
+ *
12
+ * @returns {Promise<Object>} COG source with container offset and size.
13
+ */
14
+ export async function openCogAsset(url, asset) {
15
+ const container = /* alloc */ { url };
16
+ const header = decodeHeader(await readCog(container, 0, 127));
17
+ validateCogContainer(container, header);
18
+ const entry = await getCogAssetEntry(container, header, asset);
19
+ const baseOffset = header.tileDataOffset + entry.offset;
20
+ return /* alloc */ { url, baseOffset, size: entry.length, containerSize: container.size,
21
+ etag: container.etag, full: container.full?.slice(baseOffset, baseOffset + entry.length) };
22
+ }
@@ -1,39 +1,39 @@
1
- import { validateCogRange } from './validateCogRange.js';
2
- import { validateCogResponse } from './validateCogResponse.js';
3
- import { readCogBody } from './readCogBody.js';
4
-
5
- /**
6
- * Read a validated byte range from a COG source, caching an accepted full response.
7
- *
8
- * @param {Object} source COG byte source and response state.
9
- * @param {number} offset Byte offset relative to the source.
10
- * @param {number} length Number of bytes to read.
11
- * @param {AbortSignal} [signal] Request cancellation signal.
12
- *
13
- * @returns {Promise<ArrayBuffer>} Requested bytes.
14
- *
15
- * @throws {Error} If the HTTP response is unsuccessful.
16
- * @throws {Error} If a full PMTiles container response is truncated.
17
- * @throws {Error} If the resulting byte range is truncated.
18
- */
19
- export async function readCog(source, offset, length, signal) {
20
- signal?.throwIfAborted();
21
- validateCogRange(source, offset, length);
22
- if (source.full) return source.full.slice(offset, offset + length);
23
- const rangeStart = (source.baseOffset || 0) + offset;
24
- const response = await fetch(source.url, /* alloc */ {
25
- headers: /* alloc */ { Range: `bytes=${rangeStart}-${rangeStart + length - 1}` }, signal,
26
- });
27
- if (!response.ok) throw /* alloc */ new Error(`Unable to read COG: HTTP ${response.status}`);
28
- validateCogResponse(source, response, rangeStart, length);
29
- const data = await readCogBody(response, length);
30
- if (response.status === 200) {
31
- if (source.baseOffset === undefined) source.size = data.byteLength;
32
- else if (data.byteLength !== source.containerSize) throw /* alloc */ new Error('Truncated PMTiles COG container');
33
- source.full = source.baseOffset === undefined ? data.buffer
34
- : data.slice(source.baseOffset, source.baseOffset + source.size);
35
- }
36
- const result = response.status === 200 ? source.full.slice(offset, offset + length) : data.buffer;
37
- if (result.byteLength !== length) throw /* alloc */ new Error('Truncated COG byte range');
38
- return result;
39
- }
1
+ import { validateCogRange } from './validateCogRange.js';
2
+ import { validateCogResponse } from './validateCogResponse.js';
3
+ import { readCogBody } from './readCogBody.js';
4
+
5
+ /**
6
+ * Read a validated byte range from a COG source, caching an accepted full response.
7
+ *
8
+ * @param {Object} source COG byte source and response state.
9
+ * @param {number} offset Byte offset relative to the source.
10
+ * @param {number} length Number of bytes to read.
11
+ * @param {AbortSignal} [signal] Request cancellation signal.
12
+ *
13
+ * @returns {Promise<ArrayBuffer>} Requested bytes.
14
+ *
15
+ * @throws {Error} If the HTTP response is unsuccessful.
16
+ * @throws {Error} If a full PMTiles container response is truncated.
17
+ * @throws {Error} If the resulting byte range is truncated.
18
+ */
19
+ export async function readCog(source, offset, length, signal) {
20
+ signal?.throwIfAborted();
21
+ validateCogRange(source, offset, length);
22
+ if (source.full) return source.full.slice(offset, offset + length);
23
+ const rangeStart = (source.baseOffset || 0) + offset;
24
+ const response = await fetch(source.url, /* alloc */ {
25
+ headers: /* alloc */ { Range: `bytes=${rangeStart}-${rangeStart + length - 1}` }, signal,
26
+ });
27
+ if (!response.ok) throw /* alloc */ new Error(`Unable to read COG: HTTP ${response.status}`);
28
+ validateCogResponse(source, response, rangeStart, length);
29
+ const data = await readCogBody(response, length);
30
+ if (response.status === 200) {
31
+ if (source.baseOffset === undefined) source.size = data.byteLength;
32
+ else if (data.byteLength !== source.containerSize) throw /* alloc */ new Error('Truncated PMTiles COG container');
33
+ source.full = source.baseOffset === undefined ? data.buffer
34
+ : data.slice(source.baseOffset, source.baseOffset + source.size);
35
+ }
36
+ const result = response.status === 200 ? source.full.slice(offset, offset + length) : data.buffer;
37
+ if (result.byteLength !== length) throw /* alloc */ new Error('Truncated COG byte range');
38
+ return result;
39
+ }
@@ -1,19 +1,19 @@
1
- import { readCog } from './readCog.js';
2
- import { decodeCogTile } from './decodeCogTile.js';
3
-
4
- /**
5
- * Read and decode one TIFF tile block from a COG level.
6
- *
7
- * @param {Object} source Open COG byte source.
8
- * @param {Object} level COG level with block offsets and lengths.
9
- * @param {number} x Block column within the level.
10
- * @param {number} y Block row within the level.
11
- * @param {AbortSignal} [signal] Request cancellation signal.
12
- *
13
- * @returns {Promise<ArrayBuffer>} Decoded block data.
14
- */
15
- export async function readCogBlock(source, level, x, y, signal) {
16
- const index = y * level.columns + x;
17
- return decodeCogTile(await readCog(source, level.offsets[index], level.lengths[index], signal),
18
- 256 * 256 * (level.elevation ? 4 : level.samples), level.compression);
19
- }
1
+ import { readCog } from './readCog.js';
2
+ import { decodeCogTile } from './decodeCogTile.js';
3
+
4
+ /**
5
+ * Read and decode one TIFF tile block from a COG level.
6
+ *
7
+ * @param {Object} source Open COG byte source.
8
+ * @param {Object} level COG level with block offsets and lengths.
9
+ * @param {number} x Block column within the level.
10
+ * @param {number} y Block row within the level.
11
+ * @param {AbortSignal} [signal] Request cancellation signal.
12
+ *
13
+ * @returns {Promise<ArrayBuffer>} Decoded block data.
14
+ */
15
+ export async function readCogBlock(source, level, x, y, signal) {
16
+ const index = y * level.columns + x;
17
+ return decodeCogTile(await readCog(source, level.offsets[index], level.lengths[index], signal),
18
+ 256 * 256 * (level.elevation ? 4 : level.samples), level.compression);
19
+ }
@@ -1,30 +1,30 @@
1
- /**
2
- * Read a COG HTTP body while enforcing the range or full-response size limit.
3
- *
4
- * @param {Response} response HTTP response with a readable body.
5
- * @param {number} length Expected byte length for a range response.
6
- *
7
- * @returns {Promise<Uint8Array>} Response bytes.
8
- *
9
- * @throws {Error} If the response exceeds its permitted size.
10
- */
11
- export async function readCogBody(response, length) {
12
- const reader = response.body.getReader(), chunks = /* alloc */ [];
13
- let total = 0, part;
14
- try {
15
- while (!(part = await reader.read()).done) {
16
- total += part.value.byteLength;
17
- if (total > (response.status === 206 ? length : 32000000)) {
18
- await reader.cancel();
19
- throw /* alloc */ new Error('Oversized COG response');
20
- }
21
- chunks.push(part.value);
22
- }
23
- } finally {
24
- reader.releaseLock();
25
- }
26
- const data = /* alloc */ new Uint8Array(total);
27
- let start = 0, chunk;
28
- for (chunk of chunks) { data.set(chunk, start); start += chunk.length; }
29
- return data;
30
- }
1
+ /**
2
+ * Read a COG HTTP body while enforcing the range or full-response size limit.
3
+ *
4
+ * @param {Response} response HTTP response with a readable body.
5
+ * @param {number} length Expected byte length for a range response.
6
+ *
7
+ * @returns {Promise<Uint8Array>} Response bytes.
8
+ *
9
+ * @throws {Error} If the response exceeds its permitted size.
10
+ */
11
+ export async function readCogBody(response, length) {
12
+ const reader = response.body.getReader(), chunks = /* alloc */ [];
13
+ let total = 0, part;
14
+ try {
15
+ while (!(part = await reader.read()).done) {
16
+ total += part.value.byteLength;
17
+ if (total > (response.status === 206 ? length : 32000000)) {
18
+ await reader.cancel();
19
+ throw /* alloc */ new Error('Oversized COG response');
20
+ }
21
+ chunks.push(part.value);
22
+ }
23
+ } finally {
24
+ reader.releaseLock();
25
+ }
26
+ const data = /* alloc */ new Uint8Array(total);
27
+ let start = 0, chunk;
28
+ for (chunk of chunks) { data.set(chunk, start); start += chunk.length; }
29
+ return data;
30
+ }
@@ -1,32 +1,32 @@
1
- import { readCogDirectory } from './readCogDirectory.js';
2
- import { readCogLevel } from './readCogLevel.js';
3
-
4
- /**
5
- * Read TIFF image directories and register contiguous COG zoom levels.
6
- *
7
- * @param {Object} source Open COG byte source.
8
- * @param {number} offset First TIFF directory offset.
9
- *
10
- * @returns {Promise<Object>} Base image and minimum and maximum zoom.
11
- *
12
- * @throws {Error} If directories are cyclic or exceed the supported count.
13
- * @throws {Error} If there is no image directory.
14
- * @throws {Error} If overview zoom levels are not contiguous.
15
- */
16
- export async function readCogDirectories(source, offset) {
17
- const state = /* alloc */ { base: null, minZoom: Infinity, maxZoom: -Infinity };
18
- const seen = /* alloc */ new Set();
19
- let directory;
20
- while (offset) {
21
- if (seen.has(offset) || seen.size >= 24) throw /* alloc */ new Error('Cyclic or excessive COG directories');
22
- seen.add(offset);
23
- directory = await readCogDirectory(source, offset);
24
- readCogLevel(source, directory, state);
25
- offset = directory.next;
26
- }
27
- if (!state.base) throw /* alloc */ new Error('COG has no image directory');
28
- if (source.levels.size !== state.maxZoom - state.minZoom + 1) {
29
- throw /* alloc */ new Error('COG overview zooms must be contiguous');
30
- }
31
- return /* alloc */ { base: state.base, minZoom: state.minZoom, maxZoom: state.maxZoom };
32
- }
1
+ import { readCogDirectory } from './readCogDirectory.js';
2
+ import { readCogLevel } from './readCogLevel.js';
3
+
4
+ /**
5
+ * Read TIFF image directories and register contiguous COG zoom levels.
6
+ *
7
+ * @param {Object} source Open COG byte source.
8
+ * @param {number} offset First TIFF directory offset.
9
+ *
10
+ * @returns {Promise<Object>} Base image and minimum and maximum zoom.
11
+ *
12
+ * @throws {Error} If directories are cyclic or exceed the supported count.
13
+ * @throws {Error} If there is no image directory.
14
+ * @throws {Error} If overview zoom levels are not contiguous.
15
+ */
16
+ export async function readCogDirectories(source, offset) {
17
+ const state = /* alloc */ { base: null, minZoom: Infinity, maxZoom: -Infinity };
18
+ const seen = /* alloc */ new Set();
19
+ let directory;
20
+ while (offset) {
21
+ if (seen.has(offset) || seen.size >= 24) throw /* alloc */ new Error('Cyclic or excessive COG directories');
22
+ seen.add(offset);
23
+ directory = await readCogDirectory(source, offset);
24
+ readCogLevel(source, directory, state);
25
+ offset = directory.next;
26
+ }
27
+ if (!state.base) throw /* alloc */ new Error('COG has no image directory');
28
+ if (source.levels.size !== state.maxZoom - state.minZoom + 1) {
29
+ throw /* alloc */ new Error('COG overview zooms must be contiguous');
30
+ }
31
+ return /* alloc */ { base: state.base, minZoom: state.minZoom, maxZoom: state.maxZoom };
32
+ }
@@ -1,34 +1,34 @@
1
- import { readCog } from './readCog.js';
2
- import { cogTags } from '../globals/cogTags.js';
3
- import { readCogTag } from './readCogTag.js';
4
-
5
- /**
6
- * Read supported TIFF tags from one image directory.
7
- *
8
- * @param {Object} source Open COG byte source.
9
- * @param {number} offset Directory byte offset.
10
- *
11
- * @returns {Promise<Object>} Tag map and next directory offset.
12
- *
13
- * @throws {Error} If the directory size is invalid.
14
- * @throws {Error} If a nodata tag is present.
15
- * @throws {Error} If an affine transformation tag is present.
16
- * @throws {Error} If a supported tag is duplicated.
17
- */
18
- export async function readCogDirectory(source, offset) {
19
- const little = source.little;
20
- const count = /* alloc */ new DataView(await readCog(source, offset, 2)).getUint16(0, little);
21
- if (!count || count > 128) throw /* alloc */ new Error('Invalid COG directory size');
22
- const entries = /* alloc */ new DataView(await readCog(source, offset + 2, count * 12 + 4));
23
- const tags = /* alloc */ new Map();
24
- let i, tag;
25
- for (i = 0; i < count; i++) {
26
- tag = entries.getUint16(i * 12, little);
27
- if (tag === 42113) throw /* alloc */ new Error('COG nodata tags are not supported; export complete tiles');
28
- if (tag === 34264) throw /* alloc */ new Error('COG affine transformation matrices are not supported');
29
- if (!cogTags.includes(tag)) continue;
30
- if (tags.has(tag)) throw /* alloc */ new Error('Duplicate COG tag');
31
- tags.set(tag, await readCogTag(source, entries, i, tag, little));
32
- }
33
- return /* alloc */ { tags, next: entries.getUint32(count * 12, little) };
34
- }
1
+ import { readCog } from './readCog.js';
2
+ import { cogTags } from '../globals/cogTags.js';
3
+ import { readCogTag } from './readCogTag.js';
4
+
5
+ /**
6
+ * Read supported TIFF tags from one image directory.
7
+ *
8
+ * @param {Object} source Open COG byte source.
9
+ * @param {number} offset Directory byte offset.
10
+ *
11
+ * @returns {Promise<Object>} Tag map and next directory offset.
12
+ *
13
+ * @throws {Error} If the directory size is invalid.
14
+ * @throws {Error} If a nodata tag is present.
15
+ * @throws {Error} If an affine transformation tag is present.
16
+ * @throws {Error} If a supported tag is duplicated.
17
+ */
18
+ export async function readCogDirectory(source, offset) {
19
+ const little = source.little;
20
+ const count = /* alloc */ new DataView(await readCog(source, offset, 2)).getUint16(0, little);
21
+ if (!count || count > 128) throw /* alloc */ new Error('Invalid COG directory size');
22
+ const entries = /* alloc */ new DataView(await readCog(source, offset + 2, count * 12 + 4));
23
+ const tags = /* alloc */ new Map();
24
+ let i, tag;
25
+ for (i = 0; i < count; i++) {
26
+ tag = entries.getUint16(i * 12, little);
27
+ if (tag === 42113) throw /* alloc */ new Error('COG nodata tags are not supported; export complete tiles');
28
+ if (tag === 34264) throw /* alloc */ new Error('COG affine transformation matrices are not supported');
29
+ if (!cogTags.includes(tag)) continue;
30
+ if (tags.has(tag)) throw /* alloc */ new Error('Duplicate COG tag');
31
+ tags.set(tag, await readCogTag(source, entries, i, tag, little));
32
+ }
33
+ return /* alloc */ { tags, next: entries.getUint32(count * 12, little) };
34
+ }
@@ -1,36 +1,36 @@
1
- import { getCogProfile } from './getCogProfile.js';
2
- import { getCogBase } from './getCogBase.js';
3
- import { validCogGrid } from './validCogGrid.js';
4
- import { validateCogOffsets } from './validateCogOffsets.js';
5
-
6
- /**
7
- * Validate and register one TIFF directory as a COG XYZ level.
8
- *
9
- * @param {Object} source Open COG source and level map.
10
- * @param {Object} directory TIFF directory with parsed tags.
11
- * @param {Object} state Mutable base image and zoom range.
12
- *
13
- * @throws {Error} If the level does not align with the supported Web Mercator grid.
14
- */
15
- export function readCogLevel(source, directory, state) {
16
- const tags = directory.tags, profile = getCogProfile(tags);
17
- if (!state.base) state.base = getCogBase(tags, profile.width, profile.height, profile.elevation);
18
- const base = state.base, resolution = base.resolution * base.width / profile.width;
19
- const zoom = Math.round(Math.log2(20037508.342789244 * 2 / (256 * resolution)));
20
- const span = 20037508.342789244 * 2 / 2 ** zoom;
21
- let x = (base.left + 20037508.342789244) / span;
22
- let y = (20037508.342789244 - base.top) / span;
23
- if (Math.abs(x - Math.round(x)) < 1e-6) x = Math.round(x);
24
- if (Math.abs(y - Math.round(y)) < 1e-6) y = Math.round(y);
25
- if (!validCogGrid(source, base, profile, zoom, x, y, resolution)) {
26
- throw /* alloc */ new Error('COG levels must align with the Web Mercator XYZ tile grid');
27
- }
28
- const level = /* alloc */ {
29
- x, y, columns: profile.width / 256, rows: profile.height / 256, samples: profile.samples,
30
- elevation: profile.elevation, compression: tags.get(259)[0], offsets: tags.get(324), lengths: tags.get(325),
31
- };
32
- validateCogOffsets(source, level);
33
- source.levels.set(zoom, level);
34
- state.minZoom = Math.min(state.minZoom, zoom);
35
- state.maxZoom = Math.max(state.maxZoom, zoom);
36
- }
1
+ import { getCogProfile } from './getCogProfile.js';
2
+ import { getCogBase } from './getCogBase.js';
3
+ import { validCogGrid } from './validCogGrid.js';
4
+ import { validateCogOffsets } from './validateCogOffsets.js';
5
+
6
+ /**
7
+ * Validate and register one TIFF directory as a COG XYZ level.
8
+ *
9
+ * @param {Object} source Open COG source and level map.
10
+ * @param {Object} directory TIFF directory with parsed tags.
11
+ * @param {Object} state Mutable base image and zoom range.
12
+ *
13
+ * @throws {Error} If the level does not align with the supported Web Mercator grid.
14
+ */
15
+ export function readCogLevel(source, directory, state) {
16
+ const tags = directory.tags, profile = getCogProfile(tags);
17
+ if (!state.base) state.base = getCogBase(tags, profile.width, profile.height, profile.elevation);
18
+ const base = state.base, resolution = base.resolution * base.width / profile.width;
19
+ const zoom = Math.round(Math.log2(20037508.342789244 * 2 / (256 * resolution)));
20
+ const span = 20037508.342789244 * 2 / 2 ** zoom;
21
+ let x = (base.left + 20037508.342789244) / span;
22
+ let y = (20037508.342789244 - base.top) / span;
23
+ if (Math.abs(x - Math.round(x)) < 1e-6) x = Math.round(x);
24
+ if (Math.abs(y - Math.round(y)) < 1e-6) y = Math.round(y);
25
+ if (!validCogGrid(source, base, profile, zoom, x, y, resolution)) {
26
+ throw /* alloc */ new Error('COG levels must align with the Web Mercator XYZ tile grid');
27
+ }
28
+ const level = /* alloc */ {
29
+ x, y, columns: profile.width / 256, rows: profile.height / 256, samples: profile.samples,
30
+ elevation: profile.elevation, compression: tags.get(259)[0], offsets: tags.get(324), lengths: tags.get(325),
31
+ };
32
+ validateCogOffsets(source, level);
33
+ source.levels.set(zoom, level);
34
+ state.minZoom = Math.min(state.minZoom, zoom);
35
+ state.maxZoom = Math.max(state.maxZoom, zoom);
36
+ }
@@ -1,28 +1,28 @@
1
- import { readCog } from './readCog.js';
2
-
3
- /**
4
- * Read the numeric values of a supported TIFF directory entry.
5
- *
6
- * @param {Object} source Open COG byte source.
7
- * @param {DataView} entries Directory entry data.
8
- * @param {number} i Entry index.
9
- * @param {number} tag TIFF tag number.
10
- * @param {boolean} little Whether the TIFF uses little-endian byte order.
11
- *
12
- * @returns {Promise<Array<number>>} Decoded tag values.
13
- *
14
- * @throws {Error} If the tag type or value count is unsupported.
15
- */
16
- export async function readCogTag(source, entries, i, tag, little) {
17
- const type = entries.getUint16(i * 12 + 2, little);
18
- const size = type === 3 ? 2 : type === 4 ? 4 : type === 12 ? 8 : 0;
19
- const length = entries.getUint32(i * 12 + 4, little);
20
- if (!size || !length || length > 1048576) throw /* alloc */ new Error(`Unsupported COG tag ${tag}`);
21
- const data = size * length <= 4 ? /* alloc */ new DataView(entries.buffer, i * 12 + 8, 4)
22
- : /* alloc */ new DataView(await readCog(source, entries.getUint32(i * 12 + 8, little), size * length));
23
- const values = /* alloc */ [];
24
- let j;
25
- for (j = 0; j < length; j++) values.push(type === 3 ? data.getUint16(j * size, little)
26
- : type === 4 ? data.getUint32(j * size, little) : data.getFloat64(j * size, little));
27
- return values;
28
- }
1
+ import { readCog } from './readCog.js';
2
+
3
+ /**
4
+ * Read the numeric values of a supported TIFF directory entry.
5
+ *
6
+ * @param {Object} source Open COG byte source.
7
+ * @param {DataView} entries Directory entry data.
8
+ * @param {number} i Entry index.
9
+ * @param {number} tag TIFF tag number.
10
+ * @param {boolean} little Whether the TIFF uses little-endian byte order.
11
+ *
12
+ * @returns {Promise<Array<number>>} Decoded tag values.
13
+ *
14
+ * @throws {Error} If the tag type or value count is unsupported.
15
+ */
16
+ export async function readCogTag(source, entries, i, tag, little) {
17
+ const type = entries.getUint16(i * 12 + 2, little);
18
+ const size = type === 3 ? 2 : type === 4 ? 4 : type === 12 ? 8 : 0;
19
+ const length = entries.getUint32(i * 12 + 4, little);
20
+ if (!size || !length || length > 1048576) throw /* alloc */ new Error(`Unsupported COG tag ${tag}`);
21
+ const data = size * length <= 4 ? /* alloc */ new DataView(entries.buffer, i * 12 + 8, 4)
22
+ : /* alloc */ new DataView(await readCog(source, entries.getUint32(i * 12 + 8, little), size * length));
23
+ const values = /* alloc */ [];
24
+ let j;
25
+ for (j = 0; j < length; j++) values.push(type === 3 ? data.getUint16(j * size, little)
26
+ : type === 4 ? data.getUint32(j * size, little) : data.getFloat64(j * size, little));
27
+ return values;
28
+ }
@@ -1,15 +1,15 @@
1
- /**
2
- * Check COG image dimensions, tile size, compression, planar layout and predictor.
3
- *
4
- * @param {Map} tags TIFF tags.
5
- * @param {number} width Image width.
6
- * @param {number} height Image height.
7
- *
8
- * @returns {boolean} Whether the image uses supported dimensions and layout.
9
- */
10
- export function validCogDimensions(tags, width, height) {
11
- return !!width && !!height && width % 256 === 0 && height % 256 === 0 &&
12
- tags.get(322)?.[0] === 256 && tags.get(323)?.[0] === 256 &&
13
- (tags.get(259)?.[0] === 1 || tags.get(259)?.[0] === 8) &&
14
- (tags.get(284)?.[0] ?? 1) === 1 && (tags.get(317)?.[0] ?? 1) === 1;
15
- }
1
+ /**
2
+ * Check COG image dimensions, tile size, compression, planar layout and predictor.
3
+ *
4
+ * @param {Map} tags TIFF tags.
5
+ * @param {number} width Image width.
6
+ * @param {number} height Image height.
7
+ *
8
+ * @returns {boolean} Whether the image uses supported dimensions and layout.
9
+ */
10
+ export function validCogDimensions(tags, width, height) {
11
+ return !!width && !!height && width % 256 === 0 && height % 256 === 0 &&
12
+ tags.get(322)?.[0] === 256 && tags.get(323)?.[0] === 256 &&
13
+ (tags.get(259)?.[0] === 1 || tags.get(259)?.[0] === 8) &&
14
+ (tags.get(284)?.[0] ?? 1) === 1 && (tags.get(317)?.[0] ?? 1) === 1;
15
+ }
@@ -1,18 +1,18 @@
1
- /**
2
- * Check whether a TIFF profile is supported grayscale elevation or unsigned RGB(A).
3
- *
4
- * @param {Map} tags TIFF tags.
5
- * @param {number} samples Samples per pixel.
6
- * @param {Array<number>} bits Bits per sample.
7
- * @param {Array<number>} format Sample format values.
8
- * @param {boolean} elevation Whether the profile is Float32 elevation.
9
- * @param {boolean} bytes Whether all samples use eight bits.
10
- * @param {boolean} unsigned Whether all sample formats are unsigned.
11
- *
12
- * @returns {boolean} Whether the encoding is supported.
13
- */
14
- export function validCogEncoding(tags, samples, bits, format, elevation, bytes, unsigned) {
15
- if (elevation) return tags.get(262)?.[0] === 1;
16
- return (samples === 3 || samples === 4) && bits?.length === samples && bytes && unsigned &&
17
- tags.get(262)?.[0] === 2;
18
- }
1
+ /**
2
+ * Check whether a TIFF profile is supported grayscale elevation or unsigned RGB(A).
3
+ *
4
+ * @param {Map} tags TIFF tags.
5
+ * @param {number} samples Samples per pixel.
6
+ * @param {Array<number>} bits Bits per sample.
7
+ * @param {Array<number>} format Sample format values.
8
+ * @param {boolean} elevation Whether the profile is Float32 elevation.
9
+ * @param {boolean} bytes Whether all samples use eight bits.
10
+ * @param {boolean} unsigned Whether all sample formats are unsigned.
11
+ *
12
+ * @returns {boolean} Whether the encoding is supported.
13
+ */
14
+ export function validCogEncoding(tags, samples, bits, format, elevation, bytes, unsigned) {
15
+ if (elevation) return tags.get(262)?.[0] === 1;
16
+ return (samples === 3 || samples === 4) && bits?.length === samples && bytes && unsigned &&
17
+ tags.get(262)?.[0] === 2;
18
+ }