webdggrid 1.0.5 → 1.0.7

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.
@@ -1,52 +1,159 @@
1
1
  // @ts-ignore
2
2
  import { loadWasm, unloadWasm } from './libdggrid.wasm.js';
3
3
  /**
4
- * Cell Topology
4
+ * The shape of each cell in the Discrete Global Grid System.
5
+ *
6
+ * DGGRID supports four cell topologies. The most common choice for geospatial
7
+ * analysis is `HEXAGON` because hexagonal cells have equal adjacency (every
8
+ * neighbour shares an edge), uniform area, and minimal boundary-to-area ratio.
5
9
  *
6
10
  * @export
7
- * @enum {String}
11
+ * @enum {string}
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import { Topology } from 'webdggrid';
16
+ *
17
+ * dggs.setDggs({ topology: Topology.HEXAGON, ... }, 4);
18
+ * ```
8
19
  */
9
20
  export var Topology;
10
21
  (function (Topology) {
22
+ /** Six-sided cells — the default and most widely used topology. */
11
23
  Topology["HEXAGON"] = "HEXAGON";
24
+ /** Three-sided cells. */
12
25
  Topology["TRIANGLE"] = "TRIANGLE";
26
+ /** Four-sided square cells. */
13
27
  Topology["SQUARE"] = "SQUARE";
28
+ /** Four-sided diamond cells (squares rotated 45°). */
14
29
  Topology["DIAMOND"] = "DIAMOND";
15
30
  })(Topology || (Topology = {}));
16
31
  /**
17
- * Projection type
32
+ * The map projection used to place the polyhedron faces onto the sphere.
33
+ *
34
+ * - **ISEA** (Icosahedral Snyder Equal Area) — preserves cell area at the cost
35
+ * of shape distortion. Recommended for most analytical use-cases.
36
+ * - **FULLER** (Fuller/Dymaxion) — minimises shape distortion but does not
37
+ * preserve equal area.
18
38
  *
19
39
  * @export
20
- * @enum {number}
40
+ * @enum {string}
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * import { Projection } from 'webdggrid';
45
+ *
46
+ * dggs.setDggs({ projection: Projection.ISEA, ... }, 4);
47
+ * ```
21
48
  */
22
49
  export var Projection;
23
50
  (function (Projection) {
51
+ /** Icosahedral Snyder Equal Area projection — equal-area cells. */
24
52
  Projection["ISEA"] = "ISEA";
53
+ /** Fuller/Dymaxion projection — shape-preserving cells. */
25
54
  Projection["FULLER"] = "FULLER";
26
55
  })(Projection || (Projection = {}));
56
+ /**
57
+ * Rewraps a polygon ring that crosses the antimeridian so that all longitudes
58
+ * are in a contiguous range (some may exceed 180°). This is the format
59
+ * expected by MapLibre GL / Mapbox GL globe projection for antimeridian cells.
60
+ * For renderers that require standard [-180, 180] coordinates, use the raw
61
+ * output from {@link Webdggrid.sequenceNumToGrid} directly.
62
+ */
63
+ export function unwrapAntimeridianRing(ring) {
64
+ const lons = ring.map((p) => p[0]);
65
+ const minLon = Math.min(...lons);
66
+ const maxLon = Math.max(...lons);
67
+ if (maxLon - minLon <= 180)
68
+ return ring;
69
+ return ring.map(([lon, lat]) => [lon < 0 ? lon + 360 : lon, lat]);
70
+ }
27
71
  const DEFAULT_RESOLUTION = 1;
28
72
  const DEFAULT_DGGS = {
29
73
  poleCoordinates: { lat: 0, lng: 0 },
30
74
  azimuth: 0,
31
75
  topology: Topology.HEXAGON,
32
76
  projection: Projection.ISEA,
33
- aperture: 7
77
+ aperture: 4
34
78
  };
