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