nodes2ts 3.0.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +102 -15
- package/dist/export.cjs +5350 -0
- package/dist/export.cjs.map +1 -0
- package/dist/export.d.cts +1847 -0
- package/dist/export.d.ts +1837 -20
- package/dist/export.js +5299 -62
- package/dist/export.js.map +1 -1
- package/package.json +34 -55
- package/.eslintignore +0 -3
- package/.eslintrc.cjs +0 -11
- package/.github/workflows/lint.js.yml +0 -22
- package/.github/workflows/node.js.yml +0 -22
- package/.mocharc.js +0 -7
- package/dist/Interval.d.ts +0 -24
- package/dist/Interval.js +0 -23
- package/dist/Interval.js.map +0 -1
- package/dist/MutableInteger.d.ts +0 -4
- package/dist/MutableInteger.js +0 -10
- package/dist/MutableInteger.js.map +0 -1
- package/dist/Platform.d.ts +0 -15
- package/dist/Platform.js +0 -53
- package/dist/Platform.js.map +0 -1
- package/dist/R1Interval.d.ts +0 -76
- package/dist/R1Interval.js +0 -158
- package/dist/R1Interval.js.map +0 -1
- package/dist/R2Vector.d.ts +0 -34
- package/dist/R2Vector.js +0 -131
- package/dist/R2Vector.js.map +0 -1
- package/dist/S1Angle.d.ts +0 -60
- package/dist/S1Angle.js +0 -133
- package/dist/S1Angle.js.map +0 -1
- package/dist/S1ChordAngle.d.ts +0 -166
- package/dist/S1ChordAngle.js +0 -318
- package/dist/S1ChordAngle.js.map +0 -1
- package/dist/S1Interval.d.ts +0 -109
- package/dist/S1Interval.js +0 -398
- package/dist/S1Interval.js.map +0 -1
- package/dist/S2.d.ts +0 -96
- package/dist/S2.js +0 -231
- package/dist/S2.js.map +0 -1
- package/dist/S2Cap.d.ts +0 -122
- package/dist/S2Cap.js +0 -399
- package/dist/S2Cap.js.map +0 -1
- package/dist/S2Cell.d.ts +0 -106
- package/dist/S2Cell.js +0 -358
- package/dist/S2Cell.js.map +0 -1
- package/dist/S2CellId.d.ts +0 -290
- package/dist/S2CellId.js +0 -983
- package/dist/S2CellId.js.map +0 -1
- package/dist/S2CellUnion.d.ts +0 -179
- package/dist/S2CellUnion.js +0 -523
- package/dist/S2CellUnion.js.map +0 -1
- package/dist/S2EdgeUtil.d.ts +0 -17
- package/dist/S2EdgeUtil.js +0 -785
- package/dist/S2EdgeUtil.js.map +0 -1
- package/dist/S2LatLng.d.ts +0 -77
- package/dist/S2LatLng.js +0 -186
- package/dist/S2LatLng.js.map +0 -1
- package/dist/S2LatLngRect.d.ts +0 -190
- package/dist/S2LatLngRect.js +0 -624
- package/dist/S2LatLngRect.js.map +0 -1
- package/dist/S2Metric.d.ts +0 -38
- package/dist/S2Metric.js +0 -79
- package/dist/S2Metric.js.map +0 -1
- package/dist/S2Point.d.ts +0 -78
- package/dist/S2Point.js +0 -250
- package/dist/S2Point.js.map +0 -1
- package/dist/S2Projections.d.ts +0 -102
- package/dist/S2Projections.js +0 -331
- package/dist/S2Projections.js.map +0 -1
- package/dist/S2Region.d.ts +0 -31
- package/dist/S2Region.js +0 -18
- package/dist/S2Region.js.map +0 -1
- package/dist/S2RegionCoverer.d.ts +0 -186
- package/dist/S2RegionCoverer.js +0 -471
- package/dist/S2RegionCoverer.js.map +0 -1
- package/dist/utils/preconditions.d.ts +0 -2
- package/dist/utils/preconditions.js +0 -16
- package/dist/utils/preconditions.js.map +0 -1
package/dist/S2Metric.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Defines an area or a length cell metric.
|
|
3
|
-
*/
|
|
4
|
-
export declare class S2Metric {
|
|
5
|
-
private _dim;
|
|
6
|
-
private _deriv;
|
|
7
|
-
/**
|
|
8
|
-
* Defines a cell metric of the given dimension (1 == length, 2 == area).
|
|
9
|
-
*/
|
|
10
|
-
constructor(_dim: number, _deriv: number);
|
|
11
|
-
deriv(): number;
|
|
12
|
-
dim(): number;
|
|
13
|
-
/** Return the value of a metric for cells at the given level. */
|
|
14
|
-
getValue(level: number): number;
|
|
15
|
-
/**
|
|
16
|
-
* Return the level at which the metric has approximately the given value.
|
|
17
|
-
* For example, S2::kAvgEdge.GetClosestLevel(0.1) returns the level at which
|
|
18
|
-
* the average cell edge length is approximately 0.1. The return value is
|
|
19
|
-
* always a valid level.
|
|
20
|
-
*/
|
|
21
|
-
getClosestLevel(/*double*/ value: number): number;
|
|
22
|
-
/**
|
|
23
|
-
* Return the minimum level such that the metric is at most the given value,
|
|
24
|
-
* or S2CellId::kMaxLevel if there is no such level. For example,
|
|
25
|
-
* S2::kMaxDiag.GetMinLevel(0.1) returns the minimum level such that all
|
|
26
|
-
* cell diagonal lengths are 0.1 or smaller. The return value is always a
|
|
27
|
-
* valid level.
|
|
28
|
-
*/
|
|
29
|
-
getMinLevel(value: number): number;
|
|
30
|
-
/**
|
|
31
|
-
* Return the maximum level such that the metric is at least the given
|
|
32
|
-
* value, or zero if there is no such level. For example,
|
|
33
|
-
* S2.kMinWidth.GetMaxLevel(0.1) returns the maximum level such that all
|
|
34
|
-
* cells have a minimum width of 0.1 or larger. The return value is always a
|
|
35
|
-
* valid level.
|
|
36
|
-
*/
|
|
37
|
-
getMaxLevel(value: number): number;
|
|
38
|
-
}
|
package/dist/S2Metric.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.S2Metric = void 0;
|
|
4
|
-
const Platform_1 = require("./Platform");
|
|
5
|
-
const S2_1 = require("./S2");
|
|
6
|
-
/**
|
|
7
|
-
* Defines an area or a length cell metric.
|
|
8
|
-
*/
|
|
9
|
-
class S2Metric {
|
|
10
|
-
/**
|
|
11
|
-
* Defines a cell metric of the given dimension (1 == length, 2 == area).
|
|
12
|
-
*/
|
|
13
|
-
constructor(_dim, _deriv) {
|
|
14
|
-
this._dim = _dim;
|
|
15
|
-
this._deriv = _deriv;
|
|
16
|
-
}
|
|
17
|
-
deriv() {
|
|
18
|
-
return this._deriv;
|
|
19
|
-
}
|
|
20
|
-
dim() {
|
|
21
|
-
return this._dim;
|
|
22
|
-
}
|
|
23
|
-
/** Return the value of a metric for cells at the given level. */
|
|
24
|
-
getValue(level) {
|
|
25
|
-
return this.deriv() * Math.pow(2, -this.dim() * level);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Return the level at which the metric has approximately the given value.
|
|
29
|
-
* For example, S2::kAvgEdge.GetClosestLevel(0.1) returns the level at which
|
|
30
|
-
* the average cell edge length is approximately 0.1. The return value is
|
|
31
|
-
* always a valid level.
|
|
32
|
-
*/
|
|
33
|
-
getClosestLevel(/*double*/ value) {
|
|
34
|
-
return this.getMinLevel((this.dim() == 1 ? S2_1.S2.M_SQRT2 : 2) * value);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Return the minimum level such that the metric is at most the given value,
|
|
38
|
-
* or S2CellId::kMaxLevel if there is no such level. For example,
|
|
39
|
-
* S2::kMaxDiag.GetMinLevel(0.1) returns the minimum level such that all
|
|
40
|
-
* cell diagonal lengths are 0.1 or smaller. The return value is always a
|
|
41
|
-
* valid level.
|
|
42
|
-
*/
|
|
43
|
-
getMinLevel(value /*double*/) {
|
|
44
|
-
if (value <= 0) {
|
|
45
|
-
return S2_1.S2.MAX_LEVEL;
|
|
46
|
-
}
|
|
47
|
-
// This code is equivalent to computing a floating-point "level"
|
|
48
|
-
// value and rounding up.
|
|
49
|
-
// let exponent = Platform.getExponent(value / ((1 << this.dim()) * this.deriv()));
|
|
50
|
-
const exponent = Platform_1.Platform.getExponent(this.deriv() / value);
|
|
51
|
-
// let level = Math.max(0,
|
|
52
|
-
// Math.min(S2.MAX_LEVEL, -((exponent - 1) >> (this.dim() - 1))));
|
|
53
|
-
const level = Math.max(0, Math.min(S2_1.S2.MAX_LEVEL, -(exponent >> (this.dim() - 1))));
|
|
54
|
-
// assert (level == S2CellId.MAX_LEVEL || getValue(level) <= value);
|
|
55
|
-
// assert (level == 0 || getValue(level - 1) > value);
|
|
56
|
-
return level;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Return the maximum level such that the metric is at least the given
|
|
60
|
-
* value, or zero if there is no such level. For example,
|
|
61
|
-
* S2.kMinWidth.GetMaxLevel(0.1) returns the maximum level such that all
|
|
62
|
-
* cells have a minimum width of 0.1 or larger. The return value is always a
|
|
63
|
-
* valid level.
|
|
64
|
-
*/
|
|
65
|
-
getMaxLevel(value /*double*/) {
|
|
66
|
-
if (value <= 0) {
|
|
67
|
-
return S2_1.S2.MAX_LEVEL;
|
|
68
|
-
}
|
|
69
|
-
// This code is equivalent to computing a floating-point "level"
|
|
70
|
-
// value and rounding down.
|
|
71
|
-
const exponent = Platform_1.Platform.getExponent(this.deriv() / value);
|
|
72
|
-
const level = Math.max(0, Math.min(S2_1.S2.MAX_LEVEL, exponent >> (this.dim() - 1)));
|
|
73
|
-
// assert (level == 0 || getValue(level) >= value);
|
|
74
|
-
// assert (level == S2CellId.MAX_LEVEL || getValue(level + 1) < value);
|
|
75
|
-
return level;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
exports.S2Metric = S2Metric;
|
|
79
|
-
//# sourceMappingURL=S2Metric.js.map
|
package/dist/S2Metric.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"S2Metric.js","sourceRoot":"","sources":["../src/S2Metric.ts"],"names":[],"mappings":";;;AAAA,yCAAsC;AACtC,6BAAwB;AACxB;;GAEG;AACH,MAAa,QAAQ;IAIjB;;OAEG;IACH,YAAmB,IAAW,EAAE,MAAa;QACzC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IAEzB,CAAC;IAED,KAAK;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,GAAG;QACC,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,iEAAiE;IAC1D,QAAQ,CAAC,KAAY;QAC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,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,OAAE,CAAC,SAAS,EAAE,QAAQ,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAEhF,mDAAmD;QACnD,uEAAuE;QACvE,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ;AAlFD,4BAkFC"}
|
package/dist/S2Point.d.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { R2Vector } from "./R2Vector";
|
|
2
|
-
/**
|
|
3
|
-
* An S2Point represents a point on the unit sphere as a 3D vector. Usually
|
|
4
|
-
* points are normalized to be unit length, but some methods do not require
|
|
5
|
-
* this.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
export declare class S2Point {
|
|
9
|
-
/** Origin of the coordinate system, [0,0,0]. */
|
|
10
|
-
static ORIGIN: S2Point;
|
|
11
|
-
/** Direction of the x-axis. */
|
|
12
|
-
static X_POS: S2Point;
|
|
13
|
-
/** Opposite direction of the x-axis. */
|
|
14
|
-
static X_NEG: S2Point;
|
|
15
|
-
/** Direction of the y-axis. */
|
|
16
|
-
static Y_POS: S2Point;
|
|
17
|
-
/** Opposite direction of the y-axis. */
|
|
18
|
-
static Y_NEG: S2Point;
|
|
19
|
-
/** Direction of the z-axis. */
|
|
20
|
-
static Z_POS: S2Point;
|
|
21
|
-
/** Opposite direction of the z-axis. */
|
|
22
|
-
static Z_NEG: S2Point;
|
|
23
|
-
x: number;
|
|
24
|
-
y: number;
|
|
25
|
-
z: number;
|
|
26
|
-
constructor(x: number, y: number, z: number);
|
|
27
|
-
static minus(p1: S2Point, p2: S2Point): S2Point;
|
|
28
|
-
static neg(p: S2Point): S2Point;
|
|
29
|
-
norm2(): number;
|
|
30
|
-
norm(): number;
|
|
31
|
-
static crossProd(p1: S2Point, p2: S2Point): S2Point;
|
|
32
|
-
static add(p1: S2Point, p2: S2Point): S2Point;
|
|
33
|
-
static sub(p1: S2Point, p2: S2Point): S2Point;
|
|
34
|
-
dotProd(that: S2Point): number;
|
|
35
|
-
static mul(p: any, m: number): S2Point;
|
|
36
|
-
static div(p: S2Point, m: number): S2Point;
|
|
37
|
-
/**
|
|
38
|
-
* Returns the distance in 3D coordinates from this to that.
|
|
39
|
-
*
|
|
40
|
-
* <p>Equivalent to {@code a.sub(b).norm()}, but significantly faster.
|
|
41
|
-
*
|
|
42
|
-
* <p>If ordering points by angle, this is faster than {@link #norm}, and much faster than {@link
|
|
43
|
-
* #angle}, but consider using {@link S1ChordAngle}.
|
|
44
|
-
*/
|
|
45
|
-
getDistance(that: S2Point): number;
|
|
46
|
-
/**
|
|
47
|
-
* Returns the square of the distance in 3D coordinates from this to that.
|
|
48
|
-
*
|
|
49
|
-
* <p>Equivalent to {@code getDistance(that)<sup>2</sup>}, but significantly faster.
|
|
50
|
-
*
|
|
51
|
-
* <p>If ordering points by angle, this is much faster than {@link #angle}, but consider using
|
|
52
|
-
* {@link S1ChordAngle}.
|
|
53
|
-
*/
|
|
54
|
-
getDistance2(that: S2Point): number;
|
|
55
|
-
/** return a vector orthogonal to this one */
|
|
56
|
-
ortho(): S2Point;
|
|
57
|
-
/** Return the index of the largest component fabs */
|
|
58
|
-
largestAbsComponent(): number;
|
|
59
|
-
static largestAbsComponent(x: number, y: number, z: number): number;
|
|
60
|
-
get(axis: number): number;
|
|
61
|
-
static fabs(p: S2Point): S2Point;
|
|
62
|
-
/** Returns a copy of 'p' rescaled to be unit-length. */
|
|
63
|
-
static normalize(p: S2Point): S2Point;
|
|
64
|
-
axis(axis: number): number;
|
|
65
|
-
/** Return the angle between two vectors in radians */
|
|
66
|
-
angle(va: any): number;
|
|
67
|
-
/**
|
|
68
|
-
* Compare two vectors, return true if all their components are within a
|
|
69
|
-
* difference of margin.
|
|
70
|
-
*/
|
|
71
|
-
aequal(that: S2Point, margin: number): boolean;
|
|
72
|
-
equals(that: S2Point): boolean;
|
|
73
|
-
lessThan(vb: S2Point): boolean;
|
|
74
|
-
compareTo(other: S2Point): number;
|
|
75
|
-
toFace(): number;
|
|
76
|
-
toR2Vector(face?: number): R2Vector;
|
|
77
|
-
toString(): string;
|
|
78
|
-
}
|
package/dist/S2Point.js
DELETED
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2006 Google Inc.
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.S2Point = void 0;
|
|
19
|
-
const R2Vector_1 = require("./R2Vector");
|
|
20
|
-
///re
|
|
21
|
-
/**
|
|
22
|
-
* An S2Point represents a point on the unit sphere as a 3D vector. Usually
|
|
23
|
-
* points are normalized to be unit length, but some methods do not require
|
|
24
|
-
* this.
|
|
25
|
-
*
|
|
26
|
-
*/
|
|
27
|
-
class S2Point {
|
|
28
|
-
constructor(x, y, z) {
|
|
29
|
-
this.x = (x);
|
|
30
|
-
this.y = (y);
|
|
31
|
-
this.z = (z);
|
|
32
|
-
// this.y = typeof(y) === 'number'?new Decimal(y):y as Decimal;
|
|
33
|
-
// this.z = typeof(z) === 'number'?new Decimal(z):z as Decimal;
|
|
34
|
-
}
|
|
35
|
-
static minus(p1, p2) {
|
|
36
|
-
return S2Point.sub(p1, p2);
|
|
37
|
-
}
|
|
38
|
-
static neg(p) {
|
|
39
|
-
return new S2Point(p.x * -1, p.y * -1, p.z * -1);
|
|
40
|
-
}
|
|
41
|
-
norm2() {
|
|
42
|
-
return Math.pow(this.x, 2) + Math.pow(this.y, 2) + Math.pow(this.z, 2);
|
|
43
|
-
}
|
|
44
|
-
norm() {
|
|
45
|
-
return Math.sqrt(this.norm2());
|
|
46
|
-
}
|
|
47
|
-
static crossProd(p1, p2) {
|
|
48
|
-
return new S2Point(p1.y * (p2.z) - (p1.z * (p2.y)), p1.z * (p2.x) - (p1.x * (p2.z)),
|
|
49
|
-
// p1.z * p2.x - p1.x * p2.z,
|
|
50
|
-
p1.x * (p2.y) - (p1.y * (p2.x))
|
|
51
|
-
// p1.x * p2.y - p1.y * p2.x
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
static add(p1, p2) {
|
|
55
|
-
return new S2Point(p1.x + p2.x, p1.y + p2.y, p1.z + p2.z);
|
|
56
|
-
}
|
|
57
|
-
static sub(p1, p2) {
|
|
58
|
-
return new S2Point(p1.x - p2.x, p1.y - p2.y, p1.z - p2.z);
|
|
59
|
-
}
|
|
60
|
-
dotProd(that) {
|
|
61
|
-
return this.x * (that.x) + (this.y * that.y) + (this.z * (that.z));
|
|
62
|
-
}
|
|
63
|
-
static mul(p, m) {
|
|
64
|
-
return new S2Point(m * (p.x), m * (p.y), m * (p.z));
|
|
65
|
-
}
|
|
66
|
-
static div(p, m) {
|
|
67
|
-
return new S2Point(p.x / (m), p.y / (m), p.z / (m));
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Returns the distance in 3D coordinates from this to that.
|
|
71
|
-
*
|
|
72
|
-
* <p>Equivalent to {@code a.sub(b).norm()}, but significantly faster.
|
|
73
|
-
*
|
|
74
|
-
* <p>If ordering points by angle, this is faster than {@link #norm}, and much faster than {@link
|
|
75
|
-
* #angle}, but consider using {@link S1ChordAngle}.
|
|
76
|
-
*/
|
|
77
|
-
getDistance(that) {
|
|
78
|
-
return Math.sqrt(this.getDistance2(that));
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Returns the square of the distance in 3D coordinates from this to that.
|
|
82
|
-
*
|
|
83
|
-
* <p>Equivalent to {@code getDistance(that)<sup>2</sup>}, but significantly faster.
|
|
84
|
-
*
|
|
85
|
-
* <p>If ordering points by angle, this is much faster than {@link #angle}, but consider using
|
|
86
|
-
* {@link S1ChordAngle}.
|
|
87
|
-
*/
|
|
88
|
-
getDistance2(that) {
|
|
89
|
-
const dx = this.x - that.x;
|
|
90
|
-
const dy = this.y - that.y;
|
|
91
|
-
const dz = this.z - that.z;
|
|
92
|
-
return dx * dx + dy * dy + dz * dz;
|
|
93
|
-
}
|
|
94
|
-
/** return a vector orthogonal to this one */
|
|
95
|
-
ortho() {
|
|
96
|
-
const k = this.largestAbsComponent();
|
|
97
|
-
let temp;
|
|
98
|
-
if (k == 1) {
|
|
99
|
-
temp = new S2Point(1, 0, 0);
|
|
100
|
-
}
|
|
101
|
-
else if (k == 2) {
|
|
102
|
-
temp = new S2Point(0, 1, 0);
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
temp = new S2Point(0, 0, 1);
|
|
106
|
-
}
|
|
107
|
-
return S2Point.normalize(S2Point.crossProd(this, temp));
|
|
108
|
-
}
|
|
109
|
-
/** Return the index of the largest component fabs */
|
|
110
|
-
largestAbsComponent() {
|
|
111
|
-
return S2Point.largestAbsComponent(this.x, this.y, this.z);
|
|
112
|
-
}
|
|
113
|
-
static largestAbsComponent(x, y, z) {
|
|
114
|
-
const absX = Math.abs(x);
|
|
115
|
-
const absY = Math.abs(y);
|
|
116
|
-
const absZ = Math.abs(z);
|
|
117
|
-
if (absX > absY) {
|
|
118
|
-
if (absX > absZ) {
|
|
119
|
-
return 0;
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
return 2;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
if (absY > absZ) {
|
|
127
|
-
return 1;
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
return 2;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
get(axis) {
|
|
135
|
-
return (axis == 0) ? this.x : (axis == 1) ? this.y : this.z;
|
|
136
|
-
}
|
|
137
|
-
static fabs(p) {
|
|
138
|
-
return new S2Point(Math.abs(p.x), Math.abs(p.y), Math.abs(p.z));
|
|
139
|
-
}
|
|
140
|
-
/** Returns a copy of 'p' rescaled to be unit-length. */
|
|
141
|
-
static normalize(p) {
|
|
142
|
-
let norm = p.norm();
|
|
143
|
-
if (norm != 0) {
|
|
144
|
-
norm = 1 / norm;
|
|
145
|
-
}
|
|
146
|
-
return S2Point.mul(p, norm);
|
|
147
|
-
}
|
|
148
|
-
axis(axis) {
|
|
149
|
-
return (axis == 0) ? this.x : (axis == 1) ? this.y : this.z;
|
|
150
|
-
}
|
|
151
|
-
/** Return the angle between two vectors in radians */
|
|
152
|
-
angle(va) {
|
|
153
|
-
return Math.atan2(S2Point.crossProd(this, va).norm(), this.dotProd(va));
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Compare two vectors, return true if all their components are within a
|
|
157
|
-
* difference of margin.
|
|
158
|
-
*/
|
|
159
|
-
aequal(that, margin) {
|
|
160
|
-
return this.x - Math.abs(that.x) < (margin) &&
|
|
161
|
-
this.y - Math.abs(that.y) < (margin) &&
|
|
162
|
-
this.z - Math.abs(that.z) < (margin);
|
|
163
|
-
}
|
|
164
|
-
equals(that) {
|
|
165
|
-
if (!(that instanceof S2Point)) {
|
|
166
|
-
return false;
|
|
167
|
-
}
|
|
168
|
-
return this.x == (that.x) && this.y == (that.y) && this.z == (that.z);
|
|
169
|
-
}
|
|
170
|
-
lessThan(vb) {
|
|
171
|
-
if (this.x < (vb.x)) {
|
|
172
|
-
return true;
|
|
173
|
-
}
|
|
174
|
-
if (vb.x < (this.x)) {
|
|
175
|
-
return false;
|
|
176
|
-
}
|
|
177
|
-
if (this.y < (vb.y)) {
|
|
178
|
-
return true;
|
|
179
|
-
}
|
|
180
|
-
if (vb.y < (this.y)) {
|
|
181
|
-
return false;
|
|
182
|
-
}
|
|
183
|
-
if (this.z < (vb.z)) {
|
|
184
|
-
return true;
|
|
185
|
-
}
|
|
186
|
-
return false;
|
|
187
|
-
}
|
|
188
|
-
compareTo(other) {
|
|
189
|
-
return (this.lessThan(other) ? -1 : (this.equals(other) ? 0 : 1));
|
|
190
|
-
}
|
|
191
|
-
toFace() {
|
|
192
|
-
let face = this.largestAbsComponent();
|
|
193
|
-
if (this.axis(face) < (0)) {
|
|
194
|
-
face += 3;
|
|
195
|
-
}
|
|
196
|
-
return face;
|
|
197
|
-
}
|
|
198
|
-
toR2Vector(face = this.toFace()) {
|
|
199
|
-
let u;
|
|
200
|
-
let v;
|
|
201
|
-
switch (face) {
|
|
202
|
-
case 0:
|
|
203
|
-
u = this.y / (this.x);
|
|
204
|
-
v = this.z / (this.x);
|
|
205
|
-
break;
|
|
206
|
-
case 1:
|
|
207
|
-
u = (this.x * -1) / (this.y);
|
|
208
|
-
v = this.z / (this.y);
|
|
209
|
-
break;
|
|
210
|
-
case 2:
|
|
211
|
-
u = (this.x * -1) / (this.z);
|
|
212
|
-
v = (this.y * -1) / (this.z);
|
|
213
|
-
break;
|
|
214
|
-
case 3:
|
|
215
|
-
u = this.z / (this.x);
|
|
216
|
-
v = this.y / (this.x);
|
|
217
|
-
break;
|
|
218
|
-
case 4:
|
|
219
|
-
u = this.z / (this.y);
|
|
220
|
-
v = (this.x * -1) / (this.y);
|
|
221
|
-
break;
|
|
222
|
-
case 5:
|
|
223
|
-
u = (this.y * -1) / (this.z);
|
|
224
|
-
v = (this.x * -1) / (this.z);
|
|
225
|
-
break;
|
|
226
|
-
default:
|
|
227
|
-
throw new Error('Invalid face');
|
|
228
|
-
}
|
|
229
|
-
return new R2Vector_1.R2Vector(u, v);
|
|
230
|
-
}
|
|
231
|
-
toString() {
|
|
232
|
-
return `Point(${this.x}, ${this.y}, ${this.z})`;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
exports.S2Point = S2Point;
|
|
236
|
-
/** Origin of the coordinate system, [0,0,0]. */
|
|
237
|
-
S2Point.ORIGIN = new S2Point(0, 0, 0);
|
|
238
|
-
/** Direction of the x-axis. */
|
|
239
|
-
S2Point.X_POS = new S2Point(1, 0, 0);
|
|
240
|
-
/** Opposite direction of the x-axis. */
|
|
241
|
-
S2Point.X_NEG = new S2Point(-1, 0, 0);
|
|
242
|
-
/** Direction of the y-axis. */
|
|
243
|
-
S2Point.Y_POS = new S2Point(0, 1, 0);
|
|
244
|
-
/** Opposite direction of the y-axis. */
|
|
245
|
-
S2Point.Y_NEG = new S2Point(0, -1, 0);
|
|
246
|
-
/** Direction of the z-axis. */
|
|
247
|
-
S2Point.Z_POS = new S2Point(0, 0, 1);
|
|
248
|
-
/** Opposite direction of the z-axis. */
|
|
249
|
-
S2Point.Z_NEG = new S2Point(0, 0, -1);
|
|
250
|
-
//# sourceMappingURL=S2Point.js.map
|
package/dist/S2Point.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"S2Point.js","sourceRoot":"","sources":["../src/S2Point.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,yCAAoC;AAEpC,KAAK;AACL;;;;;GAKG;AACH,MAAa,OAAO;IA0BlB,YAAY,CAAQ,EAAE,CAAQ,EAAE,CAAQ;QACtC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACb,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACb,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACb,+DAA+D;QAC/D,+DAA+D;IACjE,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,EAAU,EAAE,EAAU;QACjC,OAAO,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAC7B,CAAC;IAED,MAAM,CAA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AgD;AAClC,cAAM,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAE5C,+BAA+B;AACjB,aAAK,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAE3C,wCAAwC;AAC1B,aAAK,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAE5C,+BAA+B;AACjB,aAAK,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAE3C,wCAAwC;AAC1B,aAAK,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE5C,+BAA+B;AACjB,aAAK,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAE3C,wCAAwC;AAC1B,aAAK,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/S2Projections.d.ts
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This class specifies the details of how the cube faces are projected onto the
|
|
3
|
-
* unit sphere. This includes getting the face ordering and orientation correct
|
|
4
|
-
* so that sequentially increasing cell ids follow a continuous space-filling
|
|
5
|
-
* curve over the entire sphere, and defining the transformation from cell-space
|
|
6
|
-
* to cube-space (see s2.h) in order to make the cells more uniform in size.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* We have implemented three different projections from cell-space (s,t) to
|
|
10
|
-
* cube-space (u,v): linear, quadratic, and tangent. They have the following
|
|
11
|
-
* tradeoffs:
|
|
12
|
-
*
|
|
13
|
-
* Linear - This is the fastest transformation, but also produces the least
|
|
14
|
-
* uniform cell sizes. Cell areas vary by a factor of about 5.2, with the
|
|
15
|
-
* largest cells at the center of each face and the smallest cells in the
|
|
16
|
-
* corners.
|
|
17
|
-
*
|
|
18
|
-
* Tangent - Transforming the coordinates via atan() makes the cell sizes more
|
|
19
|
-
* uniform. The areas vary by a maximum ratio of 1.4 as opposed to a maximum
|
|
20
|
-
* ratio of 5.2. However, each call to atan() is about as expensive as all of
|
|
21
|
-
* the other calculations combined when converting from points to cell ids, i.e.
|
|
22
|
-
* it reduces performance by a factor of 3.
|
|
23
|
-
*
|
|
24
|
-
* Quadratic - This is an approximation of the tangent projection that is much
|
|
25
|
-
* faster and produces cells that are almost as uniform in size. It is about 3
|
|
26
|
-
* times faster than the tangent projection for converting cell ids to points,
|
|
27
|
-
* and 2 times faster for converting points to cell ids. Cell areas vary by a
|
|
28
|
-
* maximum ratio of about 2.1.
|
|
29
|
-
*
|
|
30
|
-
* Here is a table comparing the cell uniformity using each projection. "Area
|
|
31
|
-
* ratio" is the maximum ratio over all subdivision levels of the largest cell
|
|
32
|
-
* area to the smallest cell area at that level, "edge ratio" is the maximum
|
|
33
|
-
* ratio of the longest edge of any cell to the shortest edge of any cell at the
|
|
34
|
-
* same level, and "diag ratio" is the ratio of the longest diagonal of any cell
|
|
35
|
-
* to the shortest diagonal of any cell at the same level. "ToPoint" and
|
|
36
|
-
* "FromPoint" are the times in microseconds required to convert cell ids to and
|
|
37
|
-
* from points (unit vectors) respectively.
|
|
38
|
-
*
|
|
39
|
-
* Area Edge Diag ToPoint FromPoint Ratio Ratio Ratio (microseconds)
|
|
40
|
-
* ------------------------------------------------------- Linear: 5.200 2.117
|
|
41
|
-
* 2.959 0.103 0.123 Tangent: 1.414 1.414 1.704 0.290 0.306 Quadratic: 2.082
|
|
42
|
-
* 1.802 1.932 0.116 0.161
|
|
43
|
-
*
|
|
44
|
-
* The worst-case cell aspect ratios are about the same with all three
|
|
45
|
-
* projections. The maximum ratio of the longest edge to the shortest edge
|
|
46
|
-
* within the same cell is about 1.4 and the maximum ratio of the diagonals
|
|
47
|
-
* within the same cell is about 1.7.
|
|
48
|
-
*
|
|
49
|
-
* This data was produced using s2cell_unittest and s2cellid_unittest.
|
|
50
|
-
*
|
|
51
|
-
*/
|
|
52
|
-
import { S2Metric } from "./S2";
|
|
53
|
-
import { S2Point } from "./S2Point";
|
|
54
|
-
import { R2Vector } from "./R2Vector";
|
|
55
|
-
import Long = require("long");
|
|
56
|
-
export declare type UvTransformFunction = (x: number, y: number, z: number) => number;
|
|
57
|
-
export declare type XyzTransformFunction = (u: number, v: number) => number;
|
|
58
|
-
export declare type UvTransform = {
|
|
59
|
-
xyzToU: UvTransformFunction;
|
|
60
|
-
xyzToV: UvTransformFunction;
|
|
61
|
-
};
|
|
62
|
-
export declare type XyzTransform = {
|
|
63
|
-
uvToX: XyzTransformFunction;
|
|
64
|
-
uvToY: XyzTransformFunction;
|
|
65
|
-
uvToZ: XyzTransformFunction;
|
|
66
|
-
};
|
|
67
|
-
export declare class S2Projections {
|
|
68
|
-
static MIN_WIDTH: S2Metric;
|
|
69
|
-
static AVG_AREA: S2Metric;
|
|
70
|
-
static MAX_LEVEL: number;
|
|
71
|
-
private static FACE_UVW_AXES;
|
|
72
|
-
private static UV_TRANSFORMS;
|
|
73
|
-
private static XYZ_TRANSFORMS;
|
|
74
|
-
/**
|
|
75
|
-
* The maximum value of an si- or ti-coordinate. The range of valid (si,ti) values is
|
|
76
|
-
* [0..MAX_SiTi].
|
|
77
|
-
*/
|
|
78
|
-
static MAX_SITI: Long.Long;
|
|
79
|
-
static getUNorm(face: number, u: number): S2Point;
|
|
80
|
-
static getVNorm(face: number, v: number): S2Point;
|
|
81
|
-
static getUAxis(face: number): S2Point;
|
|
82
|
-
static getVAxis(face: number): S2Point;
|
|
83
|
-
static getNorm(face: number): S2Point;
|
|
84
|
-
/** Returns the given axis of the given face (u=0, v=1, w=2). */
|
|
85
|
-
static getUVWAxis(face: number, axis: number): S2Point;
|
|
86
|
-
/**
|
|
87
|
-
* Convert (face, si, ti) coordinates (see s2.h) to a direction vector (not
|
|
88
|
-
* necessarily unit length).
|
|
89
|
-
*/
|
|
90
|
-
static faceSiTiToXYZ(face: number, si: number, ti: number): S2Point;
|
|
91
|
-
static faceUvToXyz(face: number, u: number, v: number): S2Point;
|
|
92
|
-
static faceXyzToUv(face: number, p: S2Point): R2Vector;
|
|
93
|
-
static validFaceXyzToUv(face: number, p: S2Point): R2Vector;
|
|
94
|
-
static ijToStMin(i: number): number;
|
|
95
|
-
static stToIj(s: number): number;
|
|
96
|
-
static siTiToSt(si: number): number;
|
|
97
|
-
static ijToUV(ij: number, cellSize: number): number;
|
|
98
|
-
static xyzToFaceP(p: S2Point): number;
|
|
99
|
-
static xyzToFace(x: number, y: number, z: number): number;
|
|
100
|
-
static faceToUvTransform(face: number): UvTransform;
|
|
101
|
-
static faceToXyzTransform(face: number): XyzTransform;
|
|
102
|
-
}
|