dgeoutils 2.3.7 → 2.4.2

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 (39) hide show
  1. package/dist/{cjs/DCircle.d.ts → DCircle.d.ts} +0 -0
  2. package/dist/{es2015/DCircle.js → DCircle.js} +18 -14
  3. package/dist/{cjs/DLine.d.ts → DLine.d.ts} +0 -0
  4. package/dist/{es2015/DLine.js → DLine.js} +28 -24
  5. package/dist/{cjs/DNumbers.d.ts → DNumbers.d.ts} +0 -0
  6. package/dist/DNumbers.js +26 -0
  7. package/dist/{cjs/DPlane.d.ts → DPlane.d.ts} +0 -0
  8. package/dist/{es2015/DPlane.js → DPlane.js} +26 -22
  9. package/dist/{cjs/DPoint.d.ts → DPoint.d.ts} +0 -0
  10. package/dist/{es2015/DPoint.js → DPoint.js} +56 -52
  11. package/dist/{cjs/DPolygon.d.ts → DPolygon.d.ts} +1 -1
  12. package/dist/{es2015/DPolygon.js → DPolygon.js} +50 -42
  13. package/dist/{cjs/DPolygonLoop.d.ts → DPolygonLoop.d.ts} +0 -0
  14. package/dist/{es2015/DPolygonLoop.js → DPolygonLoop.js} +5 -1
  15. package/dist/{cjs/FastSearch.d.ts → FastSearch.d.ts} +0 -0
  16. package/dist/{es2015/FastSearch.js → FastSearch.js} +5 -1
  17. package/dist/{cjs/TraceMatrix.d.ts → TraceMatrix.d.ts} +0 -0
  18. package/dist/{es2015/TraceMatrix.js → TraceMatrix.js} +39 -35
  19. package/dist/esm/DPolygon.js +6 -1
  20. package/dist/{cjs/index.d.ts → index.d.ts} +0 -0
  21. package/dist/{cjs/index.js → index.js} +0 -0
  22. package/dist/umd/dgeoutils.js +7 -2
  23. package/dist/umd/dgeoutils.min.js +1 -1
  24. package/dist/umd/dgeoutils.min.js.map +1 -1
  25. package/dist/{cjs/utils.d.ts → utils.d.ts} +0 -0
  26. package/dist/{es2015/utils.js → utils.js} +41 -29
  27. package/package.json +5 -6
  28. package/dist/cjs/DCircle.js +0 -102
  29. package/dist/cjs/DLine.js +0 -310
  30. package/dist/cjs/DNumbers.js +0 -30
  31. package/dist/cjs/DPlane.js +0 -132
  32. package/dist/cjs/DPoint.js +0 -574
  33. package/dist/cjs/DPolygon.js +0 -1555
  34. package/dist/cjs/DPolygonLoop.js +0 -401
  35. package/dist/cjs/FastSearch.js +0 -53
  36. package/dist/cjs/TraceMatrix.js +0 -256
  37. package/dist/cjs/utils.js +0 -216
  38. package/dist/es2015/DNumbers.js +0 -22
  39. package/dist/es2015/index.js +0 -10
