webdggrid 1.5.0 → 1.6.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 (137) hide show
  1. package/dist/webdggrid.js +1 -1
  2. package/dist/webdggrid.js.map +1 -1
  3. package/dist/webdggrid.umd.js +1 -1
  4. package/dist/webdggrid.umd.js.map +1 -1
  5. package/lib-esm/libdggrid.wasm.js +1 -1
  6. package/lib-esm/tsconfig.tsbuildinfo +1 -1
  7. package/lib-esm/webdggrid.js +1169 -16
  8. package/lib-esm/webdggrid.js.map +1 -1
  9. package/lib-wasm/CMakeCache.txt +3 -3
  10. package/lib-wasm/CMakeFiles/3.31.6/CMakeCCompiler.cmake +6 -6
  11. package/lib-wasm/CMakeFiles/3.31.6/CMakeCXXCompiler.cmake +6 -6
  12. package/lib-wasm/CMakeFiles/3.31.6/CMakeSystem.cmake +1 -1
  13. package/lib-wasm/CMakeFiles/Makefile.cmake +1 -1
  14. package/lib-wasm/CMakeFiles/libdggrid.dir/build.make +339 -339
  15. package/lib-wasm/CMakeFiles/libdggrid.dir/flags.make +2 -2
  16. package/lib-wasm/CMakeFiles/libdggrid.dir/link.txt +1 -1
  17. package/lib-wasm/CMakeFiles/libdggrid.dir/src-cpp/dggrid_transform.cpp.o +0 -0
  18. package/lib-wasm/CMakeFiles/libdggrid.dir/src-cpp/dggrid_transform.cpp.o.d +676 -673
  19. package/lib-wasm/CMakeFiles/libdggrid.dir/src-cpp/webdggrid.cpp.o +0 -0
  20. package/lib-wasm/CMakeFiles/libdggrid.dir/src-cpp/webdggrid.cpp.o.d +693 -693
  21. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgAddressBase.cpp.o.d +663 -663
  22. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgAddressType.cpp.o.d +663 -663
  23. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgApSeq.cpp.o.d +670 -670
  24. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgBase.cpp.o.d +663 -663
  25. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgBoundedHexC2RF2D.cpp.o.d +672 -672
  26. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgBoundedHexC3C2RF2D.cpp.o.d +672 -672
  27. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgBoundedHexC3RF2D.cpp.o.d +672 -672
  28. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgBoundedIDGG.cpp.o.d +672 -672
  29. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgBoundedIDGGS.cpp.o.d +672 -672
  30. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgBoundedRF2D.cpp.o.d +672 -672
  31. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgBoundedRFBase0.cpp.o.d +672 -672
  32. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgBoundedRFS2D.cpp.o.d +672 -672
  33. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgCell.cpp.o.d +672 -672
  34. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgColor.cpp.o.d +670 -670
  35. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgConverterBase.cpp.o.d +672 -672
  36. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgDVec2D.cpp.o.d +672 -672
  37. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgDVec3D.cpp.o.d +672 -672
  38. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgDataFieldBase.cpp.o.d +663 -663
  39. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgDataList.cpp.o.d +663 -663
  40. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgDiscRFS2D.cpp.o.d +672 -672
  41. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgDistanceBase.cpp.o.d +672 -672
  42. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgDmdD4Grid2D.cpp.o.d +672 -672
  43. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgDmdD4Grid2DS.cpp.o.d +672 -672
  44. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgDmdD8Grid2D.cpp.o.d +672 -672
  45. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgDmdD8Grid2DS.cpp.o.d +672 -672
  46. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgDmdIDGG.cpp.o.d +672 -672
  47. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgEllipsoidRF.cpp.o.d +672 -672
  48. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgGeoSphRF.cpp.o.d +672 -672
  49. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgGridTopo.cpp.o.d +663 -663
  50. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgHexC1Grid2D.cpp.o.d +672 -672
  51. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgHexC2Grid2D.cpp.o.d +672 -672
  52. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgHexC3Grid2D.cpp.o.d +672 -672
  53. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgHexGrid2DS.cpp.o.d +672 -672
  54. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgHexIDGG.cpp.o.d +672 -672
  55. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgHexIDGGS.cpp.o.d +672 -672
  56. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgIDGG.cpp.o.d +672 -672
  57. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgIDGGBase.cpp.o.d +672 -672
  58. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgIDGGS.cpp.o.d +672 -672
  59. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgIDGGS3H.cpp.o.d +672 -672
  60. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgIDGGS43H.cpp.o.d +672 -672
  61. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgIDGGS4D.cpp.o.d +672 -672
  62. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgIDGGS4H.cpp.o.d +672 -672
  63. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgIDGGS4T.cpp.o.d +672 -672
  64. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgIDGGS7H.cpp.o.d +672 -672
  65. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgIDGGSBase.cpp.o.d +672 -672
  66. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgIDGGutil.cpp.o.d +672 -672
  67. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgIVec2D.cpp.o.d +672 -672
  68. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgIVec3D.cpp.o.d +672 -672
  69. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgIcosaMap.cpp.o.d +672 -672
  70. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgInAIGenFile.cpp.o.d +692 -692
  71. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgInLocStreamFile.cpp.o.d +683 -683
  72. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgInLocTextFile.cpp.o.d +692 -692
  73. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgInShapefile.cpp.o.d +692 -692
  74. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgInShapefileAtt.cpp.o.d +696 -696
  75. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgInputStream.cpp.o.d +683 -683
  76. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgLocBase.cpp.o.d +663 -663
  77. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgLocList.cpp.o.d +673 -673
  78. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgLocVector.cpp.o.d +672 -672
  79. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgLocation.cpp.o.d +672 -672
  80. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgOutAIGenFile.cpp.o.d +692 -692
  81. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgOutChildrenFile.cpp.o.d +691 -691
  82. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgOutGeoJSONFile.cpp.o.d +692 -692
  83. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgOutKMLfile.cpp.o.d +692 -692
  84. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgOutLocFile.cpp.o.d +696 -696
  85. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgOutLocTextFile.cpp.o.d +690 -690
  86. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgOutNeighborsFile.cpp.o.d +691 -691
  87. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgOutPRCellsFile.cpp.o.d +692 -692
  88. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgOutPRPtsFile.cpp.o.d +692 -692
  89. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgOutPtsText.cpp.o.d +692 -692
  90. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgOutRandPtsText.cpp.o.d +692 -692
  91. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgOutShapefile.cpp.o.d +699 -699
  92. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgOutputStream.cpp.o.d +683 -683
  93. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgPolygon.cpp.o.d +672 -672
  94. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgProjFuller.cpp.o.d +672 -672
  95. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgProjGnomonicRF.cpp.o.d +672 -672
  96. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgProjISEA.cpp.o.d +672 -672
  97. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgProjTriRF.cpp.o.d +672 -672
  98. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgRFBase.cpp.o.d +673 -673
  99. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgRFNetwork.cpp.o.d +672 -672
  100. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgRandom.cpp.o.d +672 -672
  101. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgSeriesConverter.cpp.o.d +673 -673
  102. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgSqrD4Grid2D.cpp.o.d +672 -672
  103. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgSqrD4Grid2DS.cpp.o.d +672 -672
  104. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgSqrD8Grid2D.cpp.o.d +672 -672
  105. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgSqrD8Grid2DS.cpp.o.d +672 -672
  106. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgSuperfund.cpp.o.d +663 -663
  107. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgTriGrid2D.cpp.o.d +672 -672
  108. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgTriGrid2DS.cpp.o.d +672 -672
  109. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgTriIDGG.cpp.o.d +672 -672
  110. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgUtil.cpp.o.d +670 -670
  111. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgZ3RF.cpp.o.d +675 -675
  112. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgZ3StringRF.cpp.o.d +672 -672
  113. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgZ7RF.cpp.o.d +675 -675
  114. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgZ7StringRF.cpp.o.d +672 -672
  115. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgZOrderRF.cpp.o.d +675 -675
  116. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/dglib/lib/DgZOrderStringRF.cpp.o.d +672 -672
  117. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/proj4lib/lib/adjlon.cpp.o.d +129 -129
  118. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/proj4lib/lib/pj_auth.cpp.o.d +133 -133
  119. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/proj4lib/lib/pj_mlfn.cpp.o.d +133 -133
  120. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/proj4lib/lib/pj_msfn.cpp.o.d +132 -132
  121. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/proj4lib/lib/pj_phi2.cpp.o.d +133 -133
  122. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/proj4lib/lib/pj_qsfn.cpp.o.d +129 -129
  123. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/proj4lib/lib/pj_tsfn.cpp.o.d +129 -129
  124. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/shapelib/lib/dbfopen.c.o.d +25 -25
  125. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/shapelib/lib/safileio.c.o.d +28 -28
  126. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/shapelib/lib/sbnsearch.c.o.d +25 -25
  127. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/shapelib/lib/shpopen.c.o.d +30 -30
  128. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/shapelib/lib/shptree.c.o.d +28 -28
  129. package/lib-wasm/CMakeFiles/libdggrid.dir/submodules/DGGRID/src/lib/shapelib/lib/shputils.c.o.d +22 -22
  130. package/lib-wasm/cmake_install.cmake +1 -1
  131. package/lib-wasm/libdggrid.js +1 -1
  132. package/lib-wasm/libdggrid.wasm +0 -0
  133. package/package.json +1 -1
  134. package/readme.md +64 -3
  135. package/src-ts/webdggrid.ts +1502 -6
  136. package/types/webdggrid.d.ts +765 -1
  137. package/types/webdggrid.d.ts.map +1 -1
