LineString constructor
LineString(
- PositionSeries chain, {
- Box? bounds,
A line string geometry with a chain
of positions and optional bounds
.
The chain
array must contain at least two positions (or be empty).
Examples:
// a line string from 2D positions
LineString(
[
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
].positions(Coords.xy),
);
// a line string from 3D positions
LineString(
[
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
].positions(Coords.xyz),
);
// a line string from measured 2D positions
LineString(
[
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
].positions(Coords.xym),
);
// a line string from measured 3D positions
LineString(
[
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
].positions(Coords.xyzm),
);
Implementation
LineString(PositionSeries chain, {super.bounds})
: _chain = chain,
assert(
chain.positionCount == 0 || chain.positionCount >= 2,
'Chain must contain at least two positions (or be empty)',
);