nodes2ts 4.0.0 → 4.0.2
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.
- package/dist/export.cjs +85 -13
- package/dist/export.cjs.map +1 -1
- package/dist/export.d.cts +63 -14
- package/dist/export.d.ts +63 -14
- package/dist/export.js +85 -13
- package/dist/export.js.map +1 -1
- package/package.json +1 -1
package/dist/export.cjs
CHANGED
|
@@ -3350,6 +3350,13 @@ var UINT64_MAX = 0xFFFFFFFFFFFFFFFFn;
|
|
|
3350
3350
|
|
|
3351
3351
|
// src/S2Projections.ts
|
|
3352
3352
|
var _S2Projections = class _S2Projections {
|
|
3353
|
+
/**
|
|
3354
|
+
* The maximum value of an si- or ti-coordinate. The range of valid (si,ti) values is
|
|
3355
|
+
* [0..MAX_SiTi].
|
|
3356
|
+
*/
|
|
3357
|
+
static get MAX_SITI() {
|
|
3358
|
+
return 1n << BigInt(_S2Projections.MAX_LEVEL + 1);
|
|
3359
|
+
}
|
|
3353
3360
|
static getUNorm(face, u) {
|
|
3354
3361
|
switch (face) {
|
|
3355
3362
|
case 0:
|
|
@@ -3590,24 +3597,38 @@ _S2Projections.XYZ_TRANSFORMS = [
|
|
|
3590
3597
|
}
|
|
3591
3598
|
}
|
|
3592
3599
|
];
|
|
3593
|
-
/**
|
|
3594
|
-
* The maximum value of an si- or ti-coordinate. The range of valid (si,ti) values is
|
|
3595
|
-
* [0..MAX_SiTi].
|
|
3596
|
-
*/
|
|
3597
|
-
_S2Projections.MAX_SITI = 1n << BigInt(_S2Projections.MAX_LEVEL + 1);
|
|
3598
3600
|
var S2Projections = _S2Projections;
|
|
3599
3601
|
|
|
3600
3602
|
// src/S2CellId.ts
|
|
3601
3603
|
var _S2CellId = class _S2CellId {
|
|
3602
3604
|
/**
|
|
3603
|
-
* Construct an S2CellId from a bigint
|
|
3605
|
+
* Construct an S2CellId from a bigint, decimal string, or number.
|
|
3604
3606
|
*
|
|
3605
3607
|
* The string may be signed ("-6533045114107854848") or unsigned
|
|
3606
3608
|
* ("11913698959601696768"); both are handled via BigInt.asUintN(64, ...).
|
|
3609
|
+
*
|
|
3610
|
+
* Numbers must be finite integers within the safe-integer range
|
|
3611
|
+
* (|n| ≤ Number.MAX_SAFE_INTEGER = 2^53 − 1). Values outside that range
|
|
3612
|
+
* may have silently lost precision in JS before reaching this constructor,
|
|
3613
|
+
* so a RangeError is thrown. Use a bigint literal for large cell IDs
|
|
3614
|
+
* (e.g. `-9182983676231680000n`).
|
|
3615
|
+
*
|
|
3616
|
+
* @throws {TypeError} if `id` is a non-integer or non-finite number.
|
|
3617
|
+
* @throws {RangeError} if `id` exceeds safe-integer precision (> 2^53 − 1).
|
|
3607
3618
|
*/
|
|
3608
3619
|
constructor(id) {
|
|
3609
3620
|
if (typeof id === "string") {
|
|
3610
3621
|
this.id = BigInt.asUintN(64, BigInt(id));
|
|
3622
|
+
} else if (typeof id === "number") {
|
|
3623
|
+
if (!Number.isInteger(id) || !isFinite(id)) {
|
|
3624
|
+
throw new TypeError(`S2CellId: non-integer or non-finite number: ${id}`);
|
|
3625
|
+
}
|
|
3626
|
+
if (!Number.isSafeInteger(id)) {
|
|
3627
|
+
throw new RangeError(
|
|
3628
|
+
`S2CellId: number ${id} exceeds safe integer precision (> 2^53). Use a bigint literal instead, e.g. ${BigInt(id)}n`
|
|
3629
|
+
);
|
|
3630
|
+
}
|
|
3631
|
+
this.id = BigInt.asUintN(64, BigInt(id));
|
|
3611
3632
|
} else {
|
|
3612
3633
|
this.id = BigInt.asUintN(64, id);
|
|
3613
3634
|
}
|
|
@@ -4191,7 +4212,7 @@ var _S2CellId = class _S2CellId {
|
|
|
4191
4212
|
* Binary search in a sorted S2CellId array.
|
|
4192
4213
|
* Returns index if found, or -(insertionPoint+1) if not found.
|
|
4193
4214
|
*
|
|
4194
|
-
* v4: `_id` accepts bigint, string, or S2CellId (was Long, string, or S2CellId).
|
|
4215
|
+
* v4: `_id` accepts bigint, string, number, or S2CellId (was Long, string, or S2CellId).
|
|
4195
4216
|
*/
|
|
4196
4217
|
static binarySearch(ids, _id, low = 0) {
|
|
4197
4218
|
let id;
|
|
@@ -4223,10 +4244,20 @@ _S2CellId.FACE_BITS = 3;
|
|
|
4223
4244
|
_S2CellId.NUM_FACES = 6;
|
|
4224
4245
|
_S2CellId.MAX_LEVEL = 30;
|
|
4225
4246
|
// Valid levels: 0..MAX_LEVEL
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4247
|
+
/**
|
|
4248
|
+
* The number of bits used by a position along the Hilbert curve over all
|
|
4249
|
+
* faces (range 1..2*MAX_LEVEL+1). This is a fixed constant encoding the
|
|
4250
|
+
* canonical 64-bit S2 cell ID layout; it must NEVER be derived from a
|
|
4251
|
+
* mutable MAX_LEVEL.
|
|
4252
|
+
*/
|
|
4253
|
+
_S2CellId.POS_BITS = 2 * 30 + 1;
|
|
4254
|
+
// = 61
|
|
4255
|
+
/**
|
|
4256
|
+
* The maximum coordinate value for an (i,j) cell index. Equal to 2^30.
|
|
4257
|
+
* Fixed constant matching the 30-level S2 grid.
|
|
4258
|
+
*/
|
|
4259
|
+
_S2CellId.MAX_SIZE = 1 << 30;
|
|
4260
|
+
// = 1073741824
|
|
4230
4261
|
/** Maximum unsigned 64-bit value (sentinel). */
|
|
4231
4262
|
_S2CellId.MAX_UNSIGNED = UINT64_MAX;
|
|
4232
4263
|
// The following lookup tables are used to convert efficiently between an
|
|
@@ -4250,6 +4281,10 @@ _S2CellId.LOOKUP_IJ = [];
|
|
|
4250
4281
|
* This is the offset required to wrap around from the beginning of the
|
|
4251
4282
|
* Hilbert curve to the end or vice versa; see next_wrap() and prev_wrap().
|
|
4252
4283
|
*/
|
|
4284
|
+
/**
|
|
4285
|
+
* Precomputed wrap offset. Fixed constant; must not be derived from a
|
|
4286
|
+
* mutable POS_BITS.
|
|
4287
|
+
*/
|
|
4253
4288
|
_S2CellId.WRAP_OFFSET = BigInt(_S2CellId.NUM_FACES) << BigInt(_S2CellId.POS_BITS);
|
|
4254
4289
|
var S2CellId = _S2CellId;
|
|
4255
4290
|
function initLookupCell(level, i, j, origOrientation, pos, orientation) {
|
|
@@ -4314,6 +4349,9 @@ var _S2Cell = class _S2Cell {
|
|
|
4314
4349
|
this.init(cellID);
|
|
4315
4350
|
}
|
|
4316
4351
|
}
|
|
4352
|
+
static get MAX_CELL_SIZE() {
|
|
4353
|
+
return 1 << S2CellId.MAX_LEVEL;
|
|
4354
|
+
}
|
|
4317
4355
|
get id() {
|
|
4318
4356
|
return this.cellID;
|
|
4319
4357
|
}
|
|
@@ -4603,7 +4641,6 @@ var _S2Cell = class _S2Cell {
|
|
|
4603
4641
|
};
|
|
4604
4642
|
}
|
|
4605
4643
|
};
|
|
4606
|
-
_S2Cell.MAX_CELL_SIZE = 1 << S2CellId.MAX_LEVEL;
|
|
4607
4644
|
// We grow the bounds slightly to make sure that the bounding rectangle
|
|
4608
4645
|
// also contains the normalized versions of the vertices. Note that the
|
|
4609
4646
|
// maximum result magnitude is Pi, with a floating-point exponent of 1.
|
|
@@ -4628,7 +4665,7 @@ var S2CellUnion = class {
|
|
|
4628
4665
|
* Populates a cell union with the given S2CellIds or 64-bit cell ids, and
|
|
4629
4666
|
* then calls Normalize().
|
|
4630
4667
|
*
|
|
4631
|
-
* v4: `cellIds` accepts `bigint[] | string[]` (was `Long[] | string[]`).
|
|
4668
|
+
* v4: `cellIds` accepts `bigint[] | string[] | number[]` (was `Long[] | string[]`).
|
|
4632
4669
|
*/
|
|
4633
4670
|
initFromIds(cellIds) {
|
|
4634
4671
|
this.initRawIds(cellIds);
|
|
@@ -5283,6 +5320,41 @@ var QueueEntry = class {
|
|
|
5283
5320
|
|
|
5284
5321
|
// src/export.ts
|
|
5285
5322
|
var Utils = class {
|
|
5323
|
+
/**
|
|
5324
|
+
* Atomically updates the maximum cell level across all S2 classes.
|
|
5325
|
+
*
|
|
5326
|
+
* This sets the `MAX_LEVEL` field on `S2`, `S2CellId`, and `S2Projections`
|
|
5327
|
+
* in one call, keeping them in sync.
|
|
5328
|
+
*
|
|
5329
|
+
* **What changes:**
|
|
5330
|
+
* - `S2Cell.MAX_CELL_SIZE` (derived via getter from `S2CellId.MAX_LEVEL`)
|
|
5331
|
+
* - `S2Projections.MAX_SITI` (derived via getter)
|
|
5332
|
+
* - `S2CellId.getSizeIJ()` / `S2CellId.getSizeST()` size calculations
|
|
5333
|
+
* - Default max-level caps in `S2RegionCoverer` and `S2Metric`
|
|
5334
|
+
* - `S2CellId.isLeaf()` / `level()` detection of the leaf level
|
|
5335
|
+
*
|
|
5336
|
+
* **What does NOT change:**
|
|
5337
|
+
* - `S2CellId.POS_BITS` (always 61) — the 64-bit S2 cell ID bit layout is
|
|
5338
|
+
* a fixed canonical format; changing it breaks encoding/decoding.
|
|
5339
|
+
* - `S2CellId.MAX_SIZE` (always 2^30) — the Hilbert-curve grid resolution.
|
|
5340
|
+
* - `S2CellId.WRAP_OFFSET` — derived from the fixed `POS_BITS`.
|
|
5341
|
+
*
|
|
5342
|
+
* For shorter cell tokens, use `parentL(desiredLevel)` or set
|
|
5343
|
+
* `S2RegionCoverer.maxLevel`; `toToken()` naturally produces compact hex
|
|
5344
|
+
* strings for lower-level cells (e.g. level 10 → 6 hex chars).
|
|
5345
|
+
*
|
|
5346
|
+
* @param level — integer in [1, 30]
|
|
5347
|
+
*/
|
|
5348
|
+
static setMaxLevel(level) {
|
|
5349
|
+
if (!Number.isInteger(level) || level < 1 || level > 30) {
|
|
5350
|
+
throw new RangeError(
|
|
5351
|
+
`MAX_LEVEL must be an integer in [1, 30], got ${level}`
|
|
5352
|
+
);
|
|
5353
|
+
}
|
|
5354
|
+
S2.MAX_LEVEL = level;
|
|
5355
|
+
S2CellId.MAX_LEVEL = level;
|
|
5356
|
+
S2Projections.MAX_LEVEL = level;
|
|
5357
|
+
}
|
|
5286
5358
|
/**
|
|
5287
5359
|
* Calculates a region covering a circle
|
|
5288
5360
|
* NOTE: The current implementation uses S2Cap while S2Loop would be better (S2Loop is not implemented yet)
|