MultiLineString.build constructor

MultiLineString.build(
  1. Iterable<Iterable<double>> lineStrings, {
  2. Coords type = Coords.xy,
  3. Box? bounds,
})

Builds a multi line string from an array of lineStrings (each with 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.

Each line string or a chain of positions is represented by a Iterable<double> instance. They contain coordinate values 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 multi line string with two line strings both with three 2D positions
MultiLineString.build(
  [
    [10.0, 20.0, 12.5, 22.5, 15.0, 25.0],
    [12.5, 23.0, 11.5, 24.0, 12.5, 24.0],
  ],
  type: Coords.xy,
);

// a multi line string with two line strings both with three 3D positions
MultiLineString.build(
  [
    [10.0, 20.0, 30.0, 12.5, 22.5, 32.5, 15.0, 25.0, 35.0],
    [12.5, 23.0, 32.5, 11.5, 24.0, 31.5, 12.5, 24.0, 32.5],
  ],
  type: Coords.xyz,
);

Implementation

factory MultiLineString.build(
  Iterable<Iterable<double>> lineStrings, {
  Coords type = Coords.xy,
  Box? bounds,
}) =>
    MultiLineString(
      lineStrings
          .map(
            (chain) => PositionSeries.view(
              chain is List<double> ? chain : toFloatNNList(chain),
              type: type,
            ),
          )
          .toList(growable: false),
      bounds: bounds,
    );