Reference · The realistic Earth's pure parts
sharedEdgesfunction
The borders of a set of shapes as line segments on the unit sphere: each edge that two different shapes share, drawn once; an edge only one shape has (a coast) is left out.
An edge longer than maxStep degrees is cut into pieces along the great circle, so the line keeps to the ground.
Import it
import { sharedEdges } from "@johnmorrisdotca/chikyu-earth/realistic";
Definition
function sharedEdges(shapes: BorderShapes, maxStep?: number): Float32Array
Parameters
| Name | Type | Description |
|---|---|---|
shapes | BorderShapes | The shapes, in longitude and latitude. |
maxStep (optional) | number | The longest piece in degrees (1 when left out). |
Returns
Float32Array<ArrayBufferLike>
The segments' ends, x, y, z for each, two points to a segment: ready for a LineSegments geometry.
Examples
import { sharedEdges } from "@johnmorrisdotca/chikyu-earth/realistic";
const west = { geometry: { type: "Polygon", coordinates: [[[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]]] } };
const east = { geometry: { type: "Polygon", coordinates: [[[1, 0], [2, 0], [2, 1], [1, 1], [1, 0]]] } };
console.log(sharedEdges({ features: [west, east] }).length / 6);1What it prints (run when this page was built)