dgeoutils 2.2.24 → 2.3.3

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 (50) hide show
  1. package/README.md +7 -0
  2. package/dist/{DCircle.d.ts → cjs/DCircle.d.ts} +0 -0
  3. package/dist/cjs/DCircle.js +102 -0
  4. package/dist/{DLine.d.ts → cjs/DLine.d.ts} +0 -0
  5. package/dist/cjs/DLine.js +300 -0
  6. package/dist/{DNumbers.d.ts → cjs/DNumbers.d.ts} +0 -0
  7. package/dist/cjs/DNumbers.js +30 -0
  8. package/dist/{DPlane.d.ts → cjs/DPlane.d.ts} +0 -0
  9. package/dist/cjs/DPlane.js +132 -0
  10. package/dist/{DPoint.d.ts → cjs/DPoint.d.ts} +0 -0
  11. package/dist/cjs/DPoint.js +574 -0
  12. package/dist/{DPolygon.d.ts → cjs/DPolygon.d.ts} +1 -1
  13. package/dist/cjs/DPolygon.js +1555 -0
  14. package/dist/{DPolygonLoop.d.ts → cjs/DPolygonLoop.d.ts} +0 -0
  15. package/dist/cjs/DPolygonLoop.js +401 -0
  16. package/dist/{FastSearch.d.ts → cjs/FastSearch.d.ts} +0 -0
  17. package/dist/cjs/FastSearch.js +53 -0
  18. package/dist/{TraceMatrix.d.ts → cjs/TraceMatrix.d.ts} +1 -2
  19. package/dist/cjs/TraceMatrix.js +256 -0
  20. package/dist/{index.d.ts → cjs/index.d.ts} +1 -4
  21. package/dist/{index.js → cjs/index.js} +1 -3
  22. package/dist/{utils.d.ts → cjs/utils.d.ts} +3 -0
  23. package/dist/cjs/utils.js +193 -0
  24. package/dist/{DCircle.js → es2015/DCircle.js} +14 -18
  25. package/dist/{DLine.js → es2015/DLine.js} +24 -28
  26. package/dist/es2015/DNumbers.js +22 -0
  27. package/dist/{DPlane.js → es2015/DPlane.js} +22 -26
  28. package/dist/{DPoint.js → es2015/DPoint.js} +52 -56
  29. package/dist/{DPolygon.js → es2015/DPolygon.js} +71 -75
  30. package/dist/{DPolygonLoop.js → es2015/DPolygonLoop.js} +1 -5
  31. package/dist/{FastSearch.js → es2015/FastSearch.js} +1 -5
  32. package/dist/{TraceMatrix.js → es2015/TraceMatrix.js} +35 -39
  33. package/dist/es2015/index.js +10 -0
  34. package/dist/{utils.js → es2015/utils.js} +28 -36
  35. package/dist/esm/DCircle.js +99 -0
  36. package/dist/esm/DLine.js +297 -0
  37. package/dist/esm/DNumbers.js +27 -0
  38. package/dist/esm/DPlane.js +129 -0
  39. package/dist/esm/DPoint.js +571 -0
  40. package/dist/esm/DPolygon.js +1552 -0
  41. package/dist/esm/DPolygonLoop.js +398 -0
  42. package/dist/esm/FastSearch.js +50 -0
  43. package/dist/esm/TraceMatrix.js +253 -0
  44. package/dist/esm/index.js +10 -0
  45. package/dist/esm/utils.js +183 -0
  46. package/dist/umd/dgeoutils.js +3568 -0
  47. package/dist/umd/dgeoutils.min.js +1 -0
  48. package/dist/umd/dgeoutils.min.js.map +1 -0
  49. package/package.json +19 -12
  50. package/dist/DNumbers.js +0 -26
@@ -0,0 +1,574 @@
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;
@@ -87,7 +87,7 @@ export declare class DPolygon {
87
87
  removePart(index: number, count: number): DPoint[];
88
88
  hasSimpleIntersection(p: DPolygon): boolean;
89
89
  simpleInclude(p: DPoint): boolean;
90
- drawPolygonOnCanvas(canvas: HTMLCanvasElement | OffscreenCanvas, fillColor?: string, strokeColor?: string, shadowColor?: string, lineWidth?: number, steps?: number): void;
90
+ drawPolygonOnCanvas(canvas: HTMLCanvasElement | OffscreenCanvas, fillColor?: string, strokeColor?: string, shadowColor?: string, lineWidth?: number, steps?: number): DPolygon;
91
91
  clearPolygonOnCanvas(canvas: HTMLCanvasElement | OffscreenCanvas): void;
92
92
  contain(p: DPoint, isBorderInside?: boolean): boolean;
93
93
  onBorder(p: DPoint): boolean;