dgeoutils 2.4.33 → 2.4.35
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/DLine.d.ts +2 -0
- package/dist/cjs/DLine.js +33 -0
- package/dist/cjs/DPolygon.d.ts +2 -0
- package/dist/cjs/DPolygon.js +14 -0
- package/dist/cjs/InterpolationMatrix.d.ts +2 -2
- package/dist/cjs/InterpolationMatrix.js +15 -2
- package/dist/es2015/DLine.js +33 -0
- package/dist/es2015/DPolygon.js +6 -0
- package/dist/es2015/InterpolationMatrix.js +14 -2
- package/dist/esm/DLine.js +33 -0
- package/dist/esm/DPolygon.js +14 -0
- package/dist/esm/InterpolationMatrix.js +15 -2
- package/dist/umd/dgeoutils.js +1078 -1019
- package/dist/umd/dgeoutils.min.js +1 -1
- package/dist/umd/dgeoutils.min.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/DLine.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DPoint } from './DPoint';
|
|
2
2
|
import { DCircle } from './DCircle';
|
|
3
|
+
import { DPolygon } from './DPolygon';
|
|
3
4
|
export declare class DLine {
|
|
4
5
|
a: number;
|
|
5
6
|
b: number;
|
|
@@ -34,4 +35,5 @@ export declare class DLine {
|
|
|
34
35
|
movePoint(points: DPoint[], distances: number[]): DPoint[];
|
|
35
36
|
findFi({ a, b }: DLine, delta?: number): number;
|
|
36
37
|
vectorProduct({ a, b, c }: DLine): DLine;
|
|
38
|
+
bresenhamsLine(): DPolygon;
|
|
37
39
|
}
|
package/dist/cjs/DLine.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.DLine = void 0;
|
|
|
4
4
|
var DPoint_1 = require("./DPoint");
|
|
5
5
|
var utils_1 = require("./utils");
|
|
6
6
|
var DNumbers_1 = require("./DNumbers");
|
|
7
|
+
var DPolygon_1 = require("./DPolygon");
|
|
7
8
|
var DLine = (function () {
|
|
8
9
|
function DLine(a, b, c, begin, end) {
|
|
9
10
|
if (begin === void 0) { begin = DPoint_1.DPoint.zero(); }
|
|
@@ -305,6 +306,38 @@ var DLine = (function () {
|
|
|
305
306
|
var _b = this, q = _b.a, w = _b.b, e = _b.c;
|
|
306
307
|
return new DLine(w * c - e * b, e * a - q * c, q * b - w * a);
|
|
307
308
|
};
|
|
309
|
+
DLine.prototype.bresenhamsLine = function () {
|
|
310
|
+
var _a = this.begin, x0 = _a.x, y0 = _a.y;
|
|
311
|
+
var _b = this.end, x1 = _b.x, y1 = _b.y;
|
|
312
|
+
var dx = Math.abs(x1 - x0);
|
|
313
|
+
var sx = x0 < x1 ? 1 : -1;
|
|
314
|
+
var dy = -Math.abs(y1 - y0);
|
|
315
|
+
var sy = y0 < y1 ? 1 : -1;
|
|
316
|
+
var error = dx + dy;
|
|
317
|
+
var res = new DPolygon_1.DPolygon();
|
|
318
|
+
while (true) {
|
|
319
|
+
res.push(new DPoint_1.DPoint(x0, y0));
|
|
320
|
+
if (x0 === x1 && y0 === y1) {
|
|
321
|
+
break;
|
|
322
|
+
}
|
|
323
|
+
var e2 = 2 * error;
|
|
324
|
+
if (e2 >= dy) {
|
|
325
|
+
if (x0 === x1) {
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
error += dy;
|
|
329
|
+
x0 += sx;
|
|
330
|
+
}
|
|
331
|
+
if (e2 <= dx) {
|
|
332
|
+
if (y0 === y1) {
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
error += dx;
|
|
336
|
+
y0 += sy;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return res;
|
|
340
|
+
};
|
|
308
341
|
return DLine;
|
|
309
342
|
}());
|
|
310
343
|
exports.DLine = DLine;
|
package/dist/cjs/DPolygon.d.ts
CHANGED
|
@@ -38,7 +38,9 @@ export declare class DPolygon {
|
|
|
38
38
|
get extend(): DPolygon;
|
|
39
39
|
get size(): DPoint;
|
|
40
40
|
get leftTop(): DPoint;
|
|
41
|
+
get minPoint(): DPoint;
|
|
41
42
|
get rightBottom(): DPoint;
|
|
43
|
+
get maxPoint(): DPoint;
|
|
42
44
|
get length(): number;
|
|
43
45
|
get fullLength(): number;
|
|
44
46
|
get perimeter(): number;
|
package/dist/cjs/DPolygon.js
CHANGED
|
@@ -340,6 +340,13 @@ var DPolygon = (function () {
|
|
|
340
340
|
enumerable: false,
|
|
341
341
|
configurable: true
|
|
342
342
|
});
|
|
343
|
+
Object.defineProperty(DPolygon.prototype, "minPoint", {
|
|
344
|
+
get: function () {
|
|
345
|
+
return this.leftTop;
|
|
346
|
+
},
|
|
347
|
+
enumerable: false,
|
|
348
|
+
configurable: true
|
|
349
|
+
});
|
|
343
350
|
Object.defineProperty(DPolygon.prototype, "rightBottom", {
|
|
344
351
|
get: function () {
|
|
345
352
|
var _a = this, maxX = _a.maxX, maxY = _a.maxY;
|
|
@@ -348,6 +355,13 @@ var DPolygon = (function () {
|
|
|
348
355
|
enumerable: false,
|
|
349
356
|
configurable: true
|
|
350
357
|
});
|
|
358
|
+
Object.defineProperty(DPolygon.prototype, "maxPoint", {
|
|
359
|
+
get: function () {
|
|
360
|
+
return this.rightBottom;
|
|
361
|
+
},
|
|
362
|
+
enumerable: false,
|
|
363
|
+
configurable: true
|
|
364
|
+
});
|
|
351
365
|
Object.defineProperty(DPolygon.prototype, "length", {
|
|
352
366
|
get: function () {
|
|
353
367
|
return this.pPoints.length;
|
|
@@ -3,8 +3,8 @@ import { DPoint } from './DPoint';
|
|
|
3
3
|
export declare class InterpolationMatrix {
|
|
4
4
|
private readonly stepSize;
|
|
5
5
|
private readonly p;
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
readonly minPoint: DPoint;
|
|
7
|
+
readonly maxPoint: DPoint;
|
|
8
8
|
private points;
|
|
9
9
|
private cells;
|
|
10
10
|
private allCells;
|
|
@@ -50,8 +50,8 @@ var InterpolationMatrix = (function () {
|
|
|
50
50
|
this.points = [];
|
|
51
51
|
this.cells = {};
|
|
52
52
|
this.allCells = [];
|
|
53
|
-
this.minPoint = bboxLike.
|
|
54
|
-
this.maxPoint = bboxLike.
|
|
53
|
+
this.minPoint = bboxLike.minPoint;
|
|
54
|
+
this.maxPoint = bboxLike.maxPoint;
|
|
55
55
|
this.sizePoly = DPolygon_1.DPolygon.createSquareBySize(new DPoint_1.DPoint(this.stepSize));
|
|
56
56
|
this.size = this.maxPoint.clone().move(this.minPoint.clone().minus())
|
|
57
57
|
.divide(this.stepSize)
|
|
@@ -60,7 +60,20 @@ var InterpolationMatrix = (function () {
|
|
|
60
60
|
this.generateCells();
|
|
61
61
|
}
|
|
62
62
|
InterpolationMatrix.prototype.setKnownPoints = function (points) {
|
|
63
|
+
var _this = this;
|
|
63
64
|
this.points = points instanceof DPolygon_1.DPolygon ? points.points : points;
|
|
65
|
+
this.minPoint.setProperties(this.points.reduce(function (a, v) { return _this.keys
|
|
66
|
+
.reduce(function (aa, k) {
|
|
67
|
+
var _a;
|
|
68
|
+
aa[k] = Math.min((_a = a[k]) !== null && _a !== void 0 ? _a : Infinity, v.properties[k]);
|
|
69
|
+
return aa;
|
|
70
|
+
}, a); }, {}));
|
|
71
|
+
this.maxPoint.setProperties(this.points.reduce(function (a, v) { return _this.keys
|
|
72
|
+
.reduce(function (aa, k) {
|
|
73
|
+
var _a;
|
|
74
|
+
aa[k] = Math.max((_a = a[k]) !== null && _a !== void 0 ? _a : -Infinity, v.properties[k]);
|
|
75
|
+
return aa;
|
|
76
|
+
}, a); }, {}));
|
|
64
77
|
return this;
|
|
65
78
|
};
|
|
66
79
|
InterpolationMatrix.prototype.positionToCellCoords = function (d) {
|
package/dist/es2015/DLine.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DPoint } from './DPoint';
|
|
2
2
|
import { checkFunction } from './utils';
|
|
3
3
|
import { DNumbers } from './DNumbers';
|
|
4
|
+
import { DPolygon } from './DPolygon';
|
|
4
5
|
export class DLine {
|
|
5
6
|
constructor(a, b, c, begin = DPoint.zero(), end = DPoint.zero()) {
|
|
6
7
|
this.a = a;
|
|
@@ -254,4 +255,36 @@ export class DLine {
|
|
|
254
255
|
const { a: q, b: w, c: e } = this;
|
|
255
256
|
return new DLine(w * c - e * b, e * a - q * c, q * b - w * a);
|
|
256
257
|
}
|
|
258
|
+
bresenhamsLine() {
|
|
259
|
+
let { x: x0, y: y0 } = this.begin;
|
|
260
|
+
const { x: x1, y: y1 } = this.end;
|
|
261
|
+
const dx = Math.abs(x1 - x0);
|
|
262
|
+
const sx = x0 < x1 ? 1 : -1;
|
|
263
|
+
const dy = -Math.abs(y1 - y0);
|
|
264
|
+
const sy = y0 < y1 ? 1 : -1;
|
|
265
|
+
let error = dx + dy;
|
|
266
|
+
const res = new DPolygon();
|
|
267
|
+
while (true) {
|
|
268
|
+
res.push(new DPoint(x0, y0));
|
|
269
|
+
if (x0 === x1 && y0 === y1) {
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
const e2 = 2 * error;
|
|
273
|
+
if (e2 >= dy) {
|
|
274
|
+
if (x0 === x1) {
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
error += dy;
|
|
278
|
+
x0 += sx;
|
|
279
|
+
}
|
|
280
|
+
if (e2 <= dx) {
|
|
281
|
+
if (y0 === y1) {
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
284
|
+
error += dx;
|
|
285
|
+
y0 += sy;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return res;
|
|
289
|
+
}
|
|
257
290
|
}
|
package/dist/es2015/DPolygon.js
CHANGED
|
@@ -178,10 +178,16 @@ export class DPolygon {
|
|
|
178
178
|
const { minX, minY } = this;
|
|
179
179
|
return new DPoint(minX, minY);
|
|
180
180
|
}
|
|
181
|
+
get minPoint() {
|
|
182
|
+
return this.leftTop;
|
|
183
|
+
}
|
|
181
184
|
get rightBottom() {
|
|
182
185
|
const { maxX, maxY } = this;
|
|
183
186
|
return new DPoint(maxX, maxY);
|
|
184
187
|
}
|
|
188
|
+
get maxPoint() {
|
|
189
|
+
return this.rightBottom;
|
|
190
|
+
}
|
|
185
191
|
get length() {
|
|
186
192
|
return this.pPoints.length;
|
|
187
193
|
}
|
|
@@ -19,8 +19,8 @@ export class InterpolationMatrix {
|
|
|
19
19
|
this.points = [];
|
|
20
20
|
this.cells = {};
|
|
21
21
|
this.allCells = [];
|
|
22
|
-
this.minPoint = bboxLike.
|
|
23
|
-
this.maxPoint = bboxLike.
|
|
22
|
+
this.minPoint = bboxLike.minPoint;
|
|
23
|
+
this.maxPoint = bboxLike.maxPoint;
|
|
24
24
|
this.sizePoly = DPolygon.createSquareBySize(new DPoint(this.stepSize));
|
|
25
25
|
this.size = this.maxPoint.clone().move(this.minPoint.clone().minus())
|
|
26
26
|
.divide(this.stepSize)
|
|
@@ -30,6 +30,18 @@ export class InterpolationMatrix {
|
|
|
30
30
|
}
|
|
31
31
|
setKnownPoints(points) {
|
|
32
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), {}));
|
|
33
45
|
return this;
|
|
34
46
|
}
|
|
35
47
|
positionToCellCoords(d) {
|
package/dist/esm/DLine.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DPoint } from './DPoint';
|
|
2
2
|
import { checkFunction } from './utils';
|
|
3
3
|
import { DNumbers } from './DNumbers';
|
|
4
|
+
import { DPolygon } from './DPolygon';
|
|
4
5
|
var DLine = (function () {
|
|
5
6
|
function DLine(a, b, c, begin, end) {
|
|
6
7
|
if (begin === void 0) { begin = DPoint.zero(); }
|
|
@@ -302,6 +303,38 @@ var DLine = (function () {
|
|
|
302
303
|
var _b = this, q = _b.a, w = _b.b, e = _b.c;
|
|
303
304
|
return new DLine(w * c - e * b, e * a - q * c, q * b - w * a);
|
|
304
305
|
};
|
|
306
|
+
DLine.prototype.bresenhamsLine = function () {
|
|
307
|
+
var _a = this.begin, x0 = _a.x, y0 = _a.y;
|
|
308
|
+
var _b = this.end, x1 = _b.x, y1 = _b.y;
|
|
309
|
+
var dx = Math.abs(x1 - x0);
|
|
310
|
+
var sx = x0 < x1 ? 1 : -1;
|
|
311
|
+
var dy = -Math.abs(y1 - y0);
|
|
312
|
+
var sy = y0 < y1 ? 1 : -1;
|
|
313
|
+
var error = dx + dy;
|
|
314
|
+
var res = new DPolygon();
|
|
315
|
+
while (true) {
|
|
316
|
+
res.push(new DPoint(x0, y0));
|
|
317
|
+
if (x0 === x1 && y0 === y1) {
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
320
|
+
var e2 = 2 * error;
|
|
321
|
+
if (e2 >= dy) {
|
|
322
|
+
if (x0 === x1) {
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
error += dy;
|
|
326
|
+
x0 += sx;
|
|
327
|
+
}
|
|
328
|
+
if (e2 <= dx) {
|
|
329
|
+
if (y0 === y1) {
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
332
|
+
error += dx;
|
|
333
|
+
y0 += sy;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return res;
|
|
337
|
+
};
|
|
305
338
|
return DLine;
|
|
306
339
|
}());
|
|
307
340
|
export { DLine };
|
package/dist/esm/DPolygon.js
CHANGED
|
@@ -337,6 +337,13 @@ var DPolygon = (function () {
|
|
|
337
337
|
enumerable: false,
|
|
338
338
|
configurable: true
|
|
339
339
|
});
|
|
340
|
+
Object.defineProperty(DPolygon.prototype, "minPoint", {
|
|
341
|
+
get: function () {
|
|
342
|
+
return this.leftTop;
|
|
343
|
+
},
|
|
344
|
+
enumerable: false,
|
|
345
|
+
configurable: true
|
|
346
|
+
});
|
|
340
347
|
Object.defineProperty(DPolygon.prototype, "rightBottom", {
|
|
341
348
|
get: function () {
|
|
342
349
|
var _a = this, maxX = _a.maxX, maxY = _a.maxY;
|
|
@@ -345,6 +352,13 @@ var DPolygon = (function () {
|
|
|
345
352
|
enumerable: false,
|
|
346
353
|
configurable: true
|
|
347
354
|
});
|
|
355
|
+
Object.defineProperty(DPolygon.prototype, "maxPoint", {
|
|
356
|
+
get: function () {
|
|
357
|
+
return this.rightBottom;
|
|
358
|
+
},
|
|
359
|
+
enumerable: false,
|
|
360
|
+
configurable: true
|
|
361
|
+
});
|
|
348
362
|
Object.defineProperty(DPolygon.prototype, "length", {
|
|
349
363
|
get: function () {
|
|
350
364
|
return this.pPoints.length;
|
|
@@ -47,8 +47,8 @@ var InterpolationMatrix = (function () {
|
|
|
47
47
|
this.points = [];
|
|
48
48
|
this.cells = {};
|
|
49
49
|
this.allCells = [];
|
|
50
|
-
this.minPoint = bboxLike.
|
|
51
|
-
this.maxPoint = bboxLike.
|
|
50
|
+
this.minPoint = bboxLike.minPoint;
|
|
51
|
+
this.maxPoint = bboxLike.maxPoint;
|
|
52
52
|
this.sizePoly = DPolygon.createSquareBySize(new DPoint(this.stepSize));
|
|
53
53
|
this.size = this.maxPoint.clone().move(this.minPoint.clone().minus())
|
|
54
54
|
.divide(this.stepSize)
|
|
@@ -57,7 +57,20 @@ var InterpolationMatrix = (function () {
|
|
|
57
57
|
this.generateCells();
|
|
58
58
|
}
|
|
59
59
|
InterpolationMatrix.prototype.setKnownPoints = function (points) {
|
|
60
|
+
var _this = this;
|
|
60
61
|
this.points = points instanceof DPolygon ? points.points : points;
|
|
62
|
+
this.minPoint.setProperties(this.points.reduce(function (a, v) { return _this.keys
|
|
63
|
+
.reduce(function (aa, k) {
|
|
64
|
+
var _a;
|
|
65
|
+
aa[k] = Math.min((_a = a[k]) !== null && _a !== void 0 ? _a : Infinity, v.properties[k]);
|
|
66
|
+
return aa;
|
|
67
|
+
}, a); }, {}));
|
|
68
|
+
this.maxPoint.setProperties(this.points.reduce(function (a, v) { return _this.keys
|
|
69
|
+
.reduce(function (aa, k) {
|
|
70
|
+
var _a;
|
|
71
|
+
aa[k] = Math.max((_a = a[k]) !== null && _a !== void 0 ? _a : -Infinity, v.properties[k]);
|
|
72
|
+
return aa;
|
|
73
|
+
}, a); }, {}));
|
|
61
74
|
return this;
|
|
62
75
|
};
|
|
63
76
|
InterpolationMatrix.prototype.positionToCellCoords = function (d) {
|