LineString.build constructor
Builds a line string geometry from a chain
of positions.
Use type
to specify the type of coordinates, by default Coords.xy
is
expected.
An optional bounds
can used set a minimum bounding box for a geometry.
The chain
array must contain at least two positions (or be empty). It
contains coordinate values of chain positions as a flat structure. For
example for Coords.xyz
the first three coordinate values are x, y and z
of the first position, the next three coordinate values are x, y and z of
the second position, and so on.
Examples:
// a line string from 2D positions
LineString.build(
[
10.0, 20.0, // (x, y) for position 0
12.5, 22.5, // (x, y) for position 1
15.0, 25.0, // (x, y) for position 2
],
type: Coords.xy,
);
// a line string from 3D positions
LineString.build(
[
10.0, 20.0, 30.0, // (x, y, z) for position 0
12.5, 22.5, 32.5, // (x, y, z) for position 1
15.0, 25.0, 35.0, // (x, y, z) for position 2
],
type: Coords.xyz,
);
// a line string from measured 2D positions
LineString.build(
[
10.0, 20.0, 40.0, // (x, y, m) for position 0
12.5, 22.5, 42.5, // (x, y, m) for position 1
15.0, 25.0, 45.0, // (x, y, m) for position 2
],
type: Coords.xym,
);
// a line string from measured 3D positions
LineString.build(
[
10.0, 20.0, 30.0, 40.0, // (x, y, z, m) for position 0
12.5, 22.5, 32.5, 42.5, // (x, y, z, m) for position 1
15.0, 25.0, 35.0, 45.0, // (x, y, z, m) for position 2
],
type: Coords.xyzm,
);
Implementation
factory LineString.build(
Iterable<double> chain, {
Coords type = Coords.xy,
Box? bounds,
}) =>
LineString(
PositionSeries.view(
chain is List<double> ? chain : toFloatNNList(chain),
type: type,
),
bounds: bounds,
);