@@ -1,132 +0,0 @@
1
- "use strict";
2
- var __read = (this && this.__read) || function (o, n) {
3
- var m = typeof Symbol === "function" && o[Symbol.iterator];
4
- if (!m) return o;
5
- var i = m.call(o), r, ar = [], e;
6
- try {
7
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
- }
9
- catch (error) { e = { error: error }; }
10
- finally {
11
- try {
12
- if (r && !r.done && (m = i["return"])) m.call(i);
13
- }
14
- finally { if (e) throw e.error; }
15
- }
16
- return ar;
17
- };
18
- Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.DPlane = void 0;
20
- var DPoint_1 = require("./DPoint");
21
- var utils_1 = require("./utils");
22
- var DNumbers_1 = require("./DNumbers");
23
- var DPlane = (function () {
24
- function DPlane(a, b, c, d, p1, p2, p3) {
25
- if (p1 === void 0) { p1 = DPoint_1.DPoint.zero(); }
26
- if (p2 === void 0) { p2 = DPoint_1.DPoint.zero(); }
27
- if (p3 === void 0) { p3 = DPoint_1.DPoint.zero(); }
28
- this.a = a;
29
- this.b = b;
30
- this.c = c;
31
- this.d = d;
32
- this.p1 = p1;
33
- this.p2 = p2;
34
- this.p3 = p3;
35
- }
36
- DPlane.find = function (p1, p2, p3) {
37
- if (p1.x === p2.x && p2.x === p3.x) {
38
- return new DPlane(1, 0, 0, -p1.x, p1, p2, p3);
39
- }
40
- if (p1.y === p2.y && p2.y === p3.y) {
41
- return new DPlane(0, 1, 0, -p1.y, p1, p2, p3);
42
- }
43
- if (p1.z === p2.z && p2.z === p3.z) {
44
- return new DPlane(0, 0, 1, -p1.z, p1, p2, p3);
45
- }
46
- var d = 1;
47
- var _a = __read((0, utils_1.gaussianElimination)([
48
- [p1.x, p1.y, p1.z, -d],
49
- [p2.x, p2.y, p2.z, -d],
50
- [p3.x, p3.y, p3.z, -d]
51
- ]), 3), a = _a[0], b = _a[1], c = _a[2];
52
- return new DPlane(a, b, c, d, p1, p2, p3);
53
- };
54
- DPlane.prototype.x = function (p) {
55
- var _this = this;
56
- if (p instanceof DPoint_1.DPoint) {
57
- var _a = this, a = _a.a, b = _a.b, c = _a.c, d = _a.d;
58
- var y = p.y, z = p.z;
59
- p.x = -(b * y + c * z + d) / a;
60
- return p;
61
- }
62
- return p.map(function (t) { return _this.x(t); });
63
- };
64
- DPlane.prototype.y = function (p) {
65
- var _this = this;
66
- if (p instanceof DPoint_1.DPoint) {
67
- var _a = this, a = _a.a, b = _a.b, c = _a.c, d = _a.d;
68
- var x = p.x, z = p.z;
69
- p.y = -(a * x + c * z + d) / b;
70
- return p;
71
- }
72
- return p.map(function (t) { return _this.y(t); });
73
- };
74
- DPlane.prototype.z = function (p) {
75
- var _this = this;
76
- if (p instanceof DPoint_1.DPoint) {
77
- var _a = this, a = _a.a, b = _a.b, c = _a.c, d = _a.d;
78
- var x = p.x, y = p.y;
79
- p.z = -(a * x + b * y + d) / c;
80
- return p;
81
- }
82
- return p.map(function (t) { return _this.z(t); });
83
- };
84
- DPlane.prototype.clone = function () {
85
- var _a = this, a = _a.a, b = _a.b, c = _a.c, d = _a.d, p1 = _a.p1, p2 = _a.p2, p3 = _a.p3;
86
- return new DPlane(a, b, c, d, p1, p2, p3);
87
- };
88
- DPlane.prototype.distance = function (p) {
89
- if (p instanceof DPoint_1.DPoint) {
90
- var x = p.x, y = p.y, z = p.z;
91
- var _a = this, a_1 = _a.a, b_1 = _a.b, c_1 = _a.c, d_1 = _a.d;
92
- return Math.abs(a_1 * x + b_1 * y + c_1 * z + d_1) / Math.sqrt(a_1 * a_1 + b_1 * b_1 + c_1 * c_1);
93
- }
94
- var _b = p, a = _b.a, b = _b.b, c = _b.c, d = _b.d;
95
- var r = this.d;
96
- return Math.abs(d - r) / Math.sqrt(a * a + b * b + c * c);
97
- };
98
- DPlane.prototype.equal = function (p) {
99
- var a = p.a, b = p.b, c = p.c, d = p.d;
100
- var _a = this, q = _a.a, w = _a.b, e = _a.c, r = _a.d;
101
- return DNumbers_1.DNumbers.like(a, q) &&
102
- DNumbers_1.DNumbers.like(b, w) &&
103
- DNumbers_1.DNumbers.like(c, e) &&
104
- DNumbers_1.DNumbers.like(d, r);
105
- };
106
- DPlane.prototype.same = function (p) {
107
- var a = p.a, b = p.b, c = p.c, d = p.d;
108
- var _a = this, q = _a.a, w = _a.b, e = _a.c, r = _a.d;
109
- var t = a / q;
110
- var y = b / w;
111
- var u = c / e;
112
- var i = d / r;
113
- return DNumbers_1.DNumbers.like(t, y) &&
114
- DNumbers_1.DNumbers.like(t, u) &&
115
- DNumbers_1.DNumbers.like(t, c) &&
116
- DNumbers_1.DNumbers.like(t, i);
117
- };
118
- DPlane.prototype.parallel = function (p) {
119
- var a = p.a, b = p.b, c = p.c, d = p.d;
120
- var _a = this, q = _a.a, w = _a.b, e = _a.c, r = _a.d;
121
- var t = a / q;
122
- var y = b / w;
123
- var u = c / e;
124
- var i = d / r;
125
- return DNumbers_1.DNumbers.like(t, y) &&
126
- DNumbers_1.DNumbers.like(t, u) &&
127
- DNumbers_1.DNumbers.like(t, c) &&
128
- !DNumbers_1.DNumbers.like(t, i);
129
- };
130
- return DPlane;
131
- }());
132
- exports.DPlane = DPlane;
@@ -1,574 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __read = (this && this.__read) || function (o, n) {
14
- var m = typeof Symbol === "function" && o[Symbol.iterator];
15
- if (!m) return o;
16
- var i = m.call(o), r, ar = [], e;
17
- try {
18
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
19
- }
20
- catch (error) { e = { error: error }; }
21
- finally {
22
- try {
23
- if (r && !r.done && (m = i["return"])) m.call(i);
24
- }
25
- finally { if (e) throw e.error; }
26
- }
27
- return ar;
28
- };
29
- Object.defineProperty(exports, "__esModule", { value: true });
30
- 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;
31
- var DLine_1 = require("./DLine");
32
- var DPolygon_1 = require("./DPolygon");
33
- var utils_1 = require("./utils");
34
- var diff = 0;
35
- var radiansPolygon = new DPolygon_1.DPolygon();
36
- var pseudoMercatorPolygon = new DPolygon_1.DPolygon();
37
- var worldGeodeticPolygon = new DPolygon_1.DPolygon();
38
- exports.EARTH_RADIUS_IN_METERS = 6371008.8;
39
- var EARTH_IN_MITERS = 20037508.34;
40
- var DEGREES_IN_EARTH = 180;
41
- var MITERS_IN_ONE_DEGREE = EARTH_IN_MITERS / DEGREES_IN_EARTH;
42
- var DEGREES_IN_ONE_MITER = DEGREES_IN_EARTH / EARTH_IN_MITERS;
43
- exports.HALF_PI_IN_DEGREE = 90;
44
- exports.PI_IN_DEGREE = 180;
45
- exports.DOUBLE_PI_IN_DEGREE = 360;
46
- exports.PI_TO_DEGREE = Math.PI / exports.PI_IN_DEGREE;
47
- exports.DEGREE_TO_PI = exports.PI_IN_DEGREE / Math.PI;
48
- var DPoint = (function () {
49
- function DPoint(x, y, z) {
50
- if (x === void 0) { x = 0; }
51
- if (y === void 0) { y = x; }
52
- this.x = x;
53
- this.y = y;
54
- this.z = z;
55
- this.properties = {};
56
- }
57
- DPoint.zero = function () {
58
- return new DPoint();
59
- };
60
- DPoint.parse = function (c) {
61
- var _a = c, lat = _a.lat, lng = _a.lng;
62
- if (lat && lng) {
63
- return new DPoint(lat, lng, 0);
64
- }
65
- var _b = __read(c, 3), x = _b[0], y = _b[1], z = _b[2];
66
- return new DPoint(x, y, z);
67
- };
68
- DPoint.parseFromWKT = function (wkt) {
69
- var regexp = /POINT \((?<data>(?:(?!\)).)*?)\)$/miu;
70
- var data = wkt.trim().toUpperCase();
71
- var res = regexp.exec(data);
72
- var _a = __read(res.groups.data.split(' ').map(Number), 3), x = _a[0], y = _a[1], z = _a[2];
73
- return new DPoint(x, y, z);
74
- };
75
- DPoint.random = function () {
76
- return new DPoint(Math.random(), Math.random());
77
- };
78
- DPoint.prototype.getTileFromCoords = function (zoom) {
79
- if (zoom === void 0) { zoom = this.z; }
80
- (0, utils_1.checkFunction)('getTileFromCoords')
81
- .checkArgument('this')
82
- .shouldBeDegree(this);
83
- var x = Math.floor((this.x + exports.PI_IN_DEGREE) / exports.DOUBLE_PI_IN_DEGREE * (Math.pow(2, zoom)));
84
- var 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)));
85
- return new DPoint(x, y, zoom);
86
- };
87
- DPoint.prototype.getCoordsFromTile = function (zoom) {
88
- if (zoom === void 0) { zoom = this.z; }
89
- (0, utils_1.checkFunction)('getCoordsFromTile')
90
- .checkArgument('this')
91
- .shouldBeUInt(this);
92
- var n = Math.PI - 2 * Math.PI * this.y / (Math.pow(2, zoom));
93
- var x = this.x / (Math.pow(2, zoom)) * exports.DOUBLE_PI_IN_DEGREE - exports.PI_IN_DEGREE;
94
- var y = exports.PI_IN_DEGREE / Math.PI * Math.atan((Math.exp(n) - Math.exp(-n)) / 2);
95
- return new DPoint(x, y, zoom);
96
- };
97
- DPoint.prototype.toCoords = function () {
98
- if (this.z === undefined) {
99
- return [this.x, this.y];
100
- }
101
- return [this.x, this.y, this.z];
102
- };
103
- DPoint.prototype.findLine = function (p) {
104
- (0, utils_1.checkFunction)('findLine')
105
- .checkArgument('this')
106
- .shouldBeMeters(this)
107
- .checkArgument('p')
108
- .shouldBeMeters(p);
109
- if (this.equal(p)) {
110
- return this.findLine(p.clone().move(0, 1));
111
- }
112
- var a = this.y - p.y - diff;
113
- var b = p.x - this.x - diff;
114
- var c = this.x * p.y - p.x * this.y - diff;
115
- if (a === 0) {
116
- return new DLine_1.DLine(0, 1, c / b, this, p);
117
- }
118
- if (b === 0) {
119
- return new DLine_1.DLine(1, 0, c / a, this, p);
120
- }
121
- return new DLine_1.DLine(a, b, c, this, p);
122
- };
123
- DPoint.prototype.findInnerAngle = function (p1, p3) {
124
- (0, utils_1.checkFunction)('findInnerAngle')
125
- .checkArgument('this')
126
- .shouldBeMeters(this)
127
- .checkArgument('p1')
128
- .shouldBeMeters(p1)
129
- .checkArgument('p3')
130
- .shouldBeMeters(p3);
131
- var a1 = this.findLine(p1).getFi();
132
- var a2 = this.findLine(p3).getFi();
133
- if (a2 >= a1) {
134
- return a2 - a1;
135
- }
136
- return a2 + Math.PI * 2 - a1;
137
- };
138
- DPoint.prototype.toString = function () {
139
- return this.x + " " + this.y;
140
- };
141
- DPoint.prototype.getValue = function () {
142
- return [this.x, this.y];
143
- };
144
- DPoint.prototype.height = function (z) {
145
- this.z = z;
146
- return this;
147
- };
148
- DPoint.prototype.toWKT = function () {
149
- var _a = this, x = _a.x, y = _a.y;
150
- return "POINT (" + x + " " + y + ")";
151
- };
152
- DPoint.prototype.distance = function (p) {
153
- (0, utils_1.checkFunction)('distance')
154
- .checkArgument('this')
155
- .shouldBeMeters(this)
156
- .checkArgument('p')
157
- .shouldBeMeters(p);
158
- var dx = p.x - this.x;
159
- var dy = p.y - this.y;
160
- return Math.sqrt(dx * dx + dy * dy);
161
- };
162
- DPoint.prototype.distance3d = function (p) {
163
- (0, utils_1.checkFunction)('distance3d')
164
- .checkArgument('this')
165
- .shouldBeMeters(this)
166
- .checkArgument('p')
167
- .shouldBeMeters(p)
168
- .checkArgument('this.z')
169
- .shouldExist(this.z)
170
- .checkArgument('p.z')
171
- .shouldExist(p.z);
172
- var dx = p.x - this.x;
173
- var dy = p.y - this.y;
174
- var dz = p.z - this.z;
175
- return Math.sqrt(dx * dx + dy * dy + dz * dz);
176
- };
177
- DPoint.prototype.setX = function (x) {
178
- this.x = typeof x === 'number' ? x : x(this);
179
- return this;
180
- };
181
- DPoint.prototype.setZ = function (z) {
182
- this.z = typeof z === 'number' ? z : z(this);
183
- return this;
184
- };
185
- DPoint.prototype.setY = function (y) {
186
- this.y = typeof y === 'number' ? y : y(this);
187
- return this;
188
- };
189
- DPoint.prototype.clone = function () {
190
- var p = new DPoint(this.x, this.y, this.z);
191
- p.properties = __assign({}, this.properties);
192
- return p;
193
- };
194
- DPoint.prototype.gt = function (p) {
195
- return this.x > p.x && this.y > p.y;
196
- };
197
- DPoint.prototype.lt = function (p) {
198
- return this.x < p.x && this.y < p.y;
199
- };
200
- DPoint.prototype.gtOrEqual = function (p) {
201
- return this.gt(p) || this.equal(p);
202
- };
203
- DPoint.prototype.ltOrEqual = function (p) {
204
- return this.lt(p) || this.equal(p);
205
- };
206
- DPoint.prototype.rotate = function (a) {
207
- var x = this.x * Math.cos(a) - this.y * Math.sin(a);
208
- var y = this.x * Math.sin(a) + this.y * Math.cos(a);
209
- this.x = x;
210
- this.y = y;
211
- return this;
212
- };
213
- DPoint.prototype.rotate3dX = function (a) {
214
- var _a = this, y = _a.y, z = _a.z;
215
- this.y = y * Math.cos(a) + z * Math.sin(a);
216
- this.z = -y * Math.sin(a) + z * Math.cos(a);
217
- return this;
218
- };
219
- DPoint.prototype.rotate3dY = function (a) {
220
- var _a = this, x = _a.x, z = _a.z;
221
- this.x = x * Math.cos(a) + z * Math.sin(a);
222
- this.z = -x * Math.sin(a) + z * Math.cos(a);
223
- return this;
224
- };
225
- DPoint.prototype.rotate3dZ = function (a) {
226
- var _a = this, x = _a.x, y = _a.y;
227
- this.x = x * Math.cos(a) - y * Math.sin(a);
228
- this.y = -x * Math.sin(a) + y * Math.cos(a);
229
- return this;
230
- };
231
- DPoint.prototype.move = function (x, y, z) {
232
- if (y === void 0) { y = x; }
233
- var xV = 0;
234
- var yV = 0;
235
- var zV = undefined;
236
- if (x instanceof DPoint) {
237
- xV = this.x + x.x;
238
- yV = this.y + x.y;
239
- if ((0, utils_1.isDefAndNotNull)(this.z) && (0, utils_1.isDefAndNotNull)(x.z)) {
240
- zV = this.z + x.z;
241
- }
242
- }
243
- else {
244
- xV = this.x + x;
245
- yV = this.y + y;
246
- if ((0, utils_1.isDefAndNotNull)(this.z) && (0, utils_1.isDefAndNotNull)(z)) {
247
- zV = this.z + z;
248
- }
249
- }
250
- this.x = xV;
251
- this.y = yV;
252
- if ((0, utils_1.isDefAndNotNull)(zV)) {
253
- this.z = zV;
254
- }
255
- return this;
256
- };
257
- DPoint.prototype.degreeToMeters = function () {
258
- (0, utils_1.checkFunction)('degreeToMeters')
259
- .checkArgument('this')
260
- .shouldBeDegree(this);
261
- var x = ((this.x + exports.PI_IN_DEGREE) % exports.DOUBLE_PI_IN_DEGREE - exports.PI_IN_DEGREE) * MITERS_IN_ONE_DEGREE;
262
- var y = (Math.log(Math.tan(((this.y + exports.HALF_PI_IN_DEGREE) % exports.PI_IN_DEGREE) *
263
- (Math.PI / exports.DOUBLE_PI_IN_DEGREE))) / exports.PI_TO_DEGREE) * MITERS_IN_ONE_DEGREE;
264
- this.x = x;
265
- this.y = y;
266
- return this;
267
- };
268
- DPoint.prototype.metersToDegree = function () {
269
- (0, utils_1.checkFunction)('metersToDegree')
270
- .checkArgument('this')
271
- .shouldBeMeters(this);
272
- var lon = this.x * DEGREES_IN_ONE_MITER;
273
- var lat = Math.atan(Math.pow(Math.E, ((this.y / MITERS_IN_ONE_DEGREE) * exports.PI_TO_DEGREE))) *
274
- (exports.DOUBLE_PI_IN_DEGREE / Math.PI) - exports.HALF_PI_IN_DEGREE;
275
- this.x = lon;
276
- this.y = lat;
277
- return this;
278
- };
279
- DPoint.prototype.degreeToRadians = function () {
280
- (0, utils_1.checkFunction)('degreeToRadians')
281
- .checkArgument('this')
282
- .shouldBeDegree(this);
283
- return this.scale(exports.PI_TO_DEGREE);
284
- };
285
- DPoint.prototype.radiansToDegrees = function () {
286
- (0, utils_1.checkFunction)('radiansToDegrees')
287
- .checkArgument('this')
288
- .shouldBeRadians(this);
289
- return this.scale(exports.DEGREE_TO_PI);
290
- };
291
- DPoint.prototype.radiansToMeters = function () {
292
- (0, utils_1.checkFunction)('radiansToMeters')
293
- .checkArgument('this')
294
- .shouldBeRadians(this);
295
- return this.radiansToDegrees().degreeToMeters();
296
- };
297
- DPoint.prototype.metersToRadians = function () {
298
- (0, utils_1.checkFunction)('metersToRadians')
299
- .checkArgument('this')
300
- .shouldBeMeters(this);
301
- return this.metersToDegree().degreeToRadians();
302
- };
303
- DPoint.prototype.round = function () {
304
- this.x = Math.round(this.x);
305
- this.y = Math.round(this.y);
306
- return this;
307
- };
308
- DPoint.prototype.ceil = function () {
309
- this.x = Math.ceil(this.x);
310
- this.y = Math.ceil(this.y);
311
- return this;
312
- };
313
- DPoint.prototype.floor = function () {
314
- this.x = Math.floor(this.x);
315
- this.y = Math.floor(this.y);
316
- return this;
317
- };
318
- DPoint.prototype.toFixed = function (n) {
319
- if (n === void 0) { n = 2; }
320
- this.x = parseFloat(this.x.toFixed(n));
321
- this.y = parseFloat(this.y.toFixed(n));
322
- return this;
323
- };
324
- DPoint.prototype.abs = function () {
325
- this.x = Math.abs(this.x);
326
- this.y = Math.abs(this.y);
327
- return this;
328
- };
329
- DPoint.prototype.scale = function (x, y, z) {
330
- if (y === void 0) { y = x; }
331
- var xV = 0;
332
- var yV = 0;
333
- var zV = undefined;
334
- if (x instanceof DPoint) {
335
- xV = this.x * x.x;
336
- yV = this.y * x.y;
337
- if ((0, utils_1.isDefAndNotNull)(this.z) && (0, utils_1.isDefAndNotNull)(x.z)) {
338
- zV = this.z * x.z;
339
- }
340
- }
341
- else {
342
- xV = this.x * x;
343
- yV = this.y * y;
344
- if ((0, utils_1.isDefAndNotNull)(this.z) && (0, utils_1.isDefAndNotNull)(z)) {
345
- zV = this.z * z;
346
- }
347
- }
348
- this.x = xV;
349
- this.y = yV;
350
- if ((0, utils_1.isDefAndNotNull)(zV)) {
351
- this.z = zV;
352
- }
353
- return this;
354
- };
355
- DPoint.prototype.divide = function (x, y, z) {
356
- if (y === void 0) { y = x; }
357
- var xV = 0;
358
- var yV = 0;
359
- var zV = undefined;
360
- if (x instanceof DPoint) {
361
- xV = this.x / x.x;
362
- yV = this.y / x.y;
363
- if ((0, utils_1.isDefAndNotNull)(this.z) && (0, utils_1.isDefAndNotNull)(x.z)) {
364
- zV = this.z / x.z;
365
- }
366
- }
367
- else {
368
- xV = this.x / x;
369
- yV = this.y / y;
370
- if ((0, utils_1.isDefAndNotNull)(this.z) && (0, utils_1.isDefAndNotNull)(z)) {
371
- zV = this.z / z;
372
- }
373
- }
374
- this.x = xV;
375
- this.y = yV;
376
- if ((0, utils_1.isDefAndNotNull)(zV)) {
377
- this.z = zV;
378
- }
379
- return this;
380
- };
381
- DPoint.prototype.equal = function (p) {
382
- return this.x === p.x && this.y === p.y && this.z === p.z;
383
- };
384
- DPoint.prototype.like = function (p, d) {
385
- var _a, _b, _c, _d;
386
- if (d === void 0) { d = 0.001; }
387
- if (this.equal(p)) {
388
- return true;
389
- }
390
- var likeX = Math.abs(this.x - p.x) < d;
391
- var likeY = Math.abs(this.y - p.y) < d;
392
- var likeZ = Math.abs(((_b = (_a = this.z) !== null && _a !== void 0 ? _a : p.z) !== null && _b !== void 0 ? _b : 0) - ((_d = (_c = p.z) !== null && _c !== void 0 ? _c : this.z) !== null && _d !== void 0 ? _d : 0)) < d;
393
- return likeX && likeY && likeZ;
394
- };
395
- DPoint.prototype.flipVertically = function (size) {
396
- var v = size;
397
- if (size instanceof DPoint) {
398
- v = size.y;
399
- }
400
- this.y = v - this.y;
401
- return this;
402
- };
403
- Object.defineProperty(DPoint.prototype, "likeRadians", {
404
- get: function () {
405
- if (radiansPolygon.length === 0) {
406
- radiansPolygon.push(new DPoint(-Math.PI, -Math.PI / 2), new DPoint(Math.PI, Math.PI / 2));
407
- }
408
- return radiansPolygon.simpleInclude(this);
409
- },
410
- enumerable: false,
411
- configurable: true
412
- });
413
- Object.defineProperty(DPoint.prototype, "likeWorldGeodeticSystem", {
414
- get: function () {
415
- if (worldGeodeticPolygon.length === 0) {
416
- worldGeodeticPolygon.push(new DPoint(-180, -90), new DPoint(180, 90));
417
- }
418
- return !this.likeRadians && worldGeodeticPolygon.simpleInclude(this);
419
- },
420
- enumerable: false,
421
- configurable: true
422
- });
423
- Object.defineProperty(DPoint.prototype, "likePseudoMercator", {
424
- get: function () {
425
- if (pseudoMercatorPolygon.length === 0) {
426
- pseudoMercatorPolygon.push(new DPoint(-20026376.39, -20048966.10), new DPoint(20026376.39, 20048966.10));
427
- }
428
- return !this.likeRadians && !this.likeWorldGeodeticSystem && pseudoMercatorPolygon.simpleInclude(this);
429
- },
430
- enumerable: false,
431
- configurable: true
432
- });
433
- Object.defineProperty(DPoint.prototype, "w", {
434
- get: function () {
435
- return this.x;
436
- },
437
- set: function (x) {
438
- this.x = x;
439
- },
440
- enumerable: false,
441
- configurable: true
442
- });
443
- Object.defineProperty(DPoint.prototype, "h", {
444
- get: function () {
445
- return this.y;
446
- },
447
- set: function (y) {
448
- this.y = y;
449
- },
450
- enumerable: false,
451
- configurable: true
452
- });
453
- Object.defineProperty(DPoint.prototype, "area", {
454
- get: function () {
455
- (0, utils_1.checkFunction)('area')
456
- .checkArgument('this')
457
- .shouldBeMeters(this);
458
- return this.w * this.h;
459
- },
460
- enumerable: false,
461
- configurable: true
462
- });
463
- Object.defineProperty(DPoint.prototype, "hip", {
464
- get: function () {
465
- (0, utils_1.checkFunction)('hip')
466
- .checkArgument('this')
467
- .shouldBeMeters(this);
468
- return Math.sqrt(this.w * this.w + this.h * this.h);
469
- },
470
- enumerable: false,
471
- configurable: true
472
- });
473
- Object.defineProperty(DPoint.prototype, "min", {
474
- get: function () {
475
- return Math.min(this.x, this.y);
476
- },
477
- enumerable: false,
478
- configurable: true
479
- });
480
- Object.defineProperty(DPoint.prototype, "max", {
481
- get: function () {
482
- return Math.max(this.x, this.y);
483
- },
484
- enumerable: false,
485
- configurable: true
486
- });
487
- Object.defineProperty(DPoint.prototype, "hipPoint", {
488
- get: function () {
489
- var hip = this.hip;
490
- return new DPoint(hip, hip);
491
- },
492
- enumerable: false,
493
- configurable: true
494
- });
495
- Object.defineProperty(DPoint.prototype, "xPoint", {
496
- get: function () {
497
- var x = this.x;
498
- return new DPoint(x, x);
499
- },
500
- enumerable: false,
501
- configurable: true
502
- });
503
- Object.defineProperty(DPoint.prototype, "yPoint", {
504
- get: function () {
505
- var y = this.y;
506
- return new DPoint(y, y);
507
- },
508
- enumerable: false,
509
- configurable: true
510
- });
511
- Object.defineProperty(DPoint.prototype, "wPoint", {
512
- get: function () {
513
- return this.xPoint;
514
- },
515
- enumerable: false,
516
- configurable: true
517
- });
518
- Object.defineProperty(DPoint.prototype, "hPoint", {
519
- get: function () {
520
- return this.yPoint;
521
- },
522
- enumerable: false,
523
- configurable: true
524
- });
525
- DPoint.prototype.simple = function (xKey, yKey) {
526
- var _a;
527
- if (xKey === void 0) { xKey = 'x'; }
528
- if (yKey === void 0) { yKey = 'y'; }
529
- return _a = {},
530
- _a[xKey] = this.x,
531
- _a[yKey] = this.y,
532
- _a;
533
- };
534
- DPoint.prototype.setIfLessThan = function (p) {
535
- this.x = Math.max(this.x, p.x);
536
- this.y = Math.max(this.y, p.y);
537
- return this;
538
- };
539
- DPoint.prototype.minus = function () {
540
- return this.scale(-1);
541
- };
542
- DPoint.prototype.orthodromicPath = function (point, pointsCount) {
543
- if (pointsCount === void 0) { pointsCount = 360; }
544
- (0, utils_1.checkFunction)('orthodromicPath')
545
- .checkArgument('this')
546
- .shouldBeDegree(this)
547
- .checkArgument('point')
548
- .shouldBeDegree(point);
549
- var t = this.clone().degreeToRadians();
550
- var p = point.clone().degreeToRadians();
551
- var d = Math.sin(p.x - t.x);
552
- var step = (p.x - t.x) / (pointsCount - 1);
553
- return new DPolygon_1.DPolygon((0, utils_1.createArray)(pointsCount)
554
- .map(function (v, i) {
555
- var x = t.x + step * i;
556
- var y = Math.atan((Math.tan(t.y) * Math.sin(p.x - x)) / d +
557
- (Math.tan(p.y) * Math.sin(x - t.x)) / d);
558
- return new DPoint(x, y).radiansToDegrees();
559
- }));
560
- };
561
- DPoint.prototype.sortByDistance = function (p) {
562
- var _this = this;
563
- return p
564
- .clone()
565
- .map(function (d, index) {
566
- d.properties.distance = d.distance(_this);
567
- d.properties.index = index;
568
- return d;
569
- })
570
- .sort(function (a, b) { return a.properties.distance - b.properties.distance; });
571
- };
572
- return DPoint;
573
- }());
574
- exports.DPoint = DPoint;