79
+ /**
80
+ * Main entry point for the WebDggrid library.
81
+ *
82
+ * `Webdggrid` wraps the DGGRID C++ library compiled to WebAssembly and exposes
83
+ * methods for:
84
+ * - **Grid configuration** — choose topology, projection, aperture, and
85
+ * resolution via {@link setDggs} / {@link setResolution}.
86
+ * - **Coordinate conversion** — convert between geographic coordinates and
87
+ * DGGS cell IDs (sequence numbers) with {@link geoToSequenceNum} and
88
+ * {@link sequenceNumToGeo}.
89
+ * - **Grid geometry** — retrieve the polygon boundary of any cell with
90
+ * {@link sequenceNumToGrid} or export a ready-to-render GeoJSON
91
+ * `FeatureCollection` with {@link sequenceNumToGridFeatureCollection}.
92
+ * - **Grid statistics** — query cell counts, areas, and spacings with
93
+ * {@link nCells}, {@link cellAreaKM}, and {@link cellDistKM}.
94
+ *
95
+ * ## Quick start
96
+ *
97
+ * ```ts
98
+ * import { Webdggrid } from 'webdggrid';
99
+ *
100
+ * const dggs = await Webdggrid.load();
101
+ *
102
+ * // Convert a geographic point to its DGGS cell ID at resolution 5
103
+ * const [cellId] = dggs.geoToSequenceNum([[-73.9857, 40.7484]], 5);
104
+ *
105
+ * // Get the polygon boundary of that cell as GeoJSON
106
+ * const geojson = dggs.sequenceNumToGridFeatureCollection([cellId], 5);
107
+ * ```
108
+ *
109
+ * ## Lifecycle
110
+ *
111
+ * The WASM module is a singleton. Call {@link Webdggrid.load} once and reuse
112
+ * the returned instance throughout your application. Call
113
+ * {@link Webdggrid.unload} when you are completely done to free memory.
114
+ */
35
115
  export class Webdggrid {
36
116
  constructor(_module) {
37
117
  this._module = _module;
118
+ /**
119
+ * The active DGGS configuration used by all conversion and statistics
120
+ * methods. Change it at any time via {@link setDggs}.
121
+ *
122
+ * Defaults to ISEA4H (ISEA projection, aperture 4, hexagon topology,
123
+ * pole at 0° N 0° E, azimuth 0°).
124
+ */
38
125
  this.dggs = DEFAULT_DGGS;
126
+ /**
127
+ * The active grid resolution. Higher values produce finer, smaller cells.
128
+ * The valid range depends on the aperture — for aperture 4 the practical
129
+ * limit is around resolution 15 before cell counts become unwieldy.
130
+ *
131
+ * Change via {@link setResolution} or pass an explicit `resolution`
132
+ * argument to any conversion method.
133
+ *
134
+ * Defaults to `1`.
135
+ */
39
136
  this.resolution = DEFAULT_RESOLUTION;
40
137
  this._module = _module;
41
138
  }
42
139
  /**
43
- * Compiles and instantiates the raw wasm.
140
+ * Compiles and instantiates the DGGRID WebAssembly module.
141
+ *
142
+ * This is the only way to construct a `Webdggrid` instance. The method is
143
+ * asynchronous because WebAssembly compilation is prohibited on the main
144
+ * thread for buffers larger than 4 KB.
145
+ *
146
+ * ```ts
147
+ * const dggs = await Webdggrid.load();
148
+ * ```
44
149
  *
45
150
  * ::: info
46
- * In general WebAssembly compilation is disallowed on the main thread if the buffer size is larger than 4KB, hence forcing `load` to be asynchronous;
151
+ * In general WebAssembly compilation is disallowed on the main thread if
152
+ * the buffer size is larger than 4 KB, hence forcing `load` to be
153
+ * asynchronous.
47
154
  * :::
48
155
  *
49
- * @returns A promise to an instance of the Webdggrid class.
156
+ * @returns A promise that resolves to a fully initialised `Webdggrid` instance.
50
157
  */
51
158
  static load() {
52
159
  return loadWasm().then((module) => {
@@ -54,99 +161,232 @@ export class Webdggrid {
54
161
  }).catch(console.log);
55
162
  }
56
163
  /**
57
- * Unloades the compiled wasm instance.
164
+ * Releases the compiled WASM instance and frees its memory.
165
+ *
166
+ * Call this when your application no longer needs the library. After
167
+ * calling `unload`, any existing `Webdggrid` instances become unusable —
168
+ * you must call {@link load} again to create a new one.
58
169
  */
59
170
  static unload() {
60
171
  unloadWasm();
61
172
  }
62
173
  /**
63
- * @returns The Webdggrid c++ version
174
+ * Returns the version string of the underlying DGGRID C++ library.
175
+ *
176
+ * ```ts
177
+ * console.log(dggs.version()); // e.g. "8.3b"
178
+ * ```
179
+ *
180
+ * @returns The DGGRID C++ library version string.
64
181
  */
65
182
  version() {
66
183
  return this._module.Webdggrid.prototype.version();
67
184
  }
68
185
  /**
69
- * Set the main dggs configuration
70
- * @param dggs A dggs object
186
+ * Sets both the DGGS configuration and the resolution in one call.
187
+ *
188
+ * All subsequent conversion and statistics methods will use this
189
+ * configuration unless they receive an explicit `resolution` argument.
190
+ *
191
+ * ```ts
192
+ * dggs.setDggs({
193
+ * poleCoordinates: { lat: 0, lng: 0 },
194
+ * azimuth: 0,
195
+ * aperture: 4,
196
+ * topology: Topology.HEXAGON,
197
+ * projection: Projection.ISEA,
198
+ * }, 5);
199
+ * ```
200
+ *
201
+ * @param dggs - The new DGGS configuration. Defaults to ISEA4H at pole (0,0).
202
+ * @param resolution - The new resolution level. Defaults to `1`.
71
203
  */
72
204
  setDggs(dggs = DEFAULT_DGGS, resolution = DEFAULT_RESOLUTION) {
73
205
  this.dggs = dggs;
74
206
  this.resolution = resolution;
75
207
  }
76
208
  /**
77
- * Get the resolution of the current dggs
78
- * @returns {number} the current dggs resolution
79
- * @memberof WebDggrid
209
+ * Returns the currently active grid resolution.
210
+ *
211
+ * ```ts
212
+ * dggs.setResolution(7);
213
+ * console.log(dggs.getResolution()); // 7
214
+ * ```
215
+ *
216
+ * @returns The current resolution level.
80
217
  */
81
218
  getResolution() {
82
219
  return this.resolution;
83
220
  }
84
221
  /**
85
- * Set the resolution of the dggs
86
- * @param {number} [resolution=DEFAULT_RESOLUTION] the resolution. It should be a valid integer
87
- * @memberof WebDggrid
222
+ * Sets the grid resolution used by default in all conversion and
223
+ * statistics methods.
224
+ *
225
+ * ```ts
226
+ * dggs.setResolution(5);
227
+ * const count = dggs.nCells(); // uses resolution 5
228
+ * ```
229
+ *
230
+ * @param resolution - The new resolution level. Must be a positive integer.
88
231
  */
89
232
  setResolution(resolution) {
90
233
  this.resolution = resolution;
91
234
  }
92
235
  /**
93
- * test function
94
- *
95
- * @return {*}
96
- * @memberof WebDggrid
236
+ * Internal test helper that invokes the WASM module's `_main` entry point.
237
+ * Not intended for production use.
238
+ * @internal
97
239
  */
98
240
  _main() {
99
241
  return this._module._main();
100
242
  }
101
243
  /**
102
- * @follow Hi
103
- * Returns the number of the cells in specific resolution
104
- * @param {number} [resolution=DEFAULT_RESOLUTION]
105
- * @return {number}
106
- * @memberof WebDggrid
244
+ * Returns the total number of cells that tile the entire globe at the
245
+ * given resolution under the current DGGS configuration.
246
+ *
247
+ * Cell counts grow exponentially with resolution. For the default ISEA4H
248
+ * grid:
249
+ *
250
+ * | Resolution | Approx. cell count |
251
+ * |---|---|
252
+ * | 1 | 42 |
253
+ * | 2 | 162 |
254
+ * | 3 | 642 |
255
+ * | 4 | 2 562 |
256
+ * | 5 | 10 242 |
257
+ * | 6 | 40 962 |
258
+ *
259
+ * ```ts
260
+ * const total = dggs.nCells(3); // 642
261
+ * ```
262
+ *
263
+ * @param resolution - Resolution level to query. Defaults to the instance's
264
+ * current {@link resolution}.
265
+ * @returns Total number of cells at the given resolution.
107
266
  */
108
267
  nCells(resolution = DEFAULT_RESOLUTION) {
109
268
  const { poleCoordinates: { lat, lng }, azimuth, topology, projection, aperture, } = this.dggs;
110
- const cellCount = this._module.nCells(lat, lng, azimuth, aperture, resolution, topology, projection);
269
+ const cellCount = this._module.nCells(lng, lat, azimuth, aperture, resolution, topology, projection);
111
270
  return cellCount;
112
271
  }
272
+ /**
273
+ * Returns the average area of a single cell in square kilometres at the
274
+ * given resolution.
275
+ *
276
+ * Because ISEA guarantees equal-area cells, all cells have the same area
277
+ * when using the `ISEA` projection. With `FULLER` the value is an average.
278
+ *
279
+ * ```ts
280
+ * const areakm2 = dggs.cellAreaKM(5);
281
+ * ```
282
+ *
283
+ * @param resolution - Resolution level to query. Defaults to the instance's
284
+ * current {@link resolution}.
285
+ * @returns Average cell area in km².
286
+ */
113
287
  cellAreaKM(resolution = DEFAULT_RESOLUTION) {
114
288
  const { poleCoordinates: { lat, lng }, azimuth, topology, projection, aperture, } = this.dggs;
115
- const cellCount = this._module.nCells(lat, lng, azimuth, aperture, resolution, topology, projection);
289
+ const cellCount = this._module.cellAreaKM(lng, lat, azimuth, aperture, resolution, topology, projection);
116
290
  return cellCount;
117
291
  }
292
+ /**
293
+ * Returns the average centre-to-centre distance between neighbouring cells
294
+ * in kilometres at the given resolution.
295
+ *
296
+ * This is useful for estimating spatial join radii or selecting a
297
+ * resolution that matches a target spatial scale.
298
+ *
299
+ * ```ts
300
+ * const spacingKm = dggs.cellDistKM(5);
301
+ * ```
302
+ *
303
+ * @param resolution - Resolution level to query. Defaults to the instance's
304
+ * current {@link resolution}.
305
+ * @returns Average cell spacing in km.
306
+ */
118
307
  cellDistKM(resolution = DEFAULT_RESOLUTION) {
119
308
  const { poleCoordinates: { lat, lng }, azimuth, topology, projection, aperture, } = this.dggs;
120
- const cellCount = this._module.nCells(lat, lng, azimuth, aperture, resolution, topology, projection);
309
+ const cellCount = this._module.cellDistKM(lng, lat, azimuth, aperture, resolution, topology, projection);
121
310
  return cellCount;
122
311
  }
312
+ /**
313
+ * Returns the characteristic length scale (CLS) of the grid at the given
314
+ * resolution — defined as the square root of the average cell area.
315
+ *
316
+ * CLS provides a single scalar that summarises the spatial granularity of
317
+ * the grid, useful for comparing resolutions across different DGGS
318
+ * configurations.
319
+ *
320
+ * ```ts
321
+ * const cls = dggs.gridStatCLS(4);
322
+ * ```
323
+ *
324
+ * @param resolution - Resolution level to query. Defaults to the instance's
325
+ * current {@link resolution}.
326
+ * @returns Grid CLS value.
327
+ */
123
328
  gridStatCLS(resolution = DEFAULT_RESOLUTION) {
124
329
  const { poleCoordinates: { lat, lng }, azimuth, topology, projection, aperture, } = this.dggs;
125
- const cellCount = this._module.nCells(lat, lng, azimuth, aperture, resolution, topology, projection);
330
+ const cellCount = this._module.gridStatCLS(lng, lat, azimuth, aperture, resolution, topology, projection);
126
331
  return cellCount;
127
332
  }
128
333
  /**
129
- * Converts an array of geography coordinates to the list of the sequence numbers AKA DggId
130
- * @param coordinates A 2d array of [[lng, lat]] values
131
- * @param resolution [resolution=DEFAULT_RESOLUTION] The dggs resolution
132
- * @returns An array of the DggIds
334
+ * Converts an array of geographic coordinates to their corresponding DGGS
335
+ * cell sequence numbers (cell IDs) at the given resolution.
336
+ *
337
+ * Each coordinate is mapped to the single cell whose boundary contains it.
338
+ * Multiple coordinates that fall within the same cell will return the same
339
+ * sequence number.
340
+ *
341
+ * Coordinates must be supplied in **`[lng, lat]`** order (GeoJSON
342
+ * convention), **not** `[lat, lng]`.
343
+ *
344
+ * ```ts
345
+ * // New York City
346
+ * const ids = dggs.geoToSequenceNum([[-74.006, 40.7128]], 5);
347
+ * console.log(ids); // [12345n]
348
+ *
349
+ * // Multiple points at once
350
+ * const ids2 = dggs.geoToSequenceNum(
351
+ * [[-74.006, 40.7128], [2.3522, 48.8566]],
352
+ * 5
353
+ * );
354
+ * ```
355
+ *
356
+ * @param coordinates - Array of `[lng, lat]` pairs in decimal degrees.
357
+ * @param resolution - Resolution at which to perform the lookup. Defaults
358
+ * to the instance's current {@link resolution}.
359
+ * @returns Array of `BigInt` sequence numbers, one per input coordinate,
360
+ * in the same order.
133
361
  */
134
362
  geoToSequenceNum(coordinates, resolution = DEFAULT_RESOLUTION) {
135
363
  const { poleCoordinates: { lat, lng }, azimuth, topology, projection, aperture, } = this.dggs;
136
364
  const xCoords = coordinates.map((coord) => coord[0]);
137
365
  const yCoords = coordinates.map((coord) => coord[1]);
138
- const resultArray = this._module.DgGEO_to_SEQNUM(lat, lng, azimuth, aperture, resolution, topology, projection, xCoords, yCoords);
366
+ const resultArray = this._module.DgGEO_to_SEQNUM(lng, lat, azimuth, aperture, resolution, topology, projection, xCoords, yCoords);
139
367
  return resultArray;
140
368
  }
141
369
  /**
142
- * Convert a sequence number to the [lng,lat] of the center of the related cell
143
- * @param sequenceNum
144
- * @param resolution [resolution=DEFAULT_RESOLUTION]
145
- * @returns An array of [lng,lat]
370
+ * Converts an array of DGGS cell sequence numbers to the geographic
371
+ * coordinates of their centroids.
372
+ *
373
+ * The returned coordinates are in **`[lng, lat]`** order (GeoJSON
374
+ * convention).
375
+ *
376
+ * ```ts
377
+ * const centroids = dggs.sequenceNumToGeo([1n, 2n, 3n], 3);
378
+ * // [[lng0, lat0], [lng1, lat1], [lng2, lat2]]
379
+ * ```
380
+ *
381
+ * @param sequenceNum - Array of `BigInt` cell IDs to look up.
382
+ * @param resolution - Resolution at which the IDs were generated. Defaults
383
+ * to the instance's current {@link resolution}.
384
+ * @returns Array of `[lng, lat]` centroid positions, one per input ID, in
385
+ * the same order.
146
386
  */
147
387
  sequenceNumToGeo(sequenceNum, resolution = DEFAULT_RESOLUTION) {
148
388
  const { poleCoordinates: { lat, lng }, azimuth, topology, projection, aperture, } = this.dggs;
149
- const resultArray = this._module.SEQNUM_to_GEO(lat, lng, azimuth, aperture, resolution, topology, projection, sequenceNum);
389
+ const resultArray = this._module.SEQNUM_to_GEO(lng, lat, azimuth, aperture, resolution, topology, projection, sequenceNum);
150
390
  const size = resultArray.length / 2;
151
391
  const arrayOfArrays = [];
152
392
  for (let i = 0; i < size; i += 1) {
@@ -155,16 +395,37 @@ export class Webdggrid {
155
395
  return arrayOfArrays;
156
396
  }
157
397
  /**
158
- * Converts a set of coordinates to the cell centroid values
159
- * @param coordinates A 2d array of lng and lat values
160
- * @param resolution [resolution=DEFAULT_RESOLUTION] The resolution of the dggs
161
- * @returns An array of dggs cell centroid coordinates
398
+ * Snaps an array of geographic coordinates to the centroid of the DGGS
399
+ * cell that contains each point.
400
+ *
401
+ * This is equivalent to calling {@link geoToSequenceNum} followed by
402
+ * {@link sequenceNumToGeo} but is more efficient because it avoids
403
+ * returning the intermediate sequence numbers.
404
+ *
405
+ * Useful for spatial aggregation: all points that fall within the same
406
+ * cell will map to the identical centroid coordinate.
407
+ *
408
+ * Coordinates must be in **`[lng, lat]`** order.
409
+ *
410
+ * ```ts
411
+ * const snapped = dggs.geoToGeo(
412
+ * [[-74.006, 40.7128], [-74.010, 40.720]],
413
+ * 5
414
+ * );
415
+ * // Both points snap to the same centroid if they share a cell
416
+ * ```
417
+ *
418
+ * @param coordinates - Array of `[lng, lat]` pairs in decimal degrees.
419
+ * @param resolution - Resolution at which to perform the snapping. Defaults
420
+ * to the instance's current {@link resolution}.
421
+ * @returns Array of `[lng, lat]` cell centroid positions, one per input
422
+ * coordinate, in the same order.
162
423
  */
163
424
  geoToGeo(coordinates, resolution = DEFAULT_RESOLUTION) {
164
425
  const { poleCoordinates: { lat, lng }, azimuth, topology, projection, aperture, } = this.dggs;
165
426
  const xCoords = coordinates.map((coord) => coord[0]);
166
427
  const yCoords = coordinates.map((coord) => coord[1]);
167
- const resultArray = this._module.GEO_to_GEO(lat, lng, azimuth, aperture, resolution, topology, projection, xCoords, yCoords);
428
+ const resultArray = this._module.GEO_to_GEO(lng, lat, azimuth, aperture, resolution, topology, projection, xCoords, yCoords);
168
429
  const size = resultArray.length / 2;
169
430
  const arrayOfArrays = [];
170
431
  for (let i = 0; i < size; i += 1) {
@@ -173,22 +434,39 @@ export class Webdggrid {
173
434
  return arrayOfArrays;
174
435
  }
175
436
  /**
176
- * Convert an array of sequence numbers to the grid coordinates with format of `[lng,lat]`. The output is an array with the same
177
- * size as input `sequenceNum` and it includes an array of `CoordinateLike` objects.
178
- * @param sequenceNum
179
- * @param resolution [resolution=DEFAULT_RESOLUTION]
180
- * @returns An array of [lng,lat]
437
+ * Returns the polygon boundary vertices for each cell in `sequenceNum`.
438
+ *
439
+ * Each cell is represented as an array of `[lng, lat]` vertex positions.
440
+ * The ring is **not** automatically closed (the first and last vertex are
441
+ * different) close it yourself if your renderer requires it.
442
+ *
443
+ * Prefer {@link sequenceNumToGridFeatureCollection} when you need
444
+ * GeoJSON output ready for a mapping library.
445
+ *
446
+ * ```ts
447
+ * const rings = dggs.sequenceNumToGrid([1n, 2n], 3);
448
+ * // rings[0] = [[lng0,lat0], [lng1,lat1], ..., [lng5,lat5]] (hexagon)
449
+ * ```
450
+ *
451
+ * @param sequenceNum - Array of `BigInt` cell IDs whose boundaries to
452
+ * retrieve.
453
+ * @param resolution - Resolution at which the IDs were generated. Defaults
454
+ * to the instance's current {@link resolution}.
455
+ * @returns A 2-D array: `result[i]` is the vertex ring of `sequenceNum[i]`.
456
+ * Each vertex is a `[lng, lat]` position.
457
+ * @throws If the WASM module encounters an invalid cell ID.
181
458
  */
182
459
  sequenceNumToGrid(sequenceNum, resolution = DEFAULT_RESOLUTION) {
183
460
  const { poleCoordinates: { lat, lng }, azimuth, topology, projection, aperture, } = this.dggs;
461
+ const inputSize = sequenceNum.length;
184
462
  let resultArray = [];
185
463
  try {
186
- resultArray = this._module.SeqNumGrid(lat, lng, azimuth, aperture, resolution, topology, projection, sequenceNum);
464
+ resultArray = this._module.SeqNumGrid(lng, lat, azimuth, aperture, resolution, topology, projection, sequenceNum);
187
465
  }
188
466
  catch (e) {
189
- throw (this._module.getExceptionMessage(e).toString());
467
+ console.error(this._module.getExceptionMessage(e).toString());
468
+ throw (e);
190
469
  }
191
- const inputSize = sequenceNum.length;
192
470
  const allShapeVertexes = resultArray.slice(0, inputSize);
193
471
  const sumVertexes = allShapeVertexes.reduce((accumulator, currentValue) => {
194
472
  return accumulator + currentValue;
@@ -204,12 +482,45 @@ export class Webdggrid {
204
482
  for (let i = 0; i < numVertexes; i += 1) {
205
483
  coordinates.push([currentShapeXVertexes[i], currentShapeYVertexes[i]]);
206
484
  }
207
- featureSet.push(coordinates);
485
+ featureSet.push(unwrapAntimeridianRing(coordinates));
208
486
  xOffset += numVertexes;
209
487
  yOffset += numVertexes;
210
488
  }
211
489
  return featureSet;
212
490
  }
491
+ /**
492
+ * Converts an array of DGGS cell IDs into a GeoJSON `FeatureCollection`
493
+ * where each `Feature` is a `Polygon` representing the cell boundary.
494
+ *
495
+ * This is the primary method for rendering DGGS cells with mapping
496
+ * libraries such as MapLibre GL JS, Leaflet, or deck.gl.
497
+ *
498
+ * Each feature includes:
499
+ * - `geometry` — a closed `Polygon` in `[lng, lat]` coordinate order.
500
+ * - `id` — the cell sequence number (converted to `string` recommended
501
+ * before passing to MapLibre to avoid BigInt serialisation errors).
502
+ * - `properties.id` — same value as `id`, accessible inside layer
503
+ * expressions.
504
+ *
505
+ * ```ts
506
+ * const ids = dggs.geoToSequenceNum([[-74.006, 40.7128]], 5);
507
+ * const fc = dggs.sequenceNumToGridFeatureCollection(ids, 5);
508
+ *
509
+ * // MapLibre / structured-clone safe: convert BigInt → string
510
+ * fc.features.forEach(f => {
511
+ * if (typeof f.id === 'bigint') f.id = f.id.toString();
512
+ * if (f.properties?.id) f.properties.id = f.properties.id.toString();
513
+ * });
514
+ *
515
+ * map.getSource('grid').setData(fc);
516
+ * ```
517
+ *
518
+ * @param sequenceNum - Array of `BigInt` cell IDs to convert.
519
+ * @param resolution - Resolution at which the IDs were generated. Defaults
520
+ * to the instance's current {@link resolution}.
521
+ * @returns A GeoJSON `FeatureCollection` of `Polygon` features, one per
522
+ * input cell ID.
523
+ */
213
524
  sequenceNumToGridFeatureCollection(sequenceNum, resolution = DEFAULT_RESOLUTION) {
214
525
  const coordinatesArray = this.sequenceNumToGrid(sequenceNum, resolution);
215
526
  const features = coordinatesArray.map((coordinates, index) => {
@@ -1 +1 @@
1
- {"version":3,"file":"webdggrid.js","sourceRoot":"","sources":["../src-ts/webdggrid.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,CAAN,IAAY,QAKX;AALD,WAAY,QAAQ;IAChB,+BAAqB,CAAA;IACrB,iCAAuB,CAAA;IACvB,6BAAmB,CAAA;IACnB,+BAAqB,CAAA;AACzB,CAAC,EALW,QAAQ,KAAR,QAAQ,QAKnB;AACD;;;;;GAKG;AACH,MAAM,CAAN,IAAY,UAGX;AAHD,WAAY,UAAU;IAClB,2BAAe,CAAA;IACf,+BAAmB,CAAA;AACvB,CAAC,EAHW,UAAU,KAAV,UAAU,QAGrB;AA8BD,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAC7B,MAAM,YAAY,GAAG;IACjB,eAAe,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE;IACnC,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,QAAQ,CAAC,OAAO;IAC1B,UAAU,EAAE,UAAU,CAAC,IAAI;IAC3B,QAAQ,EAAE,CAAC;CACA,CAAC;AAEhB,MAAM,OAAO,SAAS;IAKlB,YAA8B,OAAY;QAAZ,YAAO,GAAP,OAAO,CAAK;QAH1C,SAAI,GAAe,YAAY,CAAC;QAChC,eAAU,GAAW,kBAAkB,CAAC;QAGpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAE3B,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,IAAI;QACP,OAAO,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC,MAAW,EAAE,EAAE;YACnC,OAAO,IAAI,SAAS,CA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