nodes2ts 1.1.9 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +3 -0
- package/.eslintrc.cjs +11 -0
- package/.github/workflows/lint.js.yml +22 -0
- package/.github/workflows/node.js.yml +22 -0
- package/.mocharc.js +7 -0
- package/README.md +22 -5
- package/dist/Interval.d.ts +7 -8
- package/dist/Interval.js +12 -12
- package/dist/Interval.js.map +1 -1
- package/dist/MutableInteger.js +5 -4
- package/dist/MutableInteger.js.map +1 -1
- package/dist/Platform.d.ts +15 -0
- package/dist/Platform.js +53 -0
- package/dist/Platform.js.map +1 -0
- package/dist/R1Interval.d.ts +8 -9
- package/dist/R1Interval.js +59 -78
- package/dist/R1Interval.js.map +1 -1
- package/dist/R2Vector.d.ts +12 -13
- package/dist/R2Vector.js +65 -85
- package/dist/R2Vector.js.map +1 -1
- package/dist/S1Angle.d.ts +38 -5
- package/dist/S1Angle.js +89 -37
- package/dist/S1Angle.js.map +1 -1
- package/dist/S1ChordAngle.d.ts +166 -0
- package/dist/S1ChordAngle.js +318 -0
- package/dist/S1ChordAngle.js.map +1 -0
- package/dist/S1Interval.d.ts +11 -12
- package/dist/S1Interval.js +134 -140
- package/dist/S1Interval.js.map +1 -1
- package/dist/S2.d.ts +8 -5
- package/dist/S2.js +91 -108
- package/dist/S2.js.map +1 -1
- package/dist/S2Cap.d.ts +33 -25
- package/dist/S2Cap.js +199 -203
- package/dist/S2Cap.js.map +1 -1
- package/dist/S2Cell.d.ts +15 -13
- package/dist/S2Cell.js +196 -206
- package/dist/S2Cell.js.map +1 -1
- package/dist/S2CellId.d.ts +37 -14
- package/dist/S2CellId.js +407 -359
- package/dist/S2CellId.js.map +1 -1
- package/dist/S2CellUnion.d.ts +1 -2
- package/dist/S2CellUnion.js +137 -133
- package/dist/S2CellUnion.js.map +1 -1
- package/dist/S2EdgeUtil.js +14 -17
- package/dist/S2EdgeUtil.js.map +1 -1
- package/dist/S2LatLng.d.ts +15 -11
- package/dist/S2LatLng.js +100 -114
- package/dist/S2LatLng.js.map +1 -1
- package/dist/S2LatLngRect.d.ts +8 -4
- package/dist/S2LatLngRect.js +215 -197
- package/dist/S2LatLngRect.js.map +1 -1
- package/dist/S2Metric.d.ts +4 -5
- package/dist/S2Metric.js +30 -27
- package/dist/S2Metric.js.map +1 -1
- package/dist/S2Point.d.ts +48 -14
- package/dist/S2Point.js +156 -109
- package/dist/S2Point.js.map +1 -1
- package/dist/S2Projections.d.ts +43 -9
- package/dist/S2Projections.js +226 -47
- package/dist/S2Projections.js.map +1 -1
- package/dist/S2Region.js +2 -1
- package/dist/S2Region.js.map +1 -1
- package/dist/S2RegionCoverer.d.ts +21 -6
- package/dist/S2RegionCoverer.js +144 -109
- package/dist/S2RegionCoverer.js.map +1 -1
- package/dist/export.d.ts +0 -1
- package/dist/export.js +42 -32
- package/dist/export.js.map +1 -1
- package/dist/utils/preconditions.d.ts +2 -0
- package/dist/utils/preconditions.js +16 -0
- package/dist/utils/preconditions.js.map +1 -0
- package/package.json +28 -34
- package/.npmignore +0 -8
- package/.nyc_output/1eb1f420a13c15f529aac41a40bcaa21.json +0 -1
- package/.nyc_output/5ff62256eb1c111254ba0b469fb547da.json +0 -1
- package/.nyc_output/949d6e8c2061067f3bdfd27dfff5ba83.json +0 -1
- package/coverage/Interval.ts.html +0 -203
- package/coverage/MutableInteger.ts.html +0 -77
- package/coverage/R1Interval.ts.html +0 -647
- package/coverage/R2Vector.ts.html +0 -587
- package/coverage/S1Angle.ts.html +0 -344
- package/coverage/S1Interval.ts.html +0 -1349
- package/coverage/S2.ts.html +0 -1178
- package/coverage/S2Cap.ts.html +0 -1433
- package/coverage/S2Cell.ts.html +0 -1415
- package/coverage/S2CellId.ts.html +0 -3329
- package/coverage/S2EdgeUtil.ts.html +0 -2534
- package/coverage/S2LatLng.ts.html +0 -848
- package/coverage/S2LatLngRect.ts.html +0 -2222
- package/coverage/S2Point.ts.html +0 -758
- package/coverage/S2Projections.ts.html +0 -518
- package/coverage/base.css +0 -212
- package/coverage/decimal.ts.html +0 -68
- package/coverage/index.html +0 -288
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -1
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -158
- package/dist/decimal.d.ts +0 -3
- package/dist/decimal.js +0 -4
- package/dist/decimal.js.map +0 -1
- package/dist/decimal_augmentation.d.ts +0 -24
- package/dist/decimal_augmentation.js +0 -2
- package/dist/decimal_augmentation.js.map +0 -1
package/.eslintignore
ADDED
package/.eslintrc.cjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
name: Lint CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ master ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ master ]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
node-version: [16.x]
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v3
|
|
17
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
18
|
+
uses: actions/setup-node@v3
|
|
19
|
+
with:
|
|
20
|
+
node-version: ${{ matrix.node-version }}
|
|
21
|
+
- run: yarn --frozen-lockfile
|
|
22
|
+
- run: yarn lint
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
name: Node.js CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ master ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ master ]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
node-version: [14.x, 16.x]
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v3
|
|
17
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
18
|
+
uses: actions/setup-node@v3
|
|
19
|
+
with:
|
|
20
|
+
node-version: ${{ matrix.node-version }}
|
|
21
|
+
- run: yarn --frozen-lockfile
|
|
22
|
+
- run: yarn test
|
package/.mocharc.js
ADDED
package/README.md
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
### Node
|
|
1
|
+
### Node S2 Geometry Typescript
|
|
2
|
+
<img src="https://github.com/vekexasia/nodes2-ts/actions/workflows/node.js.yml/badge.svg" />
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
<img src="https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white"/> <img
|
|
5
|
+
src="https://img.shields.io/badge/mocha.js-323330?style=for-the-badge&logo=mocha&logoColor=Brown"/> <img
|
|
6
|
+
src="https://img.shields.io/badge/eslint-3A33D1?style=for-the-badge&logo=eslint&logoColor=white"/>
|
|
4
7
|
|
|
5
|
-
The library uses `decimal.js` and `long` as external libraries to perform the needed math.
|
|
6
8
|
|
|
9
|
+
An extensive port of google's s2 geometry library written in TypeScript.
|
|
10
|
+
|
|
11
|
+
The only direct dependencies are some math related npm packages (long and math-float64-exponent).
|
|
12
|
+
|
|
13
|
+
Npm package is `nodes2ts`.
|
|
7
14
|
|
|
8
15
|
#### Tests
|
|
9
|
-
This project is backed by
|
|
16
|
+
This project is backed by 60+ 1-by-1 comparison tests between this implementation and the original one.
|
|
10
17
|
|
|
11
18
|
When implementing a not-yet-ported feature, please generate the needed tests by modifiying the java code within `java-test-creator` folder
|
|
12
19
|
|
|
@@ -51,7 +58,7 @@ Also, for some classes, an extra `toGEOJSON` method is provided to let developer
|
|
|
51
58
|
- Convert Lat/Lng to S2CellId
|
|
52
59
|
```typescript
|
|
53
60
|
const cellId = S2CellId.fromPoint(
|
|
54
|
-
S2LatLng.fromDegrees(10 /*latitude*/, 11 /*longitude*/)
|
|
61
|
+
S2LatLng.fromDegrees(10 /*latitude*/, 11 /*longitude*/).toPoint()
|
|
55
62
|
);
|
|
56
63
|
```
|
|
57
64
|
|
|
@@ -77,6 +84,16 @@ console.log(cell.toGEOJSON());
|
|
|
77
84
|
// copy the output and paste it on http://geojson.io/
|
|
78
85
|
```
|
|
79
86
|
|
|
87
|
+
## Contributing
|
|
88
|
+
|
|
89
|
+
The library was initially conceived to be used in both server and client env leveraging TypeScript peculiarities.
|
|
90
|
+
|
|
91
|
+
If you wish to contribute please make sure, wherever applicable, to create a tiny merge request to ease the code
|
|
92
|
+
review of the proposed changes.
|
|
93
|
+
|
|
94
|
+
## Want to connect with the author?
|
|
80
95
|
|
|
96
|
+
If you wish to contact the library author for business (or any other) proposal you can write an email to `vekexasia`
|
|
97
|
+
`at` gmail `dot` com.
|
|
81
98
|
|
|
82
99
|
|
package/dist/Interval.d.ts
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
/// <reference types="decimal.js" />
|
|
2
1
|
export declare abstract class Interval {
|
|
3
|
-
lo:
|
|
4
|
-
hi:
|
|
5
|
-
constructor(lo: number
|
|
2
|
+
lo: number;
|
|
3
|
+
hi: number;
|
|
4
|
+
constructor(lo: number, hi: number);
|
|
6
5
|
/** Return true if the interval is empty, i.e. it contains no points. */
|
|
7
6
|
abstract isEmpty(): boolean;
|
|
8
7
|
/**
|
|
9
8
|
* Return the center of the interval. For empty intervals, the result is
|
|
10
9
|
* arbitrary.
|
|
11
10
|
*/
|
|
12
|
-
abstract getCenter():
|
|
11
|
+
abstract getCenter(): number;
|
|
13
12
|
/**
|
|
14
13
|
* Return the length of the interval. The length of an empty interval is
|
|
15
14
|
* negative.
|
|
16
15
|
*/
|
|
17
|
-
abstract getLength():
|
|
18
|
-
abstract contains(p: number
|
|
19
|
-
abstract interiorContains(p: number
|
|
16
|
+
abstract getLength(): number;
|
|
17
|
+
abstract contains(p: number): boolean;
|
|
18
|
+
abstract interiorContains(p: number): boolean;
|
|
20
19
|
toString(): string;
|
|
21
20
|
/**
|
|
22
21
|
* Return true if two intervals contains the same set of points.
|
package/dist/Interval.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
this.
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Interval = void 0;
|
|
4
|
+
class Interval {
|
|
5
|
+
constructor(lo, hi) {
|
|
6
|
+
this.lo = lo;
|
|
7
|
+
this.hi = hi;
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
+
toString() {
|
|
9
10
|
return "[" + this.lo.toString() + ", " + this.hi.toString() + "]";
|
|
10
|
-
}
|
|
11
|
+
}
|
|
11
12
|
/**
|
|
12
13
|
* Return true if two intervals contains the same set of points.
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
|
+
equals(that) {
|
|
15
16
|
if (typeof (that) === typeof (this)) {
|
|
16
|
-
return this.lo
|
|
17
|
+
return this.lo == that.lo && this.hi == that.hi;
|
|
17
18
|
}
|
|
18
19
|
return false;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
}());
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
22
|
exports.Interval = Interval;
|
|
23
23
|
//# sourceMappingURL=Interval.js.map
|
package/dist/Interval.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Interval.js","sourceRoot":"","sources":["../src/Interval.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Interval.js","sourceRoot":"","sources":["../src/Interval.ts"],"names":[],"mappings":";;;AAAA,MAAsB,QAAQ;IAI5B,YAAY,EAAS,EAAE,EAAS;QAC9B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IAsBO,QAAQ;QACd,OAAO,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,GAAG,CAAC;IACpE,CAAC;IAGD;;OAEG;IACI,MAAM,CAAC,IAAQ;QACpB,IAAI,OAAM,CAAC,IAAI,CAAC,KAAK,OAAM,CAAC,IAAI,CAAC,EAAE;YACjC,OAAO,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,EAAE,CAAC;SACjD;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CAGF;AA7CD,4BA6CC"}
|
package/dist/MutableInteger.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MutableInteger = void 0;
|
|
4
|
+
class MutableInteger {
|
|
5
|
+
constructor(val) {
|
|
4
6
|
this.val = val;
|
|
5
7
|
}
|
|
6
|
-
|
|
7
|
-
}());
|
|
8
|
+
}
|
|
8
9
|
exports.MutableInteger = MutableInteger;
|
|
9
10
|
//# sourceMappingURL=MutableInteger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MutableInteger.js","sourceRoot":"","sources":["../src/MutableInteger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MutableInteger.js","sourceRoot":"","sources":["../src/MutableInteger.ts"],"names":[],"mappings":";;;AAAA,MAAa,cAAc;IAEzB,YAAmB,GAAU;QAAV,QAAG,GAAH,GAAG,CAAO;IAC7B,CAAC;CACF;AAJD,wCAIC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class Platform {
|
|
2
|
+
static IEEEremainder(f1: number, f2: number): number;
|
|
3
|
+
/**
|
|
4
|
+
* If v is non-zero, return an integer {@code exp} such that
|
|
5
|
+
* {@code (0.5 <= |v|*2^(-exp) < 1)}. If v is zero, return 0.
|
|
6
|
+
*
|
|
7
|
+
* <p>Note that this arguably a bad definition of exponent because it makes
|
|
8
|
+
* {@code exp(9) == 4}. In decimal this would be like saying that the
|
|
9
|
+
* exponent of 1234 is 4, when in scientific 'exponent' notation 1234 is
|
|
10
|
+
* {@code 1.234 x 10^3}.
|
|
11
|
+
*
|
|
12
|
+
* TODO(dbeaumont): Replace this with "DoubleUtils.getExponent(v) - 1" ?
|
|
13
|
+
*/
|
|
14
|
+
static getExponent(v: number): number;
|
|
15
|
+
}
|
package/dist/Platform.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Platform = void 0;
|
|
4
|
+
const exponent = require("math-float64-exponent");
|
|
5
|
+
class Platform {
|
|
6
|
+
static IEEEremainder(f1, f2) {
|
|
7
|
+
// let r = f1 % f2;
|
|
8
|
+
// if (isNaN(r) || r == (f2) || r <= (Math.abs(f2) / 2)) {
|
|
9
|
+
// return r;
|
|
10
|
+
// } else {
|
|
11
|
+
// return (f1 >= (0) ? 1 : -1) * (r - f2);
|
|
12
|
+
// }
|
|
13
|
+
if (Number.isNaN(f1)) {
|
|
14
|
+
return f1;
|
|
15
|
+
}
|
|
16
|
+
if (Number.isNaN(f2)) {
|
|
17
|
+
return f2;
|
|
18
|
+
}
|
|
19
|
+
if ((f2 === Number.POSITIVE_INFINITY || f2 === Number.NEGATIVE_INFINITY) && Number.isFinite(f1)) {
|
|
20
|
+
return f1;
|
|
21
|
+
}
|
|
22
|
+
return f1 - (Math.round(f1 / f2) * f2);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* If v is non-zero, return an integer {@code exp} such that
|
|
26
|
+
* {@code (0.5 <= |v|*2^(-exp) < 1)}. If v is zero, return 0.
|
|
27
|
+
*
|
|
28
|
+
* <p>Note that this arguably a bad definition of exponent because it makes
|
|
29
|
+
* {@code exp(9) == 4}. In decimal this would be like saying that the
|
|
30
|
+
* exponent of 1234 is 4, when in scientific 'exponent' notation 1234 is
|
|
31
|
+
* {@code 1.234 x 10^3}.
|
|
32
|
+
*
|
|
33
|
+
* TODO(dbeaumont): Replace this with "DoubleUtils.getExponent(v) - 1" ?
|
|
34
|
+
*/
|
|
35
|
+
static getExponent(v) {
|
|
36
|
+
// if (v == 0) {
|
|
37
|
+
// return 0;
|
|
38
|
+
// }
|
|
39
|
+
// // IT should always be ((int)log(2,v))+1;
|
|
40
|
+
// const start = Math.floor(Math.log(v)/Math.log(2));
|
|
41
|
+
// for(let i= start; i<start+10; i++) {
|
|
42
|
+
// const curVal = Math.abs(v) * Math.pow(2,-i);
|
|
43
|
+
// if (curVal >= 0.5 && curVal < 1 ) {
|
|
44
|
+
// return i;
|
|
45
|
+
// }
|
|
46
|
+
// }
|
|
47
|
+
// throw new Error('method not written yet');
|
|
48
|
+
// // return (int)((S2.EXPONENT_MASK & bits) >> S2.EXPONENT_SHIFT) - 1022;
|
|
49
|
+
return exponent(v);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.Platform = Platform;
|
|
53
|
+
//# sourceMappingURL=Platform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Platform.js","sourceRoot":"","sources":["../src/Platform.ts"],"names":[],"mappings":";;;AAAA,kDAAmD;AACnD,MAAa,QAAQ;IACZ,MAAM,CAAC,aAAa,CAAC,EAAU,EAAE,EAAU;QAChD,mBAAmB;QAEnB,0DAA0D;QAC1D,cAAc;QACd,WAAW;QACX,4CAA4C;QAC5C,IAAI;QAEJ,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE;YACpB,OAAO,EAAE,CAAC;SACX;QAED,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE;YACpB,OAAO,EAAE,CAAA;SACV;QAED,IAAI,CAAC,EAAE,KAAK,MAAM,CAAC,iBAAiB,IAAI,EAAE,KAAK,MAAM,CAAC,iBAAiB,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE;YAC/F,OAAO,EAAE,CAAC;SACX;QAED,OAAO,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;IACzC,CAAC;IAED;;;;;;;;;;OAUG;IACI,MAAM,CAAC,WAAW,CAAC,CAAQ;QAChC,gBAAgB;QAChB,cAAc;QACd,IAAI;QACJ,4CAA4C;QAC5C,qDAAqD;QACrD,uCAAuC;QACvC,iDAAiD;QACjD,wCAAwC;QACxC,gBAAgB;QAChB,MAAM;QACN,IAAI;QACJ,6CAA6C;QAC7C,0EAA0E;QAC1E,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC;CACF;AApDD,4BAoDC"}
|
package/dist/R1Interval.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="decimal.js" />
|
|
2
1
|
import { Interval } from "./Interval";
|
|
3
2
|
/**
|
|
4
3
|
* An R1Interval represents a closed interval on a unit circle (also known as a
|
|
@@ -22,11 +21,11 @@ import { Interval } from "./Interval";
|
|
|
22
21
|
export declare class R1Interval extends Interval {
|
|
23
22
|
/** Return true if the interval is empty, i.e. it contains no points. */
|
|
24
23
|
isEmpty(): boolean;
|
|
25
|
-
getCenter():
|
|
26
|
-
getLength():
|
|
27
|
-
contains(
|
|
24
|
+
getCenter(): number;
|
|
25
|
+
getLength(): number;
|
|
26
|
+
contains(p: number): boolean;
|
|
28
27
|
/** Return true if the interior of the interval contains the point 'p'. */
|
|
29
|
-
interiorContains(
|
|
28
|
+
interiorContains(p: number): boolean;
|
|
30
29
|
/**
|
|
31
30
|
* Return true if the interval contains the given interval 'y'. Works for
|
|
32
31
|
* empty, full, and singleton intervals.
|
|
@@ -44,13 +43,13 @@ export declare class R1Interval extends Interval {
|
|
|
44
43
|
*/
|
|
45
44
|
interiorIntersects(y: R1Interval): boolean;
|
|
46
45
|
/** Expand the interval so that it contains the given point "p". */
|
|
47
|
-
addPoint(
|
|
46
|
+
addPoint(p: number): R1Interval;
|
|
48
47
|
/**
|
|
49
48
|
* Return an interval that contains all points with a distance "radius" of a
|
|
50
49
|
* point in this interval. Note that the expansion of an empty interval is
|
|
51
50
|
* always empty.
|
|
52
51
|
*/
|
|
53
|
-
expanded(
|
|
52
|
+
expanded(radius: number): R1Interval;
|
|
54
53
|
/**
|
|
55
54
|
* Return the smallest interval that contains this interval and the given
|
|
56
55
|
* interval "y".
|
|
@@ -67,11 +66,11 @@ export declare class R1Interval extends Interval {
|
|
|
67
66
|
*/
|
|
68
67
|
approxEquals(y: R1Interval, maxError?: number): boolean;
|
|
69
68
|
static empty(): R1Interval;
|
|
70
|
-
static fromPoint(p: number
|
|
69
|
+
static fromPoint(p: number): R1Interval;
|
|
71
70
|
/**
|
|
72
71
|
* Convenience method to construct the minimal interval containing the two
|
|
73
72
|
* given points. This is equivalent to starting with an empty interval and
|
|
74
73
|
* calling AddPoint() twice, but it is more efficient.
|
|
75
74
|
*/
|
|
76
|
-
static fromPointPair(
|
|
75
|
+
static fromPointPair(p1: number, p2: number): R1Interval;
|
|
77
76
|
}
|
package/dist/R1Interval.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
6
|
-
};
|
|
7
|
-
var Interval_1 = require("./Interval");
|
|
8
|
-
var S2_1 = require("./S2");
|
|
9
|
-
var decimal_1 = require('./decimal');
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.R1Interval = void 0;
|
|
4
|
+
const Interval_1 = require("./Interval");
|
|
10
5
|
/**
|
|
11
6
|
* An R1Interval represents a closed interval on a unit circle (also known as a
|
|
12
7
|
* 1-dimensional sphere). It is capable of representing the empty interval
|
|
@@ -26,152 +21,138 @@ var decimal_1 = require('./decimal');
|
|
|
26
21
|
* [-Pi, Pi], and the Empty() interval is [Pi, -Pi].
|
|
27
22
|
*
|
|
28
23
|
*/
|
|
29
|
-
|
|
30
|
-
__extends(R1Interval, _super);
|
|
31
|
-
function R1Interval() {
|
|
32
|
-
_super.apply(this, arguments);
|
|
33
|
-
}
|
|
24
|
+
class R1Interval extends Interval_1.Interval {
|
|
34
25
|
/** Return true if the interval is empty, i.e. it contains no points. */
|
|
35
|
-
|
|
36
|
-
return this.lo
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return this.lo
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return this.hi
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
};
|
|
26
|
+
isEmpty() {
|
|
27
|
+
return this.lo > this.hi;
|
|
28
|
+
}
|
|
29
|
+
getCenter() {
|
|
30
|
+
return (this.lo + this.hi) / 2;
|
|
31
|
+
}
|
|
32
|
+
getLength() {
|
|
33
|
+
return this.hi - this.lo;
|
|
34
|
+
}
|
|
35
|
+
contains(p) {
|
|
36
|
+
return p >= this.lo && p <= this.hi;
|
|
37
|
+
}
|
|
48
38
|
/** Return true if the interior of the interval contains the point 'p'. */
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
};
|
|
39
|
+
interiorContains(p) {
|
|
40
|
+
return p > this.lo && p < this.hi;
|
|
41
|
+
}
|
|
53
42
|
/**
|
|
54
43
|
* Return true if the interval contains the given interval 'y'. Works for
|
|
55
44
|
* empty, full, and singleton intervals.
|
|
56
45
|
*/
|
|
57
|
-
|
|
46
|
+
containsI(y) {
|
|
58
47
|
if (y.isEmpty()) {
|
|
59
48
|
return true;
|
|
60
49
|
}
|
|
61
|
-
return y.lo
|
|
62
|
-
}
|
|
63
|
-
|
|
50
|
+
return y.lo >= this.lo && y.hi <= this.hi;
|
|
51
|
+
}
|
|
52
|
+
interiorContainsI(y) {
|
|
64
53
|
if (y.isEmpty()) {
|
|
65
54
|
return true;
|
|
66
55
|
}
|
|
67
|
-
return y.lo
|
|
68
|
-
}
|
|
56
|
+
return y.lo > this.lo && y.hi < this.hi;
|
|
57
|
+
}
|
|
69
58
|
/**
|
|
70
59
|
* Return true if this interval intersects the given interval, i.e. if they
|
|
71
60
|
* have any points in common.
|
|
72
61
|
*/
|
|
73
|
-
|
|
74
|
-
if (this.lo
|
|
75
|
-
return y.lo
|
|
62
|
+
intersects(y) {
|
|
63
|
+
if (this.lo <= y.lo) {
|
|
64
|
+
return y.lo <= (this.hi) && y.lo <= (y.hi);
|
|
76
65
|
}
|
|
77
66
|
else {
|
|
78
|
-
return this.lo
|
|
67
|
+
return this.lo <= (y.hi) && this.lo <= (this.hi);
|
|
79
68
|
}
|
|
80
|
-
}
|
|
69
|
+
}
|
|
81
70
|
/**
|
|
82
71
|
* Return true if the interior of this interval intersects any point of the
|
|
83
72
|
* given interval (including its boundary).
|
|
84
73
|
*/
|
|
85
|
-
|
|
86
|
-
return y.lo
|
|
87
|
-
}
|
|
74
|
+
interiorIntersects(y) {
|
|
75
|
+
return y.lo < (this.hi) && this.lo < (y.hi) && this.lo < (this.hi) && y.lo <= (y.hi);
|
|
76
|
+
}
|
|
88
77
|
/** Expand the interval so that it contains the given point "p". */
|
|
89
|
-
|
|
90
|
-
var p = S2_1.S2.toDecimal(_p);
|
|
78
|
+
addPoint(p) {
|
|
91
79
|
if (this.isEmpty()) {
|
|
92
80
|
return R1Interval.fromPoint(p);
|
|
93
81
|
}
|
|
94
|
-
else if (p
|
|
82
|
+
else if (p < (this.lo)) {
|
|
95
83
|
return new R1Interval(p, this.hi);
|
|
96
84
|
}
|
|
97
|
-
else if (p
|
|
85
|
+
else if (p > (this.hi)) {
|
|
98
86
|
return new R1Interval(this.lo, p);
|
|
99
87
|
}
|
|
100
88
|
else {
|
|
101
89
|
return new R1Interval(this.lo, this.hi);
|
|
102
90
|
}
|
|
103
|
-
}
|
|
91
|
+
}
|
|
104
92
|
/**
|
|
105
93
|
* Return an interval that contains all points with a distance "radius" of a
|
|
106
94
|
* point in this interval. Note that the expansion of an empty interval is
|
|
107
95
|
* always empty.
|
|
108
96
|
*/
|
|
109
|
-
|
|
110
|
-
var radius = S2_1.S2.toDecimal(_radius);
|
|
97
|
+
expanded(radius) {
|
|
111
98
|
// assert (radius >= 0);
|
|
112
99
|
if (this.isEmpty()) {
|
|
113
100
|
return this;
|
|
114
101
|
}
|
|
115
|
-
return new R1Interval(this.lo
|
|
116
|
-
}
|
|
102
|
+
return new R1Interval(this.lo - radius, this.hi + radius);
|
|
103
|
+
}
|
|
117
104
|
/**
|
|
118
105
|
* Return the smallest interval that contains this interval and the given
|
|
119
106
|
* interval "y".
|
|
120
107
|
*/
|
|
121
|
-
|
|
108
|
+
union(y) {
|
|
122
109
|
if (this.isEmpty()) {
|
|
123
110
|
return y;
|
|
124
111
|
}
|
|
125
112
|
if (y.isEmpty()) {
|
|
126
113
|
return this;
|
|
127
114
|
}
|
|
128
|
-
return new R1Interval(
|
|
129
|
-
}
|
|
115
|
+
return new R1Interval(Math.min(this.lo, y.lo), Math.max(this.hi, y.hi));
|
|
116
|
+
}
|
|
130
117
|
/**
|
|
131
118
|
* Return the intersection of this interval with the given interval. Empty
|
|
132
119
|
* intervals do not need to be special-cased.
|
|
133
120
|
*/
|
|
134
|
-
|
|
135
|
-
return new R1Interval(
|
|
136
|
-
}
|
|
121
|
+
intersection(y) {
|
|
122
|
+
return new R1Interval(Math.max(this.lo, y.lo), Math.min(this.hi, y.hi));
|
|
123
|
+
}
|
|
137
124
|
/**
|
|
138
125
|
* Return true if the length of the symmetric difference between the two
|
|
139
126
|
* intervals is at most the given tolerance.
|
|
140
127
|
*/
|
|
141
|
-
|
|
142
|
-
if (maxError === void 0) { maxError = 1e-15; }
|
|
128
|
+
approxEquals(y, maxError = 1e-15) {
|
|
143
129
|
if (this.isEmpty()) {
|
|
144
|
-
return y.getLength()
|
|
130
|
+
return y.getLength() <= (maxError);
|
|
145
131
|
}
|
|
146
132
|
if (y.isEmpty()) {
|
|
147
|
-
return this.getLength()
|
|
133
|
+
return this.getLength() <= (maxError);
|
|
148
134
|
}
|
|
149
|
-
return y.lo
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
};
|
|
153
|
-
R1Interval.empty = function () {
|
|
135
|
+
return Math.abs(y.lo - (this.lo)) + Math.abs(y.hi - this.hi) <= (maxError);
|
|
136
|
+
}
|
|
137
|
+
static empty() {
|
|
154
138
|
return new R1Interval(1, 0);
|
|
155
|
-
}
|
|
156
|
-
|
|
139
|
+
}
|
|
140
|
+
static fromPoint(p) {
|
|
157
141
|
return new R1Interval(p, p);
|
|
158
|
-
}
|
|
142
|
+
}
|
|
159
143
|
/**
|
|
160
144
|
* Convenience method to construct the minimal interval containing the two
|
|
161
145
|
* given points. This is equivalent to starting with an empty interval and
|
|
162
146
|
* calling AddPoint() twice, but it is more efficient.
|
|
163
147
|
*/
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
var p2 = S2_1.S2.toDecimal(_p2);
|
|
167
|
-
if (p1.lte(p2)) {
|
|
148
|
+
static fromPointPair(p1, p2) {
|
|
149
|
+
if (p1 <= (p2)) {
|
|
168
150
|
return new R1Interval(p1, p2);
|
|
169
151
|
}
|
|
170
152
|
else {
|
|
171
153
|
return new R1Interval(p2, p1);
|
|
172
154
|
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
}(Interval_1.Interval));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
176
157
|
exports.R1Interval = R1Interval;
|
|
177
158
|
//# sourceMappingURL=R1Interval.js.map
|
package/dist/R1Interval.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"R1Interval.js","sourceRoot":"","sources":["../src/R1Interval.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"R1Interval.js","sourceRoot":"","sources":["../src/R1Interval.ts"],"names":[],"mappings":";;;AAAA,yCAAoC;AACpC;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAa,UAAW,SAA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B,CAAC;IAGD,MAAM,CAAC,SAAS,CAAC,CAAQ;QACvB,OAAO,IAAI,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9B,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,aAAa,CAAC,EAAS,EAAE,EAAS;QACvC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE;YACd,OAAO,IAAI,UAAU,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;SAC/B;aAAM;YACL,OAAO,IAAI,UAAU,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;SAC/B;IACH,CAAC;CACF;AA3JD,gCA2JC"}
|
package/dist/R2Vector.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="decimal.js" />
|
|
2
1
|
import { S2Point } from "./S2Point";
|
|
3
2
|
/**
|
|
4
3
|
* R2Vector represents a vector in the two-dimensional space. It defines the
|
|
@@ -9,27 +8,27 @@ import { S2Point } from "./S2Point";
|
|
|
9
8
|
export declare class R2Vector {
|
|
10
9
|
private _x;
|
|
11
10
|
private _y;
|
|
12
|
-
constructor(_x: number
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
get(index: number):
|
|
11
|
+
constructor(_x: number, _y: number);
|
|
12
|
+
get x(): number;
|
|
13
|
+
get y(): number;
|
|
14
|
+
get(index: number): number;
|
|
16
15
|
static fromPointFace(p: S2Point, face: number): R2Vector;
|
|
17
16
|
static add(p1: R2Vector, p2: R2Vector): R2Vector;
|
|
18
|
-
static mul(p: R2Vector,
|
|
19
|
-
norm2():
|
|
20
|
-
static dotProd(p1: R2Vector, p2: R2Vector):
|
|
21
|
-
dotProd(that: R2Vector):
|
|
22
|
-
crossProd(that: R2Vector):
|
|
17
|
+
static mul(p: R2Vector, m: number): R2Vector;
|
|
18
|
+
norm2(): number;
|
|
19
|
+
static dotProd(p1: R2Vector, p2: R2Vector): number;
|
|
20
|
+
dotProd(that: R2Vector): number;
|
|
21
|
+
crossProd(that: R2Vector): number;
|
|
23
22
|
lessThan(vb: R2Vector): boolean;
|
|
24
23
|
static fromSTVector(stVector: R2Vector): R2Vector;
|
|
25
|
-
static singleStTOUV(
|
|
26
|
-
static singleUVToST(
|
|
24
|
+
static singleStTOUV(s: number): number;
|
|
25
|
+
static singleUVToST(u: number): number;
|
|
27
26
|
/**
|
|
28
27
|
* To be used only if this vector is representing uv.
|
|
29
28
|
* @param face
|
|
30
29
|
* @returns {S2Point}
|
|
31
30
|
*/
|
|
32
31
|
toPoint(face: number): S2Point;
|
|
33
|
-
toSt(which: any):
|
|
32
|
+
toSt(which: any): number;
|
|
34
33
|
toString(): string;
|
|
35
34
|
}
|