dgeoutils 2.2.2 → 2.2.6
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/DCircle.d.ts +5 -1
- package/dist/DCircle.js +8 -4
- package/dist/DLine.d.ts +14 -7
- package/dist/DLine.js +61 -77
- package/dist/DPoint.d.ts +105 -12
- package/dist/DPoint.js +18 -21
- package/dist/DPolygon.d.ts +67 -76
- package/dist/DPolygon.js +151 -123
- package/dist/DPolygonLoop.d.ts +84 -6
- package/dist/DPolygonLoop.js +11 -4
- package/dist/TraceMatrix.d.ts +1 -1
- package/dist/TraceMatrix.js +4 -6
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +4 -2
- package/package.json +2 -2
package/dist/DPolygonLoop.js
CHANGED
|
@@ -35,6 +35,7 @@ var LoopFunctions;
|
|
|
35
35
|
// eslint-disable-next-line complexity
|
|
36
36
|
const decodePoolRecord = (a, { functionName, pointArg, numberPointArg, numberArg, setterArg }) => {
|
|
37
37
|
let res = a;
|
|
38
|
+
// eslint-disable-next-line default-case
|
|
38
39
|
switch (functionName) {
|
|
39
40
|
case LoopFunctions.getTileFromCoords:
|
|
40
41
|
res = (k) => a(k)
|
|
@@ -148,11 +149,11 @@ const decodePoolRecord = (a, { functionName, pointArg, numberPointArg, numberArg
|
|
|
148
149
|
res = (k) => a(k)
|
|
149
150
|
.flipVertically(numberPointArg);
|
|
150
151
|
break;
|
|
151
|
-
default:
|
|
152
152
|
}
|
|
153
153
|
return res;
|
|
154
154
|
};
|
|
155
155
|
class DPolygonLoop {
|
|
156
|
+
// eslint-disable-next-line no-empty-function,no-useless-constructor
|
|
156
157
|
constructor(parent) {
|
|
157
158
|
this.parent = parent;
|
|
158
159
|
this.pool = [];
|
|
@@ -166,6 +167,9 @@ class DPolygonLoop {
|
|
|
166
167
|
run() {
|
|
167
168
|
return this.parent.map(this.getLoopFunction());
|
|
168
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* @param zoom default value would be `z` of point
|
|
172
|
+
*/
|
|
169
173
|
getTileFromCoords(zoom) {
|
|
170
174
|
this.pool.push({
|
|
171
175
|
functionName: LoopFunctions.getTileFromCoords,
|
|
@@ -173,6 +177,9 @@ class DPolygonLoop {
|
|
|
173
177
|
});
|
|
174
178
|
return this;
|
|
175
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* @param zoom default value would be `z` of point
|
|
182
|
+
*/
|
|
176
183
|
getCoordsFromTile(zoom) {
|
|
177
184
|
this.pool.push({
|
|
178
185
|
functionName: LoopFunctions.getCoordsFromTile,
|
|
@@ -208,7 +215,7 @@ class DPolygonLoop {
|
|
|
208
215
|
});
|
|
209
216
|
return this;
|
|
210
217
|
}
|
|
211
|
-
move(x
|
|
218
|
+
move(x, y = x) {
|
|
212
219
|
this.pool.push({
|
|
213
220
|
functionName: LoopFunctions.move,
|
|
214
221
|
numberPointArg: x,
|
|
@@ -247,7 +254,7 @@ class DPolygonLoop {
|
|
|
247
254
|
});
|
|
248
255
|
return this;
|
|
249
256
|
}
|
|
250
|
-
scale(x
|
|
257
|
+
scale(x, y = x) {
|
|
251
258
|
this.pool.push({
|
|
252
259
|
functionName: LoopFunctions.scale,
|
|
253
260
|
numberPointArg: x,
|
|
@@ -255,7 +262,7 @@ class DPolygonLoop {
|
|
|
255
262
|
});
|
|
256
263
|
return this;
|
|
257
264
|
}
|
|
258
|
-
divide(x
|
|
265
|
+
divide(x, y) {
|
|
259
266
|
this.pool.push({
|
|
260
267
|
functionName: LoopFunctions.divide,
|
|
261
268
|
numberPointArg: x,
|
package/dist/TraceMatrix.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ export declare enum TraceMatrixValues {
|
|
|
6
6
|
}
|
|
7
7
|
declare type SimpleMatrix = TraceMatrixValues[][];
|
|
8
8
|
export declare class TraceMatrix {
|
|
9
|
-
private readonly m;
|
|
10
9
|
private readonly size;
|
|
10
|
+
private readonly m;
|
|
11
11
|
constructor(size: DPoint, f: (p: DPoint) => TraceMatrixValues);
|
|
12
12
|
fullMatrixTrace(): DPolygon[];
|
|
13
13
|
private reverseMatrix;
|
package/dist/TraceMatrix.js
CHANGED
|
@@ -4,10 +4,7 @@ exports.TraceMatrix = exports.TraceMatrixValues = void 0;
|
|
|
4
4
|
const DPoint_1 = require("./DPoint");
|
|
5
5
|
const DPolygon_1 = require("./DPolygon");
|
|
6
6
|
const FastSearch_1 = require("./FastSearch");
|
|
7
|
-
const
|
|
8
|
-
.join(' ')
|
|
9
|
-
.split('')
|
|
10
|
-
.map((r, i) => i);
|
|
7
|
+
const utils_1 = require("./utils");
|
|
11
8
|
var TraceMatrixValues;
|
|
12
9
|
(function (TraceMatrixValues) {
|
|
13
10
|
TraceMatrixValues[TraceMatrixValues["f"] = 0] = "f";
|
|
@@ -28,6 +25,7 @@ const setByPosition = (m, p, value) => {
|
|
|
28
25
|
};
|
|
29
26
|
class TraceMatrix {
|
|
30
27
|
constructor(size, f) {
|
|
28
|
+
this.size = size;
|
|
31
29
|
this.findGroupByIndex = (m, s) => {
|
|
32
30
|
const res = new DPolygon_1.DPolygon();
|
|
33
31
|
if (s && getByPosition(m, s) === TraceMatrixValues.t) {
|
|
@@ -149,7 +147,6 @@ class TraceMatrix {
|
|
|
149
147
|
const t = this.reverseMatrix(tmpMatrix);
|
|
150
148
|
return this.totalCountInMatrix(t) ? t : null;
|
|
151
149
|
};
|
|
152
|
-
this.size = size;
|
|
153
150
|
this.m = TraceMatrix.createMatrix(this.size, f);
|
|
154
151
|
}
|
|
155
152
|
fullMatrixTrace() {
|
|
@@ -201,7 +198,8 @@ class TraceMatrix {
|
|
|
201
198
|
return res;
|
|
202
199
|
}
|
|
203
200
|
static createMatrix(size, f = () => TraceMatrixValues.f) {
|
|
204
|
-
return
|
|
201
|
+
return (0, utils_1.createArray)(size.h)
|
|
202
|
+
.map((v, i) => (0, utils_1.createArray)(size.w).map((v2, j) => f(new DPoint_1.DPoint(j, i))));
|
|
205
203
|
}
|
|
206
204
|
}
|
|
207
205
|
exports.TraceMatrix = TraceMatrix;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -18,6 +18,7 @@ __exportStar(require("./DPoint"), exports);
|
|
|
18
18
|
__exportStar(require("./DPolygon"), exports);
|
|
19
19
|
__exportStar(require("./FastSearch"), exports);
|
|
20
20
|
__exportStar(require("./TraceMatrix"), exports);
|
|
21
|
+
__exportStar(require("./DPolygonLoop"), exports);
|
|
21
22
|
exports.DGeo = {
|
|
22
23
|
DEBUG: false
|
|
23
24
|
};
|
package/dist/utils.d.ts
CHANGED
package/dist/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkFunction = exports.warn = void 0;
|
|
3
|
+
exports.createArray = exports.checkFunction = exports.warn = void 0;
|
|
4
4
|
const index_1 = require("./index");
|
|
5
5
|
const DPoint_1 = require("./DPoint");
|
|
6
6
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -21,7 +21,7 @@ const shouldBeInt = (scope, funcName, argName) => (p) => {
|
|
|
21
21
|
};
|
|
22
22
|
const shouldBeUInt = (scope, funcName, argName) => (p) => {
|
|
23
23
|
if (!p.clone().round()
|
|
24
|
-
.equal(p) || !p.gtOrEqual(DPoint_1.DPoint.
|
|
24
|
+
.equal(p) || !p.gtOrEqual(DPoint_1.DPoint.zero())) {
|
|
25
25
|
(0, exports.warn)(`"${funcName}" -> "${argName}" should be UInt!`);
|
|
26
26
|
}
|
|
27
27
|
return scope;
|
|
@@ -66,3 +66,5 @@ const checkFunction = (funcName) => ({
|
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
68
|
exports.checkFunction = checkFunction;
|
|
69
|
+
const createArray = (v) => new Array(v).fill(0);
|
|
70
|
+
exports.createArray = createArray;
|
package/package.json
CHANGED