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,282 +0,0 @@
1
- var __read = (this && this.__read) || function (o, n) {
2
- var m = typeof Symbol === "function" && o[Symbol.iterator];
3
- if (!m) return o;
4
- var i = m.call(o), r, ar = [], e;
5
- try {
6
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
7
- }
8
- catch (error) { e = { error: error }; }
9
- finally {
10
- try {
11
- if (r && !r.done && (m = i["return"])) m.call(i);
12
- }
13
- finally { if (e) throw e.error; }
14
- }
15
- return ar;
16
- };
17
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
18
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
19
- if (ar || !(i in from)) {
20
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
21
- ar[i] = from[i];
22
- }
23
- }
24
- return to.concat(ar || Array.prototype.slice.call(from));
25
- };
26
- var __values = (this && this.__values) || function(o) {
27
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
28
- if (m) return m.call(o);
29
- if (o && typeof o.length === "number") return {
30
- next: function () {
31
- if (o && i >= o.length) o = void 0;
32
- return { value: o && o[i++], done: !o };
33
- }
34
- };
35
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
36
- };
37
- import { DPoint } from './DPoint';
38
- import { DPolygon, MIN_POINTS_IN_VALID_POLYGON } from './DPolygon';
39
- import { FastSearch } from './FastSearch';
40
- import { createArray } from './utils';
41
- export var TraceMatrixValues;
42
- (function (TraceMatrixValues) {
43
- TraceMatrixValues[TraceMatrixValues["f"] = 0] = "f";
44
- TraceMatrixValues[TraceMatrixValues["t"] = 1] = "t";
45
- })(TraceMatrixValues || (TraceMatrixValues = {}));
46
- var getByPosition = function (m, p, defaultValue) {
47
- if (defaultValue === void 0) { defaultValue = TraceMatrixValues.f; }
48
- if (m[p.y] === undefined || m[p.y][p.x] === undefined) {
49
- return defaultValue;
50
- }
51
- return m[p.y][p.x];
52
- };
53
- var setByPosition = function (m, p, value) {
54
- if (m[p.y] === undefined || m[p.y][p.x] === undefined) {
55
- return value;
56
- }
57
- m[p.y][p.x] = value;
58
- return m[p.y][p.x];
59
- };
60
- var TraceMatrix = (function () {
61
- function TraceMatrix(s, f) {
62
- var _this = this;
63
- this.approximation = true;
64
- this.findGroupByIndex = function (m, s) {
65
- var res = new DPolygon();
66
- if (s && getByPosition(m, s) === TraceMatrixValues.t) {
67
- res.push(s);
68
- var startIndex = 0;
69
- var marked = TraceMatrix.createMatrix(_this.size, function () { return TraceMatrixValues.f; });
70
- setByPosition(marked, s, TraceMatrixValues.t);
71
- while (startIndex < res.length) {
72
- var r = res.at(startIndex);
73
- for (var i = -1; i < 2; i++) {
74
- for (var j = -1; j < 2; j++) {
75
- var t = new DPoint(r.x + i, r.y + j);
76
- if (getByPosition(marked, t, TraceMatrixValues.t) === TraceMatrixValues.f &&
77
- getByPosition(m, t, TraceMatrixValues.f) === TraceMatrixValues.t) {
78
- res.push(t);
79
- setByPosition(marked, t, TraceMatrixValues.t);
80
- }
81
- }
82
- }
83
- startIndex++;
84
- }
85
- }
86
- return res;
87
- };
88
- this.findAllGroupsInMatrix = function (m) {
89
- var firstMark = _this.findMarked(m);
90
- if (!firstMark) {
91
- return [];
92
- }
93
- var group = _this.findGroupByIndex(m, firstMark);
94
- var groups = [group];
95
- var groupSum = group.length;
96
- var allGroups = __spreadArray([], __read(group.points), false);
97
- var fs = new FastSearch();
98
- fs.add(allGroups);
99
- while (groupSum < _this.totalCountInMatrix(m)) {
100
- var mark = _this.findMarked(m);
101
- while (mark && fs.find(mark)) {
102
- mark = _this.findMarked(m, mark);
103
- }
104
- var nextGroup = _this.findGroupByIndex(m, mark);
105
- groupSum += nextGroup.length;
106
- allGroups = __spreadArray(__spreadArray([], __read(allGroups), false), __read(nextGroup.points), false);
107
- fs.add(nextGroup.points);
108
- groups.push(nextGroup);
109
- }
110
- return groups.filter(function (g) { return g.length > 2; });
111
- };
112
- this.traceGroup = function (m, group) {
113
- var traceDirections = [
114
- new DPoint(-1, -1),
115
- new DPoint(-1, 0),
116
- new DPoint(-1, 1),
117
- new DPoint(0, 1),
118
- new DPoint(1, 1),
119
- new DPoint(1, 0),
120
- new DPoint(1, -1),
121
- new DPoint(0, -1)
122
- ];
123
- var left = function (d) { return (d + traceDirections.length + 1) % traceDirections.length; };
124
- var right = function (d) { return (d + traceDirections.length - 1) % traceDirections.length; };
125
- if (group.length < 2) {
126
- var t = group.at(0).clone();
127
- return new DPolygon([t, t, t]);
128
- }
129
- var points = new DPolygon();
130
- var direction = 0;
131
- var prevDirection = Infinity;
132
- var p = group.at(0);
133
- while (!p.equal(group.at(0)) || points.length < 2) {
134
- while (true) {
135
- var nextValue = getByPosition(m, p.clone().move(traceDirections[direction]));
136
- var nextNeighbourValue = getByPosition(m, p.clone().move(traceDirections[left(direction)]));
137
- if (nextValue === TraceMatrixValues.t && nextNeighbourValue === TraceMatrixValues.f) {
138
- break;
139
- }
140
- direction = right(direction);
141
- }
142
- if (prevDirection !== direction) {
143
- points.push(p);
144
- prevDirection = direction;
145
- }
146
- p = p.clone().move(traceDirections[direction]);
147
- direction = left(left(direction));
148
- }
149
- if (_this.approximation) {
150
- return points.approximation().close();
151
- }
152
- return points.clone().close();
153
- };
154
- this.createHoleMatrix = function (group) {
155
- var e_1, _a;
156
- var fullTraceDirections = [
157
- new DPoint(-1, 0),
158
- new DPoint(0, 1),
159
- new DPoint(1, 0),
160
- new DPoint(0, -1)
161
- ];
162
- group.prepareToFastSearch();
163
- var tmpMatrix = TraceMatrix
164
- .createMatrix(_this.size, function (p) { return group.fastHas(p) ? TraceMatrixValues.t : TraceMatrixValues.f; });
165
- var startCoords = new DPolygon();
166
- for (var i = 0; i < _this.size.w; i++) {
167
- startCoords.push(new DPoint(i, -1));
168
- startCoords.push(new DPoint(i, _this.size.h));
169
- }
170
- for (var i = 0; i < _this.size.h; i++) {
171
- startCoords.push(new DPoint(-1, i));
172
- startCoords.push(new DPoint(_this.size.w, i));
173
- }
174
- while (startCoords.length) {
175
- var point = startCoords.pop();
176
- try {
177
- for (var fullTraceDirections_1 = (e_1 = void 0, __values(fullTraceDirections)), fullTraceDirections_1_1 = fullTraceDirections_1.next(); !fullTraceDirections_1_1.done; fullTraceDirections_1_1 = fullTraceDirections_1.next()) {
178
- var direction = fullTraceDirections_1_1.value;
179
- var tmpPoint = point.clone().move(direction);
180
- var value = getByPosition(tmpMatrix, tmpPoint, TraceMatrixValues.t);
181
- if (value === TraceMatrixValues.f) {
182
- setByPosition(tmpMatrix, tmpPoint, TraceMatrixValues.t);
183
- startCoords.push(tmpPoint);
184
- }
185
- }
186
- }
187
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
188
- finally {
189
- try {
190
- if (fullTraceDirections_1_1 && !fullTraceDirections_1_1.done && (_a = fullTraceDirections_1.return)) _a.call(fullTraceDirections_1);
191
- }
192
- finally { if (e_1) throw e_1.error; }
193
- }
194
- }
195
- var t = _this.reverseMatrix(tmpMatrix);
196
- return _this.totalCountInMatrix(t) ? t : null;
197
- };
198
- this.size = s.clone().scale(4);
199
- var t = TraceMatrix.createMatrix(this.size, function (p) {
200
- var _a = p.clone().mod(4), x = _a.x, y = _a.y;
201
- if ([1, 2].includes(x) && [1, 2].includes(y)) {
202
- return f(p.clone().div(4));
203
- }
204
- return TraceMatrixValues.f;
205
- });
206
- this.m = TraceMatrix.createMatrix(this.size);
207
- for (var i = 1; i < this.size.y - 1; i++) {
208
- for (var j = 1; j < this.size.x - 1; j++) {
209
- if (t[i][j] === TraceMatrixValues.t) {
210
- this.m[i - 1][j - 1] = TraceMatrixValues.t;
211
- this.m[i - 1][j] = TraceMatrixValues.t;
212
- this.m[i - 1][j + 1] = TraceMatrixValues.t;
213
- this.m[i][j - 1] = TraceMatrixValues.t;
214
- this.m[i][j] = TraceMatrixValues.t;
215
- this.m[i][j + 1] = TraceMatrixValues.t;
216
- this.m[i + 1][j - 1] = TraceMatrixValues.t;
217
- this.m[i + 1][j] = TraceMatrixValues.t;
218
- this.m[i + 1][j + 1] = TraceMatrixValues.t;
219
- }
220
- }
221
- }
222
- }
223
- TraceMatrix.prototype.fullMatrixTrace = function () {
224
- var _this = this;
225
- var groups = this.findAllGroupsInMatrix(this.m);
226
- var paths = groups.map(function (g) { return _this.traceGroup(_this.m, g); });
227
- var holeMatrixs = groups.map(this.createHoleMatrix);
228
- var holesGroups = holeMatrixs.map(function (m) { return m && _this.findAllGroupsInMatrix(m); });
229
- var holesPaths = holesGroups.map(function (hg, index) { return hg && hg.map(function (g) { return _this
230
- .traceGroup(holeMatrixs[index], g); }).filter(function (r) { return r.length > MIN_POINTS_IN_VALID_POLYGON; }); });
231
- return groups.map(function (g, index) {
232
- var res = paths[index];
233
- if (holesGroups[index] && holesGroups[index].length) {
234
- res.holes = holesPaths[index];
235
- }
236
- return res.loop()
237
- .divide(4)
238
- .round()
239
- .run();
240
- });
241
- };
242
- TraceMatrix.prototype.reverseMatrix = function (m) {
243
- return TraceMatrix.createMatrix(this.size, function (p) { return getByPosition(m, p) === TraceMatrixValues.f ? TraceMatrixValues.t : TraceMatrixValues.f; });
244
- };
245
- TraceMatrix.prototype.findMarked = function (m, init) {
246
- var s = this.size;
247
- var ini = false;
248
- for (var i = 0; i < s.w; i++) {
249
- for (var j = 0; j < s.h; j++) {
250
- if (!ini && init) {
251
- i = init.x;
252
- j = init.y;
253
- ini = true;
254
- continue;
255
- }
256
- if (getByPosition(m, new DPoint(i, j)) === TraceMatrixValues.t) {
257
- return new DPoint(i, j);
258
- }
259
- }
260
- }
261
- return null;
262
- };
263
- TraceMatrix.prototype.totalCountInMatrix = function (m) {
264
- var res = 0;
265
- var s = this.size;
266
- for (var i = 0; i < s.w; i++) {
267
- for (var j = 0; j < s.h; j++) {
268
- if (getByPosition(m, new DPoint(i, j))) {
269
- res++;
270
- }
271
- }
272
- }
273
- return res;
274
- };
275
- TraceMatrix.createMatrix = function (size, f) {
276
- if (f === void 0) { f = function () { return TraceMatrixValues.f; }; }
277
- return createArray(size.h)
278
- .map(function (v, i) { return createArray(size.w).map(function (v2, j) { return f(new DPoint(j, i)); }); });
279
- };
280
- return TraceMatrix;
281
- }());
282
- export { TraceMatrix };
package/dist/esm/index.js DELETED
@@ -1,11 +0,0 @@
1
- export * from './DCircle';
2
- export * from './DLine';
3
- export * from './DNumbers';
4
- export * from './DPoint';
5
- export * from './DPolygon';
6
- export * from './FastSearch';
7
- export * from './TraceMatrix';
8
- export * from './InterpolationMatrix';
9
- export * from './DPolygonLoop';
10
- export * from './DPlane';
11
- export { gaussianElimination, createCanvas, createArray, createMatrix, isDefAndNotNull, cartesianProduct, getCombinations, parseDegreesMinutesSeconds, DGeo } from './utils';
package/dist/esm/utils.js DELETED
@@ -1,265 +0,0 @@
1
- var __read = (this && this.__read) || function (o, n) {
2
- var m = typeof Symbol === "function" && o[Symbol.iterator];
3
- if (!m) return o;
4
- var i = m.call(o), r, ar = [], e;
5
- try {
6
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
7
- }
8
- catch (error) { e = { error: error }; }
9
- finally {
10
- try {
11
- if (r && !r.done && (m = i["return"])) m.call(i);
12
- }
13
- finally { if (e) throw e.error; }
14
- }
15
- return ar;
16
- };
17
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
18
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
19
- if (ar || !(i in from)) {
20
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
21
- ar[i] = from[i];
22
- }
23
- }
24
- return to.concat(ar || Array.prototype.slice.call(from));
25
- };
26
- var __values = (this && this.__values) || function(o) {
27
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
28
- if (m) return m.call(o);
29
- if (o && typeof o.length === "number") return {
30
- next: function () {
31
- if (o && i >= o.length) o = void 0;
32
- return { value: o && o[i++], done: !o };
33
- }
34
- };
35
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
36
- };
37
- import { DPoint } from './DPoint';
38
- export var DGeo = {
39
- DEBUG: false,
40
- parseFormat: 'xyz'
41
- };
42
- export var warn = function () {
43
- var args = [];
44
- for (var _i = 0; _i < arguments.length; _i++) {
45
- args[_i] = arguments[_i];
46
- }
47
- if (DGeo.DEBUG) {
48
- console.warn.apply(console, __spreadArray([], __read(args), false));
49
- }
50
- };
51
- export var isDefAndNotNull = function (a) { return a != undefined; };
52
- var hook = function (scope) { return function () { return scope; }; };
53
- var shouldBeInt = function (scope, funcName, argName) { return function (p) {
54
- if (!p.clone().round()
55
- .equal(p)) {
56
- warn("\"".concat(funcName, "\" -> \"").concat(argName, "\" should be Int!"));
57
- }
58
- return scope;
59
- }; };
60
- var shouldBeUInt = function (scope, funcName, argName) { return function (p) {
61
- if (!p.clone().round()
62
- .equal(p) || !p.gtOrEqual(DPoint.zero())) {
63
- warn("\"".concat(funcName, "\" -> \"").concat(argName, "\" should be UInt!"));
64
- }
65
- return scope;
66
- }; };
67
- var shouldBeDegree = function (scope, funcName, argName) { return function (p) {
68
- if (!p.likeWorldGeodeticSystem) {
69
- warn("\"".concat(funcName, "\" -> \"").concat(argName, "\" should be degree!"));
70
- }
71
- return scope;
72
- }; };
73
- var shouldBeRadians = function (scope, funcName, argName) { return function (p) {
74
- if (!p.likeRadians) {
75
- warn("\"".concat(funcName, "\" -> \"").concat(argName, "\" should be radians!"));
76
- }
77
- return scope;
78
- }; };
79
- var shouldExist = function (scope, funcName, argName) { return function (p) {
80
- if (!isDefAndNotNull(p)) {
81
- warn("\"".concat(funcName, "\" -> \"").concat(argName, "\" should exist!"));
82
- }
83
- return scope;
84
- }; };
85
- var shouldBeMeters = function (scope, funcName, argName) { return function (p) {
86
- if (!p.likePseudoMercator) {
87
- warn("\"".concat(funcName, "\" -> \"").concat(argName, "\" should be meters!"));
88
- }
89
- return scope;
90
- }; };
91
- export var checkFunction = function (funcName) { return ({
92
- checkArgument: function (argName) {
93
- if (!DGeo.DEBUG) {
94
- return {
95
- shouldBeDegree: hook(this),
96
- shouldBeMeters: hook(this),
97
- shouldBeInt: hook(this),
98
- shouldBeUInt: hook(this),
99
- shouldBeRadians: hook(this),
100
- shouldExist: hook(this)
101
- };
102
- }
103
- return {
104
- shouldBeDegree: shouldBeDegree(this, funcName, argName),
105
- shouldBeMeters: shouldBeMeters(this, funcName, argName),
106
- shouldBeInt: shouldBeInt(this, funcName, argName),
107
- shouldBeUInt: shouldBeUInt(this, funcName, argName),
108
- shouldBeRadians: shouldBeRadians(this, funcName, argName),
109
- shouldExist: shouldExist(this, funcName, argName)
110
- };
111
- }
112
- }); };
113
- export var createArray = function (v, fillSymbol) {
114
- if (typeof fillSymbol === 'function') {
115
- return new Array(v).fill(false)
116
- .map(function (_, i) { return fillSymbol(i); });
117
- }
118
- return new Array(v).fill(fillSymbol !== null && fillSymbol !== void 0 ? fillSymbol : 0);
119
- };
120
- export var createMatrix = function (_a, fillSymbol) {
121
- var h = _a.h, w = _a.w;
122
- if (typeof fillSymbol === 'function') {
123
- return createArray(h)
124
- .map(function (_, y) { return createArray(w, function (x) { return fillSymbol(x, y); }); });
125
- }
126
- return createArray(h)
127
- .map(function () { return createArray(w, fillSymbol); });
128
- };
129
- export var gaussianElimination = function (matrix) {
130
- var n = matrix.length;
131
- var matrixClone = createMatrix(new DPoint(n + 1, n));
132
- for (var i = 0; i < n; i++) {
133
- for (var j = 0; j < n + 1; j++) {
134
- matrix[i][j] = matrix[i][j] === 0 ? gaussianElimination.MIN : matrix[i][j];
135
- matrixClone[i][j] = matrix[i][j];
136
- }
137
- }
138
- for (var k = 0; k < n; k++) {
139
- for (var i = 0; i < n + 1; i++) {
140
- matrixClone[k][i] /= matrix[k][k];
141
- }
142
- for (var i = k + 1; i < n; i++) {
143
- var K = matrixClone[i][k] / matrixClone[k][k];
144
- for (var j = 0; j < n + 1; j++) {
145
- matrixClone[i][j] -= matrixClone[k][j] * K;
146
- }
147
- }
148
- for (var i = 0; i < n; i++) {
149
- for (var j = 0; j < n + 1; j++) {
150
- matrix[i][j] = matrixClone[i][j];
151
- }
152
- }
153
- }
154
- for (var k = n - 1; k > -1; k--) {
155
- for (var i = n; i > -1; i--) {
156
- matrixClone[k][i] /= matrix[k][k];
157
- }
158
- for (var i = k - 1; i > -1; i--) {
159
- var K = matrixClone[i][k] / matrixClone[k][k];
160
- for (var j = n; j > -1; j--) {
161
- matrixClone[i][j] -= matrixClone[k][j] * K;
162
- }
163
- }
164
- }
165
- var answer = createArray(n);
166
- for (var i = 0; i < n; i++) {
167
- answer[i] = matrixClone[i][n];
168
- }
169
- return answer;
170
- };
171
- gaussianElimination.MIN = 1e-10;
172
- export var createCanvas = function (a, b, c) {
173
- var _a;
174
- var w = 0;
175
- var h = 0;
176
- var offscreen = false;
177
- if (a instanceof DPoint) {
178
- var x = a.x, y = a.y;
179
- w = x;
180
- h = y;
181
- }
182
- else {
183
- w = a;
184
- h = a;
185
- }
186
- if (typeof b === 'boolean') {
187
- offscreen = b;
188
- }
189
- else if (typeof b === 'number') {
190
- h = b;
191
- }
192
- if (typeof c === 'boolean') {
193
- offscreen = c;
194
- }
195
- var canvas = offscreen ? new OffscreenCanvas(w, h) : ((_a = createCanvas.document) !== null && _a !== void 0 ? _a : document).createElement('canvas');
196
- if (!offscreen) {
197
- canvas.width = w;
198
- canvas.height = h;
199
- }
200
- return [canvas, canvas.getContext('2d')];
201
- };
202
- var f = function (a, b) { return [].concat.apply([], __spreadArray([], __read(a.map(function (c) { return b.map(function (d) { return [].concat(c, d); }); })), false)); };
203
- export var cartesianProduct = function (a, b) {
204
- var c = [];
205
- for (var _i = 2; _i < arguments.length; _i++) {
206
- c[_i - 2] = arguments[_i];
207
- }
208
- return b ? cartesianProduct.apply(void 0, __spreadArray([f(a, b)], __read(c), false)) : a;
209
- };
210
- export var getCombinations = function (arr) {
211
- if (arr.length === 1) {
212
- return arr[0];
213
- }
214
- var ans = [];
215
- var otherCases = getCombinations(arr.slice(1));
216
- for (var i = 0; i < otherCases.length; i++) {
217
- for (var j = 0; j < arr[0].length; j++) {
218
- ans.push(__spreadArray([arr[0][j]], __read(otherCases[i]), false));
219
- }
220
- }
221
- return ans;
222
- };
223
- export var div = function (a, b) { return Math.floor(a / b); };
224
- export var toDegreesMinutesSeconds = function (v) {
225
- var degrees = Math.floor(v);
226
- var t = (v % 1) * 60;
227
- var minutes = Math.floor(t);
228
- var t2 = (t % 1) * 60;
229
- var seconds = t2.toFixed(2);
230
- return "".concat(degrees, "\u00B0 ").concat(minutes, "' ").concat(seconds, "\"");
231
- };
232
- export var parseDegreesMinutesSeconds = function (i) {
233
- var e_1, _a;
234
- var _b, _c, _d, _e, _f, _g, _h;
235
- var parts = i.matchAll(/(?<value>-?\d+(?<tail>\.\d{1,})?)(?<type>°|'|")/gmiu);
236
- var d = 0;
237
- var m = 0;
238
- var s = 0;
239
- try {
240
- for (var parts_1 = __values(parts), parts_1_1 = parts_1.next(); !parts_1_1.done; parts_1_1 = parts_1.next()) {
241
- var part = parts_1_1.value;
242
- switch ((_b = part === null || part === void 0 ? void 0 : part.groups) === null || _b === void 0 ? void 0 : _b.type) {
243
- case '°':
244
- d = Number((_d = (_c = part === null || part === void 0 ? void 0 : part.groups) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : '0');
245
- break;
246
- case '\'':
247
- m = Number((_f = (_e = part === null || part === void 0 ? void 0 : part.groups) === null || _e === void 0 ? void 0 : _e.value) !== null && _f !== void 0 ? _f : '0');
248
- break;
249
- case '"':
250
- s = Number((_h = (_g = part === null || part === void 0 ? void 0 : part.groups) === null || _g === void 0 ? void 0 : _g.value) !== null && _h !== void 0 ? _h : '0');
251
- break;
252
- default:
253
- }
254
- }
255
- }
256
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
257
- finally {
258
- try {
259
- if (parts_1_1 && !parts_1_1.done && (_a = parts_1.return)) _a.call(parts_1);
260
- }
261
- finally { if (e_1) throw e_1.error; }
262
- }
263
- var h = d < 0 ? -1 : 1;
264
- return d + h * m / 60 + h * s / 3600;
265
- };