private static string GetNextWord(WktStreamTokenizer tokenizer) { TokenType type = tokenizer.NextToken(); string token = tokenizer.GetStringValue(); if (type == TokenType.Number) { throw new Exception("Expected a number but got " + token); } else if (type == TokenType.Word) { return(token.ToUpper()); } else if (token == "(") { return("("); } else if (token == ")") { return(")"); } else if (token == ",") { return(","); } throw new Exception("Not a valid symbol in WKT format."); }
private static string GetNextCloserOrComma(WktStreamTokenizer tokenizer) { tokenizer.NextToken(); string nextWord = tokenizer.GetStringValue(); if (nextWord == "," || nextWord == ")") { return(nextWord); } throw new Exception("Expected ')' or ',' but encountered '" + nextWord + "'"); }
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 + "'"); }
private static Geometry ReadGeometryTaggedText(WktStreamTokenizer tokenizer) { tokenizer.NextToken(); string type = tokenizer.GetStringValue().ToUpper(); 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(String.Format(Map.NumberFormatEnUs, "Geometrytype '{0}' is not supported.", type)); } return(geometry); }
private static double GetNextNumber(WktStreamTokenizer tokenizer) { tokenizer.NextToken(); return(tokenizer.GetNumericValue()); }