nodes2ts 2.0.0 → 4.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/LICENSE +21 -0
- package/README.md +116 -13
- package/dist/export.cjs +5331 -0
- package/dist/export.cjs.map +1 -0
- package/dist/export.d.cts +1838 -0
- package/dist/export.d.ts +1828 -20
- package/dist/export.js +5279 -51
- package/dist/export.js.map +1 -1
- package/package.json +34 -49
- package/dist/Interval.d.ts +0 -24
- package/dist/Interval.js +0 -22
- package/dist/Interval.js.map +0 -1
- package/dist/MutableInteger.d.ts +0 -4
- package/dist/MutableInteger.js +0 -9
- package/dist/MutableInteger.js.map +0 -1
- package/dist/R1Interval.d.ts +0 -76
- package/dist/R1Interval.js +0 -167
- package/dist/R1Interval.js.map +0 -1
- package/dist/R2Vector.d.ts +0 -34
- package/dist/R2Vector.js +0 -138
- package/dist/R2Vector.js.map +0 -1
- package/dist/S1Angle.d.ts +0 -26
- package/dist/S1Angle.js +0 -78
- package/dist/S1Angle.js.map +0 -1
- package/dist/S1Interval.d.ts +0 -109
- package/dist/S1Interval.js +0 -403
- package/dist/S1Interval.js.map +0 -1
- package/dist/S2.d.ts +0 -91
- package/dist/S2.js +0 -236
- package/dist/S2.js.map +0 -1
- package/dist/S2Cap.d.ts +0 -113
- package/dist/S2Cap.js +0 -392
- package/dist/S2Cap.js.map +0 -1
- package/dist/S2Cell.d.ts +0 -103
- package/dist/S2Cell.js +0 -361
- package/dist/S2Cell.js.map +0 -1
- package/dist/S2CellId.d.ts +0 -267
- package/dist/S2CellId.js +0 -933
- package/dist/S2CellId.js.map +0 -1
- package/dist/S2CellUnion.d.ts +0 -180
- package/dist/S2CellUnion.js +0 -518
- package/dist/S2CellUnion.js.map +0 -1
- package/dist/S2EdgeUtil.d.ts +0 -17
- package/dist/S2EdgeUtil.js +0 -787
- package/dist/S2EdgeUtil.js.map +0 -1
- package/dist/S2LatLng.d.ts +0 -72
- package/dist/S2LatLng.js +0 -182
- package/dist/S2LatLng.js.map +0 -1
- package/dist/S2LatLngRect.d.ts +0 -185
- package/dist/S2LatLngRect.js +0 -605
- package/dist/S2LatLngRect.js.map +0 -1
- package/dist/S2Metric.d.ts +0 -38
- package/dist/S2Metric.js +0 -75
- package/dist/S2Metric.js.map +0 -1
- package/dist/S2Point.d.ts +0 -43
- package/dist/S2Point.js +0 -200
- package/dist/S2Point.js.map +0 -1
- package/dist/S2Projections.d.ts +0 -67
- package/dist/S2Projections.js +0 -152
- package/dist/S2Projections.js.map +0 -1
- package/dist/S2Region.d.ts +0 -31
- package/dist/S2Region.js +0 -17
- package/dist/S2Region.js.map +0 -1
- package/dist/S2RegionCoverer.d.ts +0 -171
- package/dist/S2RegionCoverer.js +0 -435
- package/dist/S2RegionCoverer.js.map +0 -1
- package/yarn.lock +0 -4381
package/dist/S2Cell.js
DELETED
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var Long = require('long');
|
|
3
|
-
var S2CellId_1 = require("./S2CellId");
|
|
4
|
-
var S2Point_1 = require("./S2Point");
|
|
5
|
-
var S2LatLng_1 = require("./S2LatLng");
|
|
6
|
-
var S2Projections_1 = require("./S2Projections");
|
|
7
|
-
var R2Vector_1 = require("./R2Vector");
|
|
8
|
-
var MutableInteger_1 = require("./MutableInteger");
|
|
9
|
-
var S2_1 = require("./S2");
|
|
10
|
-
var S2LatLngRect_1 = require("./S2LatLngRect");
|
|
11
|
-
var R1Interval_1 = require("./R1Interval");
|
|
12
|
-
var S1Interval_1 = require("./S1Interval");
|
|
13
|
-
var S2Cap_1 = require("./S2Cap");
|
|
14
|
-
var S2Cell = (function () {
|
|
15
|
-
function S2Cell(cellID) {
|
|
16
|
-
this.cellID = cellID;
|
|
17
|
-
this._uv = [];
|
|
18
|
-
this._uv.push([]);
|
|
19
|
-
this._uv.push([]);
|
|
20
|
-
this.init(cellID);
|
|
21
|
-
}
|
|
22
|
-
Object.defineProperty(S2Cell.prototype, "id", {
|
|
23
|
-
get: function () {
|
|
24
|
-
return this.cellID;
|
|
25
|
-
},
|
|
26
|
-
enumerable: true,
|
|
27
|
-
configurable: true
|
|
28
|
-
});
|
|
29
|
-
Object.defineProperty(S2Cell.prototype, "face", {
|
|
30
|
-
get: function () {
|
|
31
|
-
return this._face;
|
|
32
|
-
},
|
|
33
|
-
enumerable: true,
|
|
34
|
-
configurable: true
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(S2Cell.prototype, "level", {
|
|
37
|
-
get: function () {
|
|
38
|
-
return this._level;
|
|
39
|
-
},
|
|
40
|
-
enumerable: true,
|
|
41
|
-
configurable: true
|
|
42
|
-
});
|
|
43
|
-
Object.defineProperty(S2Cell.prototype, "orientation", {
|
|
44
|
-
get: function () {
|
|
45
|
-
return this._orientation;
|
|
46
|
-
},
|
|
47
|
-
enumerable: true,
|
|
48
|
-
configurable: true
|
|
49
|
-
});
|
|
50
|
-
// This is a static method in order to provide named parameters.
|
|
51
|
-
S2Cell.fromFacePosLevel = function (face, pos, level) {
|
|
52
|
-
return new S2Cell(S2CellId_1.S2CellId.fromFacePosLevel(face, new Long(pos), level));
|
|
53
|
-
};
|
|
54
|
-
// Convenience methods.
|
|
55
|
-
S2Cell.fromPoint = function (p) {
|
|
56
|
-
return new S2Cell(S2CellId_1.S2CellId.fromPoint(p));
|
|
57
|
-
};
|
|
58
|
-
S2Cell.fromLatLng = function (ll) {
|
|
59
|
-
return new S2Cell(S2CellId_1.S2CellId.fromPoint(ll.toPoint()));
|
|
60
|
-
};
|
|
61
|
-
S2Cell.prototype.isLeaf = function () {
|
|
62
|
-
return this.level == S2CellId_1.S2CellId.MAX_LEVEL;
|
|
63
|
-
};
|
|
64
|
-
S2Cell.prototype.getVertex = function (k) {
|
|
65
|
-
return S2Point_1.S2Point.normalize(this.getVertexRaw(k));
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* Return the k-th vertex of the cell (k = 0,1,2,3). Vertices are returned in
|
|
69
|
-
* CCW order. The points returned by GetVertexRaw are not necessarily unit
|
|
70
|
-
* length.
|
|
71
|
-
*/
|
|
72
|
-
S2Cell.prototype.getVertexRaw = function (k) {
|
|
73
|
-
// Vertices are returned in the order SW, SE, NE, NW.
|
|
74
|
-
return new R2Vector_1.R2Vector(this._uv[0][(k >> 1) ^ (k & 1)], this._uv[1][k >> 1])
|
|
75
|
-
.toPoint(this.face);
|
|
76
|
-
// return S2Projections.faceUvToXyz(this.face, );
|
|
77
|
-
};
|
|
78
|
-
S2Cell.prototype.getEdge = function (k) {
|
|
79
|
-
return S2Point_1.S2Point.normalize(this.getEdgeRaw(k));
|
|
80
|
-
};
|
|
81
|
-
S2Cell.prototype.getEdgeRaw = function (k) {
|
|
82
|
-
switch (k) {
|
|
83
|
-
case 0:
|
|
84
|
-
return S2Projections_1.S2Projections.getVNorm(this.face, this._uv[1][0]); // South
|
|
85
|
-
case 1:
|
|
86
|
-
return S2Projections_1.S2Projections.getUNorm(this.face, this._uv[0][1]); // East
|
|
87
|
-
case 2:
|
|
88
|
-
return S2Point_1.S2Point.neg(S2Projections_1.S2Projections.getVNorm(this.face, this._uv[1][1])); // North
|
|
89
|
-
default:
|
|
90
|
-
return S2Point_1.S2Point.neg(S2Projections_1.S2Projections.getUNorm(this.face, this._uv[0][0])); // West
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
/**
|
|
94
|
-
* Return the inward-facing normal of the great circle passing through the
|
|
95
|
-
* edge from vertex k to vertex k+1 (mod 4). The normals returned by
|
|
96
|
-
* GetEdgeRaw are not necessarily unit length.
|
|
97
|
-
*
|
|
98
|
-
* If this is not a leaf cell, set children[0..3] to the four children of
|
|
99
|
-
* this cell (in traversal order) and return true. Otherwise returns false.
|
|
100
|
-
* This method is equivalent to the following:
|
|
101
|
-
*
|
|
102
|
-
* for (pos=0, id=child_begin(); id != child_end(); id = id.next(), ++pos)
|
|
103
|
-
* children[i] = S2Cell(id);
|
|
104
|
-
*
|
|
105
|
-
* except that it is more than two times faster.
|
|
106
|
-
*/
|
|
107
|
-
S2Cell.prototype.subdivide = function () {
|
|
108
|
-
// This function is equivalent to just iterating over the child cell ids
|
|
109
|
-
// and calling the S2Cell constructor, but it is about 2.5 times faster.
|
|
110
|
-
if (this.isLeaf()) {
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
|
-
// Compute the cell midpoint in uv-space.
|
|
114
|
-
// const uvMid = this.getCenterUV();
|
|
115
|
-
var children = new Array(4);
|
|
116
|
-
// Create four children with the appropriate bounds.
|
|
117
|
-
var id = this.cellID.childBegin();
|
|
118
|
-
for (var pos = 0; pos < 4; ++pos, id = id.next()) {
|
|
119
|
-
children[pos] = new S2Cell(id);
|
|
120
|
-
}
|
|
121
|
-
return children;
|
|
122
|
-
};
|
|
123
|
-
/**
|
|
124
|
-
* Return the direction vector corresponding to the center in (s,t)-space of
|
|
125
|
-
* the given cell. This is the point at which the cell is divided into four
|
|
126
|
-
* subcells; it is not necessarily the centroid of the cell in (u,v)-space or
|
|
127
|
-
* (x,y,z)-space. The point returned by GetCenterRaw is not necessarily unit
|
|
128
|
-
* length.
|
|
129
|
-
*/
|
|
130
|
-
S2Cell.prototype.getCenter = function () {
|
|
131
|
-
return S2Point_1.S2Point.normalize(this.getCenterRaw());
|
|
132
|
-
};
|
|
133
|
-
S2Cell.prototype.getCenterRaw = function () {
|
|
134
|
-
return this.cellID.toPointRaw();
|
|
135
|
-
};
|
|
136
|
-
/**
|
|
137
|
-
* Return the center of the cell in (u,v) coordinates (see {@code
|
|
138
|
-
* S2Projections}). Note that the center of the cell is defined as the point
|
|
139
|
-
* at which it is recursively subdivided into four children; in general, it is
|
|
140
|
-
* not at the midpoint of the (u,v) rectangle covered by the cell
|
|
141
|
-
*/
|
|
142
|
-
S2Cell.prototype.getCenterUV = function () {
|
|
143
|
-
var i = new MutableInteger_1.MutableInteger(0);
|
|
144
|
-
var j = new MutableInteger_1.MutableInteger(0);
|
|
145
|
-
this.cellID.toFaceIJOrientation(i, j, null);
|
|
146
|
-
var cellSize = 1 << (S2CellId_1.S2CellId.MAX_LEVEL - this.level);
|
|
147
|
-
// TODO(dbeaumont): Figure out a better naming of the variables here (and elsewhere).
|
|
148
|
-
var si = (i.val & -cellSize) * 2 + cellSize - S2Cell.MAX_CELL_SIZE;
|
|
149
|
-
var x = R2Vector_1.R2Vector.singleStTOUV(1 / S2Cell.MAX_CELL_SIZE * si);
|
|
150
|
-
// let x = S2Projections.stToUV((1.0 / S2Cell.MAX_CELL_SIZE) * si);
|
|
151
|
-
var sj = (j.val & -cellSize) * 2 + cellSize - S2Cell.MAX_CELL_SIZE;
|
|
152
|
-
var y = R2Vector_1.R2Vector.singleStTOUV(1 / S2Cell.MAX_CELL_SIZE * sj);
|
|
153
|
-
// double y = S2Projections.stToUV((1.0 / S2Cell.MAX_CELL_SIZE) * sj);
|
|
154
|
-
return new R2Vector_1.R2Vector(x, y);
|
|
155
|
-
};
|
|
156
|
-
/**
|
|
157
|
-
* Return the average area of cells at this level. This is accurate to within
|
|
158
|
-
* a factor of 1.7 (for S2_QUADRATIC_PROJECTION) and is extremely cheap to
|
|
159
|
-
* compute.
|
|
160
|
-
*/
|
|
161
|
-
S2Cell.averageArea = function (level) {
|
|
162
|
-
return S2Projections_1.S2Projections.AVG_AREA.getValue(level);
|
|
163
|
-
};
|
|
164
|
-
/**
|
|
165
|
-
* Return the average area of cells at this level. This is accurate to within
|
|
166
|
-
* a factor of 1.7 (for S2_QUADRATIC_PROJECTION) and is extremely cheap to
|
|
167
|
-
* compute.
|
|
168
|
-
*/
|
|
169
|
-
S2Cell.prototype.averageArea = function () {
|
|
170
|
-
return S2Projections_1.S2Projections.AVG_AREA.getValue(this.level);
|
|
171
|
-
};
|
|
172
|
-
/**
|
|
173
|
-
* Return the approximate area of this cell. This method is accurate to within
|
|
174
|
-
* 3% percent for all cell sizes and accurate to within 0.1% for cells at
|
|
175
|
-
* level 5 or higher (i.e. 300km square or smaller). It is moderately cheap to
|
|
176
|
-
* compute.
|
|
177
|
-
*/
|
|
178
|
-
S2Cell.prototype.approxArea = function () {
|
|
179
|
-
// All cells at the first two levels have the same area.
|
|
180
|
-
if (this.level < 2) {
|
|
181
|
-
return this.averageArea();
|
|
182
|
-
}
|
|
183
|
-
// First, compute the approximate area of the cell when projected
|
|
184
|
-
// perpendicular to its normal. The cross product of its diagonals gives
|
|
185
|
-
// the normal, and the length of the normal is twice the projected area.
|
|
186
|
-
var flatArea = S2Point_1.S2Point.crossProd(S2Point_1.S2Point.sub(this.getVertex(2), this.getVertex(0)), S2Point_1.S2Point.sub(this.getVertex(3), this.getVertex(1))).norm() * 0.5;
|
|
187
|
-
// double flatArea = 0.5 * S2Point.crossProd(
|
|
188
|
-
// S2Point.sub(getVertex(2), getVertex(0)), S2Point.sub(getVertex(3), getVertex(1))).norm();
|
|
189
|
-
// Now, compensate for the curvature of the cell surface by pretending
|
|
190
|
-
// that the cell is shaped like a spherical cap. The ratio of the
|
|
191
|
-
// area of a spherical cap to the area of its projected disc turns out
|
|
192
|
-
// to be 2 / (1 + sqrt(1 - r*r)) where "r" is the radius of the disc.
|
|
193
|
-
// For example, when r=0 the ratio is 1, and when r=1 the ratio is 2.
|
|
194
|
-
// Here we set Pi*r*r == flat_area to find the equivalent disc.
|
|
195
|
-
return flatArea * 2 / (Math.sqrt((Math.min(flatArea * S2_1.S2.M_1_PI, 1) * -1) + 1) + 1);
|
|
196
|
-
};
|
|
197
|
-
//
|
|
198
|
-
// /**
|
|
199
|
-
// * Return the area of this cell as accurately as possible. This method is more
|
|
200
|
-
// * expensive but it is accurate to 6 digits of precision even for leaf cells
|
|
201
|
-
// * (whose area is approximately 1e-18).
|
|
202
|
-
// */
|
|
203
|
-
S2Cell.prototype.exactArea = function () {
|
|
204
|
-
var v0 = this.getVertex(0);
|
|
205
|
-
var v1 = this.getVertex(1);
|
|
206
|
-
var v2 = this.getVertex(2);
|
|
207
|
-
var v3 = this.getVertex(3);
|
|
208
|
-
return S2_1.S2.area(v0, v1, v2) + (S2_1.S2.area(v0, v2, v3));
|
|
209
|
-
};
|
|
210
|
-
// //////////////////////////////////////////////////////////////////////
|
|
211
|
-
// S2Region interface (see {@code S2Region} for details):
|
|
212
|
-
S2Cell.prototype.getCapBound = function () {
|
|
213
|
-
// Use the cell center in (u,v)-space as the cap axis. This vector is
|
|
214
|
-
// very close to GetCenter() and faster to compute. Neither one of these
|
|
215
|
-
// vectors yields the bounding cap with minimal surface area, but they
|
|
216
|
-
// are both pretty close.
|
|
217
|
-
//
|
|
218
|
-
// It's possible to show that the two vertices that are furthest from
|
|
219
|
-
// the (u,v)-origin never determine the maximum cap size (this is a
|
|
220
|
-
// possible future optimization).
|
|
221
|
-
var u = this._uv[0][0] + (this._uv[0][1]) * (0.5);
|
|
222
|
-
var v = this._uv[1][0] + (this._uv[1][1]) * (0.5);
|
|
223
|
-
var cap = new S2Cap_1.S2Cap(S2Point_1.S2Point.normalize(S2Projections_1.S2Projections.faceUvToXyz(this.face, u, v)), 0);
|
|
224
|
-
for (var k = 0; k < 4; ++k) {
|
|
225
|
-
cap = cap.addPoint(this.getVertex(k));
|
|
226
|
-
}
|
|
227
|
-
return cap;
|
|
228
|
-
};
|
|
229
|
-
// 35.26 degrees
|
|
230
|
-
S2Cell.prototype.getRectBound = function () {
|
|
231
|
-
if (this.level > 0) {
|
|
232
|
-
// Except for cells at level 0, the latitude and longitude extremes are
|
|
233
|
-
// attained at the vertices. Furthermore, the latitude range is
|
|
234
|
-
// determined by one pair of diagonally opposite vertices and the
|
|
235
|
-
// longitude range is determined by the other pair.
|
|
236
|
-
//
|
|
237
|
-
// We first determine which corner (i,j) of the cell has the largest
|
|
238
|
-
// absolute latitude. To maximize latitude, we want to find the point in
|
|
239
|
-
// the cell that has the largest absolute z-coordinate and the smallest
|
|
240
|
-
// absolute x- and y-coordinates. To do this we look at each coordinate
|
|
241
|
-
// (u and v), and determine whether we want to minimize or maximize that
|
|
242
|
-
// coordinate based on the axis direction and the cell's (u,v) quadrant.
|
|
243
|
-
var u = this._uv[0][0] + (this._uv[0][1]);
|
|
244
|
-
var v = this._uv[1][0] + (this._uv[1][1]);
|
|
245
|
-
var i = S2Projections_1.S2Projections.getUAxis(this.face).z == 0 ? (u < 0 ? 1 : 0) : (u > 0 ? 1 : 0);
|
|
246
|
-
var j = S2Projections_1.S2Projections.getVAxis(this.face).z == 0 ? (v < 0 ? 1 : 0) : (v > 0 ? 1 : 0);
|
|
247
|
-
var lat = R1Interval_1.R1Interval.fromPointPair(this.getLatitude(i, j), this.getLatitude(1 - i, 1 - j));
|
|
248
|
-
lat = lat.expanded(S2Cell.MAX_ERROR).intersection(S2LatLngRect_1.S2LatLngRect.fullLat());
|
|
249
|
-
if (lat.lo == (-S2_1.S2.M_PI_2) || lat.hi == (S2_1.S2.M_PI_2)) {
|
|
250
|
-
return new S2LatLngRect_1.S2LatLngRect(lat, S1Interval_1.S1Interval.full());
|
|
251
|
-
}
|
|
252
|
-
var lng = S1Interval_1.S1Interval.fromPointPair(this.getLongitude(i, 1 - j), this.getLongitude(1 - i, j));
|
|
253
|
-
return new S2LatLngRect_1.S2LatLngRect(lat, lng.expanded(S2Cell.MAX_ERROR));
|
|
254
|
-
}
|
|
255
|
-
// The face centers are the +X, +Y, +Z, -X, -Y, -Z axes in that order.
|
|
256
|
-
// assert (S2Projections.getNorm(face).get(face % 3) == ((face < 3) ? 1 : -1));
|
|
257
|
-
switch (this.face) {
|
|
258
|
-
case 0:
|
|
259
|
-
return new S2LatLngRect_1.S2LatLngRect(new R1Interval_1.R1Interval(-S2_1.S2.M_PI_4, S2_1.S2.M_PI_4), new S1Interval_1.S1Interval(-S2_1.S2.M_PI_4, S2_1.S2.M_PI_4));
|
|
260
|
-
case 1:
|
|
261
|
-
return new S2LatLngRect_1.S2LatLngRect(new R1Interval_1.R1Interval(-S2_1.S2.M_PI_4, S2_1.S2.M_PI_4), new S1Interval_1.S1Interval(S2_1.S2.M_PI_4, 3 * S2_1.S2.M_PI_4));
|
|
262
|
-
case 2:
|
|
263
|
-
return new S2LatLngRect_1.S2LatLngRect(new R1Interval_1.R1Interval(S2Cell.POLE_MIN_LAT, S2_1.S2.M_PI_2), new S1Interval_1.S1Interval(-S2_1.S2.M_PI, S2_1.S2.M_PI));
|
|
264
|
-
case 3:
|
|
265
|
-
return new S2LatLngRect_1.S2LatLngRect(new R1Interval_1.R1Interval(-S2_1.S2.M_PI_4, S2_1.S2.M_PI_4), new S1Interval_1.S1Interval(3 * S2_1.S2.M_PI_4, -3 * S2_1.S2.M_PI_4));
|
|
266
|
-
case 4:
|
|
267
|
-
return new S2LatLngRect_1.S2LatLngRect(new R1Interval_1.R1Interval(-S2_1.S2.M_PI_4, S2_1.S2.M_PI_4), new S1Interval_1.S1Interval(-3 * S2_1.S2.M_PI_4, -S2_1.S2.M_PI_4));
|
|
268
|
-
default:
|
|
269
|
-
return new S2LatLngRect_1.S2LatLngRect(new R1Interval_1.R1Interval(-S2_1.S2.M_PI_2, -S2Cell.POLE_MIN_LAT), new S1Interval_1.S1Interval(-S2_1.S2.M_PI, S2_1.S2.M_PI));
|
|
270
|
-
}
|
|
271
|
-
};
|
|
272
|
-
S2Cell.prototype.mayIntersect = function (cell) {
|
|
273
|
-
return this.cellID.intersects(cell.cellID);
|
|
274
|
-
};
|
|
275
|
-
S2Cell.prototype.contains = function (p) {
|
|
276
|
-
// We can't just call XYZtoFaceUV, because for points that lie on the
|
|
277
|
-
// boundary between two faces (i.e. u or v is +1/-1) we need to return
|
|
278
|
-
// true for both adjacent cells.
|
|
279
|
-
var uvPoint = p.toR2Vector(this.face);
|
|
280
|
-
// S2Projections.faceXyzToUv(this.face, p);
|
|
281
|
-
if (uvPoint == null) {
|
|
282
|
-
return false;
|
|
283
|
-
}
|
|
284
|
-
return (uvPoint.x >= (this._uv[0][0]) && uvPoint.x <= (this._uv[0][1])
|
|
285
|
-
&& uvPoint.y >= (this._uv[1][0]) && uvPoint.y <= (this._uv[1][1]));
|
|
286
|
-
};
|
|
287
|
-
// The point 'p' does not need to be normalized.
|
|
288
|
-
S2Cell.prototype.containsC = function (cell) {
|
|
289
|
-
return this.cellID.contains(cell.cellID);
|
|
290
|
-
};
|
|
291
|
-
S2Cell.prototype.init = function (id) {
|
|
292
|
-
this.cellID = id;
|
|
293
|
-
var ij = [];
|
|
294
|
-
var mOrientation = new MutableInteger_1.MutableInteger(0);
|
|
295
|
-
for (var d = 0; d < 2; ++d) {
|
|
296
|
-
ij[d] = new MutableInteger_1.MutableInteger(0);
|
|
297
|
-
}
|
|
298
|
-
this._face = id.toFaceIJOrientation(ij[0], ij[1], mOrientation);
|
|
299
|
-
this._orientation = mOrientation.val; // Compress int to a byte.
|
|
300
|
-
this._level = id.level();
|
|
301
|
-
var cellSize = 1 << (S2CellId_1.S2CellId.MAX_LEVEL - this.level);
|
|
302
|
-
for (var d = 0; d < 2; ++d) {
|
|
303
|
-
// Compute the cell bounds in scaled (i,j) coordinates.
|
|
304
|
-
var sijLo = (ij[d].val & -cellSize) * 2 - S2Cell.MAX_CELL_SIZE;
|
|
305
|
-
var sijHi = sijLo + cellSize * 2;
|
|
306
|
-
var s = 1 / S2Cell.MAX_CELL_SIZE;
|
|
307
|
-
this._uv[d][0] = R2Vector_1.R2Vector.singleStTOUV(s * (sijLo));
|
|
308
|
-
//S2Projections.stToUV((1.0 / S2Cell.MAX_CELL_SIZE) * sijLo);
|
|
309
|
-
this._uv[d][1] = R2Vector_1.R2Vector.singleStTOUV(s * (sijHi));
|
|
310
|
-
}
|
|
311
|
-
};
|
|
312
|
-
// Internal method that does the actual work in the constructors.
|
|
313
|
-
S2Cell.prototype.getLatitude = function (i, j) {
|
|
314
|
-
var p = S2Projections_1.S2Projections.faceUvToXyz(this.face, this._uv[0][i], this._uv[1][j]);
|
|
315
|
-
return Math.atan2(p.z, Math.sqrt(p.x * p.x + p.y * p.y));
|
|
316
|
-
// return Math.atan2(p.z, Math.sqrt(p.x * p.x + p.y * p.y));
|
|
317
|
-
};
|
|
318
|
-
S2Cell.prototype.getLongitude = function (i, j) {
|
|
319
|
-
var p = S2Projections_1.S2Projections.faceUvToXyz(this.face, this._uv[0][i], this._uv[1][j]);
|
|
320
|
-
return Math.atan2(p.y, p.x);
|
|
321
|
-
// Math.atan2(p.y, p.x);
|
|
322
|
-
};
|
|
323
|
-
// Return the latitude or longitude of the cell vertex given by (i,j),
|
|
324
|
-
// where "i" and "j" are either 0 or 1.
|
|
325
|
-
S2Cell.prototype.toString = function () {
|
|
326
|
-
return "[" + this._face + ", " + this._level + ", " + this._orientation + ", " + this.cellID.toToken() + "]";
|
|
327
|
-
};
|
|
328
|
-
S2Cell.prototype.toGEOJSON = function () {
|
|
329
|
-
var coords = [this.getVertex(0), this.getVertex(1), this.getVertex(2), this.getVertex(3), this.getVertex(0)]
|
|
330
|
-
.map(function (v) { return S2LatLng_1.S2LatLng.fromPoint(v); })
|
|
331
|
-
.map(function (v) { return ([v.lngDegrees, v.latDegrees]); });
|
|
332
|
-
// const rectJSON = this.getRectBound().toGEOJSON();
|
|
333
|
-
return {
|
|
334
|
-
type: 'Feature',
|
|
335
|
-
geometry: {
|
|
336
|
-
type: 'Polygon',
|
|
337
|
-
coordinates: [coords]
|
|
338
|
-
},
|
|
339
|
-
properties: {},
|
|
340
|
-
title: "Cell: " + this.id.toToken() + " lvl: " + this.level
|
|
341
|
-
};
|
|
342
|
-
// rectJSON.title = `Cell: ${this.id.toToken()}`;
|
|
343
|
-
// return rectJSON;
|
|
344
|
-
};
|
|
345
|
-
S2Cell.MAX_CELL_SIZE = 1 << S2CellId_1.S2CellId.MAX_LEVEL;
|
|
346
|
-
// We grow the bounds slightly to make sure that the bounding rectangle
|
|
347
|
-
// also contains the normalized versions of the vertices. Note that the
|
|
348
|
-
// maximum result magnitude is Pi, with a floating-point exponent of 1.
|
|
349
|
-
// Therefore adding or subtracting 2**-51 will always change the result.
|
|
350
|
-
// private static MAX_ERROR = S2.toDecimal(1.0).dividedBy(S2.toDecimal(new Long(1).shiftLeft(51).toString()));
|
|
351
|
-
S2Cell.MAX_ERROR = 1 / new Long(1).shiftLeft(51).toNumber();
|
|
352
|
-
// The 4 cells around the equator extend to +/-45 degrees latitude at the
|
|
353
|
-
// midpoints of their top and bottom edges. The two cells covering the
|
|
354
|
-
// poles extend down to +/-35.26 degrees at their vertices.
|
|
355
|
-
// adding kMaxError (as opposed to the C version) because of asin and atan2
|
|
356
|
-
// roundoff errors
|
|
357
|
-
S2Cell.POLE_MIN_LAT = Math.asin(Math.sqrt(1 / 3)) - S2Cell.MAX_ERROR;
|
|
358
|
-
return S2Cell;
|
|
359
|
-
}());
|
|
360
|
-
exports.S2Cell = S2Cell;
|
|
361
|
-
//# sourceMappingURL=S2Cell.js.map
|
package/dist/S2Cell.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"S2Cell.js","sourceRoot":"","sources":["../src/S2Cell.ts"],"names":[],"mappings":";AAAA,IAAO,IAAI,WAAW,MAAM,CAAC,CAAC;AAC9B,yBAAuB,YAAY,CAAC,CAAA;AACpC,wBAAsB,WAAW,CAAC,CAAA;AAClC,yBAAuB,YAAY,CAAC,CAAA;AACpC,8BAA4B,iBAAiB,CAAC,CAAA;AAC9C,yBAAuB,YAAY,CAAC,CAAA;AACpC,+BAA6B,kBAAkB,CAAC,CAAA;AAChD,mBAAiB,MAAM,CAAC,CAAA;AACxB,6BAA2B,gBAAgB,CAAC,CAAA;AAC5C,2BAAyB,cAAc,CAAC,CAAA;AACxC,2BAAyB,cAAc,CAAC,CAAA;AACxC,sBAAoB,SAAS,CAAC,CAAA;AAC9B;IAQE,gBAAoB,MAAe;QAAf,WAAM,GAAN,MAAM,CAAS;QACjC,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;QACd,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAClB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAClB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACnB,C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AAC,QAAQ,EAAE,CAAC;IAEpE,yEAAyE;IACzE,sEAAsE;IACtE,2DAA2D;IAC3D,2EAA2E;IAC3E,kBAAkB;IACD,mBAAY,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC;IA4J7E,aAAC;AAAD,CAAC,AA3aD,IA2aC;AA3aY,cAAM,SA2alB,CAAA"}
|
package/dist/S2CellId.d.ts
DELETED
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
/// <reference types="long" />
|
|
2
|
-
import * as Long from 'long';
|
|
3
|
-
import { S2Point } from "./S2Point";
|
|
4
|
-
import { MutableInteger } from "./MutableInteger";
|
|
5
|
-
import { S2LatLng } from "./S2LatLng";
|
|
6
|
-
/**
|
|
7
|
-
* An S2CellId is a 64-bit unsigned integer that uniquely identifies a cell in
|
|
8
|
-
* the S2 cell decomposition. It has the following format:
|
|
9
|
-
*
|
|
10
|
-
* <pre>
|
|
11
|
-
* id = [face][face_pos]
|
|
12
|
-
* </pre>
|
|
13
|
-
*
|
|
14
|
-
* face: a 3-bit number (range 0..5) encoding the cube face.
|
|
15
|
-
*
|
|
16
|
-
* face_pos: a 61-bit number encoding the position of the center of this cell
|
|
17
|
-
* along the Hilbert curve over this face (see the Wiki pages for details).
|
|
18
|
-
*
|
|
19
|
-
* Sequentially increasing cell ids follow a continuous space-filling curve over
|
|
20
|
-
* the entire sphere. They have the following properties:
|
|
21
|
-
* - The id of a cell at level k consists of a 3-bit face number followed by k
|
|
22
|
-
* bit pairs that recursively select one of the four children of each cell. The
|
|
23
|
-
* next bit is always 1, and all other bits are 0. Therefore, the level of a
|
|
24
|
-
* cell is determined by the position of its lowest-numbered bit that is turned
|
|
25
|
-
* on (for a cell at level k, this position is 2 * (MAX_LEVEL - k).)
|
|
26
|
-
* - The id of a parent cell is at the midpoint of the range of ids spanned by
|
|
27
|
-
* its children (or by its descendants at any level).
|
|
28
|
-
*
|
|
29
|
-
* Leaf cells are often used to represent points on the unit sphere, and this
|
|
30
|
-
* class provides methods for converting directly between these two
|
|
31
|
-
* representations. For cells that represent 2D regions rather than discrete
|
|
32
|
-
* point, it is better to use the S2Cell class.
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*/
|
|
36
|
-
export declare class S2CellId {
|
|
37
|
-
static FACE_BITS: number;
|
|
38
|
-
static NUM_FACES: number;
|
|
39
|
-
static MAX_LEVEL: number;
|
|
40
|
-
static POS_BITS: number;
|
|
41
|
-
static MAX_SIZE: number;
|
|
42
|
-
private static maxValueDivs;
|
|
43
|
-
private static maxValueMods;
|
|
44
|
-
static MAX_UNSIGNED: Long;
|
|
45
|
-
static LOOKUP_BITS: number;
|
|
46
|
-
private static SWAP_MASK;
|
|
47
|
-
private static INVERT_MASK;
|
|
48
|
-
static LOOKUP_POS: Long[];
|
|
49
|
-
static LOOKUP_IJ: number[];
|
|
50
|
-
/**
|
|
51
|
-
* This is the offset required to wrap around from the beginning of the
|
|
52
|
-
* Hilbert curve to the end or vice versa; see next_wrap() and prev_wrap().
|
|
53
|
-
*/
|
|
54
|
-
private static WRAP_OFFSET;
|
|
55
|
-
id: Long;
|
|
56
|
-
constructor(id: Long | string);
|
|
57
|
-
/** Which cube face this cell belongs to, in the range 0..5. */
|
|
58
|
-
readonly face: number;
|
|
59
|
-
/** Return the lowest-numbered bit that is on for cells at the given level. */
|
|
60
|
-
lowestOnBit(): Long;
|
|
61
|
-
/** The default constructor returns an invalid cell id. */
|
|
62
|
-
static none(): S2CellId;
|
|
63
|
-
/**
|
|
64
|
-
* Returns an invalid cell id guaranteed to be larger than any valid cell id.
|
|
65
|
-
* Useful for creating indexes.
|
|
66
|
-
*/
|
|
67
|
-
static sentinel(): S2CellId;
|
|
68
|
-
private getBits1(i, j, k, bits);
|
|
69
|
-
/**
|
|
70
|
-
* Convert (face, si, ti) coordinates (see s2.h) to a direction vector (not
|
|
71
|
-
* necessarily unit length).
|
|
72
|
-
*/
|
|
73
|
-
private faceSiTiToXYZ(face, si, ti);
|
|
74
|
-
static lowestOnBitForLevel(level: number): Long;
|
|
75
|
-
/**
|
|
76
|
-
* Return the (face, i, j) coordinates for the leaf cell corresponding to this
|
|
77
|
-
* cell id. Since cells are represented by the Hilbert curve position at the
|
|
78
|
-
* center of the cell, the returned (i,j) for non-leaf cells will be a leaf
|
|
79
|
-
* cell adjacent to the cell center. If "orientation" is non-NULL, also return
|
|
80
|
-
* the Hilbert curve orientation for the current cell.
|
|
81
|
-
*/
|
|
82
|
-
toFaceIJOrientation(pi: MutableInteger, pj: MutableInteger, orientation: MutableInteger): number;
|
|
83
|
-
/**
|
|
84
|
-
* Return true if this is a leaf cell (more efficient than checking whether
|
|
85
|
-
* level() == MAX_LEVEL).
|
|
86
|
-
*/
|
|
87
|
-
isLeaf(): boolean;
|
|
88
|
-
/**
|
|
89
|
-
* Return the cell at the previous level or at the given level (which must be
|
|
90
|
-
* less than or equal to the current level).
|
|
91
|
-
*/
|
|
92
|
-
parentL(level: number): S2CellId;
|
|
93
|
-
parent(): S2CellId;
|
|
94
|
-
/**
|
|
95
|
-
* Return a cell given its face (range 0..5), 61-bit Hilbert curve position
|
|
96
|
-
* within that face, and level (range 0..MAX_LEVEL). The given position will
|
|
97
|
-
* be modified to correspond to the Hilbert curve position at the center of
|
|
98
|
-
* the returned cell. This is a static function rather than a constructor in
|
|
99
|
-
* order to give names to the arguments.
|
|
100
|
-
*/
|
|
101
|
-
static fromFacePosLevel(face: number, pos: Long, level: number): S2CellId;
|
|
102
|
-
static fromPoint(p: S2Point): S2CellId;
|
|
103
|
-
toPoint(): S2Point;
|
|
104
|
-
/**
|
|
105
|
-
* Return the direction vector corresponding to the center of the given cell.
|
|
106
|
-
* The vector returned by ToPointRaw is not necessarily unit length.
|
|
107
|
-
*/
|
|
108
|
-
toPointRaw(): S2Point;
|
|
109
|
-
/** Return the S2LatLng corresponding to the center of the given cell. */
|
|
110
|
-
toLatLng(): S2LatLng;
|
|
111
|
-
/** Return true if id() represents a valid cell. */
|
|
112
|
-
isValid(): boolean;
|
|
113
|
-
/**
|
|
114
|
-
* The position of the cell center along the Hilbert curve over this face, in
|
|
115
|
-
* the range 0..(2**kPosBits-1).
|
|
116
|
-
*/
|
|
117
|
-
pos(): Long;
|
|
118
|
-
/** Return the subdivision level of the cell (range 0..MAX_LEVEL). */
|
|
119
|
-
level(): number;
|
|
120
|
-
/**
|
|
121
|
-
* Return true if this is a top-level face cell (more efficient than checking
|
|
122
|
-
* whether level() == 0).
|
|
123
|
-
*/
|
|
124
|
-
isFace(): boolean;
|
|
125
|
-
/**
|
|
126
|
-
* Return the child position (0..3) of this cell's ancestor at the given
|
|
127
|
-
* level, relative to its parent. The argument should be in the range
|
|
128
|
-
* 1..MAX_LEVEL. For example, child_position(1) returns the position of this
|
|
129
|
-
* cell's level-1 ancestor within its top-level face cell.
|
|
130
|
-
*/
|
|
131
|
-
childPosition(level: number): number;
|
|
132
|
-
rangeMin(): S2CellId;
|
|
133
|
-
rangeMax(): S2CellId;
|
|
134
|
-
/** Return true if the given cell is contained within this one. */
|
|
135
|
-
contains(other: S2CellId): boolean;
|
|
136
|
-
/** Return true if the given cell intersects this one. */
|
|
137
|
-
intersects(other: S2CellId): boolean;
|
|
138
|
-
childBegin(): S2CellId;
|
|
139
|
-
childBeginL(level: number): S2CellId;
|
|
140
|
-
childEnd(): S2CellId;
|
|
141
|
-
childEndL(level: number): S2CellId;
|
|
142
|
-
/**
|
|
143
|
-
* Return the next cell at the same level along the Hilbert curve. Works
|
|
144
|
-
* correctly when advancing from one face to the next, but does *not* wrap
|
|
145
|
-
* around from the last face to the first or vice versa.
|
|
146
|
-
*/
|
|
147
|
-
next(): S2CellId;
|
|
148
|
-
/**
|
|
149
|
-
* Return the previous cell at the same level along the Hilbert curve. Works
|
|
150
|
-
* correctly when advancing from one face to the next, but does *not* wrap
|
|
151
|
-
* around from the last face to the first or vice versa.
|
|
152
|
-
*/
|
|
153
|
-
prev(): S2CellId;
|
|
154
|
-
/**
|
|
155
|
-
* Like next(), but wraps around from the last face to the first and vice
|
|
156
|
-
* versa. Should *not* be used for iteration in conjunction with
|
|
157
|
-
* child_begin(), child_end(), Begin(), or End().
|
|
158
|
-
*/
|
|
159
|
-
nextWrap(): S2CellId;
|
|
160
|
-
/**
|
|
161
|
-
* Like prev(), but wraps around from the last face to the first and vice
|
|
162
|
-
* versa. Should *not* be used for iteration in conjunction with
|
|
163
|
-
* child_begin(), child_end(), Begin(), or End().
|
|
164
|
-
*/
|
|
165
|
-
prevWrap(): S2CellId;
|
|
166
|
-
static begin(level: number): S2CellId;
|
|
167
|
-
static end(level: number): S2CellId;
|
|
168
|
-
/**
|
|
169
|
-
* Decodes the cell id from a compact text string suitable for display or
|
|
170
|
-
* indexing. Cells at lower levels (i.e. larger cells) are encoded into
|
|
171
|
-
* fewer characters. The maximum token length is 16.
|
|
172
|
-
*
|
|
173
|
-
* @param token the token to decode
|
|
174
|
-
* @return the S2CellId for that token
|
|
175
|
-
* @throws NumberFormatException if the token is not formatted correctly
|
|
176
|
-
*/
|
|
177
|
-
static fromToken(token: string): S2CellId;
|
|
178
|
-
/**
|
|
179
|
-
* Encodes the cell id to compact text strings suitable for display or indexing.
|
|
180
|
-
* Cells at lower levels (i.e. larger cells) are encoded into fewer characters.
|
|
181
|
-
* The maximum token length is 16.
|
|
182
|
-
*
|
|
183
|
-
* Simple implementation: convert the id to hex and strip trailing zeros. We
|
|
184
|
-
* could use base-32 or base-64, but assuming the cells used for indexing
|
|
185
|
-
* regions are at least 100 meters across (level 16 or less), the savings
|
|
186
|
-
* would be at most 3 bytes (9 bytes hex vs. 6 bytes base-64).
|
|
187
|
-
*
|
|
188
|
-
* @return the encoded cell id
|
|
189
|
-
*/
|
|
190
|
-
toToken(): string;
|
|
191
|
-
/**
|
|
192
|
-
* Returns true if (current * radix) + digit is a number too large to be
|
|
193
|
-
* represented by an unsigned long. This is useful for detecting overflow
|
|
194
|
-
* while parsing a string representation of a number.
|
|
195
|
-
* Does not verify whether supplied radix is valid, passing an invalid radix
|
|
196
|
-
* will give undefined results or an ArrayIndexOutOfBoundsException.
|
|
197
|
-
*/
|
|
198
|
-
private static overflowInParse(current, digit, radix?);
|
|
199
|
-
/**
|
|
200
|
-
* Return the four cells that are adjacent across the cell's four edges.
|
|
201
|
-
* Neighbors are returned in the order defined by S2Cell::GetEdge. All
|
|
202
|
-
* neighbors are guaranteed to be distinct.
|
|
203
|
-
*/
|
|
204
|
-
getEdgeNeighbors(): S2CellId[];
|
|
205
|
-
/**
|
|
206
|
-
* Return the neighbors of closest vertex to this cell at the given level, by
|
|
207
|
-
* appending them to "output". Normally there are four neighbors, but the
|
|
208
|
-
* closest vertex may only have three neighbors if it is one of the 8 cube
|
|
209
|
-
* vertices.
|
|
210
|
-
*
|
|
211
|
-
* Requires: level < this.evel(), so that we can determine which vertex is
|
|
212
|
-
* closest (in particular, level == MAX_LEVEL is not allowed).
|
|
213
|
-
*/
|
|
214
|
-
getVertexNeighbors(level: number): S2CellId[];
|
|
215
|
-
/**
|
|
216
|
-
* Append all neighbors of this cell at the given level to "output". Two cells
|
|
217
|
-
* X and Y are neighbors if their boundaries intersect but their interiors do
|
|
218
|
-
* not. In particular, two cells that intersect at a single point are
|
|
219
|
-
* neighbors.
|
|
220
|
-
*
|
|
221
|
-
* Requires: nbr_level >= this->level(). Note that for cells adjacent to a
|
|
222
|
-
* face vertex, the same neighbor may be appended more than once.
|
|
223
|
-
*/
|
|
224
|
-
getAllNeighbors(nbrLevel: number): S2CellId[];
|
|
225
|
-
/**
|
|
226
|
-
* Return a leaf cell given its cube face (range 0..5) and i- and
|
|
227
|
-
* j-coordinates (see s2.h).
|
|
228
|
-
*/
|
|
229
|
-
static fromFaceIJ(face: number, i: number, j: number): S2CellId;
|
|
230
|
-
private static getBits(n, i, j, k, bits);
|
|
231
|
-
/**
|
|
232
|
-
* Return the i- or j-index of the leaf cell containing the given s- or
|
|
233
|
-
* t-value.
|
|
234
|
-
*/
|
|
235
|
-
private static stToIJ(s);
|
|
236
|
-
/**
|
|
237
|
-
* Given (i, j) coordinates that may be out of bounds, normalize them by
|
|
238
|
-
* returning the corresponding neighbor cell on an adjacent face.
|
|
239
|
-
*/
|
|
240
|
-
private static fromFaceIJWrap(face, i, j);
|
|
241
|
-
/**
|
|
242
|
-
* Public helper function that calls FromFaceIJ if sameFace is true, or
|
|
243
|
-
* FromFaceIJWrap if sameFace is false.
|
|
244
|
-
*/
|
|
245
|
-
static fromFaceIJSame(face: number, i: number, j: number, sameFace: boolean): S2CellId;
|
|
246
|
-
/**
|
|
247
|
-
* Returns true if x1 < x2, when both values are treated as unsigned.
|
|
248
|
-
*/
|
|
249
|
-
static unsignedLongLessThan(x1: Long, x2: Long): boolean;
|
|
250
|
-
/**
|
|
251
|
-
* Returns true if x1 > x2, when both values are treated as unsigned.
|
|
252
|
-
*/
|
|
253
|
-
static unsignedLongGreaterThan(x1: Long, x2: Long): boolean;
|
|
254
|
-
lessThan(x: S2CellId): boolean;
|
|
255
|
-
greaterThan(x: S2CellId): boolean;
|
|
256
|
-
lessOrEquals(x: S2CellId): boolean;
|
|
257
|
-
greaterOrEquals(x: S2CellId): boolean;
|
|
258
|
-
toString(): string;
|
|
259
|
-
compareTo(that: S2CellId): number;
|
|
260
|
-
equals(that: S2CellId): boolean;
|
|
261
|
-
/**
|
|
262
|
-
* Returns the position of the id within the given list or a negative value with
|
|
263
|
-
* the position of the index wher eit should be entered if the id was present
|
|
264
|
-
*/
|
|
265
|
-
static binarySearch(ids: S2CellId[], _id: Long | string | S2CellId, low?: number): number;
|
|
266
|
-
static indexedBinarySearch(ids: S2CellId[], id: Long | string | S2CellId, low?: number): number;
|
|
267
|
-
}
|