parsePosition<R extends Position> static method

R parsePosition<R extends Position>(
  1. String text, {
  2. required CreatePosition<R> to,
  3. Pattern? delimiter = ',',
  4. Coords? type,
})

Parses a position of R from text.

Coordinate values in text are separated by delimiter.

A position instance is created using the factory function to.

Supported coordinate value combinations for text are: (x, y), (x, y, z), (x, y, m) and (x, y, z, m).

Use an optional type to explicitely set the coordinate type. If not provided and text has 3 items, then xyz coordinates are assumed.

Throws FormatException if coordinates are invalid.

Implementation

static R parsePosition<R extends Position>(
  String text, {
  required CreatePosition<R> to,
  Pattern? delimiter = ',',
  Coords? type,
}) {
  final coords = parseNumValues(text, delimiter: delimiter);
  return buildPosition(coords, to: to, type: type);
}