nodes2ts 1.1.9 → 3.0.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.
- package/.eslintignore +3 -0
- package/.eslintrc.cjs +11 -0
- package/.github/workflows/lint.js.yml +22 -0
- package/.github/workflows/node.js.yml +22 -0
- package/.mocharc.js +7 -0
- package/README.md +22 -5
- package/dist/Interval.d.ts +7 -8
- package/dist/Interval.js +12 -12
- package/dist/Interval.js.map +1 -1
- package/dist/MutableInteger.js +5 -4
- package/dist/MutableInteger.js.map +1 -1
- package/dist/Platform.d.ts +15 -0
- package/dist/Platform.js +53 -0
- package/dist/Platform.js.map +1 -0
- package/dist/R1Interval.d.ts +8 -9
- package/dist/R1Interval.js +59 -78
- package/dist/R1Interval.js.map +1 -1
- package/dist/R2Vector.d.ts +12 -13
- package/dist/R2Vector.js +65 -85
- package/dist/R2Vector.js.map +1 -1
- package/dist/S1Angle.d.ts +38 -5
- package/dist/S1Angle.js +89 -37
- package/dist/S1Angle.js.map +1 -1
- package/dist/S1ChordAngle.d.ts +166 -0
- package/dist/S1ChordAngle.js +318 -0
- package/dist/S1ChordAngle.js.map +1 -0
- package/dist/S1Interval.d.ts +11 -12
- package/dist/S1Interval.js +134 -140
- package/dist/S1Interval.js.map +1 -1
- package/dist/S2.d.ts +8 -5
- package/dist/S2.js +91 -108
- package/dist/S2.js.map +1 -1
- package/dist/S2Cap.d.ts +33 -25
- package/dist/S2Cap.js +199 -203
- package/dist/S2Cap.js.map +1 -1
- package/dist/S2Cell.d.ts +15 -13
- package/dist/S2Cell.js +196 -206
- package/dist/S2Cell.js.map +1 -1
- package/dist/S2CellId.d.ts +37 -14
- package/dist/S2CellId.js +407 -359
- package/dist/S2CellId.js.map +1 -1
- package/dist/S2CellUnion.d.ts +1 -2
- package/dist/S2CellUnion.js +137 -133
- package/dist/S2CellUnion.js.map +1 -1
- package/dist/S2EdgeUtil.js +14 -17
- package/dist/S2EdgeUtil.js.map +1 -1
- package/dist/S2LatLng.d.ts +15 -11
- package/dist/S2LatLng.js +100 -114
- package/dist/S2LatLng.js.map +1 -1
- package/dist/S2LatLngRect.d.ts +8 -4
- package/dist/S2LatLngRect.js +215 -197
- package/dist/S2LatLngRect.js.map +1 -1
- package/dist/S2Metric.d.ts +4 -5
- package/dist/S2Metric.js +30 -27
- package/dist/S2Metric.js.map +1 -1
- package/dist/S2Point.d.ts +48 -14
- package/dist/S2Point.js +156 -109
- package/dist/S2Point.js.map +1 -1
- package/dist/S2Projections.d.ts +43 -9
- package/dist/S2Projections.js +226 -47
- package/dist/S2Projections.js.map +1 -1
- package/dist/S2Region.js +2 -1
- package/dist/S2Region.js.map +1 -1
- package/dist/S2RegionCoverer.d.ts +21 -6
- package/dist/S2RegionCoverer.js +144 -109
- package/dist/S2RegionCoverer.js.map +1 -1
- package/dist/export.d.ts +0 -1
- package/dist/export.js +42 -32
- package/dist/export.js.map +1 -1
- package/dist/utils/preconditions.d.ts +2 -0
- package/dist/utils/preconditions.js +16 -0
- package/dist/utils/preconditions.js.map +1 -0
- package/package.json +28 -34
- package/.npmignore +0 -8
- package/.nyc_output/1eb1f420a13c15f529aac41a40bcaa21.json +0 -1
- package/.nyc_output/5ff62256eb1c111254ba0b469fb547da.json +0 -1
- package/.nyc_output/949d6e8c2061067f3bdfd27dfff5ba83.json +0 -1
- package/coverage/Interval.ts.html +0 -203
- package/coverage/MutableInteger.ts.html +0 -77
- package/coverage/R1Interval.ts.html +0 -647
- package/coverage/R2Vector.ts.html +0 -587
- package/coverage/S1Angle.ts.html +0 -344
- package/coverage/S1Interval.ts.html +0 -1349
- package/coverage/S2.ts.html +0 -1178
- package/coverage/S2Cap.ts.html +0 -1433
- package/coverage/S2Cell.ts.html +0 -1415
- package/coverage/S2CellId.ts.html +0 -3329
- package/coverage/S2EdgeUtil.ts.html +0 -2534
- package/coverage/S2LatLng.ts.html +0 -848
- package/coverage/S2LatLngRect.ts.html +0 -2222
- package/coverage/S2Point.ts.html +0 -758
- package/coverage/S2Projections.ts.html +0 -518
- package/coverage/base.css +0 -212
- package/coverage/decimal.ts.html +0 -68
- package/coverage/index.html +0 -288
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -1
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -158
- package/dist/decimal.d.ts +0 -3
- package/dist/decimal.js +0 -4
- package/dist/decimal.js.map +0 -1
- package/dist/decimal_augmentation.d.ts +0 -24
- package/dist/decimal_augmentation.js +0 -2
- package/dist/decimal_augmentation.js.map +0 -1
package/dist/S2.js
CHANGED
|
@@ -1,30 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.S2Metric = exports.S2 = void 0;
|
|
4
|
+
const S2Point_1 = require("./S2Point");
|
|
5
|
+
const S2Metric_1 = require("./S2Metric");
|
|
6
|
+
Object.defineProperty(exports, "S2Metric", { enumerable: true, get: function () { return S2Metric_1.S2Metric; } });
|
|
7
|
+
const Platform_1 = require("./Platform");
|
|
8
|
+
const Long = require("long");
|
|
9
|
+
class S2 {
|
|
10
|
+
static IEEEremainder(f1, f2) {
|
|
11
|
+
return Platform_1.Platform.IEEEremainder(f1, f2);
|
|
9
12
|
}
|
|
10
|
-
S2.IEEEremainder = function (_f1, _f2) {
|
|
11
|
-
var f1 = S2.toDecimal(_f1);
|
|
12
|
-
var f2 = S2.toDecimal(_f2);
|
|
13
|
-
var r = f1.mod(f2);
|
|
14
|
-
if (r.isNaN() || r.eq(f2) || r.lessThanOrEqualTo(f2.abs().dividedBy(2))) {
|
|
15
|
-
return r;
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
return (f1.gte(0) ? S2.toDecimal(1) : S2.toDecimal(-1)).times(r.minus(f2));
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
13
|
/**
|
|
22
14
|
* Return true if the given point is approximately unit length (this is mainly
|
|
23
15
|
* useful for assertions).
|
|
24
16
|
*/
|
|
25
|
-
|
|
26
|
-
return p.norm2()
|
|
27
|
-
}
|
|
17
|
+
static isUnitLength(p) {
|
|
18
|
+
return Math.abs(p.norm2() - 1) <= (1e-15);
|
|
19
|
+
}
|
|
28
20
|
/**
|
|
29
21
|
* If v is non-zero, return an integer {@code exp} such that
|
|
30
22
|
* {@code (0.5 <= |v|*2^(-exp) < 1)}. If v is zero, return 0.
|
|
@@ -36,21 +28,9 @@ var S2 = (function () {
|
|
|
36
28
|
*
|
|
37
29
|
* TODO(dbeaumont): Replace this with "DoubleUtils.getExponent(v) - 1" ?
|
|
38
30
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
// IT should always be ((int)log(2,v))+1;
|
|
44
|
-
var start = Math.floor(Math.log(v) / Math.log(2));
|
|
45
|
-
for (var i = start; i < start + 10; i++) {
|
|
46
|
-
var curVal = Math.abs(v) * Math.pow(2, -i);
|
|
47
|
-
if (curVal >= 0.5 && curVal < 1) {
|
|
48
|
-
return i;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
throw new Error('method not written yet');
|
|
52
|
-
// return (int)((S2.EXPONENT_MASK & bits) >> S2.EXPONENT_SHIFT) - 1022;
|
|
53
|
-
};
|
|
31
|
+
static exp(v /*double*/) {
|
|
32
|
+
return Platform_1.Platform.getExponent(v);
|
|
33
|
+
}
|
|
54
34
|
/**
|
|
55
35
|
* Return a vector "c" that is orthogonal to the given unit-length vectors "a"
|
|
56
36
|
* and "b". This function is similar to a.CrossProd(b) except that it does a
|
|
@@ -63,7 +43,7 @@ var S2 = (function () {
|
|
|
63
43
|
* a == -b (3) RCP(-a,b) == -RCP(a,b) unless a == b or a == -b (4) RCP(a,-b)
|
|
64
44
|
* == -RCP(a,b) unless a == b or a == -b
|
|
65
45
|
*/
|
|
66
|
-
|
|
46
|
+
static robustCrossProd(a, b) {
|
|
67
47
|
// The direction of a.CrossProd(b) becomes unstable as (a + b) or (a - b)
|
|
68
48
|
// approaches zero. This leads to situations where a.CrossProd(b) is not
|
|
69
49
|
// very orthogonal to "a" and/or "b". We could fix this using Gram-Schmidt,
|
|
@@ -73,14 +53,14 @@ var S2 = (function () {
|
|
|
73
53
|
// Given that "a" and "b" are unit-length, this has good orthogonality to
|
|
74
54
|
// "a" and "b" even if they differ only in the lowest bit of one component.
|
|
75
55
|
// assert (isUnitLength(a) && isUnitLength(b));
|
|
76
|
-
|
|
56
|
+
const x = S2Point_1.S2Point.crossProd(S2Point_1.S2Point.add(b, a), S2Point_1.S2Point.sub(b, a));
|
|
77
57
|
if (!x.equals(new S2Point_1.S2Point(0, 0, 0))) {
|
|
78
58
|
return x;
|
|
79
59
|
}
|
|
80
60
|
// The only result that makes sense mathematically is to return zero, but
|
|
81
61
|
// we find it more convenient to return an arbitrary orthogonal vector.
|
|
82
62
|
return a.ortho();
|
|
83
|
-
}
|
|
63
|
+
}
|
|
84
64
|
/**
|
|
85
65
|
* Return the area of triangle ABC. The method used is about twice as
|
|
86
66
|
* expensive as Girard's formula, but it is numerically stable for both large
|
|
@@ -91,7 +71,7 @@ var S2 = (function () {
|
|
|
91
71
|
* becomes numerically unstable as the length of any edge approaches 180
|
|
92
72
|
* degrees.
|
|
93
73
|
*/
|
|
94
|
-
|
|
74
|
+
static area(a, b, c) {
|
|
95
75
|
// This method is based on l'Huilier's theorem,
|
|
96
76
|
//
|
|
97
77
|
// tan(E/4) = sqrt(tan(s/2) tan((s-a)/2) tan((s-b)/2) tan((s-c)/2))
|
|
@@ -125,52 +105,43 @@ var S2 = (function () {
|
|
|
125
105
|
// quantities to 64 bits. Otherwise it may compute a value of dmin > 0
|
|
126
106
|
// simply because it chose to spill one of the intermediate values to
|
|
127
107
|
// memory but not one of the others.
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
108
|
+
const sa = b.angle(c);
|
|
109
|
+
const sb = c.angle(a);
|
|
110
|
+
const sc = a.angle(b);
|
|
111
|
+
const s = sa + (sb) + (sc) * (0.5);
|
|
132
112
|
// 0.5 * (sa + sb + sc);
|
|
133
|
-
if (s
|
|
113
|
+
if (s >= (3e-4)) {
|
|
134
114
|
// Consider whether Girard's formula might be more accurate.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if (dmin
|
|
115
|
+
const s2 = s * 2;
|
|
116
|
+
const dmin = s - Math.max(sa, sb, sc);
|
|
117
|
+
if (dmin < (s2 * s2 * (s) * (1e-2))) {
|
|
138
118
|
// This triangle is skinny enough to consider Girard's formula.
|
|
139
|
-
|
|
140
|
-
if (dmin
|
|
119
|
+
const area = S2.girardArea(a, b, c);
|
|
120
|
+
if (dmin < (s * (area * (0.1)))) {
|
|
141
121
|
return area;
|
|
142
122
|
}
|
|
143
123
|
}
|
|
144
124
|
}
|
|
145
125
|
// Use l'Huilier's formula.
|
|
146
|
-
return
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
};
|
|
126
|
+
return 4 * (Math.atan(Math.sqrt(Math.max(0.0, Math.tan(s * (0.5))
|
|
127
|
+
* (Math.tan(s - (sa) * (0.5)))
|
|
128
|
+
* (Math.tan(s - (sb) * (0.5)))
|
|
129
|
+
* (Math.tan(s - (sc) * (0.5)))))));
|
|
130
|
+
}
|
|
152
131
|
/**
|
|
153
132
|
* Return the area of the triangle computed using Girard's formula. This is
|
|
154
133
|
* slightly faster than the Area() method above is not accurate for very small
|
|
155
134
|
* triangles.
|
|
156
135
|
*/
|
|
157
|
-
|
|
136
|
+
static girardArea(a, b, c) {
|
|
158
137
|
// This is equivalent to the usual Girard's formula but is slightly
|
|
159
138
|
// more accurate, faster to compute, and handles a == b == c without
|
|
160
139
|
// a special case.
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
return
|
|
165
|
-
|
|
166
|
-
.plus(bc.angle(ac)));
|
|
167
|
-
};
|
|
168
|
-
S2.toDecimal = function (value) {
|
|
169
|
-
if (typeof (value) === 'number' || typeof (value) === 'string') {
|
|
170
|
-
return new decimal_1.Decimal(value);
|
|
171
|
-
}
|
|
172
|
-
return value;
|
|
173
|
-
};
|
|
140
|
+
const ab = S2Point_1.S2Point.crossProd(a, b);
|
|
141
|
+
const bc = S2Point_1.S2Point.crossProd(b, c);
|
|
142
|
+
const ac = S2Point_1.S2Point.crossProd(a, c);
|
|
143
|
+
return Math.max(0, ab.angle(ac) - ab.angle(bc) + bc.angle(ac));
|
|
144
|
+
}
|
|
174
145
|
/**
|
|
175
146
|
* Return true if the points A, B, C are strictly counterclockwise. Return
|
|
176
147
|
* false if the points are clockwise or colinear (i.e. if they are all
|
|
@@ -184,7 +155,7 @@ var S2 = (function () {
|
|
|
184
155
|
*
|
|
185
156
|
* In other words, ABC and CBA are guaranteed not to be both CCW
|
|
186
157
|
*/
|
|
187
|
-
|
|
158
|
+
static simpleCCW(a, b, c) {
|
|
188
159
|
// We compute the signed volume of the parallelepiped ABC. The usual
|
|
189
160
|
// formula for this is (AxB).C, but we compute it here using (CxA).B
|
|
190
161
|
// in order to ensure that ABC and CBA are not both CCW. This follows
|
|
@@ -193,8 +164,8 @@ var S2 = (function () {
|
|
|
193
164
|
//
|
|
194
165
|
// (1) x.CrossProd(y) == -(y.CrossProd(x))
|
|
195
166
|
// (2) (-x).DotProd(y) == -(x.DotProd(y))
|
|
196
|
-
return S2Point_1.S2Point.crossProd(c, a).dotProd(b)
|
|
197
|
-
}
|
|
167
|
+
return S2Point_1.S2Point.crossProd(c, a).dotProd(b) > 0;
|
|
168
|
+
}
|
|
198
169
|
/**
|
|
199
170
|
*
|
|
200
171
|
* Return true if edge AB crosses CD at a point that is interior to both
|
|
@@ -203,46 +174,58 @@ var S2 = (function () {
|
|
|
203
174
|
* (1) SimpleCrossing(b,a,c,d) == SimpleCrossing(a,b,c,d) (2)
|
|
204
175
|
* SimpleCrossing(c,d,a,b) == SimpleCrossing(a,b,c,d)
|
|
205
176
|
*/
|
|
206
|
-
|
|
177
|
+
static simpleCrossing(a, b, c, d) {
|
|
207
178
|
// We compute SimpleCCW() for triangles ACB, CBD, BDA, and DAC. All
|
|
208
179
|
// of these triangles need to have the same orientation (CW or CCW)
|
|
209
180
|
// for an intersection to exist. Note that this is slightly more
|
|
210
181
|
// restrictive than the corresponding definition for planar edges,
|
|
211
182
|
// since we need to exclude pairs of line segments that would
|
|
212
183
|
// otherwise "intersect" by crossing two antipodal points.
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
return (acb
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
/** Mapping from cell orientation + Hilbert traversal to IJ-index. */
|
|
235
|
-
S2.POS_TO_ORIENTATION = [S2.SWAP_MASK, 0, 0, S2.INVERT_MASK + S2.SWAP_MASK];
|
|
236
|
-
S2.POS_TO_IJ = [
|
|
237
|
-
// 0 1 2 3
|
|
238
|
-
[0, 1, 3, 2],
|
|
239
|
-
[0, 2, 3, 1],
|
|
240
|
-
[3, 2, 0, 1],
|
|
241
|
-
[3, 1, 0, 2],
|
|
242
|
-
];
|
|
243
|
-
S2.MAX_LEVEL = 30;
|
|
244
|
-
S2.Metric = S2Metric_1.S2Metric;
|
|
245
|
-
return S2;
|
|
246
|
-
}());
|
|
184
|
+
const ab = S2Point_1.S2Point.crossProd(a, b);
|
|
185
|
+
const cd = S2Point_1.S2Point.crossProd(c, d);
|
|
186
|
+
const acb = ab.dotProd(c) * -1;
|
|
187
|
+
const cbd = cd.dotProd(b) * -1;
|
|
188
|
+
const bda = ab.dotProd(d);
|
|
189
|
+
const dac = cd.dotProd(a);
|
|
190
|
+
return (acb * (cbd) > (0)) && (cbd * (bda) > (0)) && (bda * (dac) > (0));
|
|
191
|
+
}
|
|
192
|
+
static approxEqualsPointError(a, b, maxError) {
|
|
193
|
+
return a.angle(b) <= maxError;
|
|
194
|
+
}
|
|
195
|
+
static approxEqualsPoint(a, b) {
|
|
196
|
+
return this.approxEqualsPointError(a, b, 1e-15);
|
|
197
|
+
}
|
|
198
|
+
static approxEqualsNumberError(a, b, maxError) {
|
|
199
|
+
return Math.abs(a - b) <= maxError;
|
|
200
|
+
}
|
|
201
|
+
static approxEqualsNumber(a, b) {
|
|
202
|
+
return this.approxEqualsNumberError(a, b, 1e-15);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
247
205
|
exports.S2 = S2;
|
|
206
|
+
S2.M_PI = Math.PI;
|
|
207
|
+
S2.M_1_PI = 1.0 / Math.PI;
|
|
208
|
+
S2.M_PI_2 = Math.PI / 2.0;
|
|
209
|
+
S2.M_PI_4 = Math.PI / 4.0;
|
|
210
|
+
S2.M_SQRT2 = Math.sqrt(2);
|
|
211
|
+
S2.M_E = Math.E;
|
|
212
|
+
// the axis directions are reversed).
|
|
213
|
+
S2.SWAP_MASK = 0x01;
|
|
214
|
+
S2.INVERT_MASK = 0x02;
|
|
215
|
+
// Number of bits in the mantissa of a double.
|
|
216
|
+
S2.EXPONENT_SHIFT = 52;
|
|
217
|
+
// Mask to extract the exponent from a double.
|
|
218
|
+
S2.EXPONENT_MASK = Long.fromString('0x7ff0000000000000', true, 16);
|
|
219
|
+
/** Mapping from cell orientation + Hilbert traversal to IJ-index. */
|
|
220
|
+
S2.POS_TO_ORIENTATION = [S2.SWAP_MASK, 0, 0, S2.INVERT_MASK + S2.SWAP_MASK];
|
|
221
|
+
S2.DBL_EPSILON = 2 * Number.EPSILON;
|
|
222
|
+
S2.POS_TO_IJ = [
|
|
223
|
+
// 0 1 2 3
|
|
224
|
+
[0, 1, 3, 2],
|
|
225
|
+
[0, 2, 3, 1],
|
|
226
|
+
[3, 2, 0, 1],
|
|
227
|
+
[3, 1, 0, 2], // swapped & inverted: (1,1), (0,1), (0,0), (1,0)
|
|
228
|
+
];
|
|
229
|
+
S2.MAX_LEVEL = 30;
|
|
230
|
+
S2.Metric = S2Metric_1.S2Metric;
|
|
248
231
|
//# sourceMappingURL=S2.js.map
|
package/dist/S2.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"S2.js","sourceRoot":"","sources":["../src/S2.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"S2.js","sourceRoot":"","sources":["../src/S2.ts"],"names":[],"mappings":";;;AAAA,uCAAkC;AAClC,yCAAoC;AA2Q3B,yFA3QD,mBAAQ,OA2QC;AA1QjB,yCAAsC;AAEtC,6BAA8B;AAG9B,MAAa,EAAE;IA6BN,MAAM,CAAC,aAAa,CAAC,EAAS,EAAE,EAAS;QAC9C,OAAO,mBAAQ,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACxC,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,YAAY,CAAC,CAAS;QAClC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;;;;;;OAUG;IACH,MAAM,CAAC,GAAG,CAAC,CAAQ,CAAC,UAAU;QAC5B,OAAO,mBAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IACjC,CAAC;IAED;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,eAAe,CAAC,CAAS,EAAE,CAAS;QACzC,yEAAyE;QACzE,wEAAwE;QACxE,2EAA2E;QAC3E,kEAAkE;QAClE,EAAE;QACF,2EAA2E;QAC3E,yEAAyE;QACzE,2EAA2E;QAE3E,+CAA+C;QAC/C,MAAM,CAAC,GAAG,iBAAO,CAAC,SAAS,CAAC,iBAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAA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AACvB,YAAS,GAAG,IAAI,CAAC;AACjB,cAAW,GAAG,IAAI,CAAC;AAEjC,8CAA8C;AAC/B,iBAAc,GAAG,EAAE,CAAC;AACnC,8CAA8C;AAC/B,gBAAa,GAAG,IAAI,CAAC,UAAU,CAAC,oBAAoB,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;AAC/E,qEAAqE;AACvD,qBAAkB,GAAG,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,WAAW,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;AACzE,cAAW,GAAG,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC;AAEjC,YAAS,GAAG;IACxB,UAAU;IACV,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACZ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACZ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACZ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,iDAAiD;CAChE,CAAC;AACK,YAAS,GAAG,EAAE,CAAC;AAuOf,SAAM,GAAG,mBAAQ,CAAA"}
|
package/dist/S2Cap.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/// <reference types="decimal.js" />
|
|
2
1
|
import { S2Region } from "./S2Region";
|
|
3
2
|
import { S2Point } from "./S2Point";
|
|
4
3
|
import { S1Angle } from "./S1Angle";
|
|
5
4
|
import { S2LatLngRect } from "./S2LatLngRect";
|
|
6
5
|
import { S2Cell } from "./S2Cell";
|
|
6
|
+
import { S1ChordAngle } from "./S1ChordAngle";
|
|
7
7
|
/**
|
|
8
8
|
* This class represents a spherical cap, i.e. a portion of a sphere cut off by
|
|
9
9
|
* a plane. The cap is defined by its axis and height. This representation has
|
|
@@ -26,13 +26,19 @@ export declare class S2Cap implements S2Region {
|
|
|
26
26
|
*/
|
|
27
27
|
private static ROUND_UP;
|
|
28
28
|
axis: S2Point;
|
|
29
|
-
|
|
29
|
+
radius: S1ChordAngle;
|
|
30
30
|
/**
|
|
31
31
|
* Create a cap given its axis and the cap height, i.e. the maximum projected
|
|
32
32
|
* distance along the cap axis from the cap center. 'axis' should be a
|
|
33
33
|
* unit-length vector.
|
|
34
34
|
*/
|
|
35
|
-
constructor(axis: S2Point,
|
|
35
|
+
constructor(axis: S2Point, radius: S1ChordAngle);
|
|
36
|
+
static fromAxisChord(center: S2Point, radius: S1ChordAngle): S2Cap;
|
|
37
|
+
/**
|
|
38
|
+
* Create a cap given its axis and the cap height, i.e. the maximum projected distance along the
|
|
39
|
+
* cap axis from the cap center. 'axis' should be a unit-length vector.
|
|
40
|
+
*/
|
|
41
|
+
static fromAxisHeight(axis: S2Point, height: number): S2Cap;
|
|
36
42
|
/**
|
|
37
43
|
* Create a cap given its axis and the cap opening angle, i.e. maximum angle
|
|
38
44
|
* between the axis and a point on the cap. 'axis' should be a unit-length
|
|
@@ -40,24 +46,27 @@ export declare class S2Cap implements S2Region {
|
|
|
40
46
|
*/
|
|
41
47
|
static fromAxisAngle(axis: S2Point, angle: S1Angle): S2Cap;
|
|
42
48
|
/**
|
|
43
|
-
* Create a cap given its axis and its area in steradians. 'axis' should be a
|
|
44
|
-
*
|
|
49
|
+
* Create a cap given its axis and its area in steradians. 'axis' should be a unit-length vector,
|
|
50
|
+
* and 'area' should be between 0 and 4 * M_PI.
|
|
45
51
|
*/
|
|
46
|
-
static fromAxisArea(axis: S2Point,
|
|
52
|
+
static fromAxisArea(axis: S2Point, area: number): S2Cap;
|
|
47
53
|
/** Return an empty cap, i.e. a cap that contains no points. */
|
|
48
54
|
static empty(): S2Cap;
|
|
49
55
|
/** Return a full cap, i.e. a cap that contains all points. */
|
|
50
56
|
static full(): S2Cap;
|
|
51
57
|
getCapBound(): S2Cap;
|
|
52
|
-
|
|
58
|
+
height(): number;
|
|
59
|
+
area(): number;
|
|
53
60
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
61
|
+
* Returns the cap radius as an S1Angle. Since the cap angle is stored internally as an
|
|
62
|
+
* S1ChordAngle, this method requires a trigonometric operation and may yield a slightly different
|
|
63
|
+
* result than the value passed to {@link #fromAxisAngle(S2Point, S1Angle)}.
|
|
56
64
|
*/
|
|
57
65
|
angle(): S1Angle;
|
|
58
66
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
67
|
+
* Returns true if the axis is {@link S2#isUnitLength unit length}, and the angle is less than Pi.
|
|
68
|
+
*
|
|
69
|
+
* <p>Negative angles or heights are valid, and represent empty caps.
|
|
61
70
|
*/
|
|
62
71
|
isValid(): boolean;
|
|
63
72
|
/** Return true if the cap is empty, i.e. it contains no points. */
|
|
@@ -65,10 +74,10 @@ export declare class S2Cap implements S2Region {
|
|
|
65
74
|
/** Return true if the cap is full, i.e. it contains all points. */
|
|
66
75
|
isFull(): boolean;
|
|
67
76
|
/**
|
|
68
|
-
* Return the complement of the interior of the cap. A cap and its complement
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
77
|
+
* Return the complement of the interior of the cap. A cap and its complement have the same
|
|
78
|
+
* boundary but do not share any interior points. The complement operator is not a bijection,
|
|
79
|
+
* since the complement of a singleton cap (containing a single point) is the same as the
|
|
80
|
+
* complement of an empty cap.
|
|
72
81
|
*/
|
|
73
82
|
complement(): S2Cap;
|
|
74
83
|
/**
|
|
@@ -77,26 +86,24 @@ export declare class S2Cap implements S2Region {
|
|
|
77
86
|
*/
|
|
78
87
|
containsCap(other: S2Cap): boolean;
|
|
79
88
|
/**
|
|
80
|
-
* Return true if and only if the interior of this cap intersects the given
|
|
81
|
-
*
|
|
82
|
-
* this cap is used.)
|
|
89
|
+
* Return true if and only if the interior of this cap intersects the given other cap. (This
|
|
90
|
+
* relationship is not symmetric, since only the interior of this cap is used.)
|
|
83
91
|
*/
|
|
84
92
|
interiorIntersects(other: S2Cap): boolean;
|
|
85
93
|
/**
|
|
86
|
-
* Return true if and only if the given point is contained in the interior of
|
|
87
|
-
*
|
|
88
|
-
* unit-length vector.
|
|
94
|
+
* Return true if and only if the given point is contained in the interior of the region (i.e. the
|
|
95
|
+
* region excluding its boundary). 'p' should be a unit-length vector.
|
|
89
96
|
*/
|
|
90
97
|
interiorContains(p: S2Point): boolean;
|
|
91
98
|
/**
|
|
92
|
-
* Increase the cap
|
|
93
|
-
* is
|
|
94
|
-
*
|
|
99
|
+
* Increase the cap radius if necessary to include the given point. If the cap is empty the axis
|
|
100
|
+
* is set to the given point, but otherwise it is left unchanged.
|
|
101
|
+
*
|
|
102
|
+
* @param p must be {@link S2#isUnitLength unit length}
|
|
95
103
|
*/
|
|
96
104
|
addPoint(p: S2Point): S2Cap;
|
|
97
105
|
addCap(other: S2Cap): S2Cap;
|
|
98
106
|
getRectBound(): S2LatLngRect;
|
|
99
|
-
containsC(cell: S2Cell): boolean;
|
|
100
107
|
mayIntersectC(cell: S2Cell): boolean;
|
|
101
108
|
/**
|
|
102
109
|
* Return true if the cap intersects 'cell', given that the cap vertices have
|
|
@@ -104,6 +111,7 @@ export declare class S2Cap implements S2Region {
|
|
|
104
111
|
*/
|
|
105
112
|
intersects(cell: S2Cell, vertices: S2Point[]): boolean;
|
|
106
113
|
contains(p: S2Point): boolean;
|
|
114
|
+
containsC(cell: S2Cell): boolean;
|
|
107
115
|
/**
|
|
108
116
|
* Return true if the cap axis and height differ by at most "max_error" from
|
|
109
117
|
* the given cap "other".
|