Double.fromCoordinatesDimMeas constructor

Double.fromCoordinatesDimMeas(
  1. List<Coordinate>? coordinates,
  2. int dimension,
  3. int measures
)

Builds a new packed coordinate sequence out of a coordinate array

@param coordinates an array of {@link Coordinate}s @param dimension the total number of ordinates that make up a {@link Coordinate} in this sequence. @param measures the number of measure-ordinates each {@link Coordinate} in this sequence has.

Implementation

Double.fromCoordinatesDimMeas(
    List<Coordinate>? coordinates, int dimension, int measures)
    : super(dimension, measures) {
  if (coordinates == null) {
    coordinates = [];
  }

  coords = List.filled(coordinates.length * this.dimension, 0.0);
  for (int i = 0; i < coordinates.length; i++) {
    int offset = i * dimension;
    coords[offset] = coordinates[i].x;
    coords[offset + 1] = coordinates[i].y;
    if (dimension >= 3) {
      coords[offset + 2] = coordinates[i].getOrdinate(2);
    } // Z or M
    if (dimension >= 4) {
      coords[offset + 3] = coordinates[i].getOrdinate(3);
    } // M
  }
}