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/S2CellUnion.js
DELETED
|
@@ -1,523 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.S2CellUnion = void 0;
|
|
4
|
-
/*
|
|
5
|
-
* Copyright 2005 Google Inc.
|
|
6
|
-
*
|
|
7
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
* you may not use this file except in compliance with the License.
|
|
9
|
-
* You may obtain a copy of the License at
|
|
10
|
-
*
|
|
11
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
*
|
|
13
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
* See the License for the specific language governing permissions and
|
|
17
|
-
* limitations under the License.
|
|
18
|
-
*/
|
|
19
|
-
const Long = require("long");
|
|
20
|
-
const S2CellId_1 = require("./S2CellId");
|
|
21
|
-
const S2Cell_1 = require("./S2Cell");
|
|
22
|
-
const S2Projections_1 = require("./S2Projections");
|
|
23
|
-
const S2LatLngRect_1 = require("./S2LatLngRect");
|
|
24
|
-
const S2Point_1 = require("./S2Point");
|
|
25
|
-
const S2Cap_1 = require("./S2Cap");
|
|
26
|
-
const S1ChordAngle_1 = require("./S1ChordAngle");
|
|
27
|
-
/**
|
|
28
|
-
* An S2CellUnion is a region consisting of cells of various sizes. Typically a
|
|
29
|
-
* cell union is used to approximate some other shape. There is a tradeoff
|
|
30
|
-
* between the accuracy of the approximation and how many cells are used. Unlike
|
|
31
|
-
* polygons, cells have a fixed hierarchical structure. This makes them more
|
|
32
|
-
* suitable for optimizations based on preprocessing.
|
|
33
|
-
*
|
|
34
|
-
*/
|
|
35
|
-
class S2CellUnion {
|
|
36
|
-
constructor() {
|
|
37
|
-
/** The CellIds that form the Union */
|
|
38
|
-
this.cellIds = [];
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Populates a cell union with the given S2CellIds or 64-bit cells ids, and
|
|
42
|
-
* then calls Normalize(). The InitSwap() version takes ownership of the
|
|
43
|
-
* vector data without copying and clears the given vector. These methods may
|
|
44
|
-
* be called multiple times.
|
|
45
|
-
*/
|
|
46
|
-
initFromIds(cellIds) {
|
|
47
|
-
this.initRawIds(cellIds);
|
|
48
|
-
this.normalize();
|
|
49
|
-
}
|
|
50
|
-
initFromCellIds(cellIds) {
|
|
51
|
-
this.initRawCellIds(cellIds);
|
|
52
|
-
this.normalize();
|
|
53
|
-
}
|
|
54
|
-
initSwap(cellIds) {
|
|
55
|
-
this.initRawSwap(cellIds);
|
|
56
|
-
this.normalize();
|
|
57
|
-
}
|
|
58
|
-
initRawCellIds(cellIds) {
|
|
59
|
-
this.cellIds = cellIds;
|
|
60
|
-
}
|
|
61
|
-
initRawIds(cellIds) {
|
|
62
|
-
const size = cellIds.length;
|
|
63
|
-
this.cellIds = [];
|
|
64
|
-
for (let i = 0; i < size; i++) {
|
|
65
|
-
this.cellIds.push(new S2CellId_1.S2CellId(cellIds[i]));
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Like Init(), but does not call Normalize(). The cell union *must* be
|
|
70
|
-
* normalized before doing any calculations with it, so it is the caller's
|
|
71
|
-
* responsibility to make sure that the input is normalized. This method is
|
|
72
|
-
* useful when converting cell unions to another representation and back.
|
|
73
|
-
* These methods may be called multiple times.
|
|
74
|
-
*/
|
|
75
|
-
initRawSwap(cellIds) {
|
|
76
|
-
this.cellIds = [].concat(cellIds);
|
|
77
|
-
}
|
|
78
|
-
size() {
|
|
79
|
-
return this.cellIds.length;
|
|
80
|
-
}
|
|
81
|
-
/** Convenience methods for accessing the individual cell ids. */
|
|
82
|
-
cellId(i) {
|
|
83
|
-
return this.cellIds[i];
|
|
84
|
-
}
|
|
85
|
-
getCellIds() {
|
|
86
|
-
return this.cellIds;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Replaces "output" with an expanded version of the cell union where any
|
|
90
|
-
* cells whose level is less than "min_level" or where (level - min_level) is
|
|
91
|
-
* not a multiple of "level_mod" are replaced by their children, until either
|
|
92
|
-
* both of these conditions are satisfied or the maximum level is reached.
|
|
93
|
-
*
|
|
94
|
-
* This method allows a covering generated by S2RegionCoverer using
|
|
95
|
-
* min_level() or level_mod() constraints to be stored as a normalized cell
|
|
96
|
-
* union (which allows various geometric computations to be done) and then
|
|
97
|
-
* converted back to the original list of cell ids that satisfies the desired
|
|
98
|
-
* constraints.
|
|
99
|
-
*/
|
|
100
|
-
denormalize(minLevel, levelMod) {
|
|
101
|
-
// assert (minLevel >= 0 && minLevel <= S2CellId.MAX_LEVEL);
|
|
102
|
-
// assert (levelMod >= 1 && levelMod <= 3);
|
|
103
|
-
const output = [];
|
|
104
|
-
for (let i = 0; i < this.cellIds.length; i++) {
|
|
105
|
-
const id = this.cellIds[i];
|
|
106
|
-
const level = id.level();
|
|
107
|
-
let newLevel = Math.max(minLevel, level);
|
|
108
|
-
if (levelMod > 1) {
|
|
109
|
-
// Round up so that (new_level - min_level) is a multiple of level_mod.
|
|
110
|
-
// (Note that S2CellId::kMaxLevel is a multiple of 1, 2, and 3.)
|
|
111
|
-
newLevel += (S2CellId_1.S2CellId.MAX_LEVEL - (newLevel - minLevel)) % levelMod;
|
|
112
|
-
newLevel = Math.min(S2CellId_1.S2CellId.MAX_LEVEL, newLevel);
|
|
113
|
-
}
|
|
114
|
-
if (newLevel == level) {
|
|
115
|
-
output.push(id);
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
const end = id.childEndL(newLevel);
|
|
119
|
-
for (let iid = id.childBeginL(newLevel); !iid.equals(end); iid = iid.next()) {
|
|
120
|
-
output.push(iid);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return output;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* If there are more than "excess" elements of the cell_ids() vector that are
|
|
128
|
-
* allocated but unused, reallocate the array to eliminate the excess space.
|
|
129
|
-
* This reduces memory usage when many cell unions need to be held in memory
|
|
130
|
-
* at once.
|
|
131
|
-
*/
|
|
132
|
-
pack() {
|
|
133
|
-
throw new Error('useless');
|
|
134
|
-
// this.cellIds.trimToSize();
|
|
135
|
-
}
|
|
136
|
-
containsC(cell) {
|
|
137
|
-
return this.containsCell(cell);
|
|
138
|
-
}
|
|
139
|
-
mayIntersectC(cell) {
|
|
140
|
-
return this.mayIntersectCell(cell);
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Return true if the cell union contains the given cell id. Containment is
|
|
144
|
-
* defined with respect to regions, e.g. a cell contains its 4 children. This
|
|
145
|
-
* is a fast operation (logarithmic in the size of the cell union).
|
|
146
|
-
*/
|
|
147
|
-
contains(id) {
|
|
148
|
-
// This function requires that Normalize has been called first.
|
|
149
|
-
//
|
|
150
|
-
// This is an exact test. Each cell occupies a linear span of the S2
|
|
151
|
-
// space-filling curve, and the cell id is simply the position at the center
|
|
152
|
-
// of this span. The cell union ids are sorted in increasing order along
|
|
153
|
-
// the space-filling curve. So we simply find the pair of cell ids that
|
|
154
|
-
// surround the given cell id (using binary search). There is containment
|
|
155
|
-
// if and only if one of these two cell ids contains this cell.
|
|
156
|
-
let pos = S2CellId_1.S2CellId.binarySearch(this.cellIds, id.id);
|
|
157
|
-
if (pos < 0) {
|
|
158
|
-
pos = -pos - 1;
|
|
159
|
-
}
|
|
160
|
-
if (pos < this.cellIds.length && this.cellIds[pos].rangeMin().lessOrEquals(id)) {
|
|
161
|
-
return true;
|
|
162
|
-
}
|
|
163
|
-
return pos != 0 && this.cellIds[pos - 1].rangeMax().greaterOrEquals(id);
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Return true if the cell union intersects the given cell id. This is a fast
|
|
167
|
-
* operation (logarithmic in the size of the cell union).
|
|
168
|
-
*/
|
|
169
|
-
intersects(id) {
|
|
170
|
-
// This function requires that Normalize has been called first.
|
|
171
|
-
// This is an exact test; see the comments for Contains() above.
|
|
172
|
-
let pos = S2CellId_1.S2CellId.binarySearch(this.cellIds, id.id);
|
|
173
|
-
if (pos < 0) {
|
|
174
|
-
pos = -pos - 1;
|
|
175
|
-
}
|
|
176
|
-
if (pos < this.cellIds.length && this.cellIds[pos].rangeMin().lessOrEquals(id.rangeMax())) {
|
|
177
|
-
return true;
|
|
178
|
-
}
|
|
179
|
-
return pos != 0 && this.cellIds[pos - 1].rangeMax().greaterOrEquals(id.rangeMin());
|
|
180
|
-
}
|
|
181
|
-
containsUnion(that) {
|
|
182
|
-
// A divide-and-conquer or alternating-skip-search approach
|
|
183
|
-
// may be significantly faster in both the average and worst case.
|
|
184
|
-
for (let i = 0; i < that.cellIds.length; i++) {
|
|
185
|
-
if (!this.contains(that.cellIds[i])) {
|
|
186
|
-
return false;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return true;
|
|
190
|
-
}
|
|
191
|
-
/** This is a fast operation (logarithmic in the size of the cell union). */
|
|
192
|
-
containsCell(cell) {
|
|
193
|
-
return this.contains(cell.id);
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Return true if this cell union contain/intersects the given other cell
|
|
197
|
-
* union.
|
|
198
|
-
*/
|
|
199
|
-
intersectsUnion(that) {
|
|
200
|
-
// A divide-and-conquer or alternating-skip-search approach
|
|
201
|
-
// may be significantly faster in both the average and worst case.
|
|
202
|
-
for (let i = 0; i < that.cellIds.length; i++) {
|
|
203
|
-
if (!this.intersects(that.cellIds[i])) {
|
|
204
|
-
return false;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
return true;
|
|
208
|
-
}
|
|
209
|
-
getUnion(x, y) {
|
|
210
|
-
// assert (x != this && y != this);
|
|
211
|
-
this.cellIds = [].concat(x.cellIds).concat(y.cellIds);
|
|
212
|
-
this.normalize();
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Specialized version of GetIntersection() that gets the intersection of a
|
|
216
|
-
* cell union with the given cell id. This can be useful for "splitting" a
|
|
217
|
-
* cell union into chunks.
|
|
218
|
-
*/
|
|
219
|
-
getIntersection(x, id) {
|
|
220
|
-
// assert (x != this);
|
|
221
|
-
this.cellIds = [];
|
|
222
|
-
if (x.contains(id)) {
|
|
223
|
-
this.cellIds.push(id);
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
let pos = S2CellId_1.S2CellId.binarySearch(x.cellIds, id.rangeMin().id);
|
|
227
|
-
if (pos < 0) {
|
|
228
|
-
pos = -pos - 1;
|
|
229
|
-
}
|
|
230
|
-
const idmax = id.rangeMax();
|
|
231
|
-
const size = x.cellIds.length;
|
|
232
|
-
while (pos < size && x.cellIds[pos].lessOrEquals(idmax)) {
|
|
233
|
-
this.cellIds.push(x.cellIds[(pos++)]);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Initialize this cell union to the union or intersection of the two given
|
|
239
|
-
* cell unions. Requires: x != this and y != this.
|
|
240
|
-
*/
|
|
241
|
-
getIntersectionUU(x, y) {
|
|
242
|
-
// assert (x != this && y != this);
|
|
243
|
-
// This is a fairly efficient calculation that uses binary search to skip
|
|
244
|
-
// over sections of both input vectors. It takes constant time if all the
|
|
245
|
-
// cells of "x" come before or after all the cells of "y" in S2CellId order.
|
|
246
|
-
this.cellIds = [];
|
|
247
|
-
let i = 0;
|
|
248
|
-
let j = 0;
|
|
249
|
-
while (i < x.cellIds.length && j < y.cellIds.length) {
|
|
250
|
-
const imin = x.cellId(i).rangeMin();
|
|
251
|
-
const jmin = y.cellId(j).rangeMin();
|
|
252
|
-
if (imin.greaterThan(jmin)) {
|
|
253
|
-
// Either j->contains(*i) or the two cells are disjoint.
|
|
254
|
-
if (x.cellId(i).lessOrEquals(y.cellId(j).rangeMax())) {
|
|
255
|
-
this.cellIds.push(x.cellId(i++));
|
|
256
|
-
}
|
|
257
|
-
else {
|
|
258
|
-
// Advance "j" to the first cell possibly contained by *i.
|
|
259
|
-
j = S2CellId_1.S2CellId.indexedBinarySearch(y.cellIds, imin, j + 1);
|
|
260
|
-
// The previous cell *(j-1) may now contain *i.
|
|
261
|
-
if (x.cellId(i).lessOrEquals(y.cellId(j - 1).rangeMax())) {
|
|
262
|
-
--j;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
else if (jmin.greaterThan(imin)) {
|
|
267
|
-
// Identical to the code above with "i" and "j" reversed.
|
|
268
|
-
if (y.cellId(j).lessOrEquals(x.cellId(i).rangeMax())) {
|
|
269
|
-
this.cellIds.push(y.cellId(j++));
|
|
270
|
-
}
|
|
271
|
-
else {
|
|
272
|
-
i = S2CellId_1.S2CellId.indexedBinarySearch(x.cellIds, jmin, i + 1);
|
|
273
|
-
if (y.cellId(j).lessOrEquals(x.cellId(i - 1).rangeMax())) {
|
|
274
|
-
--i;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
else {
|
|
279
|
-
// "i" and "j" have the same range_min(), so one contains the other.
|
|
280
|
-
if (x.cellId(i).lessThan(y.cellId(j))) {
|
|
281
|
-
this.cellIds.push(x.cellId(i++));
|
|
282
|
-
}
|
|
283
|
-
else {
|
|
284
|
-
this.cellIds.push(y.cellId(j++));
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
// The output is generated in sorted order, and there should not be any
|
|
289
|
-
// cells that can be merged (provided that both inputs were normalized).
|
|
290
|
-
// assert (!normalize());
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* Expands the cell union such that it contains all cells of the given level
|
|
294
|
-
* that are adjacent to any cell of the original union. Two cells are defined
|
|
295
|
-
* as adjacent if their boundaries have any points in common, i.e. most cells
|
|
296
|
-
* have 8 adjacent cells (not counting the cell itself).
|
|
297
|
-
*
|
|
298
|
-
* Note that the size of the output is exponential in "level". For example,
|
|
299
|
-
* if level == 20 and the input has a cell at level 10, there will be on the
|
|
300
|
-
* order of 4000 adjacent cells in the output. For most applications the
|
|
301
|
-
* Expand(min_fraction, min_distance) method below is easier to use.
|
|
302
|
-
*/
|
|
303
|
-
expand(level) {
|
|
304
|
-
let output = [];
|
|
305
|
-
const levelLsb = S2CellId_1.S2CellId.lowestOnBitForLevel(level);
|
|
306
|
-
let i = this.size() - 1;
|
|
307
|
-
do {
|
|
308
|
-
let id = this.cellId(i);
|
|
309
|
-
if (id.lowestOnBit().lessThan(levelLsb)) {
|
|
310
|
-
id = id.parentL(level);
|
|
311
|
-
// Optimization: skip over any cells contained by this one. This is
|
|
312
|
-
// especially important when very small regions are being expanded.
|
|
313
|
-
while (i > 0 && id.contains(this.cellId(i - 1))) {
|
|
314
|
-
--i;
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
output.push(id);
|
|
318
|
-
output = output.concat(id.getAllNeighbors(level));
|
|
319
|
-
} while (--i >= 0);
|
|
320
|
-
this.initSwap(output);
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* Expand the cell union such that it contains all points whose distance to
|
|
324
|
-
* the cell union is at most minRadius, but do not use cells that are more
|
|
325
|
-
* than maxLevelDiff levels higher than the largest cell in the input. The
|
|
326
|
-
* second parameter controls the tradeoff between accuracy and output size
|
|
327
|
-
* when a large region is being expanded by a small amount (e.g. expanding
|
|
328
|
-
* Canada by 1km).
|
|
329
|
-
*
|
|
330
|
-
* For example, if maxLevelDiff == 4, the region will always be expanded by
|
|
331
|
-
* approximately 1/16 the width of its largest cell. Note that in the worst
|
|
332
|
-
* case, the number of cells in the output can be up to 4 * (1 + 2 **
|
|
333
|
-
* maxLevelDiff) times larger than the number of cells in the input.
|
|
334
|
-
*/
|
|
335
|
-
expandA(minRadius, maxLevelDiff) {
|
|
336
|
-
let minLevel = S2CellId_1.S2CellId.MAX_LEVEL;
|
|
337
|
-
for (let i = 0; i < this.cellIds.length; i++) {
|
|
338
|
-
const id = this.cellId(i);
|
|
339
|
-
minLevel = Math.min(minLevel, id.level());
|
|
340
|
-
}
|
|
341
|
-
// Find the maximum level such that all cells are at least "min_radius"
|
|
342
|
-
// wide.
|
|
343
|
-
const radiusLevel = S2Projections_1.S2Projections.MIN_WIDTH.getMaxLevel(minRadius.radians);
|
|
344
|
-
if (radiusLevel == 0 && minRadius.radians > (S2Projections_1.S2Projections.MIN_WIDTH.getValue(0))) {
|
|
345
|
-
// The requested expansion is greater than the width of a face cell.
|
|
346
|
-
// The easiest way to handle this is to expand twice.
|
|
347
|
-
this.expand(0);
|
|
348
|
-
}
|
|
349
|
-
this.expand(Math.min(minLevel + maxLevelDiff, radiusLevel));
|
|
350
|
-
}
|
|
351
|
-
getCapBound() {
|
|
352
|
-
// Compute the approximate centroid of the region. This won't produce the
|
|
353
|
-
// bounding cap of minimal area, but it should be close enough.
|
|
354
|
-
if (this.cellIds.length == 0) {
|
|
355
|
-
return S2Cap_1.S2Cap.empty();
|
|
356
|
-
}
|
|
357
|
-
let centroid = new S2Point_1.S2Point(0, 0, 0);
|
|
358
|
-
this.cellIds.forEach(id => {
|
|
359
|
-
const area = S2Cell_1.S2Cell.averageArea(id.level());
|
|
360
|
-
centroid = S2Point_1.S2Point.add(centroid, S2Point_1.S2Point.mul(id.toPoint(), area));
|
|
361
|
-
});
|
|
362
|
-
if (centroid.equals(S2Point_1.S2Point.ORIGIN)) {
|
|
363
|
-
centroid = S2Point_1.S2Point.X_POS;
|
|
364
|
-
}
|
|
365
|
-
else {
|
|
366
|
-
centroid = S2Point_1.S2Point.normalize(centroid);
|
|
367
|
-
}
|
|
368
|
-
// Use the centroid as the cap axis, and expand the cap angle so that it
|
|
369
|
-
// contains the bounding caps of all the individual cells. Note that it is
|
|
370
|
-
// *not* sufficient to just bound all the cell vertices because the bounding
|
|
371
|
-
// cap may be concave (i.e. cover more than one hemisphere).
|
|
372
|
-
let cap = S2Cap_1.S2Cap.fromAxisChord(centroid, S1ChordAngle_1.S1ChordAngle.ZERO);
|
|
373
|
-
this.cellIds.forEach(id => {
|
|
374
|
-
cap = cap.addCap(new S2Cell_1.S2Cell(id).getCapBound());
|
|
375
|
-
});
|
|
376
|
-
return cap;
|
|
377
|
-
}
|
|
378
|
-
getRectBound() {
|
|
379
|
-
let bound = S2LatLngRect_1.S2LatLngRect.empty();
|
|
380
|
-
this.cellIds.forEach(id => {
|
|
381
|
-
bound = bound.union(new S2Cell_1.S2Cell(id).getRectBound());
|
|
382
|
-
});
|
|
383
|
-
return bound;
|
|
384
|
-
}
|
|
385
|
-
/** This is a fast operation (logarithmic in the size of the cell union). */
|
|
386
|
-
mayIntersectCell(cell) {
|
|
387
|
-
return this.intersects(cell.id);
|
|
388
|
-
}
|
|
389
|
-
/**
|
|
390
|
-
* The point 'p' does not need to be normalized. This is a fast operation
|
|
391
|
-
* (logarithmic in the size of the cell union).
|
|
392
|
-
*/
|
|
393
|
-
containsPoint(p) {
|
|
394
|
-
return this.contains(S2CellId_1.S2CellId.fromPoint(p));
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* The number of leaf cells covered by the union.
|
|
398
|
-
* This will be no more than 6*2^60 for the whole sphere.
|
|
399
|
-
*
|
|
400
|
-
* @return the number of leaf cells covered by the union
|
|
401
|
-
*/
|
|
402
|
-
leafCellsCovered() {
|
|
403
|
-
let numLeaves = new Long(0);
|
|
404
|
-
this.cellIds.forEach((id) => {
|
|
405
|
-
const invertedLevel = S2CellId_1.S2CellId.MAX_LEVEL - id.level();
|
|
406
|
-
numLeaves = numLeaves
|
|
407
|
-
.add(new Long(1).shiftLeft(invertedLevel << 1));
|
|
408
|
-
});
|
|
409
|
-
return numLeaves;
|
|
410
|
-
}
|
|
411
|
-
/**
|
|
412
|
-
* Approximate this cell union's area by summing the average area of
|
|
413
|
-
* each contained cell's average area, using {@link S2Cell#averageArea()}.
|
|
414
|
-
* This is equivalent to the number of leaves covered, multiplied by
|
|
415
|
-
* the average area of a leaf.
|
|
416
|
-
* Note that {@link S2Cell#averageArea()} does not take into account
|
|
417
|
-
* distortion of cell, and thus may be off by up to a factor of 1.7.
|
|
418
|
-
* NOTE: Since this is proportional to LeafCellsCovered(), it is
|
|
419
|
-
* always better to use the other function if all you care about is
|
|
420
|
-
* the relative average area between objects.
|
|
421
|
-
*
|
|
422
|
-
* @return the sum of the average area of each contained cell's average area
|
|
423
|
-
*/
|
|
424
|
-
averageBasedArea() {
|
|
425
|
-
return this.leafCellsCovered().mul(S2Projections_1.S2Projections.AVG_AREA.getValue(S2CellId_1.S2CellId.MAX_LEVEL)).toNumber();
|
|
426
|
-
}
|
|
427
|
-
/**
|
|
428
|
-
* Calculates this cell union's area by summing the approximate area for each
|
|
429
|
-
* contained cell, using {@link S2Cell#approxArea()}.
|
|
430
|
-
*
|
|
431
|
-
* @return approximate area of the cell union
|
|
432
|
-
*/
|
|
433
|
-
approxArea() {
|
|
434
|
-
let area = 0;
|
|
435
|
-
this.cellIds.forEach(id => {
|
|
436
|
-
area = area + (new S2Cell_1.S2Cell(id).approxArea());
|
|
437
|
-
});
|
|
438
|
-
return area;
|
|
439
|
-
}
|
|
440
|
-
/**
|
|
441
|
-
* Calculates this cell union's area by summing the exact area for each
|
|
442
|
-
* contained cell, using the {@link S2Cell#exactArea()}.
|
|
443
|
-
*
|
|
444
|
-
* @return the exact area of the cell union
|
|
445
|
-
*/
|
|
446
|
-
exactArea() {
|
|
447
|
-
let area = 0;
|
|
448
|
-
this.cellIds.forEach(id => {
|
|
449
|
-
area = area + new S2Cell_1.S2Cell(id).exactArea();
|
|
450
|
-
});
|
|
451
|
-
return area;
|
|
452
|
-
}
|
|
453
|
-
/**
|
|
454
|
-
* Normalizes the cell union by discarding cells that are contained by other
|
|
455
|
-
* cells, replacing groups of 4 child cells by their parent cell whenever
|
|
456
|
-
* possible, and sorting all the cell ids in increasing order. Returns true if
|
|
457
|
-
* the number of cells was reduced.
|
|
458
|
-
*
|
|
459
|
-
* This method *must* be called before doing any calculations on the cell
|
|
460
|
-
* union, such as Intersects() or Contains().
|
|
461
|
-
*
|
|
462
|
-
* @return true if the normalize operation had any effect on the cell union,
|
|
463
|
-
* false if the union was already normalized
|
|
464
|
-
*/
|
|
465
|
-
normalize() {
|
|
466
|
-
// Optimize the representation by looking for cases where all subcells
|
|
467
|
-
// of a parent cell are present.
|
|
468
|
-
const output = [];
|
|
469
|
-
// ArrayList<S2CellId> output = new ArrayList<>(this.cellIds.size());
|
|
470
|
-
// output.ensureCapacity(this.cellIds.size());
|
|
471
|
-
this.cellIds.sort((a, b) => a.compareTo(b));
|
|
472
|
-
// Collections.sort(this.cellIds);
|
|
473
|
-
this.cellIds.forEach(id => {
|
|
474
|
-
let size = output.length;
|
|
475
|
-
// Check whether this cell is contained by the previous cell.
|
|
476
|
-
if (output.length !== 0 && output[size - 1].contains(id)) {
|
|
477
|
-
return;
|
|
478
|
-
}
|
|
479
|
-
// Discard any previous cells contained by this cell.
|
|
480
|
-
while (output.length !== 0 && id.contains(output[output.length - 1])) {
|
|
481
|
-
output.splice(output.length - 1, 1);
|
|
482
|
-
// output.remove(output.size() - 1);
|
|
483
|
-
}
|
|
484
|
-
// Check whether the last 3 elements of "output" plus "id" can be
|
|
485
|
-
// collapsed into a single parent cell.
|
|
486
|
-
while (output.length >= 3) {
|
|
487
|
-
size = output.length;
|
|
488
|
-
// A necessary (but not sufficient) condition is that the XOR of the
|
|
489
|
-
// four cells must be zero. This is also very fast to test.
|
|
490
|
-
if ((output[size - 3].id.xor(output[size - 2].id).xor(output[size - 1].id)).notEquals(id.id)) {
|
|
491
|
-
break;
|
|
492
|
-
}
|
|
493
|
-
// Now we do a slightly more expensive but exact test. First, compute a
|
|
494
|
-
// mask that blocks out the two bits that encode the child position of
|
|
495
|
-
// "id" with respect to its parent, then check that the other three
|
|
496
|
-
// children all agree with "mask.
|
|
497
|
-
let mask = id.lowestOnBit().shiftLeft(1);
|
|
498
|
-
mask = mask.add(mask.shiftLeft(1)).not();
|
|
499
|
-
// mask = ~(mask + (mask << 1));
|
|
500
|
-
const idMasked = id.id.and(mask);
|
|
501
|
-
if ((output[size - 3].id.and(mask)).notEquals(idMasked)
|
|
502
|
-
|| (output[size - 2].id.and(mask)).notEquals(idMasked)
|
|
503
|
-
|| (output[size - 1].id.and(mask)).notEquals(idMasked) || id.isFace()) {
|
|
504
|
-
break;
|
|
505
|
-
}
|
|
506
|
-
// Replace four children by their parent cell.
|
|
507
|
-
output.splice(size - 3);
|
|
508
|
-
// output.remove(size - 1);
|
|
509
|
-
// output.remove(size - 2);
|
|
510
|
-
// output.remove(size - 3);
|
|
511
|
-
id = id.parent();
|
|
512
|
-
}
|
|
513
|
-
output.push(id);
|
|
514
|
-
});
|
|
515
|
-
if (output.length < this.size()) {
|
|
516
|
-
this.initRawSwap(output);
|
|
517
|
-
return true;
|
|
518
|
-
}
|
|
519
|
-
return false;
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
exports.S2CellUnion = S2CellUnion;
|
|
523
|
-
//# sourceMappingURL=S2CellUnion.js.map
|
package/dist/S2CellUnion.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"S2CellUnion.js","sourceRoot":"","sources":["../src/S2CellUnion.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,6BAA6B;AAE7B,yCAAoC;AACpC,qCAAgC;AAEhC,mDAA8C;AAC9C,iDAA4C;AAC5C,uCAAkC;AAClC,mCAA8B;AAC9B,iDAA8C;AAC9C;;;;;;;GAOG;AACH,MAAa,WAAW;IAAxB;QAGE,sCAAsC;QAC9B,YAAO,GAAc,EAAE,CAAC;IAuhBlC,CAAC;IArhBC;;;;;OAKG;IACI,WAAW,CAAC,OAAuB;QACxC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACzB,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAEM,eAAe,CAAC,OAAkB;QACvC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAC7B,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAEM,QAAQ,CAAC,OAAkB;QAChC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAC1B,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAEM,cAAc,CAAC,OAAkB;QACtC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAEM,UAAU,CAAC,OAAuB;QACvC,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,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AI,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC;uBACnD,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE;oBACzE,MAAM;iBACP;gBAED,8CAA8C;gBAC9C,MAAM,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;gBACxB,2BAA2B;gBAC3B,2BAA2B;gBAC3B,2BAA2B;gBAC3B,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC;aAClB;YACD,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;QAEH,IAAI,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,EAAE;YAC/B,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YACzB,OAAO,IAAI,CAAC;SACb;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA3hBD,kCA2hBC"}
|
package/dist/S2EdgeUtil.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { S2Point } from "./S2Point";
|
|
2
|
-
import { S1Angle } from "./S1Angle";
|
|
3
|
-
/**
|
|
4
|
-
* This class contains various utility functions related to edges. It collects
|
|
5
|
-
* together common code that is needed to implement polygonal geometry such as
|
|
6
|
-
* polylines, loops, and general polygons.
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
export declare class S2EdgeUtil {
|
|
10
|
-
/**
|
|
11
|
-
* A slightly more efficient version of getDistance() where the cross product
|
|
12
|
-
* of the two endpoints has been precomputed. The cross product does not need
|
|
13
|
-
* to be normalized, but should be computed using S2.robustCrossProd() for the
|
|
14
|
-
* most accurate results.
|
|
15
|
-
*/
|
|
16
|
-
static getDistance(x: S2Point, a: S2Point, b: S2Point, aCrossB?: S2Point): S1Angle;
|
|
17
|
-
}
|