dgeoutils 2.4.1 → 2.4.4

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.
@@ -1,43 +1,81 @@
1
1
  "use strict";
2
+ var __read = (this && this.__read) || function (o, n) {
3
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
4
+ if (!m) return o;
5
+ var i = m.call(o), r, ar = [], e;
6
+ try {
7
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
+ }
9
+ catch (error) { e = { error: error }; }
10
+ finally {
11
+ try {
12
+ if (r && !r.done && (m = i["return"])) m.call(i);
13
+ }
14
+ finally { if (e) throw e.error; }
15
+ }
16
+ return ar;
17
+ };
18
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
20
+ if (ar || !(i in from)) {
21
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
22
+ ar[i] = from[i];
23
+ }
24
+ }
25
+ return to.concat(ar || Array.prototype.slice.call(from));
26
+ };
27
+ var __values = (this && this.__values) || function(o) {
28
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
29
+ if (m) return m.call(o);
30
+ if (o && typeof o.length === "number") return {
31
+ next: function () {
32
+ if (o && i >= o.length) o = void 0;
33
+ return { value: o && o[i++], done: !o };
34
+ }
35
+ };
36
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
37
+ };
2
38
  Object.defineProperty(exports, "__esModule", { value: true });
3
39
  exports.TraceMatrix = exports.TraceMatrixValues = void 0;
4
- const DPoint_1 = require("./DPoint");
5
- const DPolygon_1 = require("./DPolygon");
6
- const FastSearch_1 = require("./FastSearch");
7
- const utils_1 = require("./utils");
40
+ var DPoint_1 = require("./DPoint");
41
+ var DPolygon_1 = require("./DPolygon");
42
+ var FastSearch_1 = require("./FastSearch");
43
+ var utils_1 = require("./utils");
8
44
  var TraceMatrixValues;
9
45
  (function (TraceMatrixValues) {
10
46
  TraceMatrixValues[TraceMatrixValues["f"] = 0] = "f";
11
47
  TraceMatrixValues[TraceMatrixValues["t"] = 1] = "t";
12
48
  })(TraceMatrixValues = exports.TraceMatrixValues || (exports.TraceMatrixValues = {}));
