dgeoutils 2.4.2 → 2.4.5

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.
Files changed (43) hide show
  1. package/dist/{DCircle.d.ts → cjs/DCircle.d.ts} +0 -0
  2. package/dist/cjs/DCircle.js +102 -0
  3. package/dist/{DLine.d.ts → cjs/DLine.d.ts} +0 -0
  4. package/dist/cjs/DLine.js +310 -0
  5. package/dist/{DNumbers.d.ts → cjs/DNumbers.d.ts} +0 -0
  6. package/dist/cjs/DNumbers.js +30 -0
  7. package/dist/{DPlane.d.ts → cjs/DPlane.d.ts} +0 -0
  8. package/dist/cjs/DPlane.js +132 -0
  9. package/dist/{DPoint.d.ts → cjs/DPoint.d.ts} +2 -0
  10. package/dist/cjs/DPoint.js +614 -0
  11. package/dist/{DPolygon.d.ts → cjs/DPolygon.d.ts} +0 -0
  12. package/dist/cjs/DPolygon.js +1560 -0
  13. package/dist/{DPolygonLoop.d.ts → cjs/DPolygonLoop.d.ts} +0 -0
  14. package/dist/cjs/DPolygonLoop.js +401 -0
  15. package/dist/{FastSearch.d.ts → cjs/FastSearch.d.ts} +0 -0
  16. package/dist/cjs/FastSearch.js +53 -0
  17. package/dist/{TraceMatrix.d.ts → cjs/TraceMatrix.d.ts} +0 -0
  18. package/dist/cjs/TraceMatrix.js +256 -0
  19. package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
  20. package/dist/{index.js → cjs/index.js} +5 -1
  21. package/dist/{utils.d.ts → cjs/utils.d.ts} +0 -0
  22. package/dist/cjs/utils.js +216 -0
  23. package/dist/{DCircle.js → es2015/DCircle.js} +14 -18
  24. package/dist/{DLine.js → es2015/DLine.js} +24 -28
  25. package/dist/es2015/DNumbers.js +22 -0
  26. package/dist/{DPlane.js → es2015/DPlane.js} +22 -26
  27. package/dist/{DPoint.js → es2015/DPoint.js} +91 -56
  28. package/dist/{DPolygon.js → es2015/DPolygon.js} +41 -45
  29. package/dist/{DPolygonLoop.js → es2015/DPolygonLoop.js} +1 -5
  30. package/dist/{FastSearch.js → es2015/FastSearch.js} +1 -5
  31. package/dist/{TraceMatrix.js → es2015/TraceMatrix.js} +35 -39
  32. package/dist/es2015/index.js +10 -0
  33. package/dist/{utils.js → es2015/utils.js} +29 -41
  34. package/dist/esm/DCircle.js +1 -1
  35. package/dist/esm/DLine.js +2 -2
  36. package/dist/esm/DPoint.js +42 -2
  37. package/dist/esm/DPolygon.js +7 -7
  38. package/dist/esm/utils.js +6 -6
  39. package/dist/umd/dgeoutils.js +59 -19
  40. package/dist/umd/dgeoutils.min.js +1 -1
  41. package/dist/umd/dgeoutils.min.js.map +1 -1
  42. package/package.json +9 -13
  43. package/dist/DNumbers.js +0 -26
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DLine = void 0;
4
- const DPoint_1 = require("./DPoint");
5
- const utils_1 = require("./utils");
6
- const DNumbers_1 = require("./DNumbers");
7
- class DLine {
8
- constructor(a, b, c, begin = DPoint_1.DPoint.zero(), end = DPoint_1.DPoint.zero()) {
1
+ import { DPoint } from './DPoint';
2
+ import { checkFunction } from './utils';
3
+ import { DNumbers } from './DNumbers';
4
+ export class DLine {
5
+ constructor(a, b, c, begin = DPoint.zero(), end = DPoint.zero()) {
9
6
  this.a = a;
10
7
  this.b = b;
11
8
  this.c = c;
@@ -16,7 +13,7 @@ class DLine {
16
13
  return new DLine(this.a, this.b, this.c, this.begin.clone(), this.end.clone());
17
14
  }
18
15
  findPerpendicular(p) {
19
- (0, utils_1.checkFunction)('findPerpendicular')
16
+ checkFunction('findPerpendicular')
20
17
  .checkArgument('this.begin')
21
18
  .shouldBeMeters(this.begin)
22
19
  .checkArgument('this.end')
@@ -26,7 +23,7 @@ class DLine {
26
23
  return new DLine(-this.b, this.a, this.b * p.x - this.a * p.y);
27
24
  }
28
25
  perpendicularDistance(p) {
29
- (0, utils_1.checkFunction)('perpendicularDistance')
26
+ checkFunction('perpendicularDistance')
30
27
  .checkArgument('this.begin')
31
28
  .shouldBeMeters(this.begin)
32
29
  .checkArgument('this.end')
@@ -140,21 +137,21 @@ class DLine {
140
137
  }
141
138
  x(p) {
142
139
  if (this.isParallelY) {
143
- return new DPoint_1.DPoint(-this.c / this.a, p.y);
140
+ return new DPoint(-this.c / this.a, p.y);
144
141
  }
145
142
  if (this.isParallelX) {
146
- return new DPoint_1.DPoint(p.x, -this.c / this.b);
143
+ return new DPoint(p.x, -this.c / this.b);
147
144
  }
148
- return new DPoint_1.DPoint(-this.b / this.a * p.y - this.c / this.a, p.y);
145
+ return new DPoint(-this.b / this.a * p.y - this.c / this.a, p.y);
149
146
  }
150
147
  y(p) {
151
148
  if (this.isParallelY) {
152
- return new DPoint_1.DPoint(-this.c / this.a, p.y);
149
+ return new DPoint(-this.c / this.a, p.y);
153
150
  }
154
151
  if (this.isParallelX) {
155
- return new DPoint_1.DPoint(p.x, -this.c / this.b);
152
+ return new DPoint(p.x, -this.c / this.b);
156
153
  }
157
- return new DPoint_1.DPoint(p.x, -this.a / this.b * p.x - this.c / this.b);
154
+ return new DPoint(p.x, -this.a / this.b * p.x - this.c / this.b);
158
155
  }
159
156
  findPoint(l) {
160
157
  if (this.isParallelY && l.isParallelY) {
@@ -164,28 +161,28 @@ class DLine {
164
161
  return null;
165
162
  }
166
163
  if (this.isParallelX && l.isParallelY) {
167
- return new DPoint_1.DPoint(-l.c / l.a, -this.c / this.b);
164
+ return new DPoint(-l.c / l.a, -this.c / this.b);
168
165
  }
169
166
  if (this.isParallelY && l.isParallelX) {
170
- return new DPoint_1.DPoint(-this.c / this.a, -l.c / l.b);
167
+ return new DPoint(-this.c / this.a, -l.c / l.b);
171
168
  }
172
169
  if (this.isParallelY) {
173
170
  const x = -this.c / this.a;
174
- return l.y(new DPoint_1.DPoint(x));
171
+ return l.y(new DPoint(x));
175
172
  }
176
173
  if (this.isParallelX) {
177
174
  const y = -this.c / this.b;
178
- return l.x(new DPoint_1.DPoint(0, y));
175
+ return l.x(new DPoint(0, y));
179
176
  }
180
177
  if (l.isParallelY) {
181
178
  const x = -l.c / l.a;
182
- return this.y(new DPoint_1.DPoint(x));
179
+ return this.y(new DPoint(x));
183
180
  }
184
181
  if (l.isParallelX) {
185
182
  const y = -l.c / l.b;
186
- return this.x(new DPoint_1.DPoint(0, y));
183
+ return this.x(new DPoint(0, y));
187
184
  }
188
- const res = this.y(new DPoint_1.DPoint((l.c / l.b - this.c / this.b) / (this.a / this.b - l.a / l.b)));
185
+ const res = this.y(new DPoint((l.c / l.b - this.c / this.b) / (this.a / this.b - l.a / l.b)));
189
186
  if (!isFinite(res.x) && !isFinite(res.y)) {
190
187
  return null;
191
188
  }
@@ -204,7 +201,7 @@ class DLine {
204
201
  return [this.begin, this.end];
205
202
  }
206
203
  getFi() {
207
- (0, utils_1.checkFunction)('getFi')
204
+ checkFunction('getFi')
208
205
  .checkArgument('this.begin')
209
206
  .shouldBeMeters(this.begin)
210
207
  .checkArgument('this.end')
@@ -225,13 +222,13 @@ class DLine {
225
222
  const p = isArray ? i : [i];
226
223
  const d = (isArray ? k : [k]);
227
224
  const fi = this.findFi(new DLine(1, 0, 0));
228
- const td = this.x(new DPoint_1.DPoint(1, 1)).distance(this.x(new DPoint_1.DPoint(2, 2))) / 2;
229
- const sinCos = new DPoint_1.DPoint(Math.sin(fi), Math.cos(fi));
225
+ const td = this.x(new DPoint(1, 1)).distance(this.x(new DPoint(2, 2))) / 2;
226
+ const sinCos = new DPoint(Math.sin(fi), Math.cos(fi));
230
227
  const dt = sinCos.clone().scale(td);
231
228
  const p1T = p[0].clone().move(dt.clone().minus());
232
229
  const p2T = p[0].clone().move(dt);
233
230
  let res = [];
234
- if (DNumbers_1.DNumbers.like(this.y(p1T).y, p1T.y) || DNumbers_1.DNumbers.like(this.y(p2T).y, p2T.y)) {
231
+ if (DNumbers.like(this.y(p1T).y, p1T.y) || DNumbers.like(this.y(p2T).y, p2T.y)) {
235
232
  res = p.map((t, index) => t.clone()
236
233
  .move(sinCos.clone().scale(d[index])));
237
234
  }
@@ -258,4 +255,3 @@ class DLine {
258
255
  return new DLine(w * c - e * b, e * a - q * c, q * b - w * a);
259
256
  }
260
257
  }
261
- exports.DLine = DLine;
@@ -0,0 +1,22 @@
1
+ import { DEGREE_TO_PI, DOUBLE_PI_IN_DEGREE, PI_IN_DEGREE, PI_TO_DEGREE } from './DPoint';
2
+ const delta = 0.001;
3
+ export class DNumbers {
4
+ static like(v, s, d = delta) {
5
+ return Math.abs(v - s) < d;
6
+ }
7
+ static likeZero(v) {
8
+ return DNumbers.like(v, 0);
9
+ }
10
+ static like2PI(v) {
11
+ return DNumbers.like(DNumbers.rad2Deg(v), DOUBLE_PI_IN_DEGREE);
12
+ }
13
+ static likePI(v) {
14
+ return DNumbers.like(DNumbers.rad2Deg(v), PI_IN_DEGREE);
15
+ }
16
+ static rad2Deg(v) {
17
+ return v * DEGREE_TO_PI;
18
+ }
19
+ static deg2Rad(v) {
20
+ return v * PI_TO_DEGREE;
21
+ }
22
+ }
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DPlane = void 0;
4
- const DPoint_1 = require("./DPoint");
5
- const utils_1 = require("./utils");
6
- const DNumbers_1 = require("./DNumbers");
7
- class DPlane {
8
- constructor(a, b, c, d, p1 = DPoint_1.DPoint.zero(), p2 = DPoint_1.DPoint.zero(), p3 = DPoint_1.DPoint.zero()) {
1
+ import { DPoint } from './DPoint';
2
+ import { gaussianElimination } from './utils';
3
+ import { DNumbers } from './DNumbers';
4
+ export class DPlane {
5
+ constructor(a, b, c, d, p1 = DPoint.zero(), p2 = DPoint.zero(), p3 = DPoint.zero()) {
9
6
  this.a = a;
10
7
  this.b = b;
11
8
  this.c = c;
@@ -25,7 +22,7 @@ class DPlane {
25
22
  return new DPlane(0, 0, 1, -p1.z, p1, p2, p3);
26
23
  }
27
24
  const d = 1;
28
- const [a, b, c] = (0, utils_1.gaussianElimination)([
25
+ const [a, b, c] = gaussianElimination([
29
26
  [p1.x, p1.y, p1.z, -d],
30
27
  [p2.x, p2.y, p2.z, -d],
31
28
  [p3.x, p3.y, p3.z, -d]
@@ -33,7 +30,7 @@ class DPlane {
33
30
  return new DPlane(a, b, c, d, p1, p2, p3);
34
31
  }
35
32
  x(p) {
36
- if (p instanceof DPoint_1.DPoint) {
33
+ if (p instanceof DPoint) {
37
34
  const { a, b, c, d } = this;
38
35
  const { y, z } = p;
39
36
  p.x = -(b * y + c * z + d) / a;
@@ -42,7 +39,7 @@ class DPlane {
42
39
  return p.map((t) => this.x(t));
43
40
  }
44
41
  y(p) {
45
- if (p instanceof DPoint_1.DPoint) {
42
+ if (p instanceof DPoint) {
46
43
  const { a, b, c, d } = this;
47
44
  const { x, z } = p;
48
45
  p.y = -(a * x + c * z + d) / b;
@@ -51,7 +48,7 @@ class DPlane {
51
48
  return p.map((t) => this.y(t));
52
49
  }
53
50
  z(p) {
54
- if (p instanceof DPoint_1.DPoint) {
51
+ if (p instanceof DPoint) {
55
52
  const { a, b, c, d } = this;
56
53
  const { x, y } = p;
57
54
  p.z = -(a * x + b * y + d) / c;
@@ -64,7 +61,7 @@ class DPlane {
64
61
  return new DPlane(a, b, c, d, p1, p2, p3);
65
62
  }
66
63
  distance(p) {
67
- if (p instanceof DPoint_1.DPoint) {
64
+ if (p instanceof DPoint) {
68
65
  const { x, y, z } = p;
69
66
  const { a, b, c, d } = this;
70
67
  return Math.abs(a * x + b * y + c * z + d) / Math.sqrt(a * a + b * b + c * c);
@@ -76,10 +73,10 @@ class DPlane {
76
73
  equal(p) {
77
74
  const { a, b, c, d } = p;
78
75
  const { a: q, b: w, c: e, d: r } = this;
79
- return DNumbers_1.DNumbers.like(a, q) &&
80
- DNumbers_1.DNumbers.like(b, w) &&
81
- DNumbers_1.DNumbers.like(c, e) &&
82
- DNumbers_1.DNumbers.like(d, r);
76
+ return DNumbers.like(a, q) &&
77
+ DNumbers.like(b, w) &&
78
+ DNumbers.like(c, e) &&
79
+ DNumbers.like(d, r);
83
80
  }
84
81
  same(p) {
85
82
  const { a, b, c, d } = p;
@@ -88,10 +85,10 @@ class DPlane {
88
85
  const y = b / w;
89
86
  const u = c / e;
90
87
  const i = d / r;
91
- return DNumbers_1.DNumbers.like(t, y) &&
92
- DNumbers_1.DNumbers.like(t, u) &&
93
- DNumbers_1.DNumbers.like(t, c) &&
94
- DNumbers_1.DNumbers.like(t, i);
88
+ return DNumbers.like(t, y) &&
89
+ DNumbers.like(t, u) &&
90
+ DNumbers.like(t, c) &&
91
+ DNumbers.like(t, i);
95
92
  }
96
93
  parallel(p) {
97
94
  const { a, b, c, d } = p;
@@ -100,10 +97,9 @@ class DPlane {
100
97
  const y = b / w;
101
98
  const u = c / e;
102
99
  const i = d / r;
103
- return DNumbers_1.DNumbers.like(t, y) &&
104
- DNumbers_1.DNumbers.like(t, u) &&
105
- DNumbers_1.DNumbers.like(t, c) &&
106
- !DNumbers_1.DNumbers.like(t, i);
100
+ return DNumbers.like(t, y) &&
101
+ DNumbers.like(t, u) &&
102
+ DNumbers.like(t, c) &&
103
+ !DNumbers.like(t, i);
107
104
  }
108
105
  }
109
- exports.DPlane = DPlane;
@@ -1,24 +1,21 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DPoint = exports.DEGREE_TO_PI = exports.PI_TO_DEGREE = exports.DOUBLE_PI_IN_DEGREE = exports.PI_IN_DEGREE = exports.HALF_PI_IN_DEGREE = exports.EARTH_RADIUS_IN_METERS = void 0;
4
- const DLine_1 = require("./DLine");
5
- const DPolygon_1 = require("./DPolygon");
6
- const utils_1 = require("./utils");
1
+ import { DLine } from './DLine';
2
+ import { DPolygon } from './DPolygon';
3
+ import { checkFunction, createArray, isDefAndNotNull } from './utils';
7
4
  const diff = 0;
8
- const radiansPolygon = new DPolygon_1.DPolygon();
9
- const pseudoMercatorPolygon = new DPolygon_1.DPolygon();
10
- const worldGeodeticPolygon = new DPolygon_1.DPolygon();
11
- exports.EARTH_RADIUS_IN_METERS = 6371008.8;
5
+ const radiansPolygon = new DPolygon();
6
+ const pseudoMercatorPolygon = new DPolygon();
7
+ const worldGeodeticPolygon = new DPolygon();
8
+ export const EARTH_RADIUS_IN_METERS = 6371008.8;
12
9
  const EARTH_IN_MITERS = 20037508.34;
13
10
  const DEGREES_IN_EARTH = 180;
14
11
  const MITERS_IN_ONE_DEGREE = EARTH_IN_MITERS / DEGREES_IN_EARTH;
15
12
  const DEGREES_IN_ONE_MITER = DEGREES_IN_EARTH / EARTH_IN_MITERS;
16
- exports.HALF_PI_IN_DEGREE = 90;
17
- exports.PI_IN_DEGREE = 180;
18
- exports.DOUBLE_PI_IN_DEGREE = 360;
19
- exports.PI_TO_DEGREE = Math.PI / exports.PI_IN_DEGREE;
20
- exports.DEGREE_TO_PI = exports.PI_IN_DEGREE / Math.PI;
21
- class DPoint {
13
+ export const HALF_PI_IN_DEGREE = 90;
14
+ export const PI_IN_DEGREE = 180;
15
+ export const DOUBLE_PI_IN_DEGREE = 360;
16
+ export const PI_TO_DEGREE = Math.PI / PI_IN_DEGREE;
17
+ export const DEGREE_TO_PI = PI_IN_DEGREE / Math.PI;
18
+ export class DPoint {
22
19
  constructor(x = 0, y = x, z) {
23
20
  this.x = x;
24
21
  this.y = y;
@@ -46,21 +43,60 @@ class DPoint {
46
43
  static random() {
47
44
  return new DPoint(Math.random(), Math.random());
48
45
  }
46
+ static getTileFromQuadKey(quadKey) {
47
+ const p = new DPoint(0, 0, quadKey.length);
48
+ for (let i = p.z; i > 0; i--) {
49
+ const mask = 1 << (i - 1);
50
+ switch (quadKey[p.z - i]) {
51
+ case '0':
52
+ break;
53
+ case '1':
54
+ p.x |= mask;
55
+ break;
56
+ case '2':
57
+ p.y |= mask;
58
+ break;
59
+ case '3':
60
+ p.x |= mask;
61
+ p.y |= mask;
62
+ break;
63
+ default:
64
+ throw new Error('Invalid QuadKey digit sequence.');
65
+ }
66
+ }
67
+ return p;
68
+ }
49
69
  getTileFromCoords(zoom = this.z) {
50
- (0, utils_1.checkFunction)('getTileFromCoords')
70
+ checkFunction('getTileFromCoords')
51
71
  .checkArgument('this')
52
72
  .shouldBeDegree(this);
53
- const x = Math.floor((this.x + exports.PI_IN_DEGREE) / exports.DOUBLE_PI_IN_DEGREE * (Math.pow(2, zoom)));
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)));
73
+ const x = Math.floor((this.x + PI_IN_DEGREE) / DOUBLE_PI_IN_DEGREE * (Math.pow(2, zoom)));
74
+ const y = Math.floor((1 - Math.log(Math.tan(this.y * PI_TO_DEGREE) + 1 / Math.cos(this.y * PI_TO_DEGREE)) / Math.PI) / 2 * (Math.pow(2, zoom)));
55
75
  return new DPoint(x, y, zoom);
56
76
  }
77
+ getQuadKeyFromTile(zoom = this.z) {
78
+ const quadKey = [];
79
+ for (let i = zoom; i > 0; i--) {
80
+ let digit = 0;
81
+ const mask = 1 << (i - 1);
82
+ if ((this.x & mask) !== 0) {
83
+ digit++;
84
+ }
85
+ if ((this.y & mask) !== 0) {
86
+ digit++;
87
+ digit++;
88
+ }
89
+ quadKey.push(digit);
90
+ }
91
+ return quadKey.join('');
92
+ }
57
93
  getCoordsFromTile(zoom = this.z) {
58
- (0, utils_1.checkFunction)('getCoordsFromTile')
94
+ checkFunction('getCoordsFromTile')
59
95
  .checkArgument('this')
60
96
  .shouldBeUInt(this);
61
97
  const n = Math.PI - 2 * Math.PI * this.y / (Math.pow(2, zoom));
62
- const x = this.x / (Math.pow(2, zoom)) * exports.DOUBLE_PI_IN_DEGREE - exports.PI_IN_DEGREE;
63
- const y = exports.PI_IN_DEGREE / Math.PI * Math.atan((Math.exp(n) - Math.exp(-n)) / 2);
98
+ const x = this.x / (Math.pow(2, zoom)) * DOUBLE_PI_IN_DEGREE - PI_IN_DEGREE;
99
+ const y = PI_IN_DEGREE / Math.PI * Math.atan((Math.exp(n) - Math.exp(-n)) / 2);
64
100
  return new DPoint(x, y, zoom);
65
101
  }
66
102
  toCoords() {
@@ -70,7 +106,7 @@ class DPoint {
70
106
  return [this.x, this.y, this.z];
71
107
  }
72
108
  findLine(p) {
73
- (0, utils_1.checkFunction)('findLine')
109
+ checkFunction('findLine')
74
110
  .checkArgument('this')
75
111
  .shouldBeMeters(this)
76
112
  .checkArgument('p')
@@ -82,15 +118,15 @@ class DPoint {
82
118
  const b = p.x - this.x - diff;
83
119
  const c = this.x * p.y - p.x * this.y - diff;
84
120
  if (a === 0) {
85
- return new DLine_1.DLine(0, 1, c / b, this, p);
121
+ return new DLine(0, 1, c / b, this, p);
86
122
  }
87
123
  if (b === 0) {
88
- return new DLine_1.DLine(1, 0, c / a, this, p);
124
+ return new DLine(1, 0, c / a, this, p);
89
125
  }
90
- return new DLine_1.DLine(a, b, c, this, p);
126
+ return new DLine(a, b, c, this, p);
91
127
  }
92
128
  findInnerAngle(p1, p3) {
93
- (0, utils_1.checkFunction)('findInnerAngle')
129
+ checkFunction('findInnerAngle')
94
130
  .checkArgument('this')
95
131
  .shouldBeMeters(this)
96
132
  .checkArgument('p1')
@@ -119,7 +155,7 @@ class DPoint {
119
155
  return `POINT (${x} ${y})`;
120
156
  }
121
157
  distance(p) {
122
- (0, utils_1.checkFunction)('distance')
158
+ checkFunction('distance')
123
159
  .checkArgument('this')
124
160
  .shouldBeMeters(this)
125
161
  .checkArgument('p')
@@ -129,7 +165,7 @@ class DPoint {
129
165
  return Math.sqrt(dx * dx + dy * dy);
130
166
  }
131
167
  distance3d(p) {
132
- (0, utils_1.checkFunction)('distance3d')
168
+ checkFunction('distance3d')
133
169
  .checkArgument('this')
134
170
  .shouldBeMeters(this)
135
171
  .checkArgument('p')
@@ -204,66 +240,66 @@ class DPoint {
204
240
  if (x instanceof DPoint) {
205
241
  xV = this.x + x.x;
206
242
  yV = this.y + x.y;
207
- if ((0, utils_1.isDefAndNotNull)(this.z) && (0, utils_1.isDefAndNotNull)(x.z)) {
243
+ if (isDefAndNotNull(this.z) && isDefAndNotNull(x.z)) {
208
244
  zV = this.z + x.z;
209
245
  }
210
246
  }
211
247
  else {
212
248
  xV = this.x + x;
213
249
  yV = this.y + y;
214
- if ((0, utils_1.isDefAndNotNull)(this.z) && (0, utils_1.isDefAndNotNull)(z)) {
250
+ if (isDefAndNotNull(this.z) && isDefAndNotNull(z)) {
215
251
  zV = this.z + z;
216
252
  }
217
253
  }
218
254
  this.x = xV;
219
255
  this.y = yV;
220
- if ((0, utils_1.isDefAndNotNull)(zV)) {
256
+ if (isDefAndNotNull(zV)) {
221
257
  this.z = zV;
222
258
  }
223
259
  return this;
224
260
  }
225
261
  degreeToMeters() {
226
- (0, utils_1.checkFunction)('degreeToMeters')
262
+ checkFunction('degreeToMeters')
227
263
  .checkArgument('this')
228
264
  .shouldBeDegree(this);
229
- const x = ((this.x + exports.PI_IN_DEGREE) % exports.DOUBLE_PI_IN_DEGREE - exports.PI_IN_DEGREE) * MITERS_IN_ONE_DEGREE;
230
- const y = (Math.log(Math.tan(((this.y + exports.HALF_PI_IN_DEGREE) % exports.PI_IN_DEGREE) *
231
- (Math.PI / exports.DOUBLE_PI_IN_DEGREE))) / exports.PI_TO_DEGREE) * MITERS_IN_ONE_DEGREE;
265
+ const x = ((this.x + PI_IN_DEGREE) % DOUBLE_PI_IN_DEGREE - PI_IN_DEGREE) * MITERS_IN_ONE_DEGREE;
266
+ const y = (Math.log(Math.tan(((this.y + HALF_PI_IN_DEGREE) % PI_IN_DEGREE) *
267
+ (Math.PI / DOUBLE_PI_IN_DEGREE))) / PI_TO_DEGREE) * MITERS_IN_ONE_DEGREE;
232
268
  this.x = x;
233
269
  this.y = y;
234
270
  return this;
235
271
  }
236
272
  metersToDegree() {
237
- (0, utils_1.checkFunction)('metersToDegree')
273
+ checkFunction('metersToDegree')
238
274
  .checkArgument('this')
239
275
  .shouldBeMeters(this);
240
276
  const lon = this.x * DEGREES_IN_ONE_MITER;
241
- const lat = Math.atan(Math.pow(Math.E, ((this.y / MITERS_IN_ONE_DEGREE) * exports.PI_TO_DEGREE))) *
242
- (exports.DOUBLE_PI_IN_DEGREE / Math.PI) - exports.HALF_PI_IN_DEGREE;
277
+ const lat = Math.atan(Math.pow(Math.E, ((this.y / MITERS_IN_ONE_DEGREE) * PI_TO_DEGREE))) *
278
+ (DOUBLE_PI_IN_DEGREE / Math.PI) - HALF_PI_IN_DEGREE;
243
279
  this.x = lon;
244
280
  this.y = lat;
245
281
  return this;
246
282
  }
247
283
  degreeToRadians() {
248
- (0, utils_1.checkFunction)('degreeToRadians')
284
+ checkFunction('degreeToRadians')
249
285
  .checkArgument('this')
250
286
  .shouldBeDegree(this);
251
- return this.scale(exports.PI_TO_DEGREE);
287
+ return this.scale(PI_TO_DEGREE);
252
288
  }
253
289
  radiansToDegrees() {
254
- (0, utils_1.checkFunction)('radiansToDegrees')
290
+ checkFunction('radiansToDegrees')
255
291
  .checkArgument('this')
256
292
  .shouldBeRadians(this);
257
- return this.scale(exports.DEGREE_TO_PI);
293
+ return this.scale(DEGREE_TO_PI);
258
294
  }
259
295
  radiansToMeters() {
260
- (0, utils_1.checkFunction)('radiansToMeters')
296
+ checkFunction('radiansToMeters')
261
297
  .checkArgument('this')
262
298
  .shouldBeRadians(this);
263
299
  return this.radiansToDegrees().degreeToMeters();
264
300
  }
265
301
  metersToRadians() {
266
- (0, utils_1.checkFunction)('metersToRadians')
302
+ checkFunction('metersToRadians')
267
303
  .checkArgument('this')
268
304
  .shouldBeMeters(this);
269
305
  return this.metersToDegree().degreeToRadians();
@@ -300,20 +336,20 @@ class DPoint {
300
336
  if (x instanceof DPoint) {
301
337
  xV = this.x * x.x;
302
338
  yV = this.y * x.y;
303
- if ((0, utils_1.isDefAndNotNull)(this.z) && (0, utils_1.isDefAndNotNull)(x.z)) {
339
+ if (isDefAndNotNull(this.z) && isDefAndNotNull(x.z)) {
304
340
  zV = this.z * x.z;
305
341
  }
306
342
  }
307
343
  else {
308
344
  xV = this.x * x;
309
345
  yV = this.y * y;
310
- if ((0, utils_1.isDefAndNotNull)(this.z) && (0, utils_1.isDefAndNotNull)(z)) {
346
+ if (isDefAndNotNull(this.z) && isDefAndNotNull(z)) {
311
347
  zV = this.z * z;
312
348
  }
313
349
  }
314
350
  this.x = xV;
315
351
  this.y = yV;
316
- if ((0, utils_1.isDefAndNotNull)(zV)) {
352
+ if (isDefAndNotNull(zV)) {
317
353
  this.z = zV;
318
354
  }
319
355
  return this;
@@ -325,20 +361,20 @@ class DPoint {
325
361
  if (x instanceof DPoint) {
326
362
  xV = this.x / x.x;
327
363
  yV = this.y / x.y;
328
- if ((0, utils_1.isDefAndNotNull)(this.z) && (0, utils_1.isDefAndNotNull)(x.z)) {
364
+ if (isDefAndNotNull(this.z) && isDefAndNotNull(x.z)) {
329
365
  zV = this.z / x.z;
330
366
  }
331
367
  }
332
368
  else {
333
369
  xV = this.x / x;
334
370
  yV = this.y / y;
335
- if ((0, utils_1.isDefAndNotNull)(this.z) && (0, utils_1.isDefAndNotNull)(z)) {
371
+ if (isDefAndNotNull(this.z) && isDefAndNotNull(z)) {
336
372
  zV = this.z / z;
337
373
  }
338
374
  }
339
375
  this.x = xV;
340
376
  this.y = yV;
341
- if ((0, utils_1.isDefAndNotNull)(zV)) {
377
+ if (isDefAndNotNull(zV)) {
342
378
  this.z = zV;
343
379
  }
344
380
  return this;
@@ -395,13 +431,13 @@ class DPoint {
395
431
  this.y = y;
396
432
  }
397
433
  get area() {
398
- (0, utils_1.checkFunction)('area')
434
+ checkFunction('area')
399
435
  .checkArgument('this')
400
436
  .shouldBeMeters(this);
401
437
  return this.w * this.h;
402
438
  }
403
439
  get hip() {
404
- (0, utils_1.checkFunction)('hip')
440
+ checkFunction('hip')
405
441
  .checkArgument('this')
406
442
  .shouldBeMeters(this);
407
443
  return Math.sqrt(this.w * this.w + this.h * this.h);
@@ -445,7 +481,7 @@ class DPoint {
445
481
  return this.scale(-1);
446
482
  }
447
483
  orthodromicPath(point, pointsCount = 360) {
448
- (0, utils_1.checkFunction)('orthodromicPath')
484
+ checkFunction('orthodromicPath')
449
485
  .checkArgument('this')
450
486
  .shouldBeDegree(this)
451
487
  .checkArgument('point')
@@ -454,7 +490,7 @@ class DPoint {
454
490
  const p = point.clone().degreeToRadians();
455
491
  const d = Math.sin(p.x - t.x);
456
492
  const step = (p.x - t.x) / (pointsCount - 1);
457
- return new DPolygon_1.DPolygon((0, utils_1.createArray)(pointsCount)
493
+ return new DPolygon(createArray(pointsCount)
458
494
  .map((v, i) => {
459
495
  const x = t.x + step * i;
460
496
  const y = Math.atan((Math.tan(t.y) * Math.sin(p.x - x)) / d +
@@ -473,4 +509,3 @@ class DPoint {
473
509
  .sort((a, b) => a.properties.distance - b.properties.distance);
474
510
  }
475
511
  }
476
- exports.DPoint = DPoint;