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.xis longitude in degrees, andyis latitude in degrees.options(Object, optional)size(Number) - the number of elements in each vertex. Size2will interpretpositionsas[x0, y0, x1, y1, ...]and size3will interpretpositionsas[x0, y0, z0, x1, y1, z1, ...]. Default2.startIndex(Number, optional) - the index inpositionsto start reading vertices. Default0.endIndex(Number, optional) - the index inpositionsto 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.