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
@@ -0,0 +1,614 @@
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.getTileFromQuadKey = function (quadKey) {
79
+ var p = new DPoint(0, 0, quadKey.length);
80
+ for (var i = p.z; i > 0; i--) {
81
+ var mask = 1 << (i - 1);
82
+ switch (quadKey[p.z - i]) {
83
+ case '0':
84
+ break;
85
+ case '1':
86
+ p.x |= mask;
87
+ break;
88
+ case '2':
89
+ p.y |= mask;
90
+ break;
91
+ case '3':
92
+ p.x |= mask;
93
+ p.y |= mask;
94
+ break;
95
+ default:
96
+ throw new Error('Invalid QuadKey digit sequence.');
97
+ }
98
+ }
99
+ return p;
100
+ };
101
+ DPoint.prototype.getTileFromCoords = function (zoom) {
102
+ if (zoom === void 0) { zoom = this.z; }
103
+ (0, utils_1.checkFunction)('getTileFromCoords')
104
+ .checkArgument('this')
105
+ .shouldBeDegree(this);
106
+ var x = Math.floor((this.x + exports.PI_IN_DEGREE) / exports.DOUBLE_PI_IN_DEGREE * (Math.pow(2, zoom)));
107
+ 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)));
108
+ return new DPoint(x, y, zoom);
109
+ };
110
+ DPoint.prototype.getQuadKeyFromTile = function (zoom) {
111
+ if (zoom === void 0) { zoom = this.z; }
112
+ var quadKey = [];
113
+ for (var i = zoom; i > 0; i--) {
114
+ var digit = 0;
115
+ var mask = 1 << (i - 1);
116
+ if ((this.x & mask) !== 0) {
117
+ digit++;
118
+ }
119
+ if ((this.y & mask) !== 0) {
120
+ digit++;
121
+ digit++;
122
+ }
123
+ quadKey.push(digit);
124
+ }
125
+ return quadKey.join('');
126
+ };
127
+ DPoint.prototype.getCoordsFromTile = function (zoom) {
128
+ if (zoom === void 0) { zoom = this.z; }
129
+ (0, utils_1.checkFunction)('getCoordsFromTile')
130
+ .checkArgument('this')
131
+ .shouldBeUInt(this);
132
+ var n = Math.PI - 2 * Math.PI * this.y / (Math.pow(2, zoom));
133
+ var x = this.x / (Math.pow(2, zoom)) * exports.DOUBLE_PI_IN_DEGREE - exports.PI_IN_DEGREE;
134
+ var y = exports.PI_IN_DEGREE / Math.PI * Math.atan((Math.exp(n) - Math.exp(-n)) / 2);
135
+ return new DPoint(x, y, zoom);
136
+ };
137
+ DPoint.prototype.toCoords = function () {
138
+ if (this.z === undefined) {
139
+ return [this.x, this.y];
140
+ }
141
+ return [this.x, this.y, this.z];
142
+ };
143
+ DPoint.prototype.findLine = function (p) {
144
+ (0, utils_1.checkFunction)('findLine')
145
+ .checkArgument('this')
146
+ .shouldBeMeters(this)
147
+ .checkArgument('p')
148
+ .shouldBeMeters(p);
149
+ if (this.equal(p)) {
150
+ return this.findLine(p.clone().move(0, 1));
151
+ }
152
+ var a = this.y - p.y - diff;
153
+ var b = p.x - this.x - diff;
154
+ var c = this.x * p.y - p.x * this.y - diff;
155
+ if (a === 0) {
156
+ return new DLine_1.DLine(0, 1, c / b, this, p);
157
+ }
158
+ if (b === 0) {
159
+ return new DLine_1.DLine(1, 0, c / a, this, p);
160
+ }
161
+ return new DLine_1.DLine(a, b, c, this, p);
162
+ };
163
+ DPoint.prototype.findInnerAngle = function (p1, p3) {
164
+ (0, utils_1.checkFunction)('findInnerAngle')
165
+ .checkArgument('this')
166
+ .shouldBeMeters(this)
167
+ .checkArgument('p1')
168
+ .shouldBeMeters(p1)
169
+ .checkArgument('p3')
170
+ .shouldBeMeters(p3);
171
+ var a1 = this.findLine(p1).getFi();
172
+ var a2 = this.findLine(p3).getFi();
173
+ if (a2 >= a1) {
174
+ return a2 - a1;
175
+ }
176
+ return a2 + Math.PI * 2 - a1;
177
+ };
178
+ DPoint.prototype.toString = function () {
179
+ return "".concat(this.x, " ").concat(this.y);
180
+ };
181
+ DPoint.prototype.getValue = function () {
182
+ return [this.x, this.y];
183
+ };
184
+ DPoint.prototype.height = function (z) {
185
+ this.z = z;
186
+ return this;
187
+ };
188
+ DPoint.prototype.toWKT = function () {
189
+ var _a = this, x = _a.x, y = _a.y;
190
+ return "POINT (".concat(x, " ").concat(y, ")");
191
+ };
192
+ DPoint.prototype.distance = function (p) {
193
+ (0, utils_1.checkFunction)('distance')
194
+ .checkArgument('this')
195
+ .shouldBeMeters(this)
196
+ .checkArgument('p')
197
+ .shouldBeMeters(p);
198
+ var dx = p.x - this.x;
199
+ var dy = p.y - this.y;
200
+ return Math.sqrt(dx * dx + dy * dy);
201
+ };
202
+ DPoint.prototype.distance3d = function (p) {
203
+ (0, utils_1.checkFunction)('distance3d')
204
+ .checkArgument('this')
205
+ .shouldBeMeters(this)
206
+ .checkArgument('p')
207
+ .shouldBeMeters(p)
208
+ .checkArgument('this.z')
209
+ .shouldExist(this.z)
210
+ .checkArgument('p.z')
211
+ .shouldExist(p.z);
212
+ var dx = p.x - this.x;
213
+ var dy = p.y - this.y;
214
+ var dz = p.z - this.z;
215
+ return Math.sqrt(dx * dx + dy * dy + dz * dz);
216
+ };
217
+ DPoint.prototype.setX = function (x) {
218
+ this.x = typeof x === 'number' ? x : x(this);
219
+ return this;
220
+ };
221
+ DPoint.prototype.setZ = function (z) {
222
+ this.z = typeof z === 'number' ? z : z(this);
223
+ return this;
224
+ };
225
+ DPoint.prototype.setY = function (y) {
226
+ this.y = typeof y === 'number' ? y : y(this);
227
+ return this;
228
+ };
229
+ DPoint.prototype.clone = function () {
230
+ var p = new DPoint(this.x, this.y, this.z);
231
+ p.properties = __assign({}, this.properties);
232
+ return p;
233
+ };
234
+ DPoint.prototype.gt = function (p) {
235
+ return this.x > p.x && this.y > p.y;
236
+ };
237
+ DPoint.prototype.lt = function (p) {
238
+ return this.x < p.x && this.y < p.y;
239
+ };
240
+ DPoint.prototype.gtOrEqual = function (p) {
241
+ return this.gt(p) || this.equal(p);
242
+ };
243
+ DPoint.prototype.ltOrEqual = function (p) {
244
+ return this.lt(p) || this.equal(p);
245
+ };
246
+ DPoint.prototype.rotate = function (a) {
247
+ var x = this.x * Math.cos(a) - this.y * Math.sin(a);
248
+ var y = this.x * Math.sin(a) + this.y * Math.cos(a);
249
+ this.x = x;
250
+ this.y = y;
251
+ return this;
252
+ };
253
+ DPoint.prototype.rotate3dX = function (a) {
254
+ var _a = this, y = _a.y, z = _a.z;
255
+ this.y = y * Math.cos(a) + z * Math.sin(a);
256
+ this.z = -y * Math.sin(a) + z * Math.cos(a);
257
+ return this;
258
+ };
259
+ DPoint.prototype.rotate3dY = function (a) {
260
+ var _a = this, x = _a.x, z = _a.z;
261
+ this.x = x * Math.cos(a) + z * Math.sin(a);
262
+ this.z = -x * Math.sin(a) + z * Math.cos(a);
263
+ return this;
264
+ };
265
+ DPoint.prototype.rotate3dZ = function (a) {
266
+ var _a = this, x = _a.x, y = _a.y;
267
+ this.x = x * Math.cos(a) - y * Math.sin(a);
268
+ this.y = -x * Math.sin(a) + y * Math.cos(a);
269
+ return this;
270
+ };
271
+ DPoint.prototype.move = function (x, y, z) {
272
+ if (y === void 0) { y = x; }
273
+ var xV = 0;
274
+ var yV = 0;
275
+ var zV = undefined;
276
+ if (x instanceof DPoint) {
277
+ xV = this.x + x.x;
278
+ yV = this.y + x.y;
279
+ if ((0, utils_1.isDefAndNotNull)(this.z) && (0, utils_1.isDefAndNotNull)(x.z)) {
280
+ zV = this.z + x.z;
281
+ }
282
+ }
283
+ else {
284
+ xV = this.x + x;
285
+ yV = this.y + y;
286
+ if ((0, utils_1.isDefAndNotNull)(this.z) && (0, utils_1.isDefAndNotNull)(z)) {
287
+ zV = this.z + z;
288
+ }
289
+ }
290
+ this.x = xV;
291
+ this.y = yV;
292
+ if ((0, utils_1.isDefAndNotNull)(zV)) {
293
+ this.z = zV;
294
+ }
295
+ return this;
296
+ };
297
+ DPoint.prototype.degreeToMeters = function () {
298
+ (0, utils_1.checkFunction)('degreeToMeters')
299
+ .checkArgument('this')
300
+ .shouldBeDegree(this);
301
+ var x = ((this.x + exports.PI_IN_DEGREE) % exports.DOUBLE_PI_IN_DEGREE - exports.PI_IN_DEGREE) * MITERS_IN_ONE_DEGREE;
302
+ var y = (Math.log(Math.tan(((this.y + exports.HALF_PI_IN_DEGREE) % exports.PI_IN_DEGREE) *
303
+ (Math.PI / exports.DOUBLE_PI_IN_DEGREE))) / exports.PI_TO_DEGREE) * MITERS_IN_ONE_DEGREE;
304
+ this.x = x;
305
+ this.y = y;
306
+ return this;
307
+ };
308
+ DPoint.prototype.metersToDegree = function () {
309
+ (0, utils_1.checkFunction)('metersToDegree')
310
+ .checkArgument('this')
311
+ .shouldBeMeters(this);
312
+ var lon = this.x * DEGREES_IN_ONE_MITER;
313
+ var lat = Math.atan(Math.pow(Math.E, ((this.y / MITERS_IN_ONE_DEGREE) * exports.PI_TO_DEGREE))) *
314
+ (exports.DOUBLE_PI_IN_DEGREE / Math.PI) - exports.HALF_PI_IN_DEGREE;
315
+ this.x = lon;
316
+ this.y = lat;
317
+ return this;
318
+ };
319
+ DPoint.prototype.degreeToRadians = function () {
320
+ (0, utils_1.checkFunction)('degreeToRadians')
321
+ .checkArgument('this')
322
+ .shouldBeDegree(this);
323
+ return this.scale(exports.PI_TO_DEGREE);
324
+ };
325
+ DPoint.prototype.radiansToDegrees = function () {
326
+ (0, utils_1.checkFunction)('radiansToDegrees')
327
+ .checkArgument('this')
328
+ .shouldBeRadians(this);
329
+ return this.scale(exports.DEGREE_TO_PI);
330
+ };
331
+ DPoint.prototype.radiansToMeters = function () {
332
+ (0, utils_1.checkFunction)('radiansToMeters')
333
+ .checkArgument('this')
334
+ .shouldBeRadians(this);
335
+ return this.radiansToDegrees().degreeToMeters();
336
+ };
337
+ DPoint.prototype.metersToRadians = function () {
338
+ (0, utils_1.checkFunction)('metersToRadians')
339
+ .checkArgument('this')
340
+ .shouldBeMeters(this);
341
+ return this.metersToDegree().degreeToRadians();
342
+ };
343
+ DPoint.prototype.round = function () {
344
+ this.x = Math.round(this.x);
345
+ this.y = Math.round(this.y);
346
+ return this;
347
+ };
348
+ DPoint.prototype.ceil = function () {
349
+ this.x = Math.ceil(this.x);
350
+ this.y = Math.ceil(this.y);
351
+ return this;
352
+ };
353
+ DPoint.prototype.floor = function () {
354
+ this.x = Math.floor(this.x);
355
+ this.y = Math.floor(this.y);
356
+ return this;
357
+ };
358
+ DPoint.prototype.toFixed = function (n) {
359
+ if (n === void 0) { n = 2; }
360
+ this.x = parseFloat(this.x.toFixed(n));
361
+ this.y = parseFloat(this.y.toFixed(n));
362
+ return this;
363
+ };
364
+ DPoint.prototype.abs = function () {
365
+ this.x = Math.abs(this.x);
366
+ this.y = Math.abs(this.y);
367
+ return this;
368
+ };
369
+ DPoint.prototype.scale = function (x, y, z) {
370
+ if (y === void 0) { y = x; }
371
+ var xV = 0;
372
+ var yV = 0;
373
+ var zV = undefined;
374
+ if (x instanceof DPoint) {
375
+ xV = this.x * x.x;
376
+ yV = this.y * x.y;
377
+ if ((0, utils_1.isDefAndNotNull)(this.z) && (0, utils_1.isDefAndNotNull)(x.z)) {
378
+ zV = this.z * x.z;
379
+ }
380
+ }
381
+ else {
382
+ xV = this.x * x;
383
+ yV = this.y * y;
384
+ if ((0, utils_1.isDefAndNotNull)(this.z) && (0, utils_1.isDefAndNotNull)(z)) {
385
+ zV = this.z * z;
386
+ }
387
+ }
388
+ this.x = xV;
389
+ this.y = yV;
390
+ if ((0, utils_1.isDefAndNotNull)(zV)) {
391
+ this.z = zV;
392
+ }
393
+ return this;
394
+ };
395
+ DPoint.prototype.divide = function (x, y, z) {
396
+ if (y === void 0) { y = x; }
397
+ var xV = 0;
398
+ var yV = 0;
399
+ var zV = undefined;
400
+ if (x instanceof DPoint) {
401
+ xV = this.x / x.x;
402
+ yV = this.y / x.y;
403
+ if ((0, utils_1.isDefAndNotNull)(this.z) && (0, utils_1.isDefAndNotNull)(x.z)) {
404
+ zV = this.z / x.z;
405
+ }
406
+ }
407
+ else {
408
+ xV = this.x / x;
409
+ yV = this.y / y;
410
+ if ((0, utils_1.isDefAndNotNull)(this.z) && (0, utils_1.isDefAndNotNull)(z)) {
411
+ zV = this.z / z;
412
+ }
413
+ }
414
+ this.x = xV;
415
+ this.y = yV;
416
+ if ((0, utils_1.isDefAndNotNull)(zV)) {
417
+ this.z = zV;
418
+ }
419
+ return this;
420
+ };
421
+ DPoint.prototype.equal = function (p) {
422
+ return this.x === p.x && this.y === p.y && this.z === p.z;
423
+ };
424
+ DPoint.prototype.like = function (p, d) {
425
+ var _a, _b, _c, _d;
426
+ if (d === void 0) { d = 0.001; }
427
+ if (this.equal(p)) {
428
+ return true;
429
+ }
430
+ var likeX = Math.abs(this.x - p.x) < d;
431
+ var likeY = Math.abs(this.y - p.y) < d;
432
+ 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;
433
+ return likeX && likeY && likeZ;
434
+ };
435
+ DPoint.prototype.flipVertically = function (size) {
436
+ var v = size;
437
+ if (size instanceof DPoint) {
438
+ v = size.y;
439
+ }
440
+ this.y = v - this.y;
441
+ return this;
442
+ };
443
+ Object.defineProperty(DPoint.prototype, "likeRadians", {
444
+ get: function () {
445
+ if (radiansPolygon.length === 0) {
446
+ radiansPolygon.push(new DPoint(-Math.PI, -Math.PI / 2), new DPoint(Math.PI, Math.PI / 2));
447
+ }
448
+ return radiansPolygon.simpleInclude(this);
449
+ },
450
+ enumerable: false,
451
+ configurable: true
452
+ });
453
+ Object.defineProperty(DPoint.prototype, "likeWorldGeodeticSystem", {
454
+ get: function () {
455
+ if (worldGeodeticPolygon.length === 0) {
456
+ worldGeodeticPolygon.push(new DPoint(-180, -90), new DPoint(180, 90));
457
+ }
458
+ return !this.likeRadians && worldGeodeticPolygon.simpleInclude(this);
459
+ },
460
+ enumerable: false,
461
+ configurable: true
462
+ });
463
+ Object.defineProperty(DPoint.prototype, "likePseudoMercator", {
464
+ get: function () {
465
+ if (pseudoMercatorPolygon.length === 0) {
466
+ pseudoMercatorPolygon.push(new DPoint(-20026376.39, -20048966.10), new DPoint(20026376.39, 20048966.10));
467
+ }
468
+ return !this.likeRadians && !this.likeWorldGeodeticSystem && pseudoMercatorPolygon.simpleInclude(this);
469
+ },
470
+ enumerable: false,
471
+ configurable: true
472
+ });
473
+ Object.defineProperty(DPoint.prototype, "w", {
474
+ get: function () {
475
+ return this.x;
476
+ },
477
+ set: function (x) {
478
+ this.x = x;
479
+ },
480
+ enumerable: false,
481
+ configurable: true
482
+ });
483
+ Object.defineProperty(DPoint.prototype, "h", {
484
+ get: function () {
485
+ return this.y;
486
+ },
487
+ set: function (y) {
488
+ this.y = y;
489
+ },
490
+ enumerable: false,
491
+ configurable: true
492
+ });
493
+ Object.defineProperty(DPoint.prototype, "area", {
494
+ get: function () {
495
+ (0, utils_1.checkFunction)('area')
496
+ .checkArgument('this')
497
+ .shouldBeMeters(this);
498
+ return this.w * this.h;
499
+ },
500
+ enumerable: false,
501
+ configurable: true
502
+ });
503
+ Object.defineProperty(DPoint.prototype, "hip", {
504
+ get: function () {
505
+ (0, utils_1.checkFunction)('hip')
506
+ .checkArgument('this')
507
+ .shouldBeMeters(this);
508
+ return Math.sqrt(this.w * this.w + this.h * this.h);
509
+ },
510
+ enumerable: false,
511
+ configurable: true
512
+ });
513
+ Object.defineProperty(DPoint.prototype, "min", {
514
+ get: function () {
515
+ return Math.min(this.x, this.y);
516
+ },
517
+ enumerable: false,
518
+ configurable: true
519
+ });
520
+ Object.defineProperty(DPoint.prototype, "max", {
521
+ get: function () {
522
+ return Math.max(this.x, this.y);
523
+ },
524
+ enumerable: false,
525
+ configurable: true
526
+ });
527
+ Object.defineProperty(DPoint.prototype, "hipPoint", {
528
+ get: function () {
529
+ var hip = this.hip;
530
+ return new DPoint(hip, hip);
531
+ },
532
+ enumerable: false,
533
+ configurable: true
534
+ });
535
+ Object.defineProperty(DPoint.prototype, "xPoint", {
536
+ get: function () {
537
+ var x = this.x;
538
+ return new DPoint(x, x);
539
+ },
540
+ enumerable: false,
541
+ configurable: true
542
+ });
543
+ Object.defineProperty(DPoint.prototype, "yPoint", {
544
+ get: function () {
545
+ var y = this.y;
546
+ return new DPoint(y, y);
547
+ },
548
+ enumerable: false,
549
+ configurable: true
550
+ });
551
+ Object.defineProperty(DPoint.prototype, "wPoint", {
552
+ get: function () {
553
+ return this.xPoint;
554
+ },
555
+ enumerable: false,
556
+ configurable: true
557
+ });
558
+ Object.defineProperty(DPoint.prototype, "hPoint", {
559
+ get: function () {
560
+ return this.yPoint;
561
+ },
562
+ enumerable: false,
563
+ configurable: true
564
+ });
565
+ DPoint.prototype.simple = function (xKey, yKey) {
566
+ var _a;
567
+ if (xKey === void 0) { xKey = 'x'; }
568
+ if (yKey === void 0) { yKey = 'y'; }
569
+ return _a = {},
570
+ _a[xKey] = this.x,
571
+ _a[yKey] = this.y,
572
+ _a;
573
+ };
574
+ DPoint.prototype.setIfLessThan = function (p) {
575
+ this.x = Math.max(this.x, p.x);
576
+ this.y = Math.max(this.y, p.y);
577
+ return this;
578
+ };
579
+ DPoint.prototype.minus = function () {
580
+ return this.scale(-1);
581
+ };
582
+ DPoint.prototype.orthodromicPath = function (point, pointsCount) {
583
+ if (pointsCount === void 0) { pointsCount = 360; }
584
+ (0, utils_1.checkFunction)('orthodromicPath')
585
+ .checkArgument('this')
586
+ .shouldBeDegree(this)
587
+ .checkArgument('point')
588
+ .shouldBeDegree(point);
589
+ var t = this.clone().degreeToRadians();
590
+ var p = point.clone().degreeToRadians();
591
+ var d = Math.sin(p.x - t.x);
592
+ var step = (p.x - t.x) / (pointsCount - 1);
593
+ return new DPolygon_1.DPolygon((0, utils_1.createArray)(pointsCount)
594
+ .map(function (v, i) {
595
+ var x = t.x + step * i;
596
+ var y = Math.atan((Math.tan(t.y) * Math.sin(p.x - x)) / d +
597
+ (Math.tan(p.y) * Math.sin(x - t.x)) / d);
598
+ return new DPoint(x, y).radiansToDegrees();
599
+ }));
600
+ };
601
+ DPoint.prototype.sortByDistance = function (p) {
602
+ var _this = this;
603
+ return p
604
+ .clone()
605
+ .map(function (d, index) {
606
+ d.properties.distance = d.distance(_this);
607
+ d.properties.index = index;
608
+ return d;
609
+ })
610
+ .sort(function (a, b) { return a.properties.distance - b.properties.distance; });
611
+ };
612
+ return DPoint;
613
+ }());
614
+ exports.DPoint = DPoint;
File without changes