13
- const getByPosition = (m, p, defaultValue = TraceMatrixValues.f) => {
49
+ var getByPosition = function (m, p, defaultValue) {
50
+ if (defaultValue === void 0) { defaultValue = TraceMatrixValues.f; }
14
51
  if (m[p.y] === undefined || m[p.y][p.x] === undefined) {
15
52
  return defaultValue;
16
53
  }
17
54
  return m[p.y][p.x];
18
55
  };
19
- const setByPosition = (m, p, value) => {
56
+ var setByPosition = function (m, p, value) {
20
57
  if (m[p.y] === undefined || m[p.y][p.x] === undefined) {
21
58
  return value;
22
59
  }
23
60
  m[p.y][p.x] = value;
24
61
  return m[p.y][p.x];
25
62
  };
26
- class TraceMatrix {
27
- constructor(size, f) {
63
+ var TraceMatrix = (function () {
64
+ function TraceMatrix(size, f) {
65
+ var _this = this;
28
66
  this.size = size;
29
- this.findGroupByIndex = (m, s) => {
30
- const res = new DPolygon_1.DPolygon();
67
+ this.findGroupByIndex = function (m, s) {
68
+ var res = new DPolygon_1.DPolygon();
31
69
  if (s && getByPosition(m, s) === TraceMatrixValues.t) {
32
70
  res.push(s);
33
- let startIndex = 0;
34
- const marked = TraceMatrix.createMatrix(this.size, () => TraceMatrixValues.f);
71
+ var startIndex = 0;
72
+ var marked = TraceMatrix.createMatrix(_this.size, function () { return TraceMatrixValues.f; });
35
73
  setByPosition(marked, s, TraceMatrixValues.t);
36
74
  while (startIndex < res.length) {
37
- const r = res.at(startIndex);
38
- for (let i = -1; i < 2; i++) {
39
- for (let j = -1; j < 2; j++) {
40
- const t = new DPoint_1.DPoint(r.x + i, r.y + j);
75
+ var r = res.at(startIndex);
76
+ for (var i = -1; i < 2; i++) {
77
+ for (var j = -1; j < 2; j++) {
78
+ var t = new DPoint_1.DPoint(r.x + i, r.y + j);
41
79
  if (getByPosition(marked, t, TraceMatrixValues.t) === TraceMatrixValues.f &&
42
80
  getByPosition(m, t, TraceMatrixValues.f) === TraceMatrixValues.t) {
43
81
  res.push(t);
@@ -50,32 +88,32 @@ class TraceMatrix {
50
88
  }
51
89
  return res;
52
90
  };
53
- this.findAllGroupsInMatrix = (m) => {
54
- const firstMark = this.findMarked(m);
91
+ this.findAllGroupsInMatrix = function (m) {
92
+ var firstMark = _this.findMarked(m);
55
93
  if (!firstMark) {
56
94
  return [];
57
95
  }
58
- const group = this.findGroupByIndex(m, firstMark);
59
- const groups = [group];
60
- let groupSum = group.length;
61
- let allGroups = [...group.points];
62
- const fs = new FastSearch_1.FastSearch();
96
+ var group = _this.findGroupByIndex(m, firstMark);
97
+ var groups = [group];
98
+ var groupSum = group.length;
99
+ var allGroups = __spreadArray([], __read(group.points), false);
100
+ var fs = new FastSearch_1.FastSearch();
63
101
  fs.add(allGroups);
64
- while (groupSum < this.totalCountInMatrix(m)) {
65
- let mark = this.findMarked(m);
102
+ while (groupSum < _this.totalCountInMatrix(m)) {
103
+ var mark = _this.findMarked(m);
66
104
  while (mark && fs.find(mark)) {
67
- mark = this.findMarked(m, mark);
105
+ mark = _this.findMarked(m, mark);
68
106
  }
69
- const nextGroup = this.findGroupByIndex(m, mark);
107
+ var nextGroup = _this.findGroupByIndex(m, mark);
70
108
  groupSum += nextGroup.length;
71
- allGroups = [...allGroups, ...nextGroup.points];
109
+ allGroups = __spreadArray(__spreadArray([], __read(allGroups), false), __read(nextGroup.points), false);
72
110
  fs.add(nextGroup.points);
73
111
  groups.push(nextGroup);
74
112
  }
75
- return groups.filter((g) => g.length > 2);
113
+ return groups.filter(function (g) { return g.length > 2; });
76
114
  };
77
- this.traceGroup = (m, group) => {
78
- const traceDirections = [
115
+ this.traceGroup = function (m, group) {
116
+ var traceDirections = [
79
117
  new DPoint_1.DPoint(-1, -1),
80
118
  new DPoint_1.DPoint(-1, 0),
81
119
  new DPoint_1.DPoint(-1, 1),
@@ -85,20 +123,20 @@ class TraceMatrix {
85
123
  new DPoint_1.DPoint(1, -1),
86
124
  new DPoint_1.DPoint(0, -1)
87
125
  ];
88
- const left = (d) => (d + traceDirections.length + 1) % traceDirections.length;
89
- const right = (d) => (d + traceDirections.length - 1) % traceDirections.length;
126
+ var left = function (d) { return (d + traceDirections.length + 1) % traceDirections.length; };
127
+ var right = function (d) { return (d + traceDirections.length - 1) % traceDirections.length; };
90
128
  if (group.length < 2) {
91
- const t = group.at(0).clone();
129
+ var t = group.at(0).clone();
92
130
  return new DPolygon_1.DPolygon([t, t, t]);
93
131
  }
94
- const points = new DPolygon_1.DPolygon();
95
- let direction = 0;
96
- let prevDirection = Infinity;
97
- let p = group.at(0);
132
+ var points = new DPolygon_1.DPolygon();
133
+ var direction = 0;
134
+ var prevDirection = Infinity;
135
+ var p = group.at(0);
98
136
  while (!p.equal(group.at(0)) || points.length < 2) {
99
137
  while (true) {
100
- const nextValue = getByPosition(m, p.clone().move(traceDirections[direction]));
101
- const nextNeighbourValue = getByPosition(m, p.clone().move(traceDirections[left(direction)]));
138
+ var nextValue = getByPosition(m, p.clone().move(traceDirections[direction]));
139
+ var nextNeighbourValue = getByPosition(m, p.clone().move(traceDirections[left(direction)]));
102
140
  if (nextValue === TraceMatrixValues.t && nextNeighbourValue === TraceMatrixValues.f) {
103
141
  break;
104
142
  }
@@ -113,64 +151,76 @@ class TraceMatrix {
113
151
  }
114
152
  return points.approximation().close();
115
153
  };
116
- this.createHoleMatrix = (group) => {
117
- const fullTraceDirections = [
154
+ this.createHoleMatrix = function (group) {
155
+ var e_1, _a;
156
+ var fullTraceDirections = [
118
157
  new DPoint_1.DPoint(-1, 0),
119
158
  new DPoint_1.DPoint(0, 1),
120
159
  new DPoint_1.DPoint(1, 0),
121
160
  new DPoint_1.DPoint(0, -1)
122
161
  ];
123
162
  group.prepareToFastSearch();
124
- const tmpMatrix = TraceMatrix
125
- .createMatrix(this.size, (p) => group.fastHas(p) ? TraceMatrixValues.t : TraceMatrixValues.f);
126
- const startCoords = new DPolygon_1.DPolygon();
127
- for (let i = 0; i < this.size.w; i++) {
163
+ var tmpMatrix = TraceMatrix
164
+ .createMatrix(_this.size, function (p) { return group.fastHas(p) ? TraceMatrixValues.t : TraceMatrixValues.f; });
165
+ var startCoords = new DPolygon_1.DPolygon();
166
+ for (var i = 0; i < _this.size.w; i++) {
128
167
  startCoords.push(new DPoint_1.DPoint(i, -1));
129
- startCoords.push(new DPoint_1.DPoint(i, this.size.h));
168
+ startCoords.push(new DPoint_1.DPoint(i, _this.size.h));
130
169
  }
131
- for (let i = 0; i < this.size.h; i++) {
170
+ for (var i = 0; i < _this.size.h; i++) {
132
171
  startCoords.push(new DPoint_1.DPoint(-1, i));
133
- startCoords.push(new DPoint_1.DPoint(this.size.w, i));
172
+ startCoords.push(new DPoint_1.DPoint(_this.size.w, i));
134
173
  }
135
174
  while (startCoords.length) {
136
- const point = startCoords.pop();
137
- for (const direction of fullTraceDirections) {
138
- const tmpPoint = point.clone().move(direction);
139
- const value = getByPosition(tmpMatrix, tmpPoint, TraceMatrixValues.t);
140
- if (value === TraceMatrixValues.f) {
141
- setByPosition(tmpMatrix, tmpPoint, TraceMatrixValues.t);
142
- startCoords.push(tmpPoint);
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);
143
191
  }
192
+ finally { if (e_1) throw e_1.error; }
144
193
  }
145
194
  }
146
- const t = this.reverseMatrix(tmpMatrix);
147
- return this.totalCountInMatrix(t) ? t : null;
195
+ var t = _this.reverseMatrix(tmpMatrix);
196
+ return _this.totalCountInMatrix(t) ? t : null;
148
197
  };
149
198
  this.m = TraceMatrix.createMatrix(this.size, f);
150
199
  }
151
- fullMatrixTrace() {
152
- const groups = this.findAllGroupsInMatrix(this.m);
153
- const paths = groups.map((g) => this.traceGroup(this.m, g));
154
- const holeMatrixs = groups.map(this.createHoleMatrix);
155
- const holesGroups = holeMatrixs.map((m) => m && this.findAllGroupsInMatrix(m));
156
- const holesPaths = holesGroups.map((hg, index) => hg && hg.map((g) => this
157
- .traceGroup(holeMatrixs[index], g)).filter((r) => r.length > DPolygon_1.MIN_POINTS_IN_VALID_POLYGON));
158
- return groups.map((g, index) => {
159
- const res = paths[index];
200
+ TraceMatrix.prototype.fullMatrixTrace = function () {
201
+ var _this = this;
202
+ var groups = this.findAllGroupsInMatrix(this.m);
203
+ var paths = groups.map(function (g) { return _this.traceGroup(_this.m, g); });
204
+ var holeMatrixs = groups.map(this.createHoleMatrix);
205
+ var holesGroups = holeMatrixs.map(function (m) { return m && _this.findAllGroupsInMatrix(m); });
206
+ var holesPaths = holesGroups.map(function (hg, index) { return hg && hg.map(function (g) { return _this
207
+ .traceGroup(holeMatrixs[index], g); }).filter(function (r) { return r.length > DPolygon_1.MIN_POINTS_IN_VALID_POLYGON; }); });
208
+ return groups.map(function (g, index) {
209
+ var res = paths[index];
160
210
  if (holesGroups[index] && holesGroups[index].length) {
161
211
  res.holes = holesPaths[index];
162
212
  }
163
213
  return res;
164
214
  });
165
- }
166
- reverseMatrix(m) {
167
- return TraceMatrix.createMatrix(this.size, (p) => getByPosition(m, p) === TraceMatrixValues.f ? TraceMatrixValues.t : TraceMatrixValues.f);
168
- }
169
- findMarked(m, init) {
170
- const s = this.size;
171
- let ini = false;
172
- for (let i = 0; i < s.w; i++) {
173
- for (let j = 0; j < s.h; j++) {
215
+ };
216
+ TraceMatrix.prototype.reverseMatrix = function (m) {
217
+ return TraceMatrix.createMatrix(this.size, function (p) { return getByPosition(m, p) === TraceMatrixValues.f ? TraceMatrixValues.t : TraceMatrixValues.f; });
218
+ };
219
+ TraceMatrix.prototype.findMarked = function (m, init) {
220
+ var s = this.size;
221
+ var ini = false;
222
+ for (var i = 0; i < s.w; i++) {
223
+ for (var j = 0; j < s.h; j++) {
174
224
  if (!ini && init) {
175
225
  i = init.x;
176
226
  j = init.y;
@@ -183,22 +233,24 @@ class TraceMatrix {
183
233
  }
184
234
  }
185
235
  return null;
186
- }
187
- totalCountInMatrix(m) {
188
- let res = 0;
189
- const s = this.size;
190
- for (let i = 0; i < s.w; i++) {
191
- for (let j = 0; j < s.h; j++) {
236
+ };
237
+ TraceMatrix.prototype.totalCountInMatrix = function (m) {
238
+ var res = 0;
239
+ var s = this.size;
240
+ for (var i = 0; i < s.w; i++) {
241
+ for (var j = 0; j < s.h; j++) {
192
242
  if (getByPosition(m, new DPoint_1.DPoint(i, j))) {
193
243
  res++;
194
244
  }
195
245
  }
196
246
  }
197
247
  return res;
198
- }
199
- static createMatrix(size, f = () => TraceMatrixValues.f) {
248
+ };
249
+ TraceMatrix.createMatrix = function (size, f) {
250
+ if (f === void 0) { f = function () { return TraceMatrixValues.f; }; }
200
251
  return (0, utils_1.createArray)(size.h)
201
- .map((v, i) => (0, utils_1.createArray)(size.w).map((v2, j) => f(new DPoint_1.DPoint(j, i))));
202
- }
203
- }
252
+ .map(function (v, i) { return (0, utils_1.createArray)(size.w).map(function (v2, j) { return f(new DPoint_1.DPoint(j, i)); }); });
253
+ };
254
+ return TraceMatrix;
255
+ }());
204
256
  exports.TraceMatrix = TraceMatrix;
package/dist/cjs/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
package/dist/cjs/utils.js CHANGED
@@ -1,58 +1,87 @@
1
1
  "use strict";
2
+ var __read = (this && this.__read) || function (o, n) {
3
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
4
+ if (!m) return o;
5
+ var i = m.call(o), r, ar = [], e;
6
+ try {
7
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
+ }
9
+ catch (error) { e = { error: error }; }
10
+ finally {
11
+ try {
12
+ if (r && !r.done && (m = i["return"])) m.call(i);
13
+ }
14
+ finally { if (e) throw e.error; }
15
+ }
16
+ return ar;
17
+ };
18
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
20
+ if (ar || !(i in from)) {
21
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
22
+ ar[i] = from[i];
23
+ }
24
+ }
25
+ return to.concat(ar || Array.prototype.slice.call(from));
26
+ };
2
27
  Object.defineProperty(exports, "__esModule", { value: true });
3
28
  exports.getCombinations = exports.cartesianProduct = exports.createCanvas = exports.gaussianElimination = exports.createMatrix = exports.createArray = exports.checkFunction = exports.isDefAndNotNull = exports.warn = exports.DGeo = void 0;
4
- const DPoint_1 = require("./DPoint");
29
+ var DPoint_1 = require("./DPoint");
5
30
  exports.DGeo = {
6
31
  DEBUG: false
7
32
  };
8
- const warn = (...args) => {
33
+ var warn = function () {
34
+ var args = [];
35
+ for (var _i = 0; _i < arguments.length; _i++) {
36
+ args[_i] = arguments[_i];
37
+ }
9
38
  if (exports.DGeo.DEBUG) {
10
- console.warn(...args);
39
+ console.warn.apply(console, __spreadArray([], __read(args), false));
11
40
  }
12
41
  };
13
42
  exports.warn = warn;
14
- const isDefAndNotNull = (a) => a != undefined;
43
+ var isDefAndNotNull = function (a) { return a != undefined; };
15
44
  exports.isDefAndNotNull = isDefAndNotNull;
16
- const hook = (scope) => () => scope;
17
- const shouldBeInt = (scope, funcName, argName) => (p) => {
45
+ var hook = function (scope) { return function () { return scope; }; };
46
+ var shouldBeInt = function (scope, funcName, argName) { return function (p) {
18
47
  if (!p.clone().round()
19
48
  .equal(p)) {
20
- (0, exports.warn)(`"${funcName}" -> "${argName}" should be Int!`);
49
+ (0, exports.warn)("\"".concat(funcName, "\" -> \"").concat(argName, "\" should be Int!"));
21
50
  }
22
51
  return scope;
23
- };
24
- const shouldBeUInt = (scope, funcName, argName) => (p) => {
52
+ }; };
53
+ var shouldBeUInt = function (scope, funcName, argName) { return function (p) {
25
54
  if (!p.clone().round()
26
55
  .equal(p) || !p.gtOrEqual(DPoint_1.DPoint.zero())) {
27
- (0, exports.warn)(`"${funcName}" -> "${argName}" should be UInt!`);
56
+ (0, exports.warn)("\"".concat(funcName, "\" -> \"").concat(argName, "\" should be UInt!"));
28
57
  }
29
58
  return scope;
30
- };
31
- const shouldBeDegree = (scope, funcName, argName) => (p) => {
59
+ }; };
60
+ var shouldBeDegree = function (scope, funcName, argName) { return function (p) {
32
61
  if (!p.likeWorldGeodeticSystem) {
33
- (0, exports.warn)(`"${funcName}" -> "${argName}" should be degree!`);
62
+ (0, exports.warn)("\"".concat(funcName, "\" -> \"").concat(argName, "\" should be degree!"));
34
63
  }
35
64
  return scope;
36
- };
37
- const shouldBeRadians = (scope, funcName, argName) => (p) => {
65
+ }; };
66
+ var shouldBeRadians = function (scope, funcName, argName) { return function (p) {
38
67
  if (!p.likeRadians) {
39
- (0, exports.warn)(`"${funcName}" -> "${argName}" should be radians!`);
68
+ (0, exports.warn)("\"".concat(funcName, "\" -> \"").concat(argName, "\" should be radians!"));
40
69
  }
41
70
  return scope;
42
- };
43
- const shouldExist = (scope, funcName, argName) => (p) => {
71
+ }; };
72
+ var shouldExist = function (scope, funcName, argName) { return function (p) {
44
73
  if (!(0, exports.isDefAndNotNull)(p)) {
45
- (0, exports.warn)(`"${funcName}" -> "${argName}" should exist!`);
74
+ (0, exports.warn)("\"".concat(funcName, "\" -> \"").concat(argName, "\" should exist!"));
46
75
  }
47
76
  return scope;
48
- };
49
- const shouldBeMeters = (scope, funcName, argName) => (p) => {
77
+ }; };
78
+ var shouldBeMeters = function (scope, funcName, argName) { return function (p) {
50
79
  if (!p.likePseudoMercator) {
51
- (0, exports.warn)(`"${funcName}" -> "${argName}" should be meters!`);
80
+ (0, exports.warn)("\"".concat(funcName, "\" -> \"").concat(argName, "\" should be meters!"));
52
81
  }
53
82
  return scope;
54
- };
55
- const checkFunction = (funcName) => ({
83
+ }; };
84
+ var checkFunction = function (funcName) { return ({
56
85
  checkArgument: function (argName) {
57
86
  if (!exports.DGeo.DEBUG) {
58
87
  return {
@@ -73,64 +102,71 @@ const checkFunction = (funcName) => ({
73
102
  shouldExist: shouldExist(this, funcName, argName)
74
103
  };
75
104
  }
76
- });
105
+ }); };
77
106
  exports.checkFunction = checkFunction;
78
- const createArray = (v, fillSymbol = 0) => new Array(v).fill(fillSymbol);
107
+ var createArray = function (v, fillSymbol) {
108
+ if (fillSymbol === void 0) { fillSymbol = 0; }
109
+ return new Array(v).fill(fillSymbol);
110
+ };
79
111
  exports.createArray = createArray;
80
- const createMatrix = ({ h, w }, fillSymbol = 0) => (0, exports.createArray)(h)
81
- .map(() => (0, exports.createArray)(w, fillSymbol));
112
+ var createMatrix = function (_a, fillSymbol) {
113
+ var h = _a.h, w = _a.w;
114
+ if (fillSymbol === void 0) { fillSymbol = 0; }
115
+ return (0, exports.createArray)(h)
116
+ .map(function () { return (0, exports.createArray)(w, fillSymbol); });
117
+ };
82
118
  exports.createMatrix = createMatrix;
83
- const gaussianElimination = (matrix) => {
84
- const n = matrix.length;
85
- const matrixClone = (0, exports.createMatrix)(new DPoint_1.DPoint(n + 1, n));
86
- for (let i = 0; i < n; i++) {
87
- for (let j = 0; j < n + 1; j++) {
119
+ var gaussianElimination = function (matrix) {
120
+ var n = matrix.length;
121
+ var matrixClone = (0, exports.createMatrix)(new DPoint_1.DPoint(n + 1, n));
122
+ for (var i = 0; i < n; i++) {
123
+ for (var j = 0; j < n + 1; j++) {
88
124
  matrix[i][j] = matrix[i][j] === 0 ? exports.gaussianElimination.MIN : matrix[i][j];
89
125
  matrixClone[i][j] = matrix[i][j];
90
126
  }
91
127
  }
92
- for (let k = 0; k < n; k++) {
93
- for (let i = 0; i < n + 1; i++) {
128
+ for (var k = 0; k < n; k++) {
129
+ for (var i = 0; i < n + 1; i++) {
94
130
  matrixClone[k][i] /= matrix[k][k];
95
131
  }
96
- for (let i = k + 1; i < n; i++) {
97
- const K = matrixClone[i][k] / matrixClone[k][k];
98
- for (let j = 0; j < n + 1; j++) {
132
+ for (var i = k + 1; i < n; i++) {
133
+ var K = matrixClone[i][k] / matrixClone[k][k];
134
+ for (var j = 0; j < n + 1; j++) {
99
135
  matrixClone[i][j] -= matrixClone[k][j] * K;
100
136
  }
101
137
  }
102
- for (let i = 0; i < n; i++) {
103
- for (let j = 0; j < n + 1; j++) {
138
+ for (var i = 0; i < n; i++) {
139
+ for (var j = 0; j < n + 1; j++) {
104
140
  matrix[i][j] = matrixClone[i][j];
105
141
  }
106
142
  }
107
143
  }
108
- for (let k = n - 1; k > -1; k--) {
109
- for (let i = n; i > -1; i--) {
144
+ for (var k = n - 1; k > -1; k--) {
145
+ for (var i = n; i > -1; i--) {
110
146
  matrixClone[k][i] /= matrix[k][k];
111
147
  }
112
- for (let i = k - 1; i > -1; i--) {
113
- const K = matrixClone[i][k] / matrixClone[k][k];
114
- for (let j = n; j > -1; j--) {
148
+ for (var i = k - 1; i > -1; i--) {
149
+ var K = matrixClone[i][k] / matrixClone[k][k];
150
+ for (var j = n; j > -1; j--) {
115
151
  matrixClone[i][j] -= matrixClone[k][j] * K;
116
152
  }
117
153
  }
118
154
  }
119
- const answer = (0, exports.createArray)(n);
120
- for (let i = 0; i < n; i++) {
155
+ var answer = (0, exports.createArray)(n);
156
+ for (var i = 0; i < n; i++) {
121
157
  answer[i] = matrixClone[i][n];
122
158
  }
123
159
  return answer;
124
160
  };
125
161
  exports.gaussianElimination = gaussianElimination;
126
162
  exports.gaussianElimination.MIN = 1e-10;
127
- const createCanvas = (a, b, c) => {
163
+ var createCanvas = function (a, b, c) {
128
164
  var _a;
129
- let w = 0;
130
- let h = 0;
131
- let offscreen = false;
165
+ var w = 0;
166
+ var h = 0;
167
+ var offscreen = false;
132
168
  if (a instanceof DPoint_1.DPoint) {
133
- const { x, y } = a;
169
+ var x = a.x, y = a.y;
134
170
  w = x;
135
171
  h = y;
136
172
  }
@@ -147,7 +183,7 @@ const createCanvas = (a, b, c) => {
147
183
  if (typeof c === 'boolean') {
148
184
  offscreen = c;
149
185
  }
150
- const canvas = offscreen ? new OffscreenCanvas(w, h) : ((_a = exports.createCanvas.document) !== null && _a !== void 0 ? _a : document).createElement('canvas');
186
+ var canvas = offscreen ? new OffscreenCanvas(w, h) : ((_a = exports.createCanvas.document) !== null && _a !== void 0 ? _a : document).createElement('canvas');
151
187
  if (!offscreen) {
152
188
  canvas.width = w;
153
189
  canvas.height = h;
@@ -155,18 +191,24 @@ const createCanvas = (a, b, c) => {
155
191
  return [canvas, canvas.getContext('2d')];
156
192
  };
157
193
  exports.createCanvas = createCanvas;
158
- const f = (a, b) => [].concat(...a.map((c) => b.map((d) => [].concat(c, d))));
159
- const cartesianProduct = (a, b, ...c) => b ? (0, exports.cartesianProduct)(f(a, b), ...c) : a;
194
+ var f = function (a, b) { return [].concat.apply([], __spreadArray([], __read(a.map(function (c) { return b.map(function (d) { return [].concat(c, d); }); })), false)); };
195
+ var cartesianProduct = function (a, b) {
196
+ var c = [];
197
+ for (var _i = 2; _i < arguments.length; _i++) {
198
+ c[_i - 2] = arguments[_i];
199
+ }
200
+ return b ? exports.cartesianProduct.apply(void 0, __spreadArray([f(a, b)], __read(c), false)) : a;
201
+ };
160
202
  exports.cartesianProduct = cartesianProduct;
161
- const getCombinations = (arr) => {
203
+ var getCombinations = function (arr) {
162
204
  if (arr.length === 1) {
163
205
  return arr[0];
164
206
  }
165
- const ans = [];
166
- const otherCases = (0, exports.getCombinations)(arr.slice(1));
167
- for (let i = 0; i < otherCases.length; i++) {
168
- for (let j = 0; j < arr[0].length; j++) {
169
- ans.push([arr[0][j], ...otherCases[i]]);
207
+ var ans = [];
208
+ var otherCases = (0, exports.getCombinations)(arr.slice(1));
209
+ for (var i = 0; i < otherCases.length; i++) {
210
+ for (var j = 0; j < arr[0].length; j++) {
211
+ ans.push(__spreadArray([arr[0][j]], __read(otherCases[i]), false));
170
212
  }
171
213
  }
172
214
  return ans;
@@ -9,7 +9,7 @@ var DCircle = (function () {
9
9
  this.r = r;
10
10
  }
11
11
  DCircle.prototype.toString = function () {
12
- return "(" + this.center.toString() + ", " + this.r + ")";
12
+ return "(".concat(this.center.toString(), ", ").concat(this.r, ")");
13
13
  };
14
14
  DCircle.prototype.getValue = function () {
15
15
  return { center: this.center, r: this.r };
package/dist/esm/DLine.js CHANGED
@@ -156,7 +156,7 @@ var DLine = (function () {
156
156
  configurable: true
157
157
  });
158
158
  DLine.prototype.toString = function () {
159
- return "(" + this.a + ", " + this.b + ", " + this.c + ")";
159
+ return "(".concat(this.a, ", ").concat(this.b, ", ").concat(this.c, ")");
160
160
  };
161
161
  DLine.prototype.getValue = function () {
162
162
  return [this.a, this.b, this.c];
@@ -257,7 +257,7 @@ var DLine = (function () {
257
257
  };
258
258
  DLine.prototype.toWKT = function () {
259
259
  var _a = this, _b = _a.begin, x1 = _b.x, y1 = _b.y, _c = _a.end, x2 = _c.x, y2 = _c.y;
260
- return "LINESTRING (" + x1 + " " + y1 + ", " + x2 + " " + y2 + ")";
260
+ return "LINESTRING (".concat(x1, " ").concat(y1, ", ").concat(x2, " ").concat(y2, ")");
261
261
  };
262
262
  DLine.prototype.movePoint = function (i, k) {
263
263
  var isArray = Array.isArray(i);
@@ -133,7 +133,7 @@ var DPoint = (function () {
133
133
  return a2 + Math.PI * 2 - a1;
134
134
  };
135
135
  DPoint.prototype.toString = function () {
136
- return this.x + " " + this.y;
136
+ return "".concat(this.x, " ").concat(this.y);
137
137
  };
138
138
  DPoint.prototype.getValue = function () {
139
139
  return [this.x, this.y];
@@ -144,7 +144,7 @@ var DPoint = (function () {
144
144
  };
145
145
  DPoint.prototype.toWKT = function () {
146
146
  var _a = this, x = _a.x, y = _a.y;
147
- return "POINT (" + x + " " + y + ")";
147
+ return "POINT (".concat(x, " ").concat(y, ")");
148
148
  };
149
149
  DPoint.prototype.distance = function (p) {
150
150
  checkFunction('distance')