/// <summary> /// Parses a multilinestring text. /// </summary> /// <param name="tokens">The list of tokens.</param> /// <param name="is3D">bool value indicating whether multilinestring being parsed has z-coordinate.</param> /// <param name="isMeasured">bool value indicating whether multilinestring being parsed has m-value.</param> /// <returns>A multilinestring specified by tokens.</returns> /// <remarks><![CDATA[<multilinestring text> ::= <empty set> | <left paren><linestring text> {<comma> <linestring text>}* <right paren>]]></remarks> private static MultiLineString ParseMultiLineStringText(WktTokensBuffer tokens, bool is3D, bool isMeasured) { WktToken t = tokens.Peek(true); if (t.Type == TokenType.STRING && t.Value.ToUpperInvariant() == "EMPTY") { tokens.GetToken(true); return(new MultiLineString()); } WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); MultiLineString result = new MultiLineString(WktReader.ParseLineStrings(tokens, is3D, isMeasured)); WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); return(result); }
/// <summary> /// Parses a polygon text. /// </summary> /// <param name="tokens">The list of tokens.</param> /// <param name="is3D">bool value indicating whether polygon being parsed has z-coordinate.</param> /// <param name="isMeasured">bool value indicating whether polygon being parsed has m-value.</param> /// <returns>A polygon specified by tokens.</returns> /// <remarks><![CDATA[<empty set> | <left paren> <linestring text> {<comma> <linestring text>}* <right paren>]]></remarks> private static Polygon ParsePolygonText(WktTokensBuffer tokens, bool is3D, bool isMeasured) { WktToken t = tokens.Peek(true); if (t.Type == TokenType.STRING && t.Value.ToUpperInvariant() == "EMPTY") { tokens.GetToken(true); return(new Polygon()); } WktReader.Expect(TokenType.LEFT_PARENTHESIS, tokens); IEnumerable <LineString> linestrings = WktReader.ParseLineStrings(tokens, is3D, isMeasured); Polygon result = new Polygon(linestrings.First().Coordinates); foreach (var inner in linestrings.Skip(1)) { result.InteriorRings.Add(inner.Coordinates); } WktReader.Expect(TokenType.RIGHT_PARENTHESIS, tokens); return(result); }