@@ -269,8 +269,10 @@ export class Webdggrid {
269
269
  * @returns Total number of cells at the given resolution.
270
270
  */
271
271
  nCells(resolution = DEFAULT_RESOLUTION) {
272
- const { poleCoordinates: { lat, lng }, azimuth, topology, projection, aperture, } = this.dggs;
273
- const cellCount = this._module.nCells(lng, lat, azimuth, aperture, resolution, topology, projection);
272
+ const { poleCoordinates: { lat, lng }, azimuth, topology, projection, aperture, apertureSequence, } = this.dggs;
273
+ const isApertureSequence = !!apertureSequence;
274
+ const apSeq = apertureSequence || "";
275
+ const cellCount = this._module.nCells(lng, lat, azimuth, aperture, resolution, topology, projection, isApertureSequence, apSeq);
274
276
  return cellCount;
275
277
  }
276
278
  /**
@@ -289,8 +291,10 @@ export class Webdggrid {
289
291
  * @returns Average cell area in km².
290
292
  */
291
293
  cellAreaKM(resolution = DEFAULT_RESOLUTION) {
292
- const { poleCoordinates: { lat, lng }, azimuth, topology, projection, aperture, } = this.dggs;
293
- const cellCount = this._module.cellAreaKM(lng, lat, azimuth, aperture, resolution, topology, projection);
294
+ const { poleCoordinates: { lat, lng }, azimuth, topology, projection, aperture, apertureSequence, } = this.dggs;
295
+ const isApertureSequence = !!apertureSequence;
296
+ const apSeq = apertureSequence || "";
297
+ const cellCount = this._module.cellAreaKM(lng, lat, azimuth, aperture, resolution, topology, projection, isApertureSequence, apSeq);
294
298
  return cellCount;
295
299
  }
296
300
  /**
@@ -309,8 +313,10 @@ export class Webdggrid {
309
313
  * @returns Average cell spacing in km.
310
314
  */
311
315
  cellDistKM(resolution = DEFAULT_RESOLUTION) {
312
- const { poleCoordinates: { lat, lng }, azimuth, topology, projection, aperture, } = this.dggs;
313
- const cellCount = this._module.cellDistKM(lng, lat, azimuth, aperture, resolution, topology, projection);
316
+ const { poleCoordinates: { lat, lng }, azimuth, topology, projection, aperture, apertureSequence, } = this.dggs;
317
+ const isApertureSequence = !!apertureSequence;
318
+ const apSeq = apertureSequence || "";
319
+ const cellCount = this._module.cellDistKM(lng, lat, azimuth, aperture, resolution, topology, projection, isApertureSequence, apSeq);
314
320
  return cellCount;
315
321
  }
316
322
  /**
@@ -330,8 +336,10 @@ export class Webdggrid {
330
336
  * @returns Grid CLS value.
331
337
  */
332
338
  gridStatCLS(resolution = DEFAULT_RESOLUTION) {
333
- const { poleCoordinates: { lat, lng }, azimuth, topology, projection, aperture, } = this.dggs;
334
- const cellCount = this._module.gridStatCLS(lng, lat, azimuth, aperture, resolution, topology, projection);
339
+ const { poleCoordinates: { lat, lng }, azimuth, topology, projection, aperture, apertureSequence, } = this.dggs;
340
+ const isApertureSequence = !!apertureSequence;
341
+ const apSeq = apertureSequence || "";
342
+ const cellCount = this._module.gridStatCLS(lng, lat, azimuth, aperture, resolution, topology, projection, isApertureSequence, apSeq);
335
343
  return cellCount;
336
344
  }
337
345
  /**
@@ -364,10 +372,12 @@ export class Webdggrid {
364
372
  * in the same order.
365
373
  */
366
374
  geoToSequenceNum(coordinates, resolution = DEFAULT_RESOLUTION) {
367
- const { poleCoordinates: { lat, lng }, azimuth, topology, projection, aperture, } = this.dggs;
375
+ const { poleCoordinates: { lat, lng }, azimuth, topology, projection, aperture, apertureSequence, } = this.dggs;
376
+ const isApertureSequence = !!apertureSequence;
377
+ const apSeq = apertureSequence || "";
368
378
  const xCoords = coordinates.map((coord) => coord[0]);
369
379
  const yCoords = coordinates.map((coord) => coord[1]);
370
- const resultArray = this._module.DgGEO_to_SEQNUM(lng, lat, azimuth, aperture, resolution, topology, projection, xCoords, yCoords);
380
+ const resultArray = this._module.DgGEO_to_SEQNUM(lng, lat, azimuth, aperture, resolution, topology, projection, isApertureSequence, apSeq, xCoords, yCoords);
371
381
  return resultArray;
372
382
  }
373
383
  /**
@@ -389,8 +399,10 @@ export class Webdggrid {
389
399
  * the same order.
390
400
  */
391
401
  sequenceNumToGeo(sequenceNum, resolution = DEFAULT_RESOLUTION) {
392
- const { poleCoordinates: { lat, lng }, azimuth, topology, projection, aperture, } = this.dggs;
393
- const resultArray = this._module.SEQNUM_to_GEO(lng, lat, azimuth, aperture, resolution, topology, projection, sequenceNum);
402
+ const { poleCoordinates: { lat, lng }, azimuth, topology, projection, aperture, apertureSequence, } = this.dggs;
403
+ const isApertureSequence = !!apertureSequence;
404
+ const apSeq = apertureSequence || "";
405
+ const resultArray = this._module.SEQNUM_to_GEO(lng, lat, azimuth, aperture, resolution, topology, projection, isApertureSequence, apSeq, sequenceNum);
394
406
  const size = resultArray.length / 2;
395
407
  const arrayOfArrays = [];
396
408
  for (let i = 0; i < size; i += 1) {
@@ -426,10 +438,12 @@ export class Webdggrid {
426
438
  * coordinate, in the same order.
427
439
  */
428
440
  geoToGeo(coordinates, resolution = DEFAULT_RESOLUTION) {
429
- const { poleCoordinates: { lat, lng }, azimuth, topology, projection, aperture, } = this.dggs;
441
+ const { poleCoordinates: { lat, lng }, azimuth, topology, projection, aperture, apertureSequence, } = this.dggs;
442
+ const isApertureSequence = !!apertureSequence;
443
+ const apSeq = apertureSequence || "";
430
444
  const xCoords = coordinates.map((coord) => coord[0]);
431
445
  const yCoords = coordinates.map((coord) => coord[1]);
432
- const resultArray = this._module.GEO_to_GEO(lng, lat, azimuth, aperture, resolution, topology, projection, xCoords, yCoords);
446
+ const resultArray = this._module.GEO_to_GEO(lng, lat, azimuth, aperture, resolution, topology, projection, isApertureSequence, apSeq, xCoords, yCoords);
433
447
  const size = resultArray.length / 2;
434
448
  const arrayOfArrays = [];
435
449
  for (let i = 0; i < size; i += 1) {
@@ -461,11 +475,13 @@ export class Webdggrid {
461
475
  * @throws If the WASM module encounters an invalid cell ID.
462
476
  */
463
477
  sequenceNumToGrid(sequenceNum, resolution = DEFAULT_RESOLUTION) {
464
- const { poleCoordinates: { lat, lng }, azimuth, topology, projection, aperture, } = this.dggs;
478
+ const { poleCoordinates: { lat, lng }, azimuth, topology, projection, aperture, apertureSequence, } = this.dggs;
479
+ const isApertureSequence = !!apertureSequence;
480
+ const apSeq = apertureSequence || "";
465
481
  const inputSize = sequenceNum.length;
466
482
  let resultArray = [];
467
483
  try {
468
- resultArray = this._module.SeqNumGrid(lng, lat, azimuth, aperture, resolution, topology, projection, sequenceNum);
484
+ resultArray = this._module.SeqNumGrid(lng, lat, azimuth, aperture, resolution, topology, projection, isApertureSequence, apSeq, sequenceNum);
469
485
  }
470
486
  catch (e) {
471
487
  console.error(this._module.getExceptionMessage(e).toString());
@@ -544,5 +560,1142 @@ export class Webdggrid {
544
560
  features,
545
561
  };
546
562
  }
563
+ /**
564
+ * Returns all neighboring cells (sharing an edge) for each input cell.
565
+ *
566
+ * For hexagonal grids, each interior cell typically has 6 neighbors.
567
+ * Pentagon cells and boundary cells may have fewer. Triangle topology
568
+ * is not supported by the underlying DGGRID library.
569
+ *
570
+ * The output is a 2-D array: `result[i]` contains all neighbors of
571
+ * `sequenceNum[i]`.
572
+ *
573
+ * ```ts
574
+ * const neighbors = dggs.sequenceNumNeighbors([123n], 5);
575
+ * // neighbors[0] = [122n, 124n, 125n, 126n, 127n, 128n]
576
+ * ```
577
+ *
578
+ * ::: warning
579
+ * Triangle topology is **not supported**. Attempting to retrieve neighbors
580
+ * for a TRIANGLE grid will throw an error.
581
+ * :::
582
+ *
583
+ * @param sequenceNum - Array of `BigInt` cell IDs whose neighbors to find.
584
+ * @param resolution - Resolution at which the IDs were generated. Defaults
585
+ * to the instance's current {@link resolution}.
586
+ * @returns A 2-D array of `BigInt[]`: `result[i]` is the array of neighbor
587
+ * IDs for `sequenceNum[i]`.
588
+ * @throws If Triangle topology is used or if an invalid cell ID is provided.
589
+ */
590
+ sequenceNumNeighbors(sequenceNum, resolution = DEFAULT_RESOLUTION) {
591
+ const { poleCoordinates: { lat, lng }, azimuth, topology, projection, aperture, apertureSequence, } = this.dggs;
592
+ if (topology === Topology.TRIANGLE) {
593
+ throw new Error('Neighbor detection is not supported for TRIANGLE topology');
594
+ }
595
+ const isApertureSequence = !!apertureSequence;
596
+ const apSeq = apertureSequence || "";
597
+ try {
598
+ const resultArray = this._module.SEQNUMS_neighbors(lng, lat, azimuth, aperture, resolution, topology, projection, isApertureSequence, apSeq, sequenceNum);
599
+ // The result is a flat array with format:
600
+ // [count0, count1, ..., countN, neighbor0_0, neighbor0_1, ..., neighbor0_(count0-1), neighbor1_0, ...]
601
+ const inputSize = sequenceNum.length;
602
+ const counts = resultArray.slice(0, inputSize);
603
+ const neighbors = [];
604
+ let offset = inputSize;
605
+ for (let i = 0; i < inputSize; i++) {
606
+ const count = Number(counts[i]);
607
+ neighbors.push(resultArray.slice(offset, offset + count));
608
+ offset += count;
609
+ }
610
+ return neighbors;
611
+ }
612
+ catch (e) {
613
+ console.error(this._module.getExceptionMessage(e).toString());
614
+ throw e;
615
+ }
616
+ }
617
+ /**
618
+ * Returns the parent cell at the next coarser resolution (resolution - 1)
619
+ * for each input cell.
620
+ *
621
+ * The parent-child relationship forms a hierarchical index structure. For
622
+ * aperture 4 grids, each parent contains 4 children; for aperture 7, each
623
+ * parent contains 7 children.
624
+ *
625
+ * ```ts
626
+ * const parents = dggs.sequenceNumParent([123n, 456n], 5);
627
+ * // parents = [30n, 114n] (at resolution 4)
628
+ * ```
629
+ *
630
+ * ::: info
631
+ * Calling this method at resolution 0 will throw an error because there
632
+ * are no cells at resolution -1.
633
+ * :::
634
+ *
635
+ * @param sequenceNum - Array of `BigInt` cell IDs whose parents to find.
636
+ * @param resolution - Resolution at which the input IDs were generated.
637
+ * Must be > 0. Defaults to the instance's current {@link resolution}.
638
+ * @returns Array of `BigInt` parent cell IDs at resolution - 1, one per
639
+ * input cell, in the same order.
640
+ * @throws If resolution is 0 or if an invalid cell ID is provided.
641
+ */
642
+ sequenceNumParent(sequenceNum, resolution = DEFAULT_RESOLUTION) {
643
+ if (resolution <= 0) {
644
+ throw new Error('Cannot get parent at resolution 0 or below');
645
+ }
646
+ const { poleCoordinates: { lat, lng }, azimuth, topology, projection, aperture, apertureSequence, } = this.dggs;
647
+ const isApertureSequence = !!apertureSequence;
648
+ const apSeq = apertureSequence || "";
649
+ try {
650
+ const resultArray = this._module.SEQNUMS_parents(lng, lat, azimuth, aperture, resolution, topology, projection, isApertureSequence, apSeq, sequenceNum);
651
+ return resultArray;
652
+ }
653
+ catch (e) {
654
+ console.error(this._module.getExceptionMessage(e).toString());
655
+ throw e;
656
+ }
657
+ }
658
+ /**
659
+ * Returns all child cells at the next finer resolution (resolution + 1)
660
+ * for each input cell.
661
+ *
662
+ * The number of children depends on the aperture:
663
+ * - Aperture 3: 3 children per parent
664
+ * - Aperture 4: 4 children per parent
665
+ * - Aperture 7: 7 children per parent
666
+ *
667
+ * The output is a 2-D array: `result[i]` contains all children of
668
+ * `sequenceNum[i]`.
669
+ *
670
+ * ```ts
671
+ * const children = dggs.sequenceNumChildren([30n], 4);
672
+ * // children[0] = [120n, 121n, 122n, 123n] (at resolution 5, aperture 4)
673
+ * ```
674
+ *
675
+ * ::: info
676
+ * Children always include both boundary and interior cells. The returned
677
+ * cells completely cover the parent cell's area.
678
+ * :::
679
+ *
680
+ * @param sequenceNum - Array of `BigInt` cell IDs whose children to find.
681
+ * @param resolution - Resolution at which the input IDs were generated.
682
+ * Defaults to the instance's current {@link resolution}.
683
+ * @returns A 2-D array of `BigInt[]`: `result[i]` is the array of child
684
+ * IDs for `sequenceNum[i]` at resolution + 1.
685
+ * @throws If an invalid cell ID is provided or if the maximum resolution
686
+ * is exceeded.
687
+ */
688
+ sequenceNumChildren(sequenceNum, resolution = DEFAULT_RESOLUTION) {
689
+ const { poleCoordinates: { lat, lng }, azimuth, topology, projection, aperture, apertureSequence, } = this.dggs;
690
+ const isApertureSequence = !!apertureSequence;
691
+ const apSeq = apertureSequence || "";
692
+ try {
693
+ const resultArray = this._module.SEQNUMS_children(lng, lat, azimuth, aperture, resolution, topology, projection, isApertureSequence, apSeq, sequenceNum);
694
+ // The result is a flat array with format:
695
+ // [count0, count1, ..., countN, child0_0, child0_1, ..., child0_(count0-1), child1_0, ...]
696
+ const inputSize = sequenceNum.length;
697
+ const counts = resultArray.slice(0, inputSize);
698
+ const children = [];
699
+ let offset = inputSize;
700
+ for (let i = 0; i < inputSize; i++) {
701
+ const count = Number(counts[i]);
702
+ children.push(resultArray.slice(offset, offset + count));
703
+ offset += count;
704
+ }
705
+ return children;
706
+ }
707
+ catch (e) {
708
+ console.error(this._module.getExceptionMessage(e).toString());
709
+ throw e;
710
+ }
711
+ }
712
+ // =========================================================================
713
+ // Hierarchical Address Type Conversions
714
+ // These methods convert between SEQNUM and hierarchical indexing systems
715
+ // =========================================================================
716
+ /**
717
+ * Convert a SEQNUM cell ID to VERTEX2DD (icosahedral vertex) coordinates.
718
+ *
719
+ * VERTEX2DD addresses represent positions relative to the vertices and
720
+ * triangular faces of the underlying icosahedron.
721
+ *
722
+ * ```ts
723
+ * const vertex = dggs.sequenceNumToVertex2DD(100n, 5);
724
+ * // vertex = { keep: true, vertNum: 1, triNum: 1, x: 0.0625, y: 0.054... }
725
+ * ```
726
+ *
727
+ * @param sequenceNum - The cell sequence number to convert.
728
+ * @param resolution - Resolution of the input cell. Defaults to the
729
+ * instance's current {@link resolution}.
730
+ * @returns An object with `{keep, vertNum, triNum, x, y}` representing
731
+ * the vertex coordinate.
732
+ */
733
+ sequenceNumToVertex2DD(sequenceNum, resolution = DEFAULT_RESOLUTION) {
734
+ try {
735
+ const result = this._module.SEQNUM_to_VERTEX2DD(...this._getParams(resolution), sequenceNum);
736
+ return result;
737
+ }
738
+ catch (e) {
739
+ console.error(this._module.getExceptionMessage(e).toString());
740
+ throw e;
741
+ }
742
+ }
743
+ /**
744
+ * Convert VERTEX2DD (icosahedral vertex) coordinates to a SEQNUM cell ID.
745
+ *
746
+ * ```ts
747
+ * const seqnum = dggs.vertex2DDToSequenceNum(true, 1, 1, 0.0625, 0.054, 5);
748
+ * // seqnum = 100n
749
+ * ```
750
+ *
751
+ * @param keep - Whether to keep this vertex.
752
+ * @param vertNum - Vertex number (0-11 for icosahedron).
753
+ * @param triNum - Triangle number on the icosahedron.
754
+ * @param x - X coordinate within the triangle.
755
+ * @param y - Y coordinate within the triangle.
756
+ * @param resolution - Resolution at which to compute the cell ID. Defaults
757
+ * to the instance's current {@link resolution}.
758
+ * @returns The sequence number (BigInt) of the cell containing this coordinate.
759
+ */
760
+ vertex2DDToSequenceNum(keep, vertNum, triNum, x, y, resolution = DEFAULT_RESOLUTION) {
761
+ try {
762
+ return this._module.VERTEX2DD_to_SEQNUM(...this._getParams(resolution), keep, vertNum, triNum, x, y);
763
+ }
764
+ catch (e) {
765
+ console.error(this._module.getExceptionMessage(e).toString());
766
+ throw e;
767
+ }
768
+ }
769
+ /**
770
+ * Convert a SEQNUM cell ID to ZORDER (Z-order curve) coordinate.
771
+ *
772
+ * ZORDER uses digit-interleaved coordinates to create a space-filling
773
+ * curve index. This provides good spatial locality for range queries.
774
+ *
775
+ * **Compatibility:** ZORDER is only available for **aperture 3 and 4**
776
+ * hexagon grids. It is **NOT supported** for aperture 7.
777
+ *
778
+ * ```ts
779
+ * // With aperture 4:
780
+ * const zorder = dggs.sequenceNumToZOrder(100n, 5);
781
+ * // zorder = 1168684103302643712n
782
+ * ```
783
+ *
784
+ * @param sequenceNum - The cell sequence number to convert.
785
+ * @param resolution - Resolution of the input cell. Defaults to the
786
+ * instance's current {@link resolution}.
787
+ * @returns A BigInt representing the Z-order coordinate.
788
+ * @throws If used with an incompatible aperture (7) or topology.
789
+ */
790
+ sequenceNumToZOrder(sequenceNum, resolution = DEFAULT_RESOLUTION) {
791
+ const { aperture, apertureSequence } = this.dggs;
792
+ // Check aperture compatibility
793
+ if (aperture === 7 && !apertureSequence) {
794
+ throw new Error('ZORDER is not available for aperture 7. ' +
795
+ 'Use Z7 hierarchical indexing instead, or switch to aperture 3 or 4.');
796
+ }
797
+ try {
798
+ return this._module.SEQNUM_to_ZORDER(...this._getParams(resolution), sequenceNum);
799
+ }
800
+ catch (e) {
801
+ const errMsg = this._module.getExceptionMessage(e).toString();
802
+ if (errMsg.includes('aperture')) {
803
+ throw new Error(`ZORDER error: ${errMsg}. ZORDER requires aperture 3 or 4 (not 7).`);
804
+ }
805
+ console.error(errMsg);
806
+ throw e;
807
+ }
808
+ }
809
+ /**
810
+ * Convert a ZORDER (Z-order curve) coordinate to a SEQNUM cell ID.
811
+ *
812
+ * ```ts
813
+ * const seqnum = dggs.zOrderToSequenceNum(1168684103302643712n, 5);
814
+ * // seqnum = 100n
815
+ * ```
816
+ *
817
+ * @param zorderValue - The Z-order coordinate value (BigInt).
818
+ * @param resolution - Resolution at which to compute the cell ID. Defaults
819
+ * to the instance's current {@link resolution}.
820
+ * @returns The sequence number (BigInt) corresponding to this Z-order value.
821
+ * @throws If used with an incompatible aperture (7) or topology.
822
+ */
823
+ zOrderToSequenceNum(zorderValue, resolution = DEFAULT_RESOLUTION) {
824
+ const { aperture, apertureSequence } = this.dggs;
825
+ if (aperture === 7 && !apertureSequence) {
826
+ throw new Error('ZORDER is not available for aperture 7. ' +
827
+ 'Use Z7 hierarchical indexing instead, or switch to aperture 3 or 4.');
828
+ }
829
+ try {
830
+ return this._module.ZORDER_to_SEQNUM(...this._getParams(resolution), zorderValue);
831
+ }
832
+ catch (e) {
833
+ const errMsg = this._module.getExceptionMessage(e).toString();
834
+ if (errMsg.includes('aperture')) {
835
+ throw new Error(`ZORDER error: ${errMsg}. ZORDER requires aperture 3 or 4 (not 7).`);
836
+ }
837
+ console.error(errMsg);
838
+ throw e;
839
+ }
840
+ }
841
+ /**
842
+ * Convert a SEQNUM cell ID to Z3 (base-3 Central Place Indexing) coordinate.
843
+ *
844
+ * Z3 uses base-3 digit encoding optimized for aperture 3 hexagon grids.
845
+ * Each parent cell contains exactly 3 children in the hierarchy.
846
+ *
847
+ * **Compatibility:** Z3 is **only available for aperture 3** hexagon grids.
848
+ *
849
+ * ```ts
850
+ * // With aperture 3:
851
+ * const z3 = dggs.sequenceNumToZ3(100n, 5);
852
+ * // z3 = 1773292353277132799n
853
+ * ```
854
+ *
855
+ * @param sequenceNum - The cell sequence number to convert.
856
+ * @param resolution - Resolution of the input cell. Defaults to the
857
+ * instance's current {@link resolution}.
858
+ * @returns A BigInt representing the Z3 coordinate (INT64 format).
859
+ * @throws If used with an incompatible aperture (not 3) or topology.
860
+ */
861
+ sequenceNumToZ3(sequenceNum, resolution = DEFAULT_RESOLUTION) {
862
+ const { aperture, topology, apertureSequence } = this.dggs;
863
+ if ((aperture !== 3 || topology !== 'HEXAGON') && !apertureSequence) {
864
+ throw new Error('Z3 is only available for aperture 3 hexagon grids. ' +
865
+ `Current configuration: aperture ${aperture}, topology ${topology}.`);
866
+ }
867
+ try {
868
+ return this._module.SEQNUM_to_Z3(...this._getParams(resolution), sequenceNum);
869
+ }
870
+ catch (e) {
871
+ const errMsg = this._module.getExceptionMessage(e).toString();
872
+ if (errMsg.includes('aperture') || errMsg.includes('Z3')) {
873
+ throw new Error(`Z3 error: ${errMsg}. Z3 requires aperture 3 hexagon grids.`);
874
+ }
875
+ console.error(errMsg);
876
+ throw e;
877
+ }
878
+ }
879
+ /**
880
+ * Convert a Z3 (base-3 Central Place Indexing) coordinate to a SEQNUM cell ID.
881
+ *
882
+ * ```ts
883
+ * const seqnum = dggs.z3ToSequenceNum(1773292353277132799n, 5);
884
+ * // seqnum = 100n
885
+ * ```
886
+ *
887
+ * @param z3Value - The Z3 coordinate value (BigInt, INT64 format).
888
+ * @param resolution - Resolution at which to compute the cell ID. Defaults
889
+ * to the instance's current {@link resolution}.
890
+ * @returns The sequence number (BigInt) corresponding to this Z3 value.
891
+ * @throws If used with an incompatible aperture (not 3) or topology.
892
+ */
893
+ z3ToSequenceNum(z3Value, resolution = DEFAULT_RESOLUTION) {
894
+ const { aperture, topology, apertureSequence } = this.dggs;
895
+ if ((aperture !== 3 || topology !== 'HEXAGON') && !apertureSequence) {
896
+ throw new Error('Z3 is only available for aperture 3 hexagon grids. ' +
897
+ `Current configuration: aperture ${aperture}, topology ${topology}.`);
898
+ }
899
+ try {
900
+ return this._module.Z3_to_SEQNUM(...this._getParams(resolution), z3Value);
901
+ }
902
+ catch (e) {
903
+ const errMsg = this._module.getExceptionMessage(e).toString();
904
+ if (errMsg.includes('aperture') || errMsg.includes('Z3')) {
905
+ throw new Error(`Z3 error: ${errMsg}. Z3 requires aperture 3 hexagon grids.`);
906
+ }
907
+ console.error(errMsg);
908
+ throw e;
909
+ }
910
+ }
911
+ /**
912
+ * Convert a SEQNUM cell ID to Z7 (base-7 Central Place Indexing) coordinate.
913
+ *
914
+ * Z7 uses base-7 digit encoding with pure bitarithmetic operations,
915
+ * optimized for aperture 7 hexagon grids. Each parent cell contains
916
+ * exactly 7 children in the hierarchy.
917
+ *
918
+ * **Compatibility:** Z7 is **only available for aperture 7** hexagon grids.
919
+ *
920
+ * ```ts
921
+ * // With aperture 7:
922
+ * const z7 = dggs.sequenceNumToZ7(100n, 5);
923
+ * // z7 = 1153167795211468799n (displayed as hex: 0x1000000000000fff)
924
+ * ```
925
+ *
926
+ * @param sequenceNum - The cell sequence number to convert.
927
+ * @param resolution - Resolution of the input cell. Defaults to the
928
+ * instance's current {@link resolution}.
929
+ * @returns A BigInt representing the Z7 coordinate (INT64/hex format).
930
+ * @throws If used with an incompatible aperture (not 7) or topology.
931
+ */
932
+ sequenceNumToZ7(sequenceNum, resolution = DEFAULT_RESOLUTION) {
933
+ const { aperture, topology, apertureSequence } = this.dggs;
934
+ if ((aperture !== 7 || topology !== 'HEXAGON') && !apertureSequence) {
935
+ throw new Error('Z7 is only available for aperture 7 hexagon grids. ' +
936
+ `Current configuration: aperture ${aperture}, topology ${topology}.`);
937
+ }
938
+ try {
939
+ return this._module.SEQNUM_to_Z7(...this._getParams(resolution), sequenceNum);
940
+ }
941
+ catch (e) {
942
+ const errMsg = this._module.getExceptionMessage(e).toString();
943
+ if (errMsg.includes('aperture') || errMsg.includes('Z7')) {
944
+ throw new Error(`Z7 error: ${errMsg}. Z7 requires aperture 7 hexagon grids.`);
945
+ }
946
+ console.error(errMsg);
947
+ throw e;
948
+ }
949
+ }
950
+ /**
951
+ * Convert a Z7 (base-7 Central Place Indexing) coordinate to a SEQNUM cell ID.
952
+ *
953
+ * ```ts
954
+ * const seqnum = dggs.z7ToSequenceNum(1153167795211468799n, 5);
955
+ * // seqnum = 100n
956
+ * ```
957
+ *
958
+ * @param z7Value - The Z7 coordinate value (BigInt, INT64/hex format).
959
+ * @param resolution - Resolution at which to compute the cell ID. Defaults
960
+ * to the instance's current {@link resolution}.
961
+ * @returns The sequence number (BigInt) corresponding to this Z7 value.
962
+ * @throws If used with an incompatible aperture (not 7) or topology.
963
+ */
964
+ z7ToSequenceNum(z7Value, resolution = DEFAULT_RESOLUTION) {
965
+ const { aperture, topology, apertureSequence } = this.dggs;
966
+ if ((aperture !== 7 || topology !== 'HEXAGON') && !apertureSequence) {
967
+ throw new Error('Z7 is only available for aperture 7 hexagon grids. ' +
968
+ `Current configuration: aperture ${aperture}, topology ${topology}.`);
969
+ }
970
+ try {
971
+ return this._module.Z7_to_SEQNUM(...this._getParams(resolution), z7Value);
972
+ }
973
+ catch (e) {
974
+ const errMsg = this._module.getExceptionMessage(e).toString();
975
+ if (errMsg.includes('aperture') || errMsg.includes('Z7')) {
976
+ throw new Error(`Z7 error: ${errMsg}. Z7 requires aperture 7 hexagon grids.`);
977
+ }
978
+ console.error(errMsg);
979
+ throw e;
980
+ }
981
+ }
982
+ /**
983
+ * Get the quad (icosahedron face) number from a Z7 index.
984
+ *
985
+ * The quad occupies bits 63–60 of the 64-bit packed value.
986
+ *
987
+ * ```ts
988
+ * const quad = dggs.z7GetQuad(z7Value); // 0–11
989
+ * ```
990
+ *
991
+ * @param z7Value - A Z7 packed index (BigInt).
992
+ * @returns The quad number (0–11).
993
+ */
994
+ z7GetQuad(z7Value) {
995
+ return Number((z7Value & Webdggrid.Z7_QUAD_MASK) >> Webdggrid.Z7_QUAD_OFFSET);
996
+ }
997
+ /**
998
+ * Get the digit at a specific resolution level from a Z7 index.
999
+ *
1000
+ * Each digit is 3 bits wide and occupies a fixed position in the 64-bit value.
1001
+ * Valid digits are 0–6; the value 7 is the invalid/padding marker.
1002
+ *
1003
+ * ```ts
1004
+ * const digit = dggs.z7GetDigit(z7Value, 3); // 0–6 (or 7 = invalid)
1005
+ * ```
1006
+ *
1007
+ * @param z7Value - A Z7 packed index (BigInt).
1008
+ * @param res - Resolution level (1-based, 1 to 20).
1009
+ * @returns The digit value (0–7).
1010
+ */
1011
+ z7GetDigit(z7Value, res) {
1012
+ const shift = BigInt(Webdggrid.Z7_MAX_RES - res) * Webdggrid.Z7_BITS_PER_DIGIT;
1013
+ return Number((z7Value >> shift) & Webdggrid.Z7_DIGIT_MASK);
1014
+ }
1015
+ /**
1016
+ * Set the digit at a specific resolution level in a Z7 index.
1017
+ *
1018
+ * Returns a new Z7 value with the digit at position `res` replaced.
1019
+ *
1020
+ * ```ts
1021
+ * const child = dggs.z7SetDigit(z7Value, 6, 3); // set res-6 digit to 3
1022
+ * ```
1023
+ *
1024
+ * @param z7Value - A Z7 packed index (BigInt).
1025
+ * @param res - Resolution level (1-based, 1 to 20).
1026
+ * @param digit - The digit value to set (0–6, or 7 for invalid).
1027
+ * @returns A new Z7 value with the digit replaced.
1028
+ */
1029
+ z7SetDigit(z7Value, res, digit) {
1030
+ const shift = BigInt(Webdggrid.Z7_MAX_RES - res) * Webdggrid.Z7_BITS_PER_DIGIT;
1031
+ return (z7Value & ~(Webdggrid.Z7_DIGIT_MASK << shift)) | (BigInt(digit) << shift);
1032
+ }
1033
+ /**
1034
+ * Extract all digits from a Z7 index up to a given resolution.
1035
+ *
1036
+ * ```ts
1037
+ * const { quad, digits } = dggs.z7ExtractDigits(z7Value, 5);
1038
+ * // quad: 1, digits: [2, 0, 3, 4, 1]
1039
+ * ```
1040
+ *
1041
+ * @param z7Value - A Z7 packed index (BigInt).
1042
+ * @param resolution - Number of digits to extract (1-based).
1043
+ * @returns Object with `quad` (number) and `digits` (number array).
1044
+ */
1045
+ z7ExtractDigits(z7Value, resolution) {
1046
+ const quad = this.z7GetQuad(z7Value);
1047
+ const digits = [];
1048
+ for (let r = 1; r <= resolution; r++) {
1049
+ digits.push(this.z7GetDigit(z7Value, r));
1050
+ }
1051
+ return { quad, digits };
1052
+ }
1053
+ /**
1054
+ * Get the quad (icosahedron face) number from a Z3 index.
1055
+ *
1056
+ * ```ts
1057
+ * const quad = dggs.z3GetQuad(z3Value); // 0–11
1058
+ * ```
1059
+ *
1060
+ * @param z3Value - A Z3 packed index (BigInt).
1061
+ * @returns The quad number (0–11).
1062
+ */
1063
+ z3GetQuad(z3Value) {
1064
+ return Number((z3Value & Webdggrid.Z3_QUAD_MASK) >> Webdggrid.Z3_QUAD_OFFSET);
1065
+ }
1066
+ /**
1067
+ * Get the digit at a specific resolution level from a Z3 index.
1068
+ *
1069
+ * Each digit is 2 bits wide. Valid digits are 0–2; the value 3 is the
1070
+ * invalid/padding marker.
1071
+ *
1072
+ * ```ts
1073
+ * const digit = dggs.z3GetDigit(z3Value, 3); // 0–2 (or 3 = invalid)
1074
+ * ```
1075
+ *
1076
+ * @param z3Value - A Z3 packed index (BigInt).
1077
+ * @param res - Resolution level (1-based, 1 to 30).
1078
+ * @returns The digit value (0–3).
1079
+ */
1080
+ z3GetDigit(z3Value, res) {
1081
+ const shift = BigInt(Webdggrid.Z3_MAX_RES - res) * Webdggrid.Z3_BITS_PER_DIGIT;
1082
+ return Number((z3Value >> shift) & Webdggrid.Z3_DIGIT_MASK);
1083
+ }
1084
+ /**
1085
+ * Set the digit at a specific resolution level in a Z3 index.
1086
+ *
1087
+ * ```ts
1088
+ * const child = dggs.z3SetDigit(z3Value, 6, 1); // set res-6 digit to 1
1089
+ * ```
1090
+ *
1091
+ * @param z3Value - A Z3 packed index (BigInt).
1092
+ * @param res - Resolution level (1-based, 1 to 30).
1093
+ * @param digit - The digit value to set (0–2, or 3 for invalid).
1094
+ * @returns A new Z3 value with the digit replaced.
1095
+ */
1096
+ z3SetDigit(z3Value, res, digit) {
1097
+ const shift = BigInt(Webdggrid.Z3_MAX_RES - res) * Webdggrid.Z3_BITS_PER_DIGIT;
1098
+ return (z3Value & ~(Webdggrid.Z3_DIGIT_MASK << shift)) | (BigInt(digit) << shift);
1099
+ }
1100
+ /**
1101
+ * Extract all digits from a Z3 index up to a given resolution.
1102
+ *
1103
+ * ```ts
1104
+ * const { quad, digits } = dggs.z3ExtractDigits(z3Value, 5);
1105
+ * // quad: 1, digits: [1, 0, 2, 1, 0]
1106
+ * ```
1107
+ *
1108
+ * @param z3Value - A Z3 packed index (BigInt).
1109
+ * @param resolution - Number of digits to extract (1-based).
1110
+ * @returns Object with `quad` (number) and `digits` (number array).
1111
+ */
1112
+ z3ExtractDigits(z3Value, resolution) {
1113
+ const quad = this.z3GetQuad(z3Value);
1114
+ const digits = [];
1115
+ for (let r = 1; r <= resolution; r++) {
1116
+ digits.push(this.z3GetDigit(z3Value, r));
1117
+ }
1118
+ return { quad, digits };
1119
+ }
1120
+ /**
1121
+ * Get the quad (icosahedron face) number from a ZORDER index.
1122
+ *
1123
+ * ```ts
1124
+ * const quad = dggs.zOrderGetQuad(zorderValue); // 0–11
1125
+ * ```
1126
+ *
1127
+ * @param zorderValue - A ZORDER packed index (BigInt).
1128
+ * @returns The quad number (0–11).
1129
+ */
1130
+ zOrderGetQuad(zorderValue) {
1131
+ return Number((zorderValue & Webdggrid.ZORDER_QUAD_MASK) >> Webdggrid.ZORDER_QUAD_OFFSET);
1132
+ }
1133
+ /**
1134
+ * Get the digit at a specific resolution level from a ZORDER index.
1135
+ *
1136
+ * Each digit is 2 bits wide (values 0–3).
1137
+ *
1138
+ * ```ts
1139
+ * const digit = dggs.zOrderGetDigit(zorderValue, 3); // 0–3
1140
+ * ```
1141
+ *
1142
+ * @param zorderValue - A ZORDER packed index (BigInt).
1143
+ * @param res - Resolution level (1-based, 1 to 30).
1144
+ * @returns The digit value (0–3).
1145
+ */
1146
+ zOrderGetDigit(zorderValue, res) {
1147
+ const shift = BigInt(Webdggrid.ZORDER_MAX_RES - res) * Webdggrid.ZORDER_BITS_PER_DIGIT;
1148
+ return Number((zorderValue >> shift) & Webdggrid.ZORDER_DIGIT_MASK);
1149
+ }
1150
+ /**
1151
+ * Set the digit at a specific resolution level in a ZORDER index.
1152
+ *
1153
+ * ```ts
1154
+ * const modified = dggs.zOrderSetDigit(zorderValue, 3, 2);
1155
+ * ```
1156
+ *
1157
+ * @param zorderValue - A ZORDER packed index (BigInt).
1158
+ * @param res - Resolution level (1-based, 1 to 30).
1159
+ * @param digit - The digit value to set (0–3).
1160
+ * @returns A new ZORDER value with the digit replaced.
1161
+ */
1162
+ zOrderSetDigit(zorderValue, res, digit) {
1163
+ const shift = BigInt(Webdggrid.ZORDER_MAX_RES - res) * Webdggrid.ZORDER_BITS_PER_DIGIT;
1164
+ return (zorderValue & ~(Webdggrid.ZORDER_DIGIT_MASK << shift)) | (BigInt(digit) << shift);
1165
+ }
1166
+ /**
1167
+ * Extract all digits from a ZORDER index up to a given resolution.
1168
+ *
1169
+ * ```ts
1170
+ * const { quad, digits } = dggs.zOrderExtractDigits(zorderValue, 5);
1171
+ * // quad: 1, digits: [2, 0, 3, 1, 0]
1172
+ * ```
1173
+ *
1174
+ * @param zorderValue - A ZORDER packed index (BigInt).
1175
+ * @param resolution - Number of digits to extract (1-based).
1176
+ * @returns Object with `quad` (number) and `digits` (number array).
1177
+ */
1178
+ zOrderExtractDigits(zorderValue, resolution) {
1179
+ const quad = this.zOrderGetQuad(zorderValue);
1180
+ const digits = [];
1181
+ for (let r = 1; r <= resolution; r++) {
1182
+ digits.push(this.zOrderGetDigit(zorderValue, r));
1183
+ }
1184
+ return { quad, digits };
1185
+ }
1186
+ // =========================================================================
1187
+ // Low-level coordinate transformation methods
1188
+ // These methods expose all DGGRID coordinate systems beyond GEO/SEQNUM
1189
+ // =========================================================================
1190
+ /**
1191
+ * Helper to build the DGGS parameter array for WASM calls.
1192
+ * @private
1193
+ */
1194
+ _getParams(resolution = DEFAULT_RESOLUTION) {
1195
+ const { poleCoordinates: { lat, lng }, azimuth, topology, projection, aperture, apertureSequence, } = this.dggs;
1196
+ const isApertureSequence = !!apertureSequence;
1197
+ const apSeq = apertureSequence || "";
1198
+ return [
1199
+ lng,
1200
+ lat,
1201
+ azimuth,
1202
+ aperture,
1203
+ resolution,
1204
+ topology,
1205
+ projection,
1206
+ isApertureSequence,
1207
+ apSeq
1208
+ ];
1209
+ }
1210
+ // -------------------------------------------------------------------------
1211
+ // GEO transformations (beyond the high-level methods above)
1212
+ // -------------------------------------------------------------------------
1213
+ /**
1214
+ * Converts geographic coordinates to PLANE coordinates.
1215
+ *
1216
+ * @param coordinates - Array of `[lng, lat]` pairs
1217
+ * @param resolution - Resolution level
1218
+ * @returns Array of `{x, y}` plane coordinates
1219
+ */
1220
+ geoToPlane(coordinates, resolution = DEFAULT_RESOLUTION) {
1221
+ const xCoords = coordinates.map(c => c[0]);
1222
+ const yCoords = coordinates.map(c => c[1]);
1223
+ const result = this._module.GEO_to_PLANE(...this._getParams(resolution), xCoords, yCoords);
1224
+ const size = result.length / 2;
1225
+ const output = [];
1226
+ for (let i = 0; i < size; i++) {
1227
+ output.push({ x: result[i], y: result[i + size] });
1228
+ }
1229
+ return output;
1230
+ }
1231
+ /**
1232
+ * Converts geographic coordinates to PROJTRI coordinates.
1233
+ *
1234
+ * @param coordinates - Array of `[lng, lat]` pairs
1235
+ * @param resolution - Resolution level
1236
+ * @returns Array of `{tnum, x, y}` projection triangle coordinates
1237
+ */
1238
+ geoToProjtri(coordinates, resolution = DEFAULT_RESOLUTION) {
1239
+ const xCoords = coordinates.map(c => c[0]);
1240
+ const yCoords = coordinates.map(c => c[1]);
1241
+ const result = this._module.GEO_to_PROJTRI(...this._getParams(resolution), xCoords, yCoords);
1242
+ const size = result.length / 3;
1243
+ const output = [];
1244
+ for (let i = 0; i < size; i++) {
1245
+ output.push({
1246
+ tnum: result[i],
1247
+ x: result[i + size],
1248
+ y: result[i + 2 * size]
1249
+ });
1250
+ }
1251
+ return output;
1252
+ }
1253
+ /**
1254
+ * Converts geographic coordinates to Q2DD coordinates.
1255
+ *
1256
+ * @param coordinates - Array of `[lng, lat]` pairs
1257
+ * @param resolution - Resolution level
1258
+ * @returns Array of `{quad, x, y}` quad 2D double coordinates
1259
+ */
1260
+ geoToQ2dd(coordinates, resolution = DEFAULT_RESOLUTION) {
1261
+ const xCoords = coordinates.map(c => c[0]);
1262
+ const yCoords = coordinates.map(c => c[1]);
1263
+ const result = this._module.GEO_to_Q2DD(...this._getParams(resolution), xCoords, yCoords);
1264
+ const size = result.length / 3;
1265
+ const output = [];
1266
+ for (let i = 0; i < size; i++) {
1267
+ output.push({
1268
+ quad: result[i],
1269
+ x: result[i + size],
1270
+ y: result[i + 2 * size]
1271
+ });
1272
+ }
1273
+ return output;
1274
+ }
1275
+ /**
1276
+ * Converts geographic coordinates to Q2DI coordinates.
1277
+ *
1278
+ * @param coordinates - Array of `[lng, lat]` pairs
1279
+ * @param resolution - Resolution level
1280
+ * @returns Array of `{quad, i, j}` quad 2D integer coordinates
1281
+ */
1282
+ geoToQ2di(coordinates, resolution = DEFAULT_RESOLUTION) {
1283
+ const xCoords = coordinates.map(c => c[0]);
1284
+ const yCoords = coordinates.map(c => c[1]);
1285
+ const result = this._module.GEO_to_Q2DI(...this._getParams(resolution), xCoords, yCoords);
1286
+ const size = result.length / 3;
1287
+ const output = [];
1288
+ for (let i = 0; i < size; i++) {
1289
+ output.push({
1290
+ quad: result[i],
1291
+ i: BigInt(result[i + size]),
1292
+ j: BigInt(result[i + 2 * size])
1293
+ });
1294
+ }
1295
+ return output;
1296
+ }
1297
+ // -------------------------------------------------------------------------
1298
+ // SEQNUM transformations (beyond the high-level methods above)
1299
+ // -------------------------------------------------------------------------
1300
+ /**
1301
+ * Converts sequence numbers to PLANE coordinates.
1302
+ *
1303
+ * @param sequenceNum - Array of cell IDs
1304
+ * @param resolution - Resolution level
1305
+ * @returns Array of `{x, y}` plane coordinates
1306
+ */
1307
+ sequenceNumToPlane(sequenceNum, resolution = DEFAULT_RESOLUTION) {
1308
+ const result = this._module.SEQNUM_to_PLANE(...this._getParams(resolution), sequenceNum);
1309
+ const size = result.length / 2;
1310
+ const output = [];
1311
+ for (let i = 0; i < size; i++) {
1312
+ output.push({ x: result[i], y: result[i + size] });
1313
+ }
1314
+ return output;
1315
+ }
1316
+ /**
1317
+ * Converts sequence numbers to PROJTRI coordinates.
1318
+ *
1319
+ * @param sequenceNum - Array of cell IDs
1320
+ * @param resolution - Resolution level
1321
+ * @returns Array of `{tnum, x, y}` projection triangle coordinates
1322
+ */
1323
+ sequenceNumToProjtri(sequenceNum, resolution = DEFAULT_RESOLUTION) {
1324
+ const result = this._module.SEQNUM_to_PROJTRI(...this._getParams(resolution), sequenceNum);
1325
+ const size = result.length / 3;
1326
+ const output = [];
1327
+ for (let i = 0; i < size; i++) {
1328
+ output.push({
1329
+ tnum: result[i],
1330
+ x: result[i + size],
1331
+ y: result[i + 2 * size]
1332
+ });
1333
+ }
1334
+ return output;
1335
+ }
1336
+ /**
1337
+ * Converts sequence numbers to Q2DD coordinates.
1338
+ *
1339
+ * @param sequenceNum - Array of cell IDs
1340
+ * @param resolution - Resolution level
1341
+ * @returns Array of `{quad, x, y}` quad 2D double coordinates
1342
+ */
1343
+ sequenceNumToQ2dd(sequenceNum, resolution = DEFAULT_RESOLUTION) {
1344
+ const result = this._module.SEQNUM_to_Q2DD(...this._getParams(resolution), sequenceNum);
1345
+ const size = result.length / 3;
1346
+ const output = [];
1347
+ for (let i = 0; i < size; i++) {
1348
+ output.push({
1349
+ quad: result[i],
1350
+ x: result[i + size],
1351
+ y: result[i + 2 * size]
1352
+ });
1353
+ }
1354
+ return output;
1355
+ }
1356
+ /**
1357
+ * Converts sequence numbers to Q2DI coordinates.
1358
+ *
1359
+ * @param sequenceNum - Array of cell IDs
1360
+ * @param resolution - Resolution level
1361
+ * @returns Array of `{quad, i, j}` quad 2D integer coordinates
1362
+ */
1363
+ sequenceNumToQ2di(sequenceNum, resolution = DEFAULT_RESOLUTION) {
1364
+ const result = this._module.SEQNUM_to_Q2DI(...this._getParams(resolution), sequenceNum);
1365
+ const size = result.length / 3;
1366
+ const output = [];
1367
+ for (let i = 0; i < size; i++) {
1368
+ output.push({
1369
+ quad: result[i],
1370
+ i: BigInt(result[i + size]),
1371
+ j: BigInt(result[i + 2 * size])
1372
+ });
1373
+ }
1374
+ return output;
1375
+ }
1376
+ // -------------------------------------------------------------------------
1377
+ // Q2DI transformations
1378
+ // -------------------------------------------------------------------------
1379
+ /**
1380
+ * Converts Q2DI coordinates to geographic coordinates.
1381
+ *
1382
+ * @param coords - Array of `{quad, i, j}` coordinates
1383
+ * @param resolution - Resolution level
1384
+ * @returns Array of `[lng, lat]` positions
1385
+ */
1386
+ q2diToGeo(coords, resolution = DEFAULT_RESOLUTION) {
1387
+ const quads = coords.map(c => c.quad);
1388
+ const is = coords.map(c => Number(c.i));
1389
+ const js = coords.map(c => Number(c.j));
1390
+ const result = this._module.Q2DI_to_GEO(...this._getParams(resolution), quads, is, js);
1391
+ const size = result.length / 2;
1392
+ const output = [];
1393
+ for (let i = 0; i < size; i++) {
1394
+ output.push([result[i], result[i + size]]);
1395
+ }
1396
+ return output;
1397
+ }
1398
+ /**
1399
+ * Converts Q2DI coordinates to sequence numbers.
1400
+ *
1401
+ * @param coords - Array of `{quad, i, j}` coordinates
1402
+ * @param resolution - Resolution level
1403
+ * @returns Array of cell IDs
1404
+ */
1405
+ q2diToSequenceNum(coords, resolution = DEFAULT_RESOLUTION) {
1406
+ const quads = coords.map(c => c.quad);
1407
+ const is = coords.map(c => Number(c.i));
1408
+ const js = coords.map(c => Number(c.j));
1409
+ return this._module.Q2DI_to_SEQNUM(...this._getParams(resolution), quads, is, js);
1410
+ }
1411
+ /**
1412
+ * Converts Q2DI coordinates to PLANE coordinates.
1413
+ *
1414
+ * @param coords - Array of `{quad, i, j}` coordinates
1415
+ * @param resolution - Resolution level
1416
+ * @returns Array of `{x, y}` plane coordinates
1417
+ */
1418
+ q2diToPlane(coords, resolution = DEFAULT_RESOLUTION) {
1419
+ const quads = coords.map(c => c.quad);
1420
+ const is = coords.map(c => Number(c.i));
1421
+ const js = coords.map(c => Number(c.j));
1422
+ const result = this._module.Q2DI_to_PLANE(...this._getParams(resolution), quads, is, js);
1423
+ const size = result.length / 2;
1424
+ const output = [];
1425
+ for (let i = 0; i < size; i++) {
1426
+ output.push({ x: result[i], y: result[i + size] });
1427
+ }
1428
+ return output;
1429
+ }
1430
+ /**
1431
+ * Converts Q2DI coordinates to PROJTRI coordinates.
1432
+ *
1433
+ * @param coords - Array of `{quad, i, j}` coordinates
1434
+ * @param resolution - Resolution level
1435
+ * @returns Array of `{tnum, x, y}` projection triangle coordinates
1436
+ */
1437
+ q2diToProjtri(coords, resolution = DEFAULT_RESOLUTION) {
1438
+ const quads = coords.map(c => c.quad);
1439
+ const is = coords.map(c => Number(c.i));
1440
+ const js = coords.map(c => Number(c.j));
1441
+ const result = this._module.Q2DI_to_PROJTRI(...this._getParams(resolution), quads, is, js);
1442
+ const size = result.length / 3;
1443
+ const output = [];
1444
+ for (let i = 0; i < size; i++) {
1445
+ output.push({
1446
+ tnum: result[i],
1447
+ x: result[i + size],
1448
+ y: result[i + 2 * size]
1449
+ });
1450
+ }
1451
+ return output;
1452
+ }
1453
+ /**
1454
+ * Converts Q2DI coordinates to Q2DD coordinates.
1455
+ *
1456
+ * @param coords - Array of `{quad, i, j}` coordinates
1457
+ * @param resolution - Resolution level
1458
+ * @returns Array of `{quad, x, y}` quad 2D double coordinates
1459
+ */
1460
+ q2diToQ2dd(coords, resolution = DEFAULT_RESOLUTION) {
1461
+ const quads = coords.map(c => c.quad);
1462
+ const is = coords.map(c => Number(c.i));
1463
+ const js = coords.map(c => Number(c.j));
1464
+ const result = this._module.Q2DI_to_Q2DD(...this._getParams(resolution), quads, is, js);
1465
+ const size = result.length / 3;
1466
+ const output = [];
1467
+ for (let i = 0; i < size; i++) {
1468
+ output.push({
1469
+ quad: result[i],
1470
+ x: result[i + size],
1471
+ y: result[i + 2 * size]
1472
+ });
1473
+ }
1474
+ return output;
1475
+ }
1476
+ // -------------------------------------------------------------------------
1477
+ // Q2DD transformations
1478
+ // -------------------------------------------------------------------------
1479
+ /**
1480
+ * Converts Q2DD coordinates to geographic coordinates.
1481
+ *
1482
+ * @param coords - Array of `{quad, x, y}` coordinates
1483
+ * @param resolution - Resolution level
1484
+ * @returns Array of `[lng, lat]` positions
1485
+ */
1486
+ q2ddToGeo(coords, resolution = DEFAULT_RESOLUTION) {
1487
+ const quads = coords.map(c => c.quad);
1488
+ const xs = coords.map(c => c.x);
1489
+ const ys = coords.map(c => c.y);
1490
+ const result = this._module.Q2DD_to_GEO(...this._getParams(resolution), quads, xs, ys);
1491
+ const size = result.length / 2;
1492
+ const output = [];
1493
+ for (let i = 0; i < size; i++) {
1494
+ output.push([result[i], result[i + size]]);
1495
+ }
1496
+ return output;
1497
+ }
1498
+ /**
1499
+ * Converts Q2DD coordinates to sequence numbers.
1500
+ *
1501
+ * @param coords - Array of `{quad, x, y}` coordinates
1502
+ * @param resolution - Resolution level
1503
+ * @returns Array of cell IDs
1504
+ */
1505
+ q2ddToSequenceNum(coords, resolution = DEFAULT_RESOLUTION) {
1506
+ const quads = coords.map(c => c.quad);
1507
+ const xs = coords.map(c => c.x);
1508
+ const ys = coords.map(c => c.y);
1509
+ return this._module.Q2DD_to_SEQNUM(...this._getParams(resolution), quads, xs, ys);
1510
+ }
1511
+ /**
1512
+ * Converts Q2DD coordinates to PLANE coordinates.
1513
+ *
1514
+ * @param coords - Array of `{quad, x, y}` coordinates
1515
+ * @param resolution - Resolution level
1516
+ * @returns Array of `{x, y}` plane coordinates
1517
+ */
1518
+ q2ddToPlane(coords, resolution = DEFAULT_RESOLUTION) {
1519
+ const quads = coords.map(c => c.quad);
1520
+ const xs = coords.map(c => c.x);
1521
+ const ys = coords.map(c => c.y);
1522
+ const result = this._module.Q2DD_to_PLANE(...this._getParams(resolution), quads, xs, ys);
1523
+ const size = result.length / 2;
1524
+ const output = [];
1525
+ for (let i = 0; i < size; i++) {
1526
+ output.push({ x: result[i], y: result[i + size] });
1527
+ }
1528
+ return output;
1529
+ }
1530
+ /**
1531
+ * Converts Q2DD coordinates to PROJTRI coordinates.
1532
+ *
1533
+ * @param coords - Array of `{quad, x, y}` coordinates
1534
+ * @param resolution - Resolution level
1535
+ * @returns Array of `{tnum, x, y}` projection triangle coordinates
1536
+ */
1537
+ q2ddToProjtri(coords, resolution = DEFAULT_RESOLUTION) {
1538
+ const quads = coords.map(c => c.quad);
1539
+ const xs = coords.map(c => c.x);
1540
+ const ys = coords.map(c => c.y);
1541
+ const result = this._module.Q2DD_to_PROJTRI(...this._getParams(resolution), quads, xs, ys);
1542
+ const size = result.length / 3;
1543
+ const output = [];
1544
+ for (let i = 0; i < size; i++) {
1545
+ output.push({
1546
+ tnum: result[i],
1547
+ x: result[i + size],
1548
+ y: result[i + 2 * size]
1549
+ });
1550
+ }
1551
+ return output;
1552
+ }
1553
+ /**
1554
+ * Converts Q2DD coordinates to Q2DI coordinates.
1555
+ *
1556
+ * @param coords - Array of `{quad, x, y}` coordinates
1557
+ * @param resolution - Resolution level
1558
+ * @returns Array of `{quad, i, j}` quad 2D integer coordinates
1559
+ */
1560
+ q2ddToQ2di(coords, resolution = DEFAULT_RESOLUTION) {
1561
+ const quads = coords.map(c => c.quad);
1562
+ const xs = coords.map(c => c.x);
1563
+ const ys = coords.map(c => c.y);
1564
+ const result = this._module.Q2DD_to_Q2DI(...this._getParams(resolution), quads, xs, ys);
1565
+ const size = result.length / 3;
1566
+ const output = [];
1567
+ for (let i = 0; i < size; i++) {
1568
+ output.push({
1569
+ quad: result[i],
1570
+ i: BigInt(result[i + size]),
1571
+ j: BigInt(result[i + 2 * size])
1572
+ });
1573
+ }
1574
+ return output;
1575
+ }
1576
+ // -------------------------------------------------------------------------
1577
+ // PROJTRI transformations
1578
+ // -------------------------------------------------------------------------
1579
+ /**
1580
+ * Converts PROJTRI coordinates to geographic coordinates.
1581
+ *
1582
+ * @param coords - Array of `{tnum, x, y}` coordinates
1583
+ * @param resolution - Resolution level
1584
+ * @returns Array of `[lng, lat]` positions
1585
+ */
1586
+ projtriToGeo(coords, resolution = DEFAULT_RESOLUTION) {
1587
+ const tnums = coords.map(c => c.tnum);
1588
+ const xs = coords.map(c => c.x);
1589
+ const ys = coords.map(c => c.y);
1590
+ const result = this._module.PROJTRI_to_GEO(...this._getParams(resolution), tnums, xs, ys);
1591
+ const size = result.length / 2;
1592
+ const output = [];
1593
+ for (let i = 0; i < size; i++) {
1594
+ output.push([result[i], result[i + size]]);
1595
+ }
1596
+ return output;
1597
+ }
1598
+ /**
1599
+ * Converts PROJTRI coordinates to sequence numbers.
1600
+ *
1601
+ * @param coords - Array of `{tnum, x, y}` coordinates
1602
+ * @param resolution - Resolution level
1603
+ * @returns Array of cell IDs
1604
+ */
1605
+ projtriToSequenceNum(coords, resolution = DEFAULT_RESOLUTION) {
1606
+ const tnums = coords.map(c => c.tnum);
1607
+ const xs = coords.map(c => c.x);
1608
+ const ys = coords.map(c => c.y);
1609
+ return this._module.PROJTRI_to_SEQNUM(...this._getParams(resolution), tnums, xs, ys);
1610
+ }
1611
+ /**
1612
+ * Converts PROJTRI coordinates to PLANE coordinates.
1613
+ *
1614
+ * @param coords - Array of `{tnum, x, y}` coordinates
1615
+ * @param resolution - Resolution level
1616
+ * @returns Array of `{x, y}` plane coordinates
1617
+ */
1618
+ projtriToPlane(coords, resolution = DEFAULT_RESOLUTION) {
1619
+ const tnums = coords.map(c => c.tnum);
1620
+ const xs = coords.map(c => c.x);
1621
+ const ys = coords.map(c => c.y);
1622
+ const result = this._module.PROJTRI_to_PLANE(...this._getParams(resolution), tnums, xs, ys);
1623
+ const size = result.length / 2;
1624
+ const output = [];
1625
+ for (let i = 0; i < size; i++) {
1626
+ output.push({ x: result[i], y: result[i + size] });
1627
+ }
1628
+ return output;
1629
+ }
1630
+ /**
1631
+ * Converts PROJTRI coordinates to Q2DD coordinates.
1632
+ *
1633
+ * @param coords - Array of `{tnum, x, y}` coordinates
1634
+ * @param resolution - Resolution level
1635
+ * @returns Array of `{quad, x, y}` quad 2D double coordinates
1636
+ */
1637
+ projtriToQ2dd(coords, resolution = DEFAULT_RESOLUTION) {
1638
+ const tnums = coords.map(c => c.tnum);
1639
+ const xs = coords.map(c => c.x);
1640
+ const ys = coords.map(c => c.y);
1641
+ const result = this._module.PROJTRI_to_Q2DD(...this._getParams(resolution), tnums, xs, ys);
1642
+ const size = result.length / 3;
1643
+ const output = [];
1644
+ for (let i = 0; i < size; i++) {
1645
+ output.push({
1646
+ quad: result[i],
1647
+ x: result[i + size],
1648
+ y: result[i + 2 * size]
1649
+ });
1650
+ }
1651
+ return output;
1652
+ }
1653
+ /**
1654
+ * Converts PROJTRI coordinates to Q2DI coordinates.
1655
+ *
1656
+ * @param coords - Array of `{tnum, x, y}` coordinates
1657
+ * @param resolution - Resolution level
1658
+ * @returns Array of `{quad, i, j}` quad 2D integer coordinates
1659
+ */
1660
+ projtriToQ2di(coords, resolution = DEFAULT_RESOLUTION) {
1661
+ const tnums = coords.map(c => c.tnum);
1662
+ const xs = coords.map(c => c.x);
1663
+ const ys = coords.map(c => c.y);
1664
+ const result = this._module.PROJTRI_to_Q2DI(...this._getParams(resolution), tnums, xs, ys);
1665
+ const size = result.length / 3;
1666
+ const output = [];
1667
+ for (let i = 0; i < size; i++) {
1668
+ output.push({
1669
+ quad: result[i],
1670
+ i: BigInt(result[i + size]),
1671
+ j: BigInt(result[i + 2 * size])
1672
+ });
1673
+ }
1674
+ return output;
1675
+ }
547
1676
  }
1677
+ // =========================================================================
1678
+ // Index digit manipulation
1679
+ // Pure bitwise operations on Z7, Z3, and ZORDER packed indices.
1680
+ // These match DGGRID's internal macros (Z7_GET_INDEX_DIGIT, etc.)
1681
+ // and do NOT require WASM calls.
1682
+ // =========================================================================
1683
+ // --- Z7 constants (3 bits per digit, max 20 resolutions) ---
1684
+ /** @internal */ Webdggrid.Z7_MAX_RES = 20;
1685
+ /** @internal */ Webdggrid.Z7_BITS_PER_DIGIT = 3n;
1686
+ /** @internal */ Webdggrid.Z7_DIGIT_MASK = 7n;
1687
+ /** @internal */ Webdggrid.Z7_QUAD_OFFSET = 60n;
1688
+ /** @internal */ Webdggrid.Z7_QUAD_MASK = 0xf000000000000000n;
1689
+ // --- Z3 constants (2 bits per digit, max 30 resolutions) ---
1690
+ /** @internal */ Webdggrid.Z3_MAX_RES = 30;
1691
+ /** @internal */ Webdggrid.Z3_BITS_PER_DIGIT = 2n;
1692
+ /** @internal */ Webdggrid.Z3_DIGIT_MASK = 3n;
1693
+ /** @internal */ Webdggrid.Z3_QUAD_OFFSET = 60n;
1694
+ /** @internal */ Webdggrid.Z3_QUAD_MASK = 0xf000000000000000n;
1695
+ // --- ZORDER constants (2 bits per digit, max 30 resolutions) ---
1696
+ /** @internal */ Webdggrid.ZORDER_MAX_RES = 30;
1697
+ /** @internal */ Webdggrid.ZORDER_BITS_PER_DIGIT = 2n;
1698
+ /** @internal */ Webdggrid.ZORDER_DIGIT_MASK = 3n;
1699
+ /** @internal */ Webdggrid.ZORDER_QUAD_OFFSET = 60n;
1700
+ /** @internal */ Webdggrid.ZORDER_QUAD_MASK = 0xf000000000000000n;
548
1701
  //# sourceMappingURL=webdggrid.js.map