dgeoutils 2.2.5 → 2.2.9
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/dist/DCircle.d.ts +0 -28
- package/dist/DCircle.js +0 -30
- package/dist/DLine.d.ts +0 -60
- package/dist/DLine.js +1 -67
- package/dist/DPoint.d.ts +2 -129
- package/dist/DPoint.js +4 -50
- package/dist/DPolygon.d.ts +4 -209
- package/dist/DPolygon.js +87 -249
- package/dist/DPolygonLoop.d.ts +2 -72
- package/dist/DPolygonLoop.js +35 -35
- package/dist/TraceMatrix.js +0 -1
- package/dist/utils.js +0 -3
- package/package.json +1 -1
package/dist/DCircle.d.ts
CHANGED
|
@@ -3,10 +3,6 @@ import { DPolygon } from './DPolygon';
|
|
|
3
3
|
export declare class DCircle {
|
|
4
4
|
center: DPoint;
|
|
5
5
|
r: number;
|
|
6
|
-
/**
|
|
7
|
-
* @param [center=(0,0)]
|
|
8
|
-
* @param [r=0]
|
|
9
|
-
*/
|
|
10
6
|
constructor(center?: DPoint, r?: number);
|
|
11
7
|
toString(): string;
|
|
12
8
|
getValue(): {
|
|
@@ -14,33 +10,9 @@ export declare class DCircle {
|
|
|
14
10
|
r: number;
|
|
15
11
|
};
|
|
16
12
|
clone(): DCircle;
|
|
17
|
-
/**
|
|
18
|
-
* Find intersection points with other circle.
|
|
19
|
-
*
|
|
20
|
-
* 
|
|
21
|
-
* @param c
|
|
22
|
-
*/
|
|
23
13
|
findPoints(c: DCircle): DPoint[] | number;
|
|
24
14
|
equal({ center, r }: DCircle): boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Transform circle to polygon
|
|
27
|
-
*
|
|
28
|
-
* 
|
|
29
|
-
* @param [pointCount=64]
|
|
30
|
-
*/
|
|
31
15
|
findPolygonInside(pointCount?: number): DPolygon;
|
|
32
|
-
/**
|
|
33
|
-
* Transform circle to polygon on sphere. It would be different for different latitude.
|
|
34
|
-
*
|
|
35
|
-
* @remarks
|
|
36
|
-
* Center should be Lng/Lat.
|
|
37
|
-
*
|
|
38
|
-
* @remarks
|
|
39
|
-
* Radius should be in meters.
|
|
40
|
-
*
|
|
41
|
-
* 
|
|
42
|
-
* @param [pointCount=64]
|
|
43
|
-
*/
|
|
44
16
|
findPolygonInsideOnSphere(pointCount?: number): DPolygon;
|
|
45
17
|
private sphereOffset;
|
|
46
18
|
}
|
package/dist/DCircle.js
CHANGED
|
@@ -5,13 +5,7 @@ const DPoint_1 = require("./DPoint");
|
|
|
5
5
|
const DPolygon_1 = require("./DPolygon");
|
|
6
6
|
const DNumbers_1 = require("./DNumbers");
|
|
7
7
|
const utils_1 = require("./utils");
|
|
8
|
-
// eslint-disable-next-line padded-blocks
|
|
9
8
|
class DCircle {
|
|
10
|
-
/**
|
|
11
|
-
* @param [center=(0,0)]
|
|
12
|
-
* @param [r=0]
|
|
13
|
-
*/
|
|
14
|
-
// eslint-disable-next-line no-useless-constructor,no-empty-function
|
|
15
9
|
constructor(center = DPoint_1.DPoint.zero(), r = 0) {
|
|
16
10
|
this.center = center;
|
|
17
11
|
this.r = r;
|
|
@@ -25,12 +19,6 @@ class DCircle {
|
|
|
25
19
|
clone() {
|
|
26
20
|
return new DCircle(this.center, this.r);
|
|
27
21
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Find intersection points with other circle.
|
|
30
|
-
*
|
|
31
|
-
* 
|
|
32
|
-
* @param c
|
|
33
|
-
*/
|
|
34
22
|
findPoints(c) {
|
|
35
23
|
if (this.equal(c)) {
|
|
36
24
|
return Infinity;
|
|
@@ -63,12 +51,6 @@ class DCircle {
|
|
|
63
51
|
equal({ center, r }) {
|
|
64
52
|
return this.center.equal(center) && this.r === r;
|
|
65
53
|
}
|
|
66
|
-
/**
|
|
67
|
-
* Transform circle to polygon
|
|
68
|
-
*
|
|
69
|
-
* 
|
|
70
|
-
* @param [pointCount=64]
|
|
71
|
-
*/
|
|
72
54
|
findPolygonInside(pointCount = 64) {
|
|
73
55
|
const preAngle = 2 * Math.PI / pointCount;
|
|
74
56
|
const points = [];
|
|
@@ -80,18 +62,6 @@ class DCircle {
|
|
|
80
62
|
}
|
|
81
63
|
return new DPolygon_1.DPolygon([...points, points[0]]);
|
|
82
64
|
}
|
|
83
|
-
/**
|
|
84
|
-
* Transform circle to polygon on sphere. It would be different for different latitude.
|
|
85
|
-
*
|
|
86
|
-
* @remarks
|
|
87
|
-
* Center should be Lng/Lat.
|
|
88
|
-
*
|
|
89
|
-
* @remarks
|
|
90
|
-
* Radius should be in meters.
|
|
91
|
-
*
|
|
92
|
-
* 
|
|
93
|
-
* @param [pointCount=64]
|
|
94
|
-
*/
|
|
95
65
|
findPolygonInsideOnSphere(pointCount = 64) {
|
|
96
66
|
(0, utils_1.checkFunction)('findPolygonInsideOnSphere')
|
|
97
67
|
.checkArgument('center')
|
package/dist/DLine.d.ts
CHANGED
|
@@ -6,37 +6,13 @@ export declare class DLine {
|
|
|
6
6
|
c: number;
|
|
7
7
|
begin: DPoint;
|
|
8
8
|
end: DPoint;
|
|
9
|
-
/**
|
|
10
|
-
* @param a
|
|
11
|
-
* @param b
|
|
12
|
-
* @param c
|
|
13
|
-
* @param [begin=DPoint.zero()]
|
|
14
|
-
* @param [end=DPoint.zero()]
|
|
15
|
-
*/
|
|
16
9
|
constructor(a: number, b: number, c: number, begin?: DPoint, end?: DPoint);
|
|
17
10
|
clone(): DLine;
|
|
18
11
|
findPerpendicular(p: DPoint): DLine;
|
|
19
12
|
perpendicularDistance(p: DPoint): number;
|
|
20
|
-
/**
|
|
21
|
-
* Find intersection of two lines segments.
|
|
22
|
-
* For intersection of two lines use [[findPoint]]
|
|
23
|
-
* @param l
|
|
24
|
-
* @param [d=0]
|
|
25
|
-
* @param [includeOnly=false]
|
|
26
|
-
*/
|
|
27
13
|
intersection(l: DLine, d?: number, includeOnly?: boolean): DPoint | null;
|
|
28
14
|
intersectionWithCircle(circle: DCircle): DPoint | [DPoint, DPoint] | null;
|
|
29
|
-
/**
|
|
30
|
-
* Check if point below to line segment
|
|
31
|
-
* @param p
|
|
32
|
-
* @param d
|
|
33
|
-
*/
|
|
34
15
|
inRange(p: DPoint, d?: number): boolean;
|
|
35
|
-
/**
|
|
36
|
-
* Check if point below to line segment, but not equal star or end point.
|
|
37
|
-
* @param p
|
|
38
|
-
* @param [d=0]
|
|
39
|
-
*/
|
|
40
16
|
insideRange(p: DPoint, d?: number): boolean;
|
|
41
17
|
get center(): DPoint;
|
|
42
18
|
get minX(): number;
|
|
@@ -45,52 +21,16 @@ export declare class DLine {
|
|
|
45
21
|
get maxY(): number;
|
|
46
22
|
toString(): string;
|
|
47
23
|
getValue(): number[];
|
|
48
|
-
/**
|
|
49
|
-
* Find `x` from `y` value of point
|
|
50
|
-
* @param p
|
|
51
|
-
*/
|
|
52
24
|
x(p: DPoint): DPoint;
|
|
53
|
-
/**
|
|
54
|
-
* Find `y` from `x` value of point
|
|
55
|
-
* @param p
|
|
56
|
-
*/
|
|
57
25
|
y(p: DPoint): DPoint;
|
|
58
|
-
/**
|
|
59
|
-
* Find intersection of two lines.
|
|
60
|
-
* For intersection of two lines segments use [[intersection]]
|
|
61
|
-
* @param l
|
|
62
|
-
*/
|
|
63
26
|
findPoint(l: DLine): DPoint | null;
|
|
64
|
-
/**
|
|
65
|
-
* Check if line parallel to `x` or `y` axis
|
|
66
|
-
*/
|
|
67
27
|
get isParallel(): boolean;
|
|
68
28
|
get isParallelY(): boolean;
|
|
69
29
|
get isParallelX(): boolean;
|
|
70
|
-
/**
|
|
71
|
-
* Get lines segment start and end points as array
|
|
72
|
-
*/
|
|
73
30
|
get points(): [DPoint, DPoint];
|
|
74
|
-
/**
|
|
75
|
-
* Get line segment direction (from start point to end point)
|
|
76
|
-
*/
|
|
77
31
|
getFi(): number;
|
|
78
32
|
toWKT(): string;
|
|
79
|
-
/**
|
|
80
|
-
* Move lines point to left or right
|
|
81
|
-
* @param p
|
|
82
|
-
* @param d
|
|
83
|
-
*/
|
|
84
33
|
movePoint(p: DPoint, d: number): DPoint;
|
|
85
|
-
/**
|
|
86
|
-
* Find angle between current line and line in argument
|
|
87
|
-
* @param l
|
|
88
|
-
* @param delta
|
|
89
|
-
*/
|
|
90
34
|
findFi({ a, b }: DLine, delta?: number): number;
|
|
91
|
-
/**
|
|
92
|
-
* [Cross product](https://en.wikipedia.org/wiki/Cross_product)
|
|
93
|
-
* @param l {DLine}
|
|
94
|
-
*/
|
|
95
35
|
vectorProduct({ a, b, c }: DLine): DLine;
|
|
96
36
|
}
|
package/dist/DLine.js
CHANGED
|
@@ -3,19 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DLine = void 0;
|
|
4
4
|
const DPoint_1 = require("./DPoint");
|
|
5
5
|
const utils_1 = require("./utils");
|
|
6
|
-
// eslint-disable-next-line padded-blocks
|
|
7
6
|
class DLine {
|
|
8
|
-
|
|
9
|
-
* @param a
|
|
10
|
-
* @param b
|
|
11
|
-
* @param c
|
|
12
|
-
* @param [begin=DPoint.zero()]
|
|
13
|
-
* @param [end=DPoint.zero()]
|
|
14
|
-
*/
|
|
15
|
-
// eslint-disable-next-line no-useless-constructor
|
|
16
|
-
constructor(a, b, c, begin = DPoint_1.DPoint.zero(), end = DPoint_1.DPoint.zero()
|
|
17
|
-
// eslint-disable-next-line no-empty-function
|
|
18
|
-
) {
|
|
7
|
+
constructor(a, b, c, begin = DPoint_1.DPoint.zero(), end = DPoint_1.DPoint.zero()) {
|
|
19
8
|
this.a = a;
|
|
20
9
|
this.b = b;
|
|
21
10
|
this.c = c;
|
|
@@ -47,13 +36,6 @@ class DLine {
|
|
|
47
36
|
const targetPoint = perpendicularLine.findPoint(this);
|
|
48
37
|
return targetPoint.distance(p);
|
|
49
38
|
}
|
|
50
|
-
/**
|
|
51
|
-
* Find intersection of two lines segments.
|
|
52
|
-
* For intersection of two lines use [[findPoint]]
|
|
53
|
-
* @param l
|
|
54
|
-
* @param [d=0]
|
|
55
|
-
* @param [includeOnly=false]
|
|
56
|
-
*/
|
|
57
39
|
intersection(l, d = 0, includeOnly = false) {
|
|
58
40
|
const p = this.findPoint(l);
|
|
59
41
|
if (p) {
|
|
@@ -80,14 +62,12 @@ class DLine {
|
|
|
80
62
|
if (this.isParallel) {
|
|
81
63
|
const ct = center.distance(t);
|
|
82
64
|
const move = Math.sqrt(r * r - ct * ct);
|
|
83
|
-
// Mean "|" x = const
|
|
84
65
|
if (this.isParallelY) {
|
|
85
66
|
t.x = this.begin.x;
|
|
86
67
|
const r1 = t.clone().move(0, -move);
|
|
87
68
|
const r2 = t.clone().move(0, move);
|
|
88
69
|
return [r1, r2];
|
|
89
70
|
}
|
|
90
|
-
// Mean "-" y = const
|
|
91
71
|
if (this.isParallelX) {
|
|
92
72
|
t.y = this.begin.y;
|
|
93
73
|
const r1 = t.clone().move(move, 0);
|
|
@@ -115,11 +95,6 @@ class DLine {
|
|
|
115
95
|
}
|
|
116
96
|
return null;
|
|
117
97
|
}
|
|
118
|
-
/**
|
|
119
|
-
* Check if point below to line segment
|
|
120
|
-
* @param p
|
|
121
|
-
* @param d
|
|
122
|
-
*/
|
|
123
98
|
inRange(p, d = 0) {
|
|
124
99
|
const { minX, minY, maxX, maxY } = this;
|
|
125
100
|
const { x, y } = p;
|
|
@@ -127,11 +102,6 @@ class DLine {
|
|
|
127
102
|
const isInY = y >= minY - d && y <= maxY + d;
|
|
128
103
|
return isInX && isInY;
|
|
129
104
|
}
|
|
130
|
-
/**
|
|
131
|
-
* Check if point below to line segment, but not equal star or end point.
|
|
132
|
-
* @param p
|
|
133
|
-
* @param [d=0]
|
|
134
|
-
*/
|
|
135
105
|
insideRange(p, d = 0) {
|
|
136
106
|
const { begin, end } = this;
|
|
137
107
|
return this.inRange(p, d) && !begin.like(p, 0.00001) && !end.like(p, 0.00001);
|
|
@@ -167,10 +137,6 @@ class DLine {
|
|
|
167
137
|
getValue() {
|
|
168
138
|
return [this.a, this.b, this.c];
|
|
169
139
|
}
|
|
170
|
-
/**
|
|
171
|
-
* Find `x` from `y` value of point
|
|
172
|
-
* @param p
|
|
173
|
-
*/
|
|
174
140
|
x(p) {
|
|
175
141
|
if (this.isParallelY) {
|
|
176
142
|
return new DPoint_1.DPoint(-this.c / this.a, p.y);
|
|
@@ -180,10 +146,6 @@ class DLine {
|
|
|
180
146
|
}
|
|
181
147
|
return new DPoint_1.DPoint(-this.b / this.a * p.y - this.c / this.a, p.y);
|
|
182
148
|
}
|
|
183
|
-
/**
|
|
184
|
-
* Find `y` from `x` value of point
|
|
185
|
-
* @param p
|
|
186
|
-
*/
|
|
187
149
|
y(p) {
|
|
188
150
|
if (this.isParallelY) {
|
|
189
151
|
return new DPoint_1.DPoint(-this.c / this.a, p.y);
|
|
@@ -193,11 +155,6 @@ class DLine {
|
|
|
193
155
|
}
|
|
194
156
|
return new DPoint_1.DPoint(p.x, -this.a / this.b * p.x - this.c / this.b);
|
|
195
157
|
}
|
|
196
|
-
/**
|
|
197
|
-
* Find intersection of two lines.
|
|
198
|
-
* For intersection of two lines segments use [[intersection]]
|
|
199
|
-
* @param l
|
|
200
|
-
*/
|
|
201
158
|
findPoint(l) {
|
|
202
159
|
if (this.isParallelY && l.isParallelY) {
|
|
203
160
|
return null;
|
|
@@ -233,9 +190,6 @@ class DLine {
|
|
|
233
190
|
}
|
|
234
191
|
return res;
|
|
235
192
|
}
|
|
236
|
-
/**
|
|
237
|
-
* Check if line parallel to `x` or `y` axis
|
|
238
|
-
*/
|
|
239
193
|
get isParallel() {
|
|
240
194
|
return this.isParallelX || this.isParallelY;
|
|
241
195
|
}
|
|
@@ -245,15 +199,9 @@ class DLine {
|
|
|
245
199
|
get isParallelX() {
|
|
246
200
|
return Math.abs(this.a) < 0.001;
|
|
247
201
|
}
|
|
248
|
-
/**
|
|
249
|
-
* Get lines segment start and end points as array
|
|
250
|
-
*/
|
|
251
202
|
get points() {
|
|
252
203
|
return [this.begin, this.end];
|
|
253
204
|
}
|
|
254
|
-
/**
|
|
255
|
-
* Get line segment direction (from start point to end point)
|
|
256
|
-
*/
|
|
257
205
|
getFi() {
|
|
258
206
|
(0, utils_1.checkFunction)('getFi')
|
|
259
207
|
.checkArgument('this.begin')
|
|
@@ -271,11 +219,6 @@ class DLine {
|
|
|
271
219
|
const { begin: { x: x1, y: y1 }, end: { x: x2, y: y2 } } = this;
|
|
272
220
|
return `LINESTRING (${x1} ${y1}, ${x2} ${y2})`;
|
|
273
221
|
}
|
|
274
|
-
/**
|
|
275
|
-
* Move lines point to left or right
|
|
276
|
-
* @param p
|
|
277
|
-
* @param d
|
|
278
|
-
*/
|
|
279
222
|
movePoint(p, d) {
|
|
280
223
|
const fi = this.findFi(new DLine(1, 0, 0));
|
|
281
224
|
const td = this.begin.distance(this.end) / 2;
|
|
@@ -292,11 +235,6 @@ class DLine {
|
|
|
292
235
|
}
|
|
293
236
|
return p3;
|
|
294
237
|
}
|
|
295
|
-
/**
|
|
296
|
-
* Find angle between current line and line in argument
|
|
297
|
-
* @param l
|
|
298
|
-
* @param delta
|
|
299
|
-
*/
|
|
300
238
|
findFi({ a, b }, delta = 1.0001) {
|
|
301
239
|
const { a: q, b: w } = this;
|
|
302
240
|
let val = (q * a + w * b) / (Math.sqrt(q * q + w * w) * Math.sqrt(a * a + b * b));
|
|
@@ -308,10 +246,6 @@ class DLine {
|
|
|
308
246
|
}
|
|
309
247
|
return Math.acos(val);
|
|
310
248
|
}
|
|
311
|
-
/**
|
|
312
|
-
* [Cross product](https://en.wikipedia.org/wiki/Cross_product)
|
|
313
|
-
* @param l {DLine}
|
|
314
|
-
*/
|
|
315
249
|
vectorProduct({ a, b, c }) {
|
|
316
250
|
const { a: q, b: w, c: e } = this;
|
|
317
251
|
return new DLine(w * c - e * b, e * a - q * c, q * b - w * a);
|
package/dist/DPoint.d.ts
CHANGED
|
@@ -19,53 +19,17 @@ export declare class DPoint {
|
|
|
19
19
|
properties: {
|
|
20
20
|
[key: string]: any;
|
|
21
21
|
};
|
|
22
|
-
/**
|
|
23
|
-
* Create point with zero coords `(0, 0)`
|
|
24
|
-
*/
|
|
25
22
|
constructor();
|
|
26
|
-
/**
|
|
27
|
-
* Create point
|
|
28
|
-
* @param xy - `x` and `y` value
|
|
29
|
-
*/
|
|
30
23
|
constructor(xy: number);
|
|
31
|
-
/**
|
|
32
|
-
* Create point
|
|
33
|
-
* @param x - lng, meters to East, radians to East or width
|
|
34
|
-
* @param y - lat, meters to North, radians to North or height
|
|
35
|
-
*/
|
|
36
24
|
constructor(x: number, y: number);
|
|
37
|
-
/**
|
|
38
|
-
* Create point
|
|
39
|
-
* @param x - lng, meters to East, radians to East or width
|
|
40
|
-
* @param y - lat, meters to North, radians to North or height
|
|
41
|
-
* @param z - height
|
|
42
|
-
*/
|
|
43
25
|
constructor(x: number, y: number, z?: number);
|
|
44
26
|
static zero(): DPoint;
|
|
45
27
|
static parse(c: LatLng | number[] | DCoord): DPoint;
|
|
46
28
|
static parseFromWKT(wkt: string): DPoint;
|
|
47
29
|
static random(): DPoint;
|
|
48
|
-
/**
|
|
49
|
-
* @remark Point should be Lng/Lat.
|
|
50
|
-
*
|
|
51
|
-
* @remark `z` value default for `zoom` argument.
|
|
52
|
-
*
|
|
53
|
-
* @param [zoom=this.z]
|
|
54
|
-
*/
|
|
55
30
|
getTileFromCoords(zoom?: number): DPoint;
|
|
56
|
-
/**
|
|
57
|
-
* Result would be Lng/Lat.
|
|
58
|
-
*
|
|
59
|
-
* @remark `z` value default for `zoom` argument.
|
|
60
|
-
*
|
|
61
|
-
* @param [zoom=this.z]
|
|
62
|
-
*/
|
|
63
31
|
getCoordsFromTile(zoom?: number): DPoint;
|
|
64
32
|
toCoords(): DCoord;
|
|
65
|
-
/**
|
|
66
|
-
* Find line between two points.
|
|
67
|
-
* @param p
|
|
68
|
-
*/
|
|
69
33
|
findLine(p: DPoint): DLine;
|
|
70
34
|
findInnerAngle(p1: DPoint, p3: DPoint): number;
|
|
71
35
|
toString(): string;
|
|
@@ -73,51 +37,20 @@ export declare class DPoint {
|
|
|
73
37
|
height(z: number): DPoint;
|
|
74
38
|
toWKT(): string;
|
|
75
39
|
distance(p: DPoint): number;
|
|
76
|
-
/**
|
|
77
|
-
* Set `x` value
|
|
78
|
-
* @param x
|
|
79
|
-
*/
|
|
80
40
|
setX(x: number): DPoint;
|
|
81
|
-
/**
|
|
82
|
-
* Transform `x` value by function
|
|
83
|
-
* @param f
|
|
84
|
-
*/
|
|
85
41
|
setX(f: SetterFunction): DPoint;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
* @param y
|
|
89
|
-
*/
|
|
42
|
+
setZ(z: number): DPoint;
|
|
43
|
+
setZ(f: SetterFunction): DPoint;
|
|
90
44
|
setY(y: number): DPoint;
|
|
91
|
-
/**
|
|
92
|
-
* Transform `y` value by function
|
|
93
|
-
* @param f
|
|
94
|
-
*/
|
|
95
45
|
setY(f: SetterFunction): DPoint;
|
|
96
46
|
clone(): DPoint;
|
|
97
47
|
gt(p: DPoint): boolean;
|
|
98
48
|
lt(p: DPoint): boolean;
|
|
99
49
|
gtOrEqual(p: DPoint): boolean;
|
|
100
50
|
ltOrEqual(p: DPoint): boolean;
|
|
101
|
-
/**
|
|
102
|
-
* Clockwise rotation
|
|
103
|
-
* @param a radians
|
|
104
|
-
*/
|
|
105
51
|
rotate(a: number): DPoint;
|
|
106
|
-
/**
|
|
107
|
-
* Add `v` to `x` and `y`
|
|
108
|
-
* @param v
|
|
109
|
-
*/
|
|
110
52
|
move(v: number): DPoint;
|
|
111
|
-
/**
|
|
112
|
-
* Add `p.x` to `x` field and `p.y` to `y` field.
|
|
113
|
-
* @param p
|
|
114
|
-
*/
|
|
115
53
|
move(p: DPoint): DPoint;
|
|
116
|
-
/**
|
|
117
|
-
* Add `x` to `x` field and `y` to `y` field.
|
|
118
|
-
* @param x
|
|
119
|
-
* @param y
|
|
120
|
-
*/
|
|
121
54
|
move(x: number, y: number): DPoint;
|
|
122
55
|
degreeToMeters(): DPoint;
|
|
123
56
|
metersToDegree(): DPoint;
|
|
@@ -128,70 +61,20 @@ export declare class DPoint {
|
|
|
128
61
|
round(): DPoint;
|
|
129
62
|
ceil(): DPoint;
|
|
130
63
|
floor(): DPoint;
|
|
131
|
-
/**
|
|
132
|
-
* @param [n=2]
|
|
133
|
-
*/
|
|
134
64
|
toFixed(n?: number): DPoint;
|
|
135
65
|
abs(): DPoint;
|
|
136
|
-
/**
|
|
137
|
-
* Multiply `v` to `x` and `y`
|
|
138
|
-
* @param v
|
|
139
|
-
*/
|
|
140
66
|
scale(v: number): DPoint;
|
|
141
|
-
/**
|
|
142
|
-
* Multiply `p.x` to `x` field and `p.y` to `y` field.
|
|
143
|
-
* @param p
|
|
144
|
-
*/
|
|
145
67
|
scale(p: DPoint): DPoint;
|
|
146
|
-
/**
|
|
147
|
-
* Multiply `x` to `x` field and `y` to `y` field.
|
|
148
|
-
* @param x
|
|
149
|
-
* @param y
|
|
150
|
-
*/
|
|
151
68
|
scale(x: number, y: number): DPoint;
|
|
152
|
-
/**
|
|
153
|
-
* Divide `x` and `y` to `v`
|
|
154
|
-
* @param v
|
|
155
|
-
*/
|
|
156
69
|
divide(v: number): DPoint;
|
|
157
|
-
/**
|
|
158
|
-
* Divide `x` field to `p.x` and `y` field to `p.y`.
|
|
159
|
-
* @param p
|
|
160
|
-
*/
|
|
161
70
|
divide(p: DPoint): DPoint;
|
|
162
|
-
/**
|
|
163
|
-
* Divide `x` field to `x` and `y` field to `y`.
|
|
164
|
-
* @param x
|
|
165
|
-
* @param y
|
|
166
|
-
*/
|
|
167
71
|
divide(x: number, y: number): DPoint;
|
|
168
72
|
equal(p: DPoint): boolean;
|
|
169
|
-
/**
|
|
170
|
-
* @param p
|
|
171
|
-
* @param [d=0.001]
|
|
172
|
-
*/
|
|
173
73
|
like(p: DPoint, d?: number): boolean;
|
|
174
|
-
/**
|
|
175
|
-
* Flip vertically
|
|
176
|
-
* @param size canvas size
|
|
177
|
-
*/
|
|
178
74
|
flipVertically(size: DPoint): DPoint;
|
|
179
|
-
/**
|
|
180
|
-
* Flip vertically
|
|
181
|
-
* @param height canvas height
|
|
182
|
-
*/
|
|
183
75
|
flipVertically(height: number): DPoint;
|
|
184
|
-
/**
|
|
185
|
-
* Check if point looks like radians
|
|
186
|
-
*/
|
|
187
76
|
get likeRadians(): boolean;
|
|
188
|
-
/**
|
|
189
|
-
* Check if point looks like `EPSG:4326` (degrees)
|
|
190
|
-
*/
|
|
191
77
|
get likeWorldGeodeticSystem(): boolean;
|
|
192
|
-
/**
|
|
193
|
-
* Check if point looks like `EPSG:3857` (meters)
|
|
194
|
-
*/
|
|
195
78
|
get likePseudoMercator(): boolean;
|
|
196
79
|
get w(): number;
|
|
197
80
|
set w(x: number);
|
|
@@ -211,15 +94,5 @@ export declare class DPoint {
|
|
|
211
94
|
};
|
|
212
95
|
setIfLessThan(p: DPoint): DPoint;
|
|
213
96
|
minus(): DPoint;
|
|
214
|
-
/**
|
|
215
|
-
* Find [orthodromic path](https://en.wikipedia.org/wiki/Great-circle_navigation) between to points.
|
|
216
|
-
*
|
|
217
|
-
* @remark Points should be Lng/Lat.
|
|
218
|
-
*
|
|
219
|
-
* 
|
|
220
|
-
*
|
|
221
|
-
* @param point
|
|
222
|
-
* @param [pointsCount=360]
|
|
223
|
-
*/
|
|
224
97
|
orthodromicPath(point: DPoint, pointsCount?: number): DPolygon;
|
|
225
98
|
}
|
package/dist/DPoint.js
CHANGED
|
@@ -19,12 +19,10 @@ exports.DOUBLE_PI_IN_DEGREE = 360;
|
|
|
19
19
|
exports.PI_TO_DEGREE = Math.PI / exports.PI_IN_DEGREE;
|
|
20
20
|
exports.DEGREE_TO_PI = exports.PI_IN_DEGREE / Math.PI;
|
|
21
21
|
class DPoint {
|
|
22
|
-
// eslint-disable-next-line no-empty-function,no-useless-constructor
|
|
23
22
|
constructor(x = 0, y = x, z) {
|
|
24
23
|
this.x = x;
|
|
25
24
|
this.y = y;
|
|
26
25
|
this.z = z;
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
26
|
this.properties = {};
|
|
29
27
|
}
|
|
30
28
|
static zero() {
|
|
@@ -48,13 +46,6 @@ class DPoint {
|
|
|
48
46
|
static random() {
|
|
49
47
|
return new DPoint(Math.random(), Math.random());
|
|
50
48
|
}
|
|
51
|
-
/**
|
|
52
|
-
* @remark Point should be Lng/Lat.
|
|
53
|
-
*
|
|
54
|
-
* @remark `z` value default for `zoom` argument.
|
|
55
|
-
*
|
|
56
|
-
* @param [zoom=this.z]
|
|
57
|
-
*/
|
|
58
49
|
getTileFromCoords(zoom = this.z) {
|
|
59
50
|
(0, utils_1.checkFunction)('getTileFromCoords')
|
|
60
51
|
.checkArgument('this')
|
|
@@ -63,13 +54,6 @@ class DPoint {
|
|
|
63
54
|
const y = Math.floor((1 - Math.log(Math.tan(this.y * exports.PI_TO_DEGREE) + 1 / Math.cos(this.y * exports.PI_TO_DEGREE)) / Math.PI) / 2 * (Math.pow(2, zoom)));
|
|
64
55
|
return new DPoint(x, y, zoom);
|
|
65
56
|
}
|
|
66
|
-
/**
|
|
67
|
-
* Result would be Lng/Lat.
|
|
68
|
-
*
|
|
69
|
-
* @remark `z` value default for `zoom` argument.
|
|
70
|
-
*
|
|
71
|
-
* @param [zoom=this.z]
|
|
72
|
-
*/
|
|
73
57
|
getCoordsFromTile(zoom = this.z) {
|
|
74
58
|
(0, utils_1.checkFunction)('getCoordsFromTile')
|
|
75
59
|
.checkArgument('this')
|
|
@@ -85,10 +69,6 @@ class DPoint {
|
|
|
85
69
|
}
|
|
86
70
|
return [this.x, this.y, this.z];
|
|
87
71
|
}
|
|
88
|
-
/**
|
|
89
|
-
* Find line between two points.
|
|
90
|
-
* @param p
|
|
91
|
-
*/
|
|
92
72
|
findLine(p) {
|
|
93
73
|
(0, utils_1.checkFunction)('findLine')
|
|
94
74
|
.checkArgument('this')
|
|
@@ -152,6 +132,10 @@ class DPoint {
|
|
|
152
132
|
this.x = typeof x === 'number' ? x : x(this);
|
|
153
133
|
return this;
|
|
154
134
|
}
|
|
135
|
+
setZ(z) {
|
|
136
|
+
this.z = typeof z === 'number' ? z : z(this);
|
|
137
|
+
return this;
|
|
138
|
+
}
|
|
155
139
|
setY(y) {
|
|
156
140
|
this.y = typeof y === 'number' ? y : y(this);
|
|
157
141
|
return this;
|
|
@@ -173,10 +157,6 @@ class DPoint {
|
|
|
173
157
|
ltOrEqual(p) {
|
|
174
158
|
return this.lt(p) || this.equal(p);
|
|
175
159
|
}
|
|
176
|
-
/**
|
|
177
|
-
* Clockwise rotation
|
|
178
|
-
* @param a radians
|
|
179
|
-
*/
|
|
180
160
|
rotate(a) {
|
|
181
161
|
const x = this.x * Math.cos(a) - this.y * Math.sin(a);
|
|
182
162
|
const y = this.x * Math.sin(a) + this.y * Math.cos(a);
|
|
@@ -260,9 +240,6 @@ class DPoint {
|
|
|
260
240
|
this.y = Math.floor(this.y);
|
|
261
241
|
return this;
|
|
262
242
|
}
|
|
263
|
-
/**
|
|
264
|
-
* @param [n=2]
|
|
265
|
-
*/
|
|
266
243
|
toFixed(n = 2) {
|
|
267
244
|
this.x = parseFloat(this.x.toFixed(n));
|
|
268
245
|
this.y = parseFloat(this.y.toFixed(n));
|
|
@@ -306,10 +283,6 @@ class DPoint {
|
|
|
306
283
|
equal(p) {
|
|
307
284
|
return this.x === p.x && this.y === p.y && this.z === p.z;
|
|
308
285
|
}
|
|
309
|
-
/**
|
|
310
|
-
* @param p
|
|
311
|
-
* @param [d=0.001]
|
|
312
|
-
*/
|
|
313
286
|
like(p, d = 0.001) {
|
|
314
287
|
if (this.equal(p)) {
|
|
315
288
|
return true;
|
|
@@ -327,27 +300,18 @@ class DPoint {
|
|
|
327
300
|
this.y = v - this.y;
|
|
328
301
|
return this;
|
|
329
302
|
}
|
|
330
|
-
/**
|
|
331
|
-
* Check if point looks like radians
|
|
332
|
-
*/
|
|
333
303
|
get likeRadians() {
|
|
334
304
|
if (radiansPolygon.length === 0) {
|
|
335
305
|
radiansPolygon.push(new DPoint(-Math.PI, -Math.PI / 2), new DPoint(Math.PI, Math.PI / 2));
|
|
336
306
|
}
|
|
337
307
|
return radiansPolygon.simpleInclude(this);
|
|
338
308
|
}
|
|
339
|
-
/**
|
|
340
|
-
* Check if point looks like `EPSG:4326` (degrees)
|
|
341
|
-
*/
|
|
342
309
|
get likeWorldGeodeticSystem() {
|
|
343
310
|
if (worldGeodeticPolygon.length === 0) {
|
|
344
311
|
worldGeodeticPolygon.push(new DPoint(-180, -90), new DPoint(180, 90));
|
|
345
312
|
}
|
|
346
313
|
return !this.likeRadians && worldGeodeticPolygon.simpleInclude(this);
|
|
347
314
|
}
|
|
348
|
-
/**
|
|
349
|
-
* Check if point looks like `EPSG:3857` (meters)
|
|
350
|
-
*/
|
|
351
315
|
get likePseudoMercator() {
|
|
352
316
|
if (pseudoMercatorPolygon.length === 0) {
|
|
353
317
|
pseudoMercatorPolygon.push(new DPoint(-20026376.39, -20048966.10), new DPoint(20026376.39, 20048966.10));
|
|
@@ -416,16 +380,6 @@ class DPoint {
|
|
|
416
380
|
minus() {
|
|
417
381
|
return this.clone().scale(-1);
|
|
418
382
|
}
|
|
419
|
-
/**
|
|
420
|
-
* Find [orthodromic path](https://en.wikipedia.org/wiki/Great-circle_navigation) between to points.
|
|
421
|
-
*
|
|
422
|
-
* @remark Points should be Lng/Lat.
|
|
423
|
-
*
|
|
424
|
-
* 
|
|
425
|
-
*
|
|
426
|
-
* @param point
|
|
427
|
-
* @param [pointsCount=360]
|
|
428
|
-
*/
|
|
429
383
|
orthodromicPath(point, pointsCount = 360) {
|
|
430
384
|
(0, utils_1.checkFunction)('orthodromicPath')
|
|
431
385
|
.checkArgument('this')
|