dgeoutils 2.4.1 → 2.4.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 (34) hide show
  1. package/dist/{cjs/DCircle.d.ts → DCircle.d.ts} +0 -0
  2. package/dist/{cjs/DCircle.js → DCircle.js} +0 -0
  3. package/dist/{cjs/DLine.d.ts → DLine.d.ts} +0 -0
  4. package/dist/{cjs/DLine.js → DLine.js} +0 -0
  5. package/dist/{cjs/DNumbers.d.ts → DNumbers.d.ts} +0 -0
  6. package/dist/{cjs/DNumbers.js → DNumbers.js} +0 -0
  7. package/dist/{cjs/DPlane.d.ts → DPlane.d.ts} +0 -0
  8. package/dist/{cjs/DPlane.js → DPlane.js} +0 -0
  9. package/dist/{cjs/DPoint.d.ts → DPoint.d.ts} +0 -0
  10. package/dist/{cjs/DPoint.js → DPoint.js} +0 -0
  11. package/dist/{cjs/DPolygon.d.ts → DPolygon.d.ts} +0 -0
  12. package/dist/{cjs/DPolygon.js → DPolygon.js} +0 -0
  13. package/dist/{cjs/DPolygonLoop.d.ts → DPolygonLoop.d.ts} +0 -0
  14. package/dist/{cjs/DPolygonLoop.js → DPolygonLoop.js} +0 -0
  15. package/dist/{cjs/FastSearch.d.ts → FastSearch.d.ts} +0 -0
  16. package/dist/{cjs/FastSearch.js → FastSearch.js} +0 -0
  17. package/dist/{cjs/TraceMatrix.d.ts → TraceMatrix.d.ts} +0 -0
  18. package/dist/{cjs/TraceMatrix.js → TraceMatrix.js} +0 -0
  19. package/dist/{cjs/index.d.ts → index.d.ts} +0 -0
  20. package/dist/{cjs/index.js → index.js} +0 -0
  21. package/dist/{cjs/utils.d.ts → utils.d.ts} +0 -0
  22. package/dist/{cjs/utils.js → utils.js} +0 -0
  23. package/package.json +5 -6
  24. package/dist/es2015/DCircle.js +0 -87
  25. package/dist/es2015/DLine.js +0 -257
  26. package/dist/es2015/DNumbers.js +0 -22
  27. package/dist/es2015/DPlane.js +0 -105
  28. package/dist/es2015/DPoint.js +0 -472
  29. package/dist/es2015/DPolygon.js +0 -1040
  30. package/dist/es2015/DPolygonLoop.js +0 -392
  31. package/dist/es2015/FastSearch.js +0 -25
  32. package/dist/es2015/TraceMatrix.js +0 -200
  33. package/dist/es2015/index.js +0 -10
  34. package/dist/es2015/utils.js +0 -162
@@ -1,162 +0,0 @@
1
- import { DPoint } from './DPoint';
2
- export const DGeo = {
3
- DEBUG: false
4
- };
5
- export const warn = (...args) => {
6
- if (DGeo.DEBUG) {
7
- console.warn(...args);
8
- }
9
- };
10
- export const isDefAndNotNull = (a) => a != undefined;
11
- const hook = (scope) => () => scope;
12
- const shouldBeInt = (scope, funcName, argName) => (p) => {
13
- if (!p.clone().round()
14
- .equal(p)) {
15
- warn(`"${funcName}" -> "${argName}" should be Int!`);
16
- }
17
- return scope;
18
- };
19
- const shouldBeUInt = (scope, funcName, argName) => (p) => {
20
- if (!p.clone().round()
21
- .equal(p) || !p.gtOrEqual(DPoint.zero())) {
22
- warn(`"${funcName}" -> "${argName}" should be UInt!`);
23
- }
24
- return scope;
25
- };
26
- const shouldBeDegree = (scope, funcName, argName) => (p) => {
27
- if (!p.likeWorldGeodeticSystem) {
28
- warn(`"${funcName}" -> "${argName}" should be degree!`);
29
- }
30
- return scope;
31
- };
32
- const shouldBeRadians = (scope, funcName, argName) => (p) => {
33
- if (!p.likeRadians) {
34
- warn(`"${funcName}" -> "${argName}" should be radians!`);
35
- }
36
- return scope;
37
- };
38
- const shouldExist = (scope, funcName, argName) => (p) => {
39
- if (!isDefAndNotNull(p)) {
40
- warn(`"${funcName}" -> "${argName}" should exist!`);
41
- }
42
- return scope;
43
- };
44
- const shouldBeMeters = (scope, funcName, argName) => (p) => {
45
- if (!p.likePseudoMercator) {
46
- warn(`"${funcName}" -> "${argName}" should be meters!`);
47
- }
48
- return scope;
49
- };
50
- export const checkFunction = (funcName) => ({
51
- checkArgument: function (argName) {
52
- if (!DGeo.DEBUG) {
53
- return {
54
- shouldBeDegree: hook(this),
55
- shouldBeMeters: hook(this),
56
- shouldBeInt: hook(this),
57
- shouldBeUInt: hook(this),
58
- shouldBeRadians: hook(this),
59
- shouldExist: hook(this)
60
- };
61
- }
62
- return {
63
- shouldBeDegree: shouldBeDegree(this, funcName, argName),
64
- shouldBeMeters: shouldBeMeters(this, funcName, argName),
65
- shouldBeInt: shouldBeInt(this, funcName, argName),
66
- shouldBeUInt: shouldBeUInt(this, funcName, argName),
67
- shouldBeRadians: shouldBeRadians(this, funcName, argName),
68
- shouldExist: shouldExist(this, funcName, argName)
69
- };
70
- }
71
- });
72
- export const createArray = (v, fillSymbol = 0) => new Array(v).fill(fillSymbol);
73
- export const createMatrix = ({ h, w }, fillSymbol = 0) => createArray(h)
74
- .map(() => createArray(w, fillSymbol));
75
- export const gaussianElimination = (matrix) => {
76
- const n = matrix.length;
77
- const matrixClone = createMatrix(new DPoint(n + 1, n));
78
- for (let i = 0; i < n; i++) {
79
- for (let j = 0; j < n + 1; j++) {
80
- matrix[i][j] = matrix[i][j] === 0 ? gaussianElimination.MIN : matrix[i][j];
81
- matrixClone[i][j] = matrix[i][j];
82
- }
83
- }
84
- for (let k = 0; k < n; k++) {
85
- for (let i = 0; i < n + 1; i++) {
86
- matrixClone[k][i] /= matrix[k][k];
87
- }
88
- for (let i = k + 1; i < n; i++) {
89
- const K = matrixClone[i][k] / matrixClone[k][k];
90
- for (let j = 0; j < n + 1; j++) {
91
- matrixClone[i][j] -= matrixClone[k][j] * K;
92
- }
93
- }
94
- for (let i = 0; i < n; i++) {
95
- for (let j = 0; j < n + 1; j++) {
96
- matrix[i][j] = matrixClone[i][j];
97
- }
98
- }
99
- }
100
- for (let k = n - 1; k > -1; k--) {
101
- for (let i = n; i > -1; i--) {
102
- matrixClone[k][i] /= matrix[k][k];
103
- }
104
- for (let i = k - 1; i > -1; i--) {
105
- const K = matrixClone[i][k] / matrixClone[k][k];
106
- for (let j = n; j > -1; j--) {
107
- matrixClone[i][j] -= matrixClone[k][j] * K;
108
- }
109
- }
110
- }
111
- const answer = createArray(n);
112
- for (let i = 0; i < n; i++) {
113
- answer[i] = matrixClone[i][n];
114
- }
115
- return answer;
116
- };
117
- gaussianElimination.MIN = 1e-10;
118
- export const createCanvas = (a, b, c) => {
119
- var _a;
120
- let w = 0;
121
- let h = 0;
122
- let offscreen = false;
123
- if (a instanceof DPoint) {
124
- const { x, y } = a;
125
- w = x;
126
- h = y;
127
- }
128
- else {
129
- w = a;
130
- h = a;
131
- }
132
- if (typeof b === 'boolean') {
133
- offscreen = b;
134
- }
135
- else if (typeof b === 'number') {
136
- h = b;
137
- }
138
- if (typeof c === 'boolean') {
139
- offscreen = c;
140
- }
141
- const canvas = offscreen ? new OffscreenCanvas(w, h) : ((_a = createCanvas.document) !== null && _a !== void 0 ? _a : document).createElement('canvas');
142
- if (!offscreen) {
143
- canvas.width = w;
144
- canvas.height = h;
145
- }
146
- return [canvas, canvas.getContext('2d')];
147
- };
148
- const f = (a, b) => [].concat(...a.map((c) => b.map((d) => [].concat(c, d))));
149
- export const cartesianProduct = (a, b, ...c) => b ? cartesianProduct(f(a, b), ...c) : a;
150
- export const getCombinations = (arr) => {
151
- if (arr.length === 1) {
152
- return arr[0];
153
- }
154
- const ans = [];
155
- const otherCases = getCombinations(arr.slice(1));
156
- for (let i = 0; i < otherCases.length; i++) {
157
- for (let j = 0; j < arr[0].length; j++) {
158
- ans.push([arr[0][j], ...otherCases[i]]);
159
- }
160
- }
161
- return ans;
162
- };