dgeoutils 2.4.41 → 2.4.44

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 (52) hide show
  1. package/package.json +1 -4
  2. package/dist/cjs/DCircle.d.ts +0 -18
  3. package/dist/cjs/DCircle.js +0 -102
  4. package/dist/cjs/DLine.d.ts +0 -39
  5. package/dist/cjs/DLine.js +0 -343
  6. package/dist/cjs/DNumbers.d.ts +0 -8
  7. package/dist/cjs/DNumbers.js +0 -30
  8. package/dist/cjs/DPlane.d.ts +0 -25
  9. package/dist/cjs/DPlane.js +0 -132
  10. package/dist/cjs/DPoint.d.ts +0 -138
  11. package/dist/cjs/DPoint.js +0 -803
  12. package/dist/cjs/DPolygon.d.ts +0 -137
  13. package/dist/cjs/DPolygon.js +0 -1745
  14. package/dist/cjs/DPolygonLoop.d.ts +0 -60
  15. package/dist/cjs/DPolygonLoop.js +0 -439
  16. package/dist/cjs/FastSearch.d.ts +0 -6
  17. package/dist/cjs/FastSearch.js +0 -53
  18. package/dist/cjs/InterpolationMatrix.d.ts +0 -24
  19. package/dist/cjs/InterpolationMatrix.js +0 -173
  20. package/dist/cjs/TraceMatrix.d.ts +0 -22
  21. package/dist/cjs/TraceMatrix.js +0 -285
  22. package/dist/cjs/index.d.ts +0 -11
  23. package/dist/cjs/index.js +0 -37
  24. package/dist/cjs/utils.d.ts +0 -49
  25. package/dist/cjs/utils.js +0 -280
  26. package/dist/es2015/DCircle.js +0 -87
  27. package/dist/es2015/DLine.js +0 -290
  28. package/dist/es2015/DNumbers.js +0 -22
  29. package/dist/es2015/DPlane.js +0 -105
  30. package/dist/es2015/DPoint.js +0 -676
  31. package/dist/es2015/DPolygon.js +0 -1193
  32. package/dist/es2015/DPolygonLoop.js +0 -430
  33. package/dist/es2015/FastSearch.js +0 -25
  34. package/dist/es2015/InterpolationMatrix.js +0 -128
  35. package/dist/es2015/TraceMatrix.js +0 -229
  36. package/dist/es2015/index.js +0 -11
  37. package/dist/es2015/utils.js +0 -207
  38. package/dist/esm/DCircle.js +0 -99
  39. package/dist/esm/DLine.js +0 -340
  40. package/dist/esm/DNumbers.js +0 -27
  41. package/dist/esm/DPlane.js +0 -129
  42. package/dist/esm/DPoint.js +0 -800
  43. package/dist/esm/DPolygon.js +0 -1742
  44. package/dist/esm/DPolygonLoop.js +0 -436
  45. package/dist/esm/FastSearch.js +0 -50
  46. package/dist/esm/InterpolationMatrix.js +0 -170
  47. package/dist/esm/TraceMatrix.js +0 -282
  48. package/dist/esm/index.js +0 -11
  49. package/dist/esm/utils.js +0 -265
  50. package/dist/umd/dgeoutils.js +0 -4347
  51. package/dist/umd/dgeoutils.min.js +0 -1
  52. package/dist/umd/dgeoutils.min.js.map +0 -1
@@ -1,676 +0,0 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import { DLine } from './DLine';
13
- import { DPolygon } from './DPolygon';
14
- import { checkFunction, createArray, DGeo, div, isDefAndNotNull, toDegreesMinutesSeconds } from './utils';
15
- const diff = 0;
16
- const radiansPolygon = new DPolygon();
17
- const pseudoMercatorPolygon = new DPolygon();
18
- const worldGeodeticPolygon = new DPolygon();
19
- export const EARTH_RADIUS_IN_METERS = 6378137;
20
- const EARTH_IN_METERS = 20037508.34;
21
- const DEGREES_IN_EARTH = 180;
22
- const METERS_IN_ONE_DEGREE = EARTH_IN_METERS / DEGREES_IN_EARTH;
23
- const DEGREES_IN_ONE_METER = DEGREES_IN_EARTH / EARTH_IN_METERS;
24
- export const HALF_PI_IN_DEGREE = 90;
25
- export const PI_IN_DEGREE = 180;
26
- export const DOUBLE_PI_IN_DEGREE = 360;
27
- export const PI_TO_DEGREE = Math.PI / PI_IN_DEGREE;
28
- export const DEGREE_TO_PI = PI_IN_DEGREE / Math.PI;
29
- export class DPoint {
30
- constructor(x = 0, y = x, z) {
31
- this.x = x;
32
- this.y = y;
33
- this.z = z;
34
- this.properties = {};
35
- }
36
- static zero() {
37
- return new DPoint();
38
- }
39
- static parse(c, format = DGeo.parseFormat) {
40
- const { lat, lon, lng = lon, alt } = c;
41
- if (lat && lng) {
42
- return new DPoint(lng, lat, alt !== null && alt !== void 0 ? alt : 0);
43
- }
44
- const _a = c, { x, y, z } = _a, properties = __rest(_a, ["x", "y", "z"]);
45
- if (isDefAndNotNull(x) && isDefAndNotNull(y)) {
46
- return new DPoint(x, y, z).setProperties(properties);
47
- }
48
- let t = c;
49
- if (c.type === 'Point') {
50
- t = c.coordinates;
51
- }
52
- if (c.type === 'Feature') {
53
- const f = DPoint.parse(c.geometry, format);
54
- f.properties = Object.assign({}, c.properties);
55
- return f;
56
- }
57
- return format.replace(/[^x-z]/gmiu, '')
58
- .split('')
59
- .reduce((a, k, index) => {
60
- var _a, _b;
61
- switch (k) {
62
- case 'x':
63
- a.x = (_a = t[index]) !== null && _a !== void 0 ? _a : 0;
64
- break;
65
- case 'y':
66
- a.y = (_b = t[index]) !== null && _b !== void 0 ? _b : 0;
67
- break;
68
- case 'z':
69
- a.z = t[index];
70
- break;
71
- default:
72
- }
73
- return a;
74
- }, new DPoint());
75
- }
76
- static parseFromWKT(wkt) {
77
- const regexp = /POINT \((?<data>(?:(?!\)).)*?)\)$/miu;
78
- const data = wkt.trim().toUpperCase();
79
- const res = regexp.exec(data);
80
- const [x, y, z] = res.groups.data.split(' ').map(Number);
81
- return new DPoint(x, y, z);
82
- }
83
- static random() {
84
- return new DPoint(Math.random(), Math.random());
85
- }
86
- static getTileFromQuadKey(quadKey) {
87
- const p = new DPoint(0, 0, quadKey.length);
88
- for (let i = p.z; i > 0; i--) {
89
- const mask = 1 << (i - 1);
90
- switch (quadKey[p.z - i]) {
91
- case '0':
92
- break;
93
- case '1':
94
- p.x |= mask;
95
- break;
96
- case '2':
97
- p.y |= mask;
98
- break;
99
- case '3':
100
- p.x |= mask;
101
- p.y |= mask;
102
- break;
103
- default:
104
- throw new Error('Invalid QuadKey digit sequence.');
105
- }
106
- }
107
- return p;
108
- }
109
- toDegreesMinutesSeconds() {
110
- return {
111
- x: toDegreesMinutesSeconds(this.x),
112
- y: toDegreesMinutesSeconds(this.y)
113
- };
114
- }
115
- getTileFromCoords(zoom = this.z) {
116
- checkFunction('getTileFromCoords')
117
- .checkArgument('this')
118
- .shouldBeDegree(this);
119
- const x = Math.floor((this.x + PI_IN_DEGREE) / DOUBLE_PI_IN_DEGREE * (Math.pow(2, zoom)));
120
- 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)));
121
- return new DPoint(x, y, zoom);
122
- }
123
- getQuadKeyFromTile(zoom = this.z) {
124
- const quadKey = [];
125
- for (let i = zoom; i > 0; i--) {
126
- let digit = 0;
127
- const mask = 1 << (i - 1);
128
- if ((this.x & mask) !== 0) {
129
- digit++;
130
- }
131
- if ((this.y & mask) !== 0) {
132
- digit++;
133
- digit++;
134
- }
135
- quadKey.push(digit);
136
- }
137
- return quadKey.join('');
138
- }
139
- getCoordsFromTile(zoom = this.z) {
140
- checkFunction('getCoordsFromTile')
141
- .checkArgument('this')
142
- .shouldBeUInt(this);
143
- const n = Math.PI - 2 * Math.PI * this.y / (Math.pow(2, zoom));
144
- const x = this.x / (Math.pow(2, zoom)) * DOUBLE_PI_IN_DEGREE - PI_IN_DEGREE;
145
- const y = PI_IN_DEGREE / Math.PI * Math.atan((Math.exp(n) - Math.exp(-n)) / 2);
146
- return new DPoint(x, y, zoom);
147
- }
148
- toCoords(format = DGeo.parseFormat) {
149
- return format.replace(/[^x-z]/gmiu, '').split('')
150
- .map((k) => ({
151
- x: this.x,
152
- y: this.y,
153
- z: this.z
154
- })[k])
155
- .filter((r) => r !== undefined);
156
- }
157
- toGeoJSON(format = DGeo.parseFormat) {
158
- return {
159
- type: 'Point',
160
- coordinates: this.toCoords(format)
161
- };
162
- }
163
- toGeoJSONFeature(format = DGeo.parseFormat) {
164
- return {
165
- type: 'Feature',
166
- properties: Object.assign({}, this.properties),
167
- geometry: this.toGeoJSON(format)
168
- };
169
- }
170
- findLine(p) {
171
- checkFunction('findLine')
172
- .checkArgument('this')
173
- .shouldBeMeters(this)
174
- .checkArgument('p')
175
- .shouldBeMeters(p);
176
- if (this.equal(p)) {
177
- return this.findLine(p.clone().move(0, 1));
178
- }
179
- const a = this.y - p.y - diff;
180
- const b = p.x - this.x - diff;
181
- const c = this.x * p.y - p.x * this.y - diff;
182
- if (a === 0) {
183
- return new DLine(0, 1, c / b, this, p);
184
- }
185
- if (b === 0) {
186
- return new DLine(1, 0, c / a, this, p);
187
- }
188
- return new DLine(a, b, c, this, p);
189
- }
190
- findInnerAngle(p1, p3) {
191
- checkFunction('findInnerAngle')
192
- .checkArgument('this')
193
- .shouldBeMeters(this)
194
- .checkArgument('p1')
195
- .shouldBeMeters(p1)
196
- .checkArgument('p3')
197
- .shouldBeMeters(p3);
198
- const a1 = this.findLine(p1).getFi();
199
- const a2 = this.findLine(p3).getFi();
200
- if (a2 >= a1) {
201
- return a2 - a1;
202
- }
203
- return a2 + Math.PI * 2 - a1;
204
- }
205
- toString() {
206
- return `${this.x} ${this.y}`;
207
- }
208
- getValue() {
209
- return [this.x, this.y];
210
- }
211
- height(z) {
212
- this.z = z;
213
- return this;
214
- }
215
- toWKT() {
216
- const { x, y } = this;
217
- return `POINT (${x} ${y})`;
218
- }
219
- distance(p) {
220
- checkFunction('distance')
221
- .checkArgument('this')
222
- .shouldBeMeters(this)
223
- .checkArgument('p')
224
- .shouldBeMeters(p);
225
- const dx = p.x - this.x;
226
- const dy = p.y - this.y;
227
- return Math.sqrt(dx * dx + dy * dy);
228
- }
229
- distance3d(p) {
230
- checkFunction('distance3d')
231
- .checkArgument('this')
232
- .shouldBeMeters(this)
233
- .checkArgument('p')
234
- .shouldBeMeters(p)
235
- .checkArgument('this.z')
236
- .shouldExist(this.z)
237
- .checkArgument('p.z')
238
- .shouldExist(p.z);
239
- const dx = p.x - this.x;
240
- const dy = p.y - this.y;
241
- const dz = p.z - this.z;
242
- return Math.sqrt(dx * dx + dy * dy + dz * dz);
243
- }
244
- setX(x) {
245
- this.x = typeof x === 'number' ? x : x(this);
246
- return this;
247
- }
248
- setZ(z) {
249
- this.z = typeof z === 'number' ? z : z(this);
250
- return this;
251
- }
252
- setY(y) {
253
- this.y = typeof y === 'number' ? y : y(this);
254
- return this;
255
- }
256
- setProperties(v) {
257
- this.properties = typeof v === 'object' ? v : v(this);
258
- return this;
259
- }
260
- clone() {
261
- const p = new DPoint(this.x, this.y, this.z);
262
- p.properties = Object.assign({}, this.properties);
263
- return p;
264
- }
265
- gt(p) {
266
- return this.x > p.x && this.y > p.y;
267
- }
268
- lt(p) {
269
- return this.x < p.x && this.y < p.y;
270
- }
271
- gtOrEqual(p) {
272
- return this.gt(p) || this.equal(p);
273
- }
274
- ltOrEqual(p) {
275
- return this.lt(p) || this.equal(p);
276
- }
277
- rotate(a) {
278
- const x = this.x * Math.cos(a) - this.y * Math.sin(a);
279
- const y = this.x * Math.sin(a) + this.y * Math.cos(a);
280
- this.x = x;
281
- this.y = y;
282
- return this;
283
- }
284
- rotate3dX(a) {
285
- const { y, z } = this;
286
- this.y = y * Math.cos(a) + z * Math.sin(a);
287
- this.z = -y * Math.sin(a) + z * Math.cos(a);
288
- return this;
289
- }
290
- rotate3dY(a) {
291
- const { x, z } = this;
292
- this.x = x * Math.cos(a) + z * Math.sin(a);
293
- this.z = -x * Math.sin(a) + z * Math.cos(a);
294
- return this;
295
- }
296
- rotate3dZ(a) {
297
- const { x, y } = this;
298
- this.x = x * Math.cos(a) - y * Math.sin(a);
299
- this.y = -x * Math.sin(a) + y * Math.cos(a);
300
- return this;
301
- }
302
- move(x, y = x, z) {
303
- let xV = 0;
304
- let yV = 0;
305
- let zV = undefined;
306
- if (x instanceof DPoint) {
307
- xV = this.x + x.x;
308
- yV = this.y + x.y;
309
- if (isDefAndNotNull(this.z) && isDefAndNotNull(x.z)) {
310
- zV = this.z + x.z;
311
- }
312
- }
313
- else {
314
- xV = this.x + x;
315
- yV = this.y + y;
316
- if (isDefAndNotNull(this.z) && isDefAndNotNull(z)) {
317
- zV = this.z + z;
318
- }
319
- }
320
- this.x = xV;
321
- this.y = yV;
322
- if (isDefAndNotNull(zV)) {
323
- this.z = zV;
324
- }
325
- return this;
326
- }
327
- degreeToMeters() {
328
- checkFunction('degreeToMeters')
329
- .checkArgument('this')
330
- .shouldBeDegree(this);
331
- const x = ((this.x + PI_IN_DEGREE) % DOUBLE_PI_IN_DEGREE - PI_IN_DEGREE) * METERS_IN_ONE_DEGREE;
332
- const y = (Math.log(Math.tan(((this.y + HALF_PI_IN_DEGREE) % PI_IN_DEGREE) *
333
- (Math.PI / DOUBLE_PI_IN_DEGREE))) / PI_TO_DEGREE) * METERS_IN_ONE_DEGREE;
334
- this.x = x;
335
- this.y = y;
336
- return this;
337
- }
338
- metersToDegree() {
339
- checkFunction('metersToDegree')
340
- .checkArgument('this')
341
- .shouldBeMeters(this);
342
- const lon = this.x * DEGREES_IN_ONE_METER;
343
- const lat = Math.atan(Math.pow(Math.E, ((this.y / METERS_IN_ONE_DEGREE) * PI_TO_DEGREE))) *
344
- (DOUBLE_PI_IN_DEGREE / Math.PI) - HALF_PI_IN_DEGREE;
345
- this.x = lon;
346
- this.y = lat;
347
- return this;
348
- }
349
- degreeToRadians() {
350
- checkFunction('degreeToRadians')
351
- .checkArgument('this')
352
- .shouldBeDegree(this);
353
- return this.scale(PI_TO_DEGREE);
354
- }
355
- radiansToDegrees() {
356
- checkFunction('radiansToDegrees')
357
- .checkArgument('this')
358
- .shouldBeRadians(this);
359
- return this.scale(DEGREE_TO_PI);
360
- }
361
- radiansToMeters() {
362
- checkFunction('radiansToMeters')
363
- .checkArgument('this')
364
- .shouldBeRadians(this);
365
- return this.radiansToDegrees().degreeToMeters();
366
- }
367
- metersToRadians() {
368
- checkFunction('metersToRadians')
369
- .checkArgument('this')
370
- .shouldBeMeters(this);
371
- return this.metersToDegree().degreeToRadians();
372
- }
373
- round() {
374
- this.x = Math.round(this.x);
375
- this.y = Math.round(this.y);
376
- return this;
377
- }
378
- ceil() {
379
- this.x = Math.ceil(this.x);
380
- this.y = Math.ceil(this.y);
381
- return this;
382
- }
383
- floor() {
384
- this.x = Math.floor(this.x);
385
- this.y = Math.floor(this.y);
386
- return this;
387
- }
388
- toFixed(n = 2) {
389
- this.x = parseFloat(this.x.toFixed(n));
390
- this.y = parseFloat(this.y.toFixed(n));
391
- return this;
392
- }
393
- abs() {
394
- this.x = Math.abs(this.x);
395
- this.y = Math.abs(this.y);
396
- return this;
397
- }
398
- scale(x, y = x, z) {
399
- let xV = 0;
400
- let yV = 0;
401
- let zV = undefined;
402
- if (x instanceof DPoint) {
403
- xV = this.x * x.x;
404
- yV = this.y * x.y;
405
- if (isDefAndNotNull(this.z) && isDefAndNotNull(x.z)) {
406
- zV = this.z * x.z;
407
- }
408
- }
409
- else {
410
- xV = this.x * x;
411
- yV = this.y * y;
412
- if (isDefAndNotNull(this.z) && isDefAndNotNull(z)) {
413
- zV = this.z * z;
414
- }
415
- }
416
- this.x = xV;
417
- this.y = yV;
418
- if (isDefAndNotNull(zV)) {
419
- this.z = zV;
420
- }
421
- return this;
422
- }
423
- divide(x, y = x, z) {
424
- let xV = 0;
425
- let yV = 0;
426
- let zV = undefined;
427
- if (x instanceof DPoint) {
428
- xV = this.x / x.x;
429
- yV = this.y / x.y;
430
- if (isDefAndNotNull(this.z) && isDefAndNotNull(x.z)) {
431
- zV = this.z / x.z;
432
- }
433
- }
434
- else {
435
- xV = this.x / x;
436
- yV = this.y / y;
437
- if (isDefAndNotNull(this.z) && isDefAndNotNull(z)) {
438
- zV = this.z / z;
439
- }
440
- }
441
- this.x = xV;
442
- this.y = yV;
443
- if (isDefAndNotNull(zV)) {
444
- this.z = zV;
445
- }
446
- return this;
447
- }
448
- mod(x, y = x, z) {
449
- let xV = 0;
450
- let yV = 0;
451
- let zV = undefined;
452
- if (x instanceof DPoint) {
453
- xV = this.x % x.x;
454
- yV = this.y % x.y;
455
- if (isDefAndNotNull(this.z) && isDefAndNotNull(x.z)) {
456
- zV = this.z % x.z;
457
- }
458
- }
459
- else {
460
- xV = this.x % x;
461
- yV = this.y % y;
462
- if (isDefAndNotNull(this.z) && isDefAndNotNull(z)) {
463
- zV = this.z % z;
464
- }
465
- }
466
- this.x = xV;
467
- this.y = yV;
468
- if (isDefAndNotNull(zV)) {
469
- this.z = zV;
470
- }
471
- return this;
472
- }
473
- div(x, y = x, z) {
474
- let xV = 0;
475
- let yV = 0;
476
- let zV = undefined;
477
- if (x instanceof DPoint) {
478
- xV = div(this.x, x.x);
479
- yV = div(this.y, x.y);
480
- if (isDefAndNotNull(this.z) && isDefAndNotNull(x.z)) {
481
- zV = div(this.z, x.z);
482
- }
483
- }
484
- else {
485
- xV = div(this.x, x);
486
- yV = div(this.y, y);
487
- if (isDefAndNotNull(this.z) && isDefAndNotNull(z)) {
488
- zV = div(this.z, z);
489
- }
490
- }
491
- this.x = xV;
492
- this.y = yV;
493
- if (isDefAndNotNull(zV)) {
494
- this.z = zV;
495
- }
496
- return this;
497
- }
498
- equal(p) {
499
- return this.x === p.x && this.y === p.y && this.z === p.z;
500
- }
501
- like(p, d = 0.001) {
502
- var _a, _b, _c, _d;
503
- if (this.equal(p)) {
504
- return true;
505
- }
506
- const likeX = Math.abs(this.x - p.x) < d;
507
- const likeY = Math.abs(this.y - p.y) < d;
508
- const 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;
509
- return likeX && likeY && likeZ;
510
- }
511
- flipVertically(size) {
512
- let v = size;
513
- if (size instanceof DPoint) {
514
- v = size.y;
515
- }
516
- this.y = v - this.y;
517
- return this;
518
- }
519
- get likeRadians() {
520
- if (radiansPolygon.length === 0) {
521
- radiansPolygon.push(new DPoint(-Math.PI, -Math.PI / 2), new DPoint(Math.PI, Math.PI / 2));
522
- }
523
- return radiansPolygon.simpleInclude(this);
524
- }
525
- get likeWorldGeodeticSystem() {
526
- if (worldGeodeticPolygon.length === 0) {
527
- worldGeodeticPolygon.push(new DPoint(-180, -90), new DPoint(180, 90));
528
- }
529
- return !this.likeRadians && worldGeodeticPolygon.simpleInclude(this);
530
- }
531
- get likePseudoMercator() {
532
- if (pseudoMercatorPolygon.length === 0) {
533
- pseudoMercatorPolygon.push(new DPoint(-20026376.39, -20048966.10), new DPoint(20026376.39, 20048966.10));
534
- }
535
- return !this.likeRadians && !this.likeWorldGeodeticSystem && pseudoMercatorPolygon.simpleInclude(this);
536
- }
537
- get w() {
538
- return this.x;
539
- }
540
- set w(x) {
541
- this.x = x;
542
- }
543
- get h() {
544
- return this.y;
545
- }
546
- set h(y) {
547
- this.y = y;
548
- }
549
- get area() {
550
- checkFunction('area')
551
- .checkArgument('this')
552
- .shouldBeMeters(this);
553
- return this.w * this.h;
554
- }
555
- get hip() {
556
- checkFunction('hip')
557
- .checkArgument('this')
558
- .shouldBeMeters(this);
559
- return Math.sqrt(this.w * this.w + this.h * this.h);
560
- }
561
- get min() {
562
- return Math.min(this.x, this.y);
563
- }
564
- get max() {
565
- return Math.max(this.x, this.y);
566
- }
567
- get hipPoint() {
568
- const { hip } = this;
569
- return new DPoint(hip, hip);
570
- }
571
- get xPoint() {
572
- const { x } = this;
573
- return new DPoint(x, x);
574
- }
575
- get yPoint() {
576
- const { y } = this;
577
- return new DPoint(y, y);
578
- }
579
- get wPoint() {
580
- return this.xPoint;
581
- }
582
- get hPoint() {
583
- return this.yPoint;
584
- }
585
- get lat() {
586
- return this.y;
587
- }
588
- set lat(v) {
589
- this.y = v;
590
- }
591
- get lng() {
592
- return this.x;
593
- }
594
- set lng(v) {
595
- this.x = v;
596
- }
597
- get lon() {
598
- return this.x;
599
- }
600
- set lon(v) {
601
- this.x = v;
602
- }
603
- get alt() {
604
- return this.z;
605
- }
606
- set alt(v) {
607
- this.z = v;
608
- }
609
- simple(xKey = 'x', yKey = 'y', zKey = 'z') {
610
- return Object.assign({ [xKey]: this.x, [yKey]: this.y }, (isDefAndNotNull(this.z) ? {
611
- [zKey]: this.z
612
- } : {}));
613
- }
614
- setIfLessThan(p) {
615
- this.x = Math.max(this.x, p.x);
616
- this.y = Math.max(this.y, p.y);
617
- return this;
618
- }
619
- setIfMoreThan(p) {
620
- this.x = Math.min(this.x, p.x);
621
- this.y = Math.min(this.y, p.y);
622
- return this;
623
- }
624
- minus() {
625
- return this.scale(-1);
626
- }
627
- orthodromicPath(point, pointsCount = 360) {
628
- checkFunction('orthodromicPath')
629
- .checkArgument('this')
630
- .shouldBeDegree(this)
631
- .checkArgument('point')
632
- .shouldBeDegree(point);
633
- const t = this.clone().degreeToRadians();
634
- const p = point.clone().degreeToRadians();
635
- const d = Math.sin(p.x - t.x);
636
- const step = (p.x - t.x) / (pointsCount - 1);
637
- return new DPolygon(createArray(pointsCount)
638
- .map((v, i) => {
639
- const x = t.x + step * i;
640
- const y = Math.atan((Math.tan(t.y) * Math.sin(p.x - x)) / d +
641
- (Math.tan(p.y) * Math.sin(x - t.x)) / d);
642
- return new DPoint(x, y).radiansToDegrees();
643
- }));
644
- }
645
- sortByDistance(p) {
646
- return p
647
- .clone()
648
- .map((d, index) => {
649
- d.properties.distance = d.distance(this);
650
- d.properties.index = index;
651
- return d;
652
- })
653
- .sort((a, b) => a.properties.distance - b.properties.distance);
654
- }
655
- calculateAltitudeByDistanceBetweenPoints(p1, p2) {
656
- var _a, _b, _c, _d, _e;
657
- if (p1.alt === p2.alt) {
658
- this.alt = p1.alt;
659
- }
660
- else {
661
- const minAlt = Math.min((_a = p1.alt) !== null && _a !== void 0 ? _a : 0, (_b = p2.alt) !== null && _b !== void 0 ? _b : 0);
662
- const maxAlt = Math.max((_c = p1.alt) !== null && _c !== void 0 ? _c : 0, (_d = p2.alt) !== null && _d !== void 0 ? _d : 0);
663
- const dAlt = maxAlt - minAlt;
664
- const distance1 = this.distance(p1);
665
- const distance2 = this.distance(p2);
666
- const totalDistance = distance1 + distance2;
667
- if (((_e = p1.alt) !== null && _e !== void 0 ? _e : 0) === minAlt) {
668
- this.alt = minAlt + distance1 / totalDistance * dAlt;
669
- }
670
- else {
671
- this.alt = minAlt + distance2 / totalDistance * dAlt;
672
- }
673
- }
674
- return this;
675
- }
676
- }