WKTWriter.withDimension constructor

WKTWriter.withDimension(
  1. int outputDimension
)

Creates a writer that writes {@link Geometry}s with the given output dimension (2 to 4). The output follows the following rules:

  • If the specified output dimension is 3 and the z is measure flag is set to true, the Z value of coordinates will be written if it is present (i.e. if it is not Double.NaN)
  • If the specified output dimension is 3 and the z is measure flag is set to false, the Measure value of coordinates will be written if it is present (i.e. if it is not Double.NaN)
  • If the specified output dimension is 4, the Z value of coordinates will be written even if it is not present when the Measure value is present.The Measrue value of coordinates will be written if it is present (i.e. if it is not Double.NaN)

@param outputDimension the coordinate dimension to output (2 to 4)

Implementation

WKTWriter.withDimension(int outputDimension) {
  setTab(INDENT);
  this.outputDimension = outputDimension;

  if (outputDimension < 2 || outputDimension > 4)
    throw ArgumentError("Invalid output dimension (must be 2 to 4)");

  this.outputOrdinates = List.from([Ordinate.X, Ordinate.Y]);
  if (outputDimension > 2) {
    outputOrdinates.add(Ordinate.Z);
  }
  if (outputDimension > 3) {
    outputOrdinates.add(Ordinate.M);
  }
}