/// <summary> /// Returns the next "EMPTY" or "(" in the stream as uppercase text. /// </summary> /// <param name="tokenizer">Tokenizer over a stream of text in Well-known Text /// format. The next token must be "EMPTY" or "(".</param> /// <returns>the next "EMPTY" or "(" in the stream as uppercase /// text.</returns> /// <remarks> /// ParseException is thrown if the next token is not "EMPTY" or "(". /// </remarks> private static string GetNextEmptyOrOpener(WktStreamTokenizer tokenizer) { tokenizer.NextToken(); string nextWord = tokenizer.GetStringValue(); if (nextWord == "EMPTY" || nextWord == "(") { return(nextWord); } throw new Exception("Expected 'EMPTY' or '(' but encountered '" + nextWord + "'"); }
/// <summary> /// Creates a Geometry using the next token in the stream. /// </summary> /// <param name="tokenizer">Tokenizer over a stream of text in Well-known Text /// format. The next tokens must form a <Geometry Tagged Text>.</param> /// <returns>Returns a Geometry specified by the next token in the stream.</returns> /// <remarks> /// Exception is thrown if the coordinates used to create a Polygon /// shell and holes do not form closed linestrings, or if an unexpected /// token is encountered. /// </remarks> private static RGeos.Geometries.Geometry ReadGeometryTaggedText(WktStreamTokenizer tokenizer) { tokenizer.NextToken(); string type = tokenizer.GetStringValue().ToUpper(); RGeos.Geometries.Geometry geometry = null; switch (type) { case "POINT": geometry = ReadPointText(tokenizer); break; case "LINESTRING": geometry = ReadLineStringText(tokenizer); break; case "MULTIPOINT": geometry = ReadMultiPointText(tokenizer); break; case "MULTILINESTRING": geometry = ReadMultiLineStringText(tokenizer); break; case "POLYGON": geometry = ReadPolygonText(tokenizer); break; case "MULTIPOLYGON": geometry = ReadMultiPolygonText(tokenizer); break; case "GEOMETRYCOLLECTION": geometry = ReadGeometryCollectionText(tokenizer); break; default: throw new Exception(); //throw new Exception(String.Format(Map.NumberFormatEnUs, "Geometrytype '{0}' is not supported.", // type)); } return(geometry); }