@math.gl/geospatial 5.0.0 → 5.0.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/dist/line-simplification.d.ts +7 -0
- package/dist/line-simplification.d.ts.map +1 -1
- package/dist/line-simplification.js +4 -13
- package/dist/line-simplification.js.map +1 -1
- package/dist/linear-referencing.d.ts +13 -1
- package/dist/linear-referencing.d.ts.map +1 -1
- package/dist/linear-referencing.js +29 -9
- package/dist/linear-referencing.js.map +1 -1
- package/dist/measure-referencing.d.ts +16 -0
- package/dist/measure-referencing.d.ts.map +1 -0
- package/dist/measure-referencing.js +143 -0
- package/dist/measure-referencing.js.map +1 -0
- package/dist/polygon-simplification.d.ts +6 -0
- package/dist/polygon-simplification.d.ts.map +1 -0
- package/dist/polygon-simplification.js +141 -0
- package/dist/polygon-simplification.js.map +1 -0
- package/dist/spatial-box-clipping.d.ts +9 -0
- package/dist/spatial-box-clipping.d.ts.map +1 -0
- package/dist/spatial-box-clipping.js +123 -0
- package/dist/spatial-box-clipping.js.map +1 -0
- package/dist/spatial-dwithin.d.ts +19 -0
- package/dist/spatial-dwithin.d.ts.map +1 -0
- package/dist/spatial-dwithin.js +107 -0
- package/dist/spatial-dwithin.js.map +1 -0
- package/dist/spatial-hulls.d.ts +6 -0
- package/dist/spatial-hulls.d.ts.map +1 -0
- package/dist/spatial-hulls.js +176 -0
- package/dist/spatial-hulls.js.map +1 -0
- package/dist/spatial-line-intersection-result.d.ts +4 -0
- package/dist/spatial-line-intersection-result.d.ts.map +1 -0
- package/dist/spatial-line-intersection-result.js +79 -0
- package/dist/spatial-line-intersection-result.js.map +1 -0
- package/dist/spatial-line-polygon-intersection.d.ts +4 -0
- package/dist/spatial-line-polygon-intersection.d.ts.map +1 -0
- package/dist/spatial-line-polygon-intersection.js +130 -0
- package/dist/spatial-line-polygon-intersection.js.map +1 -0
- package/dist/spatial-planar-intersects.d.ts +11 -0
- package/dist/spatial-planar-intersects.d.ts.map +1 -1
- package/dist/spatial-planar-intersects.js +20 -12
- package/dist/spatial-planar-intersects.js.map +1 -1
- package/dist/spatial-planar.d.ts +9 -0
- package/dist/spatial-planar.d.ts.map +1 -1
- package/dist/spatial-planar.js +13 -1
- package/dist/spatial-planar.js.map +1 -1
- package/dist/spatial-polygon-overlay.d.ts +5 -0
- package/dist/spatial-polygon-overlay.d.ts.map +1 -0
- package/dist/spatial-polygon-overlay.js +23 -0
- package/dist/spatial-polygon-overlay.js.map +1 -0
- package/dist/spatial-sql.d.ts +13 -2
- package/dist/spatial-sql.d.ts.map +1 -1
- package/dist/spatial-sql.js +30 -12
- package/dist/spatial-sql.js.map +1 -1
- package/dist/spatial-subdivision.d.ts +9 -0
- package/dist/spatial-subdivision.d.ts.map +1 -0
- package/dist/spatial-subdivision.js +61 -0
- package/dist/spatial-subdivision.js.map +1 -0
- package/dist/spatial-touches.d.ts +13 -0
- package/dist/spatial-touches.d.ts.map +1 -0
- package/dist/spatial-touches.js +192 -0
- package/dist/spatial-touches.js.map +1 -0
- package/dist/st-functions.cjs +2411 -112
- package/dist/st-functions.cjs.map +3 -3
- package/dist/st-functions.d.ts +67 -2
- package/dist/st-functions.d.ts.map +1 -1
- package/dist/st-functions.js +195 -12
- package/dist/st-functions.js.map +1 -1
- package/dist/st-geodesic-functions.d.ts +33 -0
- package/dist/st-geodesic-functions.d.ts.map +1 -0
- package/dist/st-geodesic-functions.js +84 -0
- package/dist/st-geodesic-functions.js.map +1 -0
- package/dist/st-hull-functions.cjs +386 -0
- package/dist/st-hull-functions.cjs.map +6 -0
- package/dist/st-hull-functions.d.ts +17 -0
- package/dist/st-hull-functions.d.ts.map +1 -0
- package/dist/st-hull-functions.js +14 -0
- package/dist/st-hull-functions.js.map +1 -0
- package/dist/st-overlay-functions.cjs +621 -0
- package/dist/st-overlay-functions.cjs.map +6 -0
- package/dist/st-overlay-functions.d.ts +36 -0
- package/dist/st-overlay-functions.d.ts.map +1 -0
- package/dist/st-overlay-functions.js +183 -0
- package/dist/st-overlay-functions.js.map +1 -0
- package/dist/st-viewport-functions.cjs +481 -0
- package/dist/st-viewport-functions.cjs.map +6 -0
- package/dist/st-viewport-functions.d.ts +13 -0
- package/dist/st-viewport-functions.d.ts.map +1 -0
- package/dist/st-viewport-functions.js +81 -0
- package/dist/st-viewport-functions.js.map +1 -0
- package/dist/terrain/index.cjs +93 -20
- package/dist/terrain/index.cjs.map +3 -3
- package/dist/terrain/index.d.ts +1 -0
- package/dist/terrain/index.d.ts.map +1 -1
- package/dist/terrain/index.js +1 -0
- package/dist/terrain/index.js.map +1 -1
- package/dist/terrain/regional-watersheds.d.ts +44 -0
- package/dist/terrain/regional-watersheds.d.ts.map +1 -0
- package/dist/terrain/regional-watersheds.js +108 -0
- package/dist/terrain/regional-watersheds.js.map +1 -0
- package/dist/terrain/tile-cutout-update.d.ts.map +1 -1
- package/dist/terrain/tile-cutout-update.js +28 -22
- package/dist/terrain/tile-cutout-update.js.map +1 -1
- package/dist/turf-functions.cjs +16 -9
- package/dist/turf-functions.cjs.map +1 -1
- package/package.json +21 -6
- package/src/line-simplification.ts +4 -16
- package/src/linear-referencing.ts +44 -16
- package/src/measure-referencing.ts +165 -0
- package/src/polygon-simplification.ts +185 -0
- package/src/spatial-box-clipping.ts +140 -0
- package/src/spatial-dwithin.ts +135 -0
- package/src/spatial-hulls.ts +203 -0
- package/src/spatial-line-intersection-result.ts +93 -0
- package/src/spatial-line-polygon-intersection.ts +147 -0
- package/src/spatial-planar-intersects.ts +21 -15
- package/src/spatial-planar.ts +20 -1
- package/src/spatial-polygon-overlay.ts +30 -0
- package/src/spatial-sql.ts +47 -12
- package/src/spatial-subdivision.ts +75 -0
- package/src/spatial-touches.ts +218 -0
- package/src/st-functions.ts +283 -15
- package/src/st-geodesic-functions.ts +121 -0
- package/src/st-hull-functions.ts +25 -0
- package/src/st-overlay-functions.ts +244 -0
- package/src/st-viewport-functions.ts +98 -0
- package/src/terrain/index.ts +7 -0
- package/src/terrain/regional-watersheds.ts +153 -0
- package/src/terrain/tile-cutout-update.ts +32 -26
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {WellKnownGeometry} from '@math.gl/core/arrow';
|
|
6
|
+
import {BoxIndex} from '@math.gl/geometry/spatial-index';
|
|
7
|
+
import {distanceToPlanarSegment, planarBounds} from './spatial-planar';
|
|
8
|
+
import {planarIntersects, segmentsMeet} from './spatial-planar-intersects';
|
|
9
|
+
|
|
10
|
+
/** One planar coordinate. */
|
|
11
|
+
type Position = readonly number[];
|
|
12
|
+
/** One polyline component. */
|
|
13
|
+
type Path = readonly Position[];
|
|
14
|
+
/** A segment and its two-dimensional bounds. */
|
|
15
|
+
type Segment = {
|
|
16
|
+
/** First endpoint. */
|
|
17
|
+
a: Position;
|
|
18
|
+
/** Second endpoint. */
|
|
19
|
+
b: Position;
|
|
20
|
+
/** Minimum X and Y followed by maximum X and Y. */
|
|
21
|
+
bounds: readonly [number, number, number, number];
|
|
22
|
+
};
|
|
23
|
+
/** 2D geometries with linear components. */
|
|
24
|
+
type Linear = Extract<WellKnownGeometry, {type: 'LineString' | 'MultiLineString'}>;
|
|
25
|
+
/** 2D geometries with polygonal components. */
|
|
26
|
+
type Areal = Extract<WellKnownGeometry, {type: 'Polygon' | 'MultiPolygon'}>;
|
|
27
|
+
/** A single point geometry. */
|
|
28
|
+
type Point = Extract<WellKnownGeometry, {type: 'Point'}>;
|
|
29
|
+
|
|
30
|
+
/** Candidate-pair cutoff above which a spatial index can avoid a full scan. */
|
|
31
|
+
const directPairLimit = 1024;
|
|
32
|
+
|
|
33
|
+
/** Tests a point against the filled area, hole boundaries, and exterior boundaries. */
|
|
34
|
+
export function pointWithinPolygonDistance(point: Point, polygon: Areal, radius: number): boolean {
|
|
35
|
+
const [x, y] = point.coordinates;
|
|
36
|
+
if (!Number.isFinite(x) || !Number.isFinite(y)) return false;
|
|
37
|
+
const bounds = planarBounds(polygon);
|
|
38
|
+
if (!bounds || !boxesWithin([x!, y!, x!, y!], bounds, radius)) return false;
|
|
39
|
+
if (planarIntersects(point, polygon)) return true;
|
|
40
|
+
if (radius === 0) return false;
|
|
41
|
+
const areas = polygon.type === 'Polygon' ? [polygon.coordinates] : polygon.coordinates;
|
|
42
|
+
for (const area of areas) {
|
|
43
|
+
for (const ring of area) {
|
|
44
|
+
for (let i = 0; i < ring.length; i++) {
|
|
45
|
+
const a = ring[i === 0 ? ring.length - 1 : i - 1]!;
|
|
46
|
+
const b = ring[i]!;
|
|
47
|
+
if (distanceToPlanarSegment(point.coordinates, a, b) <= radius) return true;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Keeps multiline components separate, including degenerate point-like segments. */
|
|
55
|
+
function lineSegments(geometry: Linear): Segment[] {
|
|
56
|
+
const paths: readonly Path[] =
|
|
57
|
+
geometry.type === 'LineString' ? [geometry.coordinates] : geometry.coordinates;
|
|
58
|
+
const segments: Segment[] = [];
|
|
59
|
+
for (const path of paths) {
|
|
60
|
+
if (path.some(point => !Number.isFinite(point[0]) || !Number.isFinite(point[1])))
|
|
61
|
+
throw new Error('ST_DWithin requires finite line coordinates');
|
|
62
|
+
if (!path.length) continue;
|
|
63
|
+
for (let i = 0; i < Math.max(1, path.length - 1); i++) {
|
|
64
|
+
const a = path[i]!;
|
|
65
|
+
const b = path[i + 1] ?? a;
|
|
66
|
+
segments.push({
|
|
67
|
+
a,
|
|
68
|
+
b,
|
|
69
|
+
bounds: [
|
|
70
|
+
Math.min(a[0]!, b[0]!),
|
|
71
|
+
Math.min(a[1]!, b[1]!),
|
|
72
|
+
Math.max(a[0]!, b[0]!),
|
|
73
|
+
Math.max(a[1]!, b[1]!)
|
|
74
|
+
]
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return segments;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Uses the largest axis gap as a conservative lower bound on Euclidean distance. */
|
|
82
|
+
function boxesWithin(a: readonly number[], b: readonly number[], radius: number): boolean {
|
|
83
|
+
return Math.max(a[0]! - b[2]!, b[0]! - a[2]!, a[1]! - b[3]!, b[1]! - a[3]!) <= radius;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Intersecting segments have zero gap; otherwise a closest pair includes an endpoint. */
|
|
87
|
+
function segmentsWithin(left: Segment, right: Segment, radius: number): boolean {
|
|
88
|
+
if (!boxesWithin(left.bounds, right.bounds, radius)) return false;
|
|
89
|
+
const {a, b} = left;
|
|
90
|
+
const {a: c, b: d} = right;
|
|
91
|
+
return (
|
|
92
|
+
segmentsMeet(a, b, c, d) ||
|
|
93
|
+
(radius > 0 &&
|
|
94
|
+
(distanceToPlanarSegment(a, c, d) <= radius ||
|
|
95
|
+
distanceToPlanarSegment(b, c, d) <= radius ||
|
|
96
|
+
distanceToPlanarSegment(c, a, b) <= radius ||
|
|
97
|
+
distanceToPlanarSegment(d, a, b) <= radius))
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Builds finite search bounds with enough padding to round outward. */
|
|
102
|
+
function expandBound(value: number, radius: number, direction: -1 | 1): number {
|
|
103
|
+
const padding = Math.max(Math.abs(value), radius) * Number.EPSILON;
|
|
104
|
+
return Math.max(
|
|
105
|
+
-Number.MAX_VALUE,
|
|
106
|
+
Math.min(Number.MAX_VALUE, value + direction * (radius + padding))
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Tests line pairs by exact segment refinement after rejecting distant bounds. */
|
|
111
|
+
export function linesWithinDistance(left: Linear, right: Linear, radius: number): boolean {
|
|
112
|
+
const leftBounds = planarBounds(left);
|
|
113
|
+
const rightBounds = planarBounds(right);
|
|
114
|
+
if (!leftBounds || !rightBounds || !boxesWithin(leftBounds, rightBounds, radius)) return false;
|
|
115
|
+
const a = lineSegments(left);
|
|
116
|
+
const b = lineSegments(right);
|
|
117
|
+
if (!a.length || !b.length) return false;
|
|
118
|
+
if (radius === Infinity) return true;
|
|
119
|
+
if (a.length * b.length <= directPairLimit || Math.min(a.length, b.length) < 8) {
|
|
120
|
+
return a.some(segment => b.some(candidate => segmentsWithin(segment, candidate, radius)));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const [indexed, queries] = a.length <= b.length ? [a, b] : [b, a];
|
|
124
|
+
const index = new BoxIndex({dimension: 2, bounds: indexed.flatMap(segment => segment.bounds)});
|
|
125
|
+
for (const segment of queries) {
|
|
126
|
+
const [x0, y0, x1, y1] = segment.bounds;
|
|
127
|
+
const {result} = index.searchQuery(
|
|
128
|
+
[expandBound(x0, radius, -1), expandBound(y0, radius, -1)],
|
|
129
|
+
[expandBound(x1, radius, 1), expandBound(y1, radius, 1)],
|
|
130
|
+
{filter: candidate => segmentsWithin(segment, indexed[candidate]!, radius), maxResults: 1}
|
|
131
|
+
);
|
|
132
|
+
if (result.length) return true;
|
|
133
|
+
}
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {WellKnownGeometry} from '@math.gl/core/arrow';
|
|
6
|
+
import triangulate from 'cdt2d';
|
|
7
|
+
import {orient2d} from 'robust-predicates';
|
|
8
|
+
import {visitPaths} from './spatial-planar';
|
|
9
|
+
|
|
10
|
+
/** Finite planar coordinate used by the triangulator. */
|
|
11
|
+
type Site = [number, number];
|
|
12
|
+
|
|
13
|
+
/** Collects distinct XY sites in lexicographic order. */
|
|
14
|
+
function collectSites(geometry: WellKnownGeometry): Site[] {
|
|
15
|
+
const sites: Site[] = [];
|
|
16
|
+
visitPaths(geometry, path => {
|
|
17
|
+
for (const [x, y] of path) {
|
|
18
|
+
if (Number.isFinite(x) && Number.isFinite(y)) sites.push([x!, y!]);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
sites.sort((a, b) => a[0] - b[0] || a[1] - b[1]);
|
|
22
|
+
return sites.filter((p, i) => !i || p[0] !== sites[i - 1]![0] || p[1] !== sites[i - 1]![1]);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Builds one monotone chain, dropping intermediate collinear points. */
|
|
26
|
+
function buildChain(sites: readonly Site[]): Site[] {
|
|
27
|
+
const chain: Site[] = [];
|
|
28
|
+
for (const point of sites) {
|
|
29
|
+
while (chain.length > 1) {
|
|
30
|
+
const a = chain[chain.length - 2]!;
|
|
31
|
+
const b = chain[chain.length - 1]!;
|
|
32
|
+
// robust-predicates returns a negative value for a Cartesian counterclockwise turn.
|
|
33
|
+
if (orient2d(...a, ...b, ...point) < 0) break;
|
|
34
|
+
chain.pop();
|
|
35
|
+
}
|
|
36
|
+
chain.push(point);
|
|
37
|
+
}
|
|
38
|
+
return chain;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Wraps sorted distinct sites, retaining degenerate point and line results. */
|
|
42
|
+
function hullFromSites(sites: Site[]): WellKnownGeometry {
|
|
43
|
+
if (!sites.length) return {type: 'GeometryCollection', geometries: []};
|
|
44
|
+
if (sites.length === 1) return {type: 'Point', coordinates: sites[0]!};
|
|
45
|
+
const lower = buildChain(sites);
|
|
46
|
+
const upper = buildChain([...sites].reverse());
|
|
47
|
+
const ring = [...lower.slice(0, -1), ...upper.slice(0, -1)];
|
|
48
|
+
return ring.length === 2
|
|
49
|
+
? {type: 'LineString', coordinates: ring}
|
|
50
|
+
: {type: 'Polygon', coordinates: [[...ring, ring[0]!]]};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Computes the smallest convex geometry enclosing the input vertices. */
|
|
54
|
+
export function convexHull(geometry: WellKnownGeometry): WellKnownGeometry {
|
|
55
|
+
return hullFromSites(collectSites(geometry));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Directed triangle edge and its adjacent triangle, if present. */
|
|
59
|
+
type Edge = {
|
|
60
|
+
/** Start site index in counterclockwise ring order. */
|
|
61
|
+
start: number;
|
|
62
|
+
/** End site index in counterclockwise ring order. */
|
|
63
|
+
end: number;
|
|
64
|
+
/** Triangle on the other side of the edge. */
|
|
65
|
+
neighbor?: Triangle;
|
|
66
|
+
/** Euclidean edge length in coordinate units. */
|
|
67
|
+
length: number;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/** A Delaunay triangle with mutable membership in the retained mesh. */
|
|
71
|
+
type Triangle = {
|
|
72
|
+
/** Three directed edges in counterclockwise order. */
|
|
73
|
+
edges: Edge[];
|
|
74
|
+
/** Whether the triangle has been eroded. */
|
|
75
|
+
removed: boolean;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/** Candidate for removing a boundary triangle across its current exterior edge. */
|
|
79
|
+
type Candidate = {
|
|
80
|
+
/** Triangle considered for erosion. */
|
|
81
|
+
triangle: Triangle;
|
|
82
|
+
/** Exterior edge replaced by the other two sides. */
|
|
83
|
+
edge: Edge;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/** Pushes a candidate into a longest-edge-first binary heap. */
|
|
87
|
+
function pushCandidate(heap: Candidate[], candidate: Candidate): void {
|
|
88
|
+
let index = heap.length;
|
|
89
|
+
heap.push(candidate);
|
|
90
|
+
while (index > 0) {
|
|
91
|
+
const parent = (index - 1) >>> 1;
|
|
92
|
+
if (heap[parent]!.edge.length >= candidate.edge.length) break;
|
|
93
|
+
heap[index] = heap[parent]!;
|
|
94
|
+
index = parent;
|
|
95
|
+
}
|
|
96
|
+
heap[index] = candidate;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Removes the longest-edge candidate and restores heap order. */
|
|
100
|
+
function popCandidate(heap: Candidate[]): Candidate {
|
|
101
|
+
const first = heap[0]!;
|
|
102
|
+
const last = heap.pop()!;
|
|
103
|
+
if (!heap.length) return first;
|
|
104
|
+
let index = 0;
|
|
105
|
+
while (index * 2 + 1 < heap.length) {
|
|
106
|
+
const left = index * 2 + 1;
|
|
107
|
+
const right = left + 1;
|
|
108
|
+
const child =
|
|
109
|
+
right < heap.length && heap[right]!.edge.length > heap[left]!.edge.length ? right : left;
|
|
110
|
+
if (heap[child]!.edge.length <= last.edge.length) break;
|
|
111
|
+
heap[index] = heap[child]!;
|
|
112
|
+
index = child;
|
|
113
|
+
}
|
|
114
|
+
heap[index] = last;
|
|
115
|
+
return first;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Connects adjacent triangles and records the Delaunay edge range. */
|
|
119
|
+
function triangulateSites(sites: Site[]) {
|
|
120
|
+
const triangles: Triangle[] = [];
|
|
121
|
+
const edgeOwners = new Map<string, {edge: Edge; triangle: Triangle}>();
|
|
122
|
+
let minimum = Infinity;
|
|
123
|
+
let maximum = 0;
|
|
124
|
+
for (const cell of triangulate(sites, [])) {
|
|
125
|
+
const [a, b, c] = cell;
|
|
126
|
+
const order = orient2d(...sites[a]!, ...sites[b]!, ...sites[c]!) < 0 ? [a, b, c] : [a, c, b];
|
|
127
|
+
const triangle: Triangle = {edges: [], removed: false};
|
|
128
|
+
for (let i = 0; i < 3; i++) {
|
|
129
|
+
const start = order[i]!;
|
|
130
|
+
const end = order[(i + 1) % 3]!;
|
|
131
|
+
const p = sites[start]!;
|
|
132
|
+
const q = sites[end]!;
|
|
133
|
+
const length = Math.hypot(p[0] - q[0], p[1] - q[1]);
|
|
134
|
+
const edge: Edge = {start, end, length};
|
|
135
|
+
const key = start < end ? start + ':' + end : end + ':' + start;
|
|
136
|
+
const owner = edgeOwners.get(key);
|
|
137
|
+
if (owner) {
|
|
138
|
+
owner.edge.neighbor = triangle;
|
|
139
|
+
edge.neighbor = owner.triangle;
|
|
140
|
+
} else {
|
|
141
|
+
edgeOwners.set(key, {edge, triangle});
|
|
142
|
+
minimum = Math.min(minimum, length);
|
|
143
|
+
maximum = Math.max(maximum, length);
|
|
144
|
+
}
|
|
145
|
+
triangle.edges.push(edge);
|
|
146
|
+
}
|
|
147
|
+
triangles.push(triangle);
|
|
148
|
+
}
|
|
149
|
+
return {triangles, minimum, maximum};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** Returns the edges with no retained triangle on the other side. */
|
|
153
|
+
function exteriorEdges(triangle: Triangle): Edge[] {
|
|
154
|
+
return triangle.edges.filter(edge => !edge.neighbor || edge.neighbor.removed);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Erodes the exterior without removing a site or introducing a ring pinch. */
|
|
158
|
+
export function concaveHull(geometry: WellKnownGeometry, ratio: number): WellKnownGeometry {
|
|
159
|
+
if (!(ratio >= 0 && ratio <= 1)) throw new Error('ST_ConcaveHull ratio must be between 0 and 1');
|
|
160
|
+
const sites = collectSites(geometry);
|
|
161
|
+
const convex = hullFromSites(sites);
|
|
162
|
+
if (ratio === 1 || convex.type !== 'Polygon') return convex;
|
|
163
|
+
const {triangles, minimum, maximum} = triangulateSites(sites);
|
|
164
|
+
const limit = (1 - ratio) * minimum + ratio * maximum;
|
|
165
|
+
const boundary = new Map<number, number>();
|
|
166
|
+
const heap: Candidate[] = [];
|
|
167
|
+
for (const triangle of triangles) {
|
|
168
|
+
for (const edge of exteriorEdges(triangle)) {
|
|
169
|
+
boundary.set(edge.start, edge.end);
|
|
170
|
+
if (edge.length > limit) pushCandidate(heap, {triangle, edge});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
while (heap.length) {
|
|
174
|
+
const {triangle, edge} = popCandidate(heap);
|
|
175
|
+
if (triangle.removed || exteriorEdges(triangle).length !== 1) continue;
|
|
176
|
+
const first = triangle.edges.find(side => side.start === edge.end)!;
|
|
177
|
+
const tip = first.end;
|
|
178
|
+
if (boundary.has(tip)) continue;
|
|
179
|
+
// Replace start → end with start → tip → end. An interior tip keeps one simple ring.
|
|
180
|
+
triangle.removed = true;
|
|
181
|
+
boundary.set(edge.start, tip);
|
|
182
|
+
boundary.set(tip, edge.end);
|
|
183
|
+
for (const side of triangle.edges) {
|
|
184
|
+
const neighbor = side.neighbor;
|
|
185
|
+
if (!neighbor || neighbor.removed || side.length <= limit) continue;
|
|
186
|
+
const reverse = neighbor.edges.find(candidate => candidate.neighbor === triangle)!;
|
|
187
|
+
pushCandidate(heap, {triangle: neighbor, edge: reverse});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
const start = boundary.keys().next().value;
|
|
191
|
+
if (start === undefined) return convex;
|
|
192
|
+
const coordinates = [sites[start]!];
|
|
193
|
+
let site = boundary.get(start)!;
|
|
194
|
+
while (site !== start && coordinates.length < boundary.size) {
|
|
195
|
+
coordinates.push(sites[site]!);
|
|
196
|
+
site = boundary.get(site)!;
|
|
197
|
+
}
|
|
198
|
+
if (site !== start || coordinates.length !== boundary.size) {
|
|
199
|
+
throw new Error('ST_ConcaveHull could not construct a single outer ring');
|
|
200
|
+
}
|
|
201
|
+
coordinates.push(sites[start]!);
|
|
202
|
+
return {type: 'Polygon', coordinates: [coordinates]};
|
|
203
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
GeoArrowBuilder,
|
|
7
|
+
makeArrowVectorFromGeoArrowColumn,
|
|
8
|
+
type GeoArrowDenseUnion,
|
|
9
|
+
type GeoArrowList,
|
|
10
|
+
type WellKnownGeometry
|
|
11
|
+
} from '@math.gl/core/arrow';
|
|
12
|
+
import type {NativeSpatialResult} from './spatial-sql';
|
|
13
|
+
|
|
14
|
+
/** Concrete result children and their canonical XY selectors. */
|
|
15
|
+
const concrete = [
|
|
16
|
+
{type: 'Point', encoding: 'geoarrow.point', id: 1},
|
|
17
|
+
{type: 'LineString', encoding: 'geoarrow.linestring', id: 2},
|
|
18
|
+
{type: 'MultiPoint', encoding: 'geoarrow.multipoint', id: 4},
|
|
19
|
+
{type: 'MultiLineString', encoding: 'geoarrow.multilinestring', id: 5}
|
|
20
|
+
] as const;
|
|
21
|
+
|
|
22
|
+
/** Fixed native mixed-geometry layout shared by every batch. */
|
|
23
|
+
export function lineIntersectionResult(): NativeSpatialResult {
|
|
24
|
+
/** Builds the result without serializing coordinates or dispatching on per-batch schema. */
|
|
25
|
+
const build: NativeSpatialResult['build'] = rows =>
|
|
26
|
+
makeArrowVectorFromGeoArrowColumn({
|
|
27
|
+
encoding: 'geoarrow.geometry',
|
|
28
|
+
dimension: 'xy',
|
|
29
|
+
coordinateLayout: 'interleaved',
|
|
30
|
+
chunks: [union(rows, true)]
|
|
31
|
+
});
|
|
32
|
+
return {encoding: 'geoarrow.geometry', type: build([]).type, build};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Builds concrete children and, at the top level, one collection child. */
|
|
36
|
+
function union(
|
|
37
|
+
rows: readonly (WellKnownGeometry | null)[],
|
|
38
|
+
collections: boolean
|
|
39
|
+
): GeoArrowDenseUnion {
|
|
40
|
+
const groups = concrete.map((): (WellKnownGeometry | null)[] => []);
|
|
41
|
+
const mixed: WellKnownGeometry[] = [];
|
|
42
|
+
const typeIds = new Int8Array(rows.length);
|
|
43
|
+
const valueOffsets = new Int32Array(rows.length);
|
|
44
|
+
for (let row = 0; row < rows.length; row++) {
|
|
45
|
+
const geometry = rows[row] ?? null;
|
|
46
|
+
if (collections && geometry?.type === 'GeometryCollection') {
|
|
47
|
+
typeIds[row] = 7;
|
|
48
|
+
valueOffsets[row] = mixed.length;
|
|
49
|
+
mixed.push(geometry);
|
|
50
|
+
} else {
|
|
51
|
+
const index = geometry ? concrete.findIndex(child => child.type === geometry.type) : 0;
|
|
52
|
+
const group = groups[index];
|
|
53
|
+
if (!group) throw new Error('Unexpected line intersection result geometry');
|
|
54
|
+
typeIds[row] = concrete[index]!.id;
|
|
55
|
+
valueOffsets[row] = group.length;
|
|
56
|
+
group.push(geometry);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const children: GeoArrowDenseUnion['children'][number][] = concrete.map(
|
|
60
|
+
({type, encoding, id}, index) => ({
|
|
61
|
+
name: type,
|
|
62
|
+
encoding,
|
|
63
|
+
typeId: id,
|
|
64
|
+
dimension: 'xy',
|
|
65
|
+
coordinateLayout: 'interleaved',
|
|
66
|
+
data: GeoArrowBuilder.build(groups[index]!, {encoding, dimension: 'xy'}).chunks[0]!
|
|
67
|
+
})
|
|
68
|
+
);
|
|
69
|
+
if (collections) {
|
|
70
|
+
children.push({
|
|
71
|
+
name: 'GeometryCollection',
|
|
72
|
+
encoding: 'geoarrow.geometrycollection',
|
|
73
|
+
typeId: 7,
|
|
74
|
+
dimension: 'xy',
|
|
75
|
+
coordinateLayout: 'interleaved',
|
|
76
|
+
data: collection(mixed)
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return {kind: 'dense-union', length: rows.length, typeIds, valueOffsets, children};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Packs collection children in a fixed inner union. */
|
|
83
|
+
function collection(rows: readonly WellKnownGeometry[]): GeoArrowList {
|
|
84
|
+
const members: WellKnownGeometry[] = [];
|
|
85
|
+
const offsets = new Int32Array(rows.length + 1);
|
|
86
|
+
for (let row = 0; row < rows.length; row++) {
|
|
87
|
+
const geometry = rows[row]!;
|
|
88
|
+
if (geometry.type === 'GeometryCollection')
|
|
89
|
+
for (const child of geometry.geometries) members.push(child);
|
|
90
|
+
offsets[row + 1] = members.length;
|
|
91
|
+
}
|
|
92
|
+
return {kind: 'list', length: rows.length, offsets, child: union(members, false)};
|
|
93
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {WellKnownGeometry} from '@math.gl/core/arrow';
|
|
6
|
+
import {locatePointInPolygon, pointOnSegment, segmentsMeet} from './spatial-planar-intersects';
|
|
7
|
+
import {endpointContacts, parameter} from './spatial-touches';
|
|
8
|
+
|
|
9
|
+
/** One XY position. */
|
|
10
|
+
type Position = readonly number[];
|
|
11
|
+
/** One line or polygon ring. */
|
|
12
|
+
type Path = readonly Position[];
|
|
13
|
+
/** Endpoints of one segment. */
|
|
14
|
+
type Edge = readonly [Position, Position];
|
|
15
|
+
|
|
16
|
+
/** Tests equality of XY positions. */
|
|
17
|
+
function same(a: Position, b: Position): boolean {
|
|
18
|
+
return a[0] === b[0] && a[1] === b[1];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Interpolates between endpoints without perturbing original vertices. */
|
|
22
|
+
function interpolate(a: Position, b: Position, t: number): Position {
|
|
23
|
+
if (t === 0) return a;
|
|
24
|
+
if (t === 1) return b;
|
|
25
|
+
return [(1 - t) * a[0]! + t * b[0]!, (1 - t) * a[1]! + t * b[1]!];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Returns the position of a proper segment crossing along the first segment. */
|
|
29
|
+
function crossingParameter([a, b]: Edge, [c, d]: Edge): number {
|
|
30
|
+
const dx = b[0]! - a[0]!;
|
|
31
|
+
const dy = b[1]! - a[1]!;
|
|
32
|
+
const ux = d[0]! - c[0]!;
|
|
33
|
+
const uy = d[1]! - c[1]!;
|
|
34
|
+
const x = c[0]! - a[0]!;
|
|
35
|
+
const y = c[1]! - a[1]!;
|
|
36
|
+
const scale = Math.max(
|
|
37
|
+
Math.abs(dx),
|
|
38
|
+
Math.abs(dy),
|
|
39
|
+
Math.abs(ux),
|
|
40
|
+
Math.abs(uy),
|
|
41
|
+
Math.abs(x),
|
|
42
|
+
Math.abs(y)
|
|
43
|
+
);
|
|
44
|
+
return (
|
|
45
|
+
((x / scale) * (uy / scale) - (y / scale) * (ux / scale)) /
|
|
46
|
+
((dx / scale) * (uy / scale) - (dy / scale) * (ux / scale))
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Clips linear components to polygon interiors and boundaries, retaining isolated contacts. */
|
|
51
|
+
export function intersectLinePolygon(
|
|
52
|
+
line: WellKnownGeometry,
|
|
53
|
+
area: WellKnownGeometry
|
|
54
|
+
): WellKnownGeometry {
|
|
55
|
+
if (line.type !== 'LineString' && line.type !== 'MultiLineString')
|
|
56
|
+
throw new Error('Line–polygon intersection requires a linear geometry');
|
|
57
|
+
if (area.type !== 'Polygon' && area.type !== 'MultiPolygon')
|
|
58
|
+
throw new Error('Line–polygon intersection requires a polygonal geometry');
|
|
59
|
+
const polygons = area.type === 'Polygon' ? [area.coordinates] : area.coordinates;
|
|
60
|
+
const boundaries: Edge[] = [];
|
|
61
|
+
for (const ring of polygons.flat()) {
|
|
62
|
+
for (let i = 0; i < ring.length; i++) {
|
|
63
|
+
const a = ring[(i + ring.length - 1) % ring.length]!;
|
|
64
|
+
const b = ring[i]!;
|
|
65
|
+
if (!same(a, b)) boundaries.push([a, b]);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Tests membership in the closed areal geometry. */
|
|
70
|
+
const covered = (point: Position): boolean =>
|
|
71
|
+
polygons.some(rings => locatePointInPolygon(point, rings) >= 0);
|
|
72
|
+
const lines: Position[][] = [];
|
|
73
|
+
const contacts = new Map<string, Position>();
|
|
74
|
+
/** Deduplicates point contacts across adjacent segments and components. */
|
|
75
|
+
const addPoint = (point: Position) => contacts.set(`${point[0]}/${point[1]}`, point);
|
|
76
|
+
for (const path of line.type === 'LineString' ? [line.coordinates] : line.coordinates) {
|
|
77
|
+
if (!path.length) continue;
|
|
78
|
+
let current: Position[] | undefined;
|
|
79
|
+
if (covered(path[0]!)) addPoint(path[0]!);
|
|
80
|
+
for (let index = 1; index < path.length; index++) {
|
|
81
|
+
const a = path[index - 1]!;
|
|
82
|
+
const b = path[index]!;
|
|
83
|
+
if (same(a, b)) continue;
|
|
84
|
+
const segment: Edge = [a, b];
|
|
85
|
+
const cuts = new Map<number, Position>([
|
|
86
|
+
[0, a],
|
|
87
|
+
[1, b]
|
|
88
|
+
]);
|
|
89
|
+
const overlap: [number, number][] = [];
|
|
90
|
+
for (const boundary of boundaries) {
|
|
91
|
+
if (!segmentsMeet(...segment, ...boundary)) continue;
|
|
92
|
+
const endpoints = endpointContacts(segment, boundary);
|
|
93
|
+
if (!endpoints.length) {
|
|
94
|
+
const t = crossingParameter(segment, boundary);
|
|
95
|
+
if (!(t >= 0 && t <= 1)) throw new Error('Unable to locate polygon boundary crossing');
|
|
96
|
+
const [x, y] = interpolate(a, b, t);
|
|
97
|
+
const [c, d] = boundary;
|
|
98
|
+
cuts.set(t, [c[0] === d[0] ? c[0]! : x!, c[1] === d[1] ? c[1]! : y!]);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
const parameters = endpoints.map(point => parameter(point, segment));
|
|
102
|
+
for (let contact = 0; contact < endpoints.length; contact++) {
|
|
103
|
+
cuts.set(parameters[contact]!, endpoints[contact]!);
|
|
104
|
+
addPoint(endpoints[contact]!);
|
|
105
|
+
}
|
|
106
|
+
if (parameters.length === 2)
|
|
107
|
+
overlap.push([Math.min(...parameters), Math.max(...parameters)]);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const entries = [...cuts].sort(([x], [y]) => x - y);
|
|
111
|
+
for (let i = 1; i < entries.length; i++) {
|
|
112
|
+
const [from, first] = entries[i - 1]!;
|
|
113
|
+
const [to, last] = entries[i]!;
|
|
114
|
+
if (
|
|
115
|
+
!overlap.some(([start, end]) => start <= from && to <= end) &&
|
|
116
|
+
!covered(interpolate(a, b, (from + to) / 2))
|
|
117
|
+
) {
|
|
118
|
+
current = undefined;
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
if (same(first, last)) continue;
|
|
122
|
+
if (current && same(current[current.length - 1]!, first)) current.push(last);
|
|
123
|
+
else {
|
|
124
|
+
current = [first, last];
|
|
125
|
+
lines.push(current);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const retainedEdges = [...lineEdges(lines)];
|
|
131
|
+
const points = [...contacts.values()].filter(
|
|
132
|
+
point => !retainedEdges.some(([a, b]) => pointOnSegment(point, a, b))
|
|
133
|
+
);
|
|
134
|
+
const parts: WellKnownGeometry[] = [];
|
|
135
|
+
if (lines.length === 1) parts.push({type: 'LineString', coordinates: lines[0]!});
|
|
136
|
+
else if (lines.length) parts.push({type: 'MultiLineString', coordinates: lines});
|
|
137
|
+
if (points.length === 1) parts.push({type: 'Point', coordinates: points[0]!});
|
|
138
|
+
else if (points.length) parts.push({type: 'MultiPoint', coordinates: points});
|
|
139
|
+
return parts.length === 1 ? parts[0]! : {type: 'GeometryCollection', geometries: parts};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** Iterates segments of already clipped linear components. */
|
|
143
|
+
function* lineEdges(paths: readonly Path[]): Generator<Edge> {
|
|
144
|
+
for (const path of paths) {
|
|
145
|
+
for (let i = 1; i < path.length; i++) yield [path[i - 1]!, path[i]!];
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -49,7 +49,7 @@ function inBounds(p: Position, a: Position, b: Position): boolean {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
/** Detects proper crossings, coincident intervals and endpoint contact. */
|
|
52
|
-
function segmentsMeet(a: Position, b: Position, c: Position, d: Position): boolean {
|
|
52
|
+
export function segmentsMeet(a: Position, b: Position, c: Position, d: Position): boolean {
|
|
53
53
|
const cSide = side(a, b, c),
|
|
54
54
|
dSide = side(a, b, d);
|
|
55
55
|
const aSide = side(c, d, a),
|
|
@@ -75,19 +75,15 @@ function anyEdge(
|
|
|
75
75
|
return false;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
/**
|
|
79
|
-
function
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
geometry.coordinates,
|
|
86
|
-
false,
|
|
87
|
-
(a, b) => inBounds(point, a, b) && !side(a, b, point)
|
|
88
|
-
);
|
|
78
|
+
/** Tests whether a point is on a segment, including either endpoint. */
|
|
79
|
+
export function pointOnSegment(point: Position, a: Position, b: Position): boolean {
|
|
80
|
+
return inBounds(point, a, b) && side(a, b, point) === 0;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Classifies a point as outside (-1), on the boundary (0), or inside (1). */
|
|
84
|
+
export function locatePointInPolygon(point: Position, rings: readonly Path[]): -1 | 0 | 1 {
|
|
89
85
|
let inside = false;
|
|
90
|
-
for (const ring of
|
|
86
|
+
for (const ring of rings) {
|
|
91
87
|
if (
|
|
92
88
|
anyEdge(ring, true, (a, b) => {
|
|
93
89
|
const orientation = side(a, b, point);
|
|
@@ -97,9 +93,19 @@ function meetsPoint(point: Position, geometry: Primitive): boolean {
|
|
|
97
93
|
return false;
|
|
98
94
|
})
|
|
99
95
|
)
|
|
100
|
-
return
|
|
96
|
+
return 0;
|
|
101
97
|
}
|
|
102
|
-
return inside;
|
|
98
|
+
return inside ? 1 : -1;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Tests a finite point against an atomic geometry, including boundaries. */
|
|
102
|
+
function meetsPoint(point: Position, geometry: Primitive): boolean {
|
|
103
|
+
if (!Number.isFinite(point[0]) || !Number.isFinite(point[1])) return false;
|
|
104
|
+
if (geometry.type === 'Point')
|
|
105
|
+
return point[0] === geometry.coordinates[0] && point[1] === geometry.coordinates[1];
|
|
106
|
+
if (geometry.type === 'LineString')
|
|
107
|
+
return anyEdge(geometry.coordinates, false, (a, b) => pointOnSegment(point, a, b));
|
|
108
|
+
return locatePointInPolygon(point, geometry.coordinates) >= 0;
|
|
103
109
|
}
|
|
104
110
|
|
|
105
111
|
/** Tests boundary intersection and full containment of individual components. */
|
package/src/spatial-planar.ts
CHANGED
|
@@ -4,6 +4,23 @@
|
|
|
4
4
|
|
|
5
5
|
import type {WellKnownGeometry} from '@math.gl/core/arrow';
|
|
6
6
|
|
|
7
|
+
/** Measures the distance to a finite segment, including its endpoints. */
|
|
8
|
+
export function distanceToPlanarSegment(
|
|
9
|
+
p: readonly number[],
|
|
10
|
+
a: readonly number[],
|
|
11
|
+
b: readonly number[]
|
|
12
|
+
): number {
|
|
13
|
+
const dx = b[0]! - a[0]!,
|
|
14
|
+
dy = b[1]! - a[1]!;
|
|
15
|
+
const length = Math.hypot(dx, dy);
|
|
16
|
+
const px = p[0]! - a[0]!,
|
|
17
|
+
py = p[1]! - a[1]!;
|
|
18
|
+
const t = length
|
|
19
|
+
? Math.max(0, Math.min(1, (px * (dx / length) + py * (dy / length)) / length))
|
|
20
|
+
: 0;
|
|
21
|
+
return Math.hypot(px - t * dx, py - t * dy);
|
|
22
|
+
}
|
|
23
|
+
|
|
7
24
|
/** A position in the input coordinate system. */
|
|
8
25
|
type Position = readonly number[];
|
|
9
26
|
/** The positions of an open or closed path. */
|
|
@@ -36,7 +53,7 @@ function isPresentPoint(position: Position): boolean {
|
|
|
36
53
|
}
|
|
37
54
|
|
|
38
55
|
/** Iterates position sequences in a supported geometry, retaining path boundaries. */
|
|
39
|
-
function visitPaths(geometry: WellKnownGeometry, visit: (path: Path) => void): void {
|
|
56
|
+
export function visitPaths(geometry: WellKnownGeometry, visit: (path: Path) => void): void {
|
|
40
57
|
switch (geometry.type) {
|
|
41
58
|
case 'Point':
|
|
42
59
|
if (isPresentPoint(geometry.coordinates)) visit([geometry.coordinates]);
|
|
@@ -107,6 +124,8 @@ export function planarArea(geometry: WellKnownGeometry): number {
|
|
|
107
124
|
|
|
108
125
|
/** Computes planar line length in coordinate units. */
|
|
109
126
|
export function planarLength(geometry: WellKnownGeometry): number {
|
|
127
|
+
if (geometry.type === 'GeometryCollection')
|
|
128
|
+
return geometry.geometries.reduce((sum, part) => sum + planarLength(part), 0);
|
|
110
129
|
if (geometry.type !== 'LineString' && geometry.type !== 'MultiLineString') return 0;
|
|
111
130
|
let length = 0;
|
|
112
131
|
visitPaths(geometry, path => {
|