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/S2Projections.js
DELETED
|
@@ -1,331 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2005 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.S2Projections = void 0;
|
|
19
|
-
/**
|
|
20
|
-
* This class specifies the details of how the cube faces are projected onto the
|
|
21
|
-
* unit sphere. This includes getting the face ordering and orientation correct
|
|
22
|
-
* so that sequentially increasing cell ids follow a continuous space-filling
|
|
23
|
-
* curve over the entire sphere, and defining the transformation from cell-space
|
|
24
|
-
* to cube-space (see s2.h) in order to make the cells more uniform in size.
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* We have implemented three different projections from cell-space (s,t) to
|
|
28
|
-
* cube-space (u,v): linear, quadratic, and tangent. They have the following
|
|
29
|
-
* tradeoffs:
|
|
30
|
-
*
|
|
31
|
-
* Linear - This is the fastest transformation, but also produces the least
|
|
32
|
-
* uniform cell sizes. Cell areas vary by a factor of about 5.2, with the
|
|
33
|
-
* largest cells at the center of each face and the smallest cells in the
|
|
34
|
-
* corners.
|
|
35
|
-
*
|
|
36
|
-
* Tangent - Transforming the coordinates via atan() makes the cell sizes more
|
|
37
|
-
* uniform. The areas vary by a maximum ratio of 1.4 as opposed to a maximum
|
|
38
|
-
* ratio of 5.2. However, each call to atan() is about as expensive as all of
|
|
39
|
-
* the other calculations combined when converting from points to cell ids, i.e.
|
|
40
|
-
* it reduces performance by a factor of 3.
|
|
41
|
-
*
|
|
42
|
-
* Quadratic - This is an approximation of the tangent projection that is much
|
|
43
|
-
* faster and produces cells that are almost as uniform in size. It is about 3
|
|
44
|
-
* times faster than the tangent projection for converting cell ids to points,
|
|
45
|
-
* and 2 times faster for converting points to cell ids. Cell areas vary by a
|
|
46
|
-
* maximum ratio of about 2.1.
|
|
47
|
-
*
|
|
48
|
-
* Here is a table comparing the cell uniformity using each projection. "Area
|
|
49
|
-
* ratio" is the maximum ratio over all subdivision levels of the largest cell
|
|
50
|
-
* area to the smallest cell area at that level, "edge ratio" is the maximum
|
|
51
|
-
* ratio of the longest edge of any cell to the shortest edge of any cell at the
|
|
52
|
-
* same level, and "diag ratio" is the ratio of the longest diagonal of any cell
|
|
53
|
-
* to the shortest diagonal of any cell at the same level. "ToPoint" and
|
|
54
|
-
* "FromPoint" are the times in microseconds required to convert cell ids to and
|
|
55
|
-
* from points (unit vectors) respectively.
|
|
56
|
-
*
|
|
57
|
-
* Area Edge Diag ToPoint FromPoint Ratio Ratio Ratio (microseconds)
|
|
58
|
-
* ------------------------------------------------------- Linear: 5.200 2.117
|
|
59
|
-
* 2.959 0.103 0.123 Tangent: 1.414 1.414 1.704 0.290 0.306 Quadratic: 2.082
|
|
60
|
-
* 1.802 1.932 0.116 0.161
|
|
61
|
-
*
|
|
62
|
-
* The worst-case cell aspect ratios are about the same with all three
|
|
63
|
-
* projections. The maximum ratio of the longest edge to the shortest edge
|
|
64
|
-
* within the same cell is about 1.4 and the maximum ratio of the diagonals
|
|
65
|
-
* within the same cell is about 1.7.
|
|
66
|
-
*
|
|
67
|
-
* This data was produced using s2cell_unittest and s2cellid_unittest.
|
|
68
|
-
*
|
|
69
|
-
*/
|
|
70
|
-
const S2_1 = require("./S2");
|
|
71
|
-
const S2CellId_1 = require("./S2CellId");
|
|
72
|
-
const S2Point_1 = require("./S2Point");
|
|
73
|
-
const R2Vector_1 = require("./R2Vector");
|
|
74
|
-
const Long = require("long");
|
|
75
|
-
var Projections;
|
|
76
|
-
(function (Projections) {
|
|
77
|
-
Projections[Projections["S2_LINEAR_PROJECTION"] = 0] = "S2_LINEAR_PROJECTION";
|
|
78
|
-
Projections[Projections["S2_TAN_PROJECTION"] = 1] = "S2_TAN_PROJECTION";
|
|
79
|
-
Projections[Projections["S2_QUADRATIC_PROJECTION"] = 2] = "S2_QUADRATIC_PROJECTION";
|
|
80
|
-
})(Projections || (Projections = {}));
|
|
81
|
-
class S2Projections {
|
|
82
|
-
static getUNorm(face, u) {
|
|
83
|
-
switch (face) {
|
|
84
|
-
case 0:
|
|
85
|
-
return new S2Point_1.S2Point(u, -1, 0);
|
|
86
|
-
case 1:
|
|
87
|
-
return new S2Point_1.S2Point(1, u, 0);
|
|
88
|
-
case 2:
|
|
89
|
-
return new S2Point_1.S2Point(1, 0, u);
|
|
90
|
-
case 3:
|
|
91
|
-
return new S2Point_1.S2Point(-u, 0, 1);
|
|
92
|
-
case 4:
|
|
93
|
-
return new S2Point_1.S2Point(0, -u, 1);
|
|
94
|
-
default:
|
|
95
|
-
return new S2Point_1.S2Point(0, -1, -u);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
static getVNorm(face, v) {
|
|
99
|
-
switch (face) {
|
|
100
|
-
case 0:
|
|
101
|
-
return new S2Point_1.S2Point(-v, 0, 1);
|
|
102
|
-
case 1:
|
|
103
|
-
return new S2Point_1.S2Point(0, -v, 1);
|
|
104
|
-
case 2:
|
|
105
|
-
return new S2Point_1.S2Point(0, -1, -v);
|
|
106
|
-
case 3:
|
|
107
|
-
return new S2Point_1.S2Point(v, -1, 0);
|
|
108
|
-
case 4:
|
|
109
|
-
return new S2Point_1.S2Point(1, v, 0);
|
|
110
|
-
default:
|
|
111
|
-
return new S2Point_1.S2Point(1, 0, v);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
static getUAxis(face) {
|
|
115
|
-
return S2Projections.getUVWAxis(face, 0);
|
|
116
|
-
}
|
|
117
|
-
static getVAxis(face) {
|
|
118
|
-
return S2Projections.getUVWAxis(face, 1);
|
|
119
|
-
}
|
|
120
|
-
static getNorm(face) {
|
|
121
|
-
return S2Projections.getUVWAxis(face, 2);
|
|
122
|
-
}
|
|
123
|
-
/** Returns the given axis of the given face (u=0, v=1, w=2). */
|
|
124
|
-
static getUVWAxis(face, axis) {
|
|
125
|
-
return S2Projections.FACE_UVW_AXES[face][axis];
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Convert (face, si, ti) coordinates (see s2.h) to a direction vector (not
|
|
129
|
-
* necessarily unit length).
|
|
130
|
-
*/
|
|
131
|
-
static faceSiTiToXYZ(face, si, ti) {
|
|
132
|
-
const u = R2Vector_1.R2Vector.singleStTOUV(this.siTiToSt(si));
|
|
133
|
-
const v = R2Vector_1.R2Vector.singleStTOUV(this.siTiToSt(ti));
|
|
134
|
-
return this.faceUvToXyz(face, u, v);
|
|
135
|
-
}
|
|
136
|
-
static faceUvToXyz(face, u, v) {
|
|
137
|
-
const t = this.faceToXyzTransform(face);
|
|
138
|
-
return new S2Point_1.S2Point(t.uvToX(u, v), t.uvToY(u, v), t.uvToZ(u, v));
|
|
139
|
-
}
|
|
140
|
-
static faceXyzToUv(face, p) {
|
|
141
|
-
if (face < 3) {
|
|
142
|
-
if (p.get(face) <= 0) {
|
|
143
|
-
return null;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
if (p.get(face - 3) >= 0) {
|
|
148
|
-
return null;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return S2Projections.validFaceXyzToUv(face, p);
|
|
152
|
-
}
|
|
153
|
-
static validFaceXyzToUv(face, p) {
|
|
154
|
-
const t = S2Projections.faceToUvTransform(face);
|
|
155
|
-
return new R2Vector_1.R2Vector(t.xyzToU(p.x, p.y, p.z), t.xyzToV(p.x, p.y, p.z));
|
|
156
|
-
}
|
|
157
|
-
static ijToStMin(i) {
|
|
158
|
-
// assert (i >= 0 && i <= S2CellId.MAX_SIZE);
|
|
159
|
-
return (1.0 / S2CellId_1.S2CellId.MAX_SIZE) * i;
|
|
160
|
-
}
|
|
161
|
-
static stToIj(s) {
|
|
162
|
-
return Math.max(0, Math.min(S2CellId_1.S2CellId.MAX_SIZE - 1, Math.round(S2CellId_1.S2CellId.MAX_SIZE * s - 0.5)));
|
|
163
|
-
}
|
|
164
|
-
static siTiToSt(si) {
|
|
165
|
-
return 1.0 / this.MAX_SITI.toNumber() * si;
|
|
166
|
-
}
|
|
167
|
-
static ijToUV(ij, cellSize) {
|
|
168
|
-
return R2Vector_1.R2Vector.singleStTOUV(S2Projections.ijToStMin(ij & -cellSize));
|
|
169
|
-
}
|
|
170
|
-
static xyzToFaceP(p) {
|
|
171
|
-
return this.xyzToFace(p.x, p.y, p.z);
|
|
172
|
-
}
|
|
173
|
-
static xyzToFace(x, y, z) {
|
|
174
|
-
switch (S2Point_1.S2Point.largestAbsComponent(x, y, z)) {
|
|
175
|
-
case 0:
|
|
176
|
-
return (x < 0) ? 3 : 0;
|
|
177
|
-
case 1:
|
|
178
|
-
return (y < 0) ? 4 : 1;
|
|
179
|
-
default:
|
|
180
|
-
return (z < 0) ? 5 : 2;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
static faceToUvTransform(face) {
|
|
184
|
-
return S2Projections.UV_TRANSFORMS[face];
|
|
185
|
-
}
|
|
186
|
-
static faceToXyzTransform(face) {
|
|
187
|
-
// We map illegal face indices to the largest face index to preserve legacy behavior, i.e., we
|
|
188
|
-
// do not (yet) want to throw an index out of bounds exception. Note that S2CellId.face() is
|
|
189
|
-
// guaranteed to return a non-negative face index even for invalid S2 cells, so it is sufficient
|
|
190
|
-
// to just map all face indices greater than 5 to a face index of 5.
|
|
191
|
-
//
|
|
192
|
-
// TODO(bjj): Remove this legacy behavior.
|
|
193
|
-
return S2Projections.XYZ_TRANSFORMS[Math.min(5, face)];
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
exports.S2Projections = S2Projections;
|
|
197
|
-
S2Projections.MIN_WIDTH = new S2_1.S2Metric(1, 2 * S2_1.S2.M_SQRT2 / 3); // 0.943
|
|
198
|
-
S2Projections.AVG_AREA = new S2_1.S2Metric(2, 4 * S2_1.S2.M_PI / 6); // ~2.094
|
|
199
|
-
S2Projections.MAX_LEVEL = 30;
|
|
200
|
-
S2Projections.FACE_UVW_AXES = [
|
|
201
|
-
[S2Point_1.S2Point.Y_POS, S2Point_1.S2Point.Z_POS, S2Point_1.S2Point.X_POS],
|
|
202
|
-
[S2Point_1.S2Point.X_NEG, S2Point_1.S2Point.Z_POS, S2Point_1.S2Point.Y_POS],
|
|
203
|
-
[S2Point_1.S2Point.X_NEG, S2Point_1.S2Point.Y_NEG, S2Point_1.S2Point.Z_POS],
|
|
204
|
-
[S2Point_1.S2Point.Z_NEG, S2Point_1.S2Point.Y_NEG, S2Point_1.S2Point.X_NEG],
|
|
205
|
-
[S2Point_1.S2Point.Z_NEG, S2Point_1.S2Point.X_POS, S2Point_1.S2Point.Y_NEG],
|
|
206
|
-
[S2Point_1.S2Point.Y_POS, S2Point_1.S2Point.X_POS, S2Point_1.S2Point.Z_NEG]
|
|
207
|
-
];
|
|
208
|
-
S2Projections.UV_TRANSFORMS = [
|
|
209
|
-
{
|
|
210
|
-
xyzToU: function xyzToU(x, y, z) {
|
|
211
|
-
return y / x;
|
|
212
|
-
},
|
|
213
|
-
xyzToV: function xyzToV(x, y, z) {
|
|
214
|
-
return z / x;
|
|
215
|
-
},
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
xyzToU: function xyzToU(x, y, z) {
|
|
219
|
-
return -x / y;
|
|
220
|
-
},
|
|
221
|
-
xyzToV: function xyzToV(x, y, z) {
|
|
222
|
-
return z / y;
|
|
223
|
-
},
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
xyzToU: function xyzToU(x, y, z) {
|
|
227
|
-
return -x / z;
|
|
228
|
-
},
|
|
229
|
-
xyzToV: function xyzToV(x, y, z) {
|
|
230
|
-
return -y / z;
|
|
231
|
-
},
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
xyzToU: function xyzToU(x, y, z) {
|
|
235
|
-
return z / x;
|
|
236
|
-
},
|
|
237
|
-
xyzToV: function xyzToV(x, y, z) {
|
|
238
|
-
return y / x;
|
|
239
|
-
},
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
xyzToU: function xyzToU(x, y, z) {
|
|
243
|
-
return z / y;
|
|
244
|
-
},
|
|
245
|
-
xyzToV: function xyzToV(x, y, z) {
|
|
246
|
-
return -x / y;
|
|
247
|
-
},
|
|
248
|
-
},
|
|
249
|
-
{
|
|
250
|
-
xyzToU: function xyzToU(x, y, z) {
|
|
251
|
-
return -y / z;
|
|
252
|
-
},
|
|
253
|
-
xyzToV: function xyzToV(x, y, z) {
|
|
254
|
-
return -x / z;
|
|
255
|
-
},
|
|
256
|
-
}
|
|
257
|
-
];
|
|
258
|
-
S2Projections.XYZ_TRANSFORMS = [
|
|
259
|
-
{
|
|
260
|
-
uvToX: function uvToX(u, v) {
|
|
261
|
-
return 1;
|
|
262
|
-
},
|
|
263
|
-
uvToY: function uvToY(u, v) {
|
|
264
|
-
return u;
|
|
265
|
-
},
|
|
266
|
-
uvToZ: function uvToZ(u, v) {
|
|
267
|
-
return v;
|
|
268
|
-
},
|
|
269
|
-
},
|
|
270
|
-
{
|
|
271
|
-
uvToX: function uvToX(u, v) {
|
|
272
|
-
return -u;
|
|
273
|
-
},
|
|
274
|
-
uvToY: function uvToY(u, v) {
|
|
275
|
-
return 1;
|
|
276
|
-
},
|
|
277
|
-
uvToZ: function uvToZ(u, v) {
|
|
278
|
-
return v;
|
|
279
|
-
},
|
|
280
|
-
},
|
|
281
|
-
{
|
|
282
|
-
uvToX: function uvToX(u, v) {
|
|
283
|
-
return -u;
|
|
284
|
-
},
|
|
285
|
-
uvToY: function uvToY(u, v) {
|
|
286
|
-
return -v;
|
|
287
|
-
},
|
|
288
|
-
uvToZ: function uvToZ(u, v) {
|
|
289
|
-
return 1;
|
|
290
|
-
},
|
|
291
|
-
},
|
|
292
|
-
{
|
|
293
|
-
uvToX: function uvToX(u, v) {
|
|
294
|
-
return -1;
|
|
295
|
-
},
|
|
296
|
-
uvToY: function uvToY(u, v) {
|
|
297
|
-
return -v;
|
|
298
|
-
},
|
|
299
|
-
uvToZ: function uvToZ(u, v) {
|
|
300
|
-
return -u;
|
|
301
|
-
},
|
|
302
|
-
},
|
|
303
|
-
{
|
|
304
|
-
uvToX: function uvToX(u, v) {
|
|
305
|
-
return v;
|
|
306
|
-
},
|
|
307
|
-
uvToY: function uvToY(u, v) {
|
|
308
|
-
return -1;
|
|
309
|
-
},
|
|
310
|
-
uvToZ: function uvToZ(u, v) {
|
|
311
|
-
return -u;
|
|
312
|
-
},
|
|
313
|
-
},
|
|
314
|
-
{
|
|
315
|
-
uvToX: function uvToX(u, v) {
|
|
316
|
-
return v;
|
|
317
|
-
},
|
|
318
|
-
uvToY: function uvToY(u, v) {
|
|
319
|
-
return u;
|
|
320
|
-
},
|
|
321
|
-
uvToZ: function uvToZ(u, v) {
|
|
322
|
-
return -1;
|
|
323
|
-
},
|
|
324
|
-
}
|
|
325
|
-
];
|
|
326
|
-
/**
|
|
327
|
-
* The maximum value of an si- or ti-coordinate. The range of valid (si,ti) values is
|
|
328
|
-
* [0..MAX_SiTi].
|
|
329
|
-
*/
|
|
330
|
-
S2Projections.MAX_SITI = Long.fromInt(1).shiftLeft(S2Projections.MAX_LEVEL + 1);
|
|
331
|
-
//# sourceMappingURL=S2Projections.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"S2Projections.js","sourceRoot":"","sources":["../src/S2Projections.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAGH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,6BAAoC;AACpC,yCAAsC;AACtC,uCAAoC;AACpC,yCAAsC;AAEtC,6BAA8B;AAE9B,IAAK,WAEJ;AAFD,WAAK,WAAW;IACd,6EAAoB,CAAA;IAAE,uEAAiB,CAAA;IAAE,mFAAuB,CAAA;AAClE,CAAC,EAFI,WAAW,KAAX,WAAW,QAEf;AAgBD,MAAa,aAAa;IAgLjB,MAAM,CAAC,QAAQ,CAAC,IAAY,EAAE,CAAS;QAC5C,QAAQ,IAAI,EAAE;YACZ,KAAK,CAAC;gBACJ,OAAO,IAAI,iBAA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C,OAAO,CAAC,CAAC,CAAC;QACZ,CAAC;KACF;IACD;QACE,KAAK,EAAE,SAAS,KAAK,CAAC,CAAS,EAAE,CAAS;YACxC,OAAO,CAAC,CAAC;QACX,CAAC;QAGD,KAAK,EAAE,SAAS,KAAK,CAAC,CAAS,EAAE,CAAS;YACxC,OAAO,CAAC,CAAC;QACX,CAAC;QAGD,KAAK,EAAE,SAAS,KAAK,CAAC,CAAS,EAAE,CAAS;YACxC,OAAO,CAAC,CAAC,CAAC;QACZ,CAAC;KACF;CACF,CAAC;AAEF;;;GAGG;AACW,sBAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,SAAS,GAAG,CAAC,CAAC,CAAA"}
|
package/dist/S2Region.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { S2Cell } from "./S2Cell";
|
|
2
|
-
import { S2Cap } from "./S2Cap";
|
|
3
|
-
/**
|
|
4
|
-
* An S2Region represents a two-dimensional region over the unit sphere. It is
|
|
5
|
-
* an abstract interface with various concrete subtypes.
|
|
6
|
-
*
|
|
7
|
-
* The main purpose of this interface is to allow complex regions to be
|
|
8
|
-
* approximated as simpler regions. So rather than having a wide variety of
|
|
9
|
-
* virtual methods that are implemented by all subtypes, the interface is
|
|
10
|
-
* restricted to methods that are useful for computing approximations.
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
|
-
export interface S2Region {
|
|
15
|
-
/** Return a bounding spherical cap. */
|
|
16
|
-
getCapBound(): S2Cap;
|
|
17
|
-
/** Return a bounding latitude-longitude rectangle. */
|
|
18
|
-
getRectBound(): any;
|
|
19
|
-
/**
|
|
20
|
-
* If this method returns true, the region completely contains the given cell.
|
|
21
|
-
* Otherwise, either the region does not contain the cell or the containment
|
|
22
|
-
* relationship could not be determined.
|
|
23
|
-
*/
|
|
24
|
-
containsC(cell: S2Cell): boolean;
|
|
25
|
-
/**
|
|
26
|
-
* If this method returns false, the region does not intersect the given cell.
|
|
27
|
-
* Otherwise, either region intersects the cell, or the intersection
|
|
28
|
-
* relationship could not be determined.
|
|
29
|
-
*/
|
|
30
|
-
mayIntersectC(cell: S2Cell): boolean;
|
|
31
|
-
}
|
package/dist/S2Region.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2005 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
|
-
//# sourceMappingURL=S2Region.js.map
|
package/dist/S2Region.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"S2Region.js","sourceRoot":"","sources":["../src/S2Region.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG"}
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { S2Region } from "./S2Region";
|
|
2
|
-
import { S2CellId } from "./S2CellId";
|
|
3
|
-
import { S2CellUnion } from "./S2CellUnion";
|
|
4
|
-
import { S2Point } from "./S2Point";
|
|
5
|
-
/**
|
|
6
|
-
* An S2RegionCoverer is a class that allows arbitrary regions to be
|
|
7
|
-
* approximated as unions of cells (S2CellUnion). This is useful for
|
|
8
|
-
* implementing various sorts of search and precomputation operations.
|
|
9
|
-
*
|
|
10
|
-
* Typical usage: {@code S2RegionCoverer coverer; coverer.setMaxCells(5); S2Cap
|
|
11
|
-
* cap = S2Cap.fromAxisAngle(...); S2CellUnion covering;
|
|
12
|
-
* coverer.getCovering(cap, covering); * }
|
|
13
|
-
*
|
|
14
|
-
* This yields a cell union of at most 5 cells that is guaranteed to cover the
|
|
15
|
-
* given cap (a disc-shaped region on the sphere).
|
|
16
|
-
*
|
|
17
|
-
* The approximation algorithm is not optimal but does a pretty good job in
|
|
18
|
-
* practice. The output does not always use the maximum number of cells allowed,
|
|
19
|
-
* both because this would not always yield a better approximation, and because
|
|
20
|
-
* max_cells() is a limit on how much work is done exploring the possible
|
|
21
|
-
* covering as well as a limit on the final output size.
|
|
22
|
-
*
|
|
23
|
-
* One can also generate interior coverings, which are sets of cells which are
|
|
24
|
-
* entirely contained within a region. Interior coverings can be empty, even for
|
|
25
|
-
* non-empty regions, if there are no cells that satisfy the provided
|
|
26
|
-
* constraints and are contained by the region. Note that for performance
|
|
27
|
-
* reasons, it is wise to specify a max_level when computing interior coverings
|
|
28
|
-
* - otherwise for regions with small or zero area, the algorithm may spend a
|
|
29
|
-
* lot of time subdividing cells all the way to leaf level to try to find
|
|
30
|
-
* contained cells.
|
|
31
|
-
*
|
|
32
|
-
* This class is thread-unsafe. Simultaneous calls to any of the getCovering
|
|
33
|
-
* methods will conflict and produce unpredictable results.
|
|
34
|
-
*
|
|
35
|
-
*/
|
|
36
|
-
export declare class S2RegionCoverer {
|
|
37
|
-
/**
|
|
38
|
-
* By default, the covering uses at most 8 cells at any level. This gives a
|
|
39
|
-
* reasonable tradeoff between the number of cells used and the accuracy of
|
|
40
|
-
* the approximation (see table below).
|
|
41
|
-
*/
|
|
42
|
-
static DEFAULT_MAX_CELLS: number;
|
|
43
|
-
private static FACE_CELLS;
|
|
44
|
-
private minLevel;
|
|
45
|
-
private maxLevel;
|
|
46
|
-
private levelMod;
|
|
47
|
-
private maxCells;
|
|
48
|
-
private interiorCovering;
|
|
49
|
-
private candidatesCreatedCounter;
|
|
50
|
-
/**
|
|
51
|
-
* We save a temporary copy of the pointer passed to GetCovering() in order to
|
|
52
|
-
* avoid passing this parameter around internally. It is only used (and only
|
|
53
|
-
* valid) for the duration of a single GetCovering() call.
|
|
54
|
-
*/
|
|
55
|
-
protected region: S2Region;
|
|
56
|
-
/**
|
|
57
|
-
* A temporary variable used by GetCovering() that holds the cell ids that
|
|
58
|
-
* have been added to the covering so far.
|
|
59
|
-
*/
|
|
60
|
-
protected result: S2CellId[];
|
|
61
|
-
/**
|
|
62
|
-
* We keep the candidates in a priority queue. We specify a vector to hold the
|
|
63
|
-
* queue entries since for some reason priority_queue<> uses a deque by
|
|
64
|
-
* default.
|
|
65
|
-
*/
|
|
66
|
-
private candidateQueue;
|
|
67
|
-
/**
|
|
68
|
-
* Default constructor, sets all fields to default values.
|
|
69
|
-
*/
|
|
70
|
-
constructor();
|
|
71
|
-
/**
|
|
72
|
-
* Sets the minimum level to be used.
|
|
73
|
-
*/
|
|
74
|
-
setMinLevel(minLevel: number): S2RegionCoverer;
|
|
75
|
-
/**
|
|
76
|
-
* Sets the maximum level to be used.
|
|
77
|
-
*/
|
|
78
|
-
setMaxLevel(maxLevel: number): S2RegionCoverer;
|
|
79
|
-
/**
|
|
80
|
-
* If specified, then only cells where (level - min_level) is a multiple of
|
|
81
|
-
* "level_mod" will be used (default 1). This effectively allows the branching
|
|
82
|
-
* factor of the S2CellId hierarchy to be increased. Currently the only
|
|
83
|
-
* parameter values allowed are 1, 2, or 3, corresponding to branching factors
|
|
84
|
-
* of 4, 16, and 64 respectively.
|
|
85
|
-
*/
|
|
86
|
-
setLevelMod(levelMod: number): S2RegionCoverer;
|
|
87
|
-
/**
|
|
88
|
-
* Sets the maximum desired number of cells in the approximation (defaults to
|
|
89
|
-
* kDefaultMaxCells). Note the following:
|
|
90
|
-
*
|
|
91
|
-
* <ul>
|
|
92
|
-
* <li>For any setting of max_cells(), up to 6 cells may be returned if that
|
|
93
|
-
* is the minimum number of cells required (e.g. if the region intersects all
|
|
94
|
-
* six face cells). Up to 3 cells may be returned even for very tiny convex
|
|
95
|
-
* regions if they happen to be located at the intersection of three cube
|
|
96
|
-
* faces.
|
|
97
|
-
*
|
|
98
|
-
* <li>For any setting of max_cells(), an arbitrary number of cells may be
|
|
99
|
-
* returned if min_level() is too high for the region being approximated.
|
|
100
|
-
*
|
|
101
|
-
* <li>If max_cells() is less than 4, the area of the covering may be
|
|
102
|
-
* arbitrarily large compared to the area of the original region even if the
|
|
103
|
-
* region is convex (e.g. an S2Cap or S2LatLngRect).
|
|
104
|
-
* </ul>
|
|
105
|
-
*
|
|
106
|
-
* Accuracy is measured by dividing the area of the covering by the area of
|
|
107
|
-
* the original region. The following table shows the median and worst case
|
|
108
|
-
* values for this area ratio on a test case consisting of 100,000 spherical
|
|
109
|
-
* caps of random size (generated using s2regioncoverer_unittest):
|
|
110
|
-
*
|
|
111
|
-
* <pre>
|
|
112
|
-
* max_cells: 3 4 5 6 8 12 20 100 1000
|
|
113
|
-
* median ratio: 5.33 3.32 2.73 2.34 1.98 1.66 1.42 1.11 1.01
|
|
114
|
-
* worst case: 215518 14.41 9.72 5.26 3.91 2.75 1.92 1.20 1.02
|
|
115
|
-
* </pre>
|
|
116
|
-
*/
|
|
117
|
-
setMaxCells(maxCells: number): S2RegionCoverer;
|
|
118
|
-
getMinLevel(): number;
|
|
119
|
-
getMaxLevel(): number;
|
|
120
|
-
getMaxCells(): number;
|
|
121
|
-
getLevelMod(): number;
|
|
122
|
-
/**
|
|
123
|
-
* Computes a list of cell ids that covers the given region and satisfies the
|
|
124
|
-
* various restrictions specified above.
|
|
125
|
-
*
|
|
126
|
-
* @param region The region to cover
|
|
127
|
-
* @param covering The list filled in by this method
|
|
128
|
-
*/
|
|
129
|
-
getCoveringCells(region: S2Region): S2CellId[];
|
|
130
|
-
/**
|
|
131
|
-
* Computes a list of cell ids that is contained within the given region and
|
|
132
|
-
* satisfies the various restrictions specified above.
|
|
133
|
-
*
|
|
134
|
-
* @param region The region to fill
|
|
135
|
-
* @param interior The list filled in by this method
|
|
136
|
-
*/
|
|
137
|
-
getInteriorCoveringCells(region: S2Region): S2CellId[];
|
|
138
|
-
/**
|
|
139
|
-
* Return a normalized cell union that covers the given region and satisfies
|
|
140
|
-
* the restrictions *EXCEPT* for min_level() and level_mod(). These criteria
|
|
141
|
-
* cannot be satisfied using a cell union because cell unions are
|
|
142
|
-
* automatically normalized by replacing four child cells with their parent
|
|
143
|
-
* whenever possible. (Note that the list of cell ids passed to the cell union
|
|
144
|
-
* constructor does in fact satisfy all the given restrictions.)
|
|
145
|
-
*/
|
|
146
|
-
getCoveringUnion(region: S2Region, covering?: S2CellUnion): S2CellUnion;
|
|
147
|
-
/**
|
|
148
|
-
* Return a normalized cell union that is contained within the given region
|
|
149
|
-
* and satisfies the restrictions *EXCEPT* for min_level() and level_mod().
|
|
150
|
-
*/
|
|
151
|
-
getInteriorCoveringUnion(region: S2Region, covering?: S2CellUnion): S2CellUnion;
|
|
152
|
-
/**
|
|
153
|
-
* Given a connected region and a starting point, return a set of cells at the given level that
|
|
154
|
-
* cover the region.
|
|
155
|
-
*/
|
|
156
|
-
static getSimpleCovering(region: S2Region, start: S2Point, level: number): S2CellId[];
|
|
157
|
-
/**
|
|
158
|
-
* If the cell intersects the given region, return a new candidate with no
|
|
159
|
-
* children, otherwise return null. Also marks the candidate as "terminal" if
|
|
160
|
-
* it should not be expanded further.
|
|
161
|
-
*/
|
|
162
|
-
private newCandidate;
|
|
163
|
-
/** Return the log base 2 of the maximum number of children of a candidate. */
|
|
164
|
-
private maxChildrenShift;
|
|
165
|
-
/**
|
|
166
|
-
* Process a candidate by either adding it to the result list or expanding its
|
|
167
|
-
* children and inserting it into the priority queue. Passing an argument of
|
|
168
|
-
* NULL does nothing.
|
|
169
|
-
*/
|
|
170
|
-
private addCandidate;
|
|
171
|
-
/**
|
|
172
|
-
* Populate the children of "candidate" by expanding the given number of
|
|
173
|
-
* levels from the given cell. Returns the number of children that were marked
|
|
174
|
-
* "terminal".
|
|
175
|
-
*/
|
|
176
|
-
private expandChildren;
|
|
177
|
-
/** Computes a set of initial candidates that cover the given region. */
|
|
178
|
-
private getInitialCandidates;
|
|
179
|
-
/** Generates a covering and stores it in result. */
|
|
180
|
-
private getCoveringInternal;
|
|
181
|
-
/**
|
|
182
|
-
* Given a region and a starting cell, return the set of all the edge-connected cells at the same
|
|
183
|
-
* level that intersect "region". The output cells are returned in arbitrary order.
|
|
184
|
-
*/
|
|
185
|
-
private static floodFill;
|
|
186
|
-
}
|