getOrdinate method

double getOrdinate(
  1. int ordinateIndex
)
override

Gets the ordinate value for the given index.

The base implementation supports values for the index are {@link X}, {@link Y}, and {@link Z}.

@param ordinateIndex the ordinate index @return the value of the ordinate @throws IllegalArgumentException if the index is not valid

Implementation

double getOrdinate(int ordinateIndex) {
  switch (ordinateIndex) {
    case Coordinate.X:
      return x;
    case Coordinate.Y:
      return y;
    case Coordinate.Z:
      return getZ(); // sure to delegate to subclass rather than offer direct field access
    case Coordinate.M:
      return getM(); // sure to delegate to subclass rather than offer direct field access
  }
  throw new ArgumentError("Invalid ordinate index: $ordinateIndex");
}