dgeoutils 2.2.7 → 2.2.8
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 +0 -28
- package/dist/DCircle.js +0 -30
- package/dist/DLine.d.ts +0 -60
- package/dist/DLine.js +1 -67
- package/dist/DPoint.d.ts +0 -137
- package/dist/DPoint.js +0 -50
- package/dist/DPolygon.d.ts +0 -209
- package/dist/DPolygon.js +0 -203
- package/dist/DPolygonLoop.d.ts +0 -80
- package/dist/DPolygonLoop.js +0 -12
- package/dist/TraceMatrix.js +0 -1
- package/dist/utils.js +0 -3
- package/package.json +1 -1
package/dist/DPolygon.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DPolygon = exports.MIN_POINTS_IN_VALID_POLYGON = void 0;
|
|
4
|
-
/* eslint-disable max-lines */
|
|
5
4
|
const DPoint_1 = require("./DPoint");
|
|
6
5
|
const DLine_1 = require("./DLine");
|
|
7
6
|
const DCircle_1 = require("./DCircle");
|
|
@@ -14,34 +13,12 @@ const APPROXIMATION_VALUE = 0.1;
|
|
|
14
13
|
const MAX_CONVEX_ITERATIONS = 100;
|
|
15
14
|
const CLOSE_TO_INTERSECTION_DISTANCE = 0.001;
|
|
16
15
|
class DPolygon {
|
|
17
|
-
// eslint-disable-next-line no-useless-constructor,no-empty-function
|
|
18
16
|
constructor(pPoints = []) {
|
|
19
17
|
this.pPoints = pPoints;
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
18
|
this.properties = {};
|
|
22
19
|
this.holes = [];
|
|
23
20
|
this.searchStore = {};
|
|
24
21
|
}
|
|
25
|
-
/**
|
|
26
|
-
* Transform array of triangles to Three.JS vertices
|
|
27
|
-
*
|
|
28
|
-
* ```
|
|
29
|
-
* const geometry = new THREE.BufferGeometry();
|
|
30
|
-
* // create a simple square shape. We duplicate the top left and bottom right
|
|
31
|
-
* // vertices because each vertex needs to appear once per triangle.
|
|
32
|
-
* const vertices = new Float32Array( DPolygon.arrayOfTrianglesToVertices(triangles, 10) );
|
|
33
|
-
*
|
|
34
|
-
* // itemSize = 3 because there are 3 values (components) per vertex
|
|
35
|
-
* geometry.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
|
|
36
|
-
* const material = new THREE.MeshBasicMaterial( { color: 0xff0000 } );
|
|
37
|
-
* mesh = new THREE.Mesh( geometry, material );
|
|
38
|
-
*
|
|
39
|
-
* scene.add( mesh );
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* @param triangles
|
|
43
|
-
* @param [height=0]
|
|
44
|
-
*/
|
|
45
22
|
static arrayOfTrianglesToVertices(triangles, height = 0) {
|
|
46
23
|
return triangles.map((v) => v
|
|
47
24
|
.loop()
|
|
@@ -50,18 +27,10 @@ class DPolygon {
|
|
|
50
27
|
.toArrayOfCoords())
|
|
51
28
|
.flat(2);
|
|
52
29
|
}
|
|
53
|
-
/**
|
|
54
|
-
* Get size of min area rectangle.
|
|
55
|
-
* @param poly should be `minAreaRectangle`
|
|
56
|
-
*/
|
|
57
30
|
static minAreaRectangleSize(poly) {
|
|
58
31
|
const { first, second, last } = poly.clone().open();
|
|
59
32
|
return new DPoint_1.DPoint(first.distance(second), first.distance(last));
|
|
60
33
|
}
|
|
61
|
-
/**
|
|
62
|
-
* Slice line string to dashes.
|
|
63
|
-
* @param poly should be `divideToPieces` at first
|
|
64
|
-
*/
|
|
65
34
|
static toDash(poly) {
|
|
66
35
|
let p = new DPolygon();
|
|
67
36
|
const result = [p];
|
|
@@ -81,10 +50,6 @@ class DPolygon {
|
|
|
81
50
|
}
|
|
82
51
|
return result;
|
|
83
52
|
}
|
|
84
|
-
/**
|
|
85
|
-
* Get min area rectangle direction
|
|
86
|
-
* @param poly should be `minAreaRectangle`
|
|
87
|
-
*/
|
|
88
53
|
static minAreaRectangleDirection(poly) {
|
|
89
54
|
const { first, second, last } = poly.clone().open();
|
|
90
55
|
if (!first || !second || !last) {
|
|
@@ -145,39 +110,21 @@ class DPolygon {
|
|
|
145
110
|
get minY() {
|
|
146
111
|
return this.pPoints.reduce((a, r) => Math.min(a, r.y), Infinity);
|
|
147
112
|
}
|
|
148
|
-
/**
|
|
149
|
-
* Get center coordinates
|
|
150
|
-
*/
|
|
151
113
|
get center() {
|
|
152
114
|
return this.leftTop.move(this.size.divide(2));
|
|
153
115
|
}
|
|
154
|
-
/**
|
|
155
|
-
* Difference between `maxY` and `minY`. Equal `ΔY` (`dY`)
|
|
156
|
-
*/
|
|
157
116
|
get h() {
|
|
158
117
|
return this.maxY - this.minY;
|
|
159
118
|
}
|
|
160
|
-
/**
|
|
161
|
-
* Difference between `maxX` and `minX`. Equal `ΔX` (`dX`)
|
|
162
|
-
*/
|
|
163
119
|
get w() {
|
|
164
120
|
return this.maxX - this.minX;
|
|
165
121
|
}
|
|
166
|
-
/**
|
|
167
|
-
* Difference between `maxY` and `minY`. Equal `height` (`h`)
|
|
168
|
-
*/
|
|
169
122
|
get dY() {
|
|
170
123
|
return this.h;
|
|
171
124
|
}
|
|
172
|
-
/**
|
|
173
|
-
* Difference between `maxX` and `minX`. Equal `width` (`w`)
|
|
174
|
-
*/
|
|
175
125
|
get dX() {
|
|
176
126
|
return this.w;
|
|
177
127
|
}
|
|
178
|
-
/**
|
|
179
|
-
* Get closed extend polygon
|
|
180
|
-
*/
|
|
181
128
|
get extend() {
|
|
182
129
|
const { minX, minY, maxX, maxY } = this;
|
|
183
130
|
return new DPolygon([
|
|
@@ -188,42 +135,24 @@ class DPolygon {
|
|
|
188
135
|
new DPoint_1.DPoint(minX, minY)
|
|
189
136
|
]);
|
|
190
137
|
}
|
|
191
|
-
/**
|
|
192
|
-
* Point with `width` value as `x` and `height` value as `y`
|
|
193
|
-
*/
|
|
194
138
|
get size() {
|
|
195
139
|
const { w, h } = this;
|
|
196
140
|
return new DPoint_1.DPoint(w, h);
|
|
197
141
|
}
|
|
198
|
-
/**
|
|
199
|
-
* Point with minimal `x` and `y`
|
|
200
|
-
*/
|
|
201
142
|
get leftTop() {
|
|
202
143
|
const { minX, minY } = this;
|
|
203
144
|
return new DPoint_1.DPoint(minX, minY);
|
|
204
145
|
}
|
|
205
|
-
/**
|
|
206
|
-
* Point with maximal `x` and `y`
|
|
207
|
-
*/
|
|
208
146
|
get rightBottom() {
|
|
209
147
|
const { maxX, maxY } = this;
|
|
210
148
|
return new DPoint_1.DPoint(maxX, maxY);
|
|
211
149
|
}
|
|
212
|
-
/**
|
|
213
|
-
* Next point index
|
|
214
|
-
*/
|
|
215
150
|
get length() {
|
|
216
151
|
return this.pPoints.length;
|
|
217
152
|
}
|
|
218
|
-
/**
|
|
219
|
-
* Get length of line string.
|
|
220
|
-
*/
|
|
221
153
|
get fullLength() {
|
|
222
154
|
return this.clone().open().perimeter;
|
|
223
155
|
}
|
|
224
|
-
/**
|
|
225
|
-
* Get perimeter.
|
|
226
|
-
*/
|
|
227
156
|
get perimeter() {
|
|
228
157
|
let p = 0;
|
|
229
158
|
for (let i = 1; i < this.pPoints.length; i++) {
|
|
@@ -231,9 +160,6 @@ class DPolygon {
|
|
|
231
160
|
}
|
|
232
161
|
return p;
|
|
233
162
|
}
|
|
234
|
-
/**
|
|
235
|
-
* Get polygon area
|
|
236
|
-
*/
|
|
237
163
|
get area() {
|
|
238
164
|
const closed = this.deintersection;
|
|
239
165
|
let sum = 0;
|
|
@@ -244,9 +170,6 @@ class DPolygon {
|
|
|
244
170
|
}
|
|
245
171
|
return Math.abs(sum / 2) - this.holes.reduce((a, hole) => a + hole.area, 0);
|
|
246
172
|
}
|
|
247
|
-
/**
|
|
248
|
-
* Get deintesected polygon.
|
|
249
|
-
*/
|
|
250
173
|
get deintersection() {
|
|
251
174
|
const p = this.clone().close();
|
|
252
175
|
for (let i = 0; i < p.length - 1; i++) {
|
|
@@ -265,33 +188,18 @@ class DPolygon {
|
|
|
265
188
|
}
|
|
266
189
|
return p;
|
|
267
190
|
}
|
|
268
|
-
/**
|
|
269
|
-
* Check if polygon contain more than three points
|
|
270
|
-
*/
|
|
271
191
|
get valid() {
|
|
272
192
|
return this.length > exports.MIN_POINTS_IN_VALID_POLYGON;
|
|
273
193
|
}
|
|
274
|
-
/**
|
|
275
|
-
* Get first point
|
|
276
|
-
*/
|
|
277
194
|
get first() {
|
|
278
195
|
return this.at(0);
|
|
279
196
|
}
|
|
280
|
-
/**
|
|
281
|
-
* Get second point
|
|
282
|
-
*/
|
|
283
197
|
get second() {
|
|
284
198
|
return this.at(1);
|
|
285
199
|
}
|
|
286
|
-
/**
|
|
287
|
-
* Get last point
|
|
288
|
-
*/
|
|
289
200
|
get last() {
|
|
290
201
|
return this.at(this.length - 1);
|
|
291
202
|
}
|
|
292
|
-
/**
|
|
293
|
-
* Get min area rectangle
|
|
294
|
-
*/
|
|
295
203
|
get minAreaRectangle() {
|
|
296
204
|
const p = this.convex;
|
|
297
205
|
let resultPolygon = new DPolygon();
|
|
@@ -339,9 +247,6 @@ class DPolygon {
|
|
|
339
247
|
}
|
|
340
248
|
return resultPolygon;
|
|
341
249
|
}
|
|
342
|
-
/**
|
|
343
|
-
* Get convex polygon
|
|
344
|
-
*/
|
|
345
250
|
get convex() {
|
|
346
251
|
let p = this.clone().open();
|
|
347
252
|
const { isClockwise } = p;
|
|
@@ -382,9 +287,6 @@ class DPolygon {
|
|
|
382
287
|
}
|
|
383
288
|
return p;
|
|
384
289
|
}
|
|
385
|
-
/**
|
|
386
|
-
* Check polygon direction
|
|
387
|
-
*/
|
|
388
290
|
get isClockwise() {
|
|
389
291
|
let sum = 0;
|
|
390
292
|
const p = this.clone().close();
|
|
@@ -395,28 +297,17 @@ class DPolygon {
|
|
|
395
297
|
}
|
|
396
298
|
return sum < 0;
|
|
397
299
|
}
|
|
398
|
-
/**
|
|
399
|
-
* Get clockwise polygon
|
|
400
|
-
*/
|
|
401
300
|
get clockWise() {
|
|
402
301
|
if (this.isClockwise) {
|
|
403
302
|
return this.clone();
|
|
404
303
|
}
|
|
405
304
|
return this.clone().reverse();
|
|
406
305
|
}
|
|
407
|
-
/**
|
|
408
|
-
* Get polygon clone without holes
|
|
409
|
-
*/
|
|
410
306
|
get noHoles() {
|
|
411
307
|
const res = this.clone();
|
|
412
308
|
res.holes = [];
|
|
413
309
|
return res;
|
|
414
310
|
}
|
|
415
|
-
/**
|
|
416
|
-
* Check polygon intersection with line
|
|
417
|
-
* @param l
|
|
418
|
-
* @param [includeOnly=false]
|
|
419
|
-
*/
|
|
420
311
|
intersection(l, includeOnly = false) {
|
|
421
312
|
const res = [];
|
|
422
313
|
for (let i = 0; i < this.pPoints.length - 1; i++) {
|
|
@@ -430,18 +321,11 @@ class DPolygon {
|
|
|
430
321
|
}
|
|
431
322
|
return res;
|
|
432
323
|
}
|
|
433
|
-
/**
|
|
434
|
-
* Set polygon center
|
|
435
|
-
* @param newCenter
|
|
436
|
-
*/
|
|
437
324
|
setCenter(newCenter) {
|
|
438
325
|
return this.loop()
|
|
439
326
|
.move(newCenter.clone().move(this.center.minus()))
|
|
440
327
|
.run();
|
|
441
328
|
}
|
|
442
|
-
/**
|
|
443
|
-
* @param [type = DPolygon.WKT_POLYGON] Available values `DPolygon.WKT_POLYGON`, `DPolygon.WKT_LINESTRING`
|
|
444
|
-
*/
|
|
445
329
|
toWKT(type = DPolygon.WKT_POLYGON) {
|
|
446
330
|
if (type === DPolygon.WKT_POLYGON) {
|
|
447
331
|
let h = '';
|
|
@@ -455,10 +339,6 @@ class DPolygon {
|
|
|
455
339
|
return `LINESTRING (${this.pPoints.map((r) => `${r.x} ${r.y}`)
|
|
456
340
|
.join(', ')})`;
|
|
457
341
|
}
|
|
458
|
-
/**
|
|
459
|
-
* Filter points
|
|
460
|
-
* @param f
|
|
461
|
-
*/
|
|
462
342
|
filter(f) {
|
|
463
343
|
this.pPoints = this.pPoints.filter(f);
|
|
464
344
|
return this;
|
|
@@ -496,9 +376,6 @@ class DPolygon {
|
|
|
496
376
|
toString() {
|
|
497
377
|
return `(${this.pPoints.map((r) => r.toString()).join(', ')})`;
|
|
498
378
|
}
|
|
499
|
-
/**
|
|
500
|
-
* Add to the end of polygon point equal to first point if it not exist
|
|
501
|
-
*/
|
|
502
379
|
close() {
|
|
503
380
|
const p0 = this.first;
|
|
504
381
|
if (p0 && !this.closed) {
|
|
@@ -506,9 +383,6 @@ class DPolygon {
|
|
|
506
383
|
}
|
|
507
384
|
return this;
|
|
508
385
|
}
|
|
509
|
-
/**
|
|
510
|
-
* Remove from the end of polygon point equal to first point if it exist
|
|
511
|
-
*/
|
|
512
386
|
open() {
|
|
513
387
|
const p = this.first;
|
|
514
388
|
if (this.length > 2 && p && this.closed) {
|
|
@@ -521,10 +395,6 @@ class DPolygon {
|
|
|
521
395
|
res.holes = [...this.holes, ...poly.holes].map((h) => h.clone());
|
|
522
396
|
return res;
|
|
523
397
|
}
|
|
524
|
-
/**
|
|
525
|
-
* Check if has point in list of points
|
|
526
|
-
* @param p
|
|
527
|
-
*/
|
|
528
398
|
has(p) {
|
|
529
399
|
return this.pPoints.some((q) => q.equal(p));
|
|
530
400
|
}
|
|
@@ -534,10 +404,6 @@ class DPolygon {
|
|
|
534
404
|
res.properties = this.properties;
|
|
535
405
|
return res;
|
|
536
406
|
}
|
|
537
|
-
/**
|
|
538
|
-
* Check is it fully equal.
|
|
539
|
-
* @param p
|
|
540
|
-
*/
|
|
541
407
|
equal(p) {
|
|
542
408
|
if (!(p instanceof DPolygon)) {
|
|
543
409
|
return false;
|
|
@@ -548,10 +414,6 @@ class DPolygon {
|
|
|
548
414
|
return (this.same(p) &&
|
|
549
415
|
this.holes.reduce((a, hole) => a && p.holes.some((pHoles) => pHoles.same(hole)), true));
|
|
550
416
|
}
|
|
551
|
-
/**
|
|
552
|
-
* Check is polygons are same. They can be with different directions and different start points.
|
|
553
|
-
* @param p
|
|
554
|
-
*/
|
|
555
417
|
same(p) {
|
|
556
418
|
const pClone = p.clone().close();
|
|
557
419
|
const thisAsString = this.clone()
|
|
@@ -569,11 +431,6 @@ class DPolygon {
|
|
|
569
431
|
findIndex(p) {
|
|
570
432
|
return this.points.findIndex((t) => t.equal(p));
|
|
571
433
|
}
|
|
572
|
-
/**
|
|
573
|
-
* Get polygon approximation by
|
|
574
|
-
* [Ramer–Douglas–Peucker algorithm](https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm)
|
|
575
|
-
* @param [e=Math.sqrt(this.perimeter)*APPROXIMATION_VALUE]
|
|
576
|
-
*/
|
|
577
434
|
approximation(e = Math.sqrt(this.perimeter) * APPROXIMATION_VALUE) {
|
|
578
435
|
return new DPolygon(this.clone().douglasPeucker(this.pPoints, e));
|
|
579
436
|
}
|
|
@@ -583,10 +440,6 @@ class DPolygon {
|
|
|
583
440
|
removePart(index, count) {
|
|
584
441
|
return this.pPoints.splice(index + 1, count);
|
|
585
442
|
}
|
|
586
|
-
/**
|
|
587
|
-
* Check intersection with other polygon
|
|
588
|
-
* @param p
|
|
589
|
-
*/
|
|
590
443
|
hasSimpleIntersection(p) {
|
|
591
444
|
const extend1 = this.extend;
|
|
592
445
|
const extend2 = p.extend;
|
|
@@ -596,10 +449,6 @@ class DPolygon {
|
|
|
596
449
|
const in2 = extend2points.some((t) => extend1.simpleInclude(t));
|
|
597
450
|
return in1 || in2;
|
|
598
451
|
}
|
|
599
|
-
/**
|
|
600
|
-
* Check if it possible to include point
|
|
601
|
-
* @param p
|
|
602
|
-
*/
|
|
603
452
|
simpleInclude(p) {
|
|
604
453
|
return this.simpleIncludeX(p) && this.simpleIncludeY(p);
|
|
605
454
|
}
|
|
@@ -643,12 +492,6 @@ class DPolygon {
|
|
|
643
492
|
ctx.fill();
|
|
644
493
|
ctx.globalCompositeOperation = old;
|
|
645
494
|
}
|
|
646
|
-
/**
|
|
647
|
-
* Check if contain point
|
|
648
|
-
* @param p
|
|
649
|
-
* @param [isBorderInside=false]
|
|
650
|
-
* @param [move=(0,0)] Ignore this parameter
|
|
651
|
-
*/
|
|
652
495
|
contain(p, isBorderInside = false, move = DPoint_1.DPoint.zero()) {
|
|
653
496
|
const simpleInclude = this.simpleInclude(p);
|
|
654
497
|
if (!simpleInclude) {
|
|
@@ -674,10 +517,6 @@ class DPolygon {
|
|
|
674
517
|
}
|
|
675
518
|
return intersectionPoints.length % 2 === 1;
|
|
676
519
|
}
|
|
677
|
-
/**
|
|
678
|
-
* Check if point on border
|
|
679
|
-
* @param p
|
|
680
|
-
*/
|
|
681
520
|
onBorder(p) {
|
|
682
521
|
const simpleInclude = this.simpleInclude(p);
|
|
683
522
|
if (simpleInclude) {
|
|
@@ -698,18 +537,12 @@ class DPolygon {
|
|
|
698
537
|
}
|
|
699
538
|
return false;
|
|
700
539
|
}
|
|
701
|
-
/**
|
|
702
|
-
* Change start point to second point
|
|
703
|
-
*/
|
|
704
540
|
nextStart() {
|
|
705
541
|
this.open();
|
|
706
542
|
this.push(this.shift());
|
|
707
543
|
this.close();
|
|
708
544
|
return this;
|
|
709
545
|
}
|
|
710
|
-
/**
|
|
711
|
-
* Remove duplicates points
|
|
712
|
-
*/
|
|
713
546
|
removeDuplicates() {
|
|
714
547
|
for (let i = 0; i < this.length - 1; i++) {
|
|
715
548
|
const p1 = this.at(i);
|
|
@@ -724,17 +557,9 @@ class DPolygon {
|
|
|
724
557
|
static parse(a) {
|
|
725
558
|
return new DPolygon(a.map((r) => DPoint_1.DPoint.parse(r)));
|
|
726
559
|
}
|
|
727
|
-
/**
|
|
728
|
-
* Transform to array of coordinates for [OpenLayers](https://openlayers.org/) or
|
|
729
|
-
* [GeoJSON](https://en.wikipedia.org/wiki/GeoJSON)
|
|
730
|
-
*/
|
|
731
560
|
toArrayOfCoords() {
|
|
732
561
|
return this.pPoints.map((r) => r.toCoords());
|
|
733
562
|
}
|
|
734
|
-
/**
|
|
735
|
-
* Divide line string to pieces by length
|
|
736
|
-
* @param piecesCount
|
|
737
|
-
*/
|
|
738
563
|
divideToPieces(piecesCount) {
|
|
739
564
|
const { fullLength } = this;
|
|
740
565
|
const pieceLength = fullLength / piecesCount;
|
|
@@ -787,13 +612,8 @@ class DPolygon {
|
|
|
787
612
|
}
|
|
788
613
|
return this.searchStore[x][y][z || 'undefined'];
|
|
789
614
|
}
|
|
790
|
-
/**
|
|
791
|
-
* Get line string as line string with growing length. For animation.
|
|
792
|
-
*/
|
|
793
615
|
get growingPiecesGenerator() {
|
|
794
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias,consistent-this
|
|
795
616
|
const polygon = this;
|
|
796
|
-
// eslint-disable-next-line func-names
|
|
797
617
|
return function* () {
|
|
798
618
|
const r = new DPolygon();
|
|
799
619
|
for (const p of polygon.pPoints) {
|
|
@@ -846,11 +666,6 @@ class DPolygon {
|
|
|
846
666
|
}
|
|
847
667
|
return res;
|
|
848
668
|
}
|
|
849
|
-
/**
|
|
850
|
-
* Divide polygon to triangles
|
|
851
|
-
*
|
|
852
|
-
* 
|
|
853
|
-
*/
|
|
854
669
|
toTriangles() {
|
|
855
670
|
const innerAndNotIntersect = (poly, p1, p2) => {
|
|
856
671
|
const l = p1.findLine(p2);
|
|
@@ -904,9 +719,6 @@ class DPolygon {
|
|
|
904
719
|
res.push(p);
|
|
905
720
|
return res;
|
|
906
721
|
}
|
|
907
|
-
/**
|
|
908
|
-
* Divide polygon to triangles and return points indexes
|
|
909
|
-
*/
|
|
910
722
|
getTrianglesPointIndexes() {
|
|
911
723
|
const innerAndNotIntersect = (poly, p1, p2) => {
|
|
912
724
|
const l = p1.findLine(p2);
|
|
@@ -973,11 +785,6 @@ class DPolygon {
|
|
|
973
785
|
get closed() {
|
|
974
786
|
return this.first.equal(this.last);
|
|
975
787
|
}
|
|
976
|
-
/**
|
|
977
|
-
* @param v
|
|
978
|
-
* @param [quadrantSegments=64]
|
|
979
|
-
* @param [type=DPolygon.CAP_ROUND] DPolygon.CAP_ROUND || DPolygon.CAP_FLAT || DPolygon.CAP_SQUARE
|
|
980
|
-
*/
|
|
981
788
|
buffer(v, quadrantSegments = 64, type = DPolygon.CAP_ROUND) {
|
|
982
789
|
const reader = new jsts_1.io.WKTReader();
|
|
983
790
|
const { noHoles, closed } = this;
|
|
@@ -1047,7 +854,6 @@ class DPolygon {
|
|
|
1047
854
|
totalFi -= fiDif;
|
|
1048
855
|
}
|
|
1049
856
|
}
|
|
1050
|
-
// eslint-disable-next-line no-magic-numbers
|
|
1051
857
|
const eps = Math.PI / 10000;
|
|
1052
858
|
let result = false;
|
|
1053
859
|
const absTotalFi = Math.abs(totalFi);
|
|
@@ -1148,17 +954,8 @@ class DPolygon {
|
|
|
1148
954
|
}
|
|
1149
955
|
}
|
|
1150
956
|
exports.DPolygon = DPolygon;
|
|
1151
|
-
/**
|
|
1152
|
-
* Specifies a round line buffer end cap style.
|
|
1153
|
-
*/
|
|
1154
957
|
DPolygon.CAP_ROUND = CAP_ROUND;
|
|
1155
|
-
/**
|
|
1156
|
-
* Specifies a flat line buffer end cap style.
|
|
1157
|
-
*/
|
|
1158
958
|
DPolygon.CAP_FLAT = CAP_FLAT;
|
|
1159
|
-
/**
|
|
1160
|
-
* Specifies a square line buffer end cap style.
|
|
1161
|
-
*/
|
|
1162
959
|
DPolygon.CAP_SQUARE = CAP_SQUARE;
|
|
1163
960
|
DPolygon.WKT_LINESTRING = 'LINESTRING';
|
|
1164
961
|
DPolygon.WKT_POLYGON = 'POLYGON';
|
package/dist/DPolygonLoop.d.ts
CHANGED
|
@@ -6,102 +6,30 @@ export declare class DPolygonLoop {
|
|
|
6
6
|
private pool;
|
|
7
7
|
constructor(parent: DPolygon);
|
|
8
8
|
private getLoopFunction;
|
|
9
|
-
/**
|
|
10
|
-
* Run loop
|
|
11
|
-
*/
|
|
12
9
|
run(): DPolygon;
|
|
13
|
-
/**
|
|
14
|
-
* @param zoom default value would be `z` of point
|
|
15
|
-
*/
|
|
16
10
|
getTileFromCoords(zoom?: number): DPolygonLoop;
|
|
17
|
-
/**
|
|
18
|
-
* @param zoom default value would be `z` of point
|
|
19
|
-
*/
|
|
20
11
|
getCoordsFromTile(zoom?: number): DPolygonLoop;
|
|
21
12
|
height(z: number): DPolygonLoop;
|
|
22
|
-
/**
|
|
23
|
-
* Set `x` value
|
|
24
|
-
* @param x
|
|
25
|
-
*/
|
|
26
13
|
setX(x: number): DPolygonLoop;
|
|
27
|
-
/**
|
|
28
|
-
* Transform `x` value by function
|
|
29
|
-
* @param f
|
|
30
|
-
*/
|
|
31
14
|
setX(f: SetterFunction): DPolygonLoop;
|
|
32
|
-
/**
|
|
33
|
-
* Set `y` value
|
|
34
|
-
* @param y
|
|
35
|
-
*/
|
|
36
15
|
setY(y: number): DPolygonLoop;
|
|
37
|
-
/**
|
|
38
|
-
* Transform `y` value by function
|
|
39
|
-
* @param f
|
|
40
|
-
*/
|
|
41
16
|
setY(f: SetterFunction): DPolygonLoop;
|
|
42
|
-
/**
|
|
43
|
-
* Set `z` value
|
|
44
|
-
* @param z
|
|
45
|
-
*/
|
|
46
17
|
setZ(z: number): DPolygonLoop;
|
|
47
|
-
/**
|
|
48
|
-
* Transform `z` value by function
|
|
49
|
-
* @param f
|
|
50
|
-
*/
|
|
51
18
|
setZ(f: SetterFunction): DPolygonLoop;
|
|
52
19
|
rotate(a: number): DPolygonLoop;
|
|
53
|
-
/**
|
|
54
|
-
* Add `v` to `x` and `y`
|
|
55
|
-
* @param v
|
|
56
|
-
*/
|
|
57
20
|
move(v: number): DPolygonLoop;
|
|
58
|
-
/**
|
|
59
|
-
* Add `p.x` to `x` field and `p.y` to `y` field.
|
|
60
|
-
* @param p
|
|
61
|
-
*/
|
|
62
21
|
move(p: DPoint): DPolygonLoop;
|
|
63
|
-
/**
|
|
64
|
-
* Add `x` to `x` field and `y` to `y` field.
|
|
65
|
-
* @param x
|
|
66
|
-
* @param y
|
|
67
|
-
*/
|
|
68
22
|
move(x: number, y: number): DPolygonLoop;
|
|
69
23
|
round(): DPolygonLoop;
|
|
70
24
|
ceil(): DPolygonLoop;
|
|
71
25
|
floor(): DPolygonLoop;
|
|
72
26
|
toFixed(n?: number): DPolygonLoop;
|
|
73
27
|
abs(): DPolygonLoop;
|
|
74
|
-
/**
|
|
75
|
-
* Multiply `v` to `x` and `y`
|
|
76
|
-
* @param v
|
|
77
|
-
*/
|
|
78
28
|
scale(v: number): DPolygonLoop;
|
|
79
|
-
/**
|
|
80
|
-
* Multiply `p.x` to `x` field and `p.y` to `y` field.
|
|
81
|
-
* @param p
|
|
82
|
-
*/
|
|
83
29
|
scale(p: DPoint): DPolygonLoop;
|
|
84
|
-
/**
|
|
85
|
-
* Multiply `x` to `x` field and `y` to `y` field.
|
|
86
|
-
* @param x
|
|
87
|
-
* @param y
|
|
88
|
-
*/
|
|
89
30
|
scale(x: number, y: number): DPolygonLoop;
|
|
90
|
-
/**
|
|
91
|
-
* Divide `x` and `y` to `v`
|
|
92
|
-
* @param v
|
|
93
|
-
*/
|
|
94
31
|
divide(v: number): DPolygonLoop;
|
|
95
|
-
/**
|
|
96
|
-
* Divide `x` field to `p.x` and `y` field to `p.y`.
|
|
97
|
-
* @param p
|
|
98
|
-
*/
|
|
99
32
|
divide(p: DPoint): DPolygonLoop;
|
|
100
|
-
/**
|
|
101
|
-
* Divide `x` field to `x` and `y` field to `y`.
|
|
102
|
-
* @param x
|
|
103
|
-
* @param y
|
|
104
|
-
*/
|
|
105
33
|
divide(x: number, y: number): DPolygonLoop;
|
|
106
34
|
degreeToRadians(): DPolygonLoop;
|
|
107
35
|
radiansToDegrees(): DPolygonLoop;
|
|
@@ -116,14 +44,6 @@ export declare class DPolygonLoop {
|
|
|
116
44
|
minus(): DPolygonLoop;
|
|
117
45
|
degreeToMeters(): DPolygonLoop;
|
|
118
46
|
metersToDegree(): DPolygonLoop;
|
|
119
|
-
/**
|
|
120
|
-
* Flip vertically
|
|
121
|
-
* @param size canvas size
|
|
122
|
-
*/
|
|
123
47
|
flipVertically(size: DPoint): DPolygonLoop;
|
|
124
|
-
/**
|
|
125
|
-
* Flip vertically
|
|
126
|
-
* @param height canvas height
|
|
127
|
-
*/
|
|
128
48
|
flipVertically(height: number): DPolygonLoop;
|
|
129
49
|
}
|
package/dist/DPolygonLoop.js
CHANGED
|
@@ -33,10 +33,8 @@ var LoopFunctions;
|
|
|
33
33
|
LoopFunctions[LoopFunctions["metersToDegree"] = 27] = "metersToDegree";
|
|
34
34
|
LoopFunctions[LoopFunctions["flipVertically"] = 28] = "flipVertically";
|
|
35
35
|
})(LoopFunctions || (LoopFunctions = {}));
|
|
36
|
-
// eslint-disable-next-line complexity
|
|
37
36
|
const decodePoolRecord = (a, { functionName, pointArg, numberPointArg, numberArg, setterArg }) => {
|
|
38
37
|
let res = a;
|
|
39
|
-
// eslint-disable-next-line default-case
|
|
40
38
|
switch (functionName) {
|
|
41
39
|
case LoopFunctions.getTileFromCoords:
|
|
42
40
|
res = (k) => a(k)
|
|
@@ -158,7 +156,6 @@ const decodePoolRecord = (a, { functionName, pointArg, numberPointArg, numberArg
|
|
|
158
156
|
return res;
|
|
159
157
|
};
|
|
160
158
|
class DPolygonLoop {
|
|
161
|
-
// eslint-disable-next-line no-empty-function,no-useless-constructor
|
|
162
159
|
constructor(parent) {
|
|
163
160
|
this.parent = parent;
|
|
164
161
|
this.pool = [];
|
|
@@ -166,15 +163,9 @@ class DPolygonLoop {
|
|
|
166
163
|
getLoopFunction() {
|
|
167
164
|
return this.pool.reduce(decodePoolRecord, (k) => k);
|
|
168
165
|
}
|
|
169
|
-
/**
|
|
170
|
-
* Run loop
|
|
171
|
-
*/
|
|
172
166
|
run() {
|
|
173
167
|
return this.parent.map(this.getLoopFunction());
|
|
174
168
|
}
|
|
175
|
-
/**
|
|
176
|
-
* @param zoom default value would be `z` of point
|
|
177
|
-
*/
|
|
178
169
|
getTileFromCoords(zoom) {
|
|
179
170
|
this.pool.push({
|
|
180
171
|
functionName: LoopFunctions.getTileFromCoords,
|
|
@@ -182,9 +173,6 @@ class DPolygonLoop {
|
|
|
182
173
|
});
|
|
183
174
|
return this;
|
|
184
175
|
}
|
|
185
|
-
/**
|
|
186
|
-
* @param zoom default value would be `z` of point
|
|
187
|
-
*/
|
|
188
176
|
getCoordsFromTile(zoom) {
|
|
189
177
|
this.pool.push({
|
|
190
178
|
functionName: LoopFunctions.getCoordsFromTile,
|
package/dist/TraceMatrix.js
CHANGED
|
@@ -96,7 +96,6 @@ class TraceMatrix {
|
|
|
96
96
|
let prevDirection = Infinity;
|
|
97
97
|
let p = group.at(0);
|
|
98
98
|
while (!p.equal(group.at(0)) || points.length < 2) {
|
|
99
|
-
// eslint-disable-next-line no-constant-condition
|
|
100
99
|
while (true) {
|
|
101
100
|
const nextValue = getByPosition(m, p.clone().move(traceDirections[direction]));
|
|
102
101
|
const nextNeighbourValue = getByPosition(m, p.clone().move(traceDirections[left(direction)]));
|
package/dist/utils.js
CHANGED
|
@@ -3,10 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createArray = exports.checkFunction = exports.warn = void 0;
|
|
4
4
|
const index_1 = require("./index");
|
|
5
5
|
const DPoint_1 = require("./DPoint");
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
6
|
const warn = (...args) => {
|
|
8
7
|
if (index_1.DGeo.DEBUG) {
|
|
9
|
-
// eslint-disable-next-line no-console
|
|
10
8
|
console.warn(...args);
|
|
11
9
|
}
|
|
12
10
|
};
|
|
@@ -45,7 +43,6 @@ const shouldBeMeters = (scope, funcName, argName) => (p) => {
|
|
|
45
43
|
return scope;
|
|
46
44
|
};
|
|
47
45
|
const checkFunction = (funcName) => ({
|
|
48
|
-
// eslint-disable-next-line func-names, object-shorthand
|
|
49
46
|
checkArgument: function (argName) {
|
|
50
47
|
if (!index_1.DGeo.DEBUG) {
|
|
51
48
|
return {
|