@maplat/tin 0.11.0 → 0.11.1

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/src/kinks.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { Position } from "geojson";
1
+ import type { Position, Feature, Point } from "geojson";
2
2
  import { point } from "@turf/helpers";
3
+ import type { IntersectionPoint } from "./types/kinks.ts";
3
4
 
4
5
  /**
5
6
  * 線分の交差点を検出するメインの関数
@@ -11,14 +12,15 @@ export default function findIntersections(coords: Position[][]) {
11
12
  const arcs = new ArcCollection(coords);
12
13
  const xy = arcs.findSegmentIntersections();
13
14
  return dedupIntersections(xy).reduce(
14
- (prev: any, apoint: any, index: any, array: any) => {
15
+ (prev: Record<string, IntersectionPoint> | Feature<Point>[], apoint: IntersectionPoint, index: number, array: IntersectionPoint[]) => {
16
+ if (Array.isArray(prev)) return prev;
15
17
  if (!prev) prev = {};
16
18
  prev[`${apoint.x}:${apoint.y}`] = apoint;
17
19
  if (index != array.length - 1) return prev;
18
20
  return Object.keys(prev).map(key => point([prev[key].x, prev[key].y]));
19
21
  },
20
- []
21
- );
22
+ {} as Record<string, IntersectionPoint>
23
+ ) as Feature<Point>[];
22
24
  }
23
25
 
24
26
  /**