readPolygonText method

Polygon readPolygonText(
  1. WKTTokenizer tokenizer,
  2. List<Ordinate> ordinateFlags
)

Creates a Polygon using the next token in the stream.

@param tokenizer tokenizer over a stream of text in Well-known Text format. The next tokens must form a <Polygon Text>. @return a Polygon specified by the next token in the stream @throws ParseException if the coordinates used to create the Polygon shell and holes do not form closed linestrings, or if an unexpected token was encountered. @throws IOException if an I/O error occurs

Implementation

Polygon readPolygonText(
    WKTTokenizer tokenizer, List<Ordinate> ordinateFlags) {
  String nextToken = getNextEmptyOrOpener(tokenizer);
  if (nextToken == EMPTY) {
    return geometryFactory.createPolygonEmpty();
  }
  List<LinearRing> holes = [];
  LinearRing shell = readLinearRingText(tokenizer, ordinateFlags);
  nextToken = getNextCloserOrComma(tokenizer);
  while (nextToken == COMMA) {
    LinearRing hole = readLinearRingText(tokenizer, ordinateFlags);
    holes.add(hole);
    nextToken = getNextCloserOrComma(tokenizer);
  }
  // List<LinearRing> array = [];//..length = (holes.length);
  return geometryFactory.createPolygon(shell, holes);
}