dgeoutils 2.4.23 → 2.4.25
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/DPolygon.d.ts +2 -0
- package/dist/cjs/DPolygon.js +5 -1
- package/dist/cjs/TraceMatrix.d.ts +2 -2
- package/dist/cjs/TraceMatrix.js +29 -4
- package/dist/es2015/DPolygon.js +5 -1
- package/dist/es2015/TraceMatrix.js +29 -4
- package/dist/esm/DPolygon.js +5 -1
- package/dist/esm/TraceMatrix.js +29 -4
- package/dist/umd/dgeoutils.js +35 -6
- package/dist/umd/dgeoutils.min.js +1 -1
- package/dist/umd/dgeoutils.min.js.map +1 -1
- package/package.json +2 -2
package/dist/cjs/DPolygon.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { LineString, Polygon, Geometry as GeoJsonGeometry, Feature, FeatureColle
|
|
|
7
7
|
interface DeepArray<T> extends Array<T | DeepArray<T>> {
|
|
8
8
|
}
|
|
9
9
|
export declare const MIN_POINTS_IN_VALID_POLYGON = 3;
|
|
10
|
+
declare type SetterFunction<T> = (t: DPolygon) => T;
|
|
10
11
|
export declare class DPolygon {
|
|
11
12
|
private pPoints;
|
|
12
13
|
properties: Record<string, any>;
|
|
@@ -116,6 +117,7 @@ export declare class DPolygon {
|
|
|
116
117
|
get closed(): boolean;
|
|
117
118
|
buffer(v: number, quadrantSegments?: number, type?: number): DPolygon;
|
|
118
119
|
sideBuffers(v: number, quadrantSegments?: number): [DPolygon, DPolygon];
|
|
120
|
+
setProperties(v: SetterFunction<Record<string, any>> | Record<string, any>): DPolygon;
|
|
119
121
|
bezier(step?: number): DPolygon;
|
|
120
122
|
setGrowingHeight(from: number, to: number): DPolygon;
|
|
121
123
|
loopPointsGenerator(): () => Generator<[DPoint, DPoint, undefined, number]>;
|
package/dist/cjs/DPolygon.js
CHANGED
|
@@ -775,7 +775,7 @@ var DPolygon = (function () {
|
|
|
775
775
|
DPolygon.prototype.clone = function () {
|
|
776
776
|
var res = new DPolygon(this.points.map(function (r) { return r.clone(); }));
|
|
777
777
|
res.holes = this.holes.map(function (h) { return h.clone(); });
|
|
778
|
-
res.properties = this.properties;
|
|
778
|
+
res.properties = __assign({}, this.properties);
|
|
779
779
|
return res;
|
|
780
780
|
};
|
|
781
781
|
DPolygon.prototype.equal = function (p) {
|
|
@@ -1409,6 +1409,10 @@ var DPolygon = (function () {
|
|
|
1409
1409
|
buffer.unshift(buffer.pop());
|
|
1410
1410
|
return [linePart.reverse(), buffer];
|
|
1411
1411
|
};
|
|
1412
|
+
DPolygon.prototype.setProperties = function (v) {
|
|
1413
|
+
this.properties = typeof v === 'object' ? v : v(this);
|
|
1414
|
+
return this;
|
|
1415
|
+
};
|
|
1412
1416
|
DPolygon.prototype.bezier = function (step) {
|
|
1413
1417
|
if (step === void 0) { step = 0.1; }
|
|
1414
1418
|
var res = new DPolygon();
|
|
@@ -6,10 +6,10 @@ export declare enum TraceMatrixValues {
|
|
|
6
6
|
}
|
|
7
7
|
export declare type SimpleMatrix = TraceMatrixValues[][];
|
|
8
8
|
export declare class TraceMatrix {
|
|
9
|
-
private readonly size;
|
|
10
9
|
private readonly m;
|
|
11
10
|
approximation: boolean;
|
|
12
|
-
|
|
11
|
+
private readonly size;
|
|
12
|
+
constructor(s: DPoint, f: (p: DPoint) => TraceMatrixValues);
|
|
13
13
|
fullMatrixTrace(): DPolygon[];
|
|
14
14
|
private reverseMatrix;
|
|
15
15
|
private findGroupByIndex;
|
package/dist/cjs/TraceMatrix.js
CHANGED
|
@@ -61,9 +61,8 @@ var setByPosition = function (m, p, value) {
|
|
|
61
61
|
return m[p.y][p.x];
|
|
62
62
|
};
|
|
63
63
|
var TraceMatrix = (function () {
|
|
64
|
-
function TraceMatrix(
|
|
64
|
+
function TraceMatrix(s, f) {
|
|
65
65
|
var _this = this;
|
|
66
|
-
this.size = size;
|
|
67
66
|
this.approximation = true;
|
|
68
67
|
this.findGroupByIndex = function (m, s) {
|
|
69
68
|
var res = new DPolygon_1.DPolygon();
|
|
@@ -199,7 +198,30 @@ var TraceMatrix = (function () {
|
|
|
199
198
|
var t = _this.reverseMatrix(tmpMatrix);
|
|
200
199
|
return _this.totalCountInMatrix(t) ? t : null;
|
|
201
200
|
};
|
|
202
|
-
this.
|
|
201
|
+
this.size = s.clone().scale(4);
|
|
202
|
+
var t = TraceMatrix.createMatrix(this.size, function (p) {
|
|
203
|
+
var _a = p.clone().mod(4), x = _a.x, y = _a.y;
|
|
204
|
+
if ([1, 2].includes(x) && [1, 2].includes(y)) {
|
|
205
|
+
return f(p.clone().div(4));
|
|
206
|
+
}
|
|
207
|
+
return TraceMatrixValues.f;
|
|
208
|
+
});
|
|
209
|
+
this.m = TraceMatrix.createMatrix(this.size);
|
|
210
|
+
for (var i = 1; i < this.size.x - 1; i++) {
|
|
211
|
+
for (var j = 1; j < this.size.y - 1; j++) {
|
|
212
|
+
if (t[i][j] === TraceMatrixValues.t) {
|
|
213
|
+
this.m[i - 1][j - 1] = TraceMatrixValues.t;
|
|
214
|
+
this.m[i - 1][j] = TraceMatrixValues.t;
|
|
215
|
+
this.m[i - 1][j + 1] = TraceMatrixValues.t;
|
|
216
|
+
this.m[i][j - 1] = TraceMatrixValues.t;
|
|
217
|
+
this.m[i][j] = TraceMatrixValues.t;
|
|
218
|
+
this.m[i][j + 1] = TraceMatrixValues.t;
|
|
219
|
+
this.m[i + 1][j - 1] = TraceMatrixValues.t;
|
|
220
|
+
this.m[i + 1][j] = TraceMatrixValues.t;
|
|
221
|
+
this.m[i + 1][j + 1] = TraceMatrixValues.t;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
203
225
|
}
|
|
204
226
|
TraceMatrix.prototype.fullMatrixTrace = function () {
|
|
205
227
|
var _this = this;
|
|
@@ -214,7 +236,10 @@ var TraceMatrix = (function () {
|
|
|
214
236
|
if (holesGroups[index] && holesGroups[index].length) {
|
|
215
237
|
res.holes = holesPaths[index];
|
|
216
238
|
}
|
|
217
|
-
return res
|
|
239
|
+
return res.loop()
|
|
240
|
+
.divide(4)
|
|
241
|
+
.round()
|
|
242
|
+
.run();
|
|
218
243
|
});
|
|
219
244
|
};
|
|
220
245
|
TraceMatrix.prototype.reverseMatrix = function (m) {
|
package/dist/es2015/DPolygon.js
CHANGED
|
@@ -458,7 +458,7 @@ export class DPolygon {
|
|
|
458
458
|
clone() {
|
|
459
459
|
const res = new DPolygon(this.points.map((r) => r.clone()));
|
|
460
460
|
res.holes = this.holes.map((h) => h.clone());
|
|
461
|
-
res.properties = this.properties;
|
|
461
|
+
res.properties = Object.assign({}, this.properties);
|
|
462
462
|
return res;
|
|
463
463
|
}
|
|
464
464
|
equal(p) {
|
|
@@ -958,6 +958,10 @@ export class DPolygon {
|
|
|
958
958
|
buffer.unshift(buffer.pop());
|
|
959
959
|
return [linePart.reverse(), buffer];
|
|
960
960
|
}
|
|
961
|
+
setProperties(v) {
|
|
962
|
+
this.properties = typeof v === 'object' ? v : v(this);
|
|
963
|
+
return this;
|
|
964
|
+
}
|
|
961
965
|
bezier(step = 0.1) {
|
|
962
966
|
const res = new DPolygon();
|
|
963
967
|
for (let i = 0; i < 1; i += step) {
|
|
@@ -21,8 +21,7 @@ const setByPosition = (m, p, value) => {
|
|
|
21
21
|
return m[p.y][p.x];
|
|
22
22
|
};
|
|
23
23
|
export class TraceMatrix {
|
|
24
|
-
constructor(
|
|
25
|
-
this.size = size;
|
|
24
|
+
constructor(s, f) {
|
|
26
25
|
this.approximation = true;
|
|
27
26
|
this.findGroupByIndex = (m, s) => {
|
|
28
27
|
const res = new DPolygon();
|
|
@@ -147,7 +146,30 @@ export class TraceMatrix {
|
|
|
147
146
|
const t = this.reverseMatrix(tmpMatrix);
|
|
148
147
|
return this.totalCountInMatrix(t) ? t : null;
|
|
149
148
|
};
|
|
150
|
-
this.
|
|
149
|
+
this.size = s.clone().scale(4);
|
|
150
|
+
const t = TraceMatrix.createMatrix(this.size, (p) => {
|
|
151
|
+
const { x, y } = p.clone().mod(4);
|
|
152
|
+
if ([1, 2].includes(x) && [1, 2].includes(y)) {
|
|
153
|
+
return f(p.clone().div(4));
|
|
154
|
+
}
|
|
155
|
+
return TraceMatrixValues.f;
|
|
156
|
+
});
|
|
157
|
+
this.m = TraceMatrix.createMatrix(this.size);
|
|
158
|
+
for (let i = 1; i < this.size.x - 1; i++) {
|
|
159
|
+
for (let j = 1; j < this.size.y - 1; j++) {
|
|
160
|
+
if (t[i][j] === TraceMatrixValues.t) {
|
|
161
|
+
this.m[i - 1][j - 1] = TraceMatrixValues.t;
|
|
162
|
+
this.m[i - 1][j] = TraceMatrixValues.t;
|
|
163
|
+
this.m[i - 1][j + 1] = TraceMatrixValues.t;
|
|
164
|
+
this.m[i][j - 1] = TraceMatrixValues.t;
|
|
165
|
+
this.m[i][j] = TraceMatrixValues.t;
|
|
166
|
+
this.m[i][j + 1] = TraceMatrixValues.t;
|
|
167
|
+
this.m[i + 1][j - 1] = TraceMatrixValues.t;
|
|
168
|
+
this.m[i + 1][j] = TraceMatrixValues.t;
|
|
169
|
+
this.m[i + 1][j + 1] = TraceMatrixValues.t;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
151
173
|
}
|
|
152
174
|
fullMatrixTrace() {
|
|
153
175
|
const groups = this.findAllGroupsInMatrix(this.m);
|
|
@@ -161,7 +183,10 @@ export class TraceMatrix {
|
|
|
161
183
|
if (holesGroups[index] && holesGroups[index].length) {
|
|
162
184
|
res.holes = holesPaths[index];
|
|
163
185
|
}
|
|
164
|
-
return res
|
|
186
|
+
return res.loop()
|
|
187
|
+
.divide(4)
|
|
188
|
+
.round()
|
|
189
|
+
.run();
|
|
165
190
|
});
|
|
166
191
|
}
|
|
167
192
|
reverseMatrix(m) {
|
package/dist/esm/DPolygon.js
CHANGED
|
@@ -772,7 +772,7 @@ var DPolygon = (function () {
|
|
|
772
772
|
DPolygon.prototype.clone = function () {
|
|
773
773
|
var res = new DPolygon(this.points.map(function (r) { return r.clone(); }));
|
|
774
774
|
res.holes = this.holes.map(function (h) { return h.clone(); });
|
|
775
|
-
res.properties = this.properties;
|
|
775
|
+
res.properties = __assign({}, this.properties);
|
|
776
776
|
return res;
|
|
777
777
|
};
|
|
778
778
|
DPolygon.prototype.equal = function (p) {
|
|
@@ -1406,6 +1406,10 @@ var DPolygon = (function () {
|
|
|
1406
1406
|
buffer.unshift(buffer.pop());
|
|
1407
1407
|
return [linePart.reverse(), buffer];
|
|
1408
1408
|
};
|
|
1409
|
+
DPolygon.prototype.setProperties = function (v) {
|
|
1410
|
+
this.properties = typeof v === 'object' ? v : v(this);
|
|
1411
|
+
return this;
|
|
1412
|
+
};
|
|
1409
1413
|
DPolygon.prototype.bezier = function (step) {
|
|
1410
1414
|
if (step === void 0) { step = 0.1; }
|
|
1411
1415
|
var res = new DPolygon();
|
package/dist/esm/TraceMatrix.js
CHANGED
|
@@ -58,9 +58,8 @@ var setByPosition = function (m, p, value) {
|
|
|
58
58
|
return m[p.y][p.x];
|
|
59
59
|
};
|
|
60
60
|
var TraceMatrix = (function () {
|
|
61
|
-
function TraceMatrix(
|
|
61
|
+
function TraceMatrix(s, f) {
|
|
62
62
|
var _this = this;
|
|
63
|
-
this.size = size;
|
|
64
63
|
this.approximation = true;
|
|
65
64
|
this.findGroupByIndex = function (m, s) {
|
|
66
65
|
var res = new DPolygon();
|
|
@@ -196,7 +195,30 @@ var TraceMatrix = (function () {
|
|
|
196
195
|
var t = _this.reverseMatrix(tmpMatrix);
|
|
197
196
|
return _this.totalCountInMatrix(t) ? t : null;
|
|
198
197
|
};
|
|
199
|
-
this.
|
|
198
|
+
this.size = s.clone().scale(4);
|
|
199
|
+
var t = TraceMatrix.createMatrix(this.size, function (p) {
|
|
200
|
+
var _a = p.clone().mod(4), x = _a.x, y = _a.y;
|
|
201
|
+
if ([1, 2].includes(x) && [1, 2].includes(y)) {
|
|
202
|
+
return f(p.clone().div(4));
|
|
203
|
+
}
|
|
204
|
+
return TraceMatrixValues.f;
|
|
205
|
+
});
|
|
206
|
+
this.m = TraceMatrix.createMatrix(this.size);
|
|
207
|
+
for (var i = 1; i < this.size.x - 1; i++) {
|
|
208
|
+
for (var j = 1; j < this.size.y - 1; j++) {
|
|
209
|
+
if (t[i][j] === TraceMatrixValues.t) {
|
|
210
|
+
this.m[i - 1][j - 1] = TraceMatrixValues.t;
|
|
211
|
+
this.m[i - 1][j] = TraceMatrixValues.t;
|
|
212
|
+
this.m[i - 1][j + 1] = TraceMatrixValues.t;
|
|
213
|
+
this.m[i][j - 1] = TraceMatrixValues.t;
|
|
214
|
+
this.m[i][j] = TraceMatrixValues.t;
|
|
215
|
+
this.m[i][j + 1] = TraceMatrixValues.t;
|
|
216
|
+
this.m[i + 1][j - 1] = TraceMatrixValues.t;
|
|
217
|
+
this.m[i + 1][j] = TraceMatrixValues.t;
|
|
218
|
+
this.m[i + 1][j + 1] = TraceMatrixValues.t;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
200
222
|
}
|
|
201
223
|
TraceMatrix.prototype.fullMatrixTrace = function () {
|
|
202
224
|
var _this = this;
|
|
@@ -211,7 +233,10 @@ var TraceMatrix = (function () {
|
|
|
211
233
|
if (holesGroups[index] && holesGroups[index].length) {
|
|
212
234
|
res.holes = holesPaths[index];
|
|
213
235
|
}
|
|
214
|
-
return res
|
|
236
|
+
return res.loop()
|
|
237
|
+
.divide(4)
|
|
238
|
+
.round()
|
|
239
|
+
.run();
|
|
215
240
|
});
|
|
216
241
|
};
|
|
217
242
|
TraceMatrix.prototype.reverseMatrix = function (m) {
|