public WktToken Dequeue(WktTokenType type) { var t = Dequeue(); if (t.Type != type) { throw new SerializationException("Invalid WKT string."); } return(t); }
public bool NextTokenIs(WktTokenType type) { if (Count == 0) { return(false); } var token = Peek(); return(token.Type == type); }
private static WktTokenType GetTokenType(char ch, WktTokenType? lastType = null) { if (char.IsWhiteSpace(ch)) return WktTokenType.Whitespace; if (ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z') { if ((ch == 'e' || ch == 'E') && lastType.HasValue && lastType.Value == WktTokenType.Number) { return WktTokenType.Number; } return WktTokenType.String; } if (ch == '-' || ch == '.' || ch >= '0' && ch <= '9') return WktTokenType.Number; if (ch == ',') return WktTokenType.Comma; if (ch == '(') return WktTokenType.LeftParenthesis; if (ch == ')') return WktTokenType.RightParenthesis; throw new SerializationException("Invalid WKT string."); }
public WktToken(WktTokenType type) : this() { Type = type; Value = default(string); }
public WktToken(WktTokenType type, string value) : this() { Type = type; Value = value; }