dgeoutils 2.0.2 → 2.2.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.
- package/dist/DCircle.d.ts +20 -0
- package/dist/DCircle.js +21 -1
- package/dist/DLine.d.ts +10 -2
- package/dist/DLine.js +28 -2
- package/dist/DPoint.d.ts +31 -19
- package/dist/DPoint.js +78 -57
- package/dist/DPolygon.d.ts +61 -9
- package/dist/DPolygon.js +176 -88
- package/dist/DPolygonLoop.d.ts +14 -5
- package/dist/DPolygonLoop.js +278 -60
- package/dist/TraceMatrix.js +4 -4
- package/package.json +1 -1
package/dist/DPolygonLoop.js
CHANGED
|
@@ -1,135 +1,353 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DPolygonLoop = void 0;
|
|
4
|
-
|
|
4
|
+
var LoopFunctions;
|
|
5
|
+
(function (LoopFunctions) {
|
|
6
|
+
LoopFunctions[LoopFunctions["getTileFromCoords"] = 0] = "getTileFromCoords";
|
|
7
|
+
LoopFunctions[LoopFunctions["getCoordsFromTile"] = 1] = "getCoordsFromTile";
|
|
8
|
+
LoopFunctions[LoopFunctions["height"] = 2] = "height";
|
|
9
|
+
LoopFunctions[LoopFunctions["setX"] = 3] = "setX";
|
|
10
|
+
LoopFunctions[LoopFunctions["setY"] = 4] = "setY";
|
|
11
|
+
LoopFunctions[LoopFunctions["rotate"] = 5] = "rotate";
|
|
12
|
+
LoopFunctions[LoopFunctions["move"] = 6] = "move";
|
|
13
|
+
LoopFunctions[LoopFunctions["round"] = 7] = "round";
|
|
14
|
+
LoopFunctions[LoopFunctions["ceil"] = 8] = "ceil";
|
|
15
|
+
LoopFunctions[LoopFunctions["floor"] = 9] = "floor";
|
|
16
|
+
LoopFunctions[LoopFunctions["toFixed"] = 10] = "toFixed";
|
|
17
|
+
LoopFunctions[LoopFunctions["abs"] = 11] = "abs";
|
|
18
|
+
LoopFunctions[LoopFunctions["scale"] = 12] = "scale";
|
|
19
|
+
LoopFunctions[LoopFunctions["divide"] = 13] = "divide";
|
|
20
|
+
LoopFunctions[LoopFunctions["degreeToRadians"] = 14] = "degreeToRadians";
|
|
21
|
+
LoopFunctions[LoopFunctions["radiansToDegrees"] = 15] = "radiansToDegrees";
|
|
22
|
+
LoopFunctions[LoopFunctions["radiansToMeters"] = 16] = "radiansToMeters";
|
|
23
|
+
LoopFunctions[LoopFunctions["metersToRadians"] = 17] = "metersToRadians";
|
|
24
|
+
LoopFunctions[LoopFunctions["hipPoint"] = 18] = "hipPoint";
|
|
25
|
+
LoopFunctions[LoopFunctions["xPoint"] = 19] = "xPoint";
|
|
26
|
+
LoopFunctions[LoopFunctions["yPoint"] = 20] = "yPoint";
|
|
27
|
+
LoopFunctions[LoopFunctions["wPoint"] = 21] = "wPoint";
|
|
28
|
+
LoopFunctions[LoopFunctions["hPoint"] = 22] = "hPoint";
|
|
29
|
+
LoopFunctions[LoopFunctions["setIfLessThan"] = 23] = "setIfLessThan";
|
|
30
|
+
LoopFunctions[LoopFunctions["minus"] = 24] = "minus";
|
|
31
|
+
LoopFunctions[LoopFunctions["degreeToMeters"] = 25] = "degreeToMeters";
|
|
32
|
+
LoopFunctions[LoopFunctions["metersToDegree"] = 26] = "metersToDegree";
|
|
33
|
+
LoopFunctions[LoopFunctions["flipVertically"] = 27] = "flipVertically";
|
|
34
|
+
})(LoopFunctions || (LoopFunctions = {}));
|
|
35
|
+
// eslint-disable-next-line complexity
|
|
36
|
+
const decodePoolRecord = (a, { functionName, pointArg, numberPointArg, numberArg, setterArg }) => {
|
|
37
|
+
let res = a;
|
|
38
|
+
switch (functionName) {
|
|
39
|
+
case LoopFunctions.getTileFromCoords:
|
|
40
|
+
res = (k) => a(k)
|
|
41
|
+
.getTileFromCoords(numberArg);
|
|
42
|
+
break;
|
|
43
|
+
case LoopFunctions.getCoordsFromTile:
|
|
44
|
+
res = (k) => a(k)
|
|
45
|
+
.getCoordsFromTile(numberArg);
|
|
46
|
+
break;
|
|
47
|
+
case LoopFunctions.height:
|
|
48
|
+
res = (k) => a(k)
|
|
49
|
+
.height(numberArg);
|
|
50
|
+
break;
|
|
51
|
+
case LoopFunctions.setX:
|
|
52
|
+
res = (k) => a(k)
|
|
53
|
+
.setX(setterArg);
|
|
54
|
+
break;
|
|
55
|
+
case LoopFunctions.setY:
|
|
56
|
+
res = (k) => a(k)
|
|
57
|
+
.setY(setterArg);
|
|
58
|
+
break;
|
|
59
|
+
case LoopFunctions.rotate:
|
|
60
|
+
res = (k) => a(k)
|
|
61
|
+
.rotate(numberArg);
|
|
62
|
+
break;
|
|
63
|
+
case LoopFunctions.move:
|
|
64
|
+
res = (k) => a(k)
|
|
65
|
+
.move(numberPointArg, numberArg);
|
|
66
|
+
break;
|
|
67
|
+
case LoopFunctions.round:
|
|
68
|
+
res = (k) => a(k)
|
|
69
|
+
.round();
|
|
70
|
+
break;
|
|
71
|
+
case LoopFunctions.ceil:
|
|
72
|
+
res = (k) => a(k)
|
|
73
|
+
.ceil();
|
|
74
|
+
break;
|
|
75
|
+
case LoopFunctions.floor:
|
|
76
|
+
res = (k) => a(k)
|
|
77
|
+
.floor();
|
|
78
|
+
break;
|
|
79
|
+
case LoopFunctions.toFixed:
|
|
80
|
+
res = (k) => a(k)
|
|
81
|
+
.toFixed(numberArg);
|
|
82
|
+
break;
|
|
83
|
+
case LoopFunctions.abs:
|
|
84
|
+
res = (k) => a(k)
|
|
85
|
+
.abs();
|
|
86
|
+
break;
|
|
87
|
+
case LoopFunctions.scale:
|
|
88
|
+
res = (k) => a(k)
|
|
89
|
+
.scale(numberPointArg, numberArg);
|
|
90
|
+
break;
|
|
91
|
+
case LoopFunctions.divide:
|
|
92
|
+
res = (k) => a(k)
|
|
93
|
+
.divide(numberPointArg, numberArg);
|
|
94
|
+
break;
|
|
95
|
+
case LoopFunctions.degreeToRadians:
|
|
96
|
+
res = (k) => a(k)
|
|
97
|
+
.degreeToRadians();
|
|
98
|
+
break;
|
|
99
|
+
case LoopFunctions.radiansToDegrees:
|
|
100
|
+
res = (k) => a(k)
|
|
101
|
+
.radiansToDegrees();
|
|
102
|
+
break;
|
|
103
|
+
case LoopFunctions.radiansToMeters:
|
|
104
|
+
res = (k) => a(k)
|
|
105
|
+
.radiansToMeters();
|
|
106
|
+
break;
|
|
107
|
+
case LoopFunctions.metersToRadians:
|
|
108
|
+
res = (k) => a(k)
|
|
109
|
+
.metersToRadians();
|
|
110
|
+
break;
|
|
111
|
+
case LoopFunctions.hipPoint:
|
|
112
|
+
res = (k) => a(k)
|
|
113
|
+
.hipPoint;
|
|
114
|
+
break;
|
|
115
|
+
case LoopFunctions.xPoint:
|
|
116
|
+
res = (k) => a(k)
|
|
117
|
+
.xPoint;
|
|
118
|
+
break;
|
|
119
|
+
case LoopFunctions.yPoint:
|
|
120
|
+
res = (k) => a(k)
|
|
121
|
+
.yPoint;
|
|
122
|
+
break;
|
|
123
|
+
case LoopFunctions.wPoint:
|
|
124
|
+
res = (k) => a(k)
|
|
125
|
+
.wPoint;
|
|
126
|
+
break;
|
|
127
|
+
case LoopFunctions.hPoint:
|
|
128
|
+
res = (k) => a(k)
|
|
129
|
+
.hPoint;
|
|
130
|
+
break;
|
|
131
|
+
case LoopFunctions.setIfLessThan:
|
|
132
|
+
res = (k) => a(k)
|
|
133
|
+
.setIfLessThan(pointArg);
|
|
134
|
+
break;
|
|
135
|
+
case LoopFunctions.minus:
|
|
136
|
+
res = (k) => a(k)
|
|
137
|
+
.minus();
|
|
138
|
+
break;
|
|
139
|
+
case LoopFunctions.degreeToMeters:
|
|
140
|
+
res = (k) => a(k)
|
|
141
|
+
.degreeToMeters();
|
|
142
|
+
break;
|
|
143
|
+
case LoopFunctions.metersToDegree:
|
|
144
|
+
res = (k) => a(k)
|
|
145
|
+
.metersToDegree();
|
|
146
|
+
break;
|
|
147
|
+
case LoopFunctions.flipVertically:
|
|
148
|
+
res = (k) => a(k)
|
|
149
|
+
.flipVertically(numberPointArg);
|
|
150
|
+
break;
|
|
151
|
+
default:
|
|
152
|
+
}
|
|
153
|
+
return res;
|
|
154
|
+
};
|
|
5
155
|
class DPolygonLoop {
|
|
6
156
|
constructor(parent) {
|
|
7
|
-
this.f = (k) => k;
|
|
8
157
|
this.parent = parent;
|
|
158
|
+
this.pool = [];
|
|
159
|
+
}
|
|
160
|
+
getLoopFunction() {
|
|
161
|
+
return this.pool.reduce(decodePoolRecord, (k) => k);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Run loop
|
|
165
|
+
*/
|
|
166
|
+
run() {
|
|
167
|
+
return this.parent.map(this.getLoopFunction());
|
|
9
168
|
}
|
|
10
169
|
getTileFromCoords(zoom) {
|
|
11
|
-
|
|
12
|
-
|
|
170
|
+
this.pool.push({
|
|
171
|
+
functionName: LoopFunctions.getTileFromCoords,
|
|
172
|
+
numberArg: zoom
|
|
173
|
+
});
|
|
13
174
|
return this;
|
|
14
175
|
}
|
|
15
176
|
getCoordsFromTile(zoom) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
transform(from = DPoint_1.PSEUDO_MERCATOR, to = DPoint_1.WORLD_GEODETIC_SYSTEM) {
|
|
21
|
-
const t = this.f.bind(null);
|
|
22
|
-
this.f = (k) => t(k).transform(from, to);
|
|
177
|
+
this.pool.push({
|
|
178
|
+
functionName: LoopFunctions.getCoordsFromTile,
|
|
179
|
+
numberArg: zoom
|
|
180
|
+
});
|
|
23
181
|
return this;
|
|
24
182
|
}
|
|
25
183
|
height(z) {
|
|
26
|
-
|
|
27
|
-
|
|
184
|
+
this.pool.push({
|
|
185
|
+
functionName: LoopFunctions.height,
|
|
186
|
+
numberArg: z
|
|
187
|
+
});
|
|
28
188
|
return this;
|
|
29
189
|
}
|
|
30
190
|
setX(x) {
|
|
31
|
-
|
|
32
|
-
|
|
191
|
+
this.pool.push({
|
|
192
|
+
functionName: LoopFunctions.setX,
|
|
193
|
+
setterArg: x
|
|
194
|
+
});
|
|
33
195
|
return this;
|
|
34
196
|
}
|
|
35
197
|
setY(y) {
|
|
36
|
-
|
|
37
|
-
|
|
198
|
+
this.pool.push({
|
|
199
|
+
functionName: LoopFunctions.setY,
|
|
200
|
+
setterArg: y
|
|
201
|
+
});
|
|
38
202
|
return this;
|
|
39
203
|
}
|
|
40
204
|
rotate(a) {
|
|
41
|
-
|
|
42
|
-
|
|
205
|
+
this.pool.push({
|
|
206
|
+
functionName: LoopFunctions.rotate,
|
|
207
|
+
numberArg: a
|
|
208
|
+
});
|
|
43
209
|
return this;
|
|
44
210
|
}
|
|
45
|
-
move(x = 0, y) {
|
|
46
|
-
|
|
47
|
-
|
|
211
|
+
move(x = 0, y = x) {
|
|
212
|
+
this.pool.push({
|
|
213
|
+
functionName: LoopFunctions.move,
|
|
214
|
+
numberPointArg: x,
|
|
215
|
+
numberArg: y
|
|
216
|
+
});
|
|
48
217
|
return this;
|
|
49
218
|
}
|
|
50
219
|
round() {
|
|
51
|
-
|
|
52
|
-
|
|
220
|
+
this.pool.push({
|
|
221
|
+
functionName: LoopFunctions.round
|
|
222
|
+
});
|
|
53
223
|
return this;
|
|
54
224
|
}
|
|
55
225
|
ceil() {
|
|
56
|
-
|
|
57
|
-
|
|
226
|
+
this.pool.push({
|
|
227
|
+
functionName: LoopFunctions.ceil
|
|
228
|
+
});
|
|
58
229
|
return this;
|
|
59
230
|
}
|
|
60
231
|
floor() {
|
|
61
|
-
|
|
62
|
-
|
|
232
|
+
this.pool.push({
|
|
233
|
+
functionName: LoopFunctions.floor
|
|
234
|
+
});
|
|
63
235
|
return this;
|
|
64
236
|
}
|
|
65
237
|
toFixed(n = 2) {
|
|
66
|
-
|
|
67
|
-
|
|
238
|
+
this.pool.push({
|
|
239
|
+
functionName: LoopFunctions.toFixed,
|
|
240
|
+
numberArg: n
|
|
241
|
+
});
|
|
68
242
|
return this;
|
|
69
243
|
}
|
|
70
244
|
abs() {
|
|
71
|
-
|
|
72
|
-
|
|
245
|
+
this.pool.push({
|
|
246
|
+
functionName: LoopFunctions.abs
|
|
247
|
+
});
|
|
73
248
|
return this;
|
|
74
249
|
}
|
|
75
|
-
scale(x = 0, y) {
|
|
76
|
-
|
|
77
|
-
|
|
250
|
+
scale(x = 0, y = x) {
|
|
251
|
+
this.pool.push({
|
|
252
|
+
functionName: LoopFunctions.scale,
|
|
253
|
+
numberPointArg: x,
|
|
254
|
+
numberArg: y
|
|
255
|
+
});
|
|
78
256
|
return this;
|
|
79
257
|
}
|
|
80
258
|
divide(x = 0, y) {
|
|
81
|
-
|
|
82
|
-
|
|
259
|
+
this.pool.push({
|
|
260
|
+
functionName: LoopFunctions.divide,
|
|
261
|
+
numberPointArg: x,
|
|
262
|
+
numberArg: y
|
|
263
|
+
});
|
|
264
|
+
return this;
|
|
265
|
+
}
|
|
266
|
+
degreeToRadians() {
|
|
267
|
+
this.pool.push({
|
|
268
|
+
functionName: LoopFunctions.degreeToRadians
|
|
269
|
+
});
|
|
83
270
|
return this;
|
|
84
271
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
272
|
+
radiansToDegrees() {
|
|
273
|
+
this.pool.push({
|
|
274
|
+
functionName: LoopFunctions.radiansToDegrees
|
|
275
|
+
});
|
|
88
276
|
return this;
|
|
89
277
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
278
|
+
radiansToMeters() {
|
|
279
|
+
this.pool.push({
|
|
280
|
+
functionName: LoopFunctions.radiansToMeters
|
|
281
|
+
});
|
|
282
|
+
return this;
|
|
283
|
+
}
|
|
284
|
+
metersToRadians() {
|
|
285
|
+
this.pool.push({
|
|
286
|
+
functionName: LoopFunctions.metersToRadians
|
|
287
|
+
});
|
|
93
288
|
return this;
|
|
94
289
|
}
|
|
95
290
|
getHipPoint() {
|
|
96
|
-
|
|
97
|
-
|
|
291
|
+
this.pool.push({
|
|
292
|
+
functionName: LoopFunctions.hipPoint
|
|
293
|
+
});
|
|
98
294
|
return this;
|
|
99
295
|
}
|
|
100
296
|
getXPoint() {
|
|
101
|
-
|
|
102
|
-
|
|
297
|
+
this.pool.push({
|
|
298
|
+
functionName: LoopFunctions.xPoint
|
|
299
|
+
});
|
|
103
300
|
return this;
|
|
104
301
|
}
|
|
105
302
|
getYPoint() {
|
|
106
|
-
|
|
107
|
-
|
|
303
|
+
this.pool.push({
|
|
304
|
+
functionName: LoopFunctions.yPoint
|
|
305
|
+
});
|
|
108
306
|
return this;
|
|
109
307
|
}
|
|
110
308
|
getWPoint() {
|
|
111
|
-
|
|
112
|
-
|
|
309
|
+
this.pool.push({
|
|
310
|
+
functionName: LoopFunctions.wPoint
|
|
311
|
+
});
|
|
113
312
|
return this;
|
|
114
313
|
}
|
|
115
314
|
getHPoint() {
|
|
116
|
-
|
|
117
|
-
|
|
315
|
+
this.pool.push({
|
|
316
|
+
functionName: LoopFunctions.hPoint
|
|
317
|
+
});
|
|
118
318
|
return this;
|
|
119
319
|
}
|
|
120
320
|
setIfLessThan(p) {
|
|
121
|
-
|
|
122
|
-
|
|
321
|
+
this.pool.push({
|
|
322
|
+
functionName: LoopFunctions.setIfLessThan,
|
|
323
|
+
pointArg: p
|
|
324
|
+
});
|
|
123
325
|
return this;
|
|
124
326
|
}
|
|
125
327
|
minus() {
|
|
126
|
-
|
|
127
|
-
|
|
328
|
+
this.pool.push({
|
|
329
|
+
functionName: LoopFunctions.minus
|
|
330
|
+
});
|
|
128
331
|
return this;
|
|
129
332
|
}
|
|
130
|
-
|
|
131
|
-
this.
|
|
132
|
-
|
|
333
|
+
degreeToMeters() {
|
|
334
|
+
this.pool.push({
|
|
335
|
+
functionName: LoopFunctions.degreeToMeters
|
|
336
|
+
});
|
|
337
|
+
return this;
|
|
338
|
+
}
|
|
339
|
+
metersToDegree() {
|
|
340
|
+
this.pool.push({
|
|
341
|
+
functionName: LoopFunctions.metersToDegree
|
|
342
|
+
});
|
|
343
|
+
return this;
|
|
344
|
+
}
|
|
345
|
+
flipVertically(size) {
|
|
346
|
+
this.pool.push({
|
|
347
|
+
functionName: LoopFunctions.flipVertically,
|
|
348
|
+
numberPointArg: size
|
|
349
|
+
});
|
|
350
|
+
return this;
|
|
133
351
|
}
|
|
134
352
|
}
|
|
135
353
|
exports.DPolygonLoop = DPolygonLoop;
|
package/dist/TraceMatrix.js
CHANGED
|
@@ -36,7 +36,7 @@ class TraceMatrix {
|
|
|
36
36
|
const marked = TraceMatrix.createMatrix(this.size, () => TraceMatrixValues.f);
|
|
37
37
|
setByPosition(marked, s, TraceMatrixValues.t);
|
|
38
38
|
while (startIndex < res.length) {
|
|
39
|
-
const r = res.
|
|
39
|
+
const r = res.at(startIndex);
|
|
40
40
|
for (let i = -1; i < 2; i++) {
|
|
41
41
|
for (let j = -1; j < 2; j++) {
|
|
42
42
|
const t = new DPoint_1.DPoint(r.x + i, r.y + j);
|
|
@@ -90,14 +90,14 @@ class TraceMatrix {
|
|
|
90
90
|
const left = (d) => (d + traceDirections.length + 1) % traceDirections.length;
|
|
91
91
|
const right = (d) => (d + traceDirections.length - 1) % traceDirections.length;
|
|
92
92
|
if (group.length < 2) {
|
|
93
|
-
const t = group.
|
|
93
|
+
const t = group.at(0).clone();
|
|
94
94
|
return new DPolygon_1.DPolygon([t, t, t]);
|
|
95
95
|
}
|
|
96
96
|
const points = new DPolygon_1.DPolygon();
|
|
97
97
|
let direction = 0;
|
|
98
98
|
let prevDirection = Infinity;
|
|
99
|
-
let p = group.
|
|
100
|
-
while (!p.equal(group.
|
|
99
|
+
let p = group.at(0);
|
|
100
|
+
while (!p.equal(group.at(0)) || points.length < 2) {
|
|
101
101
|
// eslint-disable-next-line no-constant-condition
|
|
102
102
|
while (true) {
|
|
103
103
|
const nextValue = getByPosition(m, p.clone().move(traceDirections[direction]));
|