dgeoutils 2.2.14 → 2.2.15

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.
package/dist/DPoint.d.ts CHANGED
@@ -37,6 +37,7 @@ export declare class DPoint {
37
37
  height(z: number): DPoint;
38
38
  toWKT(): string;
39
39
  distance(p: DPoint): number;
40
+ distance3d(p: DPoint): number;
40
41
  setX(x: number): DPoint;
41
42
  setX(f: SetterFunction): DPoint;
42
43
  setZ(z: number): DPoint;
package/dist/DPoint.js CHANGED
@@ -128,6 +128,21 @@ class DPoint {
128
128
  const dy = p.y - this.y;
129
129
  return Math.sqrt(dx * dx + dy * dy);
130
130
  }
131
+ distance3d(p) {
132
+ (0, utils_1.checkFunction)('distance3d')
133
+ .checkArgument('this')
134
+ .shouldBeMeters(this)
135
+ .checkArgument('p')
136
+ .shouldBeMeters(p)
137
+ .checkArgument('this.z')
138
+ .shouldExist(this.z)
139
+ .checkArgument('p.z')
140
+ .shouldExist(p.z);
141
+ const dx = p.x - this.x;
142
+ const dy = p.y - this.y;
143
+ const dz = p.z - this.z;
144
+ return Math.sqrt(dx * dx + dy * dy + dz * dz);
145
+ }
131
146
  setX(x) {
132
147
  this.x = typeof x === 'number' ? x : x(this);
133
148
  return this;
package/dist/utils.d.ts CHANGED
@@ -1,13 +1,16 @@
1
1
  /// <reference types="offscreencanvas" />
2
2
  import { DPoint } from './DPoint';
3
3
  export declare const warn: (...args: any[]) => void;
4
+ export declare const isDefAndNotNull: (a: any) => boolean;
4
5
  declare type CheckFunc = (p: DPoint) => CheckFunction;
6
+ declare type CheckFunc2 = (p: any) => CheckFunction;
5
7
  interface CheckArgument {
6
8
  shouldBeDegree: CheckFunc;
7
9
  shouldBeMeters: CheckFunc;
8
10
  shouldBeInt: CheckFunc;
9
11
  shouldBeUInt: CheckFunc;
10
12
  shouldBeRadians: CheckFunc;
13
+ shouldExist: CheckFunc2;
11
14
  }
12
15
  interface CheckFunction {
13
16
  checkArgument: (argName: string) => CheckArgument;
@@ -19,7 +22,6 @@ export declare const gaussianElimination: {
19
22
  (matrix: number[][]): number[];
20
23
  MIN: number;
21
24
  };
22
- export declare const isDefAndNotNull: (a: any) => boolean;
23
25
  declare type True = true;
24
26
  export declare const createCanvas: {
25
27
  (size: number): [HTMLCanvasElement, CanvasRenderingContext2D];
package/dist/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createCanvas = exports.isDefAndNotNull = exports.gaussianElimination = exports.createMatrix = exports.createArray = exports.checkFunction = exports.warn = void 0;
3
+ exports.createCanvas = exports.gaussianElimination = exports.createMatrix = exports.createArray = exports.checkFunction = exports.isDefAndNotNull = exports.warn = void 0;
4
4
  const index_1 = require("./index");
5
5
  const DPoint_1 = require("./DPoint");
6
6
  const warn = (...args) => {
@@ -9,6 +9,8 @@ const warn = (...args) => {
9
9
  }
10
10
  };
11
11
  exports.warn = warn;
12
+ const isDefAndNotNull = (a) => a != undefined;
13
+ exports.isDefAndNotNull = isDefAndNotNull;
12
14
  const hook = (scope) => () => scope;
13
15
  const shouldBeInt = (scope, funcName, argName) => (p) => {
14
16
  if (!p.clone().round()
@@ -36,6 +38,12 @@ const shouldBeRadians = (scope, funcName, argName) => (p) => {
36
38
  }
37
39
  return scope;
38
40
  };
41
+ const shouldExist = (scope, funcName, argName) => (p) => {
42
+ if (!(0, exports.isDefAndNotNull)(p)) {
43
+ (0, exports.warn)(`"${funcName}" -> "${argName}" should exist!`);
44
+ }
45
+ return scope;
46
+ };
39
47
  const shouldBeMeters = (scope, funcName, argName) => (p) => {
40
48
  if (!p.likePseudoMercator) {
41
49
  (0, exports.warn)(`"${funcName}" -> "${argName}" should be meters!`);
@@ -50,7 +58,8 @@ const checkFunction = (funcName) => ({
50
58
  shouldBeMeters: hook(this),
51
59
  shouldBeInt: hook(this),
52
60
  shouldBeUInt: hook(this),
53
- shouldBeRadians: hook(this)
61
+ shouldBeRadians: hook(this),
62
+ shouldExist: hook(this)
54
63
  };
55
64
  }
56
65
  return {
@@ -58,7 +67,8 @@ const checkFunction = (funcName) => ({
58
67
  shouldBeMeters: shouldBeMeters(this, funcName, argName),
59
68
  shouldBeInt: shouldBeInt(this, funcName, argName),
60
69
  shouldBeUInt: shouldBeUInt(this, funcName, argName),
61
- shouldBeRadians: shouldBeRadians(this, funcName, argName)
70
+ shouldBeRadians: shouldBeRadians(this, funcName, argName),
71
+ shouldExist: shouldExist(this, funcName, argName)
62
72
  };
63
73
  }
64
74
  });
@@ -112,8 +122,6 @@ const gaussianElimination = (matrix) => {
112
122
  };
113
123
  exports.gaussianElimination = gaussianElimination;
114
124
  exports.gaussianElimination.MIN = 1e-10;
115
- const isDefAndNotNull = (a) => a != undefined;
116
- exports.isDefAndNotNull = isDefAndNotNull;
117
125
  const createCanvas = (a, b, c) => {
118
126
  var _a;
119
127
  let w = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dgeoutils",
3
- "version": "2.2.14",
3
+ "version": "2.2.15",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build": "node_modules/.bin/tsc",