dgeoutils 2.4.22 → 2.4.24

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.
@@ -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]>;
@@ -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();
@@ -8,6 +8,7 @@ export declare type SimpleMatrix = TraceMatrixValues[][];
8
8
  export declare class TraceMatrix {
9
9
  private readonly size;
10
10
  private readonly m;
11
+ approximation: boolean;
11
12
  constructor(size: DPoint, f: (p: DPoint) => TraceMatrixValues);
12
13
  fullMatrixTrace(): DPolygon[];
13
14
  private reverseMatrix;
@@ -64,6 +64,7 @@ var TraceMatrix = (function () {
64
64
  function TraceMatrix(size, f) {
65
65
  var _this = this;
66
66
  this.size = size;
67
+ this.approximation = true;
67
68
  this.findGroupByIndex = function (m, s) {
68
69
  var res = new DPolygon_1.DPolygon();
69
70
  if (s && getByPosition(m, s) === TraceMatrixValues.t) {
@@ -149,7 +150,10 @@ var TraceMatrix = (function () {
149
150
  p = p.clone().move(traceDirections[direction]);
150
151
  direction = left(left(direction));
151
152
  }
152
- return points.approximation().close();
153
+ if (_this.approximation) {
154
+ return points.approximation().close();
155
+ }
156
+ return points.clone().close();
153
157
  };
154
158
  this.createHoleMatrix = function (group) {
155
159
  var e_1, _a;
@@ -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) {
@@ -23,6 +23,7 @@ const setByPosition = (m, p, value) => {
23
23
  export class TraceMatrix {
24
24
  constructor(size, f) {
25
25
  this.size = size;
26
+ this.approximation = true;
26
27
  this.findGroupByIndex = (m, s) => {
27
28
  const res = new DPolygon();
28
29
  if (s && getByPosition(m, s) === TraceMatrixValues.t) {
@@ -108,7 +109,10 @@ export class TraceMatrix {
108
109
  p = p.clone().move(traceDirections[direction]);
109
110
  direction = left(left(direction));
110
111
  }
111
- return points.approximation().close();
112
+ if (this.approximation) {
113
+ return points.approximation().close();
114
+ }
115
+ return points.clone().close();
112
116
  };
113
117
  this.createHoleMatrix = (group) => {
114
118
  const fullTraceDirections = [
@@ -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();
@@ -61,6 +61,7 @@ var TraceMatrix = (function () {
61
61
  function TraceMatrix(size, f) {
62
62
  var _this = this;
63
63
  this.size = size;
64
+ this.approximation = true;
64
65
  this.findGroupByIndex = function (m, s) {
65
66
  var res = new DPolygon();
66
67
  if (s && getByPosition(m, s) === TraceMatrixValues.t) {
@@ -146,7 +147,10 @@ var TraceMatrix = (function () {
146
147
  p = p.clone().move(traceDirections[direction]);
147
148
  direction = left(left(direction));
148
149
  }
149
- return points.approximation().close();
150
+ if (_this.approximation) {
151
+ return points.approximation().close();
152
+ }
153
+ return points.clone().close();
150
154
  };
151
155
  this.createHoleMatrix = function (group) {
152
156
  var e_1, _a;