MultiLineString.from constructor

MultiLineString.from(
  1. Iterable<Iterable<Position>> lineStrings, {
  2. Box? bounds,
})

A multi line string from an iterable of lineStrings (each a chain as an iterable of positions).

An optional bounds can used set a minimum bounding box for a geometry.

Each line string or a chain of positions is represented by an Iterable<Position> instance. The coordinate type of all positions in all chains should be the same.

Examples:

// a multi line string with two line strings both with three 2D positions
MultiLineString.from([
  [
    [10.0, 20.0].xy,
    [12.5, 22.5].xy,
    [15.0, 25.0].xy,
  ],
  [
    [12.5, 23.0].xy,
    [11.5, 24.0].xy,
    [12.5, 24.0].xy,
  ],
]);

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

Implementation

factory MultiLineString.from(
  Iterable<Iterable<Position>> lineStrings, {
  Box? bounds,
}) =>
    MultiLineString(
      lineStrings.map(PositionSeries.from).toList(growable: false),
      bounds: bounds,
    );