dgeoutils 2.2.17 → 2.2.18

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/DPoint.d.ts CHANGED
@@ -102,5 +102,5 @@ export declare class DPoint {
102
102
  setIfLessThan(p: DPoint): DPoint;
103
103
  minus(): DPoint;
104
104
  orthodromicPath(point: DPoint, pointsCount?: number): DPolygon;
105
- findCloserPoint(p: DPolygon): DPoint;
105
+ sortByDistance(p: DPolygon): DPolygon;
106
106
  }
package/dist/DPoint.js CHANGED
@@ -462,17 +462,15 @@ class DPoint {
462
462
  return new DPoint(x, y).radiansToDegrees();
463
463
  }));
464
464
  }
465
- findCloserPoint(p) {
466
- let d = Infinity;
467
- let res = DPoint.zero();
468
- for (const t of p.points) {
469
- const td = this.distance(t);
470
- if (td < d) {
471
- d = td;
472
- res = t.clone();
473
- }
474
- }
475
- return res;
465
+ sortByDistance(p) {
466
+ return p
467
+ .clone()
468
+ .map((d, index) => {
469
+ d.properties.distance = d.distance(this);
470
+ d.properties.index = index;
471
+ return d;
472
+ })
473
+ .sort((a, b) => a.properties.distance - b.properties.distance);
476
474
  }
477
475
  }
478
476
  exports.DPoint = DPoint;
@@ -58,6 +58,7 @@ export declare class DPolygon {
58
58
  filter(f: (p: DPoint) => boolean): DPolygon;
59
59
  map(f: (r: DPoint) => DPoint): DPolygon;
60
60
  map(f: (r: DPoint, index: number) => DPoint): DPolygon;
61
+ sort(f: (a: DPoint, b: DPoint) => number): DPolygon;
61
62
  at(index: number): DPoint;
62
63
  pop(): DPoint;
63
64
  push(...args: DPoint[]): number;
package/dist/DPolygon.js CHANGED
@@ -349,6 +349,10 @@ class DPolygon {
349
349
  this.holes = this.holes.map((h) => h.map(f));
350
350
  return this;
351
351
  }
352
+ sort(f) {
353
+ this.points.sort(f);
354
+ return this;
355
+ }
352
356
  at(index) {
353
357
  const { length } = this;
354
358
  return this.points[(index % length + length) % length];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dgeoutils",
3
- "version": "2.2.17",
3
+ "version": "2.2.18",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build": "node_modules/.bin/tsc",