cutPolylineByMercatorBounds
Splits a geospatial polyline at the 180th meridian.
import {cutPolylineByMercatorBounds} from '@math.gl/polygon';
cutPolylineByMercatorBounds([-10, -10, 10, 10, 30, -10], {size: 2, gridResolution: 10});
// returns [-10, -10, 0, 0, 10, 10, 20, 0, 30, -10]
Usage
cutPolylineByMercatorBounds(positions, [options]);
Arguments:
positions
(Array|TypedArray) - a flat array of the vertex positions that define the polyline.x
is longitude in degrees, andy
is latitude in degrees.options
(Object, optional)size
(Number) - the number of elements in each vertex. Size2
will interpretpositions
as[x0, y0, x1, y1, ...]
and size3
will interpretpositions
as[x0, y0, z0, x1, y1, z1, ...]
. Default2
.startIndex
(Number, optional) - the index inpositions
to start reading vertices. Default0
.endIndex
(Number, optional) - the index inpositions
to stop reading vertices. Defaultpositions.length
.normalize
(Boolean) - make sure the output longitudes are within[-180, 180]
. Defaulttrue
.
Returns:
An array of polylines. Each polyline is represented by a positions array that uses the same vertex size as the input.