dgeoutils 2.3.3 → 2.3.4

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.
@@ -30,7 +30,8 @@ export declare class DLine {
30
30
  get points(): [DPoint, DPoint];
31
31
  getFi(): number;
32
32
  toWKT(): string;
33
- movePoint(p: DPoint, d: number): DPoint;
33
+ movePoint(point: DPoint, distance: number): DPoint;
34
+ movePoint(points: DPoint[], distances: number[]): DPoint[];
34
35
  findFi({ a, b }: DLine, delta?: number): number;
35
36
  vectorProduct({ a, b, c }: DLine): DLine;
36
37
  }
package/dist/cjs/DLine.js CHANGED
@@ -262,20 +262,28 @@ var DLine = (function () {
262
262
  var _a = this, _b = _a.begin, x1 = _b.x, y1 = _b.y, _c = _a.end, x2 = _c.x, y2 = _c.y;
263
263
  return "LINESTRING (" + x1 + " " + y1 + ", " + x2 + " " + y2 + ")";
264
264
  };
265
- DLine.prototype.movePoint = function (p, d) {
265
+ DLine.prototype.movePoint = function (i, k) {
266
+ var p = Array.isArray(i) ? i : [i];
267
+ var d = Array.isArray(k) ? k : [k];
266
268
  var fi = this.findFi(new DLine(1, 0, 0));
267
269
  var td = this.x(new DPoint_1.DPoint(1, 1)).distance(this.x(new DPoint_1.DPoint(2, 2))) / 2;
268
270
  var sinCos = new DPoint_1.DPoint(Math.sin(fi), Math.cos(fi));
269
271
  var dt = sinCos.clone().scale(td);
270
- var p1T = p.clone().move(dt.clone().minus());
271
- var p2T = p.clone().move(dt);
272
+ var p1T = p[0].clone().move(dt.clone().minus());
273
+ var p2T = p[0].clone().move(dt);
274
+ var res = [];
272
275
  if (DNumbers_1.DNumbers.like(this.y(p1T).y, p1T.y) || DNumbers_1.DNumbers.like(this.y(p2T).y, p2T.y)) {
273
- return p.clone().move(sinCos.scale(d));
276
+ res = p.map(function (t, index) { return t.clone().move(sinCos.scale(d[index])); });
274
277
  }
275
- return p.clone().move(sinCos.scale(d).setX(function (_a) {
276
- var x = _a.x;
277
- return -x;
278
- }));
278
+ else {
279
+ res = p.map(function (t, index) { return t.clone()
280
+ .move(sinCos.scale(d[index])
281
+ .setX(function (_a) {
282
+ var x = _a.x;
283
+ return -x;
284
+ })); });
285
+ }
286
+ return res.length === 1 ? res[0] : res;
279
287
  };
280
288
  DLine.prototype.findFi = function (_a, delta) {
281
289
  var a = _a.a, b = _a.b;
@@ -217,17 +217,25 @@ export class DLine {
217
217
  const { begin: { x: x1, y: y1 }, end: { x: x2, y: y2 } } = this;
218
218
  return `LINESTRING (${x1} ${y1}, ${x2} ${y2})`;
219
219
  }
220
- movePoint(p, d) {
220
+ movePoint(i, k) {
221
+ const p = Array.isArray(i) ? i : [i];
222
+ const d = Array.isArray(k) ? k : [k];
221
223
  const fi = this.findFi(new DLine(1, 0, 0));
222
224
  const td = this.x(new DPoint(1, 1)).distance(this.x(new DPoint(2, 2))) / 2;
223
225
  const sinCos = new DPoint(Math.sin(fi), Math.cos(fi));
224
226
  const dt = sinCos.clone().scale(td);
225
- const p1T = p.clone().move(dt.clone().minus());
226
- const p2T = p.clone().move(dt);
227
+ const p1T = p[0].clone().move(dt.clone().minus());
228
+ const p2T = p[0].clone().move(dt);
229
+ let res = [];
227
230
  if (DNumbers.like(this.y(p1T).y, p1T.y) || DNumbers.like(this.y(p2T).y, p2T.y)) {
228
- return p.clone().move(sinCos.scale(d));
231
+ res = p.map((t, index) => t.clone().move(sinCos.scale(d[index])));
229
232
  }
230
- return p.clone().move(sinCos.scale(d).setX(({ x }) => -x));
233
+ else {
234
+ res = p.map((t, index) => t.clone()
235
+ .move(sinCos.scale(d[index])
236
+ .setX(({ x }) => -x)));
237
+ }
238
+ return res.length === 1 ? res[0] : res;
231
239
  }
232
240
  findFi({ a, b }, delta = 1.0001) {
233
241
  const { a: q, b: w } = this;
package/dist/esm/DLine.js CHANGED
@@ -259,20 +259,28 @@ var DLine = (function () {
259
259
  var _a = this, _b = _a.begin, x1 = _b.x, y1 = _b.y, _c = _a.end, x2 = _c.x, y2 = _c.y;
260
260
  return "LINESTRING (" + x1 + " " + y1 + ", " + x2 + " " + y2 + ")";
261
261
  };
262
- DLine.prototype.movePoint = function (p, d) {
262
+ DLine.prototype.movePoint = function (i, k) {
263
+ var p = Array.isArray(i) ? i : [i];
264
+ var d = Array.isArray(k) ? k : [k];
263
265
  var fi = this.findFi(new DLine(1, 0, 0));
264
266
  var td = this.x(new DPoint(1, 1)).distance(this.x(new DPoint(2, 2))) / 2;
265
267
  var sinCos = new DPoint(Math.sin(fi), Math.cos(fi));
266
268
  var dt = sinCos.clone().scale(td);
267
- var p1T = p.clone().move(dt.clone().minus());
268
- var p2T = p.clone().move(dt);
269
+ var p1T = p[0].clone().move(dt.clone().minus());
270
+ var p2T = p[0].clone().move(dt);
271
+ var res = [];
269
272
  if (DNumbers.like(this.y(p1T).y, p1T.y) || DNumbers.like(this.y(p2T).y, p2T.y)) {
270
- return p.clone().move(sinCos.scale(d));
273
+ res = p.map(function (t, index) { return t.clone().move(sinCos.scale(d[index])); });
271
274
  }
272
- return p.clone().move(sinCos.scale(d).setX(function (_a) {
273
- var x = _a.x;
274
- return -x;
275
- }));
275
+ else {
276
+ res = p.map(function (t, index) { return t.clone()
277
+ .move(sinCos.scale(d[index])
278
+ .setX(function (_a) {
279
+ var x = _a.x;
280
+ return -x;
281
+ })); });
282
+ }
283
+ return res.length === 1 ? res[0] : res;
276
284
  };
277
285
  DLine.prototype.findFi = function (_a, delta) {
278
286
  var a = _a.a, b = _a.b;