dgeoutils 2.4.48 → 2.5.0
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/cjs/DCircle.d.ts +18 -0
- package/dist/cjs/DCircle.js +102 -0
- package/dist/cjs/DLine.d.ts +39 -0
- package/dist/cjs/DLine.js +343 -0
- package/dist/cjs/DNumbers.d.ts +8 -0
- package/dist/cjs/DNumbers.js +30 -0
- package/dist/cjs/DPlane.d.ts +25 -0
- package/dist/cjs/DPlane.js +132 -0
- package/dist/cjs/DPoint.d.ts +139 -0
- package/dist/cjs/DPoint.js +820 -0
- package/dist/cjs/DPolygon.d.ts +139 -0
- package/dist/cjs/DPolygon.js +1774 -0
- package/dist/cjs/DPolygonLoop.d.ts +60 -0
- package/dist/cjs/DPolygonLoop.js +439 -0
- package/dist/cjs/FastSearch.d.ts +6 -0
- package/dist/cjs/FastSearch.js +53 -0
- package/dist/cjs/InterpolationMatrix.d.ts +24 -0
- package/dist/cjs/InterpolationMatrix.js +173 -0
- package/dist/cjs/TraceMatrix.d.ts +22 -0
- package/dist/cjs/TraceMatrix.js +285 -0
- package/dist/cjs/index.d.ts +11 -0
- package/dist/cjs/index.js +37 -0
- package/dist/cjs/utils.d.ts +49 -0
- package/dist/cjs/utils.js +281 -0
- package/dist/es2015/DCircle.js +87 -0
- package/dist/es2015/DLine.js +290 -0
- package/dist/es2015/DNumbers.js +22 -0
- package/dist/es2015/DPlane.js +105 -0
- package/dist/es2015/DPoint.js +693 -0
- package/dist/es2015/DPolygon.js +1203 -0
- package/dist/es2015/DPolygonLoop.js +430 -0
- package/dist/es2015/FastSearch.js +25 -0
- package/dist/es2015/InterpolationMatrix.js +128 -0
- package/dist/es2015/TraceMatrix.js +229 -0
- package/dist/es2015/index.js +11 -0
- package/dist/es2015/utils.js +208 -0
- package/dist/esm/DCircle.js +99 -0
- package/dist/esm/DLine.js +340 -0
- package/dist/esm/DNumbers.js +27 -0
- package/dist/esm/DPlane.js +129 -0
- package/dist/esm/DPoint.js +817 -0
- package/dist/esm/DPolygon.js +1771 -0
- package/dist/esm/DPolygonLoop.js +436 -0
- package/dist/esm/FastSearch.js +50 -0
- package/dist/esm/InterpolationMatrix.js +170 -0
- package/dist/esm/TraceMatrix.js +282 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/utils.js +266 -0
- package/dist/umd/dgeoutils.js +4394 -0
- package/dist/umd/dgeoutils.min.js +1 -0
- package/dist/umd/dgeoutils.min.js.map +1 -0
- package/package.json +9 -1
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
var LoopFunctions;
|
|
2
|
+
(function (LoopFunctions) {
|
|
3
|
+
LoopFunctions[LoopFunctions["getTileFromCoords"] = 0] = "getTileFromCoords";
|
|
4
|
+
LoopFunctions[LoopFunctions["getCoordsFromTile"] = 1] = "getCoordsFromTile";
|
|
5
|
+
LoopFunctions[LoopFunctions["height"] = 2] = "height";
|
|
6
|
+
LoopFunctions[LoopFunctions["setX"] = 3] = "setX";
|
|
7
|
+
LoopFunctions[LoopFunctions["setY"] = 4] = "setY";
|
|
8
|
+
LoopFunctions[LoopFunctions["setZ"] = 5] = "setZ";
|
|
9
|
+
LoopFunctions[LoopFunctions["rotate"] = 6] = "rotate";
|
|
10
|
+
LoopFunctions[LoopFunctions["rotate3dX"] = 7] = "rotate3dX";
|
|
11
|
+
LoopFunctions[LoopFunctions["rotate3dY"] = 8] = "rotate3dY";
|
|
12
|
+
LoopFunctions[LoopFunctions["rotate3dZ"] = 9] = "rotate3dZ";
|
|
13
|
+
LoopFunctions[LoopFunctions["move"] = 10] = "move";
|
|
14
|
+
LoopFunctions[LoopFunctions["round"] = 11] = "round";
|
|
15
|
+
LoopFunctions[LoopFunctions["ceil"] = 12] = "ceil";
|
|
16
|
+
LoopFunctions[LoopFunctions["floor"] = 13] = "floor";
|
|
17
|
+
LoopFunctions[LoopFunctions["toFixed"] = 14] = "toFixed";
|
|
18
|
+
LoopFunctions[LoopFunctions["abs"] = 15] = "abs";
|
|
19
|
+
LoopFunctions[LoopFunctions["scale"] = 16] = "scale";
|
|
20
|
+
LoopFunctions[LoopFunctions["divide"] = 17] = "divide";
|
|
21
|
+
LoopFunctions[LoopFunctions["degreeToRadians"] = 18] = "degreeToRadians";
|
|
22
|
+
LoopFunctions[LoopFunctions["radiansToDegrees"] = 19] = "radiansToDegrees";
|
|
23
|
+
LoopFunctions[LoopFunctions["radiansToMeters"] = 20] = "radiansToMeters";
|
|
24
|
+
LoopFunctions[LoopFunctions["metersToRadians"] = 21] = "metersToRadians";
|
|
25
|
+
LoopFunctions[LoopFunctions["hipPoint"] = 22] = "hipPoint";
|
|
26
|
+
LoopFunctions[LoopFunctions["xPoint"] = 23] = "xPoint";
|
|
27
|
+
LoopFunctions[LoopFunctions["yPoint"] = 24] = "yPoint";
|
|
28
|
+
LoopFunctions[LoopFunctions["wPoint"] = 25] = "wPoint";
|
|
29
|
+
LoopFunctions[LoopFunctions["hPoint"] = 26] = "hPoint";
|
|
30
|
+
LoopFunctions[LoopFunctions["setIfLessThan"] = 27] = "setIfLessThan";
|
|
31
|
+
LoopFunctions[LoopFunctions["minus"] = 28] = "minus";
|
|
32
|
+
LoopFunctions[LoopFunctions["degreeToMeters"] = 29] = "degreeToMeters";
|
|
33
|
+
LoopFunctions[LoopFunctions["metersToDegree"] = 30] = "metersToDegree";
|
|
34
|
+
LoopFunctions[LoopFunctions["flipVertically"] = 31] = "flipVertically";
|
|
35
|
+
LoopFunctions[LoopFunctions["setProperties"] = 32] = "setProperties";
|
|
36
|
+
LoopFunctions[LoopFunctions["div"] = 33] = "div";
|
|
37
|
+
LoopFunctions[LoopFunctions["mod"] = 34] = "mod";
|
|
38
|
+
})(LoopFunctions || (LoopFunctions = {}));
|
|
39
|
+
const decodePoolRecord = (a, { functionName, pointArg, numberPointArg, numberArg, setterArg, setterArgByObject }) => {
|
|
40
|
+
let res = a;
|
|
41
|
+
switch (functionName) {
|
|
42
|
+
case LoopFunctions.getTileFromCoords:
|
|
43
|
+
res = (k, index) => a(k, index)
|
|
44
|
+
.getTileFromCoords(numberArg);
|
|
45
|
+
break;
|
|
46
|
+
case LoopFunctions.getCoordsFromTile:
|
|
47
|
+
res = (k, index) => a(k, index)
|
|
48
|
+
.getCoordsFromTile(numberArg);
|
|
49
|
+
break;
|
|
50
|
+
case LoopFunctions.height:
|
|
51
|
+
res = (k, index) => a(k, index)
|
|
52
|
+
.height(numberArg);
|
|
53
|
+
break;
|
|
54
|
+
case LoopFunctions.setX:
|
|
55
|
+
res = (k, index) => typeof setterArg === 'number' ? a(k, index)
|
|
56
|
+
.setX(setterArg) : a(k, index).setX((p) => setterArg(p, index));
|
|
57
|
+
break;
|
|
58
|
+
case LoopFunctions.setY:
|
|
59
|
+
res = (k, index) => typeof setterArg === 'number' ? a(k, index)
|
|
60
|
+
.setY(setterArg) : a(k, index).setY((p) => setterArg(p, index));
|
|
61
|
+
break;
|
|
62
|
+
case LoopFunctions.setZ:
|
|
63
|
+
res = (k, index) => typeof setterArg === 'number' ? a(k, index)
|
|
64
|
+
.setZ(setterArg) : a(k, index).setZ((p) => setterArg(p, index));
|
|
65
|
+
break;
|
|
66
|
+
case LoopFunctions.rotate:
|
|
67
|
+
res = (k, index) => a(k, index)
|
|
68
|
+
.rotate(numberArg);
|
|
69
|
+
break;
|
|
70
|
+
case LoopFunctions.rotate3dX:
|
|
71
|
+
res = (k, index) => a(k, index)
|
|
72
|
+
.rotate3dX(numberArg);
|
|
73
|
+
break;
|
|
74
|
+
case LoopFunctions.rotate3dY:
|
|
75
|
+
res = (k, index) => a(k, index)
|
|
76
|
+
.rotate3dY(numberArg);
|
|
77
|
+
break;
|
|
78
|
+
case LoopFunctions.rotate3dZ:
|
|
79
|
+
res = (k, index) => a(k, index)
|
|
80
|
+
.rotate3dZ(numberArg);
|
|
81
|
+
break;
|
|
82
|
+
case LoopFunctions.move:
|
|
83
|
+
res = (k, index) => a(k, index)
|
|
84
|
+
.move(numberPointArg, numberArg);
|
|
85
|
+
break;
|
|
86
|
+
case LoopFunctions.round:
|
|
87
|
+
res = (k, index) => a(k, index)
|
|
88
|
+
.round();
|
|
89
|
+
break;
|
|
90
|
+
case LoopFunctions.ceil:
|
|
91
|
+
res = (k, index) => a(k, index)
|
|
92
|
+
.ceil();
|
|
93
|
+
break;
|
|
94
|
+
case LoopFunctions.floor:
|
|
95
|
+
res = (k, index) => a(k, index)
|
|
96
|
+
.floor();
|
|
97
|
+
break;
|
|
98
|
+
case LoopFunctions.toFixed:
|
|
99
|
+
res = (k, index) => a(k, index)
|
|
100
|
+
.toFixed(numberArg);
|
|
101
|
+
break;
|
|
102
|
+
case LoopFunctions.abs:
|
|
103
|
+
res = (k, index) => a(k, index)
|
|
104
|
+
.abs();
|
|
105
|
+
break;
|
|
106
|
+
case LoopFunctions.scale:
|
|
107
|
+
res = (k, index) => a(k, index)
|
|
108
|
+
.scale(numberPointArg, numberArg);
|
|
109
|
+
break;
|
|
110
|
+
case LoopFunctions.divide:
|
|
111
|
+
res = (k, index) => a(k, index)
|
|
112
|
+
.divide(numberPointArg, numberArg);
|
|
113
|
+
break;
|
|
114
|
+
case LoopFunctions.div:
|
|
115
|
+
res = (k, index) => a(k, index)
|
|
116
|
+
.div(numberPointArg, numberArg);
|
|
117
|
+
break;
|
|
118
|
+
case LoopFunctions.mod:
|
|
119
|
+
res = (k, index) => a(k, index)
|
|
120
|
+
.mod(numberPointArg, numberArg);
|
|
121
|
+
break;
|
|
122
|
+
case LoopFunctions.degreeToRadians:
|
|
123
|
+
res = (k, index) => a(k, index)
|
|
124
|
+
.degreeToRadians();
|
|
125
|
+
break;
|
|
126
|
+
case LoopFunctions.radiansToDegrees:
|
|
127
|
+
res = (k, index) => a(k, index)
|
|
128
|
+
.radiansToDegrees();
|
|
129
|
+
break;
|
|
130
|
+
case LoopFunctions.radiansToMeters:
|
|
131
|
+
res = (k, index) => a(k, index)
|
|
132
|
+
.radiansToMeters();
|
|
133
|
+
break;
|
|
134
|
+
case LoopFunctions.metersToRadians:
|
|
135
|
+
res = (k, index) => a(k, index)
|
|
136
|
+
.metersToRadians();
|
|
137
|
+
break;
|
|
138
|
+
case LoopFunctions.hipPoint:
|
|
139
|
+
res = (k, index) => a(k, index)
|
|
140
|
+
.hipPoint;
|
|
141
|
+
break;
|
|
142
|
+
case LoopFunctions.xPoint:
|
|
143
|
+
res = (k, index) => a(k, index)
|
|
144
|
+
.xPoint;
|
|
145
|
+
break;
|
|
146
|
+
case LoopFunctions.yPoint:
|
|
147
|
+
res = (k, index) => a(k, index)
|
|
148
|
+
.yPoint;
|
|
149
|
+
break;
|
|
150
|
+
case LoopFunctions.wPoint:
|
|
151
|
+
res = (k, index) => a(k, index)
|
|
152
|
+
.wPoint;
|
|
153
|
+
break;
|
|
154
|
+
case LoopFunctions.hPoint:
|
|
155
|
+
res = (k, index) => a(k, index)
|
|
156
|
+
.hPoint;
|
|
157
|
+
break;
|
|
158
|
+
case LoopFunctions.setIfLessThan:
|
|
159
|
+
res = (k, index) => a(k, index)
|
|
160
|
+
.setIfLessThan(pointArg);
|
|
161
|
+
break;
|
|
162
|
+
case LoopFunctions.minus:
|
|
163
|
+
res = (k, index) => a(k, index)
|
|
164
|
+
.minus();
|
|
165
|
+
break;
|
|
166
|
+
case LoopFunctions.degreeToMeters:
|
|
167
|
+
res = (k, index) => a(k, index)
|
|
168
|
+
.degreeToMeters();
|
|
169
|
+
break;
|
|
170
|
+
case LoopFunctions.metersToDegree:
|
|
171
|
+
res = (k, index) => a(k, index)
|
|
172
|
+
.metersToDegree();
|
|
173
|
+
break;
|
|
174
|
+
case LoopFunctions.flipVertically:
|
|
175
|
+
res = (k, index) => a(k, index)
|
|
176
|
+
.flipVertically(numberPointArg);
|
|
177
|
+
break;
|
|
178
|
+
case LoopFunctions.setProperties:
|
|
179
|
+
res = (k, index) => typeof setterArgByObject === 'object' ? a(k, index)
|
|
180
|
+
.setProperties(setterArgByObject) : a(k, index).setProperties((p) => setterArgByObject(p, index));
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
return res;
|
|
184
|
+
};
|
|
185
|
+
export class DPolygonLoop {
|
|
186
|
+
constructor(parent) {
|
|
187
|
+
this.parent = parent;
|
|
188
|
+
this.pool = [];
|
|
189
|
+
}
|
|
190
|
+
getLoopFunction() {
|
|
191
|
+
return this.pool.reduce(decodePoolRecord, (k) => k);
|
|
192
|
+
}
|
|
193
|
+
run() {
|
|
194
|
+
return this.parent.map(this.getLoopFunction());
|
|
195
|
+
}
|
|
196
|
+
getTileFromCoords(zoom) {
|
|
197
|
+
this.pool.push({
|
|
198
|
+
functionName: LoopFunctions.getTileFromCoords,
|
|
199
|
+
numberArg: zoom
|
|
200
|
+
});
|
|
201
|
+
return this;
|
|
202
|
+
}
|
|
203
|
+
getCoordsFromTile(zoom) {
|
|
204
|
+
this.pool.push({
|
|
205
|
+
functionName: LoopFunctions.getCoordsFromTile,
|
|
206
|
+
numberArg: zoom
|
|
207
|
+
});
|
|
208
|
+
return this;
|
|
209
|
+
}
|
|
210
|
+
height(z) {
|
|
211
|
+
this.pool.push({
|
|
212
|
+
functionName: LoopFunctions.height,
|
|
213
|
+
numberArg: z
|
|
214
|
+
});
|
|
215
|
+
return this;
|
|
216
|
+
}
|
|
217
|
+
setX(x) {
|
|
218
|
+
this.pool.push({
|
|
219
|
+
functionName: LoopFunctions.setX,
|
|
220
|
+
setterArg: x
|
|
221
|
+
});
|
|
222
|
+
return this;
|
|
223
|
+
}
|
|
224
|
+
setProperties(setterArgByObject) {
|
|
225
|
+
this.pool.push({
|
|
226
|
+
functionName: LoopFunctions.setProperties,
|
|
227
|
+
setterArgByObject
|
|
228
|
+
});
|
|
229
|
+
return this;
|
|
230
|
+
}
|
|
231
|
+
setY(y) {
|
|
232
|
+
this.pool.push({
|
|
233
|
+
functionName: LoopFunctions.setY,
|
|
234
|
+
setterArg: y
|
|
235
|
+
});
|
|
236
|
+
return this;
|
|
237
|
+
}
|
|
238
|
+
setZ(z) {
|
|
239
|
+
this.pool.push({
|
|
240
|
+
functionName: LoopFunctions.setZ,
|
|
241
|
+
setterArg: z
|
|
242
|
+
});
|
|
243
|
+
return this;
|
|
244
|
+
}
|
|
245
|
+
rotate(a) {
|
|
246
|
+
this.pool.push({
|
|
247
|
+
functionName: LoopFunctions.rotate,
|
|
248
|
+
numberArg: a
|
|
249
|
+
});
|
|
250
|
+
return this;
|
|
251
|
+
}
|
|
252
|
+
rotate3dX(a) {
|
|
253
|
+
this.pool.push({
|
|
254
|
+
functionName: LoopFunctions.rotate3dX,
|
|
255
|
+
numberArg: a
|
|
256
|
+
});
|
|
257
|
+
return this;
|
|
258
|
+
}
|
|
259
|
+
rotate3dY(a) {
|
|
260
|
+
this.pool.push({
|
|
261
|
+
functionName: LoopFunctions.rotate3dY,
|
|
262
|
+
numberArg: a
|
|
263
|
+
});
|
|
264
|
+
return this;
|
|
265
|
+
}
|
|
266
|
+
rotate3dZ(a) {
|
|
267
|
+
this.pool.push({
|
|
268
|
+
functionName: LoopFunctions.rotate3dZ,
|
|
269
|
+
numberArg: a
|
|
270
|
+
});
|
|
271
|
+
return this;
|
|
272
|
+
}
|
|
273
|
+
move(x, y = x) {
|
|
274
|
+
this.pool.push({
|
|
275
|
+
functionName: LoopFunctions.move,
|
|
276
|
+
numberPointArg: x,
|
|
277
|
+
numberArg: y
|
|
278
|
+
});
|
|
279
|
+
return this;
|
|
280
|
+
}
|
|
281
|
+
round() {
|
|
282
|
+
this.pool.push({
|
|
283
|
+
functionName: LoopFunctions.round
|
|
284
|
+
});
|
|
285
|
+
return this;
|
|
286
|
+
}
|
|
287
|
+
ceil() {
|
|
288
|
+
this.pool.push({
|
|
289
|
+
functionName: LoopFunctions.ceil
|
|
290
|
+
});
|
|
291
|
+
return this;
|
|
292
|
+
}
|
|
293
|
+
floor() {
|
|
294
|
+
this.pool.push({
|
|
295
|
+
functionName: LoopFunctions.floor
|
|
296
|
+
});
|
|
297
|
+
return this;
|
|
298
|
+
}
|
|
299
|
+
toFixed(n = 2) {
|
|
300
|
+
this.pool.push({
|
|
301
|
+
functionName: LoopFunctions.toFixed,
|
|
302
|
+
numberArg: n
|
|
303
|
+
});
|
|
304
|
+
return this;
|
|
305
|
+
}
|
|
306
|
+
abs() {
|
|
307
|
+
this.pool.push({
|
|
308
|
+
functionName: LoopFunctions.abs
|
|
309
|
+
});
|
|
310
|
+
return this;
|
|
311
|
+
}
|
|
312
|
+
scale(x, y = x) {
|
|
313
|
+
this.pool.push({
|
|
314
|
+
functionName: LoopFunctions.scale,
|
|
315
|
+
numberPointArg: x,
|
|
316
|
+
numberArg: y
|
|
317
|
+
});
|
|
318
|
+
return this;
|
|
319
|
+
}
|
|
320
|
+
divide(x, y) {
|
|
321
|
+
this.pool.push({
|
|
322
|
+
functionName: LoopFunctions.divide,
|
|
323
|
+
numberPointArg: x,
|
|
324
|
+
numberArg: y
|
|
325
|
+
});
|
|
326
|
+
return this;
|
|
327
|
+
}
|
|
328
|
+
div(x, y) {
|
|
329
|
+
this.pool.push({
|
|
330
|
+
functionName: LoopFunctions.div,
|
|
331
|
+
numberPointArg: x,
|
|
332
|
+
numberArg: y
|
|
333
|
+
});
|
|
334
|
+
return this;
|
|
335
|
+
}
|
|
336
|
+
mod(x, y) {
|
|
337
|
+
this.pool.push({
|
|
338
|
+
functionName: LoopFunctions.mod,
|
|
339
|
+
numberPointArg: x,
|
|
340
|
+
numberArg: y
|
|
341
|
+
});
|
|
342
|
+
return this;
|
|
343
|
+
}
|
|
344
|
+
degreeToRadians() {
|
|
345
|
+
this.pool.push({
|
|
346
|
+
functionName: LoopFunctions.degreeToRadians
|
|
347
|
+
});
|
|
348
|
+
return this;
|
|
349
|
+
}
|
|
350
|
+
radiansToDegrees() {
|
|
351
|
+
this.pool.push({
|
|
352
|
+
functionName: LoopFunctions.radiansToDegrees
|
|
353
|
+
});
|
|
354
|
+
return this;
|
|
355
|
+
}
|
|
356
|
+
radiansToMeters() {
|
|
357
|
+
this.pool.push({
|
|
358
|
+
functionName: LoopFunctions.radiansToMeters
|
|
359
|
+
});
|
|
360
|
+
return this;
|
|
361
|
+
}
|
|
362
|
+
metersToRadians() {
|
|
363
|
+
this.pool.push({
|
|
364
|
+
functionName: LoopFunctions.metersToRadians
|
|
365
|
+
});
|
|
366
|
+
return this;
|
|
367
|
+
}
|
|
368
|
+
getHipPoint() {
|
|
369
|
+
this.pool.push({
|
|
370
|
+
functionName: LoopFunctions.hipPoint
|
|
371
|
+
});
|
|
372
|
+
return this;
|
|
373
|
+
}
|
|
374
|
+
getXPoint() {
|
|
375
|
+
this.pool.push({
|
|
376
|
+
functionName: LoopFunctions.xPoint
|
|
377
|
+
});
|
|
378
|
+
return this;
|
|
379
|
+
}
|
|
380
|
+
getYPoint() {
|
|
381
|
+
this.pool.push({
|
|
382
|
+
functionName: LoopFunctions.yPoint
|
|
383
|
+
});
|
|
384
|
+
return this;
|
|
385
|
+
}
|
|
386
|
+
getWPoint() {
|
|
387
|
+
this.pool.push({
|
|
388
|
+
functionName: LoopFunctions.wPoint
|
|
389
|
+
});
|
|
390
|
+
return this;
|
|
391
|
+
}
|
|
392
|
+
getHPoint() {
|
|
393
|
+
this.pool.push({
|
|
394
|
+
functionName: LoopFunctions.hPoint
|
|
395
|
+
});
|
|
396
|
+
return this;
|
|
397
|
+
}
|
|
398
|
+
setIfLessThan(p) {
|
|
399
|
+
this.pool.push({
|
|
400
|
+
functionName: LoopFunctions.setIfLessThan,
|
|
401
|
+
pointArg: p
|
|
402
|
+
});
|
|
403
|
+
return this;
|
|
404
|
+
}
|
|
405
|
+
minus() {
|
|
406
|
+
this.pool.push({
|
|
407
|
+
functionName: LoopFunctions.minus
|
|
408
|
+
});
|
|
409
|
+
return this;
|
|
410
|
+
}
|
|
411
|
+
degreeToMeters() {
|
|
412
|
+
this.pool.push({
|
|
413
|
+
functionName: LoopFunctions.degreeToMeters
|
|
414
|
+
});
|
|
415
|
+
return this;
|
|
416
|
+
}
|
|
417
|
+
metersToDegree() {
|
|
418
|
+
this.pool.push({
|
|
419
|
+
functionName: LoopFunctions.metersToDegree
|
|
420
|
+
});
|
|
421
|
+
return this;
|
|
422
|
+
}
|
|
423
|
+
flipVertically(size) {
|
|
424
|
+
this.pool.push({
|
|
425
|
+
functionName: LoopFunctions.flipVertically,
|
|
426
|
+
numberPointArg: size
|
|
427
|
+
});
|
|
428
|
+
return this;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export class FastSearch {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.searchStore = {};
|
|
4
|
+
}
|
|
5
|
+
add(points) {
|
|
6
|
+
for (const { x, y, z } of points) {
|
|
7
|
+
if (!this.searchStore[x]) {
|
|
8
|
+
this.searchStore[x] = {};
|
|
9
|
+
}
|
|
10
|
+
if (!this.searchStore[x][y]) {
|
|
11
|
+
this.searchStore[x][y] = {};
|
|
12
|
+
}
|
|
13
|
+
this.searchStore[x][y][z || 'undefined'] = true;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
find({ x, y, z }) {
|
|
17
|
+
if (!this.searchStore[x]) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
if (!this.searchStore[x][y]) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
return this.searchStore[x][y][z || 'undefined'];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { DPolygon } from './DPolygon';
|
|
13
|
+
import { DPoint } from './DPoint';
|
|
14
|
+
import { isDefAndNotNull } from './utils';
|
|
15
|
+
export class InterpolationMatrix {
|
|
16
|
+
constructor(bboxLike, stepSize, keys, p = 2) {
|
|
17
|
+
this.stepSize = stepSize;
|
|
18
|
+
this.p = p;
|
|
19
|
+
this.points = [];
|
|
20
|
+
this.cells = {};
|
|
21
|
+
this.allCells = [];
|
|
22
|
+
this.minPoint = bboxLike.minPoint;
|
|
23
|
+
this.maxPoint = bboxLike.maxPoint;
|
|
24
|
+
this.sizePoly = DPolygon.createSquareBySize(new DPoint(this.stepSize));
|
|
25
|
+
this.size = this.maxPoint.clone().move(this.minPoint.clone().minus())
|
|
26
|
+
.divide(this.stepSize)
|
|
27
|
+
.ceil();
|
|
28
|
+
this.keys = Array.isArray(keys) ? keys : [keys];
|
|
29
|
+
this.generateCells();
|
|
30
|
+
}
|
|
31
|
+
setKnownPoints(points) {
|
|
32
|
+
this.points = points instanceof DPolygon ? points.points : points;
|
|
33
|
+
this.minPoint.setProperties(this.points.reduce((a, v) => this.keys
|
|
34
|
+
.reduce((aa, k) => {
|
|
35
|
+
var _a;
|
|
36
|
+
aa[k] = Math.min((_a = a[k]) !== null && _a !== void 0 ? _a : Infinity, v.properties[k]);
|
|
37
|
+
return aa;
|
|
38
|
+
}, a), {}));
|
|
39
|
+
this.maxPoint.setProperties(this.points.reduce((a, v) => this.keys
|
|
40
|
+
.reduce((aa, k) => {
|
|
41
|
+
var _a;
|
|
42
|
+
aa[k] = Math.max((_a = a[k]) !== null && _a !== void 0 ? _a : -Infinity, v.properties[k]);
|
|
43
|
+
return aa;
|
|
44
|
+
}, a), {}));
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
positionToCellCoords(d) {
|
|
48
|
+
return d.clone()
|
|
49
|
+
.move(this.minPoint.clone().minus())
|
|
50
|
+
.divide(this.stepSize)
|
|
51
|
+
.floor();
|
|
52
|
+
}
|
|
53
|
+
calculate() {
|
|
54
|
+
this.setKnownValues();
|
|
55
|
+
this.interpolateValues();
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
getCellValue({ x, y }, key) {
|
|
59
|
+
const cell = this.cells[x][y];
|
|
60
|
+
if (key) {
|
|
61
|
+
if (Array.isArray(key)) {
|
|
62
|
+
return key.reduce((a, k) => {
|
|
63
|
+
a[k] = cell.properties[k];
|
|
64
|
+
return a;
|
|
65
|
+
}, {});
|
|
66
|
+
}
|
|
67
|
+
return cell.properties[key];
|
|
68
|
+
}
|
|
69
|
+
return Object.assign({}, cell.properties);
|
|
70
|
+
}
|
|
71
|
+
get getCellData() {
|
|
72
|
+
return this.allCells.reduce((a, c) => {
|
|
73
|
+
const _a = c.properties, { x, y } = _a, props = __rest(_a, ["x", "y"]);
|
|
74
|
+
a[x] = a[x] || {};
|
|
75
|
+
a[x][y] = Object.assign({}, props);
|
|
76
|
+
return a;
|
|
77
|
+
}, {});
|
|
78
|
+
}
|
|
79
|
+
get allCellsClone() {
|
|
80
|
+
return this.allCells.map((p) => p.clone());
|
|
81
|
+
}
|
|
82
|
+
interpolateValues() {
|
|
83
|
+
const points = this.points.map((p) => this.positionToCellCoords(p));
|
|
84
|
+
this.allCells.forEach((cell) => {
|
|
85
|
+
const t = new DPoint(cell.properties.x, cell.properties.y);
|
|
86
|
+
const distances = points.map((p) => Math.pow(t.distance(p), this.p));
|
|
87
|
+
this.keys.forEach((k) => {
|
|
88
|
+
if (isDefAndNotNull(cell.properties[k])) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const [valueSum, oneSum] = distances.reduce((a, d, i) => {
|
|
92
|
+
if (isDefAndNotNull(this.points[i].properties[k])) {
|
|
93
|
+
a[0] += this.points[i].properties[k] / d;
|
|
94
|
+
a[1] += 1 / d;
|
|
95
|
+
}
|
|
96
|
+
return a;
|
|
97
|
+
}, [0, 0]);
|
|
98
|
+
cell.properties[k] = valueSum / oneSum;
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
setKnownValues() {
|
|
103
|
+
this.points.forEach((p) => {
|
|
104
|
+
const { x, y } = this.positionToCellCoords(p);
|
|
105
|
+
this.keys.forEach((k) => {
|
|
106
|
+
this.cells[x][y].properties[k] = p.properties[k];
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
generateCells() {
|
|
111
|
+
for (let i = this.minPoint.x, x = 0; i < this.maxPoint.x; i += this.stepSize, x++) {
|
|
112
|
+
this.cells[x] = this.cells[x] || {};
|
|
113
|
+
for (let j = this.minPoint.y, y = 0; j < this.maxPoint.y; j += this.stepSize, y++) {
|
|
114
|
+
const t = this.sizePoly
|
|
115
|
+
.clone()
|
|
116
|
+
.loop()
|
|
117
|
+
.move(i, j)
|
|
118
|
+
.run()
|
|
119
|
+
.setProperties({
|
|
120
|
+
x,
|
|
121
|
+
y
|
|
122
|
+
});
|
|
123
|
+
this.cells[x][y] = t;
|
|
124
|
+
this.allCells.push(t);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|