webdggrid 1.5.0 → 1.7.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 +1218 -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 +680 -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 +1559 -6
  136. package/types/webdggrid.d.ts +793 -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,1191 @@ 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** parent cells that touch each input cell at the coarser
660
+ * resolution (resolution - 1).
661
+ *
662
+ * Unlike {@link sequenceNumParent} which returns only the primary
663
+ * (containing) parent, this method returns every parent cell whose area
664
+ * overlaps with the child cell. For interior cells this is typically 1;
665
+ * for cells on a parent boundary it may be 2 or more.
666
+ *
667
+ * The **first element** of each inner array is always the primary
668
+ * (containing) parent — the same value returned by
669
+ * {@link sequenceNumParent}.
670
+ *
671
+ * ```ts
672
+ * const allParents = dggs.sequenceNumAllParents([256n], 3);
673
+ * // allParents[0] = [65n, 66n] — 65 is the containing parent,
674
+ * // 66 is a touching neighbor parent
675
+ * ```
676
+ *
677
+ * @param sequenceNum - Array of `BigInt` cell IDs to query.
678
+ * @param resolution - Resolution at which the input IDs were generated
679
+ * (must be > 0). Defaults to the instance's current {@link resolution}.
680
+ * @returns A 2-D array: `result[i]` contains all parent cell IDs that
681
+ * touch `sequenceNum[i]`, with the primary parent first.
682
+ * @throws If `resolution` is 0 or negative, or if an invalid cell ID is
683
+ * provided.
684
+ */
685
+ sequenceNumAllParents(sequenceNum, resolution = DEFAULT_RESOLUTION) {
686
+ if (resolution <= 0) {
687
+ throw new Error('Cannot get parents at resolution 0 or below');
688
+ }
689
+ try {
690
+ const resultArray = this._module.SEQNUMS_all_parents(...this._getParams(resolution), sequenceNum);
691
+ // Convert from JS array of arrays to bigint[][]
692
+ const result = [];
693
+ for (let i = 0; i < resultArray.length; i++) {
694
+ const inner = [];
695
+ for (let j = 0; j < resultArray[i].length; j++) {
696
+ inner.push(resultArray[i][j]);
697
+ }
698
+ result.push(inner);
699
+ }
700
+ return result;
701
+ }
702
+ catch (e) {
703
+ console.error(this._module.getExceptionMessage(e).toString());
704
+ throw e;
705
+ }
706
+ }
707
+ /**
708
+ * Returns all child cells at the next finer resolution (resolution + 1)
709
+ * for each input cell.
710
+ *
711
+ * The number of children depends on the aperture:
712
+ * - Aperture 3: 3 children per parent
713
+ * - Aperture 4: 4 children per parent
714
+ * - Aperture 7: 7 children per parent
715
+ *
716
+ * The output is a 2-D array: `result[i]` contains all children of
717
+ * `sequenceNum[i]`.
718
+ *
719
+ * ```ts
720
+ * const children = dggs.sequenceNumChildren([30n], 4);
721
+ * // children[0] = [120n, 121n, 122n, 123n] (at resolution 5, aperture 4)
722
+ * ```
723
+ *
724
+ * ::: info
725
+ * Children always include both boundary and interior cells. The returned
726
+ * cells completely cover the parent cell's area.
727
+ * :::
728
+ *
729
+ * @param sequenceNum - Array of `BigInt` cell IDs whose children to find.
730
+ * @param resolution - Resolution at which the input IDs were generated.
731
+ * Defaults to the instance's current {@link resolution}.
732
+ * @returns A 2-D array of `BigInt[]`: `result[i]` is the array of child
733
+ * IDs for `sequenceNum[i]` at resolution + 1.
734
+ * @throws If an invalid cell ID is provided or if the maximum resolution
735
+ * is exceeded.
736
+ */
737
+ sequenceNumChildren(sequenceNum, resolution = DEFAULT_RESOLUTION) {
738
+ const { poleCoordinates: { lat, lng }, azimuth, topology, projection, aperture, apertureSequence, } = this.dggs;
739
+ const isApertureSequence = !!apertureSequence;
740
+ const apSeq = apertureSequence || "";
741
+ try {
742
+ const resultArray = this._module.SEQNUMS_children(lng, lat, azimuth, aperture, resolution, topology, projection, isApertureSequence, apSeq, sequenceNum);
743
+ // The result is a flat array with format:
744
+ // [count0, count1, ..., countN, child0_0, child0_1, ..., child0_(count0-1), child1_0, ...]
745
+ const inputSize = sequenceNum.length;
746
+ const counts = resultArray.slice(0, inputSize);
747
+ const children = [];
748
+ let offset = inputSize;
749
+ for (let i = 0; i < inputSize; i++) {
750
+ const count = Number(counts[i]);
751
+ children.push(resultArray.slice(offset, offset + count));
752
+ offset += count;
753
+ }
754
+ return children;
755
+ }
756
+ catch (e) {
757
+ console.error(this._module.getExceptionMessage(e).toString());
758
+ throw e;
759
+ }
760
+ }
761
+ // =========================================================================
762
+ // Hierarchical Address Type Conversions
763
+ // These methods convert between SEQNUM and hierarchical indexing systems
764
+ // =========================================================================
765
+ /**
766
+ * Convert a SEQNUM cell ID to VERTEX2DD (icosahedral vertex) coordinates.
767
+ *
768
+ * VERTEX2DD addresses represent positions relative to the vertices and
769
+ * triangular faces of the underlying icosahedron.
770
+ *
771
+ * ```ts
772
+ * const vertex = dggs.sequenceNumToVertex2DD(100n, 5);
773
+ * // vertex = { keep: true, vertNum: 1, triNum: 1, x: 0.0625, y: 0.054... }
774
+ * ```
775
+ *
776
+ * @param sequenceNum - The cell sequence number to convert.
777
+ * @param resolution - Resolution of the input cell. Defaults to the
778
+ * instance's current {@link resolution}.
779
+ * @returns An object with `{keep, vertNum, triNum, x, y}` representing
780
+ * the vertex coordinate.
781
+ */
782
+ sequenceNumToVertex2DD(sequenceNum, resolution = DEFAULT_RESOLUTION) {
783
+ try {
784
+ const result = this._module.SEQNUM_to_VERTEX2DD(...this._getParams(resolution), sequenceNum);
785
+ return result;
786
+ }
787
+ catch (e) {
788
+ console.error(this._module.getExceptionMessage(e).toString());
789
+ throw e;
790
+ }
791
+ }
792
+ /**
793
+ * Convert VERTEX2DD (icosahedral vertex) coordinates to a SEQNUM cell ID.
794
+ *
795
+ * ```ts
796
+ * const seqnum = dggs.vertex2DDToSequenceNum(true, 1, 1, 0.0625, 0.054, 5);
797
+ * // seqnum = 100n
798
+ * ```
799
+ *
800
+ * @param keep - Whether to keep this vertex.
801
+ * @param vertNum - Vertex number (0-11 for icosahedron).
802
+ * @param triNum - Triangle number on the icosahedron.
803
+ * @param x - X coordinate within the triangle.
804
+ * @param y - Y coordinate within the triangle.
805
+ * @param resolution - Resolution at which to compute the cell ID. Defaults
806
+ * to the instance's current {@link resolution}.
807
+ * @returns The sequence number (BigInt) of the cell containing this coordinate.
808
+ */
809
+ vertex2DDToSequenceNum(keep, vertNum, triNum, x, y, resolution = DEFAULT_RESOLUTION) {
810
+ try {
811
+ return this._module.VERTEX2DD_to_SEQNUM(...this._getParams(resolution), keep, vertNum, triNum, x, y);
812
+ }
813
+ catch (e) {
814
+ console.error(this._module.getExceptionMessage(e).toString());
815
+ throw e;
816
+ }
817
+ }
818
+ /**
819
+ * Convert a SEQNUM cell ID to ZORDER (Z-order curve) coordinate.
820
+ *
821
+ * ZORDER uses digit-interleaved coordinates to create a space-filling
822
+ * curve index. This provides good spatial locality for range queries.
823
+ *
824
+ * **Compatibility:** ZORDER is only available for **aperture 3 and 4**
825
+ * hexagon grids. It is **NOT supported** for aperture 7.
826
+ *
827
+ * ```ts
828
+ * // With aperture 4:
829
+ * const zorder = dggs.sequenceNumToZOrder(100n, 5);
830
+ * // zorder = 1168684103302643712n
831
+ * ```
832
+ *
833
+ * @param sequenceNum - The cell sequence number to convert.
834
+ * @param resolution - Resolution of the input cell. Defaults to the
835
+ * instance's current {@link resolution}.
836
+ * @returns A BigInt representing the Z-order coordinate.
837
+ * @throws If used with an incompatible aperture (7) or topology.
838
+ */
839
+ sequenceNumToZOrder(sequenceNum, resolution = DEFAULT_RESOLUTION) {
840
+ const { aperture, apertureSequence } = this.dggs;
841
+ // Check aperture compatibility
842
+ if (aperture === 7 && !apertureSequence) {
843
+ throw new Error('ZORDER is not available for aperture 7. ' +
844
+ 'Use Z7 hierarchical indexing instead, or switch to aperture 3 or 4.');
845
+ }
846
+ try {
847
+ return this._module.SEQNUM_to_ZORDER(...this._getParams(resolution), sequenceNum);
848
+ }
849
+ catch (e) {
850
+ const errMsg = this._module.getExceptionMessage(e).toString();
851
+ if (errMsg.includes('aperture')) {
852
+ throw new Error(`ZORDER error: ${errMsg}. ZORDER requires aperture 3 or 4 (not 7).`);
853
+ }
854
+ console.error(errMsg);
855
+ throw e;
856
+ }
857
+ }
858
+ /**
859
+ * Convert a ZORDER (Z-order curve) coordinate to a SEQNUM cell ID.
860
+ *
861
+ * ```ts
862
+ * const seqnum = dggs.zOrderToSequenceNum(1168684103302643712n, 5);
863
+ * // seqnum = 100n
864
+ * ```
865
+ *
866
+ * @param zorderValue - The Z-order coordinate value (BigInt).
867
+ * @param resolution - Resolution at which to compute the cell ID. Defaults
868
+ * to the instance's current {@link resolution}.
869
+ * @returns The sequence number (BigInt) corresponding to this Z-order value.
870
+ * @throws If used with an incompatible aperture (7) or topology.
871
+ */
872
+ zOrderToSequenceNum(zorderValue, resolution = DEFAULT_RESOLUTION) {
873
+ const { aperture, apertureSequence } = this.dggs;
874
+ if (aperture === 7 && !apertureSequence) {
875
+ throw new Error('ZORDER is not available for aperture 7. ' +
876
+ 'Use Z7 hierarchical indexing instead, or switch to aperture 3 or 4.');
877
+ }
878
+ try {
879
+ return this._module.ZORDER_to_SEQNUM(...this._getParams(resolution), zorderValue);
880
+ }
881
+ catch (e) {
882
+ const errMsg = this._module.getExceptionMessage(e).toString();
883
+ if (errMsg.includes('aperture')) {
884
+ throw new Error(`ZORDER error: ${errMsg}. ZORDER requires aperture 3 or 4 (not 7).`);
885
+ }
886
+ console.error(errMsg);
887
+ throw e;
888
+ }
889
+ }
890
+ /**
891
+ * Convert a SEQNUM cell ID to Z3 (base-3 Central Place Indexing) coordinate.
892
+ *
893
+ * Z3 uses base-3 digit encoding optimized for aperture 3 hexagon grids.
894
+ * Each parent cell contains exactly 3 children in the hierarchy.
895
+ *
896
+ * **Compatibility:** Z3 is **only available for aperture 3** hexagon grids.
897
+ *
898
+ * ```ts
899
+ * // With aperture 3:
900
+ * const z3 = dggs.sequenceNumToZ3(100n, 5);
901
+ * // z3 = 1773292353277132799n
902
+ * ```
903
+ *
904
+ * @param sequenceNum - The cell sequence number to convert.
905
+ * @param resolution - Resolution of the input cell. Defaults to the
906
+ * instance's current {@link resolution}.
907
+ * @returns A BigInt representing the Z3 coordinate (INT64 format).
908
+ * @throws If used with an incompatible aperture (not 3) or topology.
909
+ */
910
+ sequenceNumToZ3(sequenceNum, resolution = DEFAULT_RESOLUTION) {
911
+ const { aperture, topology, apertureSequence } = this.dggs;
912
+ if ((aperture !== 3 || topology !== 'HEXAGON') && !apertureSequence) {
913
+ throw new Error('Z3 is only available for aperture 3 hexagon grids. ' +
914
+ `Current configuration: aperture ${aperture}, topology ${topology}.`);
915
+ }
916
+ try {
917
+ return this._module.SEQNUM_to_Z3(...this._getParams(resolution), sequenceNum);
918
+ }
919
+ catch (e) {
920
+ const errMsg = this._module.getExceptionMessage(e).toString();
921
+ if (errMsg.includes('aperture') || errMsg.includes('Z3')) {
922
+ throw new Error(`Z3 error: ${errMsg}. Z3 requires aperture 3 hexagon grids.`);
923
+ }
924
+ console.error(errMsg);
925
+ throw e;
926
+ }
927
+ }
928
+ /**
929
+ * Convert a Z3 (base-3 Central Place Indexing) coordinate to a SEQNUM cell ID.
930
+ *
931
+ * ```ts
932
+ * const seqnum = dggs.z3ToSequenceNum(1773292353277132799n, 5);
933
+ * // seqnum = 100n
934
+ * ```
935
+ *
936
+ * @param z3Value - The Z3 coordinate value (BigInt, INT64 format).
937
+ * @param resolution - Resolution at which to compute the cell ID. Defaults
938
+ * to the instance's current {@link resolution}.
939
+ * @returns The sequence number (BigInt) corresponding to this Z3 value.
940
+ * @throws If used with an incompatible aperture (not 3) or topology.
941
+ */
942
+ z3ToSequenceNum(z3Value, resolution = DEFAULT_RESOLUTION) {
943
+ const { aperture, topology, apertureSequence } = this.dggs;
944
+ if ((aperture !== 3 || topology !== 'HEXAGON') && !apertureSequence) {
945
+ throw new Error('Z3 is only available for aperture 3 hexagon grids. ' +
946
+ `Current configuration: aperture ${aperture}, topology ${topology}.`);
947
+ }
948
+ try {
949
+ return this._module.Z3_to_SEQNUM(...this._getParams(resolution), z3Value);
950
+ }
951
+ catch (e) {
952
+ const errMsg = this._module.getExceptionMessage(e).toString();
953
+ if (errMsg.includes('aperture') || errMsg.includes('Z3')) {
954
+ throw new Error(`Z3 error: ${errMsg}. Z3 requires aperture 3 hexagon grids.`);
955
+ }
956
+ console.error(errMsg);
957
+ throw e;
958
+ }
959
+ }
960
+ /**
961
+ * Convert a SEQNUM cell ID to Z7 (base-7 Central Place Indexing) coordinate.
962
+ *
963
+ * Z7 uses base-7 digit encoding with pure bitarithmetic operations,
964
+ * optimized for aperture 7 hexagon grids. Each parent cell contains
965
+ * exactly 7 children in the hierarchy.
966
+ *
967
+ * **Compatibility:** Z7 is **only available for aperture 7** hexagon grids.
968
+ *
969
+ * ```ts
970
+ * // With aperture 7:
971
+ * const z7 = dggs.sequenceNumToZ7(100n, 5);
972
+ * // z7 = 1153167795211468799n (displayed as hex: 0x1000000000000fff)
973
+ * ```
974
+ *
975
+ * @param sequenceNum - The cell sequence number to convert.
976
+ * @param resolution - Resolution of the input cell. Defaults to the
977
+ * instance's current {@link resolution}.
978
+ * @returns A BigInt representing the Z7 coordinate (INT64/hex format).
979
+ * @throws If used with an incompatible aperture (not 7) or topology.
980
+ */
981
+ sequenceNumToZ7(sequenceNum, resolution = DEFAULT_RESOLUTION) {
982
+ const { aperture, topology, apertureSequence } = this.dggs;
983
+ if ((aperture !== 7 || topology !== 'HEXAGON') && !apertureSequence) {
984
+ throw new Error('Z7 is only available for aperture 7 hexagon grids. ' +
985
+ `Current configuration: aperture ${aperture}, topology ${topology}.`);
986
+ }
987
+ try {
988
+ return this._module.SEQNUM_to_Z7(...this._getParams(resolution), sequenceNum);
989
+ }
990
+ catch (e) {
991
+ const errMsg = this._module.getExceptionMessage(e).toString();
992
+ if (errMsg.includes('aperture') || errMsg.includes('Z7')) {
993
+ throw new Error(`Z7 error: ${errMsg}. Z7 requires aperture 7 hexagon grids.`);
994
+ }
995
+ console.error(errMsg);
996
+ throw e;
997
+ }
998
+ }
999
+ /**
1000
+ * Convert a Z7 (base-7 Central Place Indexing) coordinate to a SEQNUM cell ID.
1001
+ *
1002
+ * ```ts
1003
+ * const seqnum = dggs.z7ToSequenceNum(1153167795211468799n, 5);
1004
+ * // seqnum = 100n
1005
+ * ```
1006
+ *
1007
+ * @param z7Value - The Z7 coordinate value (BigInt, INT64/hex format).
1008
+ * @param resolution - Resolution at which to compute the cell ID. Defaults
1009
+ * to the instance's current {@link resolution}.
1010
+ * @returns The sequence number (BigInt) corresponding to this Z7 value.
1011
+ * @throws If used with an incompatible aperture (not 7) or topology.
1012
+ */
1013
+ z7ToSequenceNum(z7Value, resolution = DEFAULT_RESOLUTION) {
1014
+ const { aperture, topology, apertureSequence } = this.dggs;
1015
+ if ((aperture !== 7 || topology !== 'HEXAGON') && !apertureSequence) {
1016
+ throw new Error('Z7 is only available for aperture 7 hexagon grids. ' +
1017
+ `Current configuration: aperture ${aperture}, topology ${topology}.`);
1018
+ }
1019
+ try {
1020
+ return this._module.Z7_to_SEQNUM(...this._getParams(resolution), z7Value);
1021
+ }
1022
+ catch (e) {
1023
+ const errMsg = this._module.getExceptionMessage(e).toString();
1024
+ if (errMsg.includes('aperture') || errMsg.includes('Z7')) {
1025
+ throw new Error(`Z7 error: ${errMsg}. Z7 requires aperture 7 hexagon grids.`);
1026
+ }
1027
+ console.error(errMsg);
1028
+ throw e;
1029
+ }
1030
+ }
1031
+ /**
1032
+ * Get the quad (icosahedron face) number from a Z7 index.
1033
+ *
1034
+ * The quad occupies bits 63–60 of the 64-bit packed value.
1035
+ *
1036
+ * ```ts
1037
+ * const quad = dggs.z7GetQuad(z7Value); // 0–11
1038
+ * ```
1039
+ *
1040
+ * @param z7Value - A Z7 packed index (BigInt).
1041
+ * @returns The quad number (0–11).
1042
+ */
1043
+ z7GetQuad(z7Value) {
1044
+ return Number((z7Value & Webdggrid.Z7_QUAD_MASK) >> Webdggrid.Z7_QUAD_OFFSET);
1045
+ }
1046
+ /**
1047
+ * Get the digit at a specific resolution level from a Z7 index.
1048
+ *
1049
+ * Each digit is 3 bits wide and occupies a fixed position in the 64-bit value.
1050
+ * Valid digits are 0–6; the value 7 is the invalid/padding marker.
1051
+ *
1052
+ * ```ts
1053
+ * const digit = dggs.z7GetDigit(z7Value, 3); // 0–6 (or 7 = invalid)
1054
+ * ```
1055
+ *
1056
+ * @param z7Value - A Z7 packed index (BigInt).
1057
+ * @param res - Resolution level (1-based, 1 to 20).
1058
+ * @returns The digit value (0–7).
1059
+ */
1060
+ z7GetDigit(z7Value, res) {
1061
+ const shift = BigInt(Webdggrid.Z7_MAX_RES - res) * Webdggrid.Z7_BITS_PER_DIGIT;
1062
+ return Number((z7Value >> shift) & Webdggrid.Z7_DIGIT_MASK);
1063
+ }
1064
+ /**
1065
+ * Set the digit at a specific resolution level in a Z7 index.
1066
+ *
1067
+ * Returns a new Z7 value with the digit at position `res` replaced.
1068
+ *
1069
+ * ```ts
1070
+ * const child = dggs.z7SetDigit(z7Value, 6, 3); // set res-6 digit to 3
1071
+ * ```
1072
+ *
1073
+ * @param z7Value - A Z7 packed index (BigInt).
1074
+ * @param res - Resolution level (1-based, 1 to 20).
1075
+ * @param digit - The digit value to set (0–6, or 7 for invalid).
1076
+ * @returns A new Z7 value with the digit replaced.
1077
+ */
1078
+ z7SetDigit(z7Value, res, digit) {
1079
+ const shift = BigInt(Webdggrid.Z7_MAX_RES - res) * Webdggrid.Z7_BITS_PER_DIGIT;
1080
+ return (z7Value & ~(Webdggrid.Z7_DIGIT_MASK << shift)) | (BigInt(digit) << shift);
1081
+ }
1082
+ /**
1083
+ * Extract all digits from a Z7 index up to a given resolution.
1084
+ *
1085
+ * ```ts
1086
+ * const { quad, digits } = dggs.z7ExtractDigits(z7Value, 5);
1087
+ * // quad: 1, digits: [2, 0, 3, 4, 1]
1088
+ * ```
1089
+ *
1090
+ * @param z7Value - A Z7 packed index (BigInt).
1091
+ * @param resolution - Number of digits to extract (1-based).
1092
+ * @returns Object with `quad` (number) and `digits` (number array).
1093
+ */
1094
+ z7ExtractDigits(z7Value, resolution) {
1095
+ const quad = this.z7GetQuad(z7Value);
1096
+ const digits = [];
1097
+ for (let r = 1; r <= resolution; r++) {
1098
+ digits.push(this.z7GetDigit(z7Value, r));
1099
+ }
1100
+ return { quad, digits };
1101
+ }
1102
+ /**
1103
+ * Get the quad (icosahedron face) number from a Z3 index.
1104
+ *
1105
+ * ```ts
1106
+ * const quad = dggs.z3GetQuad(z3Value); // 0–11
1107
+ * ```
1108
+ *
1109
+ * @param z3Value - A Z3 packed index (BigInt).
1110
+ * @returns The quad number (0–11).
1111
+ */
1112
+ z3GetQuad(z3Value) {
1113
+ return Number((z3Value & Webdggrid.Z3_QUAD_MASK) >> Webdggrid.Z3_QUAD_OFFSET);
1114
+ }
1115
+ /**
1116
+ * Get the digit at a specific resolution level from a Z3 index.
1117
+ *
1118
+ * Each digit is 2 bits wide. Valid digits are 0–2; the value 3 is the
1119
+ * invalid/padding marker.
1120
+ *
1121
+ * ```ts
1122
+ * const digit = dggs.z3GetDigit(z3Value, 3); // 0–2 (or 3 = invalid)
1123
+ * ```
1124
+ *
1125
+ * @param z3Value - A Z3 packed index (BigInt).
1126
+ * @param res - Resolution level (1-based, 1 to 30).
1127
+ * @returns The digit value (0–3).
1128
+ */
1129
+ z3GetDigit(z3Value, res) {
1130
+ const shift = BigInt(Webdggrid.Z3_MAX_RES - res) * Webdggrid.Z3_BITS_PER_DIGIT;
1131
+ return Number((z3Value >> shift) & Webdggrid.Z3_DIGIT_MASK);
1132
+ }
1133
+ /**
1134
+ * Set the digit at a specific resolution level in a Z3 index.
1135
+ *
1136
+ * ```ts
1137
+ * const child = dggs.z3SetDigit(z3Value, 6, 1); // set res-6 digit to 1
1138
+ * ```
1139
+ *
1140
+ * @param z3Value - A Z3 packed index (BigInt).
1141
+ * @param res - Resolution level (1-based, 1 to 30).
1142
+ * @param digit - The digit value to set (0–2, or 3 for invalid).
1143
+ * @returns A new Z3 value with the digit replaced.
1144
+ */
1145
+ z3SetDigit(z3Value, res, digit) {
1146
+ const shift = BigInt(Webdggrid.Z3_MAX_RES - res) * Webdggrid.Z3_BITS_PER_DIGIT;
1147
+ return (z3Value & ~(Webdggrid.Z3_DIGIT_MASK << shift)) | (BigInt(digit) << shift);
1148
+ }
1149
+ /**
1150
+ * Extract all digits from a Z3 index up to a given resolution.
1151
+ *
1152
+ * ```ts
1153
+ * const { quad, digits } = dggs.z3ExtractDigits(z3Value, 5);
1154
+ * // quad: 1, digits: [1, 0, 2, 1, 0]
1155
+ * ```
1156
+ *
1157
+ * @param z3Value - A Z3 packed index (BigInt).
1158
+ * @param resolution - Number of digits to extract (1-based).
1159
+ * @returns Object with `quad` (number) and `digits` (number array).
1160
+ */
1161
+ z3ExtractDigits(z3Value, resolution) {
1162
+ const quad = this.z3GetQuad(z3Value);
1163
+ const digits = [];
1164
+ for (let r = 1; r <= resolution; r++) {
1165
+ digits.push(this.z3GetDigit(z3Value, r));
1166
+ }
1167
+ return { quad, digits };
1168
+ }
1169
+ /**
1170
+ * Get the quad (icosahedron face) number from a ZORDER index.
1171
+ *
1172
+ * ```ts
1173
+ * const quad = dggs.zOrderGetQuad(zorderValue); // 0–11
1174
+ * ```
1175
+ *
1176
+ * @param zorderValue - A ZORDER packed index (BigInt).
1177
+ * @returns The quad number (0–11).
1178
+ */
1179
+ zOrderGetQuad(zorderValue) {
1180
+ return Number((zorderValue & Webdggrid.ZORDER_QUAD_MASK) >> Webdggrid.ZORDER_QUAD_OFFSET);
1181
+ }
1182
+ /**
1183
+ * Get the digit at a specific resolution level from a ZORDER index.
1184
+ *
1185
+ * Each digit is 2 bits wide (values 0–3).
1186
+ *
1187
+ * ```ts
1188
+ * const digit = dggs.zOrderGetDigit(zorderValue, 3); // 0–3
1189
+ * ```
1190
+ *
1191
+ * @param zorderValue - A ZORDER packed index (BigInt).
1192
+ * @param res - Resolution level (1-based, 1 to 30).
1193
+ * @returns The digit value (0–3).
1194
+ */
1195
+ zOrderGetDigit(zorderValue, res) {
1196
+ const shift = BigInt(Webdggrid.ZORDER_MAX_RES - res) * Webdggrid.ZORDER_BITS_PER_DIGIT;
1197
+ return Number((zorderValue >> shift) & Webdggrid.ZORDER_DIGIT_MASK);
1198
+ }
1199
+ /**
1200
+ * Set the digit at a specific resolution level in a ZORDER index.
1201
+ *
1202
+ * ```ts
1203
+ * const modified = dggs.zOrderSetDigit(zorderValue, 3, 2);
1204
+ * ```
1205
+ *
1206
+ * @param zorderValue - A ZORDER packed index (BigInt).
1207
+ * @param res - Resolution level (1-based, 1 to 30).
1208
+ * @param digit - The digit value to set (0–3).
1209
+ * @returns A new ZORDER value with the digit replaced.
1210
+ */
1211
+ zOrderSetDigit(zorderValue, res, digit) {
1212
+ const shift = BigInt(Webdggrid.ZORDER_MAX_RES - res) * Webdggrid.ZORDER_BITS_PER_DIGIT;
1213
+ return (zorderValue & ~(Webdggrid.ZORDER_DIGIT_MASK << shift)) | (BigInt(digit) << shift);
1214
+ }
1215
+ /**
1216
+ * Extract all digits from a ZORDER index up to a given resolution.
1217
+ *
1218
+ * ```ts
1219
+ * const { quad, digits } = dggs.zOrderExtractDigits(zorderValue, 5);
1220
+ * // quad: 1, digits: [2, 0, 3, 1, 0]
1221
+ * ```
1222
+ *
1223
+ * @param zorderValue - A ZORDER packed index (BigInt).
1224
+ * @param resolution - Number of digits to extract (1-based).
1225
+ * @returns Object with `quad` (number) and `digits` (number array).
1226
+ */
1227
+ zOrderExtractDigits(zorderValue, resolution) {
1228
+ const quad = this.zOrderGetQuad(zorderValue);
1229
+ const digits = [];
1230
+ for (let r = 1; r <= resolution; r++) {
1231
+ digits.push(this.zOrderGetDigit(zorderValue, r));
1232
+ }
1233
+ return { quad, digits };
1234
+ }
1235
+ // =========================================================================
1236
+ // Low-level coordinate transformation methods
1237
+ // These methods expose all DGGRID coordinate systems beyond GEO/SEQNUM
1238
+ // =========================================================================
1239
+ /**
1240
+ * Helper to build the DGGS parameter array for WASM calls.
1241
+ * @private
1242
+ */
1243
+ _getParams(resolution = DEFAULT_RESOLUTION) {
1244
+ const { poleCoordinates: { lat, lng }, azimuth, topology, projection, aperture, apertureSequence, } = this.dggs;
1245
+ const isApertureSequence = !!apertureSequence;
1246
+ const apSeq = apertureSequence || "";
1247
+ return [
1248
+ lng,
1249
+ lat,
1250
+ azimuth,
1251
+ aperture,
1252
+ resolution,
1253
+ topology,
1254
+ projection,
1255
+ isApertureSequence,
1256
+ apSeq
1257
+ ];
1258
+ }
1259
+ // -------------------------------------------------------------------------
1260
+ // GEO transformations (beyond the high-level methods above)
1261
+ // -------------------------------------------------------------------------
1262
+ /**
1263
+ * Converts geographic coordinates to PLANE coordinates.
1264
+ *
1265
+ * @param coordinates - Array of `[lng, lat]` pairs
1266
+ * @param resolution - Resolution level
1267
+ * @returns Array of `{x, y}` plane coordinates
1268
+ */
1269
+ geoToPlane(coordinates, resolution = DEFAULT_RESOLUTION) {
1270
+ const xCoords = coordinates.map(c => c[0]);
1271
+ const yCoords = coordinates.map(c => c[1]);
1272
+ const result = this._module.GEO_to_PLANE(...this._getParams(resolution), xCoords, yCoords);
1273
+ const size = result.length / 2;
1274
+ const output = [];
1275
+ for (let i = 0; i < size; i++) {
1276
+ output.push({ x: result[i], y: result[i + size] });
1277
+ }
1278
+ return output;
1279
+ }
1280
+ /**
1281
+ * Converts geographic coordinates to PROJTRI coordinates.
1282
+ *
1283
+ * @param coordinates - Array of `[lng, lat]` pairs
1284
+ * @param resolution - Resolution level
1285
+ * @returns Array of `{tnum, x, y}` projection triangle coordinates
1286
+ */
1287
+ geoToProjtri(coordinates, resolution = DEFAULT_RESOLUTION) {
1288
+ const xCoords = coordinates.map(c => c[0]);
1289
+ const yCoords = coordinates.map(c => c[1]);
1290
+ const result = this._module.GEO_to_PROJTRI(...this._getParams(resolution), xCoords, yCoords);
1291
+ const size = result.length / 3;
1292
+ const output = [];
1293
+ for (let i = 0; i < size; i++) {
1294
+ output.push({
1295
+ tnum: result[i],
1296
+ x: result[i + size],
1297
+ y: result[i + 2 * size]
1298
+ });
1299
+ }
1300
+ return output;
1301
+ }
1302
+ /**
1303
+ * Converts geographic coordinates to Q2DD coordinates.
1304
+ *
1305
+ * @param coordinates - Array of `[lng, lat]` pairs
1306
+ * @param resolution - Resolution level
1307
+ * @returns Array of `{quad, x, y}` quad 2D double coordinates
1308
+ */
1309
+ geoToQ2dd(coordinates, resolution = DEFAULT_RESOLUTION) {
1310
+ const xCoords = coordinates.map(c => c[0]);
1311
+ const yCoords = coordinates.map(c => c[1]);
1312
+ const result = this._module.GEO_to_Q2DD(...this._getParams(resolution), xCoords, yCoords);
1313
+ const size = result.length / 3;
1314
+ const output = [];
1315
+ for (let i = 0; i < size; i++) {
1316
+ output.push({
1317
+ quad: result[i],
1318
+ x: result[i + size],
1319
+ y: result[i + 2 * size]
1320
+ });
1321
+ }
1322
+ return output;
1323
+ }
1324
+ /**
1325
+ * Converts geographic coordinates to Q2DI coordinates.
1326
+ *
1327
+ * @param coordinates - Array of `[lng, lat]` pairs
1328
+ * @param resolution - Resolution level
1329
+ * @returns Array of `{quad, i, j}` quad 2D integer coordinates
1330
+ */
1331
+ geoToQ2di(coordinates, resolution = DEFAULT_RESOLUTION) {
1332
+ const xCoords = coordinates.map(c => c[0]);
1333
+ const yCoords = coordinates.map(c => c[1]);
1334
+ const result = this._module.GEO_to_Q2DI(...this._getParams(resolution), xCoords, yCoords);
1335
+ const size = result.length / 3;
1336
+ const output = [];
1337
+ for (let i = 0; i < size; i++) {
1338
+ output.push({
1339
+ quad: result[i],
1340
+ i: BigInt(result[i + size]),
1341
+ j: BigInt(result[i + 2 * size])
1342
+ });
1343
+ }
1344
+ return output;
1345
+ }
1346
+ // -------------------------------------------------------------------------
1347
+ // SEQNUM transformations (beyond the high-level methods above)
1348
+ // -------------------------------------------------------------------------
1349
+ /**
1350
+ * Converts sequence numbers to PLANE coordinates.
1351
+ *
1352
+ * @param sequenceNum - Array of cell IDs
1353
+ * @param resolution - Resolution level
1354
+ * @returns Array of `{x, y}` plane coordinates
1355
+ */
1356
+ sequenceNumToPlane(sequenceNum, resolution = DEFAULT_RESOLUTION) {
1357
+ const result = this._module.SEQNUM_to_PLANE(...this._getParams(resolution), sequenceNum);
1358
+ const size = result.length / 2;
1359
+ const output = [];
1360
+ for (let i = 0; i < size; i++) {
1361
+ output.push({ x: result[i], y: result[i + size] });
1362
+ }
1363
+ return output;
1364
+ }
1365
+ /**
1366
+ * Converts sequence numbers to PROJTRI coordinates.
1367
+ *
1368
+ * @param sequenceNum - Array of cell IDs
1369
+ * @param resolution - Resolution level
1370
+ * @returns Array of `{tnum, x, y}` projection triangle coordinates
1371
+ */
1372
+ sequenceNumToProjtri(sequenceNum, resolution = DEFAULT_RESOLUTION) {
1373
+ const result = this._module.SEQNUM_to_PROJTRI(...this._getParams(resolution), sequenceNum);
1374
+ const size = result.length / 3;
1375
+ const output = [];
1376
+ for (let i = 0; i < size; i++) {
1377
+ output.push({
1378
+ tnum: result[i],
1379
+ x: result[i + size],
1380
+ y: result[i + 2 * size]
1381
+ });
1382
+ }
1383
+ return output;
1384
+ }
1385
+ /**
1386
+ * Converts sequence numbers to Q2DD coordinates.
1387
+ *
1388
+ * @param sequenceNum - Array of cell IDs
1389
+ * @param resolution - Resolution level
1390
+ * @returns Array of `{quad, x, y}` quad 2D double coordinates
1391
+ */
1392
+ sequenceNumToQ2dd(sequenceNum, resolution = DEFAULT_RESOLUTION) {
1393
+ const result = this._module.SEQNUM_to_Q2DD(...this._getParams(resolution), sequenceNum);
1394
+ const size = result.length / 3;
1395
+ const output = [];
1396
+ for (let i = 0; i < size; i++) {
1397
+ output.push({
1398
+ quad: result[i],
1399
+ x: result[i + size],
1400
+ y: result[i + 2 * size]
1401
+ });
1402
+ }
1403
+ return output;
1404
+ }
1405
+ /**
1406
+ * Converts sequence numbers to Q2DI coordinates.
1407
+ *
1408
+ * @param sequenceNum - Array of cell IDs
1409
+ * @param resolution - Resolution level
1410
+ * @returns Array of `{quad, i, j}` quad 2D integer coordinates
1411
+ */
1412
+ sequenceNumToQ2di(sequenceNum, resolution = DEFAULT_RESOLUTION) {
1413
+ const result = this._module.SEQNUM_to_Q2DI(...this._getParams(resolution), sequenceNum);
1414
+ const size = result.length / 3;
1415
+ const output = [];
1416
+ for (let i = 0; i < size; i++) {
1417
+ output.push({
1418
+ quad: result[i],
1419
+ i: BigInt(result[i + size]),
1420
+ j: BigInt(result[i + 2 * size])
1421
+ });
1422
+ }
1423
+ return output;
1424
+ }
1425
+ // -------------------------------------------------------------------------
1426
+ // Q2DI transformations
1427
+ // -------------------------------------------------------------------------
1428
+ /**
1429
+ * Converts Q2DI coordinates to geographic coordinates.
1430
+ *
1431
+ * @param coords - Array of `{quad, i, j}` coordinates
1432
+ * @param resolution - Resolution level
1433
+ * @returns Array of `[lng, lat]` positions
1434
+ */
1435
+ q2diToGeo(coords, resolution = DEFAULT_RESOLUTION) {
1436
+ const quads = coords.map(c => c.quad);
1437
+ const is = coords.map(c => Number(c.i));
1438
+ const js = coords.map(c => Number(c.j));
1439
+ const result = this._module.Q2DI_to_GEO(...this._getParams(resolution), quads, is, js);
1440
+ const size = result.length / 2;
1441
+ const output = [];
1442
+ for (let i = 0; i < size; i++) {
1443
+ output.push([result[i], result[i + size]]);
1444
+ }
1445
+ return output;
1446
+ }
1447
+ /**
1448
+ * Converts Q2DI coordinates to sequence numbers.
1449
+ *
1450
+ * @param coords - Array of `{quad, i, j}` coordinates
1451
+ * @param resolution - Resolution level
1452
+ * @returns Array of cell IDs
1453
+ */
1454
+ q2diToSequenceNum(coords, resolution = DEFAULT_RESOLUTION) {
1455
+ const quads = coords.map(c => c.quad);
1456
+ const is = coords.map(c => Number(c.i));
1457
+ const js = coords.map(c => Number(c.j));
1458
+ return this._module.Q2DI_to_SEQNUM(...this._getParams(resolution), quads, is, js);
1459
+ }
1460
+ /**
1461
+ * Converts Q2DI coordinates to PLANE coordinates.
1462
+ *
1463
+ * @param coords - Array of `{quad, i, j}` coordinates
1464
+ * @param resolution - Resolution level
1465
+ * @returns Array of `{x, y}` plane coordinates
1466
+ */
1467
+ q2diToPlane(coords, resolution = DEFAULT_RESOLUTION) {
1468
+ const quads = coords.map(c => c.quad);
1469
+ const is = coords.map(c => Number(c.i));
1470
+ const js = coords.map(c => Number(c.j));
1471
+ const result = this._module.Q2DI_to_PLANE(...this._getParams(resolution), quads, is, js);
1472
+ const size = result.length / 2;
1473
+ const output = [];
1474
+ for (let i = 0; i < size; i++) {
1475
+ output.push({ x: result[i], y: result[i + size] });
1476
+ }
1477
+ return output;
1478
+ }
1479
+ /**
1480
+ * Converts Q2DI coordinates to PROJTRI coordinates.
1481
+ *
1482
+ * @param coords - Array of `{quad, i, j}` coordinates
1483
+ * @param resolution - Resolution level
1484
+ * @returns Array of `{tnum, x, y}` projection triangle coordinates
1485
+ */
1486
+ q2diToProjtri(coords, resolution = DEFAULT_RESOLUTION) {
1487
+ const quads = coords.map(c => c.quad);
1488
+ const is = coords.map(c => Number(c.i));
1489
+ const js = coords.map(c => Number(c.j));
1490
+ const result = this._module.Q2DI_to_PROJTRI(...this._getParams(resolution), quads, is, js);
1491
+ const size = result.length / 3;
1492
+ const output = [];
1493
+ for (let i = 0; i < size; i++) {
1494
+ output.push({
1495
+ tnum: result[i],
1496
+ x: result[i + size],
1497
+ y: result[i + 2 * size]
1498
+ });
1499
+ }
1500
+ return output;
1501
+ }
1502
+ /**
1503
+ * Converts Q2DI coordinates to Q2DD coordinates.
1504
+ *
1505
+ * @param coords - Array of `{quad, i, j}` coordinates
1506
+ * @param resolution - Resolution level
1507
+ * @returns Array of `{quad, x, y}` quad 2D double coordinates
1508
+ */
1509
+ q2diToQ2dd(coords, resolution = DEFAULT_RESOLUTION) {
1510
+ const quads = coords.map(c => c.quad);
1511
+ const is = coords.map(c => Number(c.i));
1512
+ const js = coords.map(c => Number(c.j));
1513
+ const result = this._module.Q2DI_to_Q2DD(...this._getParams(resolution), quads, is, js);
1514
+ const size = result.length / 3;
1515
+ const output = [];
1516
+ for (let i = 0; i < size; i++) {
1517
+ output.push({
1518
+ quad: result[i],
1519
+ x: result[i + size],
1520
+ y: result[i + 2 * size]
1521
+ });
1522
+ }
1523
+ return output;
1524
+ }
1525
+ // -------------------------------------------------------------------------
1526
+ // Q2DD transformations
1527
+ // -------------------------------------------------------------------------
1528
+ /**
1529
+ * Converts Q2DD coordinates to geographic coordinates.
1530
+ *
1531
+ * @param coords - Array of `{quad, x, y}` coordinates
1532
+ * @param resolution - Resolution level
1533
+ * @returns Array of `[lng, lat]` positions
1534
+ */
1535
+ q2ddToGeo(coords, resolution = DEFAULT_RESOLUTION) {
1536
+ const quads = coords.map(c => c.quad);
1537
+ const xs = coords.map(c => c.x);
1538
+ const ys = coords.map(c => c.y);
1539
+ const result = this._module.Q2DD_to_GEO(...this._getParams(resolution), quads, xs, ys);
1540
+ const size = result.length / 2;
1541
+ const output = [];
1542
+ for (let i = 0; i < size; i++) {
1543
+ output.push([result[i], result[i + size]]);
1544
+ }
1545
+ return output;
1546
+ }
1547
+ /**
1548
+ * Converts Q2DD coordinates to sequence numbers.
1549
+ *
1550
+ * @param coords - Array of `{quad, x, y}` coordinates
1551
+ * @param resolution - Resolution level
1552
+ * @returns Array of cell IDs
1553
+ */
1554
+ q2ddToSequenceNum(coords, resolution = DEFAULT_RESOLUTION) {
1555
+ const quads = coords.map(c => c.quad);
1556
+ const xs = coords.map(c => c.x);
1557
+ const ys = coords.map(c => c.y);
1558
+ return this._module.Q2DD_to_SEQNUM(...this._getParams(resolution), quads, xs, ys);
1559
+ }
1560
+ /**
1561
+ * Converts Q2DD coordinates to PLANE coordinates.
1562
+ *
1563
+ * @param coords - Array of `{quad, x, y}` coordinates
1564
+ * @param resolution - Resolution level
1565
+ * @returns Array of `{x, y}` plane coordinates
1566
+ */
1567
+ q2ddToPlane(coords, resolution = DEFAULT_RESOLUTION) {
1568
+ const quads = coords.map(c => c.quad);
1569
+ const xs = coords.map(c => c.x);
1570
+ const ys = coords.map(c => c.y);
1571
+ const result = this._module.Q2DD_to_PLANE(...this._getParams(resolution), quads, xs, ys);
1572
+ const size = result.length / 2;
1573
+ const output = [];
1574
+ for (let i = 0; i < size; i++) {
1575
+ output.push({ x: result[i], y: result[i + size] });
1576
+ }
1577
+ return output;
1578
+ }
1579
+ /**
1580
+ * Converts Q2DD coordinates to PROJTRI coordinates.
1581
+ *
1582
+ * @param coords - Array of `{quad, x, y}` coordinates
1583
+ * @param resolution - Resolution level
1584
+ * @returns Array of `{tnum, x, y}` projection triangle coordinates
1585
+ */
1586
+ q2ddToProjtri(coords, resolution = DEFAULT_RESOLUTION) {
1587
+ const quads = coords.map(c => c.quad);
1588
+ const xs = coords.map(c => c.x);
1589
+ const ys = coords.map(c => c.y);
1590
+ const result = this._module.Q2DD_to_PROJTRI(...this._getParams(resolution), quads, xs, ys);
1591
+ const size = result.length / 3;
1592
+ const output = [];
1593
+ for (let i = 0; i < size; i++) {
1594
+ output.push({
1595
+ tnum: result[i],
1596
+ x: result[i + size],
1597
+ y: result[i + 2 * size]
1598
+ });
1599
+ }
1600
+ return output;
1601
+ }
1602
+ /**
1603
+ * Converts Q2DD coordinates to Q2DI coordinates.
1604
+ *
1605
+ * @param coords - Array of `{quad, x, y}` coordinates
1606
+ * @param resolution - Resolution level
1607
+ * @returns Array of `{quad, i, j}` quad 2D integer coordinates
1608
+ */
1609
+ q2ddToQ2di(coords, resolution = DEFAULT_RESOLUTION) {
1610
+ const quads = coords.map(c => c.quad);
1611
+ const xs = coords.map(c => c.x);
1612
+ const ys = coords.map(c => c.y);
1613
+ const result = this._module.Q2DD_to_Q2DI(...this._getParams(resolution), quads, xs, ys);
1614
+ const size = result.length / 3;
1615
+ const output = [];
1616
+ for (let i = 0; i < size; i++) {
1617
+ output.push({
1618
+ quad: result[i],
1619
+ i: BigInt(result[i + size]),
1620
+ j: BigInt(result[i + 2 * size])
1621
+ });
1622
+ }
1623
+ return output;
1624
+ }
1625
+ // -------------------------------------------------------------------------
1626
+ // PROJTRI transformations
1627
+ // -------------------------------------------------------------------------
1628
+ /**
1629
+ * Converts PROJTRI coordinates to geographic coordinates.
1630
+ *
1631
+ * @param coords - Array of `{tnum, x, y}` coordinates
1632
+ * @param resolution - Resolution level
1633
+ * @returns Array of `[lng, lat]` positions
1634
+ */
1635
+ projtriToGeo(coords, resolution = DEFAULT_RESOLUTION) {
1636
+ const tnums = coords.map(c => c.tnum);
1637
+ const xs = coords.map(c => c.x);
1638
+ const ys = coords.map(c => c.y);
1639
+ const result = this._module.PROJTRI_to_GEO(...this._getParams(resolution), tnums, xs, ys);
1640
+ const size = result.length / 2;
1641
+ const output = [];
1642
+ for (let i = 0; i < size; i++) {
1643
+ output.push([result[i], result[i + size]]);
1644
+ }
1645
+ return output;
1646
+ }
1647
+ /**
1648
+ * Converts PROJTRI coordinates to sequence numbers.
1649
+ *
1650
+ * @param coords - Array of `{tnum, x, y}` coordinates
1651
+ * @param resolution - Resolution level
1652
+ * @returns Array of cell IDs
1653
+ */
1654
+ projtriToSequenceNum(coords, resolution = DEFAULT_RESOLUTION) {
1655
+ const tnums = coords.map(c => c.tnum);
1656
+ const xs = coords.map(c => c.x);
1657
+ const ys = coords.map(c => c.y);
1658
+ return this._module.PROJTRI_to_SEQNUM(...this._getParams(resolution), tnums, xs, ys);
1659
+ }
1660
+ /**
1661
+ * Converts PROJTRI coordinates to PLANE coordinates.
1662
+ *
1663
+ * @param coords - Array of `{tnum, x, y}` coordinates
1664
+ * @param resolution - Resolution level
1665
+ * @returns Array of `{x, y}` plane coordinates
1666
+ */
1667
+ projtriToPlane(coords, resolution = DEFAULT_RESOLUTION) {
1668
+ const tnums = coords.map(c => c.tnum);
1669
+ const xs = coords.map(c => c.x);
1670
+ const ys = coords.map(c => c.y);
1671
+ const result = this._module.PROJTRI_to_PLANE(...this._getParams(resolution), tnums, xs, ys);
1672
+ const size = result.length / 2;
1673
+ const output = [];
1674
+ for (let i = 0; i < size; i++) {
1675
+ output.push({ x: result[i], y: result[i + size] });
1676
+ }
1677
+ return output;
1678
+ }
1679
+ /**
1680
+ * Converts PROJTRI coordinates to Q2DD coordinates.
1681
+ *
1682
+ * @param coords - Array of `{tnum, x, y}` coordinates
1683
+ * @param resolution - Resolution level
1684
+ * @returns Array of `{quad, x, y}` quad 2D double coordinates
1685
+ */
1686
+ projtriToQ2dd(coords, resolution = DEFAULT_RESOLUTION) {
1687
+ const tnums = coords.map(c => c.tnum);
1688
+ const xs = coords.map(c => c.x);
1689
+ const ys = coords.map(c => c.y);
1690
+ const result = this._module.PROJTRI_to_Q2DD(...this._getParams(resolution), tnums, xs, ys);
1691
+ const size = result.length / 3;
1692
+ const output = [];
1693
+ for (let i = 0; i < size; i++) {
1694
+ output.push({
1695
+ quad: result[i],
1696
+ x: result[i + size],
1697
+ y: result[i + 2 * size]
1698
+ });
1699
+ }
1700
+ return output;
1701
+ }
1702
+ /**
1703
+ * Converts PROJTRI coordinates to Q2DI coordinates.
1704
+ *
1705
+ * @param coords - Array of `{tnum, x, y}` coordinates
1706
+ * @param resolution - Resolution level
1707
+ * @returns Array of `{quad, i, j}` quad 2D integer coordinates
1708
+ */
1709
+ projtriToQ2di(coords, resolution = DEFAULT_RESOLUTION) {
1710
+ const tnums = coords.map(c => c.tnum);
1711
+ const xs = coords.map(c => c.x);
1712
+ const ys = coords.map(c => c.y);
1713
+ const result = this._module.PROJTRI_to_Q2DI(...this._getParams(resolution), tnums, xs, ys);
1714
+ const size = result.length / 3;
1715
+ const output = [];
1716
+ for (let i = 0; i < size; i++) {
1717
+ output.push({
1718
+ quad: result[i],
1719
+ i: BigInt(result[i + size]),
1720
+ j: BigInt(result[i + 2 * size])
1721
+ });
1722
+ }
1723
+ return output;
1724
+ }
547
1725
  }
1726
+ // =========================================================================
1727
+ // Index digit manipulation
1728
+ // Pure bitwise operations on Z7, Z3, and ZORDER packed indices.
1729
+ // These match DGGRID's internal macros (Z7_GET_INDEX_DIGIT, etc.)
1730
+ // and do NOT require WASM calls.
1731
+ // =========================================================================
1732
+ // --- Z7 constants (3 bits per digit, max 20 resolutions) ---
1733
+ /** @internal */ Webdggrid.Z7_MAX_RES = 20;
1734
+ /** @internal */ Webdggrid.Z7_BITS_PER_DIGIT = 3n;
1735
+ /** @internal */ Webdggrid.Z7_DIGIT_MASK = 7n;
1736
+ /** @internal */ Webdggrid.Z7_QUAD_OFFSET = 60n;
1737
+ /** @internal */ Webdggrid.Z7_QUAD_MASK = 0xf000000000000000n;
1738
+ // --- Z3 constants (2 bits per digit, max 30 resolutions) ---
1739
+ /** @internal */ Webdggrid.Z3_MAX_RES = 30;
1740
+ /** @internal */ Webdggrid.Z3_BITS_PER_DIGIT = 2n;
1741
+ /** @internal */ Webdggrid.Z3_DIGIT_MASK = 3n;
1742
+ /** @internal */ Webdggrid.Z3_QUAD_OFFSET = 60n;
1743
+ /** @internal */ Webdggrid.Z3_QUAD_MASK = 0xf000000000000000n;
1744
+ // --- ZORDER constants (2 bits per digit, max 30 resolutions) ---
1745
+ /** @internal */ Webdggrid.ZORDER_MAX_RES = 30;
1746
+ /** @internal */ Webdggrid.ZORDER_BITS_PER_DIGIT = 2n;
1747
+ /** @internal */ Webdggrid.ZORDER_DIGIT_MASK = 3n;
1748
+ /** @internal */ Webdggrid.ZORDER_QUAD_OFFSET = 60n;
1749
+ /** @internal */ Webdggrid.ZORDER_QUAD_MASK = 0xf000000000000000n;
548
1750
  //# sourceMappingURL=webdggrid